Commits

Anonymous committed e7c6f89

crisp.el-1.33

Comments (0)

Files changed (2)

 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.03
-AUTHOR_VERSION = 1.31
+VERSION = 1.04
+AUTHOR_VERSION = 1.33
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = crisp
 PKG_TYPE = regular
 ;; @(#) crisp.el -- CRiSP/Brief Emacs emulator
 
-;; Author: Gary D. Foster <Gary.Foster@corp.sun.com>
+;; Author: Gary D. Foster <gfoster@suzieq.ml.org>
 ;; Created: 01 Mar 1996
-;; Version: 1.31
+;; Version: 1.33
 ;; 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.
+;;
+;;	Revision 1.32  1998/04/14 16:53:49  gfoster
+;;	change email address _again_
+;;
 ;;	Revision 1.31  1997/12/23 07:38:09  gfoster
 ;;	More cleanup on the bug report function I robbed from Barry.
 ;;
 (defvar crisp-load-hook nil
   "Hooks to run after loading the CRiSP emulator package.")
 
-(defconst crisp-version "1.31"
+(defconst crisp-version "1.33"
   "The version of the CRiSP emulator.")
 
-(defconst crisp-mode-help-address "gfoster@ragesoft.com"
+(defconst crisp-mode-help-address "gfoster@suzieq.ml.org"
   "The email address of the CRiSP mode author/maintainer.")
 
 ;; Silence the byte-compiler.
 (defvar last-last-command)
 
+;; The cut and paste routines are different between XEmacs and FSF 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))
+
+(if (and (not (fboundp 'kill-primary-selection))
+	 (fboundp 'clipboard-kill-region))
+    (defalias 'kill-primary-selection 'clipboard-kill-region))
+
+(if (and (not (fboundp 'yank-clipboard-selection))
+	 (fboundp 'clipboard-yank))
+    (defalias 'yank-clipboard-selection 'clipboard-yank))
+
+;; '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
+;; 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
+;; differently and could really confuse people.  Caveat emptor.
+
+(if (fboundp 'transient-mark-mode)
+    (transient-mark-mode t))
+
+(defun region-active ()
+  "Compatibility function to test for an active region."
+  (if (boundp 'zmacs-region-active-p)
+      zmacs-region-active-p
+    mark-active))
+
 ;; and now the keymap defines
 
 (define-key crisp-mode-map [(f1)]           'other-window)
 (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)
-(define-key crisp-mode-map [(insert)]       'x-yank-clipboard-selection)
-(define-key crisp-mode-map [(f16)]          'x-copy-primary-selection) ; copy on Sun5 kbd
-(define-key crisp-mode-map [(f20)]          'x-kill-primary-selection) ; cut on Sun5 kbd 
-(define-key crisp-mode-map [(f18)]          'x-yank-clipboard-selection) ; paste on Sun5 kbd
+;; 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 [(control f)]    'fill-paragraph-or-region)
 (define-key crisp-mode-map [(meta d)]       (lambda ()
 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 zmacs-region-active-p
-      (x-kill-primary-selection)
+  (if (region-active)
+      (call-interactively 'kill-primary-selection)
     (crisp-mark-line arg)
-    (x-kill-primary-selection)))
+    (call-interactively 'kill-primary-selection)))
 
 (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 zmacs-region-active-p
-	(x-copy-primary-selection)
+    (if (region-active)
+	(call-interactively 'copy-primary-selection)
       (crisp-mark-line arg)
-      (x-copy-primary-selection)))
+      (call-interactively 'copy-primary-selection))
+    ;; clear the region after the operation is complete
+    ;; XEmacs does this automagically, GNU emacs doesn't.
+    (if (boundp 'mark-active)
+	(setq mark-active nil)))
 
 (defun crisp-home ()
   "\"Home\" the point, the way CRiSP would do it.