Mercurial > hg > xemacs-beta
comparison lisp/emulators/crisp.el @ 4:b82b59fe008d r19-15b3
Import from CVS: tag r19-15b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:56 +0200 |
parents | |
children | 56c54cf7c5b6 54cc21c15cbb |
comparison
equal
deleted
inserted
replaced
3:30df88044ec6 | 4:b82b59fe008d |
---|---|
1 ;; @(#) crisp.el -- Crisp/Brief Emacs emulator | |
2 | |
3 ;; Author: Gary D. Foster <Gary.Foster@corp.sun.com> | |
4 ;; $Revision: 1.1.1.1 $ | |
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 | |
24 ;;; Commentary: | |
25 | |
26 ;; Keybindings and minor functions to duplicate the functionality and | |
27 ;; finger-feel of the Crisp/Brief editor. This package is designed to | |
28 ;; facilitate transitioning from Brief to (XE|E)macs with a minimum | |
29 ;; amount of hassles. | |
30 | |
31 ;; Enable this package by putting the following in your .emacs | |
32 ;; (require 'crisp) | |
33 ;; and use M-x crisp-mode to toggle it on or off. | |
34 | |
35 ;; This package will automatically default to loading the scroll-lock.el | |
36 ;; package unless you put (setq crisp-load-scroll-lock nil) in your | |
37 ;; .emacs. If this feature is enabled, it will bind meta-f1 to the | |
38 ;; scroll-lock mode toggle. | |
39 | |
40 ;; Also, the default keybindings for brief override the meta-x key to | |
41 ;; exit the editor. If you don't like this functionality, you can | |
42 ;; prevent this key from being rebound with | |
43 ;; (setq crisp-override-meta-x nil) in your .emacs. | |
44 | |
45 ;; Finally, if you want to change the string displayed in the modeline | |
46 ;; when this mode is in effect, override the definition of | |
47 ;; `crisp-mode-modeline-string' in your .emacs. The default value is | |
48 ;; " *Crisp*" which may be a bit lengthy if you have a lot of things | |
49 ;; being displayed there. | |
50 | |
51 ;; All these overrides should go *before* the (require 'crisp) statement. | |
52 | |
53 ;; local variables | |
54 | |
55 (defvar crisp-mode-map (copy-keymap (current-global-map)) | |
56 "Local keymap for Crisp mode. | |
57 All the bindings are done here instead of globally to try and be | |
58 nice to the world.") | |
59 | |
60 (defvar crisp-mode-modeline-string " *Crisp*" | |
61 "String to display in the modeline when Crisp mode is enabled.") | |
62 | |
63 (defvar crisp-mode-original-keymap (copy-keymap (current-global-map)) | |
64 "The original keymap before Crisp mode remaps anything. | |
65 This keymap is restored when Crisp mode is disabled.") | |
66 | |
67 (defvar crisp-mode-enabled 'nil | |
68 "Track status of Crisp mode. | |
69 A value of nil means Crisp mode is not enabled. A value of t | |
70 indicates Crisp mode is enabled.") | |
71 | |
72 (defvar crisp-override-meta-x 't | |
73 "Controls overriding the normal Emacs M-x key binding. | |
74 The normal binding for M-x is `execute-extended-command', however | |
75 the normal Crisp keybinding for M-x is to exit the editor, while | |
76 the F10 key is used to execute extended commands. If you don't | |
77 want M-x to dump you out of emacs, set this to nil before loading | |
78 the package.") | |
79 | |
80 (defvar crisp-load-scroll-lock 't | |
81 "Controls loading of the Scroll Lock minor mode package. | |
82 Default behavior is to load the scroll lock minor mode | |
83 package when Crisp mode is enabled. Set to nil prior | |
84 to loading this package to prevent it.") | |
85 | |
86 (defvar crisp-load-hook nil | |
87 "Hooks to run after Crisp mode is enabled.") | |
88 | |
89 (defvar crisp-mode-running-xemacs (string-match "XEmacs\\Lucid" emacs-version)) | |
90 | |
91 (if crisp-mode-running-xemacs | |
92 (add-minor-mode 'crisp-mode-enabled crisp-mode-modeline-string) | |
93 (or (assq 'crisp-mode-enabled minor-mode-alist) | |
94 (setq minor-mode-alist | |
95 (cons '(crisp-mode-enabled crisp-mode-modeline-string) minor-mode-alist)))) | |
96 | |
97 ;; and now the keymap defines | |
98 | |
99 (define-key crisp-mode-map [(f1)] 'other-window) | |
100 | |
101 (define-key crisp-mode-map [(f2) (down)] 'enlarge-window) | |
102 (define-key crisp-mode-map [(f2) (left)] 'shrink-window-horizontally) | |
103 (define-key crisp-mode-map [(f2) (right)] 'enlarge-window-horizontally) | |
104 (define-key crisp-mode-map [(f2) (up)] 'shrink-window) | |
105 (define-key crisp-mode-map [(f3) (down)] 'split-window-vertically) | |
106 (define-key crisp-mode-map [(f3) (right)] 'split-window-horizontally) | |
107 | |
108 (define-key crisp-mode-map [(f4)] 'delete-window) | |
109 (define-key crisp-mode-map [(control f4)] 'delete-other-windows) | |
110 | |
111 (define-key crisp-mode-map [(f5)] 'search-forward-regexp) | |
112 (define-key crisp-mode-map [(f19)] 'search-forward-regexp) | |
113 (define-key crisp-mode-map [(meta f5)] 'search-backward-regexp) | |
114 | |
115 (define-key crisp-mode-map [(f6)] 'query-replace) | |
116 | |
117 (define-key crisp-mode-map [(f7)] 'start-kbd-macro) | |
118 (define-key crisp-mode-map [(meta f7)] 'end-kbd-macro) | |
119 | |
120 (define-key crisp-mode-map [(f8)] 'call-last-kbd-macro) | |
121 (define-key crisp-mode-map [(meta f8)] 'save-kbd-macro) | |
122 | |
123 (define-key crisp-mode-map [(f9)] 'find-file) | |
124 (define-key crisp-mode-map [(meta f9)] 'load-library) | |
125 | |
126 (define-key crisp-mode-map [(f10)] 'execute-extended-command) | |
127 (define-key crisp-mode-map [(meta f10)] 'compile) | |
128 | |
129 (define-key crisp-mode-map [(SunF37)] 'kill-buffer) | |
130 (define-key crisp-mode-map [(kp_add)] 'x-copy-primary-selection) | |
131 (define-key crisp-mode-map [(kp_subtract)] 'x-kill-primary-selection) | |
132 (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 | |
134 (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 | |
136 | |
137 (define-key crisp-mode-map [(meta d)] (lambda () (interactive) (beginning-of-line) (kill-line))) | |
138 (define-key crisp-mode-map [(meta e)] 'find-file) | |
139 (define-key crisp-mode-map [(meta g)] 'goto-line) | |
140 (define-key crisp-mode-map [(meta h)] 'help) | |
141 (define-key crisp-mode-map [(meta i)] 'overwrite-mode) | |
142 (define-key crisp-mode-map [(meta u)] 'advertised-undo) | |
143 (define-key crisp-mode-map [(f14)] 'advertised-undo) | |
144 (define-key crisp-mode-map [(meta w)] 'save-buffer) | |
145 (if | |
146 (eq crisp-override-meta-x 't) | |
147 (define-key crisp-mode-map [(meta x)] 'save-buffers-kill-emacs)) | |
148 | |
149 (define-key crisp-mode-map [(shift right)] 'fkey-forward-word) | |
150 (define-key crisp-mode-map [(shift left)] 'fkey-backward-word) | |
151 (define-key crisp-mode-map [(shift delete)] 'kill-word) | |
152 (define-key crisp-mode-map [(shift backspace)] 'backward-kill-word) | |
153 (define-key crisp-mode-map [(control left)] 'backward-word) | |
154 (define-key crisp-mode-map [(control right)] 'forward-word) | |
155 | |
156 (define-key crisp-mode-map [(home)] 'crisp-home) | |
157 (define-key crisp-mode-map [(end)] 'crisp-end) | |
158 | |
159 (defun crisp-home () | |
160 "Home the point according to Crisp conventions. | |
161 First call to this moves point to beginning of the line. Second | |
162 consecutive call moves point to beginning of the screen. Third | |
163 consecutive call moves the point to the beginning of the buffer." | |
164 (interactive nil) | |
165 (cond | |
166 ((and (eq last-command 'crisp-home) (eq last-last-command 'crisp-home)) | |
167 (goto-char (point-min))) | |
168 ((eq last-command 'crisp-home) | |
169 (move-to-window-line 0)) | |
170 (t | |
171 (beginning-of-line))) | |
172 (setq last-last-command last-command)) | |
173 | |
174 (defun crisp-end () | |
175 "End the point according to Crisp conventions. | |
176 First call to this moves point to end of the line. Second | |
177 consecutive call moves point to the end of the screen. Third | |
178 consecutive call moves point to the end of the buffer." | |
179 (interactive nil) | |
180 (cond | |
181 ((and (eq last-command 'crisp-end) (eq last-last-command 'crisp-end)) | |
182 (goto-char (point-max))) | |
183 ((eq last-command 'crisp-end) | |
184 (move-to-window-line -1) | |
185 (end-of-line)) | |
186 (t | |
187 (end-of-line))) | |
188 (setq last-last-command last-command)) | |
189 | |
190 ;; Now enable the mode | |
191 | |
192 (defun crisp-mode () | |
193 "Toggle Crisp minor mode." | |
194 (interactive nil) | |
195 (setq crisp-mode-enabled (not crisp-mode-enabled)) | |
196 (cond | |
197 ((eq crisp-mode-enabled 't) | |
198 (use-global-map crisp-mode-map) | |
199 (if crisp-load-scroll-lock | |
200 (require 'scroll-lock)) | |
201 (if (featurep 'scroll-lock) | |
202 (define-key crisp-mode-map [(meta f1)] 'scroll-lock-mode)) | |
203 (run-hooks 'crisp-load-hook)) | |
204 ((eq crisp-mode-enabled 'nil) | |
205 (use-global-map crisp-mode-original-keymap)))) | |
206 | |
207 (provide 'crisp) | |
208 | |
209 ;;; crisp.el ends here |