Mercurial > emacs
comparison lisp/emulation/crisp.el @ 22758:dbd9ecc9dbac
Added next-buffer/previous-buffer keybindings (bound to M-n/M-p).
(crisp-unbury-buffer): New function.
Fixed bogus XEmacs/Lucid string-match checking.
Made modeline entry mouse2-able.
(crisp-mode-map): Make this a sparse keymap parented from
current-global-map.
(crisp-mode-original-keymap): Don't copy the keymap.
(crisp-last-last-command): Renamed from last-last-command. defvar it.
(crisp-mode): Honor ARG.
(crisp-kill-line, crisp-copy-line): When a region isn't highlighted,
use the region from point to eol. Honor prefix argument.
(crisp-submit-bug-report): New command, taken from cc-mode.
Shortened the version numbering, removed the release-version tracking
(crisp-version): New function.
New keybindings `C-home', `C-end', `M-home', `M-end', `C-f', `M-l',
`M-m'.
(crisp-copy-line): No need to save point.
Removed S-right and S-left bindings.
Abstract the marking and selection interfaces so that we can be
compatible with both Emacs and XEmacs. And try and make the
behavior as close as possible under both environments so that there
are no surprises.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 14 Jul 1998 22:17:35 +0000 |
parents | 54413501e4a9 |
children | 053f8d41f34c |
comparison
equal
deleted
inserted
replaced
22757:c4e492a7cb07 | 22758:dbd9ecc9dbac |
---|---|
1 ;;; crisp.el --- Emulator for CRiSP and Brief key bindings | 1 ;; crisp.el --- CRiSP/Brief Emacs emulator |
2 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997, 1998 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com> | 5 ;; Author: Gary D. Foster <gfoster@suzieq.ml.org> |
6 ;; Keywords: emulations | 6 ;; Keywords: emulations brief crisp |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
9 | 9 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
11 ;; it under the terms of the GNU General Public License as published by | 11 ;; it under the terms of the GNU General Public License as published by |
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 | 24 |
25 ;; CRiSP is a registered trademark of Foxtrot Systems Ltd. | |
26 | |
25 ;;; Commentary: | 27 ;;; Commentary: |
26 | 28 |
27 ;; This file provides keybindings and minor functions to duplicate the | 29 ;; Keybindings and minor functions to duplicate the functionality and |
28 ;; functionality and finger-feel of the CRiSP/Brief editor. This | 30 ;; finger-feel of the CRiSP/Brief editor. This package is designed to |
29 ;; package is designed to facilitate transitioning from Brief to Emacs | 31 ;; facilitate transitioning from Brief to (XE|E)macs with a minimum |
30 ;; with a minimum amount of hassles. | 32 ;; amount of hassles. |
31 | 33 |
32 ;; Enable this package by putting the following in your .emacs | 34 ;; Enable this package by putting (require 'crisp) in your .emacs and |
33 ;; (require 'crisp) | 35 ;; use M-x crisp-mode to toggle it on or off. |
34 ;; and use M-x crisp-mode to toggle it on or off. | 36 |
35 | 37 ;; This package will automatically load the scroll-all.el package if |
36 ;; This package will automatically default to loading the scroll-all.el | 38 ;; you put (setq crisp-load-scroll-all t) in your .emacs before |
37 ;; package unless you put (setq crisp-load-scroll-lock nil) in your | 39 ;; loading this package. If this feature is enabled, it will bind |
38 ;; .emacs. If this feature is enabled, it will bind Meta-F1 to the | 40 ;; meta-f1 to the scroll-all mode toggle. The scroll-all package |
39 ;; scroll-all mode toggle. | 41 ;; duplicates the scroll-alling feature in CRiSP. |
40 | 42 |
41 ;; Also, the default keybindings for this mode override the Meta-x key to | 43 ;; Also, the default keybindings for brief/CRiSP override the M-x |
42 ;; make it exit the editor. If you don't like this change, you can | 44 ;; key to exit the editor. If you don't like this functionality, you |
43 ;; prevent this key from being rebound with | 45 ;; can prevent this behavior (or redefine it dynamically) by setting |
44 ;; (setq crisp-override-meta-x nil) in your .emacs. | 46 ;; the value of `crisp-override-meta-x' either in your .emacs or |
47 ;; interactively. The default setting is nil, which means that M-x will | |
48 ;; by default run `execute-extended-command' instead of the command | |
49 ;; `save-buffers-kill-emacs'. | |
45 | 50 |
46 ;; Finally, if you want to change the string displayed in the modeline | 51 ;; Finally, if you want to change the string displayed in the modeline |
47 ;; when this mode is in effect, override the definition of | 52 ;; when this mode is in effect, override the definition of |
48 ;; `crisp-mode-modeline-string' in your .emacs. The default value is | 53 ;; `crisp-mode-modeline-string' in your .emacs. The default value is |
49 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things | 54 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things |
50 ;; being displayed there. | 55 ;; being displayed there. |
51 | 56 |
52 ;; All these overrides should go *before* the (require 'crisp) statement. | 57 ;; All these overrides should go *before* the (require 'crisp) statement. |
53 | 58 |
59 ;; Code: | |
60 | |
61 (require 'cl) | |
62 | |
63 ;; local variables | |
64 | |
54 (defgroup crisp nil | 65 (defgroup crisp nil |
55 "Emulator for CRiSP and Brief key bindings." | 66 "Emulator for CRiSP and Brief key bindings." |
56 :prefix "crisp-" | 67 :prefix "crisp-" |
57 :group 'emulations) | 68 :group 'emulations) |
58 | 69 |
59 ;; local variables | 70 (defvar crisp-mode-map (let ((map (make-sparse-keymap))) |
60 | 71 (set-keymap-parent map (current-global-map)) |
61 (defvar crisp-mode-map (copy-keymap (current-global-map)) | 72 map) |
62 "Local keymap for CRiSP emulation mode. | 73 "Local keymap for CRiSP emulation mode. |
63 All the emulation bindings are done here instead of globally.") | 74 All the bindings are done here instead of globally to try and be |
75 nice to the world.") | |
64 | 76 |
65 (defcustom crisp-mode-modeline-string " *CRiSP*" | 77 (defcustom crisp-mode-modeline-string " *CRiSP*" |
66 "String to display in the modeline when CRiSP emulation mode is enabled." | 78 "*String to display in the modeline when CRiSP emulation mode is enabled." |
67 :type 'string | 79 :type 'string |
68 :group 'crisp) | 80 :group 'crisp) |
69 | 81 |
70 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map)) | 82 (defvar crisp-mode-original-keymap (current-global-map) |
71 "The original keymap before CRiSP emulation mode remaps anything. | 83 "The original keymap before CRiSP emulation mode remaps anything. |
72 This keymap is restored when CRiSP emulation mode is disabled.") | 84 This keymap is restored when CRiSP emulation mode is disabled.") |
73 | 85 |
74 (defcustom crisp-mode-enabled nil | 86 (defcustom crisp-mode-enabled nil |
75 "Track status of CRiSP emulation mode. | 87 "Track status of CRiSP emulation mode. |
77 indicates CRiSP mode is enabled." | 89 indicates CRiSP mode is enabled." |
78 :type 'boolean | 90 :type 'boolean |
79 :group 'crisp) | 91 :group 'crisp) |
80 | 92 |
81 (defcustom crisp-override-meta-x t | 93 (defcustom crisp-override-meta-x t |
82 "Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. | 94 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. |
83 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs | 95 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs and |
84 and provides the usual M-x functionality on the F10 key. | 96 provides the usual M-x functionality on the F10 key. If this variable |
85 | 97 is non-nil, M-x will exit Emacs." |
86 If this variable is nil when you start the CRiSP emulator, it | |
87 does not alter the binding of M-x." | |
88 :type 'boolean | 98 :type 'boolean |
89 :group 'crisp) | 99 :group 'crisp) |
90 | 100 |
91 (defcustom crisp-load-scroll-all t | 101 (defcustom crisp-load-scroll-all nil |
92 "Controls loading of the Scroll All mode in the CRiSP emulator. | 102 "Controls loading of the Scroll Lock in the CRiSP emulator. |
93 Its Default behavior is to load and enable the Scroll All minor mode | 103 Its default behavior is to load and enable the Scroll Lock minor mode |
94 package when enabling the CRiSP emulator. | 104 package when enabling the CRiSP emulator. |
95 | 105 |
96 If this variable is nil when you start the CRiSP emulator, it | 106 If this variable is nil when you start the CRiSP emulator, it |
97 does not load Scroll All." | 107 does not load the scroll-all package." |
98 :type 'boolean | 108 :type 'boolean |
99 :group 'crisp) | 109 :group 'crisp) |
100 | 110 |
101 (defcustom crisp-load-hook nil | 111 (defcustom crisp-load-hook nil |
102 "Hooks to run after loadint the CRiSP emulator package." | 112 "Hooks to run after loading the CRiSP emulator package." |
103 :type 'hook | 113 :type 'hook |
104 :group 'crisp) | 114 :group 'crisp) |
105 | 115 |
106 (defvar crisp-version "crisp.el release 1.1/$Revision: 1.6 $" | 116 (defconst crisp-version "1.33" |
107 "The release number and RCS version for the CRiSP emulator.") | 117 "The version of the CRiSP emulator.") |
108 | 118 |
119 (defconst crisp-mode-help-address "gfoster@suzieq.ml.org" | |
120 "The email address of the CRiSP mode author/maintainer.") | |
121 | |
122 ;; Silence the byte-compiler. | |
109 (defvar crisp-last-last-command nil | 123 (defvar crisp-last-last-command nil |
110 "The command *before* the last command.") | 124 "The previous value of last-command.") |
111 | 125 |
112 (if (string-match "XEmacs\\Lucid" emacs-version) | 126 ;; The cut and paste routines are different between XEmacs and Emacs |
113 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string) | 127 ;; so we need to set up aliases for the functions. |
114 (or (assq 'crisp-mode-enabled minor-mode-alist) | 128 |
115 (setq minor-mode-alist | 129 (if (and (not (fboundp 'copy-primary-selection)) |
116 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) | 130 (fboundp 'clipboard-kill-ring-save)) |
131 (defalias 'copy-primary-selection 'clipboard-kill-ring-save)) | |
132 | |
133 (if (and (not (fboundp 'kill-primary-selection)) | |
134 (fboundp 'clipboard-kill-region)) | |
135 (defalias 'kill-primary-selection 'clipboard-kill-region)) | |
136 | |
137 (if (and (not (fboundp 'yank-clipboard-selection)) | |
138 (fboundp 'clipboard-yank)) | |
139 (defalias 'yank-clipboard-selection 'clipboard-yank)) | |
140 | |
141 ;; 'mark-something is very useful for marking arbitrary areas | |
142 ;; so I stole it from simple.el in XEmacs. | |
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 | |
163 ;; force transient-mark-mode in Emacs, so that the marking routines | |
164 ;; work as expected. If the user turns off transient mark mode, | |
165 ;; most things will still work fine except the crisp-(copy|kill) | |
166 ;; functions won't work quite as nicely when regions are marked | |
167 ;; differently and could really confuse people. Caveat emptor. | |
168 | |
169 (if (fboundp 'transient-mark-mode) | |
170 (transient-mark-mode t)) | |
171 | |
172 (defun region-active () | |
173 "Compatibility function to test for an active region." | |
174 (if (boundp 'zmacs-region-active-p) | |
175 zmacs-region-active-p | |
176 mark-active)) | |
117 | 177 |
118 ;; and now the keymap defines | 178 ;; and now the keymap defines |
119 | 179 |
120 (define-key crisp-mode-map [(f1)] 'other-window) | 180 (define-key crisp-mode-map [(f1)] 'other-window) |
121 | 181 |
129 (define-key crisp-mode-map [(f4)] 'delete-window) | 189 (define-key crisp-mode-map [(f4)] 'delete-window) |
130 (define-key crisp-mode-map [(control f4)] 'delete-other-windows) | 190 (define-key crisp-mode-map [(control f4)] 'delete-other-windows) |
131 | 191 |
132 (define-key crisp-mode-map [(f5)] 'search-forward-regexp) | 192 (define-key crisp-mode-map [(f5)] 'search-forward-regexp) |
133 (define-key crisp-mode-map [(f19)] 'search-forward-regexp) | 193 (define-key crisp-mode-map [(f19)] 'search-forward-regexp) |
134 (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp) | 194 (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp) |
135 | 195 |
136 (define-key crisp-mode-map [(f6)] 'query-replace) | 196 (define-key crisp-mode-map [(f6)] 'query-replace) |
137 | 197 |
138 (define-key crisp-mode-map [(f7)] 'start-kbd-macro) | 198 (define-key crisp-mode-map [(f7)] 'start-kbd-macro) |
139 (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro) | 199 (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro) |
140 | 200 |
141 (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro) | 201 (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro) |
142 (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro) | 202 (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro) |
143 | 203 |
144 (define-key crisp-mode-map [(f9)] 'find-file) | 204 (define-key crisp-mode-map [(f9)] 'find-file) |
145 (define-key crisp-mode-map [(meta f9)] 'load-library) | 205 (define-key crisp-mode-map [(meta f9)] 'load-library) |
146 | 206 |
147 (define-key crisp-mode-map [(f10)] 'execute-extended-command) | 207 (define-key crisp-mode-map [(f10)] 'execute-extended-command) |
148 (define-key crisp-mode-map [(meta f10)] 'compile) | 208 (define-key crisp-mode-map [(meta f10)] 'compile) |
149 | 209 |
150 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) | 210 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) |
151 (define-key crisp-mode-map [(kp-add)] 'x-copy-primary-selection) | 211 (define-key crisp-mode-map [(kp-add)] 'crisp-copy-line) |
152 (define-key crisp-mode-map [(kp-subtract)] 'x-kill-primary-selection) | 212 (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) |
153 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection) | 213 ;; just to cover all the bases (GNU Emacs, for instance) |
154 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd | 214 (define-key crisp-mode-map [(f24)] 'crisp-kill-line) |
155 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd | 215 (define-key crisp-mode-map [(insert)] 'yank-clipboard-selection) |
156 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd | 216 (define-key crisp-mode-map [(f16)] 'copy-primary-selection) ; copy on Sun5 kbd |
157 | 217 (define-key crisp-mode-map [(f20)] 'kill-primary-selection) ; cut on Sun5 kbd |
158 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line))) | 218 (define-key crisp-mode-map [(f18)] 'yank-clipboard-selection) ; paste on Sun5 kbd |
219 | |
220 (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) | |
221 (define-key crisp-mode-map [(meta d)] (lambda () | |
222 (interactive) | |
223 (beginning-of-line) (kill-line))) | |
159 (define-key crisp-mode-map [(meta e)] 'find-file) | 224 (define-key crisp-mode-map [(meta e)] 'find-file) |
160 (define-key crisp-mode-map [(meta g)] 'goto-line) | 225 (define-key crisp-mode-map [(meta g)] 'goto-line) |
161 (define-key crisp-mode-map [(meta h)] 'help) | 226 (define-key crisp-mode-map [(meta h)] 'help) |
162 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) | 227 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) |
163 (define-key crisp-mode-map [(meta j)] 'bookmark-jump) | 228 (define-key crisp-mode-map [(meta j)] 'bookmark-jump) |
229 (define-key crisp-mode-map [(meta l)] 'crisp-mark-line) | |
230 (define-key crisp-mode-map [(meta m)] 'set-mark-command) | |
231 (define-key crisp-mode-map [(meta n)] 'bury-buffer) | |
232 (define-key crisp-mode-map [(meta p)] 'crisp-unbury-buffer) | |
164 (define-key crisp-mode-map [(meta u)] 'advertised-undo) | 233 (define-key crisp-mode-map [(meta u)] 'advertised-undo) |
165 (define-key crisp-mode-map [(f14)] 'advertised-undo) | 234 (define-key crisp-mode-map [(f14)] 'advertised-undo) |
166 (define-key crisp-mode-map [(meta w)] 'save-buffer) | 235 (define-key crisp-mode-map [(meta w)] 'save-buffer) |
167 (if | 236 (define-key crisp-mode-map [(meta x)] 'crisp-meta-x-wrapper) |
168 (eq crisp-override-meta-x 't) | 237 (define-key crisp-mode-map [(meta ?0)] (lambda () |
169 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs)) | 238 (interactive) |
170 (define-key crisp-mode-map [(meta ?0)] (lambda () (interactive) (bookmark-set "0"))) | 239 (bookmark-set "0"))) |
171 (define-key crisp-mode-map [(meta ?1)] (lambda () (interactive) (bookmark-set "1"))) | 240 (define-key crisp-mode-map [(meta ?1)] (lambda () |
172 (define-key crisp-mode-map [(meta ?2)] (lambda () (interactive) (bookmark-set "2"))) | 241 (interactive) |
173 (define-key crisp-mode-map [(meta ?3)] (lambda () (interactive) (bookmark-set "3"))) | 242 (bookmark-set "1"))) |
174 (define-key crisp-mode-map [(meta ?4)] (lambda () (interactive) (bookmark-set "4"))) | 243 (define-key crisp-mode-map [(meta ?2)] (lambda () |
175 (define-key crisp-mode-map [(meta ?5)] (lambda () (interactive) (bookmark-set "5"))) | 244 (interactive) |
176 (define-key crisp-mode-map [(meta ?6)] (lambda () (interactive) (bookmark-set "6"))) | 245 (bookmark-set "2"))) |
177 (define-key crisp-mode-map [(meta ?7)] (lambda () (interactive) (bookmark-set "7"))) | 246 (define-key crisp-mode-map [(meta ?3)] (lambda () |
178 (define-key crisp-mode-map [(meta ?8)] (lambda () (interactive) (bookmark-set "8"))) | 247 (interactive) |
179 (define-key crisp-mode-map [(meta ?9)] (lambda () (interactive) (bookmark-set "9"))) | 248 (bookmark-set "3"))) |
180 | 249 (define-key crisp-mode-map [(meta ?4)] (lambda () |
181 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word) | 250 (interactive) |
182 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word) | 251 (bookmark-set "4"))) |
183 (define-key crisp-mode-map [(shift delete)] 'kill-word) | 252 (define-key crisp-mode-map [(meta ?5)] (lambda () |
253 (interactive) | |
254 (bookmark-set "5"))) | |
255 (define-key crisp-mode-map [(meta ?6)] (lambda () | |
256 (interactive) | |
257 (bookmark-set "6"))) | |
258 (define-key crisp-mode-map [(meta ?7)] (lambda () | |
259 (interactive) | |
260 (bookmark-set "7"))) | |
261 (define-key crisp-mode-map [(meta ?8)] (lambda () | |
262 (interactive) | |
263 (bookmark-set "8"))) | |
264 (define-key crisp-mode-map [(meta ?9)] (lambda () | |
265 (interactive) | |
266 (bookmark-set "9"))) | |
267 | |
268 (define-key crisp-mode-map [(shift delete)] 'kill-word) | |
184 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) | 269 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) |
185 (define-key crisp-mode-map [(control left)] 'backward-word) | 270 (define-key crisp-mode-map [(control left)] 'backward-word) |
186 (define-key crisp-mode-map [(control right)] 'forward-word) | 271 (define-key crisp-mode-map [(control right)] 'forward-word) |
187 | 272 |
188 (define-key crisp-mode-map [(home)] 'crisp-home) | 273 (define-key crisp-mode-map [(home)] 'crisp-home) |
189 (define-key crisp-mode-map [(end)] 'crisp-end) | 274 (define-key crisp-mode-map [(control home)] (lambda () |
275 (interactive) | |
276 (move-to-window-line 0))) | |
277 (define-key crisp-mode-map [(meta home)] 'beginning-of-line) | |
278 (define-key crisp-mode-map [(end)] 'crisp-end) | |
279 (define-key crisp-mode-map [(control end)] (lambda () | |
280 (interactive) | |
281 (move-to-window-line -1))) | |
282 (define-key crisp-mode-map [(meta end)] 'end-of-line) | |
283 | |
284 (define-key crisp-mode-map [(control c) (b)] 'crisp-submit-bug-report) | |
285 | |
286 (defun crisp-version (&optional arg) | |
287 "Version number of the CRiSP emulator package. | |
288 If ARG, insert results at point." | |
289 (interactive "P") | |
290 (let ((foo (concat "CRiSP version " crisp-version))) | |
291 (if arg | |
292 (insert (message foo)) | |
293 (message foo)))) | |
294 | |
295 (defun crisp-mark-line (arg) | |
296 "Put mark at the end of line. Arg works as in `end-of-line'." | |
297 (interactive "p") | |
298 (mark-something 'crisp-mark-line 'end-of-line arg)) | |
299 | |
300 (defun crisp-kill-line (arg) | |
301 "Mark and kill line(s). | |
302 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." | |
304 (interactive "*p") | |
305 (if (region-active) | |
306 (call-interactively 'kill-primary-selection) | |
307 (crisp-mark-line arg) | |
308 (call-interactively 'kill-primary-selection))) | |
309 | |
310 (defun crisp-copy-line (arg) | |
311 "Mark and copy line(s). | |
312 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 | |
314 the region." | |
315 (interactive "*p") | |
316 (if (region-active) | |
317 (call-interactively 'copy-primary-selection) | |
318 (crisp-mark-line arg) | |
319 (call-interactively 'copy-primary-selection)) | |
320 ;; clear the region after the operation is complete | |
321 ;; XEmacs does this automagically, Emacs doesn't. | |
322 (if (boundp 'mark-active) | |
323 (setq mark-active nil))) | |
190 | 324 |
191 (defun crisp-home () | 325 (defun crisp-home () |
192 "\"Home\" point, the way CRiSP would do it. | 326 "\"Home\" the point, the way CRiSP would do it. |
193 The first use moves point to beginning of the line. Second | 327 The first use moves point to beginning of the line. Second |
194 consecutive use moves point to beginning of the screen. Third | 328 consecutive use moves point to beginning of the screen. Third |
195 consecutive use moves point to the beginning of the buffer." | 329 consecutive use moves point to the beginning of the buffer." |
196 (interactive nil) | 330 (interactive nil) |
197 (cond | 331 (cond |
203 (t | 337 (t |
204 (beginning-of-line))) | 338 (beginning-of-line))) |
205 (setq crisp-last-last-command last-command)) | 339 (setq crisp-last-last-command last-command)) |
206 | 340 |
207 (defun crisp-end () | 341 (defun crisp-end () |
208 "\"End\" point, the way CRiSP would do it. | 342 "\"End\" the point, the way CRiSP would do it. |
209 The first use moves point to end of the line. Second | 343 The first use moves point to end of the line. Second |
210 consecutive use moves point to the end of the screen. Third | 344 consecutive use moves point to the end of the screen. Third |
211 consecutive use moves point to the end of the buffer." | 345 consecutive use moves point to the end of the buffer." |
212 (interactive nil) | 346 (interactive nil) |
213 (cond | 347 (cond |
214 ((and (eq last-command 'crisp-end) (eq crisp-last-last-command 'crisp-end)) | 348 ((and (eq last-command 'crisp-end) |
349 (eq crisp-last-last-command 'crisp-end)) | |
215 (goto-char (point-max))) | 350 (goto-char (point-max))) |
216 ((eq last-command 'crisp-end) | 351 ((eq last-command 'crisp-end) |
217 (move-to-window-line -1) | 352 (move-to-window-line -1) |
218 (end-of-line)) | 353 (end-of-line)) |
219 (t | 354 (t |
220 (end-of-line))) | 355 (end-of-line))) |
221 (setq crisp-last-last-command last-command)) | 356 (setq crisp-last-last-command last-command)) |
222 | 357 |
358 (defun crisp-unbury-buffer () | |
359 "Go back one buffer" | |
360 (interactive) | |
361 (switch-to-buffer (car (last (buffer-list))))) | |
362 | |
363 (defun crisp-meta-x-wrapper () | |
364 "Wrapper function to conditionally override the normal M-x bindings. | |
365 When `crisp-override-meta-x' is non-nil, M-x will exit Emacs (the | |
366 normal CRiSP binding) and when it is nil M-x will run | |
367 `execute-extended-command' (the normal Emacs binding)." | |
368 (interactive) | |
369 (if crisp-override-meta-x | |
370 (save-buffers-kill-emacs) | |
371 (call-interactively 'execute-extended-command))) | |
372 | |
373 ;; bug reporter | |
374 | |
375 (defun crisp-submit-bug-report () | |
376 "Submit via mail a bug report on CRiSP Mode." | |
377 (interactive) | |
378 ;; load in reporter | |
379 (let ((reporter-prompt-for-summary-p t) | |
380 (reporter-dont-compact-list '(c-offsets-alist))) | |
381 (and | |
382 (if (y-or-n-p "Do you want to submit a report on CRiSP Mode? ") | |
383 t (message "") nil) | |
384 (require 'reporter) | |
385 (reporter-submit-bug-report | |
386 crisp-mode-help-address | |
387 (concat "CRiSP Mode [" crisp-version "]") | |
388 nil | |
389 nil | |
390 nil | |
391 "Dear Gary," | |
392 )))) | |
393 | |
223 ;; Now enable the mode | 394 ;; Now enable the mode |
224 | 395 |
225 ;;;###autoload | 396 (defun crisp-mode (&optional arg) |
226 (defun crisp-mode () | 397 "Toggle CRiSP emulation minor mode. |
227 "Toggle CRiSP emulation minor mode." | 398 With ARG, turn CRiSP mode on if ARG is positive, off otherwise." |
228 (interactive nil) | 399 (interactive "P") |
229 (setq crisp-mode-enabled (not crisp-mode-enabled)) | 400 (setq crisp-mode-enabled (if (null arg) |
401 (not crisp-mode-enabled) | |
402 (> (prefix-numeric-value arg) 0))) | |
230 (cond | 403 (cond |
231 ((eq crisp-mode-enabled 't) | 404 ((eq crisp-mode-enabled 't) |
232 (use-global-map crisp-mode-map) | 405 (use-global-map crisp-mode-map) |
233 (if crisp-load-scroll-all | 406 (if crisp-load-scroll-all |
234 (require 'scroll-all)) | 407 (require 'scroll-all)) |
236 (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)) | 409 (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)) |
237 (run-hooks 'crisp-load-hook)) | 410 (run-hooks 'crisp-load-hook)) |
238 ((eq crisp-mode-enabled 'nil) | 411 ((eq crisp-mode-enabled 'nil) |
239 (use-global-map crisp-mode-original-keymap)))) | 412 (use-global-map crisp-mode-original-keymap)))) |
240 | 413 |
414 (if (fboundp 'add-minor-mode) | |
415 (add-minor-mode 'crisp-mode-enabled 'crisp-mode-modeline-string | |
416 nil nil 'crisp-mode) | |
417 (or (assq 'crisp-mode-enabled minor-mode-alist) | |
418 (setq minor-mode-alist | |
419 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) | |
420 | |
241 (provide 'crisp) | 421 (provide 'crisp) |
242 | 422 |
243 ;;; crisp.el ends here | 423 ;;; crisp.el ends here |
244 | |
245 |