16
|
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)
|
185
|
28 (defvar quail-mode)
|
|
29 (defvar iso-accents-mode)
|
|
30 (defvar viper-current-state)
|
163
|
31 (defvar viper-version)
|
175
|
32 (defvar viper-expert-level)
|
16
|
33 ;; end pacifier
|
|
34
|
163
|
35
|
|
36 ;; Viper version
|
|
37 (defun viper-version ()
|
|
38 (interactive)
|
|
39 (message "Viper version is %s" viper-version))
|
|
40
|
16
|
41 ;; Is it XEmacs?
|
181
|
42 (defconst viper-xemacs-p (string-match "XEmacs" emacs-version))
|
16
|
43 ;; Is it Emacs?
|
181
|
44 (defconst viper-emacs-p (not viper-xemacs-p))
|
16
|
45 ;; Tell whether we are running as a window application or on a TTY
|
181
|
46 (defsubst viper-device-type ()
|
|
47 (if viper-emacs-p
|
16
|
48 window-system
|
|
49 (device-type (selected-device))))
|
|
50 ;; in XEmacs: device-type is tty on tty and stream in batch.
|
181
|
51 (defun viper-window-display-p ()
|
|
52 (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc)))))
|
16
|
53
|
197
|
54 (defcustom viper-ms-style-os-p (memq system-type
|
|
55 '(ms-dos windows-nt windows-95))
|
175
|
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?"
|
197
|
59 :group 'viper-misc)
|
181
|
60 (defcustom viper-vms-os-p (memq system-type '(vax-vms axp-vms))
|
175
|
61 "Tells if Emacs is running under VMS."
|
|
62 :type 'boolean
|
|
63 :tag "Is it VMS?"
|
197
|
64 :group 'viper-misc)
|
16
|
65
|
181
|
66 (defcustom viper-force-faces nil
|
16
|
67 "If t, Viper will think that it is running on a display that supports faces.
|
175
|
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
|
197
|
72 :group 'viper-highlighting)
|
16
|
73
|
181
|
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)))))
|
16
|
79
|
|
80
|
|
81 ;;; Macros
|
|
82
|
181
|
83 (defmacro viper-deflocalvar (var default-value &optional documentation)
|
16
|
84 (` (progn
|
|
85 (defvar (, var) (, default-value)
|
|
86 (, (format "%s\n\(buffer local\)" documentation)))
|
|
87 (make-variable-buffer-local '(, var))
|
|
88 )))
|
|
89
|
185
|
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 )))
|
16
|
99
|
181
|
100 (defmacro viper-buffer-live-p (buf)
|
16
|
101 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
|
|
102
|
|
103 ;; return buffer-specific macro definition, given a full macro definition
|
181
|
104 (defmacro viper-kbd-buf-alist (macro-elt)
|
16
|
105 (` (nth 1 (, macro-elt))))
|
|
106 ;; get a pair: (curr-buffer . macro-definition)
|
181
|
107 (defmacro viper-kbd-buf-pair (macro-elt)
|
|
108 (` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt)))))
|
16
|
109 ;; get macro definition for current buffer
|
181
|
110 (defmacro viper-kbd-buf-definition (macro-elt)
|
|
111 (` (cdr (viper-kbd-buf-pair (, macro-elt)))))
|
16
|
112
|
|
113 ;; return mode-specific macro definitions, given a full macro definition
|
181
|
114 (defmacro viper-kbd-mode-alist (macro-elt)
|
16
|
115 (` (nth 2 (, macro-elt))))
|
|
116 ;; get a pair: (major-mode . macro-definition)
|
181
|
117 (defmacro viper-kbd-mode-pair (macro-elt)
|
|
118 (` (assoc major-mode (viper-kbd-mode-alist (, macro-elt)))))
|
16
|
119 ;; get macro definition for the current major mode
|
181
|
120 (defmacro viper-kbd-mode-definition (macro-elt)
|
|
121 (` (cdr (viper-kbd-mode-pair (, macro-elt)))))
|
16
|
122
|
|
123 ;; return global macro definition, given a full macro definition
|
181
|
124 (defmacro viper-kbd-global-pair (macro-elt)
|
16
|
125 (` (nth 3 (, macro-elt))))
|
|
126 ;; get global macro definition from an elt of macro-alist
|
181
|
127 (defmacro viper-kbd-global-definition (macro-elt)
|
|
128 (` (cdr (viper-kbd-global-pair (, macro-elt)))))
|
16
|
129
|
|
130 ;; last elt of a sequence
|
181
|
131 (defsubst viper-seq-last-elt (seq)
|
16
|
132 (elt seq (1- (length seq))))
|
185
|
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))))
|
16
|
146
|
|
147
|
181
|
148 (defvar viper-minibuffer-overlay-priority 300)
|
|
149 (defvar viper-replace-overlay-priority 400)
|
|
150 (defvar viper-search-overlay-priority 500)
|
16
|
151
|
|
152
|
|
153 ;;; Viper minor modes
|
|
154
|
|
155 ;; Mode for vital things like \e, C-z.
|
181
|
156 (viper-deflocalvar viper-vi-intercept-minor-mode nil)
|
16
|
157
|
181
|
158 (viper-deflocalvar viper-vi-basic-minor-mode nil
|
16
|
159 "Viper's minor mode for Vi bindings.")
|
|
160
|
181
|
161 (viper-deflocalvar viper-vi-local-user-minor-mode nil
|
16
|
162 "Auxiliary minor mode for user-defined local bindings in Vi state.")
|
|
163
|
181
|
164 (viper-deflocalvar viper-vi-global-user-minor-mode nil
|
16
|
165 "Auxiliary minor mode for user-defined global bindings in Vi state.")
|
|
166
|
181
|
167 (viper-deflocalvar viper-vi-state-modifier-minor-mode nil
|
16
|
168 "Minor mode used to make major-mode-specific modification to Vi state.")
|
|
169
|
181
|
170 (viper-deflocalvar viper-vi-diehard-minor-mode nil
|
16
|
171 "This minor mode is in effect when the user wants Viper to be Vi.")
|
|
172
|
181
|
173 (viper-deflocalvar viper-vi-kbd-minor-mode nil
|
16
|
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.
|
181
|
179 (viper-deflocalvar viper-insert-intercept-minor-mode nil)
|
16
|
180
|
181
|
181 (viper-deflocalvar viper-insert-basic-minor-mode nil
|
16
|
182 "Viper's minor mode for bindings in Insert mode.")
|
|
183
|
181
|
184 (viper-deflocalvar viper-insert-local-user-minor-mode nil
|
16
|
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
|
181
|
189 (viper-deflocalvar viper-insert-global-user-minor-mode nil
|
16
|
190 "Auxiliary minor mode for global user-defined bindings in Insert state.")
|
|
191
|
181
|
192 (viper-deflocalvar viper-insert-state-modifier-minor-mode nil
|
16
|
193 "Minor mode used to make major-mode-specific modification to Insert state.")
|
|
194
|
181
|
195 (viper-deflocalvar viper-insert-diehard-minor-mode nil
|
16
|
196 "Minor mode that simulates Vi very closely.
|
|
197 Not recommened, except for the novice user.")
|
|
198
|
181
|
199 (viper-deflocalvar viper-insert-kbd-minor-mode nil
|
16
|
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
|
181
|
204 (viper-deflocalvar viper-replace-minor-mode nil
|
16
|
205 "Minor mode in effect in replace state (cw, C, and the like commands).")
|
|
206
|
|
207 ;; Mode for vital things like \C-z and \C-x)
|
|
208 ;; This is t, by default. So, any new buffer will have C-z defined as
|
|
209 ;; switch to Vi, unless we switched states in this buffer
|
181
|
210 (viper-deflocalvar viper-emacs-intercept-minor-mode t)
|
16
|
211
|
181
|
212 (viper-deflocalvar viper-emacs-local-user-minor-mode t
|
16
|
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
|
181
|
217 (viper-deflocalvar viper-emacs-global-user-minor-mode t
|
16
|
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
|
181
|
222 (viper-deflocalvar viper-emacs-kbd-minor-mode t
|
16
|
223 "Minor mode for Vi style macros in Emacs state.
|
|
224 The corresponding keymap stores key bindings of Vi macros defined with
|
181
|
225 `viper-record-kbd-macro' command. There is no Ex-level command to do this
|
16
|
226 interactively.")
|
|
227
|
181
|
228 (viper-deflocalvar viper-emacs-state-modifier-minor-mode t
|
16
|
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
|
181
|
233 (viper-deflocalvar viper-vi-minibuffer-minor-mode nil
|
16
|
234 "Minor mode that forces Vi-style when the Minibuffer is in Vi state.")
|
|
235
|
181
|
236 (viper-deflocalvar viper-insert-minibuffer-minor-mode nil
|
16
|
237 "Minor mode that forces Vi-style when the Minibuffer is in Insert state.")
|
|
238
|
|
239
|
|
240
|
|
241 ;; Some common error messages
|
|
242
|
181
|
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" "")
|
16
|
255
|
|
256 ;; Is t until viper-mode executes for the very first time.
|
|
257 ;; Prevents recursive descend into startup messages.
|
181
|
258 (defvar viper-first-time t)
|
16
|
259
|
181
|
260 (defvar viper-expert-level (if (boundp 'viper-expert-level) viper-expert-level 0)
|
16
|
261 "User's expert level.
|
181
|
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.
|
175
|
266 Use `M-x viper-set-expert-level' to change this.")
|
16
|
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.
|
175
|
270 (defconst viper-max-expert-level 5)
|
16
|
271
|
|
272
|
185
|
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.
|
181
|
278 (viper-deflocalvar viper-automatic-iso-accents nil "")
|
185
|
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 "")
|
16
|
289
|
185
|
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
|
16
|
348
|
|
349 ;; VI-style Undo
|
|
350
|
|
351 ;; Used to 'undo' complex commands, such as replace and insert commands.
|
181
|
352 (viper-deflocalvar viper-undo-needs-adjustment nil)
|
|
353 (put 'viper-undo-needs-adjustment 'permanent-local t)
|
16
|
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
|
181
|
357 ;; erased by viper-change-state-to-vi and viper-repeat.
|
|
358 (defconst viper-buffer-undo-list-mark 'viper)
|
16
|
359
|
181
|
360 (defcustom viper-keep-point-on-undo nil
|
16
|
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
|
175
|
363 it better fits your working style."
|
|
364 :type 'boolean
|
|
365 :tag "Preserve Position of Point After Undo"
|
|
366 :group 'viper)
|
16
|
367
|
|
368 ;; Replace mode and changing text
|
|
369
|
181
|
370 ;; Viper's own after/before change functions, which get viper-add-hook'ed to
|
16
|
371 ;; Emacs's
|
181
|
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 "")
|
16
|
376
|
|
377 ;; Can be used to pass global states around for short period of time
|
181
|
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)
|
16
|
385
|
|
386 ;; Indicates that the current destructive command has started in replace mode.
|
181
|
387 (viper-deflocalvar viper-began-as-replace nil "")
|
16
|
388
|
181
|
389 (defcustom viper-allow-multiline-replace-regions t
|
16
|
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
|
175
|
393 delete the text being replaced, as in standard Vi."
|
|
394 :type 'boolean
|
|
395 :group 'viper)
|
16
|
396
|
181
|
397 (defcustom viper-replace-overlay-cursor-color "Red"
|
175
|
398 "*Cursor color when Viper is in Replace state."
|
|
399 :type 'string
|
|
400 :group 'viper)
|
181
|
401 (defcustom viper-insert-state-cursor-color "Green"
|
175
|
402 "Cursor color when Viper is in insert state."
|
|
403 :type 'string
|
|
404 :group 'viper)
|
|
405
|
16
|
406 ;; place to save cursor colow when switching to insert mode
|
181
|
407 (viper-deflocalvar viper-saved-cursor-color nil "")
|
16
|
408
|
181
|
409 (viper-deflocalvar viper-replace-overlay nil "")
|
|
410 (put 'viper-replace-overlay 'permanent-local t)
|
16
|
411
|
181
|
412 (defcustom viper-replace-region-end-delimiter "$"
|
16
|
413 "A string marking the end of replacement regions.
|
181
|
414 It is used only with TTYs or if `viper-use-replace-region-delimiters'
|
175
|
415 is non-nil."
|
|
416 :type 'string
|
|
417 :group 'viper)
|
181
|
418 (defcustom viper-replace-region-start-delimiter ""
|
16
|
419 "A string marking the beginning of replacement regions.
|
181
|
420 It is used only with TTYs or if `viper-use-replace-region-delimiters'
|
175
|
421 is non-nil."
|
|
422 :type 'string
|
|
423 :group 'viper)
|
185
|
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)))
|
181
|
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
|
175
|
429 color displays. By default, the delimiters are used only on TTYs."
|
|
430 :type 'boolean
|
|
431 :group 'viper)
|
16
|
432
|
|
433 ;; XEmacs requires glyphs
|
181
|
434 (if viper-xemacs-p
|
16
|
435 (progn
|
181
|
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)))
|
16
|
442 ))
|
|
443
|
|
444
|
|
445 ;; These are local marker that must be initialized to nil and moved with
|
181
|
446 ;; `viper-move-marker-locally'
|
16
|
447 ;;
|
|
448 ;; Remember the last position inside the replace region.
|
181
|
449 (viper-deflocalvar viper-last-posn-in-replace-region nil)
|
16
|
450 ;; Remember the last position while inserting
|
181
|
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)
|
16
|
454
|
181
|
455 (viper-deflocalvar viper-sitting-in-replace nil "")
|
|
456 (put 'viper-sitting-in-replace 'permanent-local t)
|
16
|
457
|
|
458 ;; Remember the number of characters that have to be deleted in replace
|
|
459 ;; mode to compensate for the inserted characters.
|
181
|
460 (viper-deflocalvar viper-replace-chars-to-delete 0 "")
|
185
|
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 "")
|
16
|
467
|
|
468 ;; Insertion ring and command ring
|
181
|
469 (defcustom viper-insertion-ring-size 14
|
175
|
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
|
197
|
474 :group 'viper-misc)
|
16
|
475 ;; The insertion ring.
|
181
|
476 (defvar viper-insertion-ring nil)
|
16
|
477 ;; This is temp insertion ring. Used to do rotation for display purposes.
|
181
|
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 "")
|
16
|
481
|
181
|
482 (defcustom viper-command-ring-size 14
|
175
|
483 "The size of history of Vi commands repeatable with dot."
|
|
484 :type 'integer
|
197
|
485 :group 'viper-misc)
|
16
|
486 ;; The command ring.
|
181
|
487 (defvar viper-command-ring nil)
|
16
|
488 ;; This is temp command ring. Used to do rotation for display purposes.
|
181
|
489 ;; When rotation just started, it is initialized to viper-command-ring.
|
|
490 (defvar viper-temp-command-ring nil)
|
16
|
491
|
175
|
492 ;; Fast keyseq and ESC keyseq timeouts
|
181
|
493 (defcustom viper-fast-keyseq-timeout 200
|
175
|
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
|
197
|
498 :group 'viper-misc)
|
175
|
499
|
181
|
500 (defcustom viper-ESC-keyseq-timeout (if (viper-window-display-p)
|
|
501 0 viper-fast-keyseq-timeout)
|
175
|
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
|
197
|
507 :group 'viper-misc)
|
175
|
508
|
16
|
509 ;; Modes and related variables
|
|
510
|
|
511 ;; Current mode. One of: `emacs-state', `vi-state', `insert-state'
|
181
|
512 (viper-deflocalvar viper-current-state 'emacs-state)
|
16
|
513
|
|
514
|
|
515 ;; Autoindent in insert
|
|
516
|
|
517 ;; Variable that keeps track of whether C-t has been pressed.
|
181
|
518 (viper-deflocalvar viper-cted nil "")
|
16
|
519
|
|
520 ;; Preserve the indent value, used by C-d in insert mode.
|
181
|
521 (viper-deflocalvar viper-current-indent 0)
|
16
|
522
|
|
523 ;; Whether to preserve the indent, used by C-d in insert mode.
|
181
|
524 (viper-deflocalvar viper-preserve-indent nil)
|
16
|
525
|
181
|
526 (viper-deflocalvar viper-auto-indent nil "")
|
|
527 (defcustom viper-auto-indent nil
|
175
|
528 "*Enable autoindent, if t.
|
|
529 This is a buffer-local variable."
|
|
530 :type 'boolean
|
|
531 :group 'viper)
|
16
|
532
|
181
|
533 (viper-deflocalvar viper-electric-mode t "")
|
|
534 (defcustom viper-electric-mode t
|
175
|
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
|
181
|
544 (defcustom viper-shift-width 8
|
175
|
545 "*The shiftwidth variable."
|
|
546 :type 'integer
|
|
547 :group 'viper)
|
16
|
548
|
|
549 ;; Variables for repeating destructive commands
|
|
550
|
181
|
551 (defcustom viper-keep-point-on-repeat t
|
16
|
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
|
175
|
555 to a new place after repeating previous Vi command."
|
|
556 :type 'boolean
|
|
557 :group 'viper)
|
16
|
558
|
|
559 ;; Remember insert point as a marker. This is a local marker that must be
|
181
|
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)
|
16
|
563
|
|
564 ;; This remembers the point before dabbrev-expand was called.
|
181
|
565 ;; If viper-insert-point turns out to be bigger than that, it is reset
|
|
566 ;; back to viper-pre-command-point.
|
16
|
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
|
181
|
570 ;; If dabbrev-expand is called after `blo' and ^ undicates viper-insert-point,
|
16
|
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
|
181
|
575 ;; viper-insert-point marker. So, Viper will think that nothing was
|
16
|
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 ;;
|
181
|
582 (viper-deflocalvar viper-pre-command-point nil)
|
|
583 (put 'viper-pre-command-point 'permanent-local t) ; this is probably an overkill
|
16
|
584
|
|
585 ;; This is used for saving inserted text.
|
181
|
586 (defvar viper-last-insertion nil)
|
16
|
587
|
|
588 ;; Remembers the last replaced region.
|
181
|
589 (defvar viper-last-replace-region "")
|
16
|
590
|
|
591 ;; Remember com point as a marker.
|
181
|
592 ;; This is a local marker. Should be moved with `viper-move-marker-locally'
|
|
593 (viper-deflocalvar viper-com-point nil)
|
16
|
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.
|
181
|
605 (defvar viper-d-com nil)
|
16
|
606
|
|
607 ;; The character remembered by the Vi `r' command.
|
181
|
608 (defvar viper-d-char nil)
|
16
|
609
|
|
610 ;; Name of register to store deleted or yanked strings
|
181
|
611 (defvar viper-use-register nil)
|
16
|
612
|
|
613
|
185
|
614 ;;; Variables for Moves and Searches
|
16
|
615
|
197
|
616 (defgroup viper-search nil
|
|
617 "Variables that define the search and query-replace behavior of Viper."
|
|
618 :prefix "viper-"
|
|
619 :group 'viper)
|
|
620
|
16
|
621 ;; For use by `;' command.
|
181
|
622 (defvar viper-f-char nil)
|
16
|
623
|
|
624 ;; For use by `.' command.
|
181
|
625 (defvar viper-F-char nil)
|
16
|
626
|
|
627 ;; For use by `;' command.
|
181
|
628 (defvar viper-f-forward nil)
|
16
|
629
|
|
630 ;; For use by `;' command.
|
181
|
631 (defvar viper-f-offset nil)
|
16
|
632
|
|
633 ;; Last search string
|
181
|
634 (defvar viper-s-string "")
|
16
|
635
|
181
|
636 (defcustom viper-quote-string "> "
|
175
|
637 "String inserted at the beginning of quoted region."
|
|
638 :type 'string
|
|
639 :group 'viper)
|
16
|
640
|
|
641 ;; If t, search is forward.
|
181
|
642 (defvar viper-s-forward nil)
|
16
|
643
|
181
|
644 (defcustom viper-case-fold-search nil
|
175
|
645 "*If not nil, search ignores cases."
|
|
646 :type 'boolean
|
197
|
647 :group 'viper-search)
|
16
|
648
|
181
|
649 (defcustom viper-re-search t
|
175
|
650 "*If not nil, search is regexp search, otherwise vanilla search."
|
|
651 :type 'boolean
|
|
652 :tag "Regexp Search"
|
197
|
653 :group 'viper-search)
|
16
|
654
|
181
|
655 (defcustom viper-search-scroll-threshold 2
|
16
|
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
|
175
|
659 negative number."
|
|
660 :type 'boolean
|
197
|
661 :group 'viper-search)
|
16
|
662
|
181
|
663 (defcustom viper-re-query-replace t
|
175
|
664 "*If t then do regexp replace, if nil then do string replace."
|
|
665 :type 'boolean
|
|
666 :tag "Regexp Query Replace"
|
197
|
667 :group 'viper-search)
|
16
|
668
|
181
|
669 (defcustom viper-re-replace t
|
175
|
670 "*If t, do regexp replace. nil means do string replace."
|
|
671 :type 'boolean
|
|
672 :tag "Regexp Replace"
|
197
|
673 :group 'viper-search)
|
16
|
674
|
181
|
675 (defcustom viper-parse-sexp-ignore-comments t
|
175
|
676 "*If t, `%' ignores the parentheses that occur inside comments."
|
|
677 :type 'boolean
|
|
678 :group 'viper)
|
155
|
679
|
181
|
680 (viper-deflocalvar viper-ex-style-motion t "")
|
|
681 (defcustom viper-ex-style-motion t
|
175
|
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)
|
16
|
686
|
185
|
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.
|
175
|
692 Note: this doesn't preclude `Backspace' and `Delete' from deleting characters
|
185
|
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."
|
175
|
696 :type 'boolean
|
|
697 :group 'viper)
|
16
|
698
|
185
|
699 (viper-deflocalvar viper-ESC-moves-cursor-back viper-ex-style-editing "")
|
181
|
700 (defcustom viper-ESC-moves-cursor-back nil
|
175
|
701 "*If t, ESC moves cursor back when changing from insert to vi state.
|
185
|
702 If nil, the cursor stays where it was when ESC was hit."
|
175
|
703 :type 'boolean
|
|
704 :group 'viper)
|
16
|
705
|
181
|
706 (viper-deflocalvar viper-delete-backwards-in-replace nil "")
|
|
707 (defcustom viper-delete-backwards-in-replace nil
|
175
|
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
|
181
|
713 (defcustom viper-buffer-search-char nil
|
175
|
714 "*Key used for buffer-searching. Must be a character type, e.g., ?g."
|
|
715 :type '(choice (const nil) character)
|
197
|
716 :group 'viper-search)
|
16
|
717
|
181
|
718 (defcustom viper-search-wrap-around-t t
|
175
|
719 "*If t, search wraps around."
|
|
720 :type 'boolean
|
|
721 :tag "Search Wraps Around"
|
197
|
722 :group 'viper-search)
|
16
|
723
|
181
|
724 (viper-deflocalvar viper-related-files-and-buffers-ring nil "")
|
|
725 (defcustom viper-related-files-and-buffers-ring nil
|
175
|
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
|
197
|
729 :group 'viper-misc)
|
181
|
730 (put 'viper-related-files-and-buffers-ring 'permanent-local t)
|
16
|
731
|
|
732 ;; Used to find out if we are done with searching the current buffer.
|
181
|
733 (viper-deflocalvar viper-local-search-start-marker nil)
|
16
|
734 ;; As above, but global
|
181
|
735 (defvar viper-search-start-marker (make-marker))
|
16
|
736
|
|
737 ;; the search overlay
|
181
|
738 (viper-deflocalvar viper-search-overlay nil)
|
16
|
739
|
|
740
|
181
|
741 (defvar viper-heading-start
|
16
|
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
|
181
|
750 (defvar viper-heading-end
|
16
|
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 ``'.
|
181
|
765 (viper-deflocalvar viper-last-jump nil)
|
16
|
766 ;; Remembers position of the last jump done using `''.
|
181
|
767 (viper-deflocalvar viper-last-jump-ignore 0)
|
16
|
768
|
|
769 ;; History variables
|
|
770
|
|
771 ;; History of search strings.
|
181
|
772 (defvar viper-search-history (list ""))
|
16
|
773 ;; History of query-replace strings used as a source.
|
181
|
774 (defvar viper-replace1-history nil)
|
16
|
775 ;; History of query-replace strings used as replacement.
|
181
|
776 (defvar viper-replace2-history nil)
|
16
|
777 ;; History of region quoting strings.
|
181
|
778 (defvar viper-quote-region-history (list viper-quote-string))
|
16
|
779 ;; History of Ex-style commands.
|
181
|
780 (defvar viper-ex-history nil)
|
16
|
781 ;; History of shell commands.
|
181
|
782 (defvar viper-shell-history nil)
|
16
|
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.
|
181
|
789 (defvar viper-last-shell-com nil)
|
|
790
|
|
791
|
|
792 ;;; Face-saving tricks
|
|
793
|
|
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
|
|
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"))
|
|
831 (t (:underline t :stipple "gray3")))
|
|
832 "*Face used to flash out the search pattern."
|
|
833 :group 'viper-highlighting)
|
|
834 ;; An internal variable. Viper takes the face from here.
|
197
|
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.")
|
181
|
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"))
|
|
861 (t (:underline t :stipple "gray3")))
|
|
862 "*Face for highlighting replace regions on a window display."
|
|
863 :group 'viper-highlighting)
|
|
864 ;; An internal variable. Viper takes the face from here.
|
197
|
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.")
|
181
|
870 (viper-hide-face 'viper-replace-overlay-face)
|
16
|
871
|
181
|
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.
|
197
|
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.")
|
181
|
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.
|
197
|
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.")
|
181
|
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.
|
197
|
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.")
|
181
|
975 (viper-hide-face 'viper-minibuffer-vi-face)
|
|
976
|
|
977 ;; the current face to be used in the minibuffer
|
197
|
978 (viper-deflocalvar
|
|
979 viper-minibuffer-current-face viper-minibuffer-emacs-face "")
|
16
|
980
|
|
981
|
|
982 ;;; Miscellaneous
|
|
983
|
181
|
984 (defvar viper-inhibit-startup-message nil
|
16
|
985 "Whether Viper startup message should be inhibited.")
|
|
986
|
181
|
987 (defcustom viper-spell-function 'ispell-region
|
175
|
988 "Spell function used by #s<move> command to spell."
|
|
989 :type 'function
|
197
|
990 :group 'viper-misc)
|
16
|
991
|
181
|
992 (defcustom viper-tags-file-name "TAGS"
|
175
|
993 "The tags file used by Viper."
|
|
994 :type 'string
|
197
|
995 :group 'viper-misc)
|
16
|
996
|
|
997 ;; Minibuffer
|
|
998
|
181
|
999 (defcustom viper-vi-style-in-minibuffer t
|
16
|
1000 "If t, use vi-style editing in minibuffer.
|
181
|
1001 Should be set in `~/.viper' file."
|
175
|
1002 :type 'boolean
|
|
1003 :group 'viper)
|
16
|
1004
|
|
1005 ;; overlay used in the minibuffer to indicate which state it is in
|
181
|
1006 (viper-deflocalvar viper-minibuffer-overlay nil)
|
16
|
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
|
185
|
1011 (defvar viper-minibuffer-exit-hook '(viper-minibuffer-trim-tail))
|
16
|
1012
|
|
1013
|
|
1014 ;; Mode line
|
181
|
1015 (defconst viper-vi-state-id "<V> "
|
16
|
1016 "Mode line tag identifying the Vi mode of Viper.")
|
181
|
1017 (defconst viper-emacs-state-id "<E> "
|
16
|
1018 "Mode line tag identifying the Emacs mode of Viper.")
|
181
|
1019 (defconst viper-insert-state-id "<I> "
|
16
|
1020 "Mode line tag identifying the Insert mode of Viper.")
|
181
|
1021 (defconst viper-replace-state-id "<R> "
|
16
|
1022 "Mode line tag identifying the Replace mode of Viper.")
|
|
1023
|
|
1024
|
197
|
1025 (defgroup viper-hooks nil
|
|
1026 "Viper hooks."
|
|
1027 :prefix "viper-"
|
|
1028 :group 'viper)
|
|
1029
|
181
|
1030 (defcustom viper-vi-state-hook nil
|
175
|
1031 "*Hooks run just before the switch to Vi mode is completed."
|
|
1032 :type 'hook
|
197
|
1033 :group 'viper-hooks)
|
181
|
1034 (defcustom viper-insert-state-hook nil
|
175
|
1035 "*Hooks run just before the switch to Insert mode is completed."
|
|
1036 :type 'hook
|
197
|
1037 :group 'viper-hooks)
|
181
|
1038 (defcustom viper-replace-state-hook nil
|
175
|
1039 "*Hooks run just before the switch to Replace mode is completed."
|
|
1040 :type 'hook
|
197
|
1041 :group 'viper-hooks)
|
181
|
1042 (defcustom viper-emacs-state-hook nil
|
175
|
1043 "*Hooks run just before the switch to Emacs mode is completed."
|
|
1044 :type 'hook
|
197
|
1045 :group 'viper-hooks)
|
16
|
1046
|
181
|
1047 (defcustom viper-load-hook nil
|
175
|
1048 "Hooks run just after loading Viper."
|
|
1049 :type 'hook
|
197
|
1050 :group 'viper-hooks)
|
16
|
1051
|
175
|
1052
|
|
1053 ;;; Local Variables:
|
181
|
1054 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
|
175
|
1055 ;;; End:
|
|
1056
|
16
|
1057 ;;; viper-ex.el ends here
|