comparison lisp/emulators/crisp.el @ 48:56c54cf7c5b6 r19-16b90

Import from CVS: tag r19-16b90
author cvs
date Mon, 13 Aug 2007 08:56:04 +0200
parents b82b59fe008d
children
comparison
equal deleted inserted replaced
47:11c6df210d7f 48:56c54cf7c5b6
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.1.1.1 $ 4 ;; $Revision: 1.2 $
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 GNU Emacs.
8 8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify 9 ;; GNU Emacs is free software; you can redistribute it and/or modify
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 GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA. 22 ;; Boston, MA 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
51 ;; All these overrides should go *before* the (require 'crisp) statement. 53 ;; All these overrides should go *before* the (require 'crisp) statement.
52 54
53 ;; local variables 55 ;; local variables
54 56
55 (defvar crisp-mode-map (copy-keymap (current-global-map)) 57 (defvar crisp-mode-map (copy-keymap (current-global-map))
56 "Local keymap for Crisp mode. 58 "Local keymap for CRiSP emulation mode.
57 All the bindings are done here instead of globally to try and be 59 All the bindings are done here instead of globally to try and be
58 nice to the world.") 60 nice to the world.")
59 61
60 (defvar crisp-mode-modeline-string " *Crisp*" 62 (defvar crisp-mode-modeline-string " *CRiSP*"
61 "String to display in the modeline when Crisp mode is enabled.") 63 "String to display in the modeline when CRiSP emulation mode is enabled.")
62 64
63 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map)) 65 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map))
64 "The original keymap before Crisp mode remaps anything. 66 "The original keymap before CRiSP emulation mode remaps anything.
65 This keymap is restored when Crisp mode is disabled.") 67 This keymap is restored when CRiSP emulation mode is disabled.")
66 68
67 (defvar crisp-mode-enabled 'nil 69 (defvar crisp-mode-enabled 'nil
68 "Track status of Crisp mode. 70 "Track status of CRiSP emulation mode.
69 A value of nil means Crisp mode is not enabled. A value of t 71 A value of nil means CRiSP mode is not enabled. A value of t
70 indicates Crisp mode is enabled.") 72 indicates CRiSP mode is enabled.")
71 73
72 (defvar crisp-override-meta-x 't 74 (defvar crisp-override-meta-x 't
73 "Controls overriding the normal Emacs M-x key binding. 75 "Controls overriding the normal Emacs M-x key binding in the CRiSP emulator.
74 The normal binding for M-x is `execute-extended-command', however 76 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs
75 the normal Crisp keybinding for M-x is to exit the editor, while 77 and provides the usual M-x functionality on the F10 key.
76 the F10 key is used to execute extended commands. If you don't 78
77 want M-x to dump you out of emacs, set this to nil before loading 79 If this variable is nil when you start the CRiSP emulator, it
78 the package.") 80 does not alter the binding of M-x.")
79 81
80 (defvar crisp-load-scroll-lock 't 82 (defvar crisp-load-scroll-lock 't
81 "Controls loading of the Scroll Lock minor mode package. 83 "Controls loading of the Scroll Lock in the CRiSP emulator.
82 Default behavior is to load the scroll lock minor mode 84 Its Default behavior is to load and enable the Scroll Lock minor mode
83 package when Crisp mode is enabled. Set to nil prior 85 package when enabling the CRiSP emulator.
84 to loading this package to prevent it.") 86
87 If this variable is nil when you start the CRiSP emulator, it
88 does not load Scroll Lock.")
85 89
86 (defvar crisp-load-hook nil 90 (defvar crisp-load-hook nil
87 "Hooks to run after Crisp mode is enabled.") 91 "Hooks to run after loadint the CRiSP emulator package.")
88 92
89 (defvar crisp-mode-running-xemacs (string-match "XEmacs\\Lucid" emacs-version)) 93 (defvar crisp-version "crisp.el release 1.1/$Revision: 1.2 $"
90 94 "The release number and RCS version for the CRiSP emulator.")
91 (if crisp-mode-running-xemacs 95
96 (if (string-match "XEmacs\\Lucid" emacs-version)
92 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string) 97 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string)
93 (or (assq 'crisp-mode-enabled minor-mode-alist) 98 (or (assq 'crisp-mode-enabled minor-mode-alist)
94 (setq minor-mode-alist 99 (setq minor-mode-alist
95 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) 100 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist))))
96 101
125 130
126 (define-key crisp-mode-map [(f10)] 'execute-extended-command) 131 (define-key crisp-mode-map [(f10)] 'execute-extended-command)
127 (define-key crisp-mode-map [(meta f10)] 'compile) 132 (define-key crisp-mode-map [(meta f10)] 'compile)
128 133
129 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) 134 (define-key crisp-mode-map [(SunF37)] 'kill-buffer)
130 (define-key crisp-mode-map [(kp_add)] 'x-copy-primary-selection) 135 (define-key crisp-mode-map [(kp-add)] 'x-copy-primary-selection)
131 (define-key crisp-mode-map [(kp_subtract)] 'x-kill-primary-selection) 136 (define-key crisp-mode-map [(kp-subtract)] 'x-kill-primary-selection)
132 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection) 137 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection)
133 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd 138 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd
134 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd 139 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd
135 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd 140 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd
136 141
137 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line))) 142 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line)))
138 (define-key crisp-mode-map [(meta e)] 'find-file) 143 (define-key crisp-mode-map [(meta e)] 'find-file)
139 (define-key crisp-mode-map [(meta g)] 'goto-line) 144 (define-key crisp-mode-map [(meta g)] 'goto-line)
140 (define-key crisp-mode-map [(meta h)] 'help) 145 (define-key crisp-mode-map [(meta h)] 'help)
141 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) 146 (define-key crisp-mode-map [(meta i)] 'overwrite-mode)
147 (define-key crisp-mode-map [(meta j)] 'bookmark-jump)
142 (define-key crisp-mode-map [(meta u)] 'advertised-undo) 148 (define-key crisp-mode-map [(meta u)] 'advertised-undo)
143 (define-key crisp-mode-map [(f14)] 'advertised-undo) 149 (define-key crisp-mode-map [(f14)] 'advertised-undo)
144 (define-key crisp-mode-map [(meta w)] 'save-buffer) 150 (define-key crisp-mode-map [(meta w)] 'save-buffer)
145 (if 151 (if
146 (eq crisp-override-meta-x 't) 152 (eq crisp-override-meta-x 't)
147 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs)) 153 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs))
154 (define-key crisp-mode-map [(meta ?0)] (lambda () (interactive) (bookmark-set "0")))
155 (define-key crisp-mode-map [(meta ?1)] (lambda () (interactive) (bookmark-set "1")))
156 (define-key crisp-mode-map [(meta ?2)] (lambda () (interactive) (bookmark-set "2")))
157 (define-key crisp-mode-map [(meta ?3)] (lambda () (interactive) (bookmark-set "3")))
158 (define-key crisp-mode-map [(meta ?4)] (lambda () (interactive) (bookmark-set "4")))
159 (define-key crisp-mode-map [(meta ?5)] (lambda () (interactive) (bookmark-set "5")))
160 (define-key crisp-mode-map [(meta ?6)] (lambda () (interactive) (bookmark-set "6")))
161 (define-key crisp-mode-map [(meta ?7)] (lambda () (interactive) (bookmark-set "7")))
162 (define-key crisp-mode-map [(meta ?8)] (lambda () (interactive) (bookmark-set "8")))
163 (define-key crisp-mode-map [(meta ?9)] (lambda () (interactive) (bookmark-set "9")))
148 164
149 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word) 165 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word)
150 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word) 166 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word)
151 (define-key crisp-mode-map [(shift delete)] 'kill-word) 167 (define-key crisp-mode-map [(shift delete)] 'kill-word)
152 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) 168 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word)
155 171
156 (define-key crisp-mode-map [(home)] 'crisp-home) 172 (define-key crisp-mode-map [(home)] 'crisp-home)
157 (define-key crisp-mode-map [(end)] 'crisp-end) 173 (define-key crisp-mode-map [(end)] 'crisp-end)
158 174
159 (defun crisp-home () 175 (defun crisp-home ()
160 "Home the point according to Crisp conventions. 176 "\"Home\" the point, the way CRiSP would do it.
161 First call to this moves point to beginning of the line. Second 177 The first use moves point to beginning of the line. Second
162 consecutive call moves point to beginning of the screen. Third 178 consecutive use moves point to beginning of the screen. Third
163 consecutive call moves the point to the beginning of the buffer." 179 consecutive use moves point to the beginning of the buffer."
164 (interactive nil) 180 (interactive nil)
165 (cond 181 (cond
166 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home)) 182 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home))
167 (goto-char (point-min))) 183 (goto-char (point-min)))
168 ((eq last-command 'crisp-home) 184 ((eq last-command 'crisp-home)
170 (t 186 (t
171 (beginning-of-line))) 187 (beginning-of-line)))
172 (setq last-last-command last-command)) 188 (setq last-last-command last-command))
173 189
174 (defun crisp-end () 190 (defun crisp-end ()
175 "End the point according to Crisp conventions. 191 "\"End\" the point, the way CRiSP would do it.
176 First call to this moves point to end of the line. Second 192 The first use moves point to end of the line. Second
177 consecutive call moves point to the end of the screen. Third 193 consecutive use moves point to the end of the screen. Third
178 consecutive call moves point to the end of the buffer." 194 consecutive use moves point to the end of the buffer."
179 (interactive nil) 195 (interactive nil)
180 (cond 196 (cond
181 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end)) 197 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end))
182 (goto-char (point-max))) 198 (goto-char (point-max)))
183 ((eq last-command 'crisp-end) 199 ((eq last-command 'crisp-end)
188 (setq last-last-command last-command)) 204 (setq last-last-command last-command))
189 205
190 ;; Now enable the mode 206 ;; Now enable the mode
191 207
192 (defun crisp-mode () 208 (defun crisp-mode ()
193 "Toggle Crisp minor mode." 209 "Toggle CRiSP emulation minor mode."
194 (interactive nil) 210 (interactive nil)
195 (setq crisp-mode-enabled (not crisp-mode-enabled)) 211 (setq crisp-mode-enabled (not crisp-mode-enabled))
196 (cond 212 (cond
197 ((eq crisp-mode-enabled 't) 213 ((eq crisp-mode-enabled 't)
198 (use-global-map crisp-mode-map) 214 (use-global-map crisp-mode-map)