Mercurial > emacs
annotate lisp/emulation/viper-init.el @ 20483:141c2d41d39c
(toggle-enable-multibyte-characters): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 21 Dec 1997 01:49:03 +0000 |
parents | f44ff2c52fac |
children | f7e788ea680b |
rev | line source |
---|---|
18047 | 1 ;;; viper-init.el --- some common definitions for Viper |
2 | |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
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. | |
11 | |
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. | |
16 | |
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. | |
21 | |
22 ;; Code | |
23 | |
24 (provide 'viper-init) | |
25 | |
26 ;; compiler pacifier | |
27 (defvar mark-even-if-inactive) | |
19462 | 28 (defvar quail-mode) |
29 (defvar iso-accents-mode) | |
30 (defvar viper-current-state) | |
18172 | 31 (defvar viper-version) |
18839 | 32 (defvar viper-expert-level) |
18047 | 33 ;; end pacifier |
34 | |
18172 | 35 |
36 ;; Viper version | |
37 (defun viper-version () | |
38 (interactive) | |
39 (message "Viper version is %s" viper-version)) | |
40 | |
18047 | 41 ;; Is it XEmacs? |
19079 | 42 (defconst viper-xemacs-p (string-match "XEmacs" emacs-version)) |
18047 | 43 ;; Is it Emacs? |
19079 | 44 (defconst viper-emacs-p (not viper-xemacs-p)) |
18047 | 45 ;; Tell whether we are running as a window application or on a TTY |
19079 | 46 (defsubst viper-device-type () |
47 (if viper-emacs-p | |
18047 | 48 window-system |
49 (device-type (selected-device)))) | |
50 ;; in XEmacs: device-type is tty on tty and stream in batch. | |
19079 | 51 (defun viper-window-display-p () |
52 (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc))))) | |
18047 | 53 |
20003 | 54 (defcustom viper-ms-style-os-p (memq system-type |
55 '(ms-dos windows-nt windows-95)) | |
18839 | 56 "Tells if Emacs is running under an MS-style OS: ms-dos, windows-nt, W95." |
57 :type 'boolean | |
58 :tag "Is it Microsoft-made OS?" | |
20003 | 59 :group 'viper-misc) |
19079 | 60 (defcustom viper-vms-os-p (memq system-type '(vax-vms axp-vms)) |
18839 | 61 "Tells if Emacs is running under VMS." |
62 :type 'boolean | |
63 :tag "Is it VMS?" | |
20003 | 64 :group 'viper-misc) |
18047 | 65 |
19079 | 66 (defcustom viper-force-faces nil |
18047 | 67 "If t, Viper will think that it is running on a display that supports faces. |
18839 | 68 This is provided as a temporary relief for users of graphics-capable terminals |
69 that Viper doesn't know about. | |
70 In all likelihood, you don't need to bother with this setting." | |
71 :type 'boolean | |
20003 | 72 :group 'viper-highlighting) |
18047 | 73 |
19079 | 74 (defun viper-has-face-support-p () |
75 (cond ((viper-window-display-p)) | |
76 (viper-force-faces) | |
77 (viper-emacs-p (memq (viper-device-type) '(pc))) | |
78 (viper-xemacs-p (memq (viper-device-type) '(tty pc))))) | |
18047 | 79 |
80 | |
81 ;;; Macros | |
82 | |
19079 | 83 (defmacro viper-deflocalvar (var default-value &optional documentation) |
18047 | 84 (` (progn |
85 (defvar (, var) (, default-value) | |
86 (, (format "%s\n\(buffer local\)" documentation))) | |
87 (make-variable-buffer-local '(, var)) | |
88 ))) | |
89 | |
19462 | 90 ;; (viper-loop COUNT BODY) Execute BODY COUNT times. |
91 (defmacro viper-loop (count &rest body) | |
92 (` (let ((count (, count))) | |
93 (while (> count 0) | |
94 (progn | |
95 (,@ body) | |
96 (setq count (1- count)) | |
97 )) | |
98 ))) | |
18047 | 99 |
19079 | 100 (defmacro viper-buffer-live-p (buf) |
18047 | 101 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) |
102 | |
103 ;; return buffer-specific macro definition, given a full macro definition | |
19079 | 104 (defmacro viper-kbd-buf-alist (macro-elt) |
18047 | 105 (` (nth 1 (, macro-elt)))) |
106 ;; get a pair: (curr-buffer . macro-definition) | |
19079 | 107 (defmacro viper-kbd-buf-pair (macro-elt) |
108 (` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt))))) | |
18047 | 109 ;; get macro definition for current buffer |
19079 | 110 (defmacro viper-kbd-buf-definition (macro-elt) |
111 (` (cdr (viper-kbd-buf-pair (, macro-elt))))) | |
18047 | 112 |
113 ;; return mode-specific macro definitions, given a full macro definition | |
19079 | 114 (defmacro viper-kbd-mode-alist (macro-elt) |
18047 | 115 (` (nth 2 (, macro-elt)))) |
116 ;; get a pair: (major-mode . macro-definition) | |
19079 | 117 (defmacro viper-kbd-mode-pair (macro-elt) |
118 (` (assoc major-mode (viper-kbd-mode-alist (, macro-elt))))) | |
18047 | 119 ;; get macro definition for the current major mode |
19079 | 120 (defmacro viper-kbd-mode-definition (macro-elt) |
121 (` (cdr (viper-kbd-mode-pair (, macro-elt))))) | |
18047 | 122 |
123 ;; return global macro definition, given a full macro definition | |
19079 | 124 (defmacro viper-kbd-global-pair (macro-elt) |
18047 | 125 (` (nth 3 (, macro-elt)))) |
126 ;; get global macro definition from an elt of macro-alist | |
19079 | 127 (defmacro viper-kbd-global-definition (macro-elt) |
128 (` (cdr (viper-kbd-global-pair (, macro-elt))))) | |
18047 | 129 |
130 ;; last elt of a sequence | |
19079 | 131 (defsubst viper-seq-last-elt (seq) |
18047 | 132 (elt seq (1- (length seq)))) |
19462 | 133 |
134 (defsubst viper-string-to-list (string) | |
135 (append (vconcat string) nil)) | |
136 | |
137 (defsubst viper-charlist-to-string (list) | |
138 (mapconcat 'char-to-string list "")) | |
139 | |
140 ;; like char-after/before, but saves typing | |
141 (defun viper-char-at-pos (direction &optional offset) | |
142 (or (integerp offset) (setq offset 0)) | |
143 (if (eq direction 'forward) | |
144 (char-after (+ (point) offset)) | |
145 (char-before (- (point) offset)))) | |
18047 | 146 |
147 | |
19079 | 148 (defvar viper-minibuffer-overlay-priority 300) |
149 (defvar viper-replace-overlay-priority 400) | |
150 (defvar viper-search-overlay-priority 500) | |
18047 | 151 |
152 | |
153 ;;; Viper minor modes | |
154 | |
155 ;; Mode for vital things like \e, C-z. | |
19079 | 156 (viper-deflocalvar viper-vi-intercept-minor-mode nil) |
18047 | 157 |
19079 | 158 (viper-deflocalvar viper-vi-basic-minor-mode nil |
18047 | 159 "Viper's minor mode for Vi bindings.") |
160 | |
19079 | 161 (viper-deflocalvar viper-vi-local-user-minor-mode nil |
18047 | 162 "Auxiliary minor mode for user-defined local bindings in Vi state.") |
163 | |
19079 | 164 (viper-deflocalvar viper-vi-global-user-minor-mode nil |
18047 | 165 "Auxiliary minor mode for user-defined global bindings in Vi state.") |
166 | |
19079 | 167 (viper-deflocalvar viper-vi-state-modifier-minor-mode nil |
18047 | 168 "Minor mode used to make major-mode-specific modification to Vi state.") |
169 | |
19079 | 170 (viper-deflocalvar viper-vi-diehard-minor-mode nil |
18047 | 171 "This minor mode is in effect when the user wants Viper to be Vi.") |
172 | |
19079 | 173 (viper-deflocalvar viper-vi-kbd-minor-mode nil |
18047 | 174 "Minor mode for Ex command macros in Vi state. |
175 The corresponding keymap stores key bindings of Vi macros defined with | |
176 the Ex command :map.") | |
177 | |
178 ;; Mode for vital things like \e, C-z. | |
19079 | 179 (viper-deflocalvar viper-insert-intercept-minor-mode nil) |
18047 | 180 |
19079 | 181 (viper-deflocalvar viper-insert-basic-minor-mode nil |
18047 | 182 "Viper's minor mode for bindings in Insert mode.") |
183 | |
19079 | 184 (viper-deflocalvar viper-insert-local-user-minor-mode nil |
18047 | 185 "Auxiliary minor mode for buffer-local user-defined bindings in Insert state. |
186 This is a way to overshadow normal Insert mode bindings locally to certain | |
187 designated buffers.") | |
188 | |
19079 | 189 (viper-deflocalvar viper-insert-global-user-minor-mode nil |
18047 | 190 "Auxiliary minor mode for global user-defined bindings in Insert state.") |
191 | |
19079 | 192 (viper-deflocalvar viper-insert-state-modifier-minor-mode nil |
18047 | 193 "Minor mode used to make major-mode-specific modification to Insert state.") |
194 | |
19079 | 195 (viper-deflocalvar viper-insert-diehard-minor-mode nil |
18047 | 196 "Minor mode that simulates Vi very closely. |
197 Not recommened, except for the novice user.") | |
198 | |
19079 | 199 (viper-deflocalvar viper-insert-kbd-minor-mode nil |
18047 | 200 "Minor mode for Ex command macros Insert state. |
201 The corresponding keymap stores key bindings of Vi macros defined with | |
202 the Ex command :map!.") | |
203 | |
19079 | 204 (viper-deflocalvar viper-replace-minor-mode nil |
18047 | 205 "Minor mode in effect in replace state (cw, C, and the like commands).") |
206 | |
20206 | 207 ;; Mode for vital things like \C-z and \C-x) This is set to t, when viper-mode |
208 ;; is invoked. So, any new buffer will have C-z defined as switch to Vi, unless | |
209 ;; we switched states in this buffer | |
210 (viper-deflocalvar viper-emacs-intercept-minor-mode nil) | |
18047 | 211 |
20206 | 212 (viper-deflocalvar viper-emacs-local-user-minor-mode nil |
18047 | 213 "Minor mode for local user bindings effective in Emacs state. |
214 Users can use it to override Emacs bindings when Viper is in its Emacs | |
215 state.") | |
216 | |
20206 | 217 (viper-deflocalvar viper-emacs-global-user-minor-mode nil |
18047 | 218 "Minor mode for global user bindings in effect in Emacs state. |
219 Users can use it to override Emacs bindings when Viper is in its Emacs | |
220 state.") | |
221 | |
20206 | 222 (viper-deflocalvar viper-emacs-kbd-minor-mode nil |
18047 | 223 "Minor mode for Vi style macros in Emacs state. |
224 The corresponding keymap stores key bindings of Vi macros defined with | |
19079 | 225 `viper-record-kbd-macro' command. There is no Ex-level command to do this |
18047 | 226 interactively.") |
227 | |
20206 | 228 (viper-deflocalvar viper-emacs-state-modifier-minor-mode nil |
18047 | 229 "Minor mode used to make major-mode-specific modification to Emacs state. |
230 For instance, a Vi purist may want to bind `dd' in Dired mode to a function | |
231 that deletes a file.") | |
232 | |
19079 | 233 (viper-deflocalvar viper-vi-minibuffer-minor-mode nil |
18047 | 234 "Minor mode that forces Vi-style when the Minibuffer is in Vi state.") |
235 | |
19079 | 236 (viper-deflocalvar viper-insert-minibuffer-minor-mode nil |
18047 | 237 "Minor mode that forces Vi-style when the Minibuffer is in Insert state.") |
238 | |
239 | |
240 | |
241 ;; Some common error messages | |
242 | |
19079 | 243 (defconst viper-SpuriousText "Spurious text after command" "") |
244 (defconst viper-BadExCommand "Not an editor command" "") | |
245 (defconst viper-InvalidCommandArgument "Invalid command argument" "") | |
246 (defconst viper-NoPrevSearch "No previous search string" "") | |
247 (defconst viper-EmptyRegister "`%c': Nothing in this register" "") | |
248 (defconst viper-InvalidRegister "`%c': Invalid register" "") | |
249 (defconst viper-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "") | |
250 (defconst viper-InvalidTextmarker "`%c': Invalid text marker" "") | |
251 (defconst viper-InvalidViCommand "Invalid command" "") | |
252 (defconst viper-BadAddress "Ill-formed address" "") | |
253 (defconst viper-FirstAddrExceedsSecond "First address exceeds second" "") | |
254 (defconst viper-NoFileSpecified "No file specified" "") | |
18047 | 255 |
256 ;; Is t until viper-mode executes for the very first time. | |
257 ;; Prevents recursive descend into startup messages. | |
19079 | 258 (defvar viper-first-time t) |
18047 | 259 |
19079 | 260 (defvar viper-expert-level (if (boundp 'viper-expert-level) viper-expert-level 0) |
18047 | 261 "User's expert level. |
19079 | 262 The minor mode viper-vi-diehard-minor-mode is in effect when |
263 viper-expert-level is 1 or 2 or when viper-want-emacs-keys-in-vi is t. | |
264 The minor mode viper-insert-diehard-minor-mode is in effect when | |
265 viper-expert-level is 1 or 2 or if viper-want-emacs-keys-in-insert is t. | |
18839 | 266 Use `M-x viper-set-expert-level' to change this.") |
18047 | 267 |
268 ;; Max expert level supported by Viper. This is NOT a user option. | |
269 ;; It is here to make it hard for the user from resetting it. | |
18839 | 270 (defconst viper-max-expert-level 5) |
18047 | 271 |
272 | |
19462 | 273 ;;; ISO characters and MULE |
274 | |
275 ;; If non-nil, ISO accents will be turned on in insert/replace emacs states and | |
276 ;; turned off in vi-state. For some users, this behavior may be too | |
277 ;; primitive. In this case, use insert/emacs/vi state hooks. | |
19079 | 278 (viper-deflocalvar viper-automatic-iso-accents nil "") |
19462 | 279 ;; Set iso-accents-mode to ARG. Check if it is bound first |
280 (defsubst viper-set-iso-accents-mode (arg) | |
281 (if (boundp 'iso-accents-mode) | |
282 (setq iso-accents-mode arg))) | |
283 | |
284 ;; Internal flag used to control when viper mule hooks are run. | |
285 ;; Don't change this! | |
286 (defvar viper-mule-hook-flag t) | |
287 ;; If non-nil, the default intl. input method is turned on. | |
288 (viper-deflocalvar viper-special-input-method nil "") | |
18047 | 289 |
19462 | 290 ;; viper hook to run on input-method activation |
291 (defun viper-activate-input-method-action () | |
292 (if (null viper-mule-hook-flag) | |
293 () | |
294 (setq viper-special-input-method t) | |
295 ;; turn off special input methods in vi-state | |
296 (if (eq viper-current-state 'vi-state) | |
297 (viper-set-input-method nil)) | |
298 (if (memq viper-current-state '(vi-state insert-state replace-state)) | |
299 (message "Viper special input method%s: on" | |
300 (if (or current-input-method default-input-method) | |
301 (format " %S" | |
302 (or current-input-method default-input-method)) | |
303 ""))) | |
304 )) | |
305 ;; viper hook to run on input-method deactivation | |
306 (defun viper-inactivate-input-method-action () | |
307 (if (null viper-mule-hook-flag) | |
308 () | |
309 (setq viper-special-input-method nil) | |
310 (if (memq viper-current-state '(vi-state insert-state replace-state)) | |
311 (message "Viper special input method%s: off" | |
312 (if (or current-input-method default-input-method) | |
313 (format " %S" | |
314 (or current-input-method default-input-method)) | |
315 ""))))) | |
316 | |
317 (defun viper-inactivate-input-method () | |
318 (cond ((and viper-emacs-p (fboundp 'inactivate-input-method)) | |
319 (inactivate-input-method)) | |
320 ((and viper-xemacs-p (boundp 'current-input-method)) | |
321 ;; XEmacs had broken quil-mode for some time, so we are working around | |
322 ;; it here | |
323 (setq quail-mode nil) | |
324 (if (featurep 'quail) | |
325 (quail-delete-overlays)) | |
326 (setq describe-current-input-method-function nil) | |
327 (setq current-input-method nil) | |
328 (run-hooks 'input-method-inactivate-hook) | |
329 (force-mode-line-update)) | |
330 )) | |
331 (defun viper-activate-input-method () | |
332 (cond ((and viper-emacs-p (fboundp 'activate-input-method)) | |
333 (activate-input-method default-input-method)) | |
334 ((and viper-xemacs-p (fboundp 'quail-mode)) | |
335 (quail-mode 1)))) | |
336 | |
337 ;; Set quail-mode to ARG | |
338 (defun viper-set-input-method (arg) | |
339 (setq viper-mule-hook-flag t) ; just a precaution | |
340 (let (viper-mule-hook-flag) ; temporarily inactivate viper mule hooks | |
341 (cond ((and arg (> (prefix-numeric-value arg) 0) default-input-method) | |
342 ;; activate input method | |
343 (viper-activate-input-method)) | |
344 (t ; deactivate input method | |
345 (viper-inactivate-input-method))) | |
346 )) | |
347 | |
18047 | 348 |
349 ;; VI-style Undo | |
350 | |
351 ;; Used to 'undo' complex commands, such as replace and insert commands. | |
19079 | 352 (viper-deflocalvar viper-undo-needs-adjustment nil) |
353 (put 'viper-undo-needs-adjustment 'permanent-local t) | |
18047 | 354 |
355 ;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a | |
356 ;; complex command that must be undone atomically. If inserted, it is | |
19079 | 357 ;; erased by viper-change-state-to-vi and viper-repeat. |
358 (defconst viper-buffer-undo-list-mark 'viper) | |
18047 | 359 |
19079 | 360 (defcustom viper-keep-point-on-undo nil |
18047 | 361 "*Non-nil means not to move point while undoing commands. |
362 This style is different from Emacs and Vi. Try it to see if | |
18839 | 363 it better fits your working style." |
364 :type 'boolean | |
365 :tag "Preserve Position of Point After Undo" | |
366 :group 'viper) | |
18047 | 367 |
368 ;; Replace mode and changing text | |
369 | |
19079 | 370 ;; Viper's own after/before change functions, which get viper-add-hook'ed to |
18047 | 371 ;; Emacs's |
19079 | 372 (viper-deflocalvar viper-after-change-functions nil "") |
373 (viper-deflocalvar viper-before-change-functions nil "") | |
374 (viper-deflocalvar viper-post-command-hooks nil "") | |
375 (viper-deflocalvar viper-pre-command-hooks nil "") | |
18047 | 376 |
377 ;; Can be used to pass global states around for short period of time | |
19079 | 378 (viper-deflocalvar viper-intermediate-command nil "") |
379 | |
380 ;; This is used to pass the right Vi command key sequence to | |
381 ;; viper-set-destructive-command whenever (this-command-keys) doesn't give the | |
382 ;; right result. For instance, in commands like c/bla<RET>, (this-command-keys) | |
383 ;; will return ^M, which invoked exit-minibuffer, while we need "c/" | |
384 (defconst viper-this-command-keys nil) | |
18047 | 385 |
386 ;; Indicates that the current destructive command has started in replace mode. | |
19079 | 387 (viper-deflocalvar viper-began-as-replace nil "") |
18047 | 388 |
19079 | 389 (defcustom viper-allow-multiline-replace-regions t |
18047 | 390 "If non-nil, Viper will allow multi-line replace regions. |
391 This is an extension to standard Vi. | |
392 If nil, commands that attempt to replace text spanning multiple lines first | |
18839 | 393 delete the text being replaced, as in standard Vi." |
394 :type 'boolean | |
395 :group 'viper) | |
18047 | 396 |
19079 | 397 (defcustom viper-replace-overlay-cursor-color "Red" |
18839 | 398 "*Cursor color when Viper is in Replace state." |
399 :type 'string | |
400 :group 'viper) | |
19079 | 401 (defcustom viper-insert-state-cursor-color "Green" |
18839 | 402 "Cursor color when Viper is in insert state." |
403 :type 'string | |
404 :group 'viper) | |
405 | |
18047 | 406 ;; place to save cursor colow when switching to insert mode |
19079 | 407 (viper-deflocalvar viper-saved-cursor-color nil "") |
18047 | 408 |
19079 | 409 (viper-deflocalvar viper-replace-overlay nil "") |
410 (put 'viper-replace-overlay 'permanent-local t) | |
18047 | 411 |
19079 | 412 (defcustom viper-replace-region-end-delimiter "$" |
18047 | 413 "A string marking the end of replacement regions. |
19079 | 414 It is used only with TTYs or if `viper-use-replace-region-delimiters' |
18839 | 415 is non-nil." |
416 :type 'string | |
417 :group 'viper) | |
19079 | 418 (defcustom viper-replace-region-start-delimiter "" |
18047 | 419 "A string marking the beginning of replacement regions. |
19079 | 420 It is used only with TTYs or if `viper-use-replace-region-delimiters' |
18839 | 421 is non-nil." |
422 :type 'string | |
423 :group 'viper) | |
19756 | 424 (defcustom viper-use-replace-region-delimiters |
425 (or (not (viper-has-face-support-p)) | |
426 (and viper-xemacs-p (eq (viper-device-type) 'tty))) | |
19079 | 427 "*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and |
428 `viper-replace-region-start-delimiter' to delimit replacement regions, even on | |
18839 | 429 color displays. By default, the delimiters are used only on TTYs." |
430 :type 'boolean | |
431 :group 'viper) | |
18047 | 432 |
433 ;; XEmacs requires glyphs | |
19079 | 434 (if viper-xemacs-p |
18047 | 435 (progn |
19079 | 436 (or (glyphp viper-replace-region-end-delimiter) |
437 (setq viper-replace-region-end-delimiter | |
438 (make-glyph viper-replace-region-end-delimiter))) | |
439 (or (glyphp viper-replace-region-start-delimiter) | |
440 (setq viper-replace-region-start-delimiter | |
441 (make-glyph viper-replace-region-start-delimiter))) | |
18047 | 442 )) |
443 | |
444 | |
445 ;; These are local marker that must be initialized to nil and moved with | |
19079 | 446 ;; `viper-move-marker-locally' |
18047 | 447 ;; |
448 ;; Remember the last position inside the replace region. | |
19079 | 449 (viper-deflocalvar viper-last-posn-in-replace-region nil) |
18047 | 450 ;; Remember the last position while inserting |
19079 | 451 (viper-deflocalvar viper-last-posn-while-in-insert-state nil) |
452 (put 'viper-last-posn-in-replace-region 'permanent-local t) | |
453 (put 'viper-last-posn-while-in-insert-state 'permanent-local t) | |
18047 | 454 |
19079 | 455 (viper-deflocalvar viper-sitting-in-replace nil "") |
456 (put 'viper-sitting-in-replace 'permanent-local t) | |
18047 | 457 |
458 ;; Remember the number of characters that have to be deleted in replace | |
459 ;; mode to compensate for the inserted characters. | |
19079 | 460 (viper-deflocalvar viper-replace-chars-to-delete 0 "") |
19462 | 461 ;; This variable is used internally by the before/after changed functions to |
462 ;; determine how many chars were deleted by the change. This can't be | |
463 ;; determined inside after-change-functions because those get the length of the | |
464 ;; deleted region, not the number of chars deleted (which are two different | |
465 ;; things under MULE). | |
466 (viper-deflocalvar viper-replace-region-chars-deleted 0 "") | |
18047 | 467 |
468 ;; Insertion ring and command ring | |
19079 | 469 (defcustom viper-insertion-ring-size 14 |
18839 | 470 "The size of history of inserted text. |
471 This is a list where Viper keeps the history of previously inserted pieces of | |
472 text." | |
473 :type 'integer | |
20003 | 474 :group 'viper-misc) |
18047 | 475 ;; The insertion ring. |
19079 | 476 (defvar viper-insertion-ring nil) |
18047 | 477 ;; This is temp insertion ring. Used to do rotation for display purposes. |
19079 | 478 ;; When rotation just started, it is initialized to viper-insertion-ring. |
479 (defvar viper-temp-insertion-ring nil) | |
480 (defvar viper-last-inserted-string-from-insertion-ring "") | |
18047 | 481 |
19079 | 482 (defcustom viper-command-ring-size 14 |
18839 | 483 "The size of history of Vi commands repeatable with dot." |
484 :type 'integer | |
20003 | 485 :group 'viper-misc) |
18047 | 486 ;; The command ring. |
19079 | 487 (defvar viper-command-ring nil) |
18047 | 488 ;; This is temp command ring. Used to do rotation for display purposes. |
19079 | 489 ;; When rotation just started, it is initialized to viper-command-ring. |
490 (defvar viper-temp-command-ring nil) | |
18047 | 491 |
18839 | 492 ;; Fast keyseq and ESC keyseq timeouts |
19079 | 493 (defcustom viper-fast-keyseq-timeout 200 |
18839 | 494 "*Key sequence separated by no more than this many milliseconds is viewed as a Vi-style macro, if such a macro is defined. |
495 Setting this too high may slow down your typing. Setting this value too low | |
496 will make it hard to use Vi-stile timeout macros." | |
497 :type 'integer | |
20003 | 498 :group 'viper-misc) |
18839 | 499 |
19079 | 500 (defcustom viper-ESC-keyseq-timeout (if (viper-window-display-p) |
501 0 viper-fast-keyseq-timeout) | |
18839 | 502 "*Key sequence beginning with ESC and separated by no more than this many milliseconds is considered to be generated by a keyboard function key. |
503 Setting this too high may slow down switching from insert to vi state. Setting | |
504 this value too low will make it impossible to use function keys in insert mode | |
505 on a dumb terminal." | |
506 :type 'integer | |
20003 | 507 :group 'viper-misc) |
18839 | 508 |
18047 | 509 ;; Modes and related variables |
510 | |
511 ;; Current mode. One of: `emacs-state', `vi-state', `insert-state' | |
19079 | 512 (viper-deflocalvar viper-current-state 'emacs-state) |
18047 | 513 |
514 | |
515 ;; Autoindent in insert | |
516 | |
517 ;; Variable that keeps track of whether C-t has been pressed. | |
19079 | 518 (viper-deflocalvar viper-cted nil "") |
18047 | 519 |
520 ;; Preserve the indent value, used by C-d in insert mode. | |
19079 | 521 (viper-deflocalvar viper-current-indent 0) |
18047 | 522 |
523 ;; Whether to preserve the indent, used by C-d in insert mode. | |
19079 | 524 (viper-deflocalvar viper-preserve-indent nil) |
18047 | 525 |
19079 | 526 (viper-deflocalvar viper-auto-indent nil "") |
527 (defcustom viper-auto-indent nil | |
18839 | 528 "*Enable autoindent, if t. |
529 This is a buffer-local variable." | |
530 :type 'boolean | |
531 :group 'viper) | |
18047 | 532 |
19079 | 533 (viper-deflocalvar viper-electric-mode t "") |
534 (defcustom viper-electric-mode t | |
18839 | 535 "*If t, electrify Viper. |
536 Currently, this only electrifies auto-indentation, making it appropriate to the | |
537 mode of the buffer. | |
538 This means that auto-indentation will depart from standard Vi and will indent | |
539 appropriate to the mode of the buffer. This is especially useful for editing | |
540 programs and LaTeX documents." | |
541 :type 'boolean | |
542 :group 'viper) | |
543 | |
19079 | 544 (defcustom viper-shift-width 8 |
18839 | 545 "*The shiftwidth variable." |
546 :type 'integer | |
547 :group 'viper) | |
18047 | 548 |
549 ;; Variables for repeating destructive commands | |
550 | |
19079 | 551 (defcustom viper-keep-point-on-repeat t |
18047 | 552 "*If t, don't move point when repeating previous command. |
553 This is useful for doing repeated changes with the '.' key. | |
554 The user can change this to nil, if she likes when the cursor moves | |
18839 | 555 to a new place after repeating previous Vi command." |
556 :type 'boolean | |
557 :group 'viper) | |
18047 | 558 |
559 ;; Remember insert point as a marker. This is a local marker that must be | |
19079 | 560 ;; initialized to nil and moved with `viper-move-marker-locally'. |
561 (viper-deflocalvar viper-insert-point nil) | |
562 (put 'viper-insert-point 'permanent-local t) | |
18047 | 563 |
564 ;; This remembers the point before dabbrev-expand was called. | |
19079 | 565 ;; If viper-insert-point turns out to be bigger than that, it is reset |
566 ;; back to viper-pre-command-point. | |
18047 | 567 ;; The reason this is needed is because dabbrev-expand (and possibly |
568 ;; others) may jump to before the insertion point, delete something and | |
569 ;; then reinsert a bigger piece. For instance: bla^blo | |
19079 | 570 ;; If dabbrev-expand is called after `blo' and ^ undicates viper-insert-point, |
18047 | 571 ;; then point jumps to the beginning of `blo'. If expansion is found, `blablo' |
572 ;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand | |
573 ;; will insert the expansion, and we get: blablo^ | |
574 ;; Whatever we insert next goes before the ^, i.e., before the | |
19079 | 575 ;; viper-insert-point marker. So, Viper will think that nothing was |
18047 | 576 ;; inserted. Remembering the orig position of the marker circumvents the |
577 ;; problem. | |
578 ;; We don't know of any command, except dabbrev-expand, that has the same | |
579 ;; problem. However, the same trick can be used if such a command is | |
580 ;; discovered later. | |
581 ;; | |
19079 | 582 (viper-deflocalvar viper-pre-command-point nil) |
583 (put 'viper-pre-command-point 'permanent-local t) ; this is probably an overkill | |
18047 | 584 |
585 ;; This is used for saving inserted text. | |
19079 | 586 (defvar viper-last-insertion nil) |
18047 | 587 |
588 ;; Remembers the last replaced region. | |
19079 | 589 (defvar viper-last-replace-region "") |
18047 | 590 |
591 ;; Remember com point as a marker. | |
19079 | 592 ;; This is a local marker. Should be moved with `viper-move-marker-locally' |
593 (viper-deflocalvar viper-com-point nil) | |
18047 | 594 |
595 ;; If non-nil, the value is a list (M-COM VAL COM REG inserted-text cmd-keys) | |
596 ;; It is used to re-execute last destructive command. | |
597 ;; M-COM is a Lisp symbol representing the function to be executed. | |
598 ;; VAL is the prefix argument that was used with that command. | |
599 ;; COM is an internal descriptor, such as ?r, ?c, ?C, which contains | |
600 ;; additional information on how the function in M-COM is to be handled. | |
601 ;; REG is the register used by command | |
602 ;; INSERTED-TEXT is text inserted by that command (in case of o, c, C, i, r | |
603 ;; commands). | |
604 ;; COMMAND-KEYS are the keys that were typed to invoke the command. | |
19079 | 605 (defvar viper-d-com nil) |
18047 | 606 |
607 ;; The character remembered by the Vi `r' command. | |
19079 | 608 (defvar viper-d-char nil) |
18047 | 609 |
610 ;; Name of register to store deleted or yanked strings | |
19079 | 611 (defvar viper-use-register nil) |
18047 | 612 |
613 | |
19462 | 614 ;;; Variables for Moves and Searches |
18047 | 615 |
20003 | 616 (defgroup viper-search nil |
617 "Variables that define the search and query-replace behavior of Viper." | |
618 :prefix "viper-" | |
619 :group 'viper) | |
620 | |
18047 | 621 ;; For use by `;' command. |
19079 | 622 (defvar viper-f-char nil) |
18047 | 623 |
624 ;; For use by `.' command. | |
19079 | 625 (defvar viper-F-char nil) |
18047 | 626 |
627 ;; For use by `;' command. | |
19079 | 628 (defvar viper-f-forward nil) |
18047 | 629 |
630 ;; For use by `;' command. | |
19079 | 631 (defvar viper-f-offset nil) |
18047 | 632 |
633 ;; Last search string | |
19079 | 634 (defvar viper-s-string "") |
18047 | 635 |
19079 | 636 (defcustom viper-quote-string "> " |
18839 | 637 "String inserted at the beginning of quoted region." |
638 :type 'string | |
639 :group 'viper) | |
18047 | 640 |
641 ;; If t, search is forward. | |
19079 | 642 (defvar viper-s-forward nil) |
18047 | 643 |
19079 | 644 (defcustom viper-case-fold-search nil |
18839 | 645 "*If not nil, search ignores cases." |
646 :type 'boolean | |
20003 | 647 :group 'viper-search) |
18047 | 648 |
19079 | 649 (defcustom viper-re-search t |
18839 | 650 "*If not nil, search is regexp search, otherwise vanilla search." |
651 :type 'boolean | |
652 :tag "Regexp Search" | |
20003 | 653 :group 'viper-search) |
18047 | 654 |
19079 | 655 (defcustom viper-search-scroll-threshold 2 |
18047 | 656 "*If search lands within this threshnold from the window top/bottom, |
657 the window will be scrolled up or down appropriately, to reveal context. | |
658 If you want Viper search to behave as usual in Vi, set this variable to a | |
18839 | 659 negative number." |
660 :type 'boolean | |
20003 | 661 :group 'viper-search) |
18047 | 662 |
19079 | 663 (defcustom viper-re-query-replace t |
18839 | 664 "*If t then do regexp replace, if nil then do string replace." |
665 :type 'boolean | |
666 :tag "Regexp Query Replace" | |
20003 | 667 :group 'viper-search) |
18047 | 668 |
19079 | 669 (defcustom viper-re-replace t |
18839 | 670 "*If t, do regexp replace. nil means do string replace." |
671 :type 'boolean | |
672 :tag "Regexp Replace" | |
20003 | 673 :group 'viper-search) |
18047 | 674 |
19079 | 675 (defcustom viper-parse-sexp-ignore-comments t |
18839 | 676 "*If t, `%' ignores the parentheses that occur inside comments." |
677 :type 'boolean | |
678 :group 'viper) | |
18047 | 679 |
19079 | 680 (viper-deflocalvar viper-ex-style-motion t "") |
681 (defcustom viper-ex-style-motion t | |
18839 | 682 "*If t, the commands l,h do not cross lines, etc (Ex-style). |
683 If nil, these commands cross line boundaries." | |
684 :type 'boolean | |
685 :group 'viper) | |
18047 | 686 |
19462 | 687 (viper-deflocalvar viper-ex-style-editing t "") |
688 (defcustom viper-ex-style-editing t | |
689 "*If t, Ex-style behavior while editing in Vi command and insert states. | |
690 `Backspace' and `Delete' don't cross line boundaries in insert. | |
691 `X' and `x' can't delete characters across line boundary in Vi, etc. | |
18839 | 692 Note: this doesn't preclude `Backspace' and `Delete' from deleting characters |
19462 | 693 by moving past the insertion point. This is a feature, not a bug. |
694 | |
695 If nil, the above commands can work across lines." | |
18839 | 696 :type 'boolean |
697 :group 'viper) | |
18047 | 698 |
19462 | 699 (viper-deflocalvar viper-ESC-moves-cursor-back viper-ex-style-editing "") |
19079 | 700 (defcustom viper-ESC-moves-cursor-back nil |
18839 | 701 "*If t, ESC moves cursor back when changing from insert to vi state. |
19462 | 702 If nil, the cursor stays where it was when ESC was hit." |
18839 | 703 :type 'boolean |
704 :group 'viper) | |
18047 | 705 |
19079 | 706 (viper-deflocalvar viper-delete-backwards-in-replace nil "") |
707 (defcustom viper-delete-backwards-in-replace nil | |
18839 | 708 "*If t, DEL key will delete characters while moving the cursor backwards. |
709 If nil, the cursor will move backwards without deleting anything." | |
710 :type 'boolean | |
711 :group 'viper) | |
712 | |
19079 | 713 (defcustom viper-buffer-search-char nil |
18839 | 714 "*Key used for buffer-searching. Must be a character type, e.g., ?g." |
715 :type '(choice (const nil) character) | |
20003 | 716 :group 'viper-search) |
18047 | 717 |
19079 | 718 (defcustom viper-search-wrap-around-t t |
18839 | 719 "*If t, search wraps around." |
720 :type 'boolean | |
721 :tag "Search Wraps Around" | |
20003 | 722 :group 'viper-search) |
18047 | 723 |
19079 | 724 (viper-deflocalvar viper-related-files-and-buffers-ring nil "") |
725 (defcustom viper-related-files-and-buffers-ring nil | |
18839 | 726 "*List of file and buffer names that are considered to be related to the current buffer. |
727 Related buffers can be cycled through via :R and :P commands." | |
728 :type 'boolean | |
20003 | 729 :group 'viper-misc) |
19079 | 730 (put 'viper-related-files-and-buffers-ring 'permanent-local t) |
18047 | 731 |
732 ;; Used to find out if we are done with searching the current buffer. | |
19079 | 733 (viper-deflocalvar viper-local-search-start-marker nil) |
18047 | 734 ;; As above, but global |
19079 | 735 (defvar viper-search-start-marker (make-marker)) |
18047 | 736 |
737 ;; the search overlay | |
19079 | 738 (viper-deflocalvar viper-search-overlay nil) |
18047 | 739 |
740 | |
19079 | 741 (defvar viper-heading-start |
18047 | 742 (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp |
743 "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++ | |
744 "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|" | |
745 "^\\\\[sb][a-z]*{.*}\\s-*$\\|" ; latex | |
746 "^@node\\|@table\\|^@m?enu\\|^@itemize\\|^@if\\|" ; texinfo | |
747 "^.+:-") ; prolog | |
748 "*Regexps for Headings. Used by \[\[ and \]\].") | |
749 | |
19079 | 750 (defvar viper-heading-end |
18047 | 751 (concat "^}\\|" ; C/C++ |
752 "^\\\\end{\\|" ; latex | |
753 "^@end \\|" ; texinfo | |
754 ")\n\n[ \t\n]*\\|" ; lisp | |
755 "\\.\\s-*$") ; prolog | |
756 "*Regexps to end Headings/Sections. Used by \[\].") | |
757 | |
758 | |
759 ;; These two vars control the interaction of jumps performed by ' and `. | |
760 ;; In this new version, '' doesn't erase the marks set by ``, so one can | |
761 ;; use both kinds of jumps interchangeably and without loosing positions | |
762 ;; inside the lines. | |
763 | |
764 ;; Remembers position of the last jump done using ``'. | |
19079 | 765 (viper-deflocalvar viper-last-jump nil) |
18047 | 766 ;; Remembers position of the last jump done using `''. |
19079 | 767 (viper-deflocalvar viper-last-jump-ignore 0) |
18047 | 768 |
769 ;; History variables | |
770 | |
771 ;; History of search strings. | |
19079 | 772 (defvar viper-search-history (list "")) |
18047 | 773 ;; History of query-replace strings used as a source. |
19079 | 774 (defvar viper-replace1-history nil) |
18047 | 775 ;; History of query-replace strings used as replacement. |
19079 | 776 (defvar viper-replace2-history nil) |
18047 | 777 ;; History of region quoting strings. |
19079 | 778 (defvar viper-quote-region-history (list viper-quote-string)) |
18047 | 779 ;; History of Ex-style commands. |
19079 | 780 (defvar viper-ex-history nil) |
18047 | 781 ;; History of shell commands. |
19079 | 782 (defvar viper-shell-history nil) |
18047 | 783 |
784 | |
785 ;; Last shell command. There are two of these, one for Ex (in viper-ex) | |
786 ;; and one for Vi. | |
787 | |
788 ;; Last shell command executed with ! command. | |
19079 | 789 (defvar viper-last-shell-com nil) |
18047 | 790 |
19203 | 791 |
792 ;;; Face-saving tricks | |
793 | |
19241 | 794 ;;(defcustom viper-replace-overlay-pixmap "gray3" |
795 ;; "Pixmap to use for search face on non-color displays." | |
796 ;; :type 'string | |
797 ;; :group 'viper) | |
798 ;;(defcustom viper-search-face-pixmap "gray3" | |
799 ;; "Pixmap to use for search face on non-color displays." | |
800 ;; :type 'string | |
801 ;; :group 'viper) | |
802 | |
19203 | 803 (defun viper-hide-face (face) |
804 (if (and (viper-has-face-support-p) viper-emacs-p) | |
805 (add-to-list 'facemenu-unlisted-faces face))) | |
806 | |
807 | |
808 (defgroup viper-highlighting nil | |
809 "Hilighting of replace region, search pattern, minibuffer, etc." | |
810 :prefix "viper-" | |
811 :group 'viper) | |
812 | |
813 ;;(defvar viper-search-face | |
814 ;; (if (viper-has-face-support-p) | |
815 ;; (progn | |
816 ;; (make-face 'viper-search-face) | |
817 ;; (or (face-differs-from-default-p 'viper-search-face) | |
818 ;; ;; face wasn't set in .viper or .Xdefaults | |
819 ;; (if (viper-can-use-colors "Black" "khaki") | |
820 ;; (progn | |
821 ;; (set-face-background 'viper-search-face "khaki") | |
822 ;; (set-face-foreground 'viper-search-face "Black")) | |
823 ;; (set-face-underline-p 'viper-search-face t) | |
824 ;; (viper-set-face-pixmap 'viper-search-face | |
825 ;; viper-search-face-pixmap))) | |
826 ;; 'viper-search-face)) | |
827 ;; "*Face used to flash out the search pattern.") | |
828 | |
829 (defface viper-search-face | |
830 '((((class color)) (:foreground "Black" :background "khaki")) | |
19234
55924d8a5b9e
(viper-replace-overlay-pixmap)
Richard M. Stallman <rms@gnu.org>
parents:
19203
diff
changeset
|
831 (t (:underline t :stipple "gray3"))) |
19203 | 832 "*Face used to flash out the search pattern." |
833 :group 'viper-highlighting) | |
834 ;; An internal variable. Viper takes the face from here. | |
20003 | 835 (defvar viper-search-face 'viper-search-face |
836 "Face used to flash out the search pattern. | |
837 DO NOT CHANGE this variable. Instead, use the customization widget | |
838 to customize the actual face object `viper-search-face' | |
839 this variable represents.") | |
19203 | 840 (viper-hide-face 'viper-search-face) |
841 | |
842 ;;(defvar viper-replace-overlay-face | |
843 ;; (if (viper-has-face-support-p) | |
844 ;; (progn | |
845 ;; (make-face 'viper-replace-overlay-face) | |
846 ;; (or (face-differs-from-default-p 'viper-replace-overlay-face) | |
847 ;; (progn | |
848 ;; (if (viper-can-use-colors "darkseagreen2" "Black") | |
849 ;; (progn | |
850 ;; (set-face-background | |
851 ;; 'viper-replace-overlay-face "darkseagreen2") | |
852 ;; (set-face-foreground 'viper-replace-overlay-face "Black"))) | |
853 ;; (set-face-underline-p 'viper-replace-overlay-face t) | |
854 ;; (viper-set-face-pixmap | |
855 ;; 'viper-replace-overlay-face viper-replace-overlay-pixmap))) | |
856 ;; 'viper-replace-overlay-face)) | |
857 ;; "*Face for highlighting replace regions on a window display.") | |
858 | |
859 (defface viper-replace-overlay-face | |
860 '((((class color)) (:foreground "Black" :background "darkseagreen2")) | |
19234
55924d8a5b9e
(viper-replace-overlay-pixmap)
Richard M. Stallman <rms@gnu.org>
parents:
19203
diff
changeset
|
861 (t (:underline t :stipple "gray3"))) |
19203 | 862 "*Face for highlighting replace regions on a window display." |
863 :group 'viper-highlighting) | |
864 ;; An internal variable. Viper takes the face from here. | |
20003 | 865 (defvar viper-replace-overlay-face 'viper-replace-overlay-face |
866 "Face for highlighting replace regions on a window display. | |
867 DO NOT CHANGE this variable. Instead, use the customization widget | |
868 to customize the actual face object `viper-replace-overlay-face' | |
869 this variable represents.") | |
19203 | 870 (viper-hide-face 'viper-replace-overlay-face) |
871 | |
872 ;;(defvar viper-minibuffer-emacs-face | |
873 ;; (if (viper-has-face-support-p) | |
874 ;; (progn | |
875 ;; (make-face 'viper-minibuffer-emacs-face) | |
876 ;; (or (face-differs-from-default-p 'viper-minibuffer-emacs-face) | |
877 ;; ;; face wasn't set in .viper or .Xdefaults | |
878 ;; (if viper-vi-style-in-minibuffer | |
879 ;; ;; emacs state is an exception in the minibuffer | |
880 ;; (if (viper-can-use-colors "darkseagreen2" "Black") | |
881 ;; (progn | |
882 ;; (set-face-background | |
883 ;; 'viper-minibuffer-emacs-face "darkseagreen2") | |
884 ;; (set-face-foreground | |
885 ;; 'viper-minibuffer-emacs-face "Black")) | |
886 ;; (copy-face 'modeline 'viper-minibuffer-emacs-face)) | |
887 ;; ;; emacs state is the main state in the minibuffer | |
888 ;; (if (viper-can-use-colors "Black" "pink") | |
889 ;; (progn | |
890 ;; (set-face-background 'viper-minibuffer-emacs-face "pink") | |
891 ;; (set-face-foreground | |
892 ;; 'viper-minibuffer-emacs-face "Black")) | |
893 ;; (copy-face 'italic 'viper-minibuffer-emacs-face)) | |
894 ;; )) | |
895 ;; 'viper-minibuffer-emacs-face)) | |
896 ;; "Face used in the Minibuffer when it is in Emacs state.") | |
897 | |
898 (defface viper-minibuffer-emacs-face | |
899 '((((class color)) (:foreground "Black" :background "darkseagreen2")) | |
900 (t (:bold t))) | |
901 "Face used in the Minibuffer when it is in Emacs state." | |
902 :group 'viper-highlighting) | |
903 ;; An internal variable. Viper takes the face from here. | |
20003 | 904 (defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face |
905 "Face used in the Minibuffer when it is in Emacs state. | |
906 DO NOT CHANGE this variable. Instead, use the customization widget | |
907 to customize the actual face object `viper-minibuffer-emacs-face' | |
908 this variable represents.") | |
19203 | 909 (viper-hide-face 'viper-minibuffer-emacs-face) |
910 | |
911 ;;(defvar viper-minibuffer-insert-face | |
912 ;; (if (viper-has-face-support-p) | |
913 ;; (progn | |
914 ;; (make-face 'viper-minibuffer-insert-face) | |
915 ;; (or (face-differs-from-default-p 'viper-minibuffer-insert-face) | |
916 ;; (if viper-vi-style-in-minibuffer | |
917 ;; (if (viper-can-use-colors "Black" "pink") | |
918 ;; (progn | |
919 ;; (set-face-background 'viper-minibuffer-insert-face "pink") | |
920 ;; (set-face-foreground | |
921 ;; 'viper-minibuffer-insert-face "Black")) | |
922 ;; (copy-face 'italic 'viper-minibuffer-insert-face)) | |
923 ;; ;; If Insert state is an exception | |
924 ;; (if (viper-can-use-colors "darkseagreen2" "Black") | |
925 ;; (progn | |
926 ;; (set-face-background | |
927 ;; 'viper-minibuffer-insert-face "darkseagreen2") | |
928 ;; (set-face-foreground | |
929 ;; 'viper-minibuffer-insert-face "Black")) | |
930 ;; (copy-face 'modeline 'viper-minibuffer-insert-face)) | |
931 ;; (viper-italicize-face 'viper-minibuffer-insert-face))) | |
932 ;; 'viper-minibuffer-insert-face)) | |
933 ;; "Face used in the Minibuffer when it is in Insert state.") | |
934 | |
935 (defface viper-minibuffer-insert-face | |
936 '((((class color)) (:foreground "Black" :background "pink")) | |
937 (t (:italic t))) | |
938 "Face used in the Minibuffer when it is in Insert state." | |
939 :group 'viper-highlighting) | |
940 ;; An internal variable. Viper takes the face from here. | |
20003 | 941 (defvar viper-minibuffer-insert-face 'viper-minibuffer-insert-face |
942 "Face used in the Minibuffer when it is in Insert state. | |
943 DO NOT CHANGE this variable. Instead, use the customization widget | |
944 to customize the actual face object `viper-minibuffer-insert-face' | |
945 this variable represents.") | |
19203 | 946 (viper-hide-face 'viper-minibuffer-insert-face) |
947 | |
948 ;;(defvar viper-minibuffer-vi-face | |
949 ;; (if (viper-has-face-support-p) | |
950 ;; (progn | |
951 ;; (make-face 'viper-minibuffer-vi-face) | |
952 ;; (or (face-differs-from-default-p 'viper-minibuffer-vi-face) | |
953 ;; (if viper-vi-style-in-minibuffer | |
954 ;; (if (viper-can-use-colors "Black" "grey") | |
955 ;; (progn | |
956 ;; (set-face-background 'viper-minibuffer-vi-face "grey") | |
957 ;; (set-face-foreground 'viper-minibuffer-vi-face "Black")) | |
958 ;; (copy-face 'bold 'viper-minibuffer-vi-face)) | |
959 ;; (copy-face 'bold 'viper-minibuffer-vi-face) | |
960 ;; (invert-face 'viper-minibuffer-vi-face))) | |
961 ;; 'viper-minibuffer-vi-face)) | |
962 ;; "Face used in the Minibuffer when it is in Vi state.") | |
963 | |
964 (defface viper-minibuffer-vi-face | |
965 '((((class color)) (:foreground "DarkGreen" :background "grey")) | |
966 (t (:inverse-video t))) | |
967 "Face used in the Minibuffer when it is in Vi state." | |
968 :group 'viper-highlighting) | |
969 ;; An internal variable. Viper takes the face from here. | |
20003 | 970 (defvar viper-minibuffer-vi-face 'viper-minibuffer-vi-face |
971 "Face used in the Minibuffer when it is in Vi state. | |
972 DO NOT CHANGE this variable. Instead, use the customization widget | |
973 to customize the actual face object `viper-minibuffer-vi-face' | |
974 this variable represents.") | |
19203 | 975 (viper-hide-face 'viper-minibuffer-vi-face) |
976 | |
977 ;; the current face to be used in the minibuffer | |
20003 | 978 (viper-deflocalvar |
979 viper-minibuffer-current-face viper-minibuffer-emacs-face "") | |
18047 | 980 |
981 | |
982 ;;; Miscellaneous | |
983 | |
19079 | 984 (defvar viper-inhibit-startup-message nil |
18047 | 985 "Whether Viper startup message should be inhibited.") |
986 | |
19079 | 987 (defcustom viper-spell-function 'ispell-region |
18839 | 988 "Spell function used by #s<move> command to spell." |
989 :type 'function | |
20003 | 990 :group 'viper-misc) |
18047 | 991 |
19079 | 992 (defcustom viper-tags-file-name "TAGS" |
18839 | 993 "The tags file used by Viper." |
994 :type 'string | |
20003 | 995 :group 'viper-misc) |
18047 | 996 |
997 ;; Minibuffer | |
998 | |
19079 | 999 (defcustom viper-vi-style-in-minibuffer t |
18047 | 1000 "If t, use vi-style editing in minibuffer. |
19079 | 1001 Should be set in `~/.viper' file." |
18839 | 1002 :type 'boolean |
1003 :group 'viper) | |
18047 | 1004 |
1005 ;; overlay used in the minibuffer to indicate which state it is in | |
19079 | 1006 (viper-deflocalvar viper-minibuffer-overlay nil) |
18047 | 1007 |
1008 ;; Hook, specific to Viper, which is run just *before* exiting the minibuffer. | |
1009 ;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run | |
1010 ;; *after* exiting the minibuffer | |
19756 | 1011 (defvar viper-minibuffer-exit-hook '(viper-minibuffer-trim-tail)) |
18047 | 1012 |
1013 | |
1014 ;; Mode line | |
19079 | 1015 (defconst viper-vi-state-id "<V> " |
18047 | 1016 "Mode line tag identifying the Vi mode of Viper.") |
19079 | 1017 (defconst viper-emacs-state-id "<E> " |
18047 | 1018 "Mode line tag identifying the Emacs mode of Viper.") |
19079 | 1019 (defconst viper-insert-state-id "<I> " |
18047 | 1020 "Mode line tag identifying the Insert mode of Viper.") |
19079 | 1021 (defconst viper-replace-state-id "<R> " |
18047 | 1022 "Mode line tag identifying the Replace mode of Viper.") |
1023 | |
1024 | |
20003 | 1025 (defgroup viper-hooks nil |
1026 "Viper hooks." | |
1027 :prefix "viper-" | |
1028 :group 'viper) | |
1029 | |
19079 | 1030 (defcustom viper-vi-state-hook nil |
18839 | 1031 "*Hooks run just before the switch to Vi mode is completed." |
1032 :type 'hook | |
20003 | 1033 :group 'viper-hooks) |
19079 | 1034 (defcustom viper-insert-state-hook nil |
18839 | 1035 "*Hooks run just before the switch to Insert mode is completed." |
1036 :type 'hook | |
20003 | 1037 :group 'viper-hooks) |
19079 | 1038 (defcustom viper-replace-state-hook nil |
18839 | 1039 "*Hooks run just before the switch to Replace mode is completed." |
1040 :type 'hook | |
20003 | 1041 :group 'viper-hooks) |
19079 | 1042 (defcustom viper-emacs-state-hook nil |
18839 | 1043 "*Hooks run just before the switch to Emacs mode is completed." |
1044 :type 'hook | |
20003 | 1045 :group 'viper-hooks) |
18047 | 1046 |
19079 | 1047 (defcustom viper-load-hook nil |
18839 | 1048 "Hooks run just after loading Viper." |
1049 :type 'hook | |
20003 | 1050 :group 'viper-hooks) |
18047 | 1051 |
18839 | 1052 |
1053 ;;; Local Variables: | |
19079 | 1054 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) |
18839 | 1055 ;;; End: |
1056 | |
18047 | 1057 ;;; viper-ex.el ends here |