Mercurial > emacs
comparison lisp/emulation/crisp.el @ 17448:b0fb37e0d14b
Install the proper version.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 14 Apr 1997 10:35:17 +0000 |
parents | ac4db12935d7 |
children | dd277f4e6737 |
comparison
equal
deleted
inserted
replaced
17447:dc2cb454b330 | 17448:b0fb37e0d14b |
---|---|
1 ;; crisp.el -- Emulator for CRiSP/Brief key bindings | 1 ;;; crisp.el --- Emulator for CRiSP and Brief key bindings |
2 | |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
2 | 4 |
3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com> | 5 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com> |
4 ;; Keywords: emulations brief crisp | 6 ;; Keywords: emulations |
5 | 7 |
6 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
7 | 9 |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
9 ;; it under the terms of the GNU General Public License as published by | 11 ;; it under the terms of the GNU General Public License as published by |
27 ;; package is designed to facilitate transitioning from Brief to Emacs | 29 ;; package is designed to facilitate transitioning from Brief to Emacs |
28 ;; with a minimum amount of hassles. | 30 ;; with a minimum amount of hassles. |
29 | 31 |
30 ;; Enable this package by putting the following in your .emacs | 32 ;; Enable this package by putting the following in your .emacs |
31 ;; (require 'crisp) | 33 ;; (require 'crisp) |
34 ;; and use M-x crisp-mode to toggle it on or off. | |
32 | 35 |
33 ;; This package will automatically default to loading the scroll-lock.el | 36 ;; This package will automatically default to loading the scroll-lock.el |
34 ;; package unless you put (setq crisp-load-scroll-lock nil) in your | 37 ;; package unless you put (setq crisp-load-scroll-lock nil) in your |
35 ;; .emacs. If this feature is enabled, it will bind meta-f1 to the | 38 ;; .emacs. If this feature is enabled, it will bind Meta-F1 to the |
36 ;; scroll-lock mode toggle. | 39 ;; scroll-lock mode toggle. |
37 | 40 |
38 ;; Also, the default keybindings for brief override the Meta-x key to | 41 ;; Also, the default keybindings for this mode override the Meta-x key to |
39 ;; exit the editor. If you don't like this functionality, you can | 42 ;; make it exit the editor. If you don't like this change, you can |
40 ;; prevent this key from being rebound with | 43 ;; prevent this key from being rebound with |
41 ;; (setq crisp-override-meta-x nil) in your .emacs. | 44 ;; (setq crisp-override-meta-x nil) in your .emacs. |
42 | 45 |
46 ;; Finally, if you want to change the string displayed in the modeline | |
47 ;; when this mode is in effect, override the definition of | |
48 ;; `crisp-mode-modeline-string' in your .emacs. The default value is | |
49 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things | |
50 ;; being displayed there. | |
51 | |
43 ;; All these overrides should go *before* the (require 'crisp) statement. | 52 ;; All these overrides should go *before* the (require 'crisp) statement. |
44 | 53 |
45 ;; local variables | 54 ;; local variables |
46 | 55 |
47 (defvar crisp-mode-map (copy-keymap (current-global-map)) | 56 (defvar crisp-mode-map (copy-keymap (current-global-map)) |
48 "Keymap for CRiSP emulation. | 57 "Local keymap for CRiSP emulation mode. |
49 All the emulation bindings are done here instead of globally.") | 58 All the emulation bindings are done here instead of globally.") |
59 | |
60 (defvar crisp-mode-modeline-string " *CRiSP*" | |
61 "String to display in the modeline when CRiSP emulation mode is enabled.") | |
62 | |
63 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map)) | |
64 "The original keymap before CRiSP emulation mode remaps anything. | |
65 This keymap is restored when CRiSP emulation mode is disabled.") | |
66 | |
67 (defvar crisp-mode-enabled nil | |
68 "Track status of CRiSP emulation mode. | |
69 A value of nil means CRiSP mode is not enabled. A value of t | |
70 indicates CRiSP mode is enabled.") | |
50 | 71 |
51 (defvar crisp-override-meta-x t | 72 (defvar crisp-override-meta-x t |
52 "Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. | 73 "Controls overriding the normal Emacs M-x key binding in the CRiSP emulator. |
53 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs | 74 Normally the CRiSP emulator rebinds M-x to save-buffers-exit-emacs |
54 and provides the usual M-x functionality on the F10 key. | 75 and provides the usual M-x functionality on the F10 key. |
55 | 76 |
56 If this variable is nil when you start the CRiSP emulator, it | 77 If this variable is nil when you start the CRiSP emulator, it |
57 does not alter the binding of M-x.") | 78 does not alter the binding of M-x.") |
58 | 79 |
59 (defvar crisp-load-scroll-lock t | 80 (defvar crisp-load-scroll-lock t |
60 "Controls loading of Scroll Lock in the CRiSP emulator. | 81 "Controls loading of the Scroll Lock in the CRiSP emulator. |
61 Its default behavior is to load and enable the Scroll Lock minor mode | 82 Its Default behavior is to load and enable the Scroll Lock minor mode |
62 package when enabling the CRiSP emulator. | 83 package when enabling the CRiSP emulator. |
63 | 84 |
64 If this variable is nil when you start the CRiSP emulator, it | 85 If this variable is nil when you start the CRiSP emulator, it |
65 does not load Scroll Lock.") | 86 does not load Scroll Lock.") |
66 | 87 |
67 (defvar crisp-load-hook nil | 88 (defvar crisp-load-hook nil |
68 "Hooks to run after loading the CRiSP emulator package.") | 89 "Hooks to run after loadint the CRiSP emulator package.") |
90 | |
91 (defvar crisp-version "crisp.el release 1.1/$Revision: 1.17 $" | |
92 "The release number and RCS version for the CRiSP emulator.") | |
93 | |
94 (if (string-match "XEmacs\\Lucid" emacs-version) | |
95 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string) | |
96 (or (assq 'crisp-mode-enabled minor-mode-alist) | |
97 (setq minor-mode-alist | |
98 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) | |
69 | 99 |
70 ;; and now the keymap defines | 100 ;; and now the keymap defines |
71 | 101 |
72 (define-key crisp-mode-map [(f1)] 'other-window) | 102 (define-key crisp-mode-map [(f1)] 'other-window) |
73 | 103 |
98 | 128 |
99 (define-key crisp-mode-map [(f10)] 'execute-extended-command) | 129 (define-key crisp-mode-map [(f10)] 'execute-extended-command) |
100 (define-key crisp-mode-map [(meta f10)] 'compile) | 130 (define-key crisp-mode-map [(meta f10)] 'compile) |
101 | 131 |
102 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) | 132 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) |
103 (define-key crisp-mode-map [(kp_add)] 'x-copy-primary-selection) | 133 (define-key crisp-mode-map [(kp-add)] 'x-copy-primary-selection) |
104 (define-key crisp-mode-map [(kp_subtract)] 'x-kill-primary-selection) | 134 (define-key crisp-mode-map [(kp-subtract)] 'x-kill-primary-selection) |
105 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection) | 135 (define-key crisp-mode-map [(insert)] 'x-yank-clipboard-selection) |
106 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd | 136 (define-key crisp-mode-map [(f16)] 'x-copy-primary-selection) ; copy on Sun5 kbd |
107 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd | 137 (define-key crisp-mode-map [(f20)] 'x-kill-primary-selection) ; cut on Sun5 kbd |
108 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd | 138 (define-key crisp-mode-map [(f18)] 'x-yank-clipboard-selection) ; paste on Sun5 kbd |
109 | 139 |
110 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line))) | 140 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line))) |
111 (define-key crisp-mode-map [(meta e)] 'find-file) | 141 (define-key crisp-mode-map [(meta e)] 'find-file) |
112 (define-key crisp-mode-map [(meta g)] 'goto-line) | 142 (define-key crisp-mode-map [(meta g)] 'goto-line) |
113 (define-key crisp-mode-map [(meta h)] 'help) | 143 (define-key crisp-mode-map [(meta h)] 'help) |
114 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) | 144 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) |
145 (define-key crisp-mode-map [(meta j)] 'bookmark-jump) | |
115 (define-key crisp-mode-map [(meta u)] 'advertised-undo) | 146 (define-key crisp-mode-map [(meta u)] 'advertised-undo) |
116 (define-key crisp-mode-map [(f14)] 'advertised-undo) | 147 (define-key crisp-mode-map [(f14)] 'advertised-undo) |
117 (define-key crisp-mode-map [(meta w)] 'save-buffer) | 148 (define-key crisp-mode-map [(meta w)] 'save-buffer) |
118 (if | 149 (if |
119 (eq crisp-override-meta-x 't) | 150 (eq crisp-override-meta-x 't) |
120 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs)) | 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"))) | |
153 (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"))) | |
155 (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"))) | |
157 (define-key crisp-mode-map [(meta ?5)] (lambda () (interactive) (bookmark-set "5"))) | |
158 (define-key crisp-mode-map [(meta ?6)] (lambda () (interactive) (bookmark-set "6"))) | |
159 (define-key crisp-mode-map [(meta ?7)] (lambda () (interactive) (bookmark-set "7"))) | |
160 (define-key crisp-mode-map [(meta ?8)] (lambda () (interactive) (bookmark-set "8"))) | |
161 (define-key crisp-mode-map [(meta ?9)] (lambda () (interactive) (bookmark-set "9"))) | |
121 | 162 |
122 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word) | 163 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word) |
123 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word) | 164 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word) |
124 (define-key crisp-mode-map [(shift delete)] 'kill-word) | 165 (define-key crisp-mode-map [(shift delete)] 'kill-word) |
125 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) | 166 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) |
127 (define-key crisp-mode-map [(control right)] 'forward-word) | 168 (define-key crisp-mode-map [(control right)] 'forward-word) |
128 | 169 |
129 (define-key crisp-mode-map [(home)] 'crisp-home) | 170 (define-key crisp-mode-map [(home)] 'crisp-home) |
130 (define-key crisp-mode-map [(end)] 'crisp-end) | 171 (define-key crisp-mode-map [(end)] 'crisp-end) |
131 | 172 |
132 | |
133 (defun crisp-home () | 173 (defun crisp-home () |
134 "\"Home\" the point, the way CRiSP would do it. | 174 "\"Home\" point, the way CRiSP would do it. |
135 The first use moves point to beginning of the line. Second | 175 The first use moves point to beginning of the line. Second |
136 consecutive use moves point to beginning of the screen. Third | 176 consecutive use moves point to beginning of the screen. Third |
137 consecutive use moves point to the beginning of the buffer." | 177 consecutive use moves point to the beginning of the buffer." |
138 (interactive nil) | 178 (interactive nil) |
139 (cond | 179 (cond |
140 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home)) | 180 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home)) |
141 (goto-char (point-min)) | 181 (goto-char (point-min))) |
142 ) | |
143 ((eq last-command 'crisp-home) | 182 ((eq last-command 'crisp-home) |
144 (move-to-window-line 0) | 183 (move-to-window-line 0)) |
145 ) | |
146 (t | 184 (t |
147 (beginning-of-line) | 185 (beginning-of-line))) |
148 ) | 186 (setq last-last-command last-command)) |
149 ) | |
150 (setq last-last-command last-command) | |
151 ) | |
152 | 187 |
153 (defun crisp-end () | 188 (defun crisp-end () |
154 "\"End\" the point, the way CRiSP would do it. | 189 "\"End\" point, the way CRiSP would do it. |
155 The first use moves point to end of the line. Second | 190 The first use moves point to end of the line. Second |
156 consecutive use moves point to the end of the screen. Third | 191 consecutive use moves point to the end of the screen. Third |
157 consecutive use moves point to the end of the buffer." | 192 consecutive use moves point to the end of the buffer." |
158 (interactive nil) | 193 (interactive nil) |
159 (cond | 194 (cond |
160 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end)) | 195 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end)) |
161 (goto-char (point-max)) | 196 (goto-char (point-max))) |
162 ) | |
163 ((eq last-command 'crisp-end) | 197 ((eq last-command 'crisp-end) |
164 (move-to-window-line -1) | 198 (move-to-window-line -1) |
165 (end-of-line) | 199 (end-of-line)) |
166 ) | |
167 (t | 200 (t |
168 (end-of-line) | 201 (end-of-line))) |
169 ) | 202 (setq last-last-command last-command)) |
170 ) | |
171 (setq last-last-command last-command) | |
172 ) | |
173 | 203 |
174 ;; Now enable the mode | 204 ;; Now enable the mode |
175 | 205 |
176 (kill-all-local-variables) | 206 (defun crisp-mode () |
177 (use-global-map crisp-mode-map) | 207 "Toggle CRiSP emulation minor mode." |
178 | 208 (interactive nil) |
179 (if (eq crisp-load-scroll-lock t) | 209 (setq crisp-mode-enabled (not crisp-mode-enabled)) |
180 (require 'scroll-lock)) | 210 (cond |
181 | 211 ((eq crisp-mode-enabled 't) |
182 (if (featurep 'scroll-lock) | 212 (use-global-map crisp-mode-map) |
183 (define-key crisp-mode-map [(meta f1)] 'scroll-lock-mode)) | 213 (if crisp-load-scroll-lock |
184 | 214 (require 'scroll-lock)) |
185 (run-hooks 'crisp-load-hook) ;; allow for hooks | 215 (if (featurep 'scroll-lock) |
216 (define-key crisp-mode-map [(meta f1)] 'scroll-lock-mode)) | |
217 (run-hooks 'crisp-load-hook)) | |
218 ((eq crisp-mode-enabled 'nil) | |
219 (use-global-map crisp-mode-original-keymap)))) | |
186 | 220 |
187 (provide 'crisp) | 221 (provide 'crisp) |
188 | 222 |
189 ;;; crisp.el ends here | 223 ;;; crisp.el ends here |
224 | |
225 |