120
|
1 ;; @(#) crisp.el -- CRiSP/Brief Emacs emulator
|
4
|
2
|
|
3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com>
|
185
|
4 ;; Created: 01 Mar 1996
|
|
5 ;; Version: 1.20
|
4
|
6 ;; Keywords: emulations brief crisp
|
185
|
7 ;; X-Modified-by:
|
|
8 ;; crisp.el,v
|
|
9 ;; Revision 1.20 1997/08/22 18:49:11 gfoster
|
|
10 ;; Added next-buffer/previous-buffer keybindings (bound to M-n/M-p)
|
|
11 ;; Added crisp-unbury-buffer function
|
|
12 ;; Standardized headers for Steve
|
|
13 ;;
|
4
|
14
|
173
|
15 ;; This file is part of XEmacs.
|
4
|
16
|
173
|
17 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
18 ;; under the terms of the GNU General Public License as published by
|
4
|
19 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
20 ;; any later version.
|
|
21
|
173
|
22 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
23 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 ;; General Public License for more details.
|
4
|
26
|
|
27 ;; You should have received a copy of the GNU General Public License
|
173
|
28 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
29 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
30 ;; 02111-1307, USA.
|
|
31
|
|
32 ;; CRiSP is a registered trademark of Foxtrot Systems Ltd.
|
4
|
33
|
|
34 ;;; Commentary:
|
|
35
|
|
36 ;; Keybindings and minor functions to duplicate the functionality and
|
173
|
37 ;; finger-feel of the CRiSP/Brief editor. This package is designed to
|
4
|
38 ;; facilitate transitioning from Brief to (XE|E)macs with a minimum
|
|
39 ;; amount of hassles.
|
|
40
|
173
|
41 ;; Enable this package by putting (require 'crisp) in your .emacs and
|
|
42 ;; use M-x crisp-mode to toggle it on or off.
|
4
|
43
|
173
|
44 ;; This package will automatically load the scroll-lock.el package if
|
|
45 ;; you put (setq crisp-load-scroll-lock t) in your .emacs before
|
|
46 ;; loading this package. If this feature is enabled, it will bind
|
|
47 ;; meta-f1 to the scroll-lock mode toggle. The scroll-lock package
|
|
48 ;; duplicates the scroll-locking feature in CRiSP.
|
4
|
49
|
173
|
50 ;; Also, the default keybindings for brief/CRiSP override the M-x
|
|
51 ;; key to exit the editor. If you don't like this functionality, you
|
|
52 ;; can prevent this behavior (or redefine it dynamically) by setting
|
|
53 ;; the value of `crisp-override-meta-x' either in your .emacs or
|
|
54 ;; interactively. The default setting is nil, which means that M-x will
|
|
55 ;; by default run `execute-extended-command' instead of the command
|
|
56 ;; `save-buffers-kill-emacs'.
|
4
|
57
|
|
58 ;; Finally, if you want to change the string displayed in the modeline
|
|
59 ;; when this mode is in effect, override the definition of
|
|
60 ;; `crisp-mode-modeline-string' in your .emacs. The default value is
|
|
61 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things
|
|
62 ;; being displayed there.
|
|
63
|
|
64 ;; All these overrides should go *before* the (require 'crisp) statement.
|
|
65
|
185
|
66 ;; Code:
|
|
67
|
|
68 (require 'cl)
|
|
69
|
4
|
70 ;; local variables
|
|
71
|
173
|
72 (defgroup emulations-crisp nil
|
|
73 "CRiSP emulator customizable settings."
|
|
74 :group 'emulations)
|
|
75
|
4
|
76 (defvar crisp-mode-map (copy-keymap (current-global-map))
|
124
|
77 "Local keymap for CRiSP emulation mode.
|
4
|
78 All the bindings are done here instead of globally to try and be
|
|
79 nice to the world.")
|
|
80
|
173
|
81 (defcustom crisp-mode-modeline-string " *CRiSP*"
|
|
82 "*String to display in the modeline when CRiSP emulation mode is enabled."
|
|
83 :type 'string
|
|
84 :group 'emulations-crisp)
|
4
|
85
|
|
86 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map))
|
124
|
87 "The original keymap before CRiSP emulation mode remaps anything.
|
|
88 This keymap is restored when CRiSP emulation mode is disabled.")
|
4
|
89
|
173
|
90 (defvar crisp-mode-enabled nil
|
124
|
91 "Track status of CRiSP emulation mode.
|
120
|
92 A value of nil means CRiSP mode is not enabled. A value of t
|
|
93 indicates CRiSP mode is enabled.")
|
4
|
94
|
173
|
95 (defcustom crisp-override-meta-x t
|
|
96 "*Controls overriding the normal Emacs M-x key binding in the CRiSP emulator.
|
|
97 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs and
|
|
98 provides the usual M-x functionality on the F10 key. If this variable
|
|
99 is non-nil, M-x will exit Emacs."
|
|
100 :type 'boolean
|
|
101 :group 'emulations-crisp)
|
124
|
102
|
173
|
103 (defvar crisp-load-scroll-lock nil
|
124
|
104 "Controls loading of the Scroll Lock in the CRiSP emulator.
|
|
105 Its Default behavior is to load and enable the Scroll Lock minor mode
|
|
106 package when enabling the CRiSP emulator.
|
|
107
|
|
108 If this variable is nil when you start the CRiSP emulator, it
|
173
|
109 does not load the scroll-lock package.")
|
4
|
110
|
|
111 (defvar crisp-load-hook nil
|
173
|
112 "Hooks to run after loading the CRiSP emulator package.")
|
4
|
113
|
185
|
114 (defconst crisp-version "crisp.el release 1.1/1.20"
|
124
|
115 "The release number and RCS version for the CRiSP emulator.")
|
4
|
116
|
124
|
117 (if (string-match "XEmacs\\Lucid" emacs-version)
|
4
|
118 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string)
|
|
119 (or (assq 'crisp-mode-enabled minor-mode-alist)
|
|
120 (setq minor-mode-alist
|
|
121 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist))))
|
|
122
|
|
123 ;; and now the keymap defines
|
|
124
|
|
125 (define-key crisp-mode-map [(f1)] 'other-window)
|
|
126
|
|
127 (define-key crisp-mode-map [(f2) (down)] 'enlarge-window)
|
|
128 (define-key crisp-mode-map [(f2) (left)] 'shrink-window-horizontally)
|
|
129 (define-key crisp-mode-map [(f2) (right)] 'enlarge-window-horizontally)
|
|
130 (define-key crisp-mode-map [(f2) (up)] 'shrink-window)
|
|
131 (define-key crisp-mode-map [(f3) (down)] 'split-window-vertically)
|
|
132 (define-key crisp-mode-map [(f3) (right)] 'split-window-horizontally)
|
|
133
|
|
134 (define-key crisp-mode-map [(f4)] 'delete-window)
|
|
135 (define-key crisp-mode-map [(control f4)] 'delete-other-windows)
|
|
136
|
|
137 (define-key crisp-mode-map [(f5)] 'search-forward-regexp)
|
|
138 (define-key crisp-mode-map [(f19)] 'search-forward-regexp)
|
|
139 (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp)
|
|
140
|
|
141 (define-key crisp-mode-map [(f6)] 'query-replace)
|
|
142
|
|
143 (define-key crisp-mode-map [(f7)] 'start-kbd-macro)
|
|
144 (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro)
|
|
145
|
|
146 (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro)
|
|
147 (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro)
|
|
148
|
|
149 (define-key crisp-mode-map [(f9)] 'find-file)
|
|
150 (define-key crisp-mode-map [(meta f9)] 'load-library)
|
|
151
|
|
152 (define-key crisp-mode-map [(f10)] 'execute-extended-command)
|
|
153 (define-key crisp-mode-map [(meta f10)] 'compile)
|
|
154
|
|
155 (define-key crisp-mode-map [(SunF37)] 'kill-buffer)
|
74
|
156 (define-key crisp-mode-map [(kp-add)] 'x-copy-primary-selection)
|
|
157 (define-key crisp-mode-map [(kp-subtract)] 'x-kill-primary-selection)
|
4
|
158 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection)
|
|
159 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd
|
|
160 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd
|
|
161 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd
|
|
162
|
|
163 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line)))
|
|
164 (define-key crisp-mode-map [(meta e)] 'find-file)
|
|
165 (define-key crisp-mode-map [(meta g)] 'goto-line)
|
|
166 (define-key crisp-mode-map [(meta h)] 'help)
|
|
167 (define-key crisp-mode-map [(meta i)] 'overwrite-mode)
|
124
|
168 (define-key crisp-mode-map [(meta j)] 'bookmark-jump)
|
185
|
169 (define-key crisp-mode-map [(meta n)] 'bury-buffer)
|
|
170 (define-key crisp-mode-map [(meta p)] 'crisp-unbury-buffer)
|
4
|
171 (define-key crisp-mode-map [(meta u)] 'advertised-undo)
|
|
172 (define-key crisp-mode-map [(f14)] 'advertised-undo)
|
|
173 (define-key crisp-mode-map [(meta w)] 'save-buffer)
|
173
|
174 (define-key crisp-mode-map [(meta x)] 'crisp-meta-x-wrapper)
|
124
|
175 (define-key crisp-mode-map [(meta ?0)] (lambda () (interactive) (bookmark-set "0")))
|
|
176 (define-key crisp-mode-map [(meta ?1)] (lambda () (interactive) (bookmark-set "1")))
|
|
177 (define-key crisp-mode-map [(meta ?2)] (lambda () (interactive) (bookmark-set "2")))
|
|
178 (define-key crisp-mode-map [(meta ?3)] (lambda () (interactive) (bookmark-set "3")))
|
|
179 (define-key crisp-mode-map [(meta ?4)] (lambda () (interactive) (bookmark-set "4")))
|
|
180 (define-key crisp-mode-map [(meta ?5)] (lambda () (interactive) (bookmark-set "5")))
|
|
181 (define-key crisp-mode-map [(meta ?6)] (lambda () (interactive) (bookmark-set "6")))
|
|
182 (define-key crisp-mode-map [(meta ?7)] (lambda () (interactive) (bookmark-set "7")))
|
|
183 (define-key crisp-mode-map [(meta ?8)] (lambda () (interactive) (bookmark-set "8")))
|
|
184 (define-key crisp-mode-map [(meta ?9)] (lambda () (interactive) (bookmark-set "9")))
|
4
|
185
|
|
186 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word)
|
|
187 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word)
|
|
188 (define-key crisp-mode-map [(shift delete)] 'kill-word)
|
|
189 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word)
|
|
190 (define-key crisp-mode-map [(control left)] 'backward-word)
|
|
191 (define-key crisp-mode-map [(control right)] 'forward-word)
|
|
192
|
|
193 (define-key crisp-mode-map [(home)] 'crisp-home)
|
|
194 (define-key crisp-mode-map [(end)] 'crisp-end)
|
|
195
|
|
196 (defun crisp-home ()
|
124
|
197 "\"Home\" the point, the way CRiSP would do it.
|
|
198 The first use moves point to beginning of the line. Second
|
|
199 consecutive use moves point to beginning of the screen. Third
|
|
200 consecutive use moves point to the beginning of the buffer."
|
4
|
201 (interactive nil)
|
|
202 (cond
|
|
203 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home))
|
|
204 (goto-char (point-min)))
|
|
205 ((eq last-command 'crisp-home)
|
|
206 (move-to-window-line 0))
|
|
207 (t
|
|
208 (beginning-of-line)))
|
|
209 (setq last-last-command last-command))
|
|
210
|
|
211 (defun crisp-end ()
|
124
|
212 "\"End\" the point, the way CRiSP would do it.
|
|
213 The first use moves point to end of the line. Second
|
|
214 consecutive use moves point to the end of the screen. Third
|
|
215 consecutive use moves point to the end of the buffer."
|
4
|
216 (interactive nil)
|
|
217 (cond
|
|
218 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end))
|
|
219 (goto-char (point-max)))
|
|
220 ((eq last-command 'crisp-end)
|
|
221 (move-to-window-line -1)
|
|
222 (end-of-line))
|
|
223 (t
|
|
224 (end-of-line)))
|
|
225 (setq last-last-command last-command))
|
|
226
|
185
|
227 (defun crisp-unbury-buffer ()
|
|
228 "Go back one buffer"
|
|
229 (interactive)
|
|
230 (switch-to-buffer (car (last (buffer-list)))))
|
|
231
|
173
|
232 (defun crisp-meta-x-wrapper ()
|
|
233 "Wrapper function to conditionally override the normal M-x bindings.
|
|
234 When `crisp-override-meta-x' is non-nil, M-x will exit Emacs (the
|
|
235 normal CRiSP binding) and when it is nil M-x will run
|
|
236 `execute-extended-command' (the normal Emacs binding)."
|
|
237 (interactive)
|
|
238 (if crisp-override-meta-x
|
|
239 (save-buffers-kill-emacs)
|
|
240 (call-interactively 'execute-extended-command)))
|
|
241
|
4
|
242 ;; Now enable the mode
|
|
243
|
|
244 (defun crisp-mode ()
|
124
|
245 "Toggle CRiSP emulation minor mode."
|
4
|
246 (interactive nil)
|
|
247 (setq crisp-mode-enabled (not crisp-mode-enabled))
|
|
248 (cond
|
|
249 ((eq crisp-mode-enabled 't)
|
|
250 (use-global-map crisp-mode-map)
|
|
251 (if crisp-load-scroll-lock
|
|
252 (require 'scroll-lock))
|
|
253 (if (featurep 'scroll-lock)
|
|
254 (define-key crisp-mode-map [(meta f1)] 'scroll-lock-mode))
|
|
255 (run-hooks 'crisp-load-hook))
|
|
256 ((eq crisp-mode-enabled 'nil)
|
|
257 (use-global-map crisp-mode-original-keymap))))
|
|
258
|
|
259 (provide 'crisp)
|
|
260
|
|
261 ;;; crisp.el ends here
|