Mercurial > emacs
annotate lisp/emulation/viper.el @ 18315:3090657a944b
(Fchar_before): Validate N after decrementing.
Don't use POS as integer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 18 Jun 1997 16:46:05 +0000 |
parents | 3a43376db2be |
children | b5cee57a4a0f |
rev | line source |
---|---|
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1 ;;; viper.el --- A full-featured Vi emulator for GNU Emacs 19 and XEmacs 19, |
10789 | 2 ;; a VI Plan for Emacs Rescue, |
3 ;; and a venomous VI PERil. | |
4 ;; Viper Is also a Package for Emacs Rebels. | |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
5 ;; |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
6 ;; Keywords: emulations |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
8 |
18047 | 9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
10 | |
18289 | 11 (defconst viper-version "2.94 of June 12, 1997" |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
12 "The current version of Viper") |
14169 | 13 |
10789 | 14 ;; This file is part of GNU Emacs. |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
15742 | 27 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 ;; Boston, MA 02111-1307, USA. | |
10789 | 30 |
31 ;;; Commentary: | |
32 | |
33 ;; Viper is a full-featured Vi emulator for Emacs 19. It emulates and | |
34 ;; improves upon the standard features of Vi and, at the same time, allows | |
35 ;; full access to all Emacs facilities. Viper supports multiple undo, | |
36 ;; file name completion, command, file, and search history and it extends | |
37 ;; Vi in many other ways. Viper is highly customizable through the various | |
38 ;; hooks, user variables, and keymaps. It is implemented as a collection | |
39 ;; of minor modes and it is designed to provide full access to all Emacs | |
40 ;; major and minor modes. | |
41 ;; | |
42 ;;; History | |
43 ;; | |
44 ;; Viper is a new name for a package formerly known as VIP-19, | |
45 ;; which was a successor of VIP version 3.5 by Masahiko Sato | |
46 ;; <ms@sail.stanford.edu> and VIP version 4.2 by Aamod Sane | |
47 ;; <sane@cs.uiuc.edu>. Some ideas from vip 4.4.2 by Aamod Sane | |
48 ;; were also shamelessly plagiarized. | |
49 ;; | |
50 ;; Viper maintains some degree of compatibility with these older | |
51 ;; packages. See the documentation for customization. | |
52 ;; | |
53 ;; The main difference between Viper and these older packages are: | |
54 ;; | |
55 ;; 1. Viper emulates Vi at several levels, from almost complete conformity | |
56 ;; to a rather loose Vi-compliance. | |
57 ;; | |
58 ;; 2. Viper provides full access to all major and minor modes of Emacs | |
59 ;; without the need to type extra keys. | |
60 ;; The older versions of VIP (and other Vi emulators) do not work with | |
61 ;; some major and minor modes. | |
62 ;; | |
63 ;; 3. Viper supports vi-style undo. | |
64 ;; | |
65 ;; 4. Viper fully emulates (and improves upon) vi's replacement mode. | |
66 ;; | |
67 ;; 5. Viper has a better interface to ex, including command, variable, and | |
68 ;; file name completion. | |
69 ;; | |
70 ;; 6. Viper uses native Emacs history and completion features; it doesn't | |
71 ;; rely on other packages (such as gmhist.el and completer.el) to provide | |
72 ;; these features. | |
73 ;; | |
74 ;; 7. Viper supports Vi-style editing in the minibuffer, by allowing the | |
75 ;; user to switch from Insert state to Vi state to Replace state, etc. | |
76 ;; | |
77 ;; 8. Viper keeps history of recently inserted pieces of text and recently | |
78 ;; executed Vi-style destructive commands, such as `i', `d', etc. | |
79 ;; These pieces of text can be inserted in later insertion commands; | |
80 ;; the previous destructive commands can be re-executed. | |
81 ;; | |
82 ;; 9. Viper has Vi-style keyboard macros, which enhances the similar | |
83 ;; facility in the original Vi. | |
84 ;; First, one can execute any Emacs command while defining a | |
85 ;; macro, not just the Vi commands. Second, macros are defined in a | |
86 ;; WYSYWYG mode, using an interface to Emacs' WYSIWYG style of defining | |
87 ;; macros. Third, in Viper, one can define macros that are specific to | |
88 ;; a given buffer, a given major mode, or macros defined for all buffers. | |
89 ;; The same macro name can have several different definitions: | |
90 ;; one global, several definitions for various major modes, and | |
91 ;; definitions for specific buffers. | |
15739 | 92 ;; Buffer-specific definitions override mode-specific |
10789 | 93 ;; definitions, which, in turn, override global definitions. |
94 ;; | |
95 ;; | |
96 ;;; Installation: | |
97 ;; ------------- | |
98 ;; | |
99 ;; (require 'viper) | |
100 ;; | |
101 | |
102 ;;; Acknowledgements: | |
103 ;; ----------------- | |
15739 | 104 ;; Bug reports and ideas contributed by many users have helped |
105 ;; improve Viper and the various versions of VIP. | |
12691
7bd050135516
(vip-info-file-name): variable removed.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12203
diff
changeset
|
106 ;; See the on-line manual for a complete list of contributors. |
10789 | 107 ;; |
108 ;; | |
109 ;;; Notes: | |
110 ;; | |
111 ;; 1. Major modes. | |
112 ;; In most cases, Viper handles major modes correctly, i.e., they come up | |
113 ;; in the right state (either vi-state or emacs-state). For instance, text | |
114 ;; files come up in vi-state, while, say, Dired appears in emacs-state by | |
115 ;; default. | |
116 ;; However, some modes do not appear in the right mode in the beginning, | |
117 ;; usually because they neglect to follow Emacs conventions (e.g., they don't | |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
118 ;; use kill-all-local-variables when they start). Some major modes |
10789 | 119 ;; may fail to come up in emacs-state if they call hooks, such as |
120 ;; text-hook, for no good reason. | |
121 ;; | |
122 ;; As an immediate solution, you can hit C-z to bring about the right mode. | |
123 ;; An interim solution is to add an appropriate hook to the mode like this: | |
124 ;; | |
125 ;; (add-hook 'your-favorite-mode 'viper-mode) | |
126 ;; or | |
127 ;; (add-hook 'your-favorite-mode 'vip-change-state-to-emacs) | |
128 ;; | |
129 ;; whichever applies. The right thing to do, however, is to complain to the | |
130 ;; author of the respective package. (Sometimes they also neglect to equip | |
131 ;; their modes with hooks, which is one more reason for complaining.) | |
132 ;; | |
133 ;; 2. Keymap handling | |
134 ;; Because Emacs 19 has an elegant mechanism for turning minor mode keymaps | |
135 ;; on and off, implementation of Viper has been greatly simplified. Viper | |
136 ;; has several minor modes. | |
137 ;; | |
138 ;; Viper's Vi state consists of seven minor modes: | |
139 ;; | |
140 ;; vip-vi-intercept-minor-mode | |
141 ;; vip-vi-local-user-minor-mode | |
142 ;; vip-vi-global-user-minor-mode | |
143 ;; vip-vi-kbd-minor-mode | |
144 ;; vip-vi-state-modifier-minor-mode | |
145 ;; vip-vi-diehard-minor-mode | |
146 ;; vip-vi-basic-minor-mode | |
147 ;; | |
148 ;; Bindings done to the keymap of the first mode overshadow those done to | |
149 ;; the second, which, in turn, overshadows those done to the third, etc. | |
150 ;; | |
151 ;; The last vip-vi-basic-minor-mode contains most of the usual Vi bindings | |
152 ;; in its edit mode. This mode provides access to all Emacs facilities. | |
153 ;; Novice users, however, may want to set their vip-expert-level to 1 | |
154 ;; in their .vip file. This will enable vip-vi-diehard-minor-mode. This | |
155 ;; minor mode's bindings make Viper simulate the usual Vi very closely. | |
156 ;; For instance, C-c will not have its standard Emacs binding | |
157 ;; and so many of the goodies of Emacs are not available. | |
158 ;; | |
15739 | 159 ;; A skilled user should set vip-expert-level to at least 3. This will |
160 ;; enable `C-c' and many Emacs facilities will become available. | |
10789 | 161 ;; In this case, vip-vi-diehard-minor-mode is inactive. |
162 ;; | |
163 ;; Viper gurus should have at least | |
164 ;; (setq vip-expert-level 4) | |
165 ;; in their ~/.vip files. This will unsuppress all Emacs keys that are not | |
166 ;; essential for VI-style editing. | |
167 ;; Pick-and-choose users may want to put | |
168 ;; (setq vip-expert-level 5) | |
169 ;; in ~/.vip. Viper will then leave it up to the user to set the variables | |
170 ;; vip-want-* See vip-set-expert-level for details. | |
171 ;; | |
172 ;; The very first minor mode, vip-vi-intercept-minor-mode, is of no | |
173 ;; concern for the user. It is needed to bind Viper's vital keys, such as | |
174 ;; ESC and C-z. | |
175 ;; | |
176 ;; The second mode, vip-vi-local-user-minor-mode, usually has an | |
177 ;; empty keymap. However, the user can set bindings in this keymap, which | |
178 ;; will overshadow the corresponding bindings in the other two minor | |
179 ;; modes. This is useful, for example, for setting up ZZ in gnus, | |
180 ;; rmail, mh-e, etc., to send message instead of saving it in a file. | |
181 ;; Likewise, in Dired mode, you may want to bind ZN and ZP to commands | |
182 ;; that would visit the next or the previous file in the Dired buffer. | |
183 ;; Setting local keys is tricky, so don't do it directly. Instead, use | |
184 ;; vip-add-local-keys function (see its doc). | |
185 ;; | |
186 ;; The third minor mode, vip-vi-global-user-minor-mode, is also intended | |
187 ;; for the users but, unlike vip-vi-local-user-minor-mode, its key | |
188 ;; bindings are seen in all Viper buffers. This mode keys can be done | |
189 ;; with define-key command. | |
190 ;; | |
191 ;; The fourth minor mode, vip-vi-kbd-minor-mode, is used by keyboard | |
192 ;; macros. Users are NOT supposed to modify this keymap directly. | |
193 ;; | |
194 ;; The fifth mode, vip-vi-state-modifier-minor-mode, can be used to set | |
195 ;; key bindings that are visible in some major modes but not in others. | |
196 ;; | |
197 ;; Users are allowed to modify keymaps that belong to | |
198 ;; vip-vi-local-user-minor-mode, vip-vi-global-user-minor-mode, | |
199 ;; and vip-vi-state-modifier-minor-mode only. | |
200 ;; | |
201 ;; Viper's Insert state also has seven minor modes: | |
202 ;; | |
203 ;; vip-insert-intercept-minor-mode | |
204 ;; vip-insert-local-user-minor-mode | |
205 ;; vip-insert-global-user-minor-mode | |
206 ;; vip-insert-kbd-minor-mode | |
207 ;; vip-insert-state-modifier-minor-mode | |
208 ;; vip-insert-diehard-minor-mode | |
209 ;; vip-insert-basic-minor-mode | |
210 ;; | |
211 ;; As with VI's editing modes, the first mode, vip-insert-intercept-minor-mode | |
212 ;; is used to bind vital keys that are not to be changed by the user. | |
213 ;; | |
214 ;; The next mode, vip-insert-local-user-minor-mode, is used to customize | |
215 ;; bindings in the insert state of Viper. The third mode, | |
216 ;; vip-insert-global-user-minor-mode is like | |
217 ;; vip-insert-local-user-minor-mode, except that its bindings are seen in | |
218 ;; all Viper buffers. As with vip-vi-local-user-minor-mode, its bindings | |
219 ;; should be done via the function vip-add-local-keys. Bindings for | |
220 ;; vip-insert-global-user-minor-mode can be set with the define-key command. | |
221 ;; | |
222 ;; The next minor mode, vip-insert-kbd-minor-mode, | |
223 ;; is used for keyboard VI-style macros defined with :map!. | |
224 ;; | |
225 ;; The fifth minor mode, vip-insert-state-modifier-minor-mode, is like | |
226 ;; vip-vi-state-modifier-minor-mode, except that it is used in the Insert | |
227 ;; state; it can be used to modify keys in a mode-specific fashion. | |
228 ;; | |
229 ;; The minor mode vip-insert-diehard-minor-mode is in effect when | |
230 ;; the user wants a high degree of Vi compatibility (a bad idea, really!). | |
231 ;; The last minor mode, vip-insert-basic-minor-mode, is always in effect | |
232 ;; when Viper is in insert state. It binds a small number of keys needed for | |
233 ;; Viper's operation. | |
234 ;; | |
235 ;; Finally, Viper provides minor modes for overriding bindings set by Emacs | |
236 ;; modes when Viper is in Emacs state: | |
237 ;; | |
238 ;; vip-emacs-local-user-minor-mode | |
239 ;; vip-emacs-global-user-minor-mode | |
240 ;; vip-emacs-kbd-minor-mode | |
241 ;; vip-emacs-state-modifier-minor-mode | |
242 ;; | |
243 ;; These minor modes are in effect when Viper is in Emacs state. The keymap | |
244 ;; associated with vip-emacs-global-user-minor-mode, | |
245 ;; vip-emacs-global-user-map, overrides the global and local keymaps as | |
246 ;; well as the minor mode keymaps set by other modes. The keymap of | |
247 ;; vip-emacs-local-user-minor-mode, vip-emacs-local-user-map, overrides | |
248 ;; everything, but it is used on a per buffer basis. | |
249 ;; The keymap associated with vip-emacs-state-modifier-minor-mode | |
250 ;; overrides keys on a per-major-mode basis. The mode | |
251 ;; vip-emacs-kbd-minor-mode is used to define Vi-style macros in Emacs | |
252 ;; state. | |
253 ;; | |
254 ;; 3. There is also one minor mode that is used when Viper is in its | |
255 ;; replace-state (used for commands like cw, C, etc.). This mode is | |
256 ;; called | |
257 ;; | |
258 ;; vip-replace-minor-mode | |
259 ;; | |
260 ;; and its keymap is vip-replace-map. Replace minor mode is always | |
261 ;; used in conjunction with the minor modes for insert-state, and its | |
262 ;; keymap overshadows the keymaps for insert minor modes. | |
263 ;; | |
264 ;; 4. Defining buffer-local bindings in Vi and Insert modes. | |
265 ;; As mentioned before, sometimes, it is convenient to have | |
266 ;; buffer-specific of mode-specific key bindings in Vi and insert modes. | |
267 ;; Viper provides a special function, vip-add-local-keys, to do precisely | |
268 ;; this. For instance, is you need to add couple of mode-specific bindings | |
269 ;; to Insert mode, you can put | |
270 ;; | |
271 ;; (vip-add-local-keys 'insert-state '((key1 . func1) (key2 .func2))) | |
272 ;; | |
273 ;; somewhere in a hook of this major mode. If you put something like this | |
274 ;; in your own elisp function, this will define bindings specific to the | |
275 ;; buffer that was current at the time of the call to vip-add-local-keys. | |
276 ;; The only thing to make sure here is that the major mode of this buffer | |
277 ;; is written according to Emacs conventions, which includes a call to | |
278 ;; (kill-all-local-variables). See vip-add-local-keys for more details. | |
279 ;; | |
280 ;; | |
281 ;; TO DO (volunteers?): | |
282 ;; | |
283 ;; 1. Some of the code that is inherited from VIP-3.5 is rather | |
284 ;; convoluted. Instead of vip-command-argument, keymaps should bind the | |
285 ;; actual commands. E.g., "dw" should be bound to a generic command | |
286 ;; vip-delete that will delete things based on the value of | |
287 ;; last-command-char. This would greatly simplify the logic and the code. | |
288 ;; | |
289 ;; 2. Somebody should venture to write a customization package a la | |
290 ;; options.el that would allow the user to change values of variables | |
291 ;; that meet certain specs (e.g., match a regexp) and whose doc string | |
292 ;; starts with a '*'. Then, the user should be offered to save | |
293 ;; variables that were changed. This will make user's customization job | |
294 ;; much easier. | |
295 ;; | |
296 | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14734
diff
changeset
|
297 ;; Code |
10789 | 298 |
299 (require 'advice) | |
300 (require 'cl) | |
301 (require 'ring) | |
302 | |
18172 | 303 ;; compiler pacifier |
304 (defvar mark-even-if-inactive) | |
305 | |
306 ;; loading happens only in non-interactive compilation | |
307 ;; in order to spare non-viperized emacs from being viperized | |
308 (if noninteractive | |
309 (eval-when-compile | |
310 (let ((load-path (cons (expand-file-name ".") load-path))) | |
311 (or (featurep 'viper-cmd) | |
312 (load "viper-cmd.el" nil nil 'nosuffix)) | |
313 ))) | |
314 ;; end pacifier | |
10789 | 315 |
18129 | 316 (require 'viper-cmd) |
10789 | 317 |
18289 | 318 (defvar vip-always t |
319 "See `viper-always'. This variable is for compatibility with older Vipers.") | |
320 (defvar viper-always vip-always | |
321 "Non-nil means, arrange for vi-state to be a default when appropriate. | |
322 This is different from `viper-mode' variable in that `viper-mode' determines | |
323 whether to use Viper in the first place, while `viper-always', if nil, lets | |
324 user decide when to invoke Viper in a major mode.") | |
10789 | 325 |
18289 | 326 (defvar viper-mode (cond (noninteractive nil) |
327 (t 'ask)) | |
328 "Viperize or not Viperize. | |
329 If t, viperize emacs. If nil -- don't. If `ask', ask the user. | |
330 This variable is used primatily when Viper is being loaded. | |
331 | |
332 Must be set in `~/.emacs' before Viper is loaded. | |
333 DO NOT set this variable interactively.") | |
334 | |
335 | |
336 ;; The following are provided for compatibility with older VIP's | |
337 | |
338 ;;;###autoload | |
339 (defalias 'vip-mode 'viper-mode) | |
10789 | 340 |
341 (defalias 'vip-change-mode-to-vi 'vip-change-state-to-vi) | |
342 (defalias 'vip-change-mode-to-insert 'vip-change-state-to-insert) | |
343 (defalias 'vip-change-mode-to-emacs 'vip-change-state-to-emacs) | |
18289 | 344 |
345 | |
346 | |
347 ;;;###autoload | |
348 (defun viper-mode () | |
349 "Turn on Viper emulation of Vi." | |
350 (interactive) | |
351 (if (not noninteractive) | |
352 (progn | |
353 ;; if the user requested viper-mode explicitly | |
354 (if viper-mode | |
355 () | |
356 (setq viper-mode 1) | |
357 (load-library "viper")) | |
358 | |
359 (if vip-first-time ; This check is important. Without it, startup and | |
360 (progn ; expert-level msgs mix up when viper-mode recurses | |
361 (setq vip-first-time nil) | |
362 (if (not vip-inhibit-startup-message) | |
363 (save-window-excursion | |
364 (setq vip-inhibit-startup-message t) | |
365 (delete-other-windows) | |
366 (switch-to-buffer "Viper Startup Message") | |
367 (erase-buffer) | |
368 (insert | |
369 (substitute-command-keys | |
370 "Viper Is a Package for Emacs Rebels. | |
371 It is also a VI Plan for Emacs Rescue and a venomous VI PERil. | |
372 | |
373 Technically speaking, Viper is a Vi emulation package for GNU Emacs 19 and | |
374 XEmacs 19. It supports virtually all of Vi and Ex functionality, extending | |
375 and improving upon much of it. | |
376 | |
377 1. Viper supports Vi at several levels. Level 1 is the closest to Vi, | |
378 level 5 provides the most flexibility to depart from many Vi conventions. | |
379 | |
380 You will be asked to specify your user level in a following screen. | |
381 | |
382 If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave | |
383 as in VI, to smooth transition to Viper for the beginners. However, to | |
384 use Emacs productively, you are advised to reach user level 3 or higher. | |
385 | |
386 If your user level is 2 or higher, ^X and ^C will invoke Emacs | |
387 functions,as usual in Emacs; ^Z will toggle vi/emacs modes, and | |
388 ^G will be the usual Emacs's keyboard-quit (something like ^C in VI). | |
389 | |
390 2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they | |
391 do not cause Emacs to quit, except at user level 1 (a novice). | |
392 3. ^X^C EXITS EMACS. | |
393 4. Viper supports multiple undo: `u' will undo. Typing `.' will repeat | |
394 undo. Another `u' changes direction. | |
395 | |
396 6. Emacs Meta functions are invoked by typing `C-\\' or `\\ ESC'. | |
397 On a window system, the best way is to use the Meta-key. | |
398 7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if | |
399 something funny happens. This would abort the current editing command. | |
400 | |
401 You can get more information on Viper by: | |
402 | |
403 a. Typing `:help' in Vi state | |
404 b. Printing Viper manual, found in ./etc/viper.dvi | |
405 c. Printing ViperCard, the Quick Reference, found in ./etc/viperCard.dvi | |
406 | |
407 This startup message appears whenever you load Viper, unless you type `y' now." | |
408 )) | |
409 (goto-char (point-min)) | |
410 (if (y-or-n-p "Inhibit Viper startup message? ") | |
411 (vip-save-setting | |
412 'vip-inhibit-startup-message | |
413 "Viper startup message inhibited" | |
414 vip-custom-file-name t)) | |
415 ;;(kill-buffer (current-buffer)) | |
416 (message | |
417 "The last message is in buffer `Viper Startup Message'") | |
418 (sit-for 4) | |
419 )) | |
420 (vip-set-expert-level 'dont-change-unless))) | |
421 (vip-change-state-to-vi)))) | |
10789 | 422 |
18129 | 423 |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
424 ;; This hook designed to enable Vi-style editing in comint-based modes." |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
425 (defun vip-comint-mode-hook () |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
426 (setq require-final-newline nil |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
427 vip-ex-style-editing-in-insert nil |
10789 | 428 vip-ex-style-motion nil) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
429 (vip-change-state-to-insert)) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
430 |
10789 | 431 |
13214
bc4eeb585ff1
(vip-set-hooks): Use view-mode-hook in emacs and view
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12900
diff
changeset
|
432 ;; This sets major mode hooks to make them come up in vi-state. |
10789 | 433 (defun vip-set-hooks () |
434 | |
435 ;; It is of course a misnomer to call viper-mode a `major mode'. | |
436 ;; However, this has the effect that if the user didn't specify the | |
437 ;; default mode, new buffers that fall back on the default will come up | |
438 ;; in Fundamental Mode and Vi state. | |
439 (setq default-major-mode 'viper-mode) | |
440 | |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
441 ;; The following major modes should come up in vi-state |
10789 | 442 (defadvice fundamental-mode (after vip-fundamental-mode-ad activate) |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
443 "Run `vip-change-state-to-vi' on entry." |
10789 | 444 (vip-change-state-to-vi)) |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
445 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
446 (defvar makefile-mode-hook) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
447 (add-hook 'makefile-mode-hook 'viper-mode) |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
448 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
449 (defvar help-mode-hook) |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
450 (add-hook 'help-mode-hook 'viper-mode) |
18047 | 451 (vip-modify-major-mode 'help-mode 'vi-state vip-help-modifier-map) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
452 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
453 (defvar awk-mode-hook) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
454 (add-hook 'awk-mode-hook 'viper-mode) |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
455 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
456 (defvar html-mode-hook) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
457 (add-hook 'html-mode-hook 'viper-mode) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
458 (defvar html-helper-mode-hook) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
459 (add-hook 'html-helper-mode-hook 'viper-mode) |
18289 | 460 |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
461 (defvar java-mode-hook) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
462 (add-hook 'java-mode-hook 'viper-mode) |
10789 | 463 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
464 (defvar emacs-lisp-mode-hook) |
10789 | 465 (add-hook 'emacs-lisp-mode-hook 'viper-mode) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
466 (defvar lisp-mode-hook) |
10789 | 467 (add-hook 'lisp-mode-hook 'viper-mode) |
18289 | 468 (defvar lisp-interaction-mode-hook) |
469 (add-hook 'lisp-interaction-mode-hook 'viper-mode) | |
10789 | 470 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
471 (defvar bibtex-mode-hook) |
10789 | 472 (add-hook 'bibtex-mode-hook 'viper-mode) |
473 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
474 (defvar cc-mode-hook) |
10789 | 475 (add-hook 'cc-mode-hook 'viper-mode) |
476 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
477 (defvar c-mode-hook) |
10789 | 478 (add-hook 'c-mode-hook 'viper-mode) |
479 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
480 (defvar c++-mode-hook) |
10789 | 481 (add-hook 'c++-mode-hook 'viper-mode) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
482 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
483 (defvar fortran-mode-hook) |
18289 | 484 (add-hook 'fortran-mode-hook 'viper-mode) |
485 (defvar f90-mode-hook) | |
486 (add-hook 'f90-mode-hook 'viper-mode) | |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
487 |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
488 (defvar basic-mode-hook) |
18289 | 489 (add-hook 'basic-mode-hook 'viper-mode) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
490 (defvar bat-mode-hook) |
18289 | 491 (add-hook 'bat-mode-hook 'viper-mode) |
10789 | 492 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
493 (defvar text-mode-hook) |
10789 | 494 (add-hook 'text-mode-hook 'viper-mode) |
495 | |
496 (add-hook 'completion-list-mode-hook 'viper-mode) | |
497 (add-hook 'compilation-mode-hook 'viper-mode) | |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
498 |
18129 | 499 (add-hook 'perl-mode-hook 'viper-mode) |
14579
a81dd4e9603a
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14434
diff
changeset
|
500 (add-hook 'tcl-mode-hook 'viper-mode) |
10789 | 501 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
502 (defvar emerge-startup-hook) |
10789 | 503 (add-hook 'emerge-startup-hook 'vip-change-state-to-emacs) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
504 |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
505 ;; Tell vc-diff to put *vc* in Vi mode |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
506 (if (featurep 'vc) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
507 (defadvice vc-diff (after vip-vc-ad activate) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
508 "Force Vi state in VC diff buffer." |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
509 (vip-change-state-to-vi)) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
510 (vip-eval-after-load |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
511 "vc" |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
512 '(defadvice vc-diff (after vip-vc-ad activate) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
513 "Force Vi state in VC diff buffer." |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
514 (vip-change-state-to-vi)))) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
515 |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
516 (vip-eval-after-load |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
517 "emerge" |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
518 '(defadvice emerge-quit (after vip-emerge-advice activate) |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
519 "Run `vip-change-state-to-vi' after quitting emerge." |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
520 (vip-change-state-to-vi))) |
10789 | 521 ;; In case Emerge was loaded before Viper. |
522 (defadvice emerge-quit (after vip-emerge-advice activate) | |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
523 "Run `vip-change-state-to-vi' after quitting emerge." |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
524 (vip-change-state-to-vi)) |
10789 | 525 |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
526 (vip-eval-after-load |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
527 "asm-mode" |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
528 '(defadvice asm-mode (after vip-asm-mode-ad activate) |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
529 "Run `vip-change-state-to-vi' on entry." |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
530 (vip-change-state-to-vi))) |
10789 | 531 |
532 ;; passwd.el sets up its own buffer, which turns up in Vi mode, | |
12691
7bd050135516
(vip-info-file-name): variable removed.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12203
diff
changeset
|
533 ;; thus overriding the local map. We don't need Vi mode here. |
10789 | 534 (vip-eval-after-load |
535 "passwd" | |
536 '(defadvice read-passwd-1 (before vip-passwd-ad activate) | |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
537 "Switch to emacs state while reading password." |
10789 | 538 (vip-change-state-to-emacs))) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
539 |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
540 (vip-eval-after-load |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
541 "prolog" |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
542 '(defadvice prolog-mode (after vip-prolog-ad activate) |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
543 "Switch to Vi state in Prolog mode." |
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
544 (vip-change-state-to-vi))) |
10789 | 545 |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
546 ;; Emacs shell, ange-ftp, and comint-based modes |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
547 (defvar comint-mode-hook) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
548 (vip-modify-major-mode |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
549 'comint-mode 'insert-state vip-comint-mode-modifier-map) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
550 (vip-modify-major-mode |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
551 'comint-mode 'vi-state vip-comint-mode-modifier-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
552 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
553 'shell-mode 'insert-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
554 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
555 'shell-mode 'vi-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
556 ;; ange-ftp in XEmacs |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
557 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
558 'ange-ftp-shell-mode 'insert-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
559 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
560 'ange-ftp-shell-mode 'vi-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
561 ;; ange-ftp in Emacs |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
562 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
563 'internal-ange-ftp-mode 'insert-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
564 (vip-modify-major-mode |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
565 'internal-ange-ftp-mode 'vi-state vip-comint-mode-modifier-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
566 ;; set hook |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
567 (add-hook 'comint-mode-hook 'vip-comint-mode-hook) |
10789 | 568 |
569 ;; Shell scripts | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
570 (defvar sh-mode-hook) |
10789 | 571 (add-hook 'sh-mode-hook 'viper-mode) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
572 (defvar ksh-mode-hook) |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
573 (add-hook 'ksh-mode-hook 'viper-mode) |
10789 | 574 |
575 ;; Dired | |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
576 (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
577 (vip-set-emacs-search-style-macros nil 'dired-mode) |
10789 | 578 (add-hook 'dired-mode-hook 'vip-change-state-to-emacs) |
579 | |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
580 ;; Tar |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
581 (vip-modify-major-mode 'tar-mode 'emacs-state vip-slash-and-colon-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
582 (vip-set-emacs-search-style-macros nil 'tar-mode) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
583 |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
584 ;; MH-E |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
585 (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
586 (vip-set-emacs-search-style-macros nil 'mh-folder-mode) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
587 ;; changing state to emacs is needed so the preceding will take hold |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
588 (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
589 (add-hook 'mh-show-mode-hook 'viper-mode) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
590 |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
591 ;; Gnus |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
592 (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
593 (vip-set-emacs-search-style-macros nil 'gnus-group-mode) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
594 (vip-modify-major-mode |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
595 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
596 (vip-set-emacs-search-style-macros nil 'gnus-summary-mode) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
597 ;; changing state to emacs is needed so the preceding will take hold |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
598 (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
599 (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
600 (add-hook 'gnus-article-mode-hook 'viper-mode) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
601 |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
602 ;; Info |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
603 (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
604 (vip-set-emacs-search-style-macros nil 'Info-mode) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
605 ;; Switching to emacs is needed so the above will take hold |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
606 (defadvice Info-mode (after vip-Info-ad activate) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
607 "Switch to emacs mode." |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
608 (vip-change-state-to-emacs)) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
609 |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
610 ;; Buffer menu |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
611 (vip-modify-major-mode |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
612 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map) |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
613 (vip-set-emacs-search-style-macros nil 'Buffer-menu-mode) |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
614 ;; Switching to emacs is needed so the above will take hold |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
615 (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
616 "Switch to emacs mode." |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
617 (vip-change-state-to-emacs)) |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
618 |
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
619 ;; View mode |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
620 (if vip-emacs-p |
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
621 (progn |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
622 (defvar view-mode-hook) |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
623 (add-hook 'view-mode-hook 'vip-change-state-to-emacs)) |
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
624 (defadvice view-minor-mode (after vip-view-ad activate) |
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
625 "Switch to Emacs state in View mode." |
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
626 (vip-change-state-to-emacs)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
627 (defvar view-hook) |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
628 (add-hook 'view-hook 'vip-change-state-to-emacs)) |
10789 | 629 |
630 ;; For VM users. | |
631 ;; Put summary and other VM buffers in Emacs state. | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
632 (defvar vm-mode-hooks) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
633 (defvar vm-summary-mode-hooks) |
10789 | 634 (add-hook 'vm-mode-hooks 'vip-change-state-to-emacs) |
635 (add-hook 'vm-summary-mode-hooks 'vip-change-state-to-emacs) | |
636 | |
637 ;; For RMAIL users. | |
638 ;; Put buf in Emacs state after edit. | |
639 (vip-eval-after-load | |
640 "rmailedit" | |
641 '(defadvice rmail-cease-edit (after vip-rmail-advice activate) | |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
642 "Switch to emacs state when done editing message." |
10789 | 643 (vip-change-state-to-emacs))) |
644 ;; In case RMAIL was loaded before Viper. | |
645 (defadvice rmail-cease-edit (after vip-rmail-advice activate) | |
12137
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
646 "Switch to emacs state when done editing message." |
e6af973190dc
(vip-envelop-ESC-key): if an ESC-sequence translates
Karl Heuer <kwzh@gnu.org>
parents:
11255
diff
changeset
|
647 (vip-change-state-to-emacs)) |
10789 | 648 ) ; vip-set-hooks |
18172 | 649 |
18289 | 650 |
651 ;; these are primarily advices and Vi-ish variable settings | |
652 (defun vip-non-hook-settings () | |
18172 | 653 |
18289 | 654 ;; This var is not local in Emacs, so we make it local. |
655 ;; It must be local because although the stack of minor modes can be the same | |
656 ;; for all buffers, the associated *keymaps* can be different. In Viper, | |
657 ;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have | |
658 ;; different keymaps for different buffers. | |
659 ;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode | |
660 ;; can be different. | |
661 (make-variable-buffer-local 'minor-mode-map-alist) | |
662 | |
663 ;; Viper changes the default mode-line-buffer-identification | |
664 (setq-default mode-line-buffer-identification '(" %b")) | |
665 | |
666 ;; setup emacs-supported vi-style feel | |
667 (setq next-line-add-newlines nil | |
668 require-final-newline t) | |
669 | |
670 (make-variable-buffer-local 'require-final-newline) | |
671 | |
672 ;; don't bark when mark is inactive | |
673 (setq mark-even-if-inactive t) | |
674 | |
675 (setq scroll-step 1) | |
676 | |
677 ;; Variable displaying the current Viper state in the mode line. | |
678 (vip-deflocalvar vip-mode-string vip-emacs-state-id) | |
679 (or (memq 'vip-mode-string global-mode-string) | |
680 (setq global-mode-string | |
681 (append '("" vip-mode-string) (cdr global-mode-string)))) | |
18172 | 682 |
18289 | 683 (defadvice read-key-sequence (around vip-read-keyseq-ad activate) |
684 "Harness to work for Viper. This advice is harmless---don't worry!" | |
685 (let (inhibit-quit event keyseq) | |
686 (setq keyseq ad-do-it) | |
687 (setq event (if vip-xemacs-p | |
688 (elt keyseq 0) ; XEmacs returns vector of events | |
689 (elt (listify-key-sequence keyseq) 0))) | |
690 (if (vip-ESC-event-p event) | |
691 (let (unread-command-events) | |
692 (vip-set-unread-command-events keyseq) | |
693 (if (vip-fast-keysequence-p) | |
694 (let ((vip-vi-global-user-minor-mode nil) | |
695 (vip-vi-local-user-minor-mode nil) | |
696 (vip-replace-minor-mode nil) ; actually unnecessary | |
697 (vip-insert-global-user-minor-mode nil) | |
698 (vip-insert-local-user-minor-mode nil)) | |
699 (setq keyseq ad-do-it)) | |
700 (setq keyseq ad-do-it)))) | |
701 keyseq)) | |
702 | |
703 (defadvice describe-key (before vip-read-keyseq-ad protect activate) | |
704 "Force to read key via `read-key-sequence'." | |
705 (interactive (list (vip-events-to-keys | |
706 (read-key-sequence "Describe key: "))))) | |
707 | |
708 (defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate) | |
709 "Force to read key via `read-key-sequence'." | |
710 (interactive (list (vip-events-to-keys | |
711 (read-key-sequence "Describe key briefly: "))))) | |
712 | |
713 | |
714 ;; Advice for use in find-file and read-file-name commands. | |
715 (defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate) | |
716 "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer." | |
717 (run-hooks 'vip-minibuffer-exit-hook)) | |
718 | |
719 (defadvice find-file (before vip-add-suffix-advice activate) | |
720 "Use `read-file-name' for reading arguments." | |
721 (interactive (cons (read-file-name "Find file: " nil default-directory) | |
722 ;; if Mule and prefix argument, ask for coding system | |
723 (if (or (boundp 'MULE) ; mule integrated Emacs 19 | |
724 (featurep 'mule)) ; mule integrated XEmacs 20 | |
725 (list | |
726 (and current-prefix-arg | |
727 (read-coding-system "Coding-system: ")))) | |
728 ))) | |
729 | |
730 (defadvice find-file-other-window (before vip-add-suffix-advice activate) | |
731 "Use `read-file-name' for reading arguments." | |
732 (interactive (cons (read-file-name "Find file in other window: " | |
733 nil default-directory) | |
734 ;; if Mule and prefix argument, ask for coding system | |
735 (if (or (boundp 'MULE) ; mule integrated Emacs 19 | |
736 (featurep 'mule)) ; mule integrated XEmacs 20 | |
737 (list | |
738 (and current-prefix-arg | |
739 (read-coding-system "Coding-system: ")))) | |
740 ))) | |
741 | |
742 (defadvice find-file-other-frame (before vip-add-suffix-advice activate) | |
743 "Use `read-file-name' for reading arguments." | |
744 (interactive (cons (read-file-name "Find file in other frame: " | |
745 nil default-directory) | |
746 ;; if Mule and prefix argument, ask for coding system | |
747 (if (or (boundp 'MULE) ; mule integrated Emacs 19 | |
748 (featurep 'mule)) ; mule integrated XEmacs 20 | |
749 (list | |
750 (and current-prefix-arg | |
751 (read-coding-system "Coding-system: ")))) | |
752 ))) | |
753 | |
754 (defadvice read-file-name (around vip-suffix-advice activate) | |
755 "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook." | |
756 (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix)) | |
757 ad-do-it)) | |
758 | |
759 (defadvice start-kbd-macro (after vip-kbd-advice activate) | |
760 "Remove Viper's intercepting bindings for C-x ). | |
761 This may be needed if the previous `:map' command terminated abnormally." | |
762 (define-key vip-vi-intercept-map "\C-x)" nil) | |
763 (define-key vip-insert-intercept-map "\C-x)" nil) | |
764 (define-key vip-emacs-intercept-map "\C-x)" nil)) | |
765 | |
766 (cond ((vip-window-display-p) | |
767 (let* ((search-key (if vip-xemacs-p | |
768 [(meta shift button1up)] [M-S-mouse-1])) | |
769 (search-key-catch | |
770 (if vip-xemacs-p [(meta shift button1)] [M-S-down-mouse-1])) | |
771 (insert-key (if vip-xemacs-p | |
772 [(meta shift button2up)] [M-S-mouse-2])) | |
773 (insert-key-catch | |
774 (if vip-xemacs-p [(meta shift button2)] [M-S-down-mouse-2])) | |
775 (search-key-unbound (and (not (key-binding search-key)) | |
776 (not (key-binding search-key-catch)))) | |
777 (insert-key-unbound (and (not (key-binding insert-key)) | |
778 (not (key-binding insert-key-catch)))) | |
779 ) | |
780 | |
781 (if search-key-unbound | |
782 (global-set-key search-key 'vip-mouse-click-search-word)) | |
783 (if insert-key-unbound | |
784 (global-set-key insert-key 'vip-mouse-click-insert-word)) | |
785 | |
786 ;; The following would be needed if you want to use the above two | |
787 ;; while clicking in another frame. If you only want to use them | |
788 ;; by clicking in another window, not frame, the bindings below | |
789 ;; aren't necessary. | |
790 | |
791 ;; These must be bound to mouse-down event for the same mouse | |
792 ;; buttons as 'vip-mouse-click-search-word and | |
793 ;; 'vip-mouse-click-insert-word | |
794 (if search-key-unbound | |
795 (global-set-key search-key-catch 'vip-mouse-catch-frame-switch)) | |
796 (if insert-key-unbound | |
797 (global-set-key insert-key-catch 'vip-mouse-catch-frame-switch)) | |
798 | |
799 (if vip-xemacs-p | |
800 (add-hook 'mouse-leave-frame-hook | |
801 'vip-remember-current-frame) | |
802 (defadvice handle-switch-frame (before vip-frame-advice activate) | |
803 "Remember the selected frame before the switch-frame event." | |
804 (vip-remember-current-frame (selected-frame)))) | |
805 ))) | |
806 ) ; end vip-non-hook-settings | |
18172 | 807 |
18289 | 808 |
809 (if (eq viper-mode 'ask) | |
810 (progn | |
811 (save-window-excursion | |
812 (with-output-to-temp-buffer " *vip-info*" | |
813 (princ " | |
814 You have loaded Viper, and are about to Viperize your emacs! | |
815 | |
816 Viper is a Package for Emacs Rebels | |
817 and a venomous VI PERil, | |
818 | |
819 It's time to decide: to Viperize or not to Viperize... | |
18172 | 820 |
18289 | 821 If you wish to Viperize AND make this your way of life, please put |
822 | |
823 (setq viper-mode t) | |
824 (require 'viper) | |
825 | |
826 in your .emacs file (preferably, close to the top). | |
827 These two lines must come in the order given. | |
828 | |
829 Also, the startup file name has changed from .vip to .viper")) | |
830 (if (y-or-n-p "Viperize? ") | |
831 (setq viper-mode t) | |
832 (setq viper-mode nil)) | |
833 (message "") | |
834 (kill-buffer " *vip-info*")))) | |
835 | |
18172 | 836 |
837 | |
838 | |
10789 | 839 |
18289 | 840 ;; Set some useful macros, advices |
841 ;; These must be BEFORE we ~/.vip is loaded, | |
842 ;; so the user can unrecord them in ~/.vip. | |
843 (if viper-mode | |
844 (progn | |
845 ;; set advices and some variables that give emacs Vi look. | |
846 (vip-non-hook-settings) | |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
847 |
18289 | 848 ;; repeat the 2nd previous command without rotating the command history |
849 (vip-record-kbd-macro | |
850 (vector vip-repeat-from-history-key '\1) 'vi-state | |
851 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) | |
852 ;; repeat the 3d previous command without rotating the command history | |
853 (vip-record-kbd-macro | |
854 (vector vip-repeat-from-history-key '\2) 'vi-state | |
855 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) | |
856 | |
857 ;; set the toggle case sensitivity and regexp search macros | |
858 (vip-set-vi-search-style-macros nil) | |
859 | |
860 ;; Make %%% toggle parsing comments for matching parentheses | |
861 (vip-record-kbd-macro | |
862 "%%%" 'vi-state | |
863 [(meta x) v i p - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return] | |
864 't) | |
865 )) | |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
866 |
10789 | 867 |
868 ;; ~/.vip is loaded if it exists | |
869 (if (and (file-exists-p vip-custom-file-name) | |
18289 | 870 viper-mode |
10789 | 871 (not noninteractive)) |
872 (load vip-custom-file-name)) | |
873 | |
874 ;; VIP compatibility: merge whatever the user has in vip-mode-map into | |
875 ;; Viper's basic map. | |
876 (vip-add-keymap vip-mode-map vip-vi-global-user-map) | |
877 | |
878 | |
879 ;; Applying Viper customization -- runs after (load .vip) | |
880 | |
14232
aa84e18af631
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
881 ;; Save user settings or Viper defaults for vars controled by vip-expert-level |
10789 | 882 (setq vip-saved-user-settings |
883 (list (cons 'vip-want-ctl-h-help vip-want-ctl-h-help) | |
18289 | 884 (cons 'viper-always viper-always) |
10789 | 885 (cons 'vip-no-multiple-ESC vip-no-multiple-ESC) |
886 (cons 'vip-ex-style-motion vip-ex-style-motion) | |
887 (cons 'vip-ex-style-editing-in-insert | |
888 vip-ex-style-editing-in-insert) | |
889 (cons 'vip-want-emacs-keys-in-vi vip-want-emacs-keys-in-vi) | |
18289 | 890 (cons 'vip-electric-mode vip-electric-mode) |
10789 | 891 (cons 'vip-want-emacs-keys-in-insert vip-want-emacs-keys-in-insert) |
892 (cons 'vip-re-search vip-re-search))) | |
893 | |
894 | |
18289 | 895 (if viper-mode |
896 (progn | |
897 (vip-set-minibuffer-style) | |
898 (if vip-buffer-search-char | |
899 (vip-buffer-search-enable)) | |
900 (vip-update-alphanumeric-class) | |
901 )) | |
10789 | 902 |
18129 | 903 |
10789 | 904 ;;; Familiarize Viper with some minor modes that have their own keymaps |
18289 | 905 (if viper-mode |
906 (progn | |
907 (vip-harness-minor-mode "compile") | |
908 (vip-harness-minor-mode "outline") | |
909 (vip-harness-minor-mode "allout") | |
910 (vip-harness-minor-mode "xref") | |
911 (vip-harness-minor-mode "lmenu") | |
912 (vip-harness-minor-mode "vc") | |
913 (vip-harness-minor-mode "ltx-math") ; LaTeX-math-mode in AUC-TeX | |
914 (vip-harness-minor-mode "latex") ; which is in one of these two files | |
915 (vip-harness-minor-mode "cyrillic") | |
916 (vip-harness-minor-mode "russian") | |
917 (vip-harness-minor-mode "view-less") | |
918 (vip-harness-minor-mode "view") | |
919 )) | |
10789 | 920 |
921 | |
922 ;; Intercept maps could go in viper-keym.el | |
923 ;; We keep them here in case someone redefines them in ~/.vip | |
924 | |
925 (define-key vip-vi-intercept-map vip-ESC-key 'vip-intercept-ESC-key) | |
926 (define-key vip-insert-intercept-map vip-ESC-key 'vip-intercept-ESC-key) | |
927 | |
928 ;; This is taken care of by vip-insert-global-user-map. | |
929 ;;(define-key vip-replace-map vip-ESC-key 'vip-intercept-ESC-key) | |
930 | |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
931 |
10789 | 932 ;; The default vip-toggle-key is \C-z; for the novice, it suspends or |
933 ;; iconifies Emacs | |
16135
102e7d27c135
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16038
diff
changeset
|
934 (define-key vip-vi-intercept-map vip-toggle-key 'vip-toggle-key-action) |
10789 | 935 (define-key vip-emacs-intercept-map vip-toggle-key 'vip-change-state-to-vi) |
936 | |
937 | |
18289 | 938 (if (and viper-mode |
939 (or viper-always | |
940 (and (< vip-expert-level 5) (> vip-expert-level 0)))) | |
10789 | 941 (vip-set-hooks)) |
942 | |
943 ;; Let all minor modes take effect after loading | |
944 ;; this may not be enough, so we also set default minor-mode-alist. | |
945 ;; Without setting the default, new buffers that come up in emacs mode have | |
946 ;; minor-mode-map-alist = nil, unless we call vip-change-state-* | |
947 (if (eq vip-current-state 'emacs-state) | |
948 (progn | |
949 (vip-change-state-to-emacs) | |
950 (setq-default minor-mode-map-alist minor-mode-map-alist) | |
951 )) | |
952 | |
12900
7a7b8d42bdec
* viper.el (vip-set-hooks): Use view-mode-hook in emacs and view hook in xemacs.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12855
diff
changeset
|
953 |
18129 | 954 |
13214
bc4eeb585ff1
(vip-set-hooks): Use view-mode-hook in emacs and view
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12900
diff
changeset
|
955 (run-hooks 'vip-load-hook) ; the last chance to change something |
10789 | 956 |
957 (provide 'vip) | |
18129 | 958 (provide 'viper) |
10789 | 959 |
960 ;;; viper.el ends here |