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