new version
[emacs.git] / lisp / emulation / viper-init.el
blobfa29b3add68c05052e82a0ea6c430800001148f4
1 ;;; viper-init.el --- some common definitions for Viper
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;; Code
24 (provide 'viper-init)
26 ;; compiler pacifier
27 (defvar mark-even-if-inactive)
28 ;; end pacifier
30 ;; Is it XEmacs?
31 (defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
32 ;; Is it Emacs?
33 (defconst vip-emacs-p (not vip-xemacs-p))
34 ;; Tell whether we are running as a window application or on a TTY
35 (defsubst vip-device-type ()
36 (if vip-emacs-p
37 window-system
38 (device-type (selected-device))))
39 ;; in XEmacs: device-type is tty on tty and stream in batch.
40 (defun vip-window-display-p ()
41 (and (vip-device-type) (not (memq (vip-device-type) '(tty stream pc)))))
43 (defvar vip-ms-style-os-p (memq system-type '(ms-dos windows-nt windows-95))
44 "Tells if Emacs is running under an MS-style OS: ms-dos, windows-nt, W95.")
45 (defvar vip-vms-os-p (memq system-type '(vax-vms axp-vms))
46 "Tells if Emacs is running under VMS.")
48 (defvar vip-force-faces nil
49 "If t, Viper will think that it is running on a display that supports faces.
50 This is provided as a temporary relief for users of face-capable displays
51 that Viper doesn't know about.")
53 (defun vip-has-face-support-p ()
54 (cond ((vip-window-display-p))
55 (vip-force-faces)
56 (vip-emacs-p (memq (vip-device-type) '(pc)))
57 (vip-xemacs-p (memq (vip-device-type) '(tty pc)))))
59 (defun vip-convert-standard-file-name (fname)
60 (if vip-emacs-p
61 (convert-standard-filename fname)
62 ;; hopefully, XEmacs adds this functionality
63 fname))
66 ;;; Macros
68 (defmacro vip-deflocalvar (var default-value &optional documentation)
69 (` (progn
70 (defvar (, var) (, default-value)
71 (, (format "%s\n\(buffer local\)" documentation)))
72 (make-variable-buffer-local '(, var))
73 )))
75 (defmacro vip-loop (count body)
76 "(vip-loop COUNT BODY) Execute BODY COUNT times."
77 (list 'let (list (list 'count count))
78 (list 'while '(> count 0)
79 body
80 '(setq count (1- count))
81 )))
83 (defmacro vip-buffer-live-p (buf)
84 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
86 ;; return buffer-specific macro definition, given a full macro definition
87 (defmacro vip-kbd-buf-alist (macro-elt)
88 (` (nth 1 (, macro-elt))))
89 ;; get a pair: (curr-buffer . macro-definition)
90 (defmacro vip-kbd-buf-pair (macro-elt)
91 (` (assoc (buffer-name) (vip-kbd-buf-alist (, macro-elt)))))
92 ;; get macro definition for current buffer
93 (defmacro vip-kbd-buf-definition (macro-elt)
94 (` (cdr (vip-kbd-buf-pair (, macro-elt)))))
96 ;; return mode-specific macro definitions, given a full macro definition
97 (defmacro vip-kbd-mode-alist (macro-elt)
98 (` (nth 2 (, macro-elt))))
99 ;; get a pair: (major-mode . macro-definition)
100 (defmacro vip-kbd-mode-pair (macro-elt)
101 (` (assoc major-mode (vip-kbd-mode-alist (, macro-elt)))))
102 ;; get macro definition for the current major mode
103 (defmacro vip-kbd-mode-definition (macro-elt)
104 (` (cdr (vip-kbd-mode-pair (, macro-elt)))))
106 ;; return global macro definition, given a full macro definition
107 (defmacro vip-kbd-global-pair (macro-elt)
108 (` (nth 3 (, macro-elt))))
109 ;; get global macro definition from an elt of macro-alist
110 (defmacro vip-kbd-global-definition (macro-elt)
111 (` (cdr (vip-kbd-global-pair (, macro-elt)))))
113 ;; last elt of a sequence
114 (defsubst vip-seq-last-elt (seq)
115 (elt seq (1- (length seq))))
118 (defvar vip-minibuffer-overlay-priority 300)
119 (defvar vip-replace-overlay-priority 400)
120 (defvar vip-search-overlay-priority 500)
123 ;;; Viper minor modes
125 ;; This is not local in Emacs, so we make it local.
126 ;; This must be local because although the stack of minor modes can be the same
127 ;; for all buffers, the associated *keymaps* can be different. In Viper,
128 ;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
129 ;; different keymaps for different buffers.
130 ;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
131 ;; can be different.
132 (make-variable-buffer-local 'minor-mode-map-alist)
134 ;; Mode for vital things like \e, C-z.
135 (vip-deflocalvar vip-vi-intercept-minor-mode nil)
137 (vip-deflocalvar vip-vi-basic-minor-mode nil
138 "Viper's minor mode for Vi bindings.")
140 (vip-deflocalvar vip-vi-local-user-minor-mode nil
141 "Auxiliary minor mode for user-defined local bindings in Vi state.")
143 (vip-deflocalvar vip-vi-global-user-minor-mode nil
144 "Auxiliary minor mode for user-defined global bindings in Vi state.")
146 (vip-deflocalvar vip-vi-state-modifier-minor-mode nil
147 "Minor mode used to make major-mode-specific modification to Vi state.")
149 (vip-deflocalvar vip-vi-diehard-minor-mode nil
150 "This minor mode is in effect when the user wants Viper to be Vi.")
152 (vip-deflocalvar vip-vi-kbd-minor-mode nil
153 "Minor mode for Ex command macros in Vi state.
154 The corresponding keymap stores key bindings of Vi macros defined with
155 the Ex command :map.")
157 ;; Mode for vital things like \e, C-z.
158 (vip-deflocalvar vip-insert-intercept-minor-mode nil)
160 (vip-deflocalvar vip-insert-basic-minor-mode nil
161 "Viper's minor mode for bindings in Insert mode.")
163 (vip-deflocalvar vip-insert-local-user-minor-mode nil
164 "Auxiliary minor mode for buffer-local user-defined bindings in Insert state.
165 This is a way to overshadow normal Insert mode bindings locally to certain
166 designated buffers.")
168 (vip-deflocalvar vip-insert-global-user-minor-mode nil
169 "Auxiliary minor mode for global user-defined bindings in Insert state.")
171 (vip-deflocalvar vip-insert-state-modifier-minor-mode nil
172 "Minor mode used to make major-mode-specific modification to Insert state.")
174 (vip-deflocalvar vip-insert-diehard-minor-mode nil
175 "Minor mode that simulates Vi very closely.
176 Not recommened, except for the novice user.")
178 (vip-deflocalvar vip-insert-kbd-minor-mode nil
179 "Minor mode for Ex command macros Insert state.
180 The corresponding keymap stores key bindings of Vi macros defined with
181 the Ex command :map!.")
183 (vip-deflocalvar vip-replace-minor-mode nil
184 "Minor mode in effect in replace state (cw, C, and the like commands).")
186 ;; Mode for vital things like \C-z and \C-x)
187 ;; This is t, by default. So, any new buffer will have C-z defined as
188 ;; switch to Vi, unless we switched states in this buffer
189 (vip-deflocalvar vip-emacs-intercept-minor-mode t)
191 (vip-deflocalvar vip-emacs-local-user-minor-mode t
192 "Minor mode for local user bindings effective in Emacs state.
193 Users can use it to override Emacs bindings when Viper is in its Emacs
194 state.")
196 (vip-deflocalvar vip-emacs-global-user-minor-mode t
197 "Minor mode for global user bindings in effect in Emacs state.
198 Users can use it to override Emacs bindings when Viper is in its Emacs
199 state.")
201 (vip-deflocalvar vip-emacs-kbd-minor-mode t
202 "Minor mode for Vi style macros in Emacs state.
203 The corresponding keymap stores key bindings of Vi macros defined with
204 `vip-record-kbd-macro' command. There is no Ex-level command to do this
205 interactively.")
207 (vip-deflocalvar vip-emacs-state-modifier-minor-mode t
208 "Minor mode used to make major-mode-specific modification to Emacs state.
209 For instance, a Vi purist may want to bind `dd' in Dired mode to a function
210 that deletes a file.")
212 (vip-deflocalvar vip-vi-minibuffer-minor-mode nil
213 "Minor mode that forces Vi-style when the Minibuffer is in Vi state.")
215 (vip-deflocalvar vip-insert-minibuffer-minor-mode nil
216 "Minor mode that forces Vi-style when the Minibuffer is in Insert state.")
220 ;; Some common error messages
222 (defconst vip-SpuriousText "Spurious text after command" "")
223 (defconst vip-BadExCommand "Not an editor command" "")
224 (defconst vip-InvalidCommandArgument "Invalid command argument" "")
225 (defconst vip-NoPrevSearch "No previous search string" "")
226 (defconst vip-EmptyRegister "`%c': Nothing in this register" "")
227 (defconst vip-InvalidRegister "`%c': Invalid register" "")
228 (defconst vip-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "")
229 (defconst vip-InvalidTextmarker "`%c': Invalid text marker" "")
230 (defconst vip-InvalidViCommand "Invalid command" "")
231 (defconst vip-BadAddress "Ill-formed address" "")
232 (defconst vip-FirstAddrExceedsSecond "First address exceeds second" "")
233 (defconst vip-NoFileSpecified "No file specified" "")
235 ;; Is t until viper-mode executes for the very first time.
236 ;; Prevents recursive descend into startup messages.
237 (defvar vip-first-time t)
239 (defvar vip-expert-level 0
240 "User's expert level.
241 The minor mode vip-vi-diehard-minor-mode is in effect when
242 vip-expert-level is 1 or 2 or when vip-want-emacs-keys-in-vi is t.
243 The minor mode vip-insert-diehard-minor-mode is in effect when
244 vip-expert-level is 1 or 2 or if vip-want-emacs-keys-in-insert is t.
245 Use `M-x vip-set-expert-level' to change this.")
247 ;; Max expert level supported by Viper. This is NOT a user option.
248 ;; It is here to make it hard for the user from resetting it.
249 (defconst vip-max-expert-level 5)
251 ;; Contains user settings for vars affected by vip-set-expert-level function.
252 ;; Not a user option.
253 (defvar vip-saved-user-settings nil)
256 ;;; ISO characters
258 (vip-deflocalvar vip-automatic-iso-accents nil
259 "*If non-nil, ISO accents will be turned on in insert/replace emacs states and turned off in vi-state.
260 For some users, this behavior may be too primitive. In this case, use
261 insert/emacs/vi state hooks.")
264 ;; VI-style Undo
266 ;; Used to 'undo' complex commands, such as replace and insert commands.
267 (vip-deflocalvar vip-undo-needs-adjustment nil)
268 (put 'vip-undo-needs-adjustment 'permanent-local t)
270 ;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a
271 ;; complex command that must be undone atomically. If inserted, it is
272 ;; erased by vip-change-state-to-vi and vip-repeat.
273 (defconst vip-buffer-undo-list-mark 'viper)
275 (defvar vip-keep-point-on-undo nil
276 "*Non-nil means not to move point while undoing commands.
277 This style is different from Emacs and Vi. Try it to see if
278 it better fits your working style.")
280 ;; Replace mode and changing text
282 ;; Viper's own after/before change functions, which get vip-add-hook'ed to
283 ;; Emacs's
284 (vip-deflocalvar vip-after-change-functions nil "")
285 (vip-deflocalvar vip-before-change-functions nil "")
286 (vip-deflocalvar vip-post-command-hooks nil "")
287 (vip-deflocalvar vip-pre-command-hooks nil "")
289 ;; Can be used to pass global states around for short period of time
290 (vip-deflocalvar vip-intermediate-command nil "")
292 ;; Indicates that the current destructive command has started in replace mode.
293 (vip-deflocalvar vip-began-as-replace nil "")
295 (defvar vip-allow-multiline-replace-regions t
296 "If non-nil, Viper will allow multi-line replace regions.
297 This is an extension to standard Vi.
298 If nil, commands that attempt to replace text spanning multiple lines first
299 delete the text being replaced, as in standard Vi.")
301 (defvar vip-replace-overlay-cursor-color "Red"
302 "*Cursor color to use in Replace state")
303 (defvar vip-insert-state-cursor-color nil
304 "Cursor color for Viper insert state.")
305 (put 'vip-insert-state-cursor-color 'permanent-local t)
306 ;; place to save cursor colow when switching to insert mode
307 (vip-deflocalvar vip-saved-cursor-color nil "")
309 (vip-deflocalvar vip-replace-overlay nil "")
310 (put 'vip-replace-overlay 'permanent-local t)
312 (defvar vip-replace-overlay-pixmap "gray3"
313 "Pixmap to use for search face on non-color displays.")
314 (defvar vip-search-face-pixmap "gray3"
315 "Pixmap to use for search face on non-color displays.")
318 (defvar vip-replace-region-end-delimiter "$"
319 "A string marking the end of replacement regions.
320 It is used only with TTYs or if `vip-use-replace-region-delimiters'
321 is non-nil.")
322 (defvar vip-replace-region-start-delimiter ""
323 "A string marking the beginning of replacement regions.
324 It is used only with TTYs or if `vip-use-replace-region-delimiters'
325 is non-nil.")
326 (defvar vip-use-replace-region-delimiters (not (vip-has-face-support-p))
327 "*If non-nil, Viper will always use `vip-replace-region-end-delimiter' and
328 `vip-replace-region-start-delimiter' to delimit replacement regions, even on
329 color displays. By default, the delimiters are used only on TTYs.")
331 ;; XEmacs requires glyphs
332 (if vip-xemacs-p
333 (progn
334 (or (glyphp vip-replace-region-end-delimiter)
335 (setq vip-replace-region-end-delimiter
336 (make-glyph vip-replace-region-end-delimiter)))
337 (or (glyphp vip-replace-region-start-delimiter)
338 (setq vip-replace-region-start-delimiter
339 (make-glyph vip-replace-region-start-delimiter)))
343 ;; These are local marker that must be initialized to nil and moved with
344 ;; `vip-move-marker-locally'
346 ;; Remember the last position inside the replace region.
347 (vip-deflocalvar vip-last-posn-in-replace-region nil)
348 ;; Remember the last position while inserting
349 (vip-deflocalvar vip-last-posn-while-in-insert-state nil)
350 (put 'vip-last-posn-in-replace-region 'permanent-local t)
351 (put 'vip-last-posn-while-in-insert-state 'permanent-local t)
353 (vip-deflocalvar vip-sitting-in-replace nil "")
354 (put 'vip-sitting-in-replace 'permanent-local t)
356 ;; Remember the number of characters that have to be deleted in replace
357 ;; mode to compensate for the inserted characters.
358 (vip-deflocalvar vip-replace-chars-to-delete 0 "")
359 (vip-deflocalvar vip-replace-chars-deleted 0 "")
361 ;; Insertion ring and command ring
362 (defvar vip-insertion-ring-size 14
363 "The size of the insertion ring.")
364 ;; The insertion ring.
365 (defvar vip-insertion-ring nil)
366 ;; This is temp insertion ring. Used to do rotation for display purposes.
367 ;; When rotation just started, it is initialized to vip-insertion-ring.
368 (defvar vip-temp-insertion-ring nil)
369 (defvar vip-last-inserted-string-from-insertion-ring "")
371 (defvar vip-command-ring-size 14
372 "The size of the command ring.")
373 ;; The command ring.
374 (defvar vip-command-ring nil)
375 ;; This is temp command ring. Used to do rotation for display purposes.
376 ;; When rotation just started, it is initialized to vip-command-ring.
377 (defvar vip-temp-command-ring nil)
379 ;; Modes and related variables
381 ;; Current mode. One of: `emacs-state', `vi-state', `insert-state'
382 (vip-deflocalvar vip-current-state 'emacs-state)
385 ;; Autoindent in insert
387 ;; Variable that keeps track of whether C-t has been pressed.
388 (vip-deflocalvar vip-cted nil "")
390 ;; Preserve the indent value, used by C-d in insert mode.
391 (vip-deflocalvar vip-current-indent 0)
393 ;; Whether to preserve the indent, used by C-d in insert mode.
394 (vip-deflocalvar vip-preserve-indent nil)
396 (vip-deflocalvar vip-auto-indent nil
397 "*Autoindent if t.")
398 (vip-deflocalvar vip-electric-mode t
399 "*If t, enable electric behavior.
400 Currently only enables auto-indentation `according to mode'.")
402 (defconst vip-shift-width 8
403 "*The shiftwidth variable.")
405 ;; Variables for repeating destructive commands
407 (defconst vip-keep-point-on-repeat t
408 "*If t, don't move point when repeating previous command.
409 This is useful for doing repeated changes with the '.' key.
410 The user can change this to nil, if she likes when the cursor moves
411 to a new place after repeating previous Vi command.")
413 ;; Remember insert point as a marker. This is a local marker that must be
414 ;; initialized to nil and moved with `vip-move-marker-locally'.
415 (vip-deflocalvar vip-insert-point nil)
416 (put 'vip-insert-point 'permanent-local t)
418 ;; This remembers the point before dabbrev-expand was called.
419 ;; If vip-insert-point turns out to be bigger than that, it is reset
420 ;; back to vip-pre-command-point.
421 ;; The reason this is needed is because dabbrev-expand (and possibly
422 ;; others) may jump to before the insertion point, delete something and
423 ;; then reinsert a bigger piece. For instance: bla^blo
424 ;; If dabbrev-expand is called after `blo' and ^ undicates vip-insert-point,
425 ;; then point jumps to the beginning of `blo'. If expansion is found, `blablo'
426 ;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand
427 ;; will insert the expansion, and we get: blablo^
428 ;; Whatever we insert next goes before the ^, i.e., before the
429 ;; vip-insert-point marker. So, Viper will think that nothing was
430 ;; inserted. Remembering the orig position of the marker circumvents the
431 ;; problem.
432 ;; We don't know of any command, except dabbrev-expand, that has the same
433 ;; problem. However, the same trick can be used if such a command is
434 ;; discovered later.
436 (vip-deflocalvar vip-pre-command-point nil)
437 (put 'vip-pre-command-point 'permanent-local t) ; this is probably an overkill
439 ;; This is used for saving inserted text.
440 (defvar vip-last-insertion nil)
442 ;; Remembers the last replaced region.
443 (defvar vip-last-replace-region "")
445 ;; Remember com point as a marker.
446 ;; This is a local marker. Should be moved with `vip-move-marker-locally'
447 (vip-deflocalvar vip-com-point nil)
449 ;; If non-nil, the value is a list (M-COM VAL COM REG inserted-text cmd-keys)
450 ;; It is used to re-execute last destructive command.
451 ;; M-COM is a Lisp symbol representing the function to be executed.
452 ;; VAL is the prefix argument that was used with that command.
453 ;; COM is an internal descriptor, such as ?r, ?c, ?C, which contains
454 ;; additional information on how the function in M-COM is to be handled.
455 ;; REG is the register used by command
456 ;; INSERTED-TEXT is text inserted by that command (in case of o, c, C, i, r
457 ;; commands).
458 ;; COMMAND-KEYS are the keys that were typed to invoke the command.
459 (defvar vip-d-com nil)
461 ;; The character remembered by the Vi `r' command.
462 (defvar vip-d-char nil)
464 ;; Name of register to store deleted or yanked strings
465 (defvar vip-use-register nil)
469 ;; Variables for Moves and Searches
471 ;; For use by `;' command.
472 (defvar vip-f-char nil)
474 ;; For use by `.' command.
475 (defvar vip-F-char nil)
477 ;; For use by `;' command.
478 (defvar vip-f-forward nil)
480 ;; For use by `;' command.
481 (defvar vip-f-offset nil)
483 ;; Last search string
484 (defvar vip-s-string "")
486 (defvar vip-quote-string "> "
487 "String inserted at the beginning of quoted region.")
489 ;; If t, search is forward.
490 (defvar vip-s-forward nil)
492 (defconst vip-case-fold-search nil
493 "*If not nil, search ignores cases.")
495 (defconst vip-re-search t
496 "*If not nil, search is reg-exp search, otherwise vanilla search.")
498 (defvar vip-search-scroll-threshold 2
499 "*If search lands within this threshnold from the window top/bottom,
500 the window will be scrolled up or down appropriately, to reveal context.
501 If you want Viper search to behave as usual in Vi, set this variable to a
502 negative number.")
504 (defconst vip-re-query-replace t
505 "*If t then do regexp replace, if nil then do string replace.")
507 (defconst vip-re-replace t
508 "*If t, do regexp replace. nil means do string replace.")
510 (defvar vip-parse-sexp-ignore-comments t
511 "*If t, `%' ignores the parentheses that occur inside comments.")
513 (vip-deflocalvar vip-ex-style-motion t
514 "*Ex-style: the commands l,h do not cross lines, etc.")
516 (vip-deflocalvar vip-ex-style-editing-in-insert t
517 "*The keys ^H, ^? don't jump lines in insert, ESC moves cursor back, etc.
518 Note: this doesn't preclude ^H and ^? from deleting characters by moving
519 past the insertion point. This is a feature, not a bug. ")
521 (vip-deflocalvar vip-delete-backwards-in-replace nil
522 "*If t, DEL key will delete characters while moving the cursor backwards.
523 If nil, the cursor will move backwards without deleting anything.")
525 (defconst vip-buffer-search-char nil
526 "*Key bound for buffer-searching.")
528 (defconst vip-search-wrap-around-t t
529 "*If t, search wraps around.")
531 (vip-deflocalvar vip-related-files-and-buffers-ring nil
532 "*Ring of file and buffer names that are considered to be related to the
533 current buffer.
534 These buffers can be cycled through via :R and :P commands.")
535 (put 'vip-related-files-and-buffers-ring 'permanent-local t)
537 ;; Used to find out if we are done with searching the current buffer.
538 (vip-deflocalvar vip-local-search-start-marker nil)
539 ;; As above, but global
540 (defvar vip-search-start-marker (make-marker))
542 ;; the search overlay
543 (vip-deflocalvar vip-search-overlay nil)
546 (defvar vip-heading-start
547 (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp
548 "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++
549 "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|"
550 "^\\\\[sb][a-z]*{.*}\\s-*$\\|" ; latex
551 "^@node\\|@table\\|^@m?enu\\|^@itemize\\|^@if\\|" ; texinfo
552 "^.+:-") ; prolog
553 "*Regexps for Headings. Used by \[\[ and \]\].")
555 (defvar vip-heading-end
556 (concat "^}\\|" ; C/C++
557 "^\\\\end{\\|" ; latex
558 "^@end \\|" ; texinfo
559 ")\n\n[ \t\n]*\\|" ; lisp
560 "\\.\\s-*$") ; prolog
561 "*Regexps to end Headings/Sections. Used by \[\].")
564 ;; These two vars control the interaction of jumps performed by ' and `.
565 ;; In this new version, '' doesn't erase the marks set by ``, so one can
566 ;; use both kinds of jumps interchangeably and without loosing positions
567 ;; inside the lines.
569 ;; Remembers position of the last jump done using ``'.
570 (vip-deflocalvar vip-last-jump nil)
571 ;; Remembers position of the last jump done using `''.
572 (vip-deflocalvar vip-last-jump-ignore 0)
574 ;; History variables
576 ;; History of search strings.
577 (defvar vip-search-history (list ""))
578 ;; History of query-replace strings used as a source.
579 (defvar vip-replace1-history nil)
580 ;; History of query-replace strings used as replacement.
581 (defvar vip-replace2-history nil)
582 ;; History of region quoting strings.
583 (defvar vip-quote-region-history (list vip-quote-string))
584 ;; History of Ex-style commands.
585 (defvar vip-ex-history nil)
586 ;; History of shell commands.
587 (defvar vip-shell-history nil)
590 ;; Last shell command. There are two of these, one for Ex (in viper-ex)
591 ;; and one for Vi.
593 ;; Last shell command executed with ! command.
594 (defvar vip-last-shell-com nil)
598 ;;; Miscellaneous
600 ;; don't bark when mark is inactive
601 (setq mark-even-if-inactive t)
603 (defvar vip-inhibit-startup-message nil
604 "Whether Viper startup message should be inhibited.")
606 (defvar vip-always t
607 "t means, arrange that vi-state will be a default.")
609 (defvar vip-custom-file-name (vip-convert-standard-file-name "~/.vip")
610 "Viper customisation file.
611 This variable must be set _before_ loading Viper.")
614 (defvar vip-spell-function 'ispell-region
615 "Spell function used by #s<move> command to spell.")
617 (defvar vip-tags-file-name "TAGS"
618 "The tags file used by Viper.")
620 ;; Indicates if we are in the middle of executing a command that takes another
621 ;; command as an argument, e.g., cw, dw, etc.
622 (defvar vip-inside-command-argument-action nil)
624 ;; Minibuffer
626 (defvar vip-vi-style-in-minibuffer t
627 "If t, use vi-style editing in minibuffer.
628 Should be set in `~/.vip' file.")
630 ;; overlay used in the minibuffer to indicate which state it is in
631 (vip-deflocalvar vip-minibuffer-overlay nil)
633 ;; Hook, specific to Viper, which is run just *before* exiting the minibuffer.
634 ;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run
635 ;; *after* exiting the minibuffer
636 (defvar vip-minibuffer-exit-hook nil)
638 ;; setup emacs-supported vi-style feel
639 (setq next-line-add-newlines nil
640 require-final-newline t)
642 (make-variable-buffer-local 'require-final-newline)
645 ;; Mode line
646 (defconst vip-vi-state-id "<V> "
647 "Mode line tag identifying the Vi mode of Viper.")
648 (defconst vip-emacs-state-id "<E> "
649 "Mode line tag identifying the Emacs mode of Viper.")
650 (defconst vip-insert-state-id "<I> "
651 "Mode line tag identifying the Insert mode of Viper.")
652 (defconst vip-replace-state-id "<R> "
653 "Mode line tag identifying the Replace mode of Viper.")
655 ;; Viper changes the default mode-line-buffer-identification
656 (setq-default mode-line-buffer-identification '(" %b"))
658 ;; Variable displaying the current Viper state in the mode line.
659 (vip-deflocalvar vip-mode-string vip-emacs-state-id)
660 (or (memq 'vip-mode-string global-mode-string)
661 (setq global-mode-string
662 (append '("" vip-mode-string) (cdr global-mode-string))))
665 (defvar vip-vi-state-hook nil
666 "*Hooks run just before the switch to Vi mode is completed.")
667 (defvar vip-insert-state-hook nil
668 "*Hooks run just before the switch to Insert mode is completed.")
669 (defvar vip-replace-state-hook nil
670 "*Hooks run just before the switch to Replace mode is completed.")
671 (defvar vip-emacs-state-hook nil
672 "*Hooks run just before the switch to Emacs mode is completed.")
674 (defvar vip-load-hook nil
675 "Hooks run just after loading Viper.")
677 ;;; viper-ex.el ends here