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)
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.
27 (defvar mark-even-if-inactive
)
28 (defvar viper-version
)
29 (defvar viper-expert-level
)
34 (defun viper-version ()
36 (message "Viper version is %s" viper-version
))
39 (defconst viper-xemacs-p
(string-match "XEmacs" emacs-version
))
41 (defconst viper-emacs-p
(not viper-xemacs-p
))
42 ;; Tell whether we are running as a window application or on a TTY
43 (defsubst viper-device-type
()
46 (device-type (selected-device))))
47 ;; in XEmacs: device-type is tty on tty and stream in batch.
48 (defun viper-window-display-p ()
49 (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc
)))))
51 (defcustom viper-ms-style-os-p
(memq system-type
'(ms-dos windows-nt windows-95
))
52 "Tells if Emacs is running under an MS-style OS: ms-dos, windows-nt, W95."
54 :tag
"Is it Microsoft-made OS?"
56 (defcustom viper-vms-os-p
(memq system-type
'(vax-vms axp-vms
))
57 "Tells if Emacs is running under VMS."
62 (defcustom viper-force-faces nil
63 "If t, Viper will think that it is running on a display that supports faces.
64 This is provided as a temporary relief for users of graphics-capable terminals
65 that Viper doesn't know about.
66 In all likelihood, you don't need to bother with this setting."
70 (defun viper-has-face-support-p ()
71 (cond ((viper-window-display-p))
73 (viper-emacs-p (memq (viper-device-type) '(pc)))
74 (viper-xemacs-p (memq (viper-device-type) '(tty pc
)))))
79 (defmacro viper-deflocalvar
(var default-value
&optional documentation
)
81 (defvar (, var
) (, default-value
)
82 (, (format "%s\n\(buffer local\)" documentation
)))
83 (make-variable-buffer-local '(, var
))
86 (defmacro viper-loop
(count body
)
87 "(viper-loop COUNT BODY) Execute BODY COUNT times."
88 (list 'let
(list (list 'count count
))
89 (list 'while
'(> count
0)
91 '(setq count
(1- count
))
94 (defmacro viper-buffer-live-p
(buf)
95 (` (and (, buf
) (get-buffer (, buf
)) (buffer-name (get-buffer (, buf
))))))
97 ;; return buffer-specific macro definition, given a full macro definition
98 (defmacro viper-kbd-buf-alist
(macro-elt)
99 (` (nth 1 (, macro-elt
))))
100 ;; get a pair: (curr-buffer . macro-definition)
101 (defmacro viper-kbd-buf-pair
(macro-elt)
102 (` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt
)))))
103 ;; get macro definition for current buffer
104 (defmacro viper-kbd-buf-definition
(macro-elt)
105 (` (cdr (viper-kbd-buf-pair (, macro-elt
)))))
107 ;; return mode-specific macro definitions, given a full macro definition
108 (defmacro viper-kbd-mode-alist
(macro-elt)
109 (` (nth 2 (, macro-elt
))))
110 ;; get a pair: (major-mode . macro-definition)
111 (defmacro viper-kbd-mode-pair
(macro-elt)
112 (` (assoc major-mode
(viper-kbd-mode-alist (, macro-elt
)))))
113 ;; get macro definition for the current major mode
114 (defmacro viper-kbd-mode-definition
(macro-elt)
115 (` (cdr (viper-kbd-mode-pair (, macro-elt
)))))
117 ;; return global macro definition, given a full macro definition
118 (defmacro viper-kbd-global-pair
(macro-elt)
119 (` (nth 3 (, macro-elt
))))
120 ;; get global macro definition from an elt of macro-alist
121 (defmacro viper-kbd-global-definition
(macro-elt)
122 (` (cdr (viper-kbd-global-pair (, macro-elt
)))))
124 ;; last elt of a sequence
125 (defsubst viper-seq-last-elt
(seq)
126 (elt seq
(1- (length seq
))))
129 (defvar viper-minibuffer-overlay-priority
300)
130 (defvar viper-replace-overlay-priority
400)
131 (defvar viper-search-overlay-priority
500)
134 ;;; Viper minor modes
136 ;; Mode for vital things like \e, C-z.
137 (viper-deflocalvar viper-vi-intercept-minor-mode nil
)
139 (viper-deflocalvar viper-vi-basic-minor-mode nil
140 "Viper's minor mode for Vi bindings.")
142 (viper-deflocalvar viper-vi-local-user-minor-mode nil
143 "Auxiliary minor mode for user-defined local bindings in Vi state.")
145 (viper-deflocalvar viper-vi-global-user-minor-mode nil
146 "Auxiliary minor mode for user-defined global bindings in Vi state.")
148 (viper-deflocalvar viper-vi-state-modifier-minor-mode nil
149 "Minor mode used to make major-mode-specific modification to Vi state.")
151 (viper-deflocalvar viper-vi-diehard-minor-mode nil
152 "This minor mode is in effect when the user wants Viper to be Vi.")
154 (viper-deflocalvar viper-vi-kbd-minor-mode nil
155 "Minor mode for Ex command macros in Vi state.
156 The corresponding keymap stores key bindings of Vi macros defined with
157 the Ex command :map.")
159 ;; Mode for vital things like \e, C-z.
160 (viper-deflocalvar viper-insert-intercept-minor-mode nil
)
162 (viper-deflocalvar viper-insert-basic-minor-mode nil
163 "Viper's minor mode for bindings in Insert mode.")
165 (viper-deflocalvar viper-insert-local-user-minor-mode nil
166 "Auxiliary minor mode for buffer-local user-defined bindings in Insert state.
167 This is a way to overshadow normal Insert mode bindings locally to certain
168 designated buffers.")
170 (viper-deflocalvar viper-insert-global-user-minor-mode nil
171 "Auxiliary minor mode for global user-defined bindings in Insert state.")
173 (viper-deflocalvar viper-insert-state-modifier-minor-mode nil
174 "Minor mode used to make major-mode-specific modification to Insert state.")
176 (viper-deflocalvar viper-insert-diehard-minor-mode nil
177 "Minor mode that simulates Vi very closely.
178 Not recommened, except for the novice user.")
180 (viper-deflocalvar viper-insert-kbd-minor-mode nil
181 "Minor mode for Ex command macros Insert state.
182 The corresponding keymap stores key bindings of Vi macros defined with
183 the Ex command :map!.")
185 (viper-deflocalvar viper-replace-minor-mode nil
186 "Minor mode in effect in replace state (cw, C, and the like commands).")
188 ;; Mode for vital things like \C-z and \C-x)
189 ;; This is t, by default. So, any new buffer will have C-z defined as
190 ;; switch to Vi, unless we switched states in this buffer
191 (viper-deflocalvar viper-emacs-intercept-minor-mode t
)
193 (viper-deflocalvar viper-emacs-local-user-minor-mode t
194 "Minor mode for local user bindings effective in Emacs state.
195 Users can use it to override Emacs bindings when Viper is in its Emacs
198 (viper-deflocalvar viper-emacs-global-user-minor-mode t
199 "Minor mode for global user bindings in effect in Emacs state.
200 Users can use it to override Emacs bindings when Viper is in its Emacs
203 (viper-deflocalvar viper-emacs-kbd-minor-mode t
204 "Minor mode for Vi style macros in Emacs state.
205 The corresponding keymap stores key bindings of Vi macros defined with
206 `viper-record-kbd-macro' command. There is no Ex-level command to do this
209 (viper-deflocalvar viper-emacs-state-modifier-minor-mode t
210 "Minor mode used to make major-mode-specific modification to Emacs state.
211 For instance, a Vi purist may want to bind `dd' in Dired mode to a function
212 that deletes a file.")
214 (viper-deflocalvar viper-vi-minibuffer-minor-mode nil
215 "Minor mode that forces Vi-style when the Minibuffer is in Vi state.")
217 (viper-deflocalvar viper-insert-minibuffer-minor-mode nil
218 "Minor mode that forces Vi-style when the Minibuffer is in Insert state.")
222 ;; Some common error messages
224 (defconst viper-SpuriousText
"Spurious text after command" "")
225 (defconst viper-BadExCommand
"Not an editor command" "")
226 (defconst viper-InvalidCommandArgument
"Invalid command argument" "")
227 (defconst viper-NoPrevSearch
"No previous search string" "")
228 (defconst viper-EmptyRegister
"`%c': Nothing in this register" "")
229 (defconst viper-InvalidRegister
"`%c': Invalid register" "")
230 (defconst viper-EmptyTextmarker
"`%c': Text marker doesn't point anywhere" "")
231 (defconst viper-InvalidTextmarker
"`%c': Invalid text marker" "")
232 (defconst viper-InvalidViCommand
"Invalid command" "")
233 (defconst viper-BadAddress
"Ill-formed address" "")
234 (defconst viper-FirstAddrExceedsSecond
"First address exceeds second" "")
235 (defconst viper-NoFileSpecified
"No file specified" "")
237 ;; Is t until viper-mode executes for the very first time.
238 ;; Prevents recursive descend into startup messages.
239 (defvar viper-first-time t
)
241 (defvar viper-expert-level
(if (boundp 'viper-expert-level
) viper-expert-level
0)
242 "User's expert level.
243 The minor mode viper-vi-diehard-minor-mode is in effect when
244 viper-expert-level is 1 or 2 or when viper-want-emacs-keys-in-vi is t.
245 The minor mode viper-insert-diehard-minor-mode is in effect when
246 viper-expert-level is 1 or 2 or if viper-want-emacs-keys-in-insert is t.
247 Use `M-x viper-set-expert-level' to change this.")
249 ;; Max expert level supported by Viper. This is NOT a user option.
250 ;; It is here to make it hard for the user from resetting it.
251 (defconst viper-max-expert-level
5)
256 (viper-deflocalvar viper-automatic-iso-accents nil
"")
257 (defcustom viper-automatic-iso-accents nil
258 "*If non-nil, ISO accents will be turned on in insert/replace emacs states and turned off in vi-state.
259 For some users, this behavior may be too primitive. In this case, use
260 insert/emacs/vi state hooks."
267 ;; Used to 'undo' complex commands, such as replace and insert commands.
268 (viper-deflocalvar viper-undo-needs-adjustment nil
)
269 (put 'viper-undo-needs-adjustment
'permanent-local t
)
271 ;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a
272 ;; complex command that must be undone atomically. If inserted, it is
273 ;; erased by viper-change-state-to-vi and viper-repeat.
274 (defconst viper-buffer-undo-list-mark
'viper
)
276 (defcustom viper-keep-point-on-undo nil
277 "*Non-nil means not to move point while undoing commands.
278 This style is different from Emacs and Vi. Try it to see if
279 it better fits your working style."
281 :tag
"Preserve Position of Point After Undo"
284 ;; Replace mode and changing text
286 ;; Viper's own after/before change functions, which get viper-add-hook'ed to
288 (viper-deflocalvar viper-after-change-functions nil
"")
289 (viper-deflocalvar viper-before-change-functions nil
"")
290 (viper-deflocalvar viper-post-command-hooks nil
"")
291 (viper-deflocalvar viper-pre-command-hooks nil
"")
293 ;; Can be used to pass global states around for short period of time
294 (viper-deflocalvar viper-intermediate-command nil
"")
296 ;; This is used to pass the right Vi command key sequence to
297 ;; viper-set-destructive-command whenever (this-command-keys) doesn't give the
298 ;; right result. For instance, in commands like c/bla<RET>, (this-command-keys)
299 ;; will return ^M, which invoked exit-minibuffer, while we need "c/"
300 (defconst viper-this-command-keys nil
)
302 ;; Indicates that the current destructive command has started in replace mode.
303 (viper-deflocalvar viper-began-as-replace nil
"")
305 (defcustom viper-allow-multiline-replace-regions t
306 "If non-nil, Viper will allow multi-line replace regions.
307 This is an extension to standard Vi.
308 If nil, commands that attempt to replace text spanning multiple lines first
309 delete the text being replaced, as in standard Vi."
313 (defcustom viper-replace-overlay-cursor-color
"Red"
314 "*Cursor color when Viper is in Replace state."
317 (defcustom viper-insert-state-cursor-color
"Green"
318 "Cursor color when Viper is in insert state."
322 ;; place to save cursor colow when switching to insert mode
323 (viper-deflocalvar viper-saved-cursor-color nil
"")
325 (viper-deflocalvar viper-replace-overlay nil
"")
326 (put 'viper-replace-overlay
'permanent-local t
)
328 (defcustom viper-replace-region-end-delimiter
"$"
329 "A string marking the end of replacement regions.
330 It is used only with TTYs or if `viper-use-replace-region-delimiters'
334 (defcustom viper-replace-region-start-delimiter
""
335 "A string marking the beginning of replacement regions.
336 It is used only with TTYs or if `viper-use-replace-region-delimiters'
340 (defcustom viper-use-replace-region-delimiters
(not (viper-has-face-support-p))
341 "*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and
342 `viper-replace-region-start-delimiter' to delimit replacement regions, even on
343 color displays. By default, the delimiters are used only on TTYs."
347 ;; XEmacs requires glyphs
350 (or (glyphp viper-replace-region-end-delimiter
)
351 (setq viper-replace-region-end-delimiter
352 (make-glyph viper-replace-region-end-delimiter
)))
353 (or (glyphp viper-replace-region-start-delimiter
)
354 (setq viper-replace-region-start-delimiter
355 (make-glyph viper-replace-region-start-delimiter
)))
359 ;; These are local marker that must be initialized to nil and moved with
360 ;; `viper-move-marker-locally'
362 ;; Remember the last position inside the replace region.
363 (viper-deflocalvar viper-last-posn-in-replace-region nil
)
364 ;; Remember the last position while inserting
365 (viper-deflocalvar viper-last-posn-while-in-insert-state nil
)
366 (put 'viper-last-posn-in-replace-region
'permanent-local t
)
367 (put 'viper-last-posn-while-in-insert-state
'permanent-local t
)
369 (viper-deflocalvar viper-sitting-in-replace nil
"")
370 (put 'viper-sitting-in-replace
'permanent-local t
)
372 ;; Remember the number of characters that have to be deleted in replace
373 ;; mode to compensate for the inserted characters.
374 (viper-deflocalvar viper-replace-chars-to-delete
0 "")
375 (viper-deflocalvar viper-replace-chars-deleted
0 "")
377 ;; Insertion ring and command ring
378 (defcustom viper-insertion-ring-size
14
379 "The size of history of inserted text.
380 This is a list where Viper keeps the history of previously inserted pieces of
384 ;; The insertion ring.
385 (defvar viper-insertion-ring nil
)
386 ;; This is temp insertion ring. Used to do rotation for display purposes.
387 ;; When rotation just started, it is initialized to viper-insertion-ring.
388 (defvar viper-temp-insertion-ring nil
)
389 (defvar viper-last-inserted-string-from-insertion-ring
"")
391 (defcustom viper-command-ring-size
14
392 "The size of history of Vi commands repeatable with dot."
396 (defvar viper-command-ring nil
)
397 ;; This is temp command ring. Used to do rotation for display purposes.
398 ;; When rotation just started, it is initialized to viper-command-ring.
399 (defvar viper-temp-command-ring nil
)
401 ;; Fast keyseq and ESC keyseq timeouts
402 (defcustom viper-fast-keyseq-timeout
200
403 "*Key sequence separated by no more than this many milliseconds is viewed as a Vi-style macro, if such a macro is defined.
404 Setting this too high may slow down your typing. Setting this value too low
405 will make it hard to use Vi-stile timeout macros."
409 (defcustom viper-ESC-keyseq-timeout
(if (viper-window-display-p)
410 0 viper-fast-keyseq-timeout
)
411 "*Key sequence beginning with ESC and separated by no more than this many milliseconds is considered to be generated by a keyboard function key.
412 Setting this too high may slow down switching from insert to vi state. Setting
413 this value too low will make it impossible to use function keys in insert mode
418 ;; Modes and related variables
420 ;; Current mode. One of: `emacs-state', `vi-state', `insert-state'
421 (viper-deflocalvar viper-current-state
'emacs-state
)
424 ;; Autoindent in insert
426 ;; Variable that keeps track of whether C-t has been pressed.
427 (viper-deflocalvar viper-cted nil
"")
429 ;; Preserve the indent value, used by C-d in insert mode.
430 (viper-deflocalvar viper-current-indent
0)
432 ;; Whether to preserve the indent, used by C-d in insert mode.
433 (viper-deflocalvar viper-preserve-indent nil
)
435 (viper-deflocalvar viper-auto-indent nil
"")
436 (defcustom viper-auto-indent nil
437 "*Enable autoindent, if t.
438 This is a buffer-local variable."
442 (viper-deflocalvar viper-electric-mode t
"")
443 (defcustom viper-electric-mode t
444 "*If t, electrify Viper.
445 Currently, this only electrifies auto-indentation, making it appropriate to the
447 This means that auto-indentation will depart from standard Vi and will indent
448 appropriate to the mode of the buffer. This is especially useful for editing
449 programs and LaTeX documents."
453 (defcustom viper-shift-width
8
454 "*The shiftwidth variable."
458 ;; Variables for repeating destructive commands
460 (defcustom viper-keep-point-on-repeat t
461 "*If t, don't move point when repeating previous command.
462 This is useful for doing repeated changes with the '.' key.
463 The user can change this to nil, if she likes when the cursor moves
464 to a new place after repeating previous Vi command."
468 ;; Remember insert point as a marker. This is a local marker that must be
469 ;; initialized to nil and moved with `viper-move-marker-locally'.
470 (viper-deflocalvar viper-insert-point nil
)
471 (put 'viper-insert-point
'permanent-local t
)
473 ;; This remembers the point before dabbrev-expand was called.
474 ;; If viper-insert-point turns out to be bigger than that, it is reset
475 ;; back to viper-pre-command-point.
476 ;; The reason this is needed is because dabbrev-expand (and possibly
477 ;; others) may jump to before the insertion point, delete something and
478 ;; then reinsert a bigger piece. For instance: bla^blo
479 ;; If dabbrev-expand is called after `blo' and ^ undicates viper-insert-point,
480 ;; then point jumps to the beginning of `blo'. If expansion is found, `blablo'
481 ;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand
482 ;; will insert the expansion, and we get: blablo^
483 ;; Whatever we insert next goes before the ^, i.e., before the
484 ;; viper-insert-point marker. So, Viper will think that nothing was
485 ;; inserted. Remembering the orig position of the marker circumvents the
487 ;; We don't know of any command, except dabbrev-expand, that has the same
488 ;; problem. However, the same trick can be used if such a command is
491 (viper-deflocalvar viper-pre-command-point nil
)
492 (put 'viper-pre-command-point
'permanent-local t
) ; this is probably an overkill
494 ;; This is used for saving inserted text.
495 (defvar viper-last-insertion nil
)
497 ;; Remembers the last replaced region.
498 (defvar viper-last-replace-region
"")
500 ;; Remember com point as a marker.
501 ;; This is a local marker. Should be moved with `viper-move-marker-locally'
502 (viper-deflocalvar viper-com-point nil
)
504 ;; If non-nil, the value is a list (M-COM VAL COM REG inserted-text cmd-keys)
505 ;; It is used to re-execute last destructive command.
506 ;; M-COM is a Lisp symbol representing the function to be executed.
507 ;; VAL is the prefix argument that was used with that command.
508 ;; COM is an internal descriptor, such as ?r, ?c, ?C, which contains
509 ;; additional information on how the function in M-COM is to be handled.
510 ;; REG is the register used by command
511 ;; INSERTED-TEXT is text inserted by that command (in case of o, c, C, i, r
513 ;; COMMAND-KEYS are the keys that were typed to invoke the command.
514 (defvar viper-d-com nil
)
516 ;; The character remembered by the Vi `r' command.
517 (defvar viper-d-char nil
)
519 ;; Name of register to store deleted or yanked strings
520 (defvar viper-use-register nil
)
524 ;; Variables for Moves and Searches
526 ;; For use by `;' command.
527 (defvar viper-f-char nil
)
529 ;; For use by `.' command.
530 (defvar viper-F-char nil
)
532 ;; For use by `;' command.
533 (defvar viper-f-forward nil
)
535 ;; For use by `;' command.
536 (defvar viper-f-offset nil
)
538 ;; Last search string
539 (defvar viper-s-string
"")
541 (defcustom viper-quote-string
"> "
542 "String inserted at the beginning of quoted region."
546 ;; If t, search is forward.
547 (defvar viper-s-forward nil
)
549 (defcustom viper-case-fold-search nil
550 "*If not nil, search ignores cases."
554 (defcustom viper-re-search t
555 "*If not nil, search is regexp search, otherwise vanilla search."
560 (defcustom viper-search-scroll-threshold
2
561 "*If search lands within this threshnold from the window top/bottom,
562 the window will be scrolled up or down appropriately, to reveal context.
563 If you want Viper search to behave as usual in Vi, set this variable to a
568 (defcustom viper-re-query-replace t
569 "*If t then do regexp replace, if nil then do string replace."
571 :tag
"Regexp Query Replace"
574 (defcustom viper-re-replace t
575 "*If t, do regexp replace. nil means do string replace."
577 :tag
"Regexp Replace"
580 (defcustom viper-parse-sexp-ignore-comments t
581 "*If t, `%' ignores the parentheses that occur inside comments."
585 (viper-deflocalvar viper-ex-style-motion t
"")
586 (defcustom viper-ex-style-motion t
587 "*If t, the commands l,h do not cross lines, etc (Ex-style).
588 If nil, these commands cross line boundaries."
592 (viper-deflocalvar viper-ex-style-editing-in-insert t
"")
593 (defcustom viper-ex-style-editing-in-insert t
594 "*If t, `Backspace' and `Delete' don't cross line boundaries in insert, etc.
595 Note: this doesn't preclude `Backspace' and `Delete' from deleting characters
596 by moving past the insertion point. This is a feature, not a bug."
600 (viper-deflocalvar viper-ESC-moves-cursor-back viper-ex-style-editing-in-insert
"")
601 (defcustom viper-ESC-moves-cursor-back nil
602 "*If t, ESC moves cursor back when changing from insert to vi state.
603 If nil, the cursor stays where it was."
607 (viper-deflocalvar viper-delete-backwards-in-replace nil
"")
608 (defcustom viper-delete-backwards-in-replace nil
609 "*If t, DEL key will delete characters while moving the cursor backwards.
610 If nil, the cursor will move backwards without deleting anything."
614 (defcustom viper-buffer-search-char nil
615 "*Key used for buffer-searching. Must be a character type, e.g., ?g."
616 :type
'(choice (const nil
) character
)
619 (defcustom viper-search-wrap-around-t t
620 "*If t, search wraps around."
622 :tag
"Search Wraps Around"
625 (viper-deflocalvar viper-related-files-and-buffers-ring nil
"")
626 (defcustom viper-related-files-and-buffers-ring nil
627 "*List of file and buffer names that are considered to be related to the current buffer.
628 Related buffers can be cycled through via :R and :P commands."
631 (put 'viper-related-files-and-buffers-ring
'permanent-local t
)
633 ;; Used to find out if we are done with searching the current buffer.
634 (viper-deflocalvar viper-local-search-start-marker nil
)
635 ;; As above, but global
636 (defvar viper-search-start-marker
(make-marker))
638 ;; the search overlay
639 (viper-deflocalvar viper-search-overlay nil
)
642 (defvar viper-heading-start
643 (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp
644 "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++
645 "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|"
646 "^\\\\[sb][a-z]*{.*}\\s-*$\\|" ; latex
647 "^@node\\|@table\\|^@m?enu\\|^@itemize\\|^@if\\|" ; texinfo
649 "*Regexps for Headings. Used by \[\[ and \]\].")
651 (defvar viper-heading-end
652 (concat "^}\\|" ; C/C++
653 "^\\\\end{\\|" ; latex
654 "^@end \\|" ; texinfo
655 ")\n\n[ \t\n]*\\|" ; lisp
656 "\\.\\s-*$") ; prolog
657 "*Regexps to end Headings/Sections. Used by \[\].")
660 ;; These two vars control the interaction of jumps performed by ' and `.
661 ;; In this new version, '' doesn't erase the marks set by ``, so one can
662 ;; use both kinds of jumps interchangeably and without loosing positions
665 ;; Remembers position of the last jump done using ``'.
666 (viper-deflocalvar viper-last-jump nil
)
667 ;; Remembers position of the last jump done using `''.
668 (viper-deflocalvar viper-last-jump-ignore
0)
672 ;; History of search strings.
673 (defvar viper-search-history
(list ""))
674 ;; History of query-replace strings used as a source.
675 (defvar viper-replace1-history nil
)
676 ;; History of query-replace strings used as replacement.
677 (defvar viper-replace2-history nil
)
678 ;; History of region quoting strings.
679 (defvar viper-quote-region-history
(list viper-quote-string
))
680 ;; History of Ex-style commands.
681 (defvar viper-ex-history nil
)
682 ;; History of shell commands.
683 (defvar viper-shell-history nil
)
686 ;; Last shell command. There are two of these, one for Ex (in viper-ex)
689 ;; Last shell command executed with ! command.
690 (defvar viper-last-shell-com nil
)
693 ;;; Face-saving tricks
695 (defcustom viper-replace-overlay-pixmap
"gray3"
696 "Pixmap to use for search face on non-color displays."
699 (defcustom viper-search-face-pixmap
"gray3"
700 "Pixmap to use for search face on non-color displays."
704 (defun viper-hide-face (face)
705 (if (and (viper-has-face-support-p) viper-emacs-p
)
706 (add-to-list 'facemenu-unlisted-faces face
)))
709 (defgroup viper-highlighting nil
710 "Hilighting of replace region, search pattern, minibuffer, etc."
714 ;;(defvar viper-search-face
715 ;; (if (viper-has-face-support-p)
717 ;; (make-face 'viper-search-face)
718 ;; (or (face-differs-from-default-p 'viper-search-face)
719 ;; ;; face wasn't set in .viper or .Xdefaults
720 ;; (if (viper-can-use-colors "Black" "khaki")
722 ;; (set-face-background 'viper-search-face "khaki")
723 ;; (set-face-foreground 'viper-search-face "Black"))
724 ;; (set-face-underline-p 'viper-search-face t)
725 ;; (viper-set-face-pixmap 'viper-search-face
726 ;; viper-search-face-pixmap)))
727 ;; 'viper-search-face))
728 ;; "*Face used to flash out the search pattern.")
730 (defface viper-search-face
731 '((((class color
)) (:foreground
"Black" :background
"khaki"))
732 (t (:underline t
:stipple viper-search-face-pixmap
)))
733 "*Face used to flash out the search pattern."
734 :group
'viper-highlighting
)
735 ;; An internal variable. Viper takes the face from here.
736 (defvar viper-search-face
'viper-search-face
)
737 (viper-hide-face 'viper-search-face
)
739 ;;(defvar viper-replace-overlay-face
740 ;; (if (viper-has-face-support-p)
742 ;; (make-face 'viper-replace-overlay-face)
743 ;; (or (face-differs-from-default-p 'viper-replace-overlay-face)
745 ;; (if (viper-can-use-colors "darkseagreen2" "Black")
747 ;; (set-face-background
748 ;; 'viper-replace-overlay-face "darkseagreen2")
749 ;; (set-face-foreground 'viper-replace-overlay-face "Black")))
750 ;; (set-face-underline-p 'viper-replace-overlay-face t)
751 ;; (viper-set-face-pixmap
752 ;; 'viper-replace-overlay-face viper-replace-overlay-pixmap)))
753 ;; 'viper-replace-overlay-face))
754 ;; "*Face for highlighting replace regions on a window display.")
756 (defface viper-replace-overlay-face
757 '((((class color
)) (:foreground
"Black" :background
"darkseagreen2"))
758 (t (:underline t
:stipple viper-replace-overlay-face-pixmap
)))
759 "*Face for highlighting replace regions on a window display."
760 :group
'viper-highlighting
)
761 ;; An internal variable. Viper takes the face from here.
762 (defvar viper-replace-overlay-face
'viper-replace-overlay-face
)
763 (viper-hide-face 'viper-replace-overlay-face
)
765 ;;(defvar viper-minibuffer-emacs-face
766 ;; (if (viper-has-face-support-p)
768 ;; (make-face 'viper-minibuffer-emacs-face)
769 ;; (or (face-differs-from-default-p 'viper-minibuffer-emacs-face)
770 ;; ;; face wasn't set in .viper or .Xdefaults
771 ;; (if viper-vi-style-in-minibuffer
772 ;; ;; emacs state is an exception in the minibuffer
773 ;; (if (viper-can-use-colors "darkseagreen2" "Black")
775 ;; (set-face-background
776 ;; 'viper-minibuffer-emacs-face "darkseagreen2")
777 ;; (set-face-foreground
778 ;; 'viper-minibuffer-emacs-face "Black"))
779 ;; (copy-face 'modeline 'viper-minibuffer-emacs-face))
780 ;; ;; emacs state is the main state in the minibuffer
781 ;; (if (viper-can-use-colors "Black" "pink")
783 ;; (set-face-background 'viper-minibuffer-emacs-face "pink")
784 ;; (set-face-foreground
785 ;; 'viper-minibuffer-emacs-face "Black"))
786 ;; (copy-face 'italic 'viper-minibuffer-emacs-face))
788 ;; 'viper-minibuffer-emacs-face))
789 ;; "Face used in the Minibuffer when it is in Emacs state.")
791 (defface viper-minibuffer-emacs-face
792 '((((class color
)) (:foreground
"Black" :background
"darkseagreen2"))
794 "Face used in the Minibuffer when it is in Emacs state."
795 :group
'viper-highlighting
)
796 ;; An internal variable. Viper takes the face from here.
797 (defvar viper-minibuffer-emacs-face
'viper-minibuffer-emacs-face
)
798 (viper-hide-face 'viper-minibuffer-emacs-face
)
800 ;;(defvar viper-minibuffer-insert-face
801 ;; (if (viper-has-face-support-p)
803 ;; (make-face 'viper-minibuffer-insert-face)
804 ;; (or (face-differs-from-default-p 'viper-minibuffer-insert-face)
805 ;; (if viper-vi-style-in-minibuffer
806 ;; (if (viper-can-use-colors "Black" "pink")
808 ;; (set-face-background 'viper-minibuffer-insert-face "pink")
809 ;; (set-face-foreground
810 ;; 'viper-minibuffer-insert-face "Black"))
811 ;; (copy-face 'italic 'viper-minibuffer-insert-face))
812 ;; ;; If Insert state is an exception
813 ;; (if (viper-can-use-colors "darkseagreen2" "Black")
815 ;; (set-face-background
816 ;; 'viper-minibuffer-insert-face "darkseagreen2")
817 ;; (set-face-foreground
818 ;; 'viper-minibuffer-insert-face "Black"))
819 ;; (copy-face 'modeline 'viper-minibuffer-insert-face))
820 ;; (viper-italicize-face 'viper-minibuffer-insert-face)))
821 ;; 'viper-minibuffer-insert-face))
822 ;; "Face used in the Minibuffer when it is in Insert state.")
824 (defface viper-minibuffer-insert-face
825 '((((class color
)) (:foreground
"Black" :background
"pink"))
827 "Face used in the Minibuffer when it is in Insert state."
828 :group
'viper-highlighting
)
829 ;; An internal variable. Viper takes the face from here.
830 (defvar viper-minibuffer-insert-face
'viper-minibuffer-insert-face
)
831 (viper-hide-face 'viper-minibuffer-insert-face
)
833 ;;(defvar viper-minibuffer-vi-face
834 ;; (if (viper-has-face-support-p)
836 ;; (make-face 'viper-minibuffer-vi-face)
837 ;; (or (face-differs-from-default-p 'viper-minibuffer-vi-face)
838 ;; (if viper-vi-style-in-minibuffer
839 ;; (if (viper-can-use-colors "Black" "grey")
841 ;; (set-face-background 'viper-minibuffer-vi-face "grey")
842 ;; (set-face-foreground 'viper-minibuffer-vi-face "Black"))
843 ;; (copy-face 'bold 'viper-minibuffer-vi-face))
844 ;; (copy-face 'bold 'viper-minibuffer-vi-face)
845 ;; (invert-face 'viper-minibuffer-vi-face)))
846 ;; 'viper-minibuffer-vi-face))
847 ;; "Face used in the Minibuffer when it is in Vi state.")
849 (defface viper-minibuffer-vi-face
850 '((((class color
)) (:foreground
"DarkGreen" :background
"grey"))
851 (t (:inverse-video t
)))
852 "Face used in the Minibuffer when it is in Vi state."
853 :group
'viper-highlighting
)
854 ;; An internal variable. Viper takes the face from here.
855 (defvar viper-minibuffer-vi-face
'viper-minibuffer-vi-face
)
856 (viper-hide-face 'viper-minibuffer-vi-face
)
858 ;; the current face to be used in the minibuffer
859 (viper-deflocalvar viper-minibuffer-current-face viper-minibuffer-emacs-face
"")
864 (defvar viper-inhibit-startup-message nil
865 "Whether Viper startup message should be inhibited.")
867 (defcustom viper-spell-function
'ispell-region
868 "Spell function used by #s<move> command to spell."
872 (defcustom viper-tags-file-name
"TAGS"
873 "The tags file used by Viper."
879 (defcustom viper-vi-style-in-minibuffer t
880 "If t, use vi-style editing in minibuffer.
881 Should be set in `~/.viper' file."
885 ;; overlay used in the minibuffer to indicate which state it is in
886 (viper-deflocalvar viper-minibuffer-overlay nil
)
888 ;; Hook, specific to Viper, which is run just *before* exiting the minibuffer.
889 ;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run
890 ;; *after* exiting the minibuffer
891 (defvar viper-minibuffer-exit-hook nil
)
895 (defconst viper-vi-state-id
"<V> "
896 "Mode line tag identifying the Vi mode of Viper.")
897 (defconst viper-emacs-state-id
"<E> "
898 "Mode line tag identifying the Emacs mode of Viper.")
899 (defconst viper-insert-state-id
"<I> "
900 "Mode line tag identifying the Insert mode of Viper.")
901 (defconst viper-replace-state-id
"<R> "
902 "Mode line tag identifying the Replace mode of Viper.")
905 (defcustom viper-vi-state-hook nil
906 "*Hooks run just before the switch to Vi mode is completed."
909 (defcustom viper-insert-state-hook nil
910 "*Hooks run just before the switch to Insert mode is completed."
913 (defcustom viper-replace-state-hook nil
914 "*Hooks run just before the switch to Replace mode is completed."
917 (defcustom viper-emacs-state-hook nil
918 "*Hooks run just before the switch to Emacs mode is completed."
922 (defcustom viper-load-hook nil
923 "Hooks run just after loading Viper."
929 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
932 ;;; viper-ex.el ends here