Mercurial > emacs
comparison lisp/emulation/crisp.el @ 24770:c9cc4db4508f
(crisp-mode-map): Don't inherit global-map.
Enter it on minor-mode-map-alist.
(crisp-mode): Re-named from `crsip-mode-enabled'. Users changed.
Autoload. Add custom setter.
(crisp-mark-line): Doc fix.
(crisp-mode): Autoload. Re-write not to frob keymaps directly.
(crisp-mode-hook): Define.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 24 May 1999 22:23:35 +0000 |
parents | 585c5f115d83 |
children | 0b882049980c |
comparison
equal
deleted
inserted
replaced
24769:28aea9fa43e1 | 24770:c9cc4db4508f |
---|---|
1 ;;; crisp.el --- CRiSP/Brief Emacs emulator | 1 ;;; crisp.el --- CRiSP/Brief Emacs emulator |
2 | 2 |
3 ;; Copyright (C) 1997, 1998 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Gary D. Foster <gfoster@suzieq.ml.org> | 5 ;; Author: Gary D. Foster <gfoster@suzieq.ml.org> |
6 ;; Keywords: emulations brief crisp | 6 ;; Keywords: emulations brief crisp |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
40 | 40 |
41 ;; Also, the default keybindings for brief/CRiSP override the M-x | 41 ;; Also, the default keybindings for brief/CRiSP override the M-x |
42 ;; key to exit the editor. If you don't like this functionality, you | 42 ;; key to exit the editor. If you don't like this functionality, you |
43 ;; can prevent this behavior (or redefine it dynamically) by setting | 43 ;; can prevent this behavior (or redefine it dynamically) by setting |
44 ;; the value of `crisp-override-meta-x' either in your .emacs or | 44 ;; the value of `crisp-override-meta-x' either in your .emacs or |
45 ;; interactively. The default setting is nil, which means that M-x will | 45 ;; interactively. The default setting is t, which means that M-x will |
46 ;; by default run `execute-extended-command' instead of the command | 46 ;; by default run `save-buffers-kill-emacs' instead of the command |
47 ;; `save-buffers-kill-emacs'. | 47 ;; `execute-extended-command'. |
48 | 48 |
49 ;; Finally, if you want to change the string displayed in the modeline | 49 ;; Finally, if you want to change the string displayed in the modeline |
50 ;; when this mode is in effect, override the definition of | 50 ;; when this mode is in effect, override the definition of |
51 ;; `crisp-mode-modeline-string' in your .emacs. The default value is | 51 ;; `crisp-mode-modeline-string' in your .emacs. The default value is |
52 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things | 52 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things |
62 "Emulator for CRiSP and Brief key bindings." | 62 "Emulator for CRiSP and Brief key bindings." |
63 :prefix "crisp-" | 63 :prefix "crisp-" |
64 :group 'emulations) | 64 :group 'emulations) |
65 | 65 |
66 (defvar crisp-mode-map (let ((map (make-sparse-keymap))) | 66 (defvar crisp-mode-map (let ((map (make-sparse-keymap))) |
67 (set-keymap-parent map (current-global-map)) | |
68 map) | 67 map) |
69 "Local keymap for CRiSP emulation mode. | 68 "Local keymap for CRiSP emulation mode. |
70 All the bindings are done here instead of globally to try and be | 69 All the bindings are done here instead of globally to try and be |
71 nice to the world.") | 70 nice to the world.") |
72 | 71 |
73 (defcustom crisp-mode-modeline-string " *CRiSP*" | 72 (defcustom crisp-mode-modeline-string " *CRiSP*" |
74 "*String to display in the modeline when CRiSP emulation mode is enabled." | 73 "*String to display in the modeline when CRiSP emulation mode is enabled." |
75 :type 'string | 74 :type 'string |
76 :group 'crisp) | 75 :group 'crisp) |
77 | 76 |
78 (defvar crisp-mode-original-keymap (current-global-map) | 77 ;;;###autoload |
79 "The original keymap before CRiSP emulation mode remaps anything. | 78 (defcustom crisp-mode nil |
80 This keymap is restored when CRiSP emulation mode is disabled.") | |
81 | |
82 (defcustom crisp-mode-enabled nil | |
83 "Track status of CRiSP emulation mode. | 79 "Track status of CRiSP emulation mode. |
84 A value of nil means CRiSP mode is not enabled. A value of t | 80 A value of nil means CRiSP mode is not enabled. A value of t |
85 indicates CRiSP mode is enabled." | 81 indicates CRiSP mode is enabled. |
82 | |
83 Setting this variable directly does not take effect; | |
84 use either M-x customize or the function `crisp-mode'." | |
85 :set (lambda (symbol value) (crisp-mode (if value 1 0))) | |
86 :require 'crisp | |
87 :version "20.4" | |
86 :type 'boolean | 88 :type 'boolean |
87 :group 'crisp) | 89 :group 'crisp) |
88 | 90 |
89 (defcustom crisp-override-meta-x t | 91 (defcustom crisp-override-meta-x t |
90 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. | 92 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. |
107 (defcustom crisp-load-hook nil | 109 (defcustom crisp-load-hook nil |
108 "Hooks to run after loading the CRiSP emulator package." | 110 "Hooks to run after loading the CRiSP emulator package." |
109 :type 'hook | 111 :type 'hook |
110 :group 'crisp) | 112 :group 'crisp) |
111 | 113 |
112 (defconst crisp-version "1.33" | 114 (defcustom crisp-mode-hook nil |
115 "Hook run by the function `crisp-mode'." | |
116 :type 'hook | |
117 :group 'crisp) | |
118 | |
119 (defconst crisp-version "1.34" | |
113 "The version of the CRiSP emulator.") | 120 "The version of the CRiSP emulator.") |
114 | 121 |
115 (defconst crisp-mode-help-address "gfoster@suzieq.ml.org" | 122 (defconst crisp-mode-help-address "gfoster@suzieq.ml.org" |
116 "The email address of the CRiSP mode author/maintainer.") | 123 "The email address of the CRiSP mode author/maintainer.") |
117 | 124 |
189 (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) | 196 (define-key crisp-mode-map [(kp-subtract)] 'crisp-kill-line) |
190 ;; just to cover all the bases (GNU Emacs, for instance) | 197 ;; just to cover all the bases (GNU Emacs, for instance) |
191 (define-key crisp-mode-map [(f24)] 'crisp-kill-line) | 198 (define-key crisp-mode-map [(f24)] 'crisp-kill-line) |
192 (define-key crisp-mode-map [(insert)] 'crisp-yank-clipboard) | 199 (define-key crisp-mode-map [(insert)] 'crisp-yank-clipboard) |
193 (define-key crisp-mode-map [(f16)] 'crisp-set-clipboard) ; copy on Sun5 kbd | 200 (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 | 201 (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 | 202 (define-key crisp-mode-map [(f18)] 'crisp-yank-clipboard) ; paste on Sun5 kbd |
196 | 203 |
197 (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) | 204 (define-key crisp-mode-map [(control f)] 'fill-paragraph-or-region) |
198 (define-key crisp-mode-map [(meta d)] (lambda () | 205 (define-key crisp-mode-map [(meta d)] (lambda () |
199 (interactive) | 206 (interactive) |
268 (if arg | 275 (if arg |
269 (insert (message foo)) | 276 (insert (message foo)) |
270 (message foo)))) | 277 (message foo)))) |
271 | 278 |
272 (defun crisp-mark-line (arg) | 279 (defun crisp-mark-line (arg) |
273 "Set mark at the end of the line. Arg works as in `end-of-line'." | 280 "Set mark at the end of the line. |
281 Arg works as in `end-of-line'." | |
274 (interactive "p") | 282 (interactive "p") |
275 (let (newmark) | 283 (let (newmark) |
276 (save-excursion | 284 (save-excursion |
277 (end-of-line arg) | 285 (end-of-line arg) |
278 (setq newmark (point))) | 286 (setq newmark (point))) |
335 (t | 343 (t |
336 (end-of-line))) | 344 (end-of-line))) |
337 (setq crisp-last-last-command last-command)) | 345 (setq crisp-last-last-command last-command)) |
338 | 346 |
339 (defun crisp-unbury-buffer () | 347 (defun crisp-unbury-buffer () |
340 "Go back one buffer" | 348 "Go back one buffer." |
341 (interactive) | 349 (interactive) |
342 (switch-to-buffer (car (last (buffer-list))))) | 350 (switch-to-buffer (car (last (buffer-list))))) |
343 | 351 |
344 (defun crisp-meta-x-wrapper () | 352 (defun crisp-meta-x-wrapper () |
345 "Wrapper function to conditionally override the normal M-x bindings. | 353 "Wrapper function to conditionally override the normal M-x bindings. |
372 "Dear Gary," | 380 "Dear Gary," |
373 )))) | 381 )))) |
374 | 382 |
375 ;; Now enable the mode | 383 ;; Now enable the mode |
376 | 384 |
385 ;;;###autoload | |
377 (defun crisp-mode (&optional arg) | 386 (defun crisp-mode (&optional arg) |
378 "Toggle CRiSP emulation minor mode. | 387 "Toggle CRiSP emulation minor mode. |
379 With ARG, turn CRiSP mode on if ARG is positive, off otherwise." | 388 With ARG, turn CRiSP mode on if ARG is positive, off otherwise." |
380 (interactive "P") | 389 (interactive "P") |
381 (setq crisp-mode-enabled (if (null arg) | 390 (setq crisp-mode (if (null arg) |
382 (not crisp-mode-enabled) | 391 (not crisp-mode) |
383 (> (prefix-numeric-value arg) 0))) | 392 (> (prefix-numeric-value arg) 0))) |
384 (cond | 393 (when crisp-mode |
385 ((eq crisp-mode-enabled 't) | |
386 (use-global-map crisp-mode-map) | |
387 (if crisp-load-scroll-all | 394 (if crisp-load-scroll-all |
388 (require 'scroll-all)) | 395 (require 'scroll-all)) |
389 (if (featurep 'scroll-all) | 396 (if (featurep 'scroll-all) |
390 (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)) | 397 (define-key crisp-mode-map [(meta f1)] 'scroll-all-mode)) |
391 (run-hooks 'crisp-load-hook)) | 398 (run-hooks 'crisp-load-hook))) |
392 ((eq crisp-mode-enabled 'nil) | |
393 (use-global-map crisp-mode-original-keymap)))) | |
394 | 399 |
395 (if (fboundp 'add-minor-mode) | 400 (if (fboundp 'add-minor-mode) |
396 (add-minor-mode 'crisp-mode-enabled 'crisp-mode-modeline-string | 401 (add-minor-mode 'crisp-mode 'crisp-mode-modeline-string |
397 nil nil 'crisp-mode) | 402 crisp-mode-map nil 'crisp-mode) |
398 (or (assq 'crisp-mode-enabled minor-mode-alist) | 403 (or (assq 'crisp-mode minor-mode-alist) |
399 (setq minor-mode-alist | 404 (setq minor-mode-alist |
400 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) | 405 (cons '(crisp-mode crisp-mode-modeline-string) minor-mode-alist))) |
406 (or (assq 'crisp-mode minor-mode-map-alist) | |
407 (setq minor-mode-map-alist (cons (cons 'crisp-mode crisp-mode-map) | |
408 minor-mode-map-alist)))) | |
401 | 409 |
402 (provide 'crisp) | 410 (provide 'crisp) |
403 | 411 |
404 ;;; crisp.el ends here | 412 ;;; crisp.el ends here |