Commits

Anonymous committed 3bdd813

Rewrote a large portion to increase the abstraction. This should
ultimately result in greater portability between Emacsen. RMS was a
major contributor towards this end.

Comments (0)

Files changed (1)

 
 ;; Author: Gary D. Foster <gfoster@suzieq.ml.org>
 ;; Created: 01 Mar 1996
-;; Version: 1.33
+;; Version: 1.34
 ;; Keywords: emulations brief crisp
 ;; X-Modified-by:
-;;	crisp.el,v
-;;	Revision 1.33  1998/06/19 00:40:55  gfoster
-;;	Abstract the marking and selection interfaces so that we can be
-;;	compatible with both GNU Emacs and XEmacs... and try and make the
-;;	behavior as close as possible under both environments so that there
-;;	are no surprises.
+;;      crisp.el,v
+;;      Revision 1.34  1998/08/11 21:18:53  gfoster
+;;      Rewrote large portions to further abstract the functionality
+;;      and enhance the portability.  Significant contributions from
+;;      RMS.
 ;;
-;;	Revision 1.32  1998/04/14 16:53:49  gfoster
-;;	change email address _again_
+;;      No new functionality this time.
 ;;
-;;	Revision 1.31  1997/12/23 07:38:09  gfoster
-;;	More cleanup on the bug report function I robbed from Barry.
+;;      Revision 1.33  1998/06/19 00:40:55  gfoster
+;;      Abstract the marking and selection interfaces so that we can be
+;;      compatible with both GNU Emacs and XEmacs... and try and make the
+;;      behavior as close as possible under both environments so that there
+;;      are no surprises.
 ;;
-;;	Revision 1.30  1997/12/23 07:17:52  gfoster
-;;	removed S-right and S-left bindings.  Don't know where my head was on
-;;	these.
+;;      Revision 1.32  1998/04/14 16:53:49  gfoster
+;;      change email address _again_
 ;;
-;;	Revision 1.29  1997/12/03 07:24:53  gfoster
-;;	removed cc-vars dependency left over from swiping the bug-report defun
+;;      Revision 1.31  1997/12/23 07:38:09  gfoster
+;;      More cleanup on the bug report function I robbed from Barry.
 ;;
-;;	Revision 1.28  1997/11/26 16:18:43  gfoster
-;;	Removed reference to CC mode in doc string for
-;;	`crisp-submit-bug-report'
-;;	no need to save point on crisp-copy-line
+;;      Revision 1.30  1997/12/23 07:17:52  gfoster
+;;      removed S-right and S-left bindings.  Don't know where my head was on
+;;      these.
 ;;
-;;	Revision 1.27  1997/11/19 07:03:16  gfoster
-;;	changed bug email address
+;;      Revision 1.29  1997/12/03 07:24:53  gfoster
+;;      removed cc-vars dependency left over from swiping the bug-report defun
 ;;
-;;	Revision 1.26  1997/11/18 05:41:02  gfoster
-;;	Added several new keybindings:
-;;		C-home	top of window
-;;		C-end	bottom of window
-;;		M-home	beginning of line
-;;		M-end	end-of-line
-;;		C-F	format region
-;;		M-l	mark line
-;;		M-m	set mark
-;;	Added crisp-version function
+;;      Revision 1.28  1997/11/26 16:18:43  gfoster
+;;      Removed reference to CC mode in doc string for
+;;      `crisp-submit-bug-report'
+;;      no need to save point on crisp-copy-line
 ;;
-;;	Revision 1.25  1997/11/18 04:19:09  gfoster
-;;	Shortened the version numbering, removed the release-version tracking
+;;      Revision 1.27  1997/11/19 07:03:16  gfoster
+;;      changed bug email address
 ;;
-;;	Revision 1.24  1997/11/18 04:15:54  gfoster
-;;	Added `crisp-submit-bug-report' (shamelessly cribbed from Barry's
-;;	cc-mode.  Thanks Barry!)
+;;      Revision 1.26  1997/11/18 05:41:02  gfoster
+;;      Added several new keybindings:
+;;              C-home  top of window
+;;              C-end   bottom of window
+;;              M-home  beginning of line
+;;              M-end   end-of-line
+;;              C-F     format region
+;;              M-l     mark line
+;;              M-m     set mark
+;;      Added crisp-version function
 ;;
-;;	Bound the above to C-c b
+;;      Revision 1.25  1997/11/18 04:19:09  gfoster
+;;      Shortened the version numbering, removed the release-version tracking
 ;;
-;;	Changed the behavior of `crisp-(kill|copy)-line' so (kill|copy)ing
-;;	works on the region from point to eol instead of the entire line, when
-;;	a region is not highlighted.
+;;      Revision 1.24  1997/11/18 04:15:54  gfoster
+;;      Added `crisp-submit-bug-report' (shamelessly cribbed from Barry's
+;;      cc-mode.  Thanks Barry!)
 ;;
-;;	Revision 1.23  1997/11/11 19:47:02  gfoster
-;;	Merged changes suggested by Hrvoje Niksic
-;;	   make crisp-mode-map a sparse keymap parented from current-global-map
-;;	   don't copy the keymap in (crisp-mode-original-keymap)
-;;	   declare last-last-command to shut up the byte-compiler
-;;	   make (crisp-mode) honor ARG
+;;      Bound the above to C-c b
 ;;
-;;	Revision 1.22  1997/11/11 19:37:44  gfoster
-;;	kp-add/minus now copy/kill the current line if there is no highlighted
-;;	region.  These also honor the universal prefix argument conventions.
+;;      Changed the behavior of `crisp-(kill|copy)-line' so (kill|copy)ing
+;;      works on the region from point to eol instead of the entire line, when
+;;      a region is not highlighted.
 ;;
-;;	Revision 1.21  1997/10/16 18:52:54  gfoster
-;;	Fixed bogus XEmacs/Lucid string-match checking
-;;	made modeline entry mouse2-able
+;;      Revision 1.23  1997/11/11 19:47:02  gfoster
+;;      Merged changes suggested by Hrvoje Niksic
+;;         make crisp-mode-map a sparse keymap parented from current-global-map
+;;         don't copy the keymap in (crisp-mode-original-keymap)
+;;         declare last-last-command to shut up the byte-compiler
+;;         make (crisp-mode) honor ARG
 ;;
-;;	Revision 1.20  1997/08/22 18:49:11  gfoster
-;;	Added next-buffer/previous-buffer keybindings (bound to M-n/M-p)
-;;	Added crisp-unbury-buffer function
-;;	Standardized headers for Steve
+;;      Revision 1.22  1997/11/11 19:37:44  gfoster
+;;      kp-add/minus now copy/kill the current line if there is no highlighted
+;;      region.  These also honor the universal prefix argument conventions.
+;;
+;;      Revision 1.21  1997/10/16 18:52:54  gfoster
+;;      Fixed bogus XEmacs/Lucid string-match checking
+;;      made modeline entry mouse2-able
+;;
+;;      Revision 1.20  1997/08/22 18:49:11  gfoster
+;;      Added next-buffer/previous-buffer keybindings (bound to M-n/M-p)
+;;      Added crisp-unbury-buffer function
+;;      Standardized headers for Steve
 ;;
 
 ;; This file is part of XEmacs.
 
 ;; Code:
 
-(require 'cl)
-
 ;; local variables
 
 (defgroup crisp nil
-  "CRiSP emulator customizable settings."
+  "Emulator for CRiSP and Brief key bindings."
+  :prefix "crisp-"
   :group 'emulations)
 
 (defvar crisp-mode-map (let ((map (make-sparse-keymap)))
   "The original keymap before CRiSP emulation mode remaps anything.
 This keymap is restored when CRiSP emulation mode is disabled.")
 
-(defvar crisp-mode-enabled nil
+(defcustom crisp-mode-enabled nil
   "Track status of CRiSP emulation mode.
 A value of nil means CRiSP mode is not enabled.  A value of t
-indicates CRiSP mode is enabled.")
+indicates CRiSP mode is enabled."
+  :type 'boolean
+  :group 'crisp)
 
 (defcustom crisp-override-meta-x t
   "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator.
-Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs and
+Normally the CRiSP emulator rebinds M-x to `save-buffers-exit-emacs', and
 provides the usual M-x functionality on the F10 key.  If this variable
 is non-nil, M-x will exit Emacs."
   :type 'boolean
   :group 'crisp)
 
-(defvar crisp-load-scroll-lock nil
+(defcustom crisp-load-scroll-lock nil
   "Controls loading of the Scroll Lock in the CRiSP emulator.
-Its Default behavior is to load and enable the Scroll Lock minor mode
+Its default behavior is to load and enable the Scroll Lock minor mode
 package when enabling the CRiSP emulator.
 
 If this variable is nil when you start the CRiSP emulator, it
-does not load the scroll-lock package.")
+does not load the scroll-lock package."
+  :type 'boolean
+  :group 'crisp)
 
-(defvar crisp-load-hook nil
-  "Hooks to run after loading the CRiSP emulator package.")
+(defcustom crisp-load-hook nil
+  "Hooks to run after loading the CRiSP emulator package."
+  :type 'hook
+  :group 'crisp)
 
 (defconst crisp-version "1.33"
   "The version of the CRiSP emulator.")
   "The email address of the CRiSP mode author/maintainer.")
 
 ;; Silence the byte-compiler.
-(defvar last-last-command)
+(defvar crisp-last-last-command nil
+  "The previous value of `last-command'.")
 
-;; The cut and paste routines are different between XEmacs and FSF Emacs
+;; The cut and paste routines are different between XEmacs and Emacs
 ;; so we need to set up aliases for the functions.
 
-(if (and (not (fboundp 'copy-primary-selection))
-	 (fboundp 'clipboard-kill-ring-save))
-    (defalias 'copy-primary-selection 'clipboard-kill-ring-save))
+(defalias 'crisp-set-clipboard
+  (if (fboundp 'clipboard-kill-ring-save)
+      'clipboard-kill-ring-save
+    'copy-primary-selection))
 
-(if (and (not (fboundp 'kill-primary-selection))
-	 (fboundp 'clipboard-kill-region))
-    (defalias 'kill-primary-selection 'clipboard-kill-region))
+(defalias 'crisp-kill-region
+  (if (fboundp 'clipboard-kill-region)
+      'clipboard-kill-region
+    'kill-primary-selection))
 
-(if (and (not (fboundp 'yank-clipboard-selection))
-	 (fboundp 'clipboard-yank))
-    (defalias 'yank-clipboard-selection 'clipboard-yank))
+(defalias 'crisp-yank-clipboard
+  (if (fboundp 'clipboard-yank)
+      'clipboard-yank
+    'yank-clipboard-selection))
 
-;; 'mark-something is very useful for marking arbitrary areas
-;; so I stole it from simple.el in XEmacs.
-
-(if (not (fboundp 'mark-something))
-    (defun mark-something (mark-fn movement-fn arg)
-  "Compatibility function swiped from XEmacs."
-  (let (newmark (pushp t))
-    (save-excursion
-      (if (and (eq last-command mark-fn) (mark))
-	  ;; Extend the previous state in the same direction:
-	  (progn
-	    (if (< (mark) (point)) (setq arg (- arg)))
-	    (goto-char (mark))
-	    (setq pushp nil)))
-      (funcall movement-fn arg)
-      (setq newmark (point)))
-    (if pushp
-	(push-mark newmark nil t)
-      ;; Do not mess with the mark stack, but merely adjust the previous state:
-      (set-mark newmark)
-      (activate-region)))))
-
-;; force transient-mark-mode in FSF Emacs, so that the marking routines
+;; force transient-mark-mode in Emacs, so that the marking routines
 ;; work as expected.  If the user turns off transient mark mode,
 ;; most things will still work fine except the crisp-(copy|kill)
 ;; functions won't work quite as nicely when regions are marked
 (if (fboundp 'transient-mark-mode)
     (transient-mark-mode t))
 
-(defun region-active ()
+(defun crisp-region-active ()
   "Compatibility function to test for an active region."
   (if (boundp 'zmacs-region-active-p)
       zmacs-region-active-p
 (define-key crisp-mode-map [(SunF37)]       'kill-buffer)
 (define-key crisp-mode-map [(kp-add)]       'crisp-copy-line)
 (define-key crisp-mode-map [(kp-subtract)]  'crisp-kill-line)
-;; just to cover all the bases (GNU emacs, for instance)
+;; just to cover all the bases (GNU Emacs, for instance)
 (define-key crisp-mode-map [(f24)]          'crisp-kill-line)
-(define-key crisp-mode-map [(insert)]       'yank-clipboard-selection)
-(define-key crisp-mode-map [(f16)]          'copy-primary-selection) ; copy on Sun5 kbd
-(define-key crisp-mode-map [(f20)]          'kill-primary-selection) ; cut on Sun5 kbd 
-(define-key crisp-mode-map [(f18)]          'yank-clipboard-selection) ; paste on Sun5 kbd
+(define-key crisp-mode-map [(insert)]       'crisp-yank-clipboard)
+(define-key crisp-mode-map [(f16)]          'crisp-set-clipboard) ; copy on Sun5 kbd
+(define-key crisp-mode-map [(f20)]          'crisp-kill-region) ; cut on Sun5 kbd 
+(define-key crisp-mode-map [(f18)]          'crisp-yank-clipboard) ; paste on Sun5 kbd
 
 (define-key crisp-mode-map [(control f)]    'fill-paragraph-or-region)
 (define-key crisp-mode-map [(meta d)]       (lambda ()
       (message foo))))
 
 (defun crisp-mark-line (arg)
-  "Put mark at the end of line.  Arg works as in `end-of-line'."
+  "Set mark at the end of the line.  Arg works as in `end-of-line'."
   (interactive "p")
-  (mark-something 'crisp-mark-line 'end-of-line arg))
+  (let (newmark)
+    (save-excursion
+      (end-of-line arg)
+      (setq newmark (point)))
+    (push-mark newmark nil t)))
 
 (defun crisp-kill-line (arg)
   "Mark and kill line(s).
 Marks from point to end of the current line (honoring prefix arguments),
 copies the region to the kill ring and clipboard, and then deletes it."
   (interactive "*p")
-  (if (region-active)
-      (call-interactively 'kill-primary-selection)
+  (if (crisp-region-active)
+      (call-interactively 'crisp-kill-region)
     (crisp-mark-line arg)
-    (call-interactively 'kill-primary-selection)))
+    (call-interactively 'crisp-kill-region)))
 
 (defun crisp-copy-line (arg)
   "Mark and copy line(s).
 copies the region to the kill ring and clipboard, and then deactivates
 the region."
   (interactive "*p")
-    (if (region-active)
-	(call-interactively 'copy-primary-selection)
+    (if (crisp-region-active)
+	(call-interactively 'crisp-set-clipboard)
       (crisp-mark-line arg)
-      (call-interactively 'copy-primary-selection))
+      (call-interactively 'crisp-set-clipboard))
     ;; clear the region after the operation is complete
-    ;; XEmacs does this automagically, GNU emacs doesn't.
+    ;; XEmacs does this automagically, Emacs doesn't.
     (if (boundp 'mark-active)
 	(setq mark-active nil)))
 
 consecutive use moves point to the beginning of the buffer."
   (interactive nil)
   (cond
-    ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home))
+    ((and (eq last-command 'crisp-home)
+	  (eq crisp-last-last-command 'crisp-home))
      (goto-char (point-min)))
     ((eq last-command 'crisp-home)
      (move-to-window-line 0))
     (t
      (beginning-of-line)))
-  (setq last-last-command last-command))
+  (setq crisp-last-last-command last-command))
 
 (defun crisp-end ()
   "\"End\" the point, the way CRiSP would do it.
 consecutive use moves point to the end of the buffer."
   (interactive nil)
   (cond
-    ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end))
+    ((and (eq last-command 'crisp-end)
+	  (eq crisp-last-last-command 'crisp-end))
      (goto-char (point-max)))
     ((eq last-command 'crisp-end)
      (move-to-window-line -1)
      (end-of-line))
     (t
      (end-of-line)))
-  (setq last-last-command last-command))
+  (setq crisp-last-last-command last-command))
 
 (defun crisp-unbury-buffer ()
   "Go back one buffer"
 (provide 'crisp)
 
 ;;; crisp.el ends here
+