comparison lisp/emulators/crisp.el @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 9b50b4588a93
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
1 ;; @(#) crisp.el -- CRiSP/Brief Emacs emulator 1 ;; @(#) crisp.el -- CRiSP/Brief Emacs emulator
2 2
3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com> 3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com>
4 ;; $Revision: 1.3 $ 4 ;; 1.19
5 ;; Keywords: emulations brief crisp 5 ;; Keywords: emulations brief crisp
6 6
7 ;; This file is part of GNU Emacs. 7 ;; This file is part of XEmacs.
8 8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify 9 ;; XEmacs is free software; you can redistribute it and/or modify it
10 ;; it under the terms of the GNU General Public License as published by 10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option) 11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version. 12 ;; any later version.
13 13
14 ;; GNU Emacs is distributed in the hope that it will be useful, 14 ;; XEmacs is distributed in the hope that it will be useful, but
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; GNU General Public License for more details. 17 ;; General Public License for more details.
18 18
19 ;; You should have received a copy of the GNU General Public License 19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the 20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 ;; Boston, MA 02111-1307, USA. 22 ;; 02111-1307, USA.
23
24 ;; CRiSP is a registered trademark of Foxtrot Systems Ltd.
23 25
24 ;;; Commentary: 26 ;;; Commentary:
25 27
26 ;; Keybindings and minor functions to duplicate the functionality and 28 ;; Keybindings and minor functions to duplicate the functionality and
27 ;; finger-feel of the Crisp/Brief editor. This package is designed to 29 ;; finger-feel of the CRiSP/Brief editor. This package is designed to
28 ;; facilitate transitioning from Brief to (XE|E)macs with a minimum 30 ;; facilitate transitioning from Brief to (XE|E)macs with a minimum
29 ;; amount of hassles. 31 ;; amount of hassles.
30 32
31 ;; Enable this package by putting the following in your .emacs 33 ;; Enable this package by putting (require 'crisp) in your .emacs and
32 ;; (require 'crisp) 34 ;; use M-x crisp-mode to toggle it on or off.
33 ;; and use M-x crisp-mode to toggle it on or off. 35
34 36 ;; This package will automatically load the scroll-lock.el package if
35 ;; This package will automatically default to loading the scroll-lock.el 37 ;; you put (setq crisp-load-scroll-lock t) in your .emacs before
36 ;; package unless you put (setq crisp-load-scroll-lock nil) in your 38 ;; loading this package. If this feature is enabled, it will bind
37 ;; .emacs. If this feature is enabled, it will bind meta-f1 to the 39 ;; meta-f1 to the scroll-lock mode toggle. The scroll-lock package
38 ;; scroll-lock mode toggle. 40 ;; duplicates the scroll-locking feature in CRiSP.
39 41
40 ;; Also, the default keybindings for brief override the meta-x key to 42 ;; Also, the default keybindings for brief/CRiSP override the M-x
41 ;; exit the editor. If you don't like this functionality, you can 43 ;; key to exit the editor. If you don't like this functionality, you
42 ;; prevent this key from being rebound with 44 ;; can prevent this behavior (or redefine it dynamically) by setting
43 ;; (setq crisp-override-meta-x nil) in your .emacs. 45 ;; the value of `crisp-override-meta-x' either in your .emacs or
46 ;; interactively. The default setting is nil, which means that M-x will
47 ;; by default run `execute-extended-command' instead of the command
48 ;; `save-buffers-kill-emacs'.
44 49
45 ;; Finally, if you want to change the string displayed in the modeline 50 ;; Finally, if you want to change the string displayed in the modeline
46 ;; when this mode is in effect, override the definition of 51 ;; when this mode is in effect, override the definition of
47 ;; `crisp-mode-modeline-string' in your .emacs. The default value is 52 ;; `crisp-mode-modeline-string' in your .emacs. The default value is
48 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things 53 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things
50 55
51 ;; All these overrides should go *before* the (require 'crisp) statement. 56 ;; All these overrides should go *before* the (require 'crisp) statement.
52 57
53 ;; local variables 58 ;; local variables
54 59
60 (defgroup emulations-crisp nil
61 "CRiSP emulator customizable settings."
62 :group 'emulations)
63
55 (defvar crisp-mode-map (copy-keymap (current-global-map)) 64 (defvar crisp-mode-map (copy-keymap (current-global-map))
56 "Local keymap for CRiSP emulation mode. 65 "Local keymap for CRiSP emulation mode.
57 All the bindings are done here instead of globally to try and be 66 All the bindings are done here instead of globally to try and be
58 nice to the world.") 67 nice to the world.")
59 68
60 (defvar crisp-mode-modeline-string " *CRiSP*" 69 (defcustom crisp-mode-modeline-string " *CRiSP*"
61 "String to display in the modeline when CRiSP emulation mode is enabled.") 70 "*String to display in the modeline when CRiSP emulation mode is enabled."
71 :type 'string
72 :group 'emulations-crisp)
62 73
63 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map)) 74 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map))
64 "The original keymap before CRiSP emulation mode remaps anything. 75 "The original keymap before CRiSP emulation mode remaps anything.
65 This keymap is restored when CRiSP emulation mode is disabled.") 76 This keymap is restored when CRiSP emulation mode is disabled.")
66 77
67 (defvar crisp-mode-enabled 'nil 78 (defvar crisp-mode-enabled nil
68 "Track status of CRiSP emulation mode. 79 "Track status of CRiSP emulation mode.
69 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
70 indicates CRiSP mode is enabled.") 81 indicates CRiSP mode is enabled.")
71 82
72 (defvar crisp-override-meta-x 't 83 (defcustom crisp-override-meta-x t
73 "Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. 84 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator.
74 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs 85 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs and
75 and provides the usual M-x functionality on the F10 key. 86 provides the usual M-x functionality on the F10 key. If this variable
76 87 is non-nil, M-x will exit Emacs."
77 If this variable is nil when you start the CRiSP emulator, it 88 :type 'boolean
78 does not alter the binding of M-x.") 89 :group 'emulations-crisp)
79 90
80 (defvar crisp-load-scroll-lock 't 91 (defvar crisp-load-scroll-lock nil
81 "Controls loading of the Scroll Lock in the CRiSP emulator. 92 "Controls loading of the Scroll Lock in the CRiSP emulator.
82 Its Default behavior is to load and enable the Scroll Lock minor mode 93 Its Default behavior is to load and enable the Scroll Lock minor mode
83 package when enabling the CRiSP emulator. 94 package when enabling the CRiSP emulator.
84 95
85 If this variable is nil when you start the CRiSP emulator, it 96 If this variable is nil when you start the CRiSP emulator, it
86 does not load Scroll Lock.") 97 does not load the scroll-lock package.")
87 98
88 (defvar crisp-load-hook nil 99 (defvar crisp-load-hook nil
89 "Hooks to run after loadint the CRiSP emulator package.") 100 "Hooks to run after loading the CRiSP emulator package.")
90 101
91 (defvar crisp-version "crisp.el release 1.1/$Revision: 1.3 $" 102 (defconst crisp-version "crisp.el release 1.1/1.19"
92 "The release number and RCS version for the CRiSP emulator.") 103 "The release number and RCS version for the CRiSP emulator.")
93 104
94 (if (string-match "XEmacs\\Lucid" emacs-version) 105 (if (string-match "XEmacs\\Lucid" emacs-version)
95 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string) 106 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string)
96 (or (assq 'crisp-mode-enabled minor-mode-alist) 107 (or (assq 'crisp-mode-enabled minor-mode-alist)
144 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) 155 (define-key crisp-mode-map [(meta i)] 'overwrite-mode)
145 (define-key crisp-mode-map [(meta j)] 'bookmark-jump) 156 (define-key crisp-mode-map [(meta j)] 'bookmark-jump)
146 (define-key crisp-mode-map [(meta u)] 'advertised-undo) 157 (define-key crisp-mode-map [(meta u)] 'advertised-undo)
147 (define-key crisp-mode-map [(f14)] 'advertised-undo) 158 (define-key crisp-mode-map [(f14)] 'advertised-undo)
148 (define-key crisp-mode-map [(meta w)] 'save-buffer) 159 (define-key crisp-mode-map [(meta w)] 'save-buffer)
149 (if 160 (define-key crisp-mode-map [(meta x)] 'crisp-meta-x-wrapper)
150 (eq crisp-override-meta-x 't)
151 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs))
152 (define-key crisp-mode-map [(meta ?0)] (lambda () (interactive) (bookmark-set "0"))) 161 (define-key crisp-mode-map [(meta ?0)] (lambda () (interactive) (bookmark-set "0")))
153 (define-key crisp-mode-map [(meta ?1)] (lambda () (interactive) (bookmark-set "1"))) 162 (define-key crisp-mode-map [(meta ?1)] (lambda () (interactive) (bookmark-set "1")))
154 (define-key crisp-mode-map [(meta ?2)] (lambda () (interactive) (bookmark-set "2"))) 163 (define-key crisp-mode-map [(meta ?2)] (lambda () (interactive) (bookmark-set "2")))
155 (define-key crisp-mode-map [(meta ?3)] (lambda () (interactive) (bookmark-set "3"))) 164 (define-key crisp-mode-map [(meta ?3)] (lambda () (interactive) (bookmark-set "3")))
156 (define-key crisp-mode-map [(meta ?4)] (lambda () (interactive) (bookmark-set "4"))) 165 (define-key crisp-mode-map [(meta ?4)] (lambda () (interactive) (bookmark-set "4")))
199 (end-of-line)) 208 (end-of-line))
200 (t 209 (t
201 (end-of-line))) 210 (end-of-line)))
202 (setq last-last-command last-command)) 211 (setq last-last-command last-command))
203 212
213 (defun crisp-meta-x-wrapper ()
214 "Wrapper function to conditionally override the normal M-x bindings.
215 When `crisp-override-meta-x' is non-nil, M-x will exit Emacs (the
216 normal CRiSP binding) and when it is nil M-x will run
217 `execute-extended-command' (the normal Emacs binding)."
218 (interactive)
219 (if crisp-override-meta-x
220 (save-buffers-kill-emacs)
221 (call-interactively 'execute-extended-command)))
222
204 ;; Now enable the mode 223 ;; Now enable the mode
205 224
206 (defun crisp-mode () 225 (defun crisp-mode ()
207 "Toggle CRiSP emulation minor mode." 226 "Toggle CRiSP emulation minor mode."
208 (interactive nil) 227 (interactive nil)