Mercurial > emacs
comparison lisp/emulation/crisp.el @ 22827:053f8d41f34c
Don't require cl.
(crisp-override-meta-x): Doc fix.
(crisp-last-last-command): Doc fix.
(mark-something): Function deleted.
(crisp-mark-line): Avoid using mark-something.
(crisp-region-active): Renamed from region-active.
(crisp-set-clipboard): Renamed from copy-primary-selection.
(crisp-kill-region): Renamed from kill-primary-selection.
(crisp-yank-clipboard): Renamed from yank-clipboard-selection.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 25 Jul 1998 20:58:03 +0000 |
parents | dbd9ecc9dbac |
children | d1d9c92ca734 |
comparison
equal
deleted
inserted
replaced
22826:e81f7de474b3 | 22827:053f8d41f34c |
---|---|
19 | 19 |
20 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02111-1307, USA. |
24 | |
25 ;; CRiSP is a registered trademark of Foxtrot Systems Ltd. | |
26 | 24 |
27 ;;; Commentary: | 25 ;;; Commentary: |
28 | 26 |
29 ;; Keybindings and minor functions to duplicate the functionality and | 27 ;; Keybindings and minor functions to duplicate the functionality and |
30 ;; finger-feel of the CRiSP/Brief editor. This package is designed to | 28 ;; finger-feel of the CRiSP/Brief editor. This package is designed to |
56 | 54 |
57 ;; All these overrides should go *before* the (require 'crisp) statement. | 55 ;; All these overrides should go *before* the (require 'crisp) statement. |
58 | 56 |
59 ;; Code: | 57 ;; Code: |
60 | 58 |
61 (require 'cl) | |
62 | |
63 ;; local variables | 59 ;; local variables |
64 | 60 |
65 (defgroup crisp nil | 61 (defgroup crisp nil |
66 "Emulator for CRiSP and Brief key bindings." | 62 "Emulator for CRiSP and Brief key bindings." |
67 :prefix "crisp-" | 63 :prefix "crisp-" |
90 :type 'boolean | 86 :type 'boolean |
91 :group 'crisp) | 87 :group 'crisp) |
92 | 88 |
93 (defcustom crisp-override-meta-x t | 89 (defcustom crisp-override-meta-x t |
94 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. | 90 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. |
95 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs and | 91 Normally the CRiSP emulator rebinds M-x to `save-buffers-exit-emacs', and |
96 provides the usual M-x functionality on the F10 key. If this variable | 92 provides the usual M-x functionality on the F10 key. If this variable |
97 is non-nil, M-x will exit Emacs." | 93 is non-nil, M-x will exit Emacs." |
98 :type 'boolean | 94 :type 'boolean |
99 :group 'crisp) | 95 :group 'crisp) |
100 | 96 |
119 (defconst crisp-mode-help-address "gfoster@suzieq.ml.org" | 115 (defconst crisp-mode-help-address "gfoster@suzieq.ml.org" |
120 "The email address of the CRiSP mode author/maintainer.") | 116 "The email address of the CRiSP mode author/maintainer.") |
121 | 117 |
122 ;; Silence the byte-compiler. | 118 ;; Silence the byte-compiler. |
123 (defvar crisp-last-last-command nil | 119 (defvar crisp-last-last-command nil |
124 "The previous value of last-command.") | 120 "The previous value of `last-command'.") |
125 | 121 |
126 ;; The cut and paste routines are different between XEmacs and Emacs | 122 ;; The cut and paste routines are different between XEmacs and Emacs |
127 ;; so we need to set up aliases for the functions. | 123 ;; so we need to set up aliases for the functions. |
128 | 124 |
129 (if (and (not (fboundp 'copy-primary-selection)) | 125 (defalias 'crisp-set-clipboard |
130 (fboundp 'clipboard-kill-ring-save)) | 126 (if (fboundp 'clipboard-kill-ring-save) |
131 (defalias 'copy-primary-selection 'clipboard-kill-ring-save)) | 127 'clipboard-kill-ring-save |
132 | 128 'copy-primary-selection)) |
133 (if (and (not (fboundp 'kill-primary-selection)) | 129 |
134 (fboundp 'clipboard-kill-region)) | 130 (defalias 'crisp-kill-region |
135 (defalias 'kill-primary-selection 'clipboard-kill-region)) | 131 (if (fboundp 'clipboard-kill-region) |
136 | 132 'clipboard-kill-region |
137 (if (and (not (fboundp 'yank-clipboard-selection)) | 133 'kill-primary-selection)) |
138 (fboundp 'clipboard-yank)) | 134 |
139 (defalias 'yank-clipboard-selection 'clipboard-yank)) | 135 (defalias 'crisp-yank-clipboard |
140 | 136 (if (fboundp 'clipboard-yank) |
141 ;; 'mark-something is very useful for marking arbitrary areas | 137 'clipboard-yank |
142 ;; so I stole it from simple.el in XEmacs. | 138 'yank-clipboard-selection)) |
143 | |
144 (if (not (fboundp 'mark-something)) | |
145 (defun mark-something (mark-fn movement-fn arg) | |
146 "Compatibility function swiped from XEmacs." | |
147 (let (newmark (pushp t)) | |
148 (save-excursion | |
149 (if (and (eq last-command mark-fn) (mark)) | |
150 ;; Extend the previous state in the same direction: | |
151 (progn | |
152 (if (< (mark) (point)) (setq arg (- arg))) | |
153 (goto-char (mark)) | |
154 (setq pushp nil))) | |
155 (funcall movement-fn arg) | |
156 (setq newmark (point))) | |
157 (if pushp | |
158 (push-mark newmark nil t) | |
159 ;; Do not mess with the mark stack, but merely adjust the previous state: | |
160 (set-mark newmark) | |
161 (activate-region))))) | |
162 | 139 |
163 ;; force transient-mark-mode in Emacs, so that the marking routines | 140 ;; force transient-mark-mode in Emacs, so that the marking routines |
164 ;; work as expected. If the user turns off transient mark mode, | 141 ;; work as expected. If the user turns off transient mark mode, |
165 ;; most things will still work fine except the crisp-(copy|kill) | 142 ;; most things will still work fine except the crisp-(copy|kill) |
166 ;; functions won't work quite as nicely when regions are marked | 143 ;; functions won't work quite as nicely when regions are marked |
167 ;; differently and could really confuse people. Caveat emptor. | 144 ;; differently and could really confuse people. Caveat emptor. |
168 | 145 |
169 (if (fboundp 'transient-mark-mode) | 146 (if (fboundp 'transient-mark-mode) |
170 (transient-mark-mode t)) | 147 (transient-mark-mode t)) |
171 | 148 |
172 (defun region-active () | 149 (defun crisp-region-active () |
173 "Compatibility function to test for an active region." | 150 "Compatibility function to test for an active region." |
174 (if (boundp 'zmacs-region-active-p) | 151 (if (boundp 'zmacs-region-active-p) |
175 zmacs-region-active-p | 152 zmacs-region-active-p |
176 mark-active)) | 153 mark-active)) |
177 | 154 |
210 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) | 187 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) |
211 (define-key crisp-mode-map [(kp-add)] 'crisp-copy-line) | 188 (define-key crisp-mode-map [(kp-add)] 'crisp-copy-line) |
212 (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) | 189 (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) |
213 ;; just to cover all the bases (GNU Emacs, for instance) | 190 ;; just to cover all the bases (GNU Emacs, for instance) |
214 (define-key crisp-mode-map [(f24)] 'crisp-kill-line) | 191 (define-key crisp-mode-map [(f24)] 'crisp-kill-line) |
215 (define-key crisp-mode-map [(insert)] 'yank-clipboard-selection) | 192 (define-key crisp-mode-map [(insert)] 'crisp-yank-clipboard) |
216 (define-key crisp-mode-map [(f16)] 'copy-primary-selection) ; copy on Sun5 kbd | 193 (define-key crisp-mode-map [(f16)] 'crisp-set-clipboard) ; copy on Sun5 kbd |
217 (define-key crisp-mode-map [(f20)] 'kill-primary-selection) ; cut on Sun5 kbd | 194 (define-key crisp-mode-map [(f20)] 'crisp-kill-region) ; cut on Sun5 kbd |
218 (define-key crisp-mode-map [(f18)] 'yank-clipboard-selection) ; paste on Sun5 kbd | 195 (define-key crisp-mode-map [(f18)] 'crisp-yank-clipboard) ; paste on Sun5 kbd |
219 | 196 |
220 (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) | 197 (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) |
221 (define-key crisp-mode-map [(meta d)] (lambda () | 198 (define-key crisp-mode-map [(meta d)] (lambda () |
222 (interactive) | 199 (interactive) |
223 (beginning-of-line) (kill-line))) | 200 (beginning-of-line) (kill-line))) |
293 (message foo)))) | 270 (message foo)))) |
294 | 271 |
295 (defun crisp-mark-line (arg) | 272 (defun crisp-mark-line (arg) |
296 "Put mark at the end of line. Arg works as in `end-of-line'." | 273 "Put mark at the end of line. Arg works as in `end-of-line'." |
297 (interactive "p") | 274 (interactive "p") |
298 (mark-something 'crisp-mark-line 'end-of-line arg)) | 275 (save-excursion |
276 (if (and (eq last-command 'crisp-mark-line) (mark)) | |
277 ;; Extend the previous state in the same direction: | |
278 (progn | |
279 (if (< (mark) (point)) (setq arg (- arg))) | |
280 (goto-char (mark)) | |
281 (end-of-line arg) | |
282 ;; Do not mess with the mark stack, but merely adjust the previous state: | |
283 (set-mark (point))) | |
284 (end-of-line arg) | |
285 (push-mark (point) nil t)))) | |
299 | 286 |
300 (defun crisp-kill-line (arg) | 287 (defun crisp-kill-line (arg) |
301 "Mark and kill line(s). | 288 "Mark and kill line(s). |
302 Marks from point to end of the current line (honoring prefix arguments), | 289 Marks from point to end of the current line (honoring prefix arguments), |
303 copies the region to the kill ring and clipboard, and then deletes it." | 290 copies the region to the kill ring and clipboard, and then deletes it." |
304 (interactive "*p") | 291 (interactive "*p") |
305 (if (region-active) | 292 (if (crisp-region-active) |
306 (call-interactively 'kill-primary-selection) | 293 (call-interactively 'crisp-kill-region) |
307 (crisp-mark-line arg) | 294 (crisp-mark-line arg) |
308 (call-interactively 'kill-primary-selection))) | 295 (call-interactively 'crisp-kill-region))) |
309 | 296 |
310 (defun crisp-copy-line (arg) | 297 (defun crisp-copy-line (arg) |
311 "Mark and copy line(s). | 298 "Mark and copy line(s). |
312 Marks from point to end of the current line (honoring prefix arguments), | 299 Marks from point to end of the current line (honoring prefix arguments), |
313 copies the region to the kill ring and clipboard, and then deactivates | 300 copies the region to the kill ring and clipboard, and then deactivates |
314 the region." | 301 the region." |
315 (interactive "*p") | 302 (interactive "*p") |
316 (if (region-active) | 303 (if (crisp-region-active) |
317 (call-interactively 'copy-primary-selection) | 304 (call-interactively 'crisp-set-clipboard) |
318 (crisp-mark-line arg) | 305 (crisp-mark-line arg) |
319 (call-interactively 'copy-primary-selection)) | 306 (call-interactively 'crisp-set-clipboard)) |
320 ;; clear the region after the operation is complete | 307 ;; clear the region after the operation is complete |
321 ;; XEmacs does this automagically, Emacs doesn't. | 308 ;; XEmacs does this automagically, Emacs doesn't. |
322 (if (boundp 'mark-active) | 309 (if (boundp 'mark-active) |
323 (setq mark-active nil))) | 310 (setq mark-active nil))) |
324 | 311 |