17361
|
1 ;; crisp.el -- Emulator for CRiSP/Brief key bindings
|
|
2
|
|
3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com>
|
|
4 ;; Keywords: emulations brief crisp
|
|
5
|
|
6 ;; This file is part of GNU Emacs.
|
|
7
|
|
8 ;; 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
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 ;; GNU General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 ;; Boston, MA 02111-1307, USA.
|
|
22
|
|
23 ;;; Commentary:
|
|
24
|
|
25 ;; This file provides keybindings and minor functions to duplicate the
|
|
26 ;; functionality and finger-feel of the CRiSP/Brief editor. This
|
|
27 ;; package is designed to facilitate transitioning from Brief to Emacs
|
|
28 ;; with a minimum amount of hassles.
|
|
29
|
|
30 ;; Enable this package by putting the following in your .emacs
|
|
31 ;; (require 'crisp)
|
|
32
|
|
33 ;; This package will automatically default to loading the scroll-lock.el
|
|
34 ;; 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
|
|
36 ;; scroll-lock mode toggle.
|
|
37
|
|
38 ;; Also, the default keybindings for brief override the Meta-x key to
|
|
39 ;; exit the editor. If you don't like this functionality, you can
|
|
40 ;; prevent this key from being rebound with
|
|
41 ;; (setq crisp-override-meta-x nil) in your .emacs.
|
|
42
|
|
43 ;; All these overrides should go *before* the (require 'crisp) statement.
|
|
44
|
|
45 ;; local variables
|
|
46
|
|
47 (defvar crisp-mode-map (copy-keymap (current-global-map))
|
|
48 "Keymap for CRiSP emulation.
|
|
49 All the emulation bindings are done here instead of globally.")
|
|
50
|
|
51 (defvar crisp-override-meta-x t
|
|
52 "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
|
|
54 and provides the usual M-x functionality on the F10 key.
|
|
55
|
|
56 If this variable is nil when you start the CRiSP emulator, it
|
|
57 does not alter the binding of M-x.")
|
|
58
|
|
59 (defvar crisp-load-scroll-lock t
|
|
60 "Controls loading of Scroll Lock in the CRiSP emulator.
|
|
61 Its default behavior is to load and enable the Scroll Lock minor mode
|
|
62 package when enabling the CRiSP emulator.
|
|
63
|
|
64 If this variable is nil when you start the CRiSP emulator, it
|
|
65 does not load Scroll Lock.")
|
|
66
|
|
67 (defvar crisp-load-hook nil
|
|
68 "Hooks to run after loading the CRiSP emulator package.")
|
|
69
|
|
70 ;; and now the keymap defines
|
|
71
|
|
72 (define-key crisp-mode-map [(f1)] 'other-window)
|
|
73
|
|
74 (define-key crisp-mode-map [(f2) (down)] 'enlarge-window)
|
|
75 (define-key crisp-mode-map [(f2) (left)] 'shrink-window-horizontally)
|
|
76 (define-key crisp-mode-map [(f2) (right)] 'enlarge-window-horizontally)
|
|
77 (define-key crisp-mode-map [(f2) (up)] 'shrink-window)
|
|
78 (define-key crisp-mode-map [(f3) (down)] 'split-window-vertically)
|
|
79 (define-key crisp-mode-map [(f3) (right)] 'split-window-horizontally)
|
|
80
|
|
81 (define-key crisp-mode-map [(f4)] 'delete-window)
|
|
82 (define-key crisp-mode-map [(control f4)] 'delete-other-windows)
|
|
83
|
|
84 (define-key crisp-mode-map [(f5)] 'search-forward-regexp)
|
|
85 (define-key crisp-mode-map [(f19)] 'search-forward-regexp)
|
|
86 (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp)
|
|
87
|
|
88 (define-key crisp-mode-map [(f6)] 'query-replace)
|
|
89
|
|
90 (define-key crisp-mode-map [(f7)] 'start-kbd-macro)
|
|
91 (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro)
|
|
92
|
|
93 (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro)
|
|
94 (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro)
|
|
95
|
|
96 (define-key crisp-mode-map [(f9)] 'find-file)
|
|
97 (define-key crisp-mode-map [(meta f9)] 'load-library)
|
|
98
|
|
99 (define-key crisp-mode-map [(f10)] 'execute-extended-command)
|
|
100 (define-key crisp-mode-map [(meta f10)] 'compile)
|
|
101
|
|
102 (define-key crisp-mode-map [(SunF37)] 'kill-buffer)
|
|
103 (define-key crisp-mode-map [(kp_add)] 'x-copy-primary-selection)
|
|
104 (define-key crisp-mode-map [(kp_subtract)] 'x-kill-primary-selection)
|
|
105 (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
|
|
107 (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
|
|
109
|
|
110 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line)))
|
|
111 (define-key crisp-mode-map [(meta e)] 'find-file)
|
|
112 (define-key crisp-mode-map [(meta g)] 'goto-line)
|
|
113 (define-key crisp-mode-map [(meta h)] 'help)
|
|
114 (define-key crisp-mode-map [(meta i)] 'overwrite-mode)
|
|
115 (define-key crisp-mode-map [(meta u)] 'advertised-undo)
|
|
116 (define-key crisp-mode-map [(f14)] 'advertised-undo)
|
|
117 (define-key crisp-mode-map [(meta w)] 'save-buffer)
|
|
118 (if
|
|
119 (eq crisp-override-meta-x 't)
|
|
120 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs))
|
|
121
|
|
122 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word)
|
|
123 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word)
|
|
124 (define-key crisp-mode-map [(shift delete)] 'kill-word)
|
|
125 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word)
|
|
126 (define-key crisp-mode-map [(control left)] 'backward-word)
|
|
127 (define-key crisp-mode-map [(control right)] 'forward-word)
|
|
128
|
|
129 (define-key crisp-mode-map [(home)] 'crisp-home)
|
|
130 (define-key crisp-mode-map [(end)] 'crisp-end)
|
|
131
|
|
132
|
|
133 (defun crisp-home ()
|
|
134 "\"Home\" the point, the way CRiSP would do it.
|
|
135 The first use moves point to beginning of the line. Second
|
|
136 consecutive use moves point to beginning of the screen. Third
|
|
137 consecutive use moves point to the beginning of the buffer."
|
|
138 (interactive nil)
|
|
139 (cond
|
|
140 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home))
|
|
141 (goto-char (point-min))
|
|
142 )
|
|
143 ((eq last-command 'crisp-home)
|
|
144 (move-to-window-line 0)
|
|
145 )
|
|
146 (t
|
|
147 (beginning-of-line)
|
|
148 )
|
|
149 )
|
|
150 (setq last-last-command last-command)
|
|
151 )
|
|
152
|
|
153 (defun crisp-end ()
|
|
154 "\"End\" the point, the way CRiSP would do it.
|
|
155 The first use moves point to end of the line. Second
|
|
156 consecutive use moves point to the end of the screen. Third
|
|
157 consecutive use moves point to the end of the buffer."
|
|
158 (interactive nil)
|
|
159 (cond
|
|
160 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end))
|
|
161 (goto-char (point-max))
|
|
162 )
|
|
163 ((eq last-command 'crisp-end)
|
|
164 (move-to-window-line -1)
|
|
165 (end-of-line)
|
|
166 )
|
|
167 (t
|
|
168 (end-of-line)
|
|
169 )
|
|
170 )
|
|
171 (setq last-last-command last-command)
|
|
172 )
|
|
173
|
|
174 ;; Now enable the mode
|
|
175
|
|
176 (kill-all-local-variables)
|
|
177 (use-global-map crisp-mode-map)
|
|
178
|
|
179 (if (eq crisp-load-scroll-lock t)
|
|
180 (require 'scroll-lock))
|
|
181
|
|
182 (if (featurep 'scroll-lock)
|
|
183 (define-key crisp-mode-map [(meta f1)] 'scroll-lock-mode))
|
|
184
|
|
185 (run-hooks 'crisp-load-hook) ;; allow for hooks
|
|
186
|
|
187 (provide 'crisp)
|
|
188
|
17367
|
189 ;;; crisp.el ends here
|