new version
[emacs.git] / lisp / emulation / viper.el
blobb7c2cfab28cbc2eb22583b02c7452a20a7205ab2
1 ;;; viper.el --- A full-featured Vi emulator for GNU Emacs 19 and XEmacs 19,
2 ;; a VI Plan for Emacs Rescue,
3 ;; and a venomous VI PERil.
4 ;; Viper Is also a Package for Emacs Rebels.
5 ;;
6 ;; Keywords: emulations
7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
11 (defconst viper-version "2.95 of July 9, 1997"
12 "The current version of Viper")
14 ;; This file is part of GNU Emacs.
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.
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.
26 ;; You should have received a copy of the GNU General Public License
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.
31 ;;; Commentary:
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.
42 ;;; History
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.
50 ;; Viper maintains some degree of compatibility with these older
51 ;; packages. See the documentation for customization.
53 ;; The main difference between Viper and these older packages are:
55 ;; 1. Viper emulates Vi at several levels, from almost complete conformity
56 ;; to a rather loose Vi-compliance.
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.
63 ;; 3. Viper supports vi-style undo.
65 ;; 4. Viper fully emulates (and improves upon) vi's replacement mode.
67 ;; 5. Viper has a better interface to ex, including command, variable, and
68 ;; file name completion.
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.
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.
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.
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.
92 ;; Buffer-specific definitions override mode-specific
93 ;; definitions, which, in turn, override global definitions.
96 ;;; Installation:
97 ;; -------------
99 ;; (require 'viper)
102 ;;; Acknowledgements:
103 ;; -----------------
104 ;; Bug reports and ideas contributed by many users have helped
105 ;; improve Viper and the various versions of VIP.
106 ;; See the on-line manual for a complete list of contributors.
109 ;;; Notes:
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
118 ;; use kill-all-local-variables when they start). Some major modes
119 ;; may fail to come up in emacs-state if they call hooks, such as
120 ;; text-hook, for no good reason.
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:
125 ;; (add-hook 'your-favorite-mode 'viper-mode)
126 ;; or
127 ;; (add-hook 'your-favorite-mode 'vip-change-state-to-emacs)
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.)
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.
138 ;; Viper's Vi state consists of seven minor modes:
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
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.
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 viper-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.
159 ;; A skilled user should set viper-expert-level to at least 3. This will
160 ;; enable `C-c' and many Emacs facilities will become available.
161 ;; In this case, vip-vi-diehard-minor-mode is inactive.
163 ;; Viper gurus should have at least
164 ;; (setq viper-expert-level 4)
165 ;; in their ~/.viper 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 viper-expert-level 5)
169 ;; in ~/.viper. Viper will then leave it up to the user to set the variables
170 ;; vip-want-* See viper-set-expert-level for details.
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.
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).
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.
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.
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.
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.
201 ;; Viper's Insert state also has seven minor modes:
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
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.
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.
222 ;; The next minor mode, vip-insert-kbd-minor-mode,
223 ;; is used for keyboard VI-style macros defined with :map!.
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.
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.
235 ;; Finally, Viper provides minor modes for overriding bindings set by Emacs
236 ;; modes when Viper is in Emacs state:
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
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.
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
258 ;; vip-replace-minor-mode
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.
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
271 ;; (vip-add-local-keys 'insert-state '((key1 . func1) (key2 .func2)))
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.
281 ;; TO DO (volunteers?):
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.
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.
297 ;; Code
299 (require 'advice)
300 (require 'cl)
301 (require 'ring)
303 ;; compiler pacifier
304 (defvar mark-even-if-inactive)
305 (defvar viper-expert-level)
306 (defvar vip-expert-level)
308 ;; loading happens only in non-interactive compilation
309 ;; in order to spare non-viperized emacs from being viperized
310 (if noninteractive
311 (eval-when-compile
312 (let ((load-path (cons (expand-file-name ".") load-path)))
313 (or (featurep 'viper-cmd)
314 (load "viper-cmd.el" nil nil 'nosuffix))
316 ;; end pacifier
318 ;; better be defined before Viper custom group.
319 (defvar vip-custom-file-name (vip-convert-standard-file-name "~/.viper")
320 "Viper customisation file.
321 If set by the user, this must be done _before_ Viper is loaded in `~/.emacs'.")
323 (defgroup viper nil
324 "Vi emulation within Emacs.
325 NOTE: Viper customization should be saved in `vip-custom-file-name', which
326 defaults to `~/.viper'."
327 :prefix "vip-"
328 :group 'emulations)
330 (require 'viper-cmd)
332 (defvar vip-always t
333 "See `viper-always'. This variable is for compatibility with older Vipers.")
334 (defcustom viper-always vip-always
335 "Non-nil means, arrange for vi-state to be a default when appropriate.
336 This is different from `viper-mode' variable in that `viper-mode' determines
337 whether to use Viper in the first place, while `viper-always', if nil, lets
338 user decide when to invoke Viper in a major mode."
339 :type 'boolean
340 :tag "Always Invoke Viper"
341 :group 'viper)
343 ;; Non-viper variables that need to be saved in case the user decides to
344 ;; de-viperize emacs.
345 (defvar viper-saved-non-viper-variables nil)
346 ;; Contains user settings for vars affected by viper-set-expert-level function.
347 ;; Not a user option.
348 (defvar viper-saved-user-settings nil)
350 (defcustom viper-mode (cond (noninteractive nil)
351 (t 'ask))
352 "To Viperize or not to Viperize.
353 If t, viperize emacs. If nil -- don't. If `ask', ask the user.
354 This variable is used primatily when Viper is being loaded.
356 Must be set in `~/.emacs' before Viper is loaded.
357 DO NOT set this variable interactively."
358 :type '(choice (const nil) (const t) (const ask))
359 :tag "Set Viper Mode on Loading"
360 :group 'viper)
363 ;; The following are provided for compatibility with older VIP's
365 ;;;###autoload
366 (defalias 'vip-mode 'viper-mode)
368 (defalias 'vip-change-mode-to-vi 'vip-change-state-to-vi)
369 (defalias 'vip-change-mode-to-insert 'vip-change-state-to-insert)
370 (defalias 'vip-change-mode-to-emacs 'vip-change-state-to-emacs)
375 ;;;###autoload
376 (defun viper-mode ()
377 "Turn on Viper emulation of Vi."
378 (interactive)
379 (if (not noninteractive)
380 (progn
381 ;; if the user requested viper-mode explicitly
382 (if viper-mode
384 (setq viper-mode 1)
385 (load-library "viper"))
387 (if vip-first-time ; This check is important. Without it, startup and
388 (progn ; expert-level msgs mix up when viper-mode recurses
389 (setq vip-first-time nil)
390 (if (not vip-inhibit-startup-message)
391 (save-window-excursion
392 (setq vip-inhibit-startup-message t)
393 (delete-other-windows)
394 (switch-to-buffer "Viper Startup Message")
395 (erase-buffer)
396 (insert
397 (substitute-command-keys
398 "Viper Is a Package for Emacs Rebels,
399 a VI Plan for Emacs Rescue, and a venomous VI PERil.
401 Incidentally, Viper emulates Vi under GNU Emacs 20 and XEmacs 20.
402 It supports all of what is good in Vi and Ex, while extending
403 and improving upon much of it.
405 1. Viper supports Vi at several levels. Level 1 is the closest to Vi,
406 level 5 provides the most flexibility to depart from many Vi conventions.
408 You will be asked to specify your user level in a following screen.
410 If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave
411 as in VI, to smooth transition to Viper for the beginners. However, to
412 use Emacs productively, you are advised to reach user level 3 or higher.
414 At user level 2 or higher, ^X and ^C have Emacs, not Vi, bindings;
415 ^Z toggles Vi/Emacs states; ^G is Emacs' keyboard-quit (like ^C in Vi).
417 2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they
418 do not cause Emacs to quit, except at user level 1 (for a novice).
419 3. ^X^C EXITS EMACS.
420 4. Viper supports multiple undo: `u' will undo. Typing `.' will repeat
421 undo. Another `u' changes direction.
423 6. Emacs Meta key is `C-\\' (in all modes) or `\\ ESC' (in Vi command mode).
424 On a window system, the best way is to use the Meta-key on your keyboard.
425 7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if
426 something funny happens. This would abort the current editing command.
428 For more information on Viper:
430 a. Type `:help' in Vi command mode
431 b. Print Viper manual, found in ./etc/viper.dvi
432 c. Print the Quick Reference, found in ./etc/viperCard.dvi
434 To submit a bug report or to contact the author, type :submitReport in Vi
435 command mode. To shoo Viper away and return to pure Emacs (horror!), type:
437 M-x viper-go-away
439 This startup message appears whenever you load Viper, unless you type `y' now."
441 (goto-char (point-min))
442 (if (y-or-n-p "Inhibit Viper startup message? ")
443 (vip-save-setting
444 'vip-inhibit-startup-message
445 "Viper startup message inhibited"
446 vip-custom-file-name t))
447 ;;(kill-buffer (current-buffer))
448 (message
449 "The last message is in buffer `Viper Startup Message'")
450 (sit-for 4)
452 (viper-set-expert-level 'dont-change-unless)))
453 (vip-change-state-to-vi))))
456 ;; This hook designed to enable Vi-style editing in comint-based modes."
457 (defun vip-comint-mode-hook ()
458 (setq require-final-newline nil
459 vip-ex-style-editing-in-insert nil
460 vip-ex-style-motion nil)
461 (vip-change-state-to-insert))
464 ;; remove viper hooks from SYMBOL
465 (defun viper-remove-hooks (symbol)
466 (cond ((not (boundp symbol)) nil)
467 ((not (listp (eval symbol))) nil)
468 ((string-match "-hook" (symbol-name symbol))
469 (remove-hook symbol 'viper-mode)
470 (remove-hook symbol 'vip-change-state-to-emacs)
471 (remove-hook symbol 'vip-change-state-to-insert)
472 (remove-hook symbol 'vip-change-state-to-vi)
475 ;; Remove local value in all existing buffers
476 ;; This doesn't delocalize vars (which would have been desirable)
477 (defun viper-delocalize-var (symbol)
478 (mapcar (function (lambda (buf)
479 (save-excursion
480 (set-buffer buf)
481 (kill-local-variable symbol))))
482 (buffer-list)))
485 (defun viper-go-away ()
486 "De-Viperize Emacs.
487 This function tries to do as good a job as possible. However, it may undo some
488 user customization, unrelated to Viper. For instance, if the user advised
489 `read-file-name', `describe-key', and some others, then this advice will be
490 undone.
491 It also doesn't undo some Viper settings. For instance, `minor-mode-map-alist'
492 remains buffer-local."
493 (interactive)
495 ;; restore non-viper vars
496 (setq-default
497 default-major-mode
498 (viper-standard-value 'default-major-mode viper-saved-non-viper-variables)
499 next-line-add-newlines
500 (viper-standard-value
501 'next-line-add-newlines viper-saved-non-viper-variables)
502 require-final-newline
503 (viper-standard-value
504 'require-final-newline viper-saved-non-viper-variables)
505 scroll-step
506 (viper-standard-value 'scroll-step viper-saved-non-viper-variables)
507 mode-line-buffer-identification
508 (viper-standard-value
509 'mode-line-buffer-identification viper-saved-non-viper-variables)
510 global-mode-string
511 (viper-standard-value 'global-mode-string viper-saved-non-viper-variables))
513 (if vip-emacs-p
514 (setq-default
515 mark-even-if-inactive
516 (viper-standard-value
517 'mark-even-if-inactive viper-saved-non-viper-variables)))
519 ;; Ideally, we would like to be able to de-localize local variables
520 (viper-delocalize-var 'minor-mode-map-alist)
521 (viper-delocalize-var 'require-final-newline)
524 ;; deactivate all advices done by Viper.
525 (ad-deactivate-regexp "vip-")
527 (setq viper-mode nil)
529 (viper-delocalize-var 'vip-vi-minibuffer-minor-mode)
530 (viper-delocalize-var 'vip-insert-minibuffer-minor-mode)
531 (viper-delocalize-var 'vip-vi-intercept-minor-mode)
532 (viper-delocalize-var 'vip-insert-intercept-minor-mode)
534 (viper-delocalize-var 'vip-vi-local-user-minor-mode)
535 (viper-delocalize-var 'vip-vi-kbd-minor-mode)
536 (viper-delocalize-var 'vip-vi-global-user-minor-mode)
537 (viper-delocalize-var 'vip-vi-state-modifier-minor-mode)
538 (viper-delocalize-var 'vip-vi-diehard-minor-mode)
539 (viper-delocalize-var 'vip-vi-basic-minor-mode)
541 (viper-delocalize-var 'vip-replace-minor-mode)
543 (viper-delocalize-var 'vip-insert-local-user-minor-mode)
544 (viper-delocalize-var 'vip-insert-kbd-minor-mode)
545 (viper-delocalize-var 'vip-insert-global-user-minor-mode)
546 (viper-delocalize-var 'vip-insert-state-modifier-minor-mode)
547 (viper-delocalize-var 'vip-insert-diehard-minor-mode)
548 (viper-delocalize-var 'vip-insert-basic-minor-mode)
550 (viper-delocalize-var 'vip-emacs-intercept-minor-mode)
551 (viper-delocalize-var 'vip-emacs-local-user-minor-mode)
552 (viper-delocalize-var 'vip-emacs-kbd-minor-mode)
553 (viper-delocalize-var 'vip-emacs-global-user-minor-mode)
554 (viper-delocalize-var 'vip-emacs-state-modifier-minor-mode)
556 (setq-default vip-vi-minibuffer-minor-mode nil
557 vip-insert-minibuffer-minor-mode nil
558 vip-vi-intercept-minor-mode nil
559 vip-insert-intercept-minor-mode nil
561 vip-vi-local-user-minor-mode nil
562 vip-vi-kbd-minor-mode nil
563 vip-vi-global-user-minor-mode nil
564 vip-vi-state-modifier-minor-mode nil
565 vip-vi-diehard-minor-mode nil
566 vip-vi-basic-minor-mode nil
568 vip-replace-minor-mode nil
570 vip-insert-local-user-minor-mode nil
571 vip-insert-kbd-minor-mode nil
572 vip-insert-global-user-minor-mode nil
573 vip-insert-state-modifier-minor-mode nil
574 vip-insert-diehard-minor-mode nil
575 vip-insert-basic-minor-mode nil
577 vip-emacs-intercept-minor-mode nil
578 vip-emacs-local-user-minor-mode nil
579 vip-emacs-kbd-minor-mode nil
580 vip-emacs-global-user-minor-mode nil
581 vip-emacs-state-modifier-minor-mode nil
584 ;; remove all hooks set by viper
585 (mapatoms 'viper-remove-hooks)
586 (remove-hook 'comint-mode-hook 'vip-comint-mode-hook)
587 (remove-hook 'minibuffer-setup-hook 'vip-minibuffer-setup-sentinel)
593 ;; This sets major mode hooks to make them come up in vi-state.
594 (defun vip-set-hooks ()
596 ;; It is of course a misnomer to call viper-mode a `major mode'.
597 ;; However, this has the effect that if the user didn't specify the
598 ;; default mode, new buffers that fall back on the default will come up
599 ;; in Fundamental Mode and Vi state.
600 (setq default-major-mode 'viper-mode)
602 ;; The following major modes should come up in vi-state
603 (defadvice fundamental-mode (after vip-fundamental-mode-ad activate)
604 "Run `vip-change-state-to-vi' on entry."
605 (vip-change-state-to-vi))
607 (defvar makefile-mode-hook)
608 (add-hook 'makefile-mode-hook 'viper-mode)
610 (defvar help-mode-hook)
611 (add-hook 'help-mode-hook 'viper-mode)
612 (vip-modify-major-mode 'help-mode 'vi-state vip-help-modifier-map)
614 (defvar awk-mode-hook)
615 (add-hook 'awk-mode-hook 'viper-mode)
617 (defvar html-mode-hook)
618 (add-hook 'html-mode-hook 'viper-mode)
619 (defvar html-helper-mode-hook)
620 (add-hook 'html-helper-mode-hook 'viper-mode)
622 (defvar java-mode-hook)
623 (add-hook 'java-mode-hook 'viper-mode)
625 (defvar javascript-mode-hook)
626 (add-hook 'javascript-mode-hook 'viper-mode)
628 (defvar emacs-lisp-mode-hook)
629 (add-hook 'emacs-lisp-mode-hook 'viper-mode)
630 (defvar lisp-mode-hook)
631 (add-hook 'lisp-mode-hook 'viper-mode)
632 (defvar lisp-interaction-mode-hook)
633 (add-hook 'lisp-interaction-mode-hook 'viper-mode)
635 (defvar bibtex-mode-hook)
636 (add-hook 'bibtex-mode-hook 'viper-mode)
638 (defvar cc-mode-hook)
639 (add-hook 'cc-mode-hook 'viper-mode)
641 (defvar c-mode-hook)
642 (add-hook 'c-mode-hook 'viper-mode)
644 (defvar c++-mode-hook)
645 (add-hook 'c++-mode-hook 'viper-mode)
647 (defvar fortran-mode-hook)
648 (add-hook 'fortran-mode-hook 'viper-mode)
649 (defvar f90-mode-hook)
650 (add-hook 'f90-mode-hook 'viper-mode)
652 (defvar basic-mode-hook)
653 (add-hook 'basic-mode-hook 'viper-mode)
654 (defvar bat-mode-hook)
655 (add-hook 'bat-mode-hook 'viper-mode)
657 (defvar asm-mode-hook)
658 (add-hook 'asm-mode-hook 'viper-mode)
660 (defvar prolog-mode-hook)
661 (add-hook 'prolog-mode-hook 'viper-mode)
663 (defvar text-mode-hook)
664 (add-hook 'text-mode-hook 'viper-mode)
666 (add-hook 'completion-list-mode-hook 'viper-mode)
667 (add-hook 'compilation-mode-hook 'viper-mode)
669 (defvar perl-mode-hook)
670 (add-hook 'perl-mode-hook 'viper-mode)
672 (defvar tcl-mode-hook)
673 (add-hook 'tcl-mode-hook 'viper-mode)
675 (defvar python-mode-hook)
676 (add-hook 'python-mode-hook 'viper-mode)
678 (defvar emerge-startup-hook)
679 (add-hook 'emerge-startup-hook 'vip-change-state-to-emacs)
681 ;; Tell vc-diff to put *vc* in Vi mode
682 (if (featurep 'vc)
683 (defadvice vc-diff (after vip-vc-ad activate)
684 "Force Vi state in VC diff buffer."
685 (vip-change-state-to-vi))
686 (vip-eval-after-load
687 "vc"
688 '(defadvice vc-diff (after vip-vc-ad activate)
689 "Force Vi state in VC diff buffer."
690 (vip-change-state-to-vi))))
692 (vip-eval-after-load
693 "emerge"
694 '(defadvice emerge-quit (after vip-emerge-advice activate)
695 "Run `vip-change-state-to-vi' after quitting emerge."
696 (vip-change-state-to-vi)))
697 ;; In case Emerge was loaded before Viper.
698 (defadvice emerge-quit (after vip-emerge-advice activate)
699 "Run `vip-change-state-to-vi' after quitting emerge."
700 (vip-change-state-to-vi))
702 ;; passwd.el sets up its own buffer, which turns up in Vi mode,
703 ;; thus overriding the local map. We don't need Vi mode here.
704 (vip-eval-after-load
705 "passwd"
706 '(defadvice read-passwd-1 (before vip-passwd-ad activate)
707 "Switch to emacs state while reading password."
708 (vip-change-state-to-emacs)))
710 ;; Emacs shell, ange-ftp, and comint-based modes
711 (defvar comint-mode-hook)
712 (vip-modify-major-mode
713 'comint-mode 'insert-state vip-comint-mode-modifier-map)
714 (vip-modify-major-mode
715 'comint-mode 'vi-state vip-comint-mode-modifier-map)
716 (vip-modify-major-mode
717 'shell-mode 'insert-state vip-comint-mode-modifier-map)
718 (vip-modify-major-mode
719 'shell-mode 'vi-state vip-comint-mode-modifier-map)
720 ;; ange-ftp in XEmacs
721 (vip-modify-major-mode
722 'ange-ftp-shell-mode 'insert-state vip-comint-mode-modifier-map)
723 (vip-modify-major-mode
724 'ange-ftp-shell-mode 'vi-state vip-comint-mode-modifier-map)
725 ;; ange-ftp in Emacs
726 (vip-modify-major-mode
727 'internal-ange-ftp-mode 'insert-state vip-comint-mode-modifier-map)
728 (vip-modify-major-mode
729 'internal-ange-ftp-mode 'vi-state vip-comint-mode-modifier-map)
730 ;; set hook
731 (add-hook 'comint-mode-hook 'vip-comint-mode-hook)
733 ;; Shell scripts
734 (defvar sh-mode-hook)
735 (add-hook 'sh-mode-hook 'viper-mode)
736 (defvar ksh-mode-hook)
737 (add-hook 'ksh-mode-hook 'viper-mode)
739 ;; Dired
740 (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map)
741 (vip-set-emacs-state-searchstyle-macros nil 'dired-mode)
742 (add-hook 'dired-mode-hook 'vip-change-state-to-emacs)
744 ;; Tar
745 (vip-modify-major-mode 'tar-mode 'emacs-state vip-slash-and-colon-map)
746 (vip-set-emacs-state-searchstyle-macros nil 'tar-mode)
748 ;; MH-E
749 (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map)
750 (vip-set-emacs-state-searchstyle-macros nil 'mh-folder-mode)
751 ;; changing state to emacs is needed so the preceding will take hold
752 (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs)
753 (add-hook 'mh-show-mode-hook 'viper-mode)
755 ;; Gnus
756 (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map)
757 (vip-set-emacs-state-searchstyle-macros nil 'gnus-group-mode)
758 (vip-modify-major-mode
759 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map)
760 (vip-set-emacs-state-searchstyle-macros nil 'gnus-summary-mode)
761 ;; changing state to emacs is needed so the preceding will take hold
762 (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs)
763 (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs)
764 (add-hook 'gnus-article-mode-hook 'viper-mode)
766 ;; Info
767 (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map)
768 (vip-set-emacs-state-searchstyle-macros nil 'Info-mode)
769 ;; Switching to emacs is needed so the above will take hold
770 (defadvice Info-mode (after vip-Info-ad activate)
771 "Switch to emacs mode."
772 (vip-change-state-to-emacs))
774 ;; Buffer menu
775 (vip-modify-major-mode
776 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map)
777 (vip-set-emacs-state-searchstyle-macros nil 'Buffer-menu-mode)
778 ;; Switching to emacs is needed so the above will take hold
779 (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate)
780 "Switch to emacs mode."
781 (vip-change-state-to-emacs))
783 ;; View mode
784 (defvar view-mode-hook)
785 (defvar view-hook)
786 (add-hook 'view-hook 'vip-change-state-to-emacs)
787 (add-hook 'view-mode-hook 'vip-change-state-to-emacs)
789 ;; For VM users.
790 ;; Put summary and other VM buffers in Emacs state.
791 (defvar vm-mode-hooks)
792 (defvar vm-summary-mode-hooks)
793 (add-hook 'vm-mode-hooks 'vip-change-state-to-emacs)
794 (add-hook 'vm-summary-mode-hooks 'vip-change-state-to-emacs)
796 ;; For RMAIL users.
797 ;; Put buf in Emacs state after edit.
798 (vip-eval-after-load
799 "rmailedit"
800 '(defadvice rmail-cease-edit (after vip-rmail-advice activate)
801 "Switch to emacs state when done editing message."
802 (vip-change-state-to-emacs)))
803 ;; In case RMAIL was loaded before Viper.
804 (defadvice rmail-cease-edit (after vip-rmail-advice activate)
805 "Switch to emacs state when done editing message."
806 (vip-change-state-to-emacs))
807 ) ; vip-set-hooks
810 ;; these are primarily advices and Vi-ish variable settings
811 (defun vip-non-hook-settings ()
813 ;; This var is not local in Emacs, so we make it local.
814 ;; It must be local because although the stack of minor modes can be the same
815 ;; for all buffers, the associated *keymaps* can be different. In Viper,
816 ;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
817 ;; different keymaps for different buffers.
818 ;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
819 ;; can be different.
820 (make-variable-buffer-local 'minor-mode-map-alist)
822 ;; Viper changes the default mode-line-buffer-identification
823 (setq-default mode-line-buffer-identification '(" %b"))
825 ;; setup emacs-supported vi-style feel
826 (setq next-line-add-newlines nil
827 require-final-newline t)
829 (make-variable-buffer-local 'require-final-newline)
831 ;; don't bark when mark is inactive
832 (if vip-emacs-p
833 (setq mark-even-if-inactive t))
835 (setq scroll-step 1)
837 ;; Variable displaying the current Viper state in the mode line.
838 (vip-deflocalvar vip-mode-string vip-emacs-state-id)
839 (or (memq 'vip-mode-string global-mode-string)
840 (setq global-mode-string
841 (append '("" vip-mode-string) (cdr global-mode-string))))
843 (defadvice read-key-sequence (around vip-read-keyseq-ad activate)
844 "Harness to work for Viper. This advice is harmless---don't worry!"
845 (let (inhibit-quit event keyseq)
846 (setq keyseq ad-do-it)
847 (setq event (if vip-xemacs-p
848 (elt keyseq 0) ; XEmacs returns vector of events
849 (elt (listify-key-sequence keyseq) 0)))
850 (if (vip-ESC-event-p event)
851 (let (unread-command-events)
852 (vip-set-unread-command-events keyseq)
853 (if (vip-fast-keysequence-p)
854 (let ((vip-vi-global-user-minor-mode nil)
855 (vip-vi-local-user-minor-mode nil)
856 (vip-replace-minor-mode nil) ; actually unnecessary
857 (vip-insert-global-user-minor-mode nil)
858 (vip-insert-local-user-minor-mode nil))
859 (setq keyseq ad-do-it))
860 (setq keyseq ad-do-it))))
861 keyseq))
863 (defadvice describe-key (before vip-read-keyseq-ad protect activate)
864 "Force to read key via `read-key-sequence'."
865 (interactive (list (vip-events-to-keys
866 (read-key-sequence "Describe key: ")))))
868 (defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate)
869 "Force to read key via `read-key-sequence'."
870 (interactive (list (vip-events-to-keys
871 (read-key-sequence "Describe key briefly: ")))))
874 ;; Advice for use in find-file and read-file-name commands.
875 (defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate)
876 "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
877 (run-hooks 'vip-minibuffer-exit-hook))
879 (defadvice find-file (before vip-add-suffix-advice activate)
880 "Use `read-file-name' for reading arguments."
881 (interactive (cons (read-file-name "Find file: " nil default-directory)
882 ;; if Mule and prefix argument, ask for coding system
883 (cond ((and vip-emacs-p
884 (boundp 'MULE)) ; Emacs 20 with MULE
885 nil)
886 ((and vip-xemacs-p
887 (featurep 'mule)) ; XEmacs 20 with MULE
888 (list
889 (and current-prefix-arg
890 (read-coding-system
891 "Coding-system: "))))
895 (defadvice find-file-other-window (before vip-add-suffix-advice activate)
896 "Use `read-file-name' for reading arguments."
897 (interactive (cons (read-file-name "Find file in other window: "
898 nil default-directory)
899 ;; if Mule and prefix argument, ask for coding system
900 (cond ((and vip-emacs-p
901 (boundp 'MULE)) ; Emacs 20 with MULE
902 nil)
903 ((and vip-xemacs-p
904 (featurep 'mule)) ; XEmacs 20 with MULE
905 (list
906 (and current-prefix-arg
907 (read-coding-system
908 "Coding-system: "))))
913 (defadvice find-file-other-frame (before vip-add-suffix-advice activate)
914 "Use `read-file-name' for reading arguments."
915 (interactive (cons (read-file-name "Find file in other frame: "
916 nil default-directory)
917 ;; if Mule and prefix argument, ask for coding system
918 (cond ((and vip-emacs-p
919 (boundp 'MULE)) ; Emacs 20 with MULE
920 nil)
921 ((and vip-xemacs-p
922 (featurep 'mule)) ; XEmacs 20 with MULE
923 (list
924 (and current-prefix-arg
925 (read-coding-system
926 "Coding-system: "))))
931 (defadvice read-file-name (around vip-suffix-advice activate)
932 "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
933 (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
934 ad-do-it))
936 (defadvice start-kbd-macro (after vip-kbd-advice activate)
937 "Remove Viper's intercepting bindings for C-x ).
938 This may be needed if the previous `:map' command terminated abnormally."
939 (define-key vip-vi-intercept-map "\C-x)" nil)
940 (define-key vip-insert-intercept-map "\C-x)" nil)
941 (define-key vip-emacs-intercept-map "\C-x)" nil))
943 (cond ((vip-window-display-p)
944 (let* ((search-key (if vip-xemacs-p
945 [(meta shift button1up)] [M-S-mouse-1]))
946 (search-key-catch
947 (if vip-xemacs-p [(meta shift button1)] [M-S-down-mouse-1]))
948 (insert-key (if vip-xemacs-p
949 [(meta shift button2up)] [M-S-mouse-2]))
950 (insert-key-catch
951 (if vip-xemacs-p [(meta shift button2)] [M-S-down-mouse-2]))
952 (search-key-unbound (and (not (key-binding search-key))
953 (not (key-binding search-key-catch))))
954 (insert-key-unbound (and (not (key-binding insert-key))
955 (not (key-binding insert-key-catch))))
958 (if search-key-unbound
959 (global-set-key search-key 'vip-mouse-click-search-word))
960 (if insert-key-unbound
961 (global-set-key insert-key 'vip-mouse-click-insert-word))
963 ;; The following would be needed if you want to use the above two
964 ;; while clicking in another frame. If you only want to use them
965 ;; by clicking in another window, not frame, the bindings below
966 ;; aren't necessary.
968 ;; These must be bound to mouse-down event for the same mouse
969 ;; buttons as 'vip-mouse-click-search-word and
970 ;; 'vip-mouse-click-insert-word
971 (if search-key-unbound
972 (global-set-key search-key-catch 'vip-mouse-catch-frame-switch))
973 (if insert-key-unbound
974 (global-set-key insert-key-catch 'vip-mouse-catch-frame-switch))
976 (if vip-xemacs-p
977 (add-hook 'mouse-leave-frame-hook
978 'vip-remember-current-frame)
979 (defadvice handle-switch-frame (before vip-frame-advice activate)
980 "Remember the selected frame before the switch-frame event."
981 (vip-remember-current-frame (selected-frame))))
983 ) ; end vip-non-hook-settings
986 (if (eq viper-mode 'ask)
987 (progn
988 (save-window-excursion
989 (with-output-to-temp-buffer " *vip-info*"
990 (princ "
991 You have loaded Viper, and are about to Viperize your emacs!
993 Viper is a Package for Emacs Rebels
994 and a venomous VI PERil,
996 It's time to decide: to Viperize or not to Viperize...
998 If you wish to Viperize AND make this your way of life, please put
1000 (setq viper-mode t)
1001 (require 'viper)
1003 in your .emacs file (preferably, close to the top).
1004 These two lines must come in the order given.
1006 Also, the startup file name has been changed from .vip to .viper"))
1007 (if (y-or-n-p "Viperize? ")
1008 (setq viper-mode t)
1009 (setq viper-mode nil))
1010 (message "")
1011 (kill-buffer " *vip-info*"))))
1016 ;; Get viper standard value of SYMBOL. If symbol is customized, get its
1017 ;; standard value. Otherwise, get the value saved in the alist STORAGE. If
1018 ;; STORAGE is nil, use viper-saved-user-settings.
1019 (defun viper-standard-value (symbol &optional storage)
1020 (or (eval (car (get symbol 'customized-value)))
1021 (eval (car (get symbol 'saved-value)))
1022 (nth 1 (assoc symbol (or storage viper-saved-user-settings)))))
1026 ;; save non-viper vars that Viper might change
1027 (if (null viper-saved-non-viper-variables)
1028 (setq viper-saved-non-viper-variables
1029 (list
1030 (cons 'default-major-mode (list default-major-mode))
1031 (cons 'next-line-add-newlines (list next-line-add-newlines))
1032 (cons 'require-final-newline (list require-final-newline))
1033 (cons 'scroll-step (list scroll-step))
1034 (cons 'mode-line-buffer-identification
1035 (list (default-value 'mode-line-buffer-identification)))
1036 (cons 'global-mode-string (list global-mode-string))
1037 (if vip-emacs-p
1038 (cons 'mark-even-if-inactive (list mark-even-if-inactive)))
1042 ;; Set some useful macros, advices
1043 ;; These must be BEFORE ~/.viper is loaded,
1044 ;; so the user can unrecord them in ~/.viper.
1045 (if viper-mode
1046 (progn
1047 ;; set advices and some variables that give emacs Vi look.
1048 (vip-non-hook-settings)
1050 ;; repeat the 2nd previous command without rotating the command history
1051 (vip-record-kbd-macro
1052 (vector vip-repeat-from-history-key '\1) 'vi-state
1053 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't)
1054 ;; repeat the 3d previous command without rotating the command history
1055 (vip-record-kbd-macro
1056 (vector vip-repeat-from-history-key '\2) 'vi-state
1057 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't)
1059 ;; set macros for toggling case sensitivity and regexp search
1060 (vip-set-searchstyle-toggling-macros nil)
1061 ;; Make %%% toggle parsing comments for matching parentheses
1062 (vip-set-parsing-style-toggling-macro nil)
1066 ;; ~/.viper is loaded if it exists
1067 (if (and (file-exists-p vip-custom-file-name)
1068 viper-mode
1069 (not noninteractive))
1070 (load vip-custom-file-name))
1072 ;; VIP compatibility: merge whatever the user has in vip-mode-map into
1073 ;; Viper's basic map.
1074 (vip-add-keymap vip-mode-map vip-vi-global-user-map)
1076 (if (boundp 'vip-expert-level)
1077 (setq viper-expert-level vip-expert-level))
1081 ;; Applying Viper customization -- runs after (load .vip)
1083 ;; Save user settings or Viper defaults for vars controled by
1084 ;; viper-expert-level
1085 (if (null viper-saved-user-settings)
1086 (setq viper-saved-user-settings
1087 (list (cons 'vip-want-ctl-h-help (list vip-want-ctl-h-help))
1088 (cons 'viper-always (list viper-always))
1089 (cons 'vip-no-multiple-ESC (list vip-no-multiple-ESC))
1090 (cons 'vip-ex-style-motion (list vip-ex-style-motion))
1091 (cons 'vip-ex-style-editing-in-insert
1092 (list vip-ex-style-editing-in-insert))
1093 (cons 'vip-want-emacs-keys-in-vi
1094 (list vip-want-emacs-keys-in-vi))
1095 (cons 'vip-electric-mode (list vip-electric-mode))
1096 (cons 'vip-want-emacs-keys-in-insert
1097 (list vip-want-emacs-keys-in-insert))
1098 (cons 'vip-re-search (list vip-re-search)))))
1101 (if viper-mode
1102 (progn
1103 (vip-set-minibuffer-style)
1104 (if vip-buffer-search-char
1105 (vip-buffer-search-enable))
1106 (vip-update-alphanumeric-class)
1110 ;;; Familiarize Viper with some minor modes that have their own keymaps
1111 (if viper-mode
1112 (progn
1113 (vip-harness-minor-mode "compile")
1114 (vip-harness-minor-mode "outline")
1115 (vip-harness-minor-mode "allout")
1116 (vip-harness-minor-mode "xref")
1117 (vip-harness-minor-mode "lmenu")
1118 (vip-harness-minor-mode "vc")
1119 (vip-harness-minor-mode "ltx-math") ; LaTeX-math-mode in AUC-TeX
1120 (vip-harness-minor-mode "latex") ; which is in one of these two files
1121 (vip-harness-minor-mode "cyrillic")
1122 (vip-harness-minor-mode "russian")
1123 (vip-harness-minor-mode "view-less")
1124 (vip-harness-minor-mode "view")
1128 ;; Intercept maps could go in viper-keym.el
1129 ;; We keep them here in case someone redefines them in ~/.viper
1131 (define-key vip-vi-intercept-map vip-ESC-key 'vip-intercept-ESC-key)
1132 (define-key vip-insert-intercept-map vip-ESC-key 'vip-intercept-ESC-key)
1134 ;; This is taken care of by vip-insert-global-user-map.
1135 ;;(define-key vip-replace-map vip-ESC-key 'vip-intercept-ESC-key)
1138 ;; The default vip-toggle-key is \C-z; for the novice, it suspends or
1139 ;; iconifies Emacs
1140 (define-key vip-vi-intercept-map vip-toggle-key 'vip-toggle-key-action)
1141 (define-key vip-emacs-intercept-map vip-toggle-key 'vip-change-state-to-vi)
1144 (if (and viper-mode
1145 (or viper-always
1146 (and (< viper-expert-level 5) (> viper-expert-level 0))))
1147 (vip-set-hooks))
1149 ;; Let all minor modes take effect after loading
1150 ;; this may not be enough, so we also set default minor-mode-alist.
1151 ;; Without setting the default, new buffers that come up in emacs mode have
1152 ;; minor-mode-map-alist = nil, unless we call vip-change-state-*
1153 (if (eq vip-current-state 'emacs-state)
1154 (progn
1155 (vip-change-state-to-emacs)
1156 (setq-default minor-mode-map-alist minor-mode-map-alist)
1161 (run-hooks 'vip-load-hook) ; the last chance to change something
1163 (provide 'vip)
1164 (provide 'viper)
1167 ;;; Local Variables:
1168 ;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun)
1169 ;;; End:
1171 ;;; viper.el ends here