diff options
| author | Stefan Monnier | 2009-09-11 01:00:37 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-09-11 01:00:37 +0000 |
| commit | 726a4d09685ff5778c4ac45969d8073f08b1be3d (patch) | |
| tree | 2d194290cc81855ef5391a11ae4a6f1c5fff3c97 | |
| parent | 8cb95edf7cdec140efb1c8dbf4f7f33320f0ca0c (diff) | |
| download | emacs-726a4d09685ff5778c4ac45969d8073f08b1be3d.tar.gz emacs-726a4d09685ff5778c4ac45969d8073f08b1be3d.zip | |
* emulation/crisp.el (crisp-mode-map): Move initialization
into declaration.
(crisp-mode): Use define-minor-mode.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/emulation/crisp.el | 235 |
2 files changed, 114 insertions, 125 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9513e9ecb4e..af99ea55822 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2009-09-11 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-09-11 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emulation/crisp.el (crisp-mode-map): Move initialization | ||
| 4 | into declaration. | ||
| 5 | (crisp-mode): Use define-minor-mode. | ||
| 6 | |||
| 3 | * progmodes/xscheme.el (xscheme-evaluation-commands): | 7 | * progmodes/xscheme.el (xscheme-evaluation-commands): |
| 4 | Put a :advertised-binding property rather than using | 8 | Put a :advertised-binding property rather than using |
| 5 | advertised-xscheme-send-previous-expression. | 9 | advertised-xscheme-send-previous-expression. |
diff --git a/lisp/emulation/crisp.el b/lisp/emulation/crisp.el index a53adf00fea..870e8799b3f 100644 --- a/lisp/emulation/crisp.el +++ b/lisp/emulation/crisp.el | |||
| @@ -64,8 +64,112 @@ | |||
| 64 | :prefix "crisp-" | 64 | :prefix "crisp-" |
| 65 | :group 'emulations) | 65 | :group 'emulations) |
| 66 | 66 | ||
| 67 | (defvar crisp-mode-map (let ((map (make-sparse-keymap))) | 67 | (defvar crisp-mode-map |
| 68 | map) | 68 | (let ((map (make-sparse-keymap))) |
| 69 | (define-key map [(f1)] 'other-window) | ||
| 70 | |||
| 71 | (define-key map [(f2) (down)] 'enlarge-window) | ||
| 72 | (define-key map [(f2) (left)] 'shrink-window-horizontally) | ||
| 73 | (define-key map [(f2) (right)] 'enlarge-window-horizontally) | ||
| 74 | (define-key map [(f2) (up)] 'shrink-window) | ||
| 75 | (define-key map [(f3) (down)] 'split-window-vertically) | ||
| 76 | (define-key map [(f3) (right)] 'split-window-horizontally) | ||
| 77 | |||
| 78 | (define-key map [(f4)] 'delete-window) | ||
| 79 | (define-key map [(control f4)] 'delete-other-windows) | ||
| 80 | |||
| 81 | (define-key map [(f5)] 'search-forward-regexp) | ||
| 82 | (define-key map [(f19)] 'search-forward-regexp) | ||
| 83 | (define-key map [(meta f5)] 'search-backward-regexp) | ||
| 84 | |||
| 85 | (define-key map [(f6)] 'query-replace) | ||
| 86 | |||
| 87 | (define-key map [(f7)] 'start-kbd-macro) | ||
| 88 | (define-key map [(meta f7)] 'end-kbd-macro) | ||
| 89 | |||
| 90 | (define-key map [(f8)] 'call-last-kbd-macro) | ||
| 91 | (define-key map [(meta f8)] 'save-kbd-macro) | ||
| 92 | |||
| 93 | (define-key map [(f9)] 'find-file) | ||
| 94 | (define-key map [(meta f9)] 'load-library) | ||
| 95 | |||
| 96 | (define-key map [(f10)] 'execute-extended-command) | ||
| 97 | (define-key map [(meta f10)] 'compile) | ||
| 98 | |||
| 99 | (define-key map [(SunF37)] 'kill-buffer) | ||
| 100 | (define-key map [(kp-add)] 'crisp-copy-line) | ||
| 101 | (define-key map [(kp-subtract)] 'crisp-kill-line) | ||
| 102 | ;; just to cover all the bases (GNU Emacs, for instance) | ||
| 103 | (define-key map [(f24)] 'crisp-kill-line) | ||
| 104 | (define-key map [(insert)] 'crisp-yank-clipboard) | ||
| 105 | (define-key map [(f16)] 'crisp-set-clipboard) ; copy on Sun5 kbd | ||
| 106 | (define-key map [(f20)] 'crisp-kill-region) ; cut on Sun5 kbd | ||
| 107 | (define-key map [(f18)] 'crisp-yank-clipboard) ; paste on Sun5 kbd | ||
| 108 | |||
| 109 | (define-key map [(control f)] 'fill-paragraph-or-region) | ||
| 110 | (define-key map [(meta d)] (lambda () | ||
| 111 | (interactive) | ||
| 112 | (beginning-of-line) (kill-line))) | ||
| 113 | (define-key map [(meta e)] 'find-file) | ||
| 114 | (define-key map [(meta g)] 'goto-line) | ||
| 115 | (define-key map [(meta h)] 'help) | ||
| 116 | (define-key map [(meta i)] 'overwrite-mode) | ||
| 117 | (define-key map [(meta j)] 'bookmark-jump) | ||
| 118 | (define-key map [(meta l)] 'crisp-mark-line) | ||
| 119 | (define-key map [(meta m)] 'set-mark-command) | ||
| 120 | (define-key map [(meta n)] 'bury-buffer) | ||
| 121 | (define-key map [(meta p)] 'crisp-unbury-buffer) | ||
| 122 | (define-key map [(meta u)] 'undo) | ||
| 123 | (define-key map [(f14)] 'undo) | ||
| 124 | (define-key map [(meta w)] 'save-buffer) | ||
| 125 | (define-key map [(meta x)] 'crisp-meta-x-wrapper) | ||
| 126 | (define-key map [(meta ?0)] (lambda () | ||
| 127 | (interactive) | ||
| 128 | (bookmark-set "0"))) | ||
| 129 | (define-key map [(meta ?1)] (lambda () | ||
| 130 | (interactive) | ||
| 131 | (bookmark-set "1"))) | ||
| 132 | (define-key map [(meta ?2)] (lambda () | ||
| 133 | (interactive) | ||
| 134 | (bookmark-set "2"))) | ||
| 135 | (define-key map [(meta ?3)] (lambda () | ||
| 136 | (interactive) | ||
| 137 | (bookmark-set "3"))) | ||
| 138 | (define-key map [(meta ?4)] (lambda () | ||
| 139 | (interactive) | ||
| 140 | (bookmark-set "4"))) | ||
| 141 | (define-key map [(meta ?5)] (lambda () | ||
| 142 | (interactive) | ||
| 143 | (bookmark-set "5"))) | ||
| 144 | (define-key map [(meta ?6)] (lambda () | ||
| 145 | (interactive) | ||
| 146 | (bookmark-set "6"))) | ||
| 147 | (define-key map [(meta ?7)] (lambda () | ||
| 148 | (interactive) | ||
| 149 | (bookmark-set "7"))) | ||
| 150 | (define-key map [(meta ?8)] (lambda () | ||
| 151 | (interactive) | ||
| 152 | (bookmark-set "8"))) | ||
| 153 | (define-key map [(meta ?9)] (lambda () | ||
| 154 | (interactive) | ||
| 155 | (bookmark-set "9"))) | ||
| 156 | |||
| 157 | (define-key map [(shift delete)] 'kill-word) | ||
| 158 | (define-key map [(shift backspace)] 'backward-kill-word) | ||
| 159 | (define-key map [(control left)] 'backward-word) | ||
| 160 | (define-key map [(control right)] 'forward-word) | ||
| 161 | |||
| 162 | (define-key map [(home)] 'crisp-home) | ||
| 163 | (define-key map [(control home)] (lambda () | ||
| 164 | (interactive) | ||
| 165 | (move-to-window-line 0))) | ||
| 166 | (define-key map [(meta home)] 'beginning-of-line) | ||
| 167 | (define-key map [(end)] 'crisp-end) | ||
| 168 | (define-key map [(control end)] (lambda () | ||
| 169 | (interactive) | ||
| 170 | (move-to-window-line -1))) | ||
| 171 | (define-key map [(meta end)] 'end-of-line) | ||
| 172 | map) | ||
| 69 | "Local keymap for CRiSP emulation mode. | 173 | "Local keymap for CRiSP emulation mode. |
| 70 | All the bindings are done here instead of globally to try and be | 174 | All the bindings are done here instead of globally to try and be |
| 71 | nice to the world.") | 175 | nice to the world.") |
| @@ -152,112 +256,6 @@ does not load the scroll-all package." | |||
| 152 | zmacs-region-active-p | 256 | zmacs-region-active-p |
| 153 | mark-active)) | 257 | mark-active)) |
| 154 | 258 | ||
| 155 | ;; and now the keymap defines | ||
| 156 | |||
| 157 | (define-key crisp-mode-map [(f1)] 'other-window) | ||
| 158 | |||
| 159 | (define-key crisp-mode-map [(f2) (down)] 'enlarge-window) | ||
| 160 | (define-key crisp-mode-map [(f2) (left)] 'shrink-window-horizontally) | ||
| 161 | (define-key crisp-mode-map [(f2) (right)] 'enlarge-window-horizontally) | ||
| 162 | (define-key crisp-mode-map [(f2) (up)] 'shrink-window) | ||
| 163 | (define-key crisp-mode-map [(f3) (down)] 'split-window-vertically) | ||
| 164 | (define-key crisp-mode-map [(f3) (right)] 'split-window-horizontally) | ||
| 165 | |||
| 166 | (define-key crisp-mode-map [(f4)] 'delete-window) | ||
| 167 | (define-key crisp-mode-map [(control f4)] 'delete-other-windows) | ||
| 168 | |||
| 169 | (define-key crisp-mode-map [(f5)] 'search-forward-regexp) | ||
| 170 | (define-key crisp-mode-map [(f19)] 'search-forward-regexp) | ||
| 171 | (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp) | ||
| 172 | |||
| 173 | (define-key crisp-mode-map [(f6)] 'query-replace) | ||
| 174 | |||
| 175 | (define-key crisp-mode-map [(f7)] 'start-kbd-macro) | ||
| 176 | (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro) | ||
| 177 | |||
| 178 | (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro) | ||
| 179 | (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro) | ||
| 180 | |||
| 181 | (define-key crisp-mode-map [(f9)] 'find-file) | ||
| 182 | (define-key crisp-mode-map [(meta f9)] 'load-library) | ||
| 183 | |||
| 184 | (define-key crisp-mode-map [(f10)] 'execute-extended-command) | ||
| 185 | (define-key crisp-mode-map [(meta f10)] 'compile) | ||
| 186 | |||
| 187 | (define-key crisp-mode-map [(SunF37)] 'kill-buffer) | ||
| 188 | (define-key crisp-mode-map [(kp-add)] 'crisp-copy-line) | ||
| 189 | (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) | ||
| 190 | ;; just to cover all the bases (GNU Emacs, for instance) | ||
| 191 | (define-key crisp-mode-map [(f24)] 'crisp-kill-line) | ||
| 192 | (define-key crisp-mode-map [(insert)] 'crisp-yank-clipboard) | ||
| 193 | (define-key crisp-mode-map [(f16)] 'crisp-set-clipboard) ; copy on Sun5 kbd | ||
| 194 | (define-key crisp-mode-map [(f20)] 'crisp-kill-region) ; cut on Sun5 kbd | ||
| 195 | (define-key crisp-mode-map [(f18)] 'crisp-yank-clipboard) ; paste on Sun5 kbd | ||
| 196 | |||
| 197 | (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) | ||
| 198 | (define-key crisp-mode-map [(meta d)] (lambda () | ||
| 199 | (interactive) | ||
| 200 | (beginning-of-line) (kill-line))) | ||
| 201 | (define-key crisp-mode-map [(meta e)] 'find-file) | ||
| 202 | (define-key crisp-mode-map [(meta g)] 'goto-line) | ||
| 203 | (define-key crisp-mode-map [(meta h)] 'help) | ||
| 204 | (define-key crisp-mode-map [(meta i)] 'overwrite-mode) | ||
| 205 | (define-key crisp-mode-map [(meta j)] 'bookmark-jump) | ||
| 206 | (define-key crisp-mode-map [(meta l)] 'crisp-mark-line) | ||
| 207 | (define-key crisp-mode-map [(meta m)] 'set-mark-command) | ||
| 208 | (define-key crisp-mode-map [(meta n)] 'bury-buffer) | ||
| 209 | (define-key crisp-mode-map [(meta p)] 'crisp-unbury-buffer) | ||
| 210 | (define-key crisp-mode-map [(meta u)] 'undo) | ||
| 211 | (define-key crisp-mode-map [(f14)] 'undo) | ||
| 212 | (define-key crisp-mode-map [(meta w)] 'save-buffer) | ||
| 213 | (define-key crisp-mode-map [(meta x)] 'crisp-meta-x-wrapper) | ||
| 214 | (define-key crisp-mode-map [(meta ?0)] (lambda () | ||
| 215 | (interactive) | ||
| 216 | (bookmark-set "0"))) | ||
| 217 | (define-key crisp-mode-map [(meta ?1)] (lambda () | ||
| 218 | (interactive) | ||
| 219 | (bookmark-set "1"))) | ||
| 220 | (define-key crisp-mode-map [(meta ?2)] (lambda () | ||
| 221 | (interactive) | ||
| 222 | (bookmark-set "2"))) | ||
| 223 | (define-key crisp-mode-map [(meta ?3)] (lambda () | ||
| 224 | (interactive) | ||
| 225 | (bookmark-set "3"))) | ||
| 226 | (define-key crisp-mode-map [(meta ?4)] (lambda () | ||
| 227 | (interactive) | ||
| 228 | (bookmark-set "4"))) | ||
| 229 | (define-key crisp-mode-map [(meta ?5)] (lambda () | ||
| 230 | (interactive) | ||
| 231 | (bookmark-set "5"))) | ||
| 232 | (define-key crisp-mode-map [(meta ?6)] (lambda () | ||
| 233 | (interactive) | ||
| 234 | (bookmark-set "6"))) | ||
| 235 | (define-key crisp-mode-map [(meta ?7)] (lambda () | ||
| 236 | (interactive) | ||
| 237 | (bookmark-set "7"))) | ||
| 238 | (define-key crisp-mode-map [(meta ?8)] (lambda () | ||
| 239 | (interactive) | ||
| 240 | (bookmark-set "8"))) | ||
| 241 | (define-key crisp-mode-map [(meta ?9)] (lambda () | ||
| 242 | (interactive) | ||
| 243 | (bookmark-set "9"))) | ||
| 244 | |||
| 245 | (define-key crisp-mode-map [(shift delete)] 'kill-word) | ||
| 246 | (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) | ||
| 247 | (define-key crisp-mode-map [(control left)] 'backward-word) | ||
| 248 | (define-key crisp-mode-map [(control right)] 'forward-word) | ||
| 249 | |||
| 250 | (define-key crisp-mode-map [(home)] 'crisp-home) | ||
| 251 | (define-key crisp-mode-map [(control home)] (lambda () | ||
| 252 | (interactive) | ||
| 253 | (move-to-window-line 0))) | ||
| 254 | (define-key crisp-mode-map [(meta home)] 'beginning-of-line) | ||
| 255 | (define-key crisp-mode-map [(end)] 'crisp-end) | ||
| 256 | (define-key crisp-mode-map [(control end)] (lambda () | ||
| 257 | (interactive) | ||
| 258 | (move-to-window-line -1))) | ||
| 259 | (define-key crisp-mode-map [(meta end)] 'end-of-line) | ||
| 260 | |||
| 261 | (defun crisp-version (&optional arg) | 259 | (defun crisp-version (&optional arg) |
| 262 | "Version number of the CRiSP emulator package. | 260 | "Version number of the CRiSP emulator package. |
| 263 | If ARG, insert results at point." | 261 | If ARG, insert results at point." |
| @@ -351,13 +349,11 @@ normal CRiSP binding) and when it is nil M-x will run | |||
| 351 | (call-interactively 'execute-extended-command))) | 349 | (call-interactively 'execute-extended-command))) |
| 352 | 350 | ||
| 353 | ;;;###autoload | 351 | ;;;###autoload |
| 354 | (defun crisp-mode (&optional arg) | 352 | (define-minor-mode crisp-mode |
| 355 | "Toggle CRiSP/Brief emulation minor mode. | 353 | "Toggle CRiSP/Brief emulation minor mode. |
| 356 | With ARG, turn CRiSP mode on if ARG is positive, off otherwise." | 354 | With ARG, turn CRiSP mode on if ARG is positive, off otherwise." |
| 357 | (interactive "P") | 355 | :keymap crisp-mode-map |
| 358 | (setq crisp-mode (if (null arg) | 356 | :lighter crisp-mode-modeline-string |
| 359 | (not crisp-mode) | ||
| 360 | (> (prefix-numeric-value arg) 0))) | ||
| 361 | (when crisp-mode | 357 | (when crisp-mode |
| 362 | ;; Make menu entries show M-u or f14 in preference to C-x u. | 358 | ;; Make menu entries show M-u or f14 in preference to C-x u. |
| 363 | (put 'undo :advertised-binding | 359 | (put 'undo :advertised-binding |
| @@ -372,23 +368,12 @@ With ARG, turn CRiSP mode on if ARG is positive, off otherwise." | |||
| 372 | (if crisp-load-scroll-all | 368 | (if crisp-load-scroll-all |
| 373 | (require 'scroll-all)) | 369 | (require 'scroll-all)) |
| 374 | (if (featurep 'scroll-all) | 370 | (if (featurep 'scroll-all) |
| 375 | (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)) | 371 | (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)))) |
| 376 | (run-hooks 'crisp-mode-hook))) | ||
| 377 | 372 | ||
| 378 | ;; People might use Apropos on `brief'. | 373 | ;; People might use Apropos on `brief'. |
| 379 | ;;;###autoload | 374 | ;;;###autoload |
| 380 | (defalias 'brief-mode 'crisp-mode) | 375 | (defalias 'brief-mode 'crisp-mode) |
| 381 | 376 | ||
| 382 | (if (fboundp 'add-minor-mode) | ||
| 383 | (add-minor-mode 'crisp-mode 'crisp-mode-modeline-string | ||
| 384 | crisp-mode-map nil 'crisp-mode) | ||
| 385 | (or (assq 'crisp-mode minor-mode-alist) | ||
| 386 | (setq minor-mode-alist | ||
| 387 | (cons '(crisp-mode crisp-mode-modeline-string) minor-mode-alist))) | ||
| 388 | (or (assq 'crisp-mode minor-mode-map-alist) | ||
| 389 | (setq minor-mode-map-alist (cons (cons 'crisp-mode crisp-mode-map) | ||
| 390 | minor-mode-map-alist)))) | ||
| 391 | |||
| 392 | ;; Interaction with other packages. | 377 | ;; Interaction with other packages. |
| 393 | (put 'crisp-home 'CUA 'move) | 378 | (put 'crisp-home 'CUA 'move) |
| 394 | (put 'crisp-end 'CUA 'move) | 379 | (put 'crisp-end 'CUA 'move) |