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