diff options
| author | Sam Steingold | 1999-11-12 18:40:24 +0000 |
|---|---|---|
| committer | Sam Steingold | 1999-11-12 18:40:24 +0000 |
| commit | f10970635d0bbf651349f88e712a0c385ccbc9e1 (patch) | |
| tree | 0e34f6032614b98a339ba18187baab53d977816d | |
| parent | 6c2599ed01ce408373a28505c90618ddad182b34 (diff) | |
| download | emacs-f10970635d0bbf651349f88e712a0c385ccbc9e1.tar.gz emacs-f10970635d0bbf651349f88e712a0c385ccbc9e1.zip | |
* emulation/viper-init.el (viper-deflocalvar, viper-loop,
viper-buffer-live-p, viper-kbd-buf-alist, viper-kbd-buf-pair,
viper-kbd-buf-definition, viper-kbd-mode-alist,
viper-kbd-mode-pair, viper-kbd-mode-definition,
viper-kbd-global-pair, viper-kbd-global-definition):
Use the new backquote syntax.
* emulation/viper-cmd.el (viper-test-com-defun,
viper-prefix-arg-value, viper-prefix-arg-com):
Use the new backquote syntax.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 764 | ||||
| -rw-r--r-- | lisp/emulation/viper-init.el | 118 |
3 files changed, 450 insertions, 443 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 274293eb327..cc443015f40 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 1999-11-12 Sam Steingold <sds@ksp.com> | 1 | 1999-11-12 Sam Steingold <sds@ksp.com> |
| 2 | 2 | ||
| 3 | * emulation/viper-init.el (viper-deflocalvar, viper-loop, | ||
| 4 | viper-buffer-live-p, viper-kbd-buf-alist, viper-kbd-buf-pair, | ||
| 5 | viper-kbd-buf-definition, viper-kbd-mode-alist, | ||
| 6 | viper-kbd-mode-pair, viper-kbd-mode-definition, | ||
| 7 | viper-kbd-global-pair, viper-kbd-global-definition): | ||
| 8 | Use the new backquote syntax. | ||
| 9 | |||
| 10 | * emulation/viper-cmd.el (viper-test-com-defun, | ||
| 11 | viper-prefix-arg-value, viper-prefix-arg-com): | ||
| 12 | Use the new backquote syntax. | ||
| 13 | |||
| 3 | * emacs-lisp/debug.el (debugger-env-macro): | 14 | * emacs-lisp/debug.el (debugger-env-macro): |
| 4 | Use the new backquote syntax. | 15 | Use the new backquote syntax. |
| 5 | 16 | ||
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index c035b9f31f6..9c4bbde61ef 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el | |||
| @@ -78,17 +78,17 @@ | |||
| 78 | (let* ((snm (symbol-name name)) | 78 | (let* ((snm (symbol-name name)) |
| 79 | (nm-p (intern (concat snm "-p"))) | 79 | (nm-p (intern (concat snm "-p"))) |
| 80 | (nms (intern (concat snm "s")))) | 80 | (nms (intern (concat snm "s")))) |
| 81 | (` (defun (, nm-p) (com) | 81 | `(defun ,nm-p (com) |
| 82 | (consp (memq (if (and (viper-characterp com) (< com 0)) | 82 | (consp (memq (if (and (viper-characterp com) (< com 0)) |
| 83 | (- com) com) (, nms))))))) | 83 | (- com) com) ,nms))))) |
| 84 | 84 | ||
| 85 | ;; Variables for defining VI commands | 85 | ;; Variables for defining VI commands |
| 86 | 86 | ||
| 87 | ;; Modifying commands that can be prefixes to movement commands | 87 | ;; Modifying commands that can be prefixes to movement commands |
| 88 | (defconst viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\")) | 88 | (defconst viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\")) |
| 89 | ;; define viper-prefix-command-p | 89 | ;; define viper-prefix-command-p |
| 90 | (viper-test-com-defun viper-prefix-command) | 90 | (viper-test-com-defun viper-prefix-command) |
| 91 | 91 | ||
| 92 | ;; Commands that are pairs eg. dd. r and R here are a hack | 92 | ;; Commands that are pairs eg. dd. r and R here are a hack |
| 93 | (defconst viper-charpair-commands '(?c ?d ?y ?! ?= ?< ?> ?r ?R)) | 93 | (defconst viper-charpair-commands '(?c ?d ?y ?! ?= ?< ?> ?r ?R)) |
| 94 | ;; define viper-charpair-command-p | 94 | ;; define viper-charpair-command-p |
| @@ -149,7 +149,7 @@ | |||
| 149 | ;; Runs viper-after-change-functions inside after-change-functions | 149 | ;; Runs viper-after-change-functions inside after-change-functions |
| 150 | (defun viper-after-change-sentinel (beg end len) | 150 | (defun viper-after-change-sentinel (beg end len) |
| 151 | (run-hook-with-args 'viper-after-change-functions beg end len)) | 151 | (run-hook-with-args 'viper-after-change-functions beg end len)) |
| 152 | 152 | ||
| 153 | ;; Runs viper-before-change-functions inside before-change-functions | 153 | ;; Runs viper-before-change-functions inside before-change-functions |
| 154 | (defun viper-before-change-sentinel (beg end) | 154 | (defun viper-before-change-sentinel (beg end) |
| 155 | (run-hook-with-args 'viper-before-change-functions beg end)) | 155 | (run-hook-with-args 'viper-before-change-functions beg end)) |
| @@ -158,10 +158,10 @@ | |||
| 158 | (run-hooks 'viper-post-command-hooks) | 158 | (run-hooks 'viper-post-command-hooks) |
| 159 | (if (eq viper-current-state 'vi-state) | 159 | (if (eq viper-current-state 'vi-state) |
| 160 | (viper-restore-cursor-color 'after-insert-mode))) | 160 | (viper-restore-cursor-color 'after-insert-mode))) |
| 161 | 161 | ||
| 162 | (defsubst viper-pre-command-sentinel () | 162 | (defsubst viper-pre-command-sentinel () |
| 163 | (run-hooks 'viper-pre-command-hooks)) | 163 | (run-hooks 'viper-pre-command-hooks)) |
| 164 | 164 | ||
| 165 | ;; Needed so that Viper will be able to figure the last inserted | 165 | ;; Needed so that Viper will be able to figure the last inserted |
| 166 | ;; chunk of text with reasonable accuracy. | 166 | ;; chunk of text with reasonable accuracy. |
| 167 | (defsubst viper-insert-state-post-command-sentinel () | 167 | (defsubst viper-insert-state-post-command-sentinel () |
| @@ -190,7 +190,7 @@ | |||
| 190 | (> viper-insert-point viper-pre-command-point)) | 190 | (> viper-insert-point viper-pre-command-point)) |
| 191 | (viper-move-marker-locally viper-insert-point viper-pre-command-point)) | 191 | (viper-move-marker-locally viper-insert-point viper-pre-command-point)) |
| 192 | ) | 192 | ) |
| 193 | 193 | ||
| 194 | (defsubst viper-insert-state-pre-command-sentinel () | 194 | (defsubst viper-insert-state-pre-command-sentinel () |
| 195 | (or (memq this-command '(self-insert-command)) | 195 | (or (memq this-command '(self-insert-command)) |
| 196 | (memq (viper-event-key last-command-event) | 196 | (memq (viper-event-key last-command-event) |
| @@ -201,7 +201,7 @@ | |||
| 201 | (markerp viper-insert-point) | 201 | (markerp viper-insert-point) |
| 202 | (marker-position viper-insert-point)) | 202 | (marker-position viper-insert-point)) |
| 203 | (setq viper-pre-command-point (marker-position viper-insert-point)))) | 203 | (setq viper-pre-command-point (marker-position viper-insert-point)))) |
| 204 | 204 | ||
| 205 | (defsubst viper-R-state-post-command-sentinel () | 205 | (defsubst viper-R-state-post-command-sentinel () |
| 206 | ;; Restoring cursor color is needed despite | 206 | ;; Restoring cursor color is needed despite |
| 207 | ;; viper-replace-state-pre-command-sentinel: When you jump to another buffer | 207 | ;; viper-replace-state-pre-command-sentinel: When you jump to another buffer |
| @@ -223,7 +223,7 @@ | |||
| 223 | '(up down left right (meta f) (meta b) | 223 | '(up down left right (meta f) (meta b) |
| 224 | (control n) (control p) (control f) (control b))) | 224 | (control n) (control p) (control f) (control b))) |
| 225 | (viper-restore-cursor-color 'after-replace-mode))) | 225 | (viper-restore-cursor-color 'after-replace-mode))) |
| 226 | 226 | ||
| 227 | (defun viper-replace-state-post-command-sentinel () | 227 | (defun viper-replace-state-post-command-sentinel () |
| 228 | ;; Restoring cursor color is needed despite | 228 | ;; Restoring cursor color is needed despite |
| 229 | ;; viper-replace-state-pre-command-sentinel: When one jumps to another buffer | 229 | ;; viper-replace-state-pre-command-sentinel: When one jumps to another buffer |
| @@ -237,7 +237,7 @@ | |||
| 237 | ;; in viper-finish-change | 237 | ;; in viper-finish-change |
| 238 | (or (memq this-command '(self-insert-command)) | 238 | (or (memq this-command '(self-insert-command)) |
| 239 | (viper-restore-cursor-color 'after-replace-mode)) | 239 | (viper-restore-cursor-color 'after-replace-mode)) |
| 240 | (cond | 240 | (cond |
| 241 | ((eq viper-current-state 'replace-state) | 241 | ((eq viper-current-state 'replace-state) |
| 242 | ;; delete characters to compensate for inserted chars. | 242 | ;; delete characters to compensate for inserted chars. |
| 243 | (let ((replace-boundary (viper-replace-end))) | 243 | (let ((replace-boundary (viper-replace-end))) |
| @@ -249,7 +249,7 @@ | |||
| 249 | ;; terminate replace mode if reached replace limit | 249 | ;; terminate replace mode if reached replace limit |
| 250 | (if (= viper-last-posn-in-replace-region (viper-replace-end)) | 250 | (if (= viper-last-posn-in-replace-region (viper-replace-end)) |
| 251 | (viper-finish-change))) | 251 | (viper-finish-change))) |
| 252 | 252 | ||
| 253 | (if (viper-pos-within-region | 253 | (if (viper-pos-within-region |
| 254 | (point) (viper-replace-start) replace-boundary) | 254 | (point) (viper-replace-start) replace-boundary) |
| 255 | (progn | 255 | (progn |
| @@ -288,7 +288,7 @@ | |||
| 288 | (setq viper-intermediate-command nil) | 288 | (setq viper-intermediate-command nil) |
| 289 | (cond ((eq new-state 'vi-state) | 289 | (cond ((eq new-state 'vi-state) |
| 290 | (cond ((member viper-current-state '(insert-state replace-state)) | 290 | (cond ((member viper-current-state '(insert-state replace-state)) |
| 291 | 291 | ||
| 292 | ;; move viper-last-posn-while-in-insert-state | 292 | ;; move viper-last-posn-while-in-insert-state |
| 293 | ;; This is a normal hook that is executed in insert/replace | 293 | ;; This is a normal hook that is executed in insert/replace |
| 294 | ;; states after each command. In Vi/Emacs state, it does | 294 | ;; states after each command. In Vi/Emacs state, it does |
| @@ -298,11 +298,11 @@ | |||
| 298 | ;; insert/repl state was dabbrev-expansion or abbrev | 298 | ;; insert/repl state was dabbrev-expansion or abbrev |
| 299 | ;; expansion caused by hitting ESC | 299 | ;; expansion caused by hitting ESC |
| 300 | (viper-insert-state-post-command-sentinel) | 300 | (viper-insert-state-post-command-sentinel) |
| 301 | 301 | ||
| 302 | (condition-case conds | 302 | (condition-case conds |
| 303 | (progn | 303 | (progn |
| 304 | (viper-save-last-insertion | 304 | (viper-save-last-insertion |
| 305 | viper-insert-point | 305 | viper-insert-point |
| 306 | viper-last-posn-while-in-insert-state) | 306 | viper-last-posn-while-in-insert-state) |
| 307 | (if viper-began-as-replace | 307 | (if viper-began-as-replace |
| 308 | (setq viper-began-as-replace nil) | 308 | (setq viper-began-as-replace nil) |
| @@ -311,15 +311,15 @@ | |||
| 311 | (viper-repeat-insert-command)))) | 311 | (viper-repeat-insert-command)))) |
| 312 | (error | 312 | (error |
| 313 | (viper-message-conditions conds))) | 313 | (viper-message-conditions conds))) |
| 314 | 314 | ||
| 315 | (if (> (length viper-last-insertion) 0) | 315 | (if (> (length viper-last-insertion) 0) |
| 316 | (viper-push-onto-ring viper-last-insertion | 316 | (viper-push-onto-ring viper-last-insertion |
| 317 | 'viper-insertion-ring)) | 317 | 'viper-insertion-ring)) |
| 318 | 318 | ||
| 319 | (if viper-ex-style-editing | 319 | (if viper-ex-style-editing |
| 320 | (or (bolp) (backward-char 1)))) | 320 | (or (bolp) (backward-char 1)))) |
| 321 | )) | 321 | )) |
| 322 | 322 | ||
| 323 | ;; insert or replace | 323 | ;; insert or replace |
| 324 | ((memq new-state '(insert-state replace-state)) | 324 | ((memq new-state '(insert-state replace-state)) |
| 325 | (if (memq viper-current-state '(emacs-state vi-state)) | 325 | (if (memq viper-current-state '(emacs-state vi-state)) |
| @@ -331,7 +331,7 @@ | |||
| 331 | (add-hook 'viper-pre-command-hooks | 331 | (add-hook 'viper-pre-command-hooks |
| 332 | 'viper-insert-state-pre-command-sentinel t 'local)) | 332 | 'viper-insert-state-pre-command-sentinel t 'local)) |
| 333 | ) ; outermost cond | 333 | ) ; outermost cond |
| 334 | 334 | ||
| 335 | ;; Nothing needs to be done to switch to emacs mode! Just set some | 335 | ;; Nothing needs to be done to switch to emacs mode! Just set some |
| 336 | ;; variables, which is already done in viper-change-state-to-emacs! | 336 | ;; variables, which is already done in viper-change-state-to-emacs! |
| 337 | 337 | ||
| @@ -356,7 +356,7 @@ | |||
| 356 | ) | 356 | ) |
| 357 | 357 | ||
| 358 | 358 | ||
| 359 | 359 | ||
| 360 | (defun viper-adjust-keys-for (state) | 360 | (defun viper-adjust-keys-for (state) |
| 361 | "Make necessary adjustments to keymaps before entering STATE." | 361 | "Make necessary adjustments to keymaps before entering STATE." |
| 362 | (cond ((memq state '(insert-state replace-state)) | 362 | (cond ((memq state '(insert-state replace-state)) |
| @@ -370,15 +370,15 @@ | |||
| 370 | (define-key viper-insert-basic-map "\C-j" 'viper-autoindent))) | 370 | (define-key viper-insert-basic-map "\C-j" 'viper-autoindent))) |
| 371 | (define-key viper-insert-basic-map "\C-m" nil) | 371 | (define-key viper-insert-basic-map "\C-m" nil) |
| 372 | (define-key viper-insert-basic-map "\C-j" nil)) | 372 | (define-key viper-insert-basic-map "\C-j" nil)) |
| 373 | 373 | ||
| 374 | (setq viper-insert-diehard-minor-mode | 374 | (setq viper-insert-diehard-minor-mode |
| 375 | (not viper-want-emacs-keys-in-insert)) | 375 | (not viper-want-emacs-keys-in-insert)) |
| 376 | 376 | ||
| 377 | (if viper-want-ctl-h-help | 377 | (if viper-want-ctl-h-help |
| 378 | (progn | 378 | (progn |
| 379 | (define-key viper-insert-basic-map "\C-h" 'help-command) | 379 | (define-key viper-insert-basic-map "\C-h" 'help-command) |
| 380 | (define-key viper-replace-map "\C-h" 'help-command)) | 380 | (define-key viper-replace-map "\C-h" 'help-command)) |
| 381 | (define-key viper-insert-basic-map | 381 | (define-key viper-insert-basic-map |
| 382 | "\C-h" 'viper-del-backward-char-in-insert) | 382 | "\C-h" 'viper-del-backward-char-in-insert) |
| 383 | (define-key viper-replace-map | 383 | (define-key viper-replace-map |
| 384 | "\C-h" 'viper-del-backward-char-in-replace)) | 384 | "\C-h" 'viper-del-backward-char-in-replace)) |
| @@ -396,35 +396,35 @@ | |||
| 396 | ;; In XEmacs, C-h overrides backspace, so we make sure it doesn't. | 396 | ;; In XEmacs, C-h overrides backspace, so we make sure it doesn't. |
| 397 | (define-key viper-vi-basic-map [backspace] 'viper-backward-char)) | 397 | (define-key viper-vi-basic-map [backspace] 'viper-backward-char)) |
| 398 | )) | 398 | )) |
| 399 | 399 | ||
| 400 | 400 | ||
| 401 | ;; Normalizes minor-mode-map-alist by putting Viper keymaps first. | 401 | ;; Normalizes minor-mode-map-alist by putting Viper keymaps first. |
| 402 | ;; This ensures that Viper bindings are in effect, regardless of which minor | 402 | ;; This ensures that Viper bindings are in effect, regardless of which minor |
| 403 | ;; modes were turned on by the user or by other packages. | 403 | ;; modes were turned on by the user or by other packages. |
| 404 | (defun viper-normalize-minor-mode-map-alist () | 404 | (defun viper-normalize-minor-mode-map-alist () |
| 405 | (setq minor-mode-map-alist | 405 | (setq minor-mode-map-alist |
| 406 | (viper-append-filter-alist | 406 | (viper-append-filter-alist |
| 407 | (list | 407 | (list |
| 408 | (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map) | 408 | (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map) |
| 409 | (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map) | 409 | (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map) |
| 410 | (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map) | 410 | (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map) |
| 411 | (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map) | 411 | (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map) |
| 412 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) | 412 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) |
| 413 | (cons 'viper-vi-state-modifier-minor-mode | 413 | (cons 'viper-vi-state-modifier-minor-mode |
| 414 | (if (keymapp | 414 | (if (keymapp |
| 415 | (cdr (assoc major-mode | 415 | (cdr (assoc major-mode |
| 416 | viper-vi-state-modifier-alist))) | 416 | viper-vi-state-modifier-alist))) |
| 417 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) | 417 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) |
| 418 | viper-empty-keymap)) | 418 | viper-empty-keymap)) |
| 419 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) | 419 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) |
| 420 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) | 420 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) |
| 421 | (cons 'viper-insert-intercept-minor-mode | 421 | (cons 'viper-insert-intercept-minor-mode |
| 422 | viper-insert-intercept-map) | 422 | viper-insert-intercept-map) |
| 423 | (cons 'viper-replace-minor-mode viper-replace-map) | 423 | (cons 'viper-replace-minor-mode viper-replace-map) |
| 424 | ;; viper-insert-minibuffer-minor-mode must come after | 424 | ;; viper-insert-minibuffer-minor-mode must come after |
| 425 | ;; viper-replace-minor-mode | 425 | ;; viper-replace-minor-mode |
| 426 | (cons 'viper-insert-minibuffer-minor-mode | 426 | (cons 'viper-insert-minibuffer-minor-mode |
| 427 | viper-minibuffer-map) | 427 | viper-minibuffer-map) |
| 428 | (cons 'viper-insert-local-user-minor-mode | 428 | (cons 'viper-insert-local-user-minor-mode |
| 429 | viper-insert-local-user-map) | 429 | viper-insert-local-user-map) |
| 430 | (cons 'viper-insert-kbd-minor-mode viper-insert-kbd-map) | 430 | (cons 'viper-insert-kbd-minor-mode viper-insert-kbd-map) |
| @@ -433,7 +433,7 @@ | |||
| 433 | (cons 'viper-insert-state-modifier-minor-mode | 433 | (cons 'viper-insert-state-modifier-minor-mode |
| 434 | (if (keymapp | 434 | (if (keymapp |
| 435 | (cdr (assoc major-mode | 435 | (cdr (assoc major-mode |
| 436 | viper-insert-state-modifier-alist))) | 436 | viper-insert-state-modifier-alist))) |
| 437 | (cdr (assoc major-mode | 437 | (cdr (assoc major-mode |
| 438 | viper-insert-state-modifier-alist)) | 438 | viper-insert-state-modifier-alist)) |
| 439 | viper-empty-keymap)) | 439 | viper-empty-keymap)) |
| @@ -455,8 +455,8 @@ | |||
| 455 | viper-empty-keymap)) | 455 | viper-empty-keymap)) |
| 456 | ) | 456 | ) |
| 457 | minor-mode-map-alist))) | 457 | minor-mode-map-alist))) |
| 458 | 458 | ||
| 459 | 459 | ||
| 460 | 460 | ||
| 461 | 461 | ||
| 462 | 462 | ||
| @@ -464,15 +464,15 @@ | |||
| 464 | 464 | ||
| 465 | ;; Modifies mode-line-buffer-identification. | 465 | ;; Modifies mode-line-buffer-identification. |
| 466 | (defun viper-refresh-mode-line () | 466 | (defun viper-refresh-mode-line () |
| 467 | (setq viper-mode-string | 467 | (setq viper-mode-string |
| 468 | (cond ((eq viper-current-state 'emacs-state) viper-emacs-state-id) | 468 | (cond ((eq viper-current-state 'emacs-state) viper-emacs-state-id) |
| 469 | ((eq viper-current-state 'vi-state) viper-vi-state-id) | 469 | ((eq viper-current-state 'vi-state) viper-vi-state-id) |
| 470 | ((eq viper-current-state 'replace-state) viper-replace-state-id) | 470 | ((eq viper-current-state 'replace-state) viper-replace-state-id) |
| 471 | ((eq viper-current-state 'insert-state) viper-insert-state-id))) | 471 | ((eq viper-current-state 'insert-state) viper-insert-state-id))) |
| 472 | 472 | ||
| 473 | ;; Sets Viper mode string in global-mode-string | 473 | ;; Sets Viper mode string in global-mode-string |
| 474 | (force-mode-line-update)) | 474 | (force-mode-line-update)) |
| 475 | 475 | ||
| 476 | 476 | ||
| 477 | ;; Switch from Insert state to Vi state. | 477 | ;; Switch from Insert state to Vi state. |
| 478 | (defun viper-exit-insert-state () | 478 | (defun viper-exit-insert-state () |
| @@ -481,22 +481,22 @@ | |||
| 481 | 481 | ||
| 482 | (defun viper-set-mode-vars-for (state) | 482 | (defun viper-set-mode-vars-for (state) |
| 483 | "Sets Viper minor mode variables to put Viper's state STATE in effect." | 483 | "Sets Viper minor mode variables to put Viper's state STATE in effect." |
| 484 | 484 | ||
| 485 | ;; Emacs state | 485 | ;; Emacs state |
| 486 | (setq viper-vi-minibuffer-minor-mode nil | 486 | (setq viper-vi-minibuffer-minor-mode nil |
| 487 | viper-insert-minibuffer-minor-mode nil | 487 | viper-insert-minibuffer-minor-mode nil |
| 488 | viper-vi-intercept-minor-mode nil | 488 | viper-vi-intercept-minor-mode nil |
| 489 | viper-insert-intercept-minor-mode nil | 489 | viper-insert-intercept-minor-mode nil |
| 490 | 490 | ||
| 491 | viper-vi-local-user-minor-mode nil | 491 | viper-vi-local-user-minor-mode nil |
| 492 | viper-vi-kbd-minor-mode nil | 492 | viper-vi-kbd-minor-mode nil |
| 493 | viper-vi-global-user-minor-mode nil | 493 | viper-vi-global-user-minor-mode nil |
| 494 | viper-vi-state-modifier-minor-mode nil | 494 | viper-vi-state-modifier-minor-mode nil |
| 495 | viper-vi-diehard-minor-mode nil | 495 | viper-vi-diehard-minor-mode nil |
| 496 | viper-vi-basic-minor-mode nil | 496 | viper-vi-basic-minor-mode nil |
| 497 | 497 | ||
| 498 | viper-replace-minor-mode nil | 498 | viper-replace-minor-mode nil |
| 499 | 499 | ||
| 500 | viper-insert-local-user-minor-mode nil | 500 | viper-insert-local-user-minor-mode nil |
| 501 | viper-insert-kbd-minor-mode nil | 501 | viper-insert-kbd-minor-mode nil |
| 502 | viper-insert-global-user-minor-mode nil | 502 | viper-insert-global-user-minor-mode nil |
| @@ -509,40 +509,40 @@ | |||
| 509 | viper-emacs-global-user-minor-mode t | 509 | viper-emacs-global-user-minor-mode t |
| 510 | viper-emacs-state-modifier-minor-mode t | 510 | viper-emacs-state-modifier-minor-mode t |
| 511 | ) | 511 | ) |
| 512 | 512 | ||
| 513 | ;; Vi state | 513 | ;; Vi state |
| 514 | (if (eq state 'vi-state) ; adjust for vi-state | 514 | (if (eq state 'vi-state) ; adjust for vi-state |
| 515 | (setq | 515 | (setq |
| 516 | viper-vi-intercept-minor-mode t | 516 | viper-vi-intercept-minor-mode t |
| 517 | viper-vi-minibuffer-minor-mode (viper-is-in-minibuffer) | 517 | viper-vi-minibuffer-minor-mode (viper-is-in-minibuffer) |
| 518 | viper-vi-local-user-minor-mode t | 518 | viper-vi-local-user-minor-mode t |
| 519 | viper-vi-kbd-minor-mode (not (viper-is-in-minibuffer)) | 519 | viper-vi-kbd-minor-mode (not (viper-is-in-minibuffer)) |
| 520 | viper-vi-global-user-minor-mode t | 520 | viper-vi-global-user-minor-mode t |
| 521 | viper-vi-state-modifier-minor-mode t | 521 | viper-vi-state-modifier-minor-mode t |
| 522 | ;; don't let the diehard keymap block command completion | 522 | ;; don't let the diehard keymap block command completion |
| 523 | ;; and other things in the minibuffer | 523 | ;; and other things in the minibuffer |
| 524 | viper-vi-diehard-minor-mode (not | 524 | viper-vi-diehard-minor-mode (not |
| 525 | (or viper-want-emacs-keys-in-vi | 525 | (or viper-want-emacs-keys-in-vi |
| 526 | (viper-is-in-minibuffer))) | 526 | (viper-is-in-minibuffer))) |
| 527 | viper-vi-basic-minor-mode t | 527 | viper-vi-basic-minor-mode t |
| 528 | viper-emacs-intercept-minor-mode nil | 528 | viper-emacs-intercept-minor-mode nil |
| 529 | viper-emacs-local-user-minor-mode nil | 529 | viper-emacs-local-user-minor-mode nil |
| 530 | viper-emacs-kbd-minor-mode nil | 530 | viper-emacs-kbd-minor-mode nil |
| 531 | viper-emacs-global-user-minor-mode nil | 531 | viper-emacs-global-user-minor-mode nil |
| 532 | viper-emacs-state-modifier-minor-mode nil | 532 | viper-emacs-state-modifier-minor-mode nil |
| 533 | )) | 533 | )) |
| 534 | 534 | ||
| 535 | ;; Insert and Replace states | 535 | ;; Insert and Replace states |
| 536 | (if (member state '(insert-state replace-state)) | 536 | (if (member state '(insert-state replace-state)) |
| 537 | (setq | 537 | (setq |
| 538 | viper-insert-intercept-minor-mode t | 538 | viper-insert-intercept-minor-mode t |
| 539 | viper-replace-minor-mode (eq state 'replace-state) | 539 | viper-replace-minor-mode (eq state 'replace-state) |
| 540 | viper-insert-minibuffer-minor-mode (viper-is-in-minibuffer) | 540 | viper-insert-minibuffer-minor-mode (viper-is-in-minibuffer) |
| 541 | viper-insert-local-user-minor-mode t | 541 | viper-insert-local-user-minor-mode t |
| 542 | viper-insert-kbd-minor-mode (not (viper-is-in-minibuffer)) | 542 | viper-insert-kbd-minor-mode (not (viper-is-in-minibuffer)) |
| 543 | viper-insert-global-user-minor-mode t | 543 | viper-insert-global-user-minor-mode t |
| 544 | viper-insert-state-modifier-minor-mode t | 544 | viper-insert-state-modifier-minor-mode t |
| 545 | ;; don't let the diehard keymap block command completion | 545 | ;; don't let the diehard keymap block command completion |
| 546 | ;; and other things in the minibuffer | 546 | ;; and other things in the minibuffer |
| 547 | viper-insert-diehard-minor-mode (not | 547 | viper-insert-diehard-minor-mode (not |
| 548 | (or | 548 | (or |
| @@ -555,7 +555,7 @@ | |||
| 555 | viper-emacs-global-user-minor-mode nil | 555 | viper-emacs-global-user-minor-mode nil |
| 556 | viper-emacs-state-modifier-minor-mode nil | 556 | viper-emacs-state-modifier-minor-mode nil |
| 557 | )) | 557 | )) |
| 558 | 558 | ||
| 559 | ;; minibuffer faces | 559 | ;; minibuffer faces |
| 560 | (if (viper-has-face-support-p) | 560 | (if (viper-has-face-support-p) |
| 561 | (setq viper-minibuffer-current-face | 561 | (setq viper-minibuffer-current-face |
| @@ -563,7 +563,7 @@ | |||
| 563 | ((eq state 'vi-state) viper-minibuffer-vi-face) | 563 | ((eq state 'vi-state) viper-minibuffer-vi-face) |
| 564 | ((memq state '(insert-state replace-state)) | 564 | ((memq state '(insert-state replace-state)) |
| 565 | viper-minibuffer-insert-face)))) | 565 | viper-minibuffer-insert-face)))) |
| 566 | 566 | ||
| 567 | (if (viper-is-in-minibuffer) | 567 | (if (viper-is-in-minibuffer) |
| 568 | (viper-set-minibuffer-overlay)) | 568 | (viper-set-minibuffer-overlay)) |
| 569 | ) | 569 | ) |
| @@ -594,7 +594,7 @@ | |||
| 594 | (viper-change-state 'vi-state) | 594 | (viper-change-state 'vi-state) |
| 595 | 595 | ||
| 596 | (viper-restore-cursor-color 'after-insert-mode) | 596 | (viper-restore-cursor-color 'after-insert-mode) |
| 597 | 597 | ||
| 598 | ;; Protect against user errors in hooks | 598 | ;; Protect against user errors in hooks |
| 599 | (condition-case conds | 599 | (condition-case conds |
| 600 | (run-hooks 'viper-vi-state-hook) | 600 | (run-hooks 'viper-vi-state-hook) |
| @@ -609,26 +609,26 @@ | |||
| 609 | (or (viper-overlay-p viper-replace-overlay) | 609 | (or (viper-overlay-p viper-replace-overlay) |
| 610 | (viper-set-replace-overlay (point-min) (point-min))) | 610 | (viper-set-replace-overlay (point-min) (point-min))) |
| 611 | (viper-hide-replace-overlay) | 611 | (viper-hide-replace-overlay) |
| 612 | 612 | ||
| 613 | (let ((has-saved-cursor-color-in-insert-mode | 613 | (let ((has-saved-cursor-color-in-insert-mode |
| 614 | (stringp (viper-get-saved-cursor-color-in-insert-mode)))) | 614 | (stringp (viper-get-saved-cursor-color-in-insert-mode)))) |
| 615 | (or has-saved-cursor-color-in-insert-mode | 615 | (or has-saved-cursor-color-in-insert-mode |
| 616 | (string= (viper-get-cursor-color) viper-insert-state-cursor-color) | 616 | (string= (viper-get-cursor-color) viper-insert-state-cursor-color) |
| 617 | (viper-save-cursor-color 'before-insert-mode)) | 617 | (viper-save-cursor-color 'before-insert-mode)) |
| 618 | (viper-change-cursor-color viper-insert-state-cursor-color)) | 618 | (viper-change-cursor-color viper-insert-state-cursor-color)) |
| 619 | 619 | ||
| 620 | ;; Protect against user errors in hooks | 620 | ;; Protect against user errors in hooks |
| 621 | (condition-case conds | 621 | (condition-case conds |
| 622 | (run-hooks 'viper-insert-state-hook) | 622 | (run-hooks 'viper-insert-state-hook) |
| 623 | (error | 623 | (error |
| 624 | (viper-message-conditions conds)))) | 624 | (viper-message-conditions conds)))) |
| 625 | 625 | ||
| 626 | (defsubst viper-downgrade-to-insert () | 626 | (defsubst viper-downgrade-to-insert () |
| 627 | (setq viper-current-state 'insert-state | 627 | (setq viper-current-state 'insert-state |
| 628 | viper-replace-minor-mode nil)) | 628 | viper-replace-minor-mode nil)) |
| 629 | 629 | ||
| 630 | 630 | ||
| 631 | 631 | ||
| 632 | ;; Change to replace state. When the end of replacement region is reached, | 632 | ;; Change to replace state. When the end of replacement region is reached, |
| 633 | ;; replace state changes to insert state. | 633 | ;; replace state changes to insert state. |
| 634 | (defun viper-change-state-to-replace (&optional non-R-cmd) | 634 | (defun viper-change-state-to-replace (&optional non-R-cmd) |
| @@ -638,14 +638,14 @@ | |||
| 638 | (run-hooks 'viper-insert-state-hook 'viper-replace-state-hook) | 638 | (run-hooks 'viper-insert-state-hook 'viper-replace-state-hook) |
| 639 | (error | 639 | (error |
| 640 | (viper-message-conditions conds))) | 640 | (viper-message-conditions conds))) |
| 641 | 641 | ||
| 642 | (if non-R-cmd | 642 | (if non-R-cmd |
| 643 | (viper-start-replace) | 643 | (viper-start-replace) |
| 644 | ;; 'R' is implemented using Emacs's overwrite-mode | 644 | ;; 'R' is implemented using Emacs's overwrite-mode |
| 645 | (viper-start-R-mode)) | 645 | (viper-start-R-mode)) |
| 646 | ) | 646 | ) |
| 647 | 647 | ||
| 648 | 648 | ||
| 649 | (defun viper-change-state-to-emacs () | 649 | (defun viper-change-state-to-emacs () |
| 650 | "Change Viper state to Emacs." | 650 | "Change Viper state to Emacs." |
| 651 | (interactive) | 651 | (interactive) |
| @@ -653,13 +653,13 @@ | |||
| 653 | (viper-set-replace-overlay (point-min) (point-min))) | 653 | (viper-set-replace-overlay (point-min) (point-min))) |
| 654 | (viper-hide-replace-overlay) | 654 | (viper-hide-replace-overlay) |
| 655 | (viper-change-state 'emacs-state) | 655 | (viper-change-state 'emacs-state) |
| 656 | 656 | ||
| 657 | ;; Protect agains user errors in hooks | 657 | ;; Protect agains user errors in hooks |
| 658 | (condition-case conds | 658 | (condition-case conds |
| 659 | (run-hooks 'viper-emacs-state-hook) | 659 | (run-hooks 'viper-emacs-state-hook) |
| 660 | (error | 660 | (error |
| 661 | (viper-message-conditions conds)))) | 661 | (viper-message-conditions conds)))) |
| 662 | 662 | ||
| 663 | ;; escape to emacs mode termporarily | 663 | ;; escape to emacs mode termporarily |
| 664 | (defun viper-escape-to-emacs (arg &optional events) | 664 | (defun viper-escape-to-emacs (arg &optional events) |
| 665 | "Escape to Emacs state from Vi state for one Emacs command. | 665 | "Escape to Emacs state from Vi state for one Emacs command. |
| @@ -669,7 +669,7 @@ EVENTS is a list of events, which become the beginning of the command." | |||
| 669 | (if (= last-command-char ?\\) | 669 | (if (= last-command-char ?\\) |
| 670 | (message "Switched to EMACS state for the next command...")) | 670 | (message "Switched to EMACS state for the next command...")) |
| 671 | (viper-escape-to-state arg events 'emacs-state)) | 671 | (viper-escape-to-state arg events 'emacs-state)) |
| 672 | 672 | ||
| 673 | ;; escape to Vi mode termporarily | 673 | ;; escape to Vi mode termporarily |
| 674 | (defun viper-escape-to-vi (arg) | 674 | (defun viper-escape-to-vi (arg) |
| 675 | "Escape from Emacs state to Vi state for one Vi 1-character command. | 675 | "Escape from Emacs state to Vi state for one Vi 1-character command. |
| @@ -679,7 +679,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to | |||
| 679 | (interactive "P") | 679 | (interactive "P") |
| 680 | (message "Switched to VI state for the next command...") | 680 | (message "Switched to VI state for the next command...") |
| 681 | (viper-escape-to-state arg nil 'vi-state)) | 681 | (viper-escape-to-state arg nil 'vi-state)) |
| 682 | 682 | ||
| 683 | ;; Escape to STATE mode for one Emacs command. | 683 | ;; Escape to STATE mode for one Emacs command. |
| 684 | (defun viper-escape-to-state (arg events state) | 684 | (defun viper-escape-to-state (arg events state) |
| 685 | ;;(let (com key prefix-arg) | 685 | ;;(let (com key prefix-arg) |
| @@ -688,15 +688,15 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to | |||
| 688 | (viper-set-mode-vars-for state) | 688 | (viper-set-mode-vars-for state) |
| 689 | (viper-normalize-minor-mode-map-alist) | 689 | (viper-normalize-minor-mode-map-alist) |
| 690 | (if events (viper-set-unread-command-events events)) | 690 | (if events (viper-set-unread-command-events events)) |
| 691 | 691 | ||
| 692 | ;; protect against keyboard quit and other errors | 692 | ;; protect against keyboard quit and other errors |
| 693 | (condition-case nil | 693 | (condition-case nil |
| 694 | (let (viper-vi-kbd-minor-mode | 694 | (let (viper-vi-kbd-minor-mode |
| 695 | viper-insert-kbd-minor-mode | 695 | viper-insert-kbd-minor-mode |
| 696 | viper-emacs-kbd-minor-mode) | 696 | viper-emacs-kbd-minor-mode) |
| 697 | (unwind-protect | 697 | (unwind-protect |
| 698 | (progn | 698 | (progn |
| 699 | (setq com (key-binding (setq key | 699 | (setq com (key-binding (setq key |
| 700 | (if viper-xemacs-p | 700 | (if viper-xemacs-p |
| 701 | (read-key-sequence nil) | 701 | (read-key-sequence nil) |
| 702 | (read-key-sequence nil t))))) | 702 | (read-key-sequence nil t))))) |
| @@ -712,7 +712,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to | |||
| 712 | ;; `state'. When we return to the orig buffer, the bindings will be | 712 | ;; `state'. When we return to the orig buffer, the bindings will be |
| 713 | ;; screwed up. | 713 | ;; screwed up. |
| 714 | (viper-set-mode-vars-for viper-current-state) | 714 | (viper-set-mode-vars-for viper-current-state) |
| 715 | 715 | ||
| 716 | ;; this-command, last-command-char, last-command-event | 716 | ;; this-command, last-command-char, last-command-event |
| 717 | (setq this-command com) | 717 | (setq this-command com) |
| 718 | (if viper-xemacs-p ; XEmacs represents key sequences as vectors | 718 | (if viper-xemacs-p ; XEmacs represents key sequences as vectors |
| @@ -723,7 +723,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to | |||
| 723 | (setq last-command-event | 723 | (setq last-command-event |
| 724 | (viper-copy-event (viper-seq-last-elt key)) | 724 | (viper-copy-event (viper-seq-last-elt key)) |
| 725 | last-command-char last-command-event)) | 725 | last-command-char last-command-event)) |
| 726 | 726 | ||
| 727 | (if (commandp com) | 727 | (if (commandp com) |
| 728 | (progn | 728 | (progn |
| 729 | (setq prefix-arg (or prefix-arg arg)) | 729 | (setq prefix-arg (or prefix-arg arg)) |
| @@ -733,7 +733,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to | |||
| 733 | (error (beep 1)))) | 733 | (error (beep 1)))) |
| 734 | ;; set state in the new buffer | 734 | ;; set state in the new buffer |
| 735 | (viper-set-mode-vars-for viper-current-state)) | 735 | (viper-set-mode-vars-for viper-current-state)) |
| 736 | 736 | ||
| 737 | (defun viper-exec-form-in-vi (form) | 737 | (defun viper-exec-form-in-vi (form) |
| 738 | "Execute FORM in Vi state, regardless of the Ccurrent Vi state." | 738 | "Execute FORM in Vi state, regardless of the Ccurrent Vi state." |
| 739 | (let ((buff (current-buffer)) | 739 | (let ((buff (current-buffer)) |
| @@ -768,7 +768,7 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes." | |||
| 768 | (viper-set-mode-vars-for viper-current-state) | 768 | (viper-set-mode-vars-for viper-current-state) |
| 769 | result)) | 769 | result)) |
| 770 | 770 | ||
| 771 | 771 | ||
| 772 | ;; This is needed because minor modes sometimes override essential Viper | 772 | ;; This is needed because minor modes sometimes override essential Viper |
| 773 | ;; bindings. By letting Viper know which files these modes are in, it will | 773 | ;; bindings. By letting Viper know which files these modes are in, it will |
| 774 | ;; arrange to reorganize minor-mode-map-alist so that things will work right. | 774 | ;; arrange to reorganize minor-mode-map-alist so that things will work right. |
| @@ -784,9 +784,9 @@ LOAD-FILE is a name of the file where the specific minor mode is defined. | |||
| 784 | Suffixes such as .el or .elc should be stripped." | 784 | Suffixes such as .el or .elc should be stripped." |
| 785 | 785 | ||
| 786 | (interactive "sEnter name of the load file: ") | 786 | (interactive "sEnter name of the load file: ") |
| 787 | 787 | ||
| 788 | (eval-after-load load-file '(viper-normalize-minor-mode-map-alist)) | 788 | (eval-after-load load-file '(viper-normalize-minor-mode-map-alist)) |
| 789 | 789 | ||
| 790 | ;; Change the default for minor-mode-map-alist each time a harnessed minor | 790 | ;; Change the default for minor-mode-map-alist each time a harnessed minor |
| 791 | ;; mode adds its own keymap to the a-list. | 791 | ;; mode adds its own keymap to the a-list. |
| 792 | (eval-after-load | 792 | (eval-after-load |
| @@ -808,7 +808,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 808 | (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state)) | 808 | (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state)) |
| 809 | (setq char (viper-read-char-exclusive)) | 809 | (setq char (viper-read-char-exclusive)) |
| 810 | (viper-escape-to-emacs arg (list ?\e char) )) | 810 | (viper-escape-to-emacs arg (list ?\e char) )) |
| 811 | ((and (eq viper-no-multiple-ESC 'twice) | 811 | ((and (eq viper-no-multiple-ESC 'twice) |
| 812 | (eq viper-current-state 'vi-state)) | 812 | (eq viper-current-state 'vi-state)) |
| 813 | (setq char (viper-read-char-exclusive)) | 813 | (setq char (viper-read-char-exclusive)) |
| 814 | (if (= char (string-to-char viper-ESC-key)) | 814 | (if (= char (string-to-char viper-ESC-key)) |
| @@ -844,7 +844,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 844 | (keyseq [nil]) | 844 | (keyseq [nil]) |
| 845 | inhibit-quit) | 845 | inhibit-quit) |
| 846 | (if (viper-ESC-event-p event) | 846 | (if (viper-ESC-event-p event) |
| 847 | (progn | 847 | (progn |
| 848 | (if (viper-fast-keysequence-p) | 848 | (if (viper-fast-keysequence-p) |
| 849 | (progn | 849 | (progn |
| 850 | (let (minor-mode-map-alist) | 850 | (let (minor-mode-map-alist) |
| @@ -888,7 +888,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 888 | ((and viper-xemacs-p | 888 | ((and viper-xemacs-p |
| 889 | (key-press-event-p first-key) | 889 | (key-press-event-p first-key) |
| 890 | (equal '(meta) key-mod)) | 890 | (equal '(meta) key-mod)) |
| 891 | (viper-set-unread-command-events | 891 | (viper-set-unread-command-events |
| 892 | (vconcat (vector | 892 | (vconcat (vector |
| 893 | (character-to-event (event-key first-key))) | 893 | (character-to-event (event-key first-key))) |
| 894 | (subseq keyseq 1))) | 894 | (subseq keyseq 1))) |
| @@ -899,7 +899,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 899 | (viper-copy-event first-key))) | 899 | (viper-copy-event first-key))) |
| 900 | )) | 900 | )) |
| 901 | ) ; end progn | 901 | ) ; end progn |
| 902 | 902 | ||
| 903 | ;; this is escape event with nothing after it | 903 | ;; this is escape event with nothing after it |
| 904 | ;; put in unread-command-event and then re-read | 904 | ;; put in unread-command-event and then re-read |
| 905 | (viper-set-unread-command-events event) | 905 | (viper-set-unread-command-events event) |
| @@ -910,7 +910,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 910 | (setq keyseq (vector event))) | 910 | (setq keyseq (vector event))) |
| 911 | keyseq)) | 911 | keyseq)) |
| 912 | 912 | ||
| 913 | 913 | ||
| 914 | 914 | ||
| 915 | ;; Listen to ESC key. | 915 | ;; Listen to ESC key. |
| 916 | ;; If a sequence of keys starting with ESC is issued with very short delays, | 916 | ;; If a sequence of keys starting with ESC is issued with very short delays, |
| @@ -918,9 +918,9 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 918 | (defun viper-intercept-ESC-key () | 918 | (defun viper-intercept-ESC-key () |
| 919 | "Function that implements ESC key in Viper emulation of Vi." | 919 | "Function that implements ESC key in Viper emulation of Vi." |
| 920 | (interactive) | 920 | (interactive) |
| 921 | (let ((cmd (or (key-binding (viper-envelop-ESC-key)) | 921 | (let ((cmd (or (key-binding (viper-envelop-ESC-key)) |
| 922 | '(lambda () (interactive) (error ""))))) | 922 | '(lambda () (interactive) (error ""))))) |
| 923 | 923 | ||
| 924 | ;; call the actual function to execute ESC (if no other symbols followed) | 924 | ;; call the actual function to execute ESC (if no other symbols followed) |
| 925 | ;; or the key bound to the ESC sequence (if the sequence was issued | 925 | ;; or the key bound to the ESC sequence (if the sequence was issued |
| 926 | ;; with very short delay between characters. | 926 | ;; with very short delay between characters. |
| @@ -929,14 +929,14 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 929 | (cond ((eq viper-current-state 'vi-state) | 929 | (cond ((eq viper-current-state 'vi-state) |
| 930 | 'viper-ESC) | 930 | 'viper-ESC) |
| 931 | ((eq viper-current-state 'insert-state) | 931 | ((eq viper-current-state 'insert-state) |
| 932 | 'viper-exit-insert-state) | 932 | 'viper-exit-insert-state) |
| 933 | ((eq viper-current-state 'replace-state) | 933 | ((eq viper-current-state 'replace-state) |
| 934 | 'viper-replace-state-exit-cmd) | 934 | 'viper-replace-state-exit-cmd) |
| 935 | (t 'viper-change-state-to-vi) | 935 | (t 'viper-change-state-to-vi) |
| 936 | ))) | 936 | ))) |
| 937 | (call-interactively cmd))) | 937 | (call-interactively cmd))) |
| 938 | 938 | ||
| 939 | 939 | ||
| 940 | 940 | ||
| 941 | 941 | ||
| 942 | ;; prefix argument for Vi mode | 942 | ;; prefix argument for Vi mode |
| @@ -976,7 +976,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 976 | (t com)))) | 976 | (t com)))) |
| 977 | 977 | ||
| 978 | 978 | ||
| 979 | ;; Compute numeric prefix arg value. | 979 | ;; Compute numeric prefix arg value. |
| 980 | ;; Invoked by EVENT. COM is the command part obtained so far. | 980 | ;; Invoked by EVENT. COM is the command part obtained so far. |
| 981 | (defun viper-prefix-arg-value (event-char com) | 981 | (defun viper-prefix-arg-value (event-char com) |
| 982 | (let ((viper-intermediate-command 'viper-digit-argument) | 982 | (let ((viper-intermediate-command 'viper-digit-argument) |
| @@ -986,13 +986,13 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 986 | (>= event-char ?0) (<= event-char ?9)) | 986 | (>= event-char ?0) (<= event-char ?9)) |
| 987 | (setq value (+ (* (if (integerp value) value 0) 10) (- event-char ?0))) | 987 | (setq value (+ (* (if (integerp value) value 0) 10) (- event-char ?0))) |
| 988 | (setq event-char (viper-read-event-convert-to-char))) | 988 | (setq event-char (viper-read-event-convert-to-char))) |
| 989 | 989 | ||
| 990 | (setq prefix-arg value) | 990 | (setq prefix-arg value) |
| 991 | (if com (setq prefix-arg (cons prefix-arg com))) | 991 | (if com (setq prefix-arg (cons prefix-arg com))) |
| 992 | (while (eq event-char ?U) | 992 | (while (eq event-char ?U) |
| 993 | (viper-describe-arg prefix-arg) | 993 | (viper-describe-arg prefix-arg) |
| 994 | (setq event-char (viper-read-event-convert-to-char))) | 994 | (setq event-char (viper-read-event-convert-to-char))) |
| 995 | 995 | ||
| 996 | (if (or com (and (not (eq viper-current-state 'vi-state)) | 996 | (if (or com (and (not (eq viper-current-state 'vi-state)) |
| 997 | ;; make sure it is a Vi command | 997 | ;; make sure it is a Vi command |
| 998 | (viper-characterp event-char) | 998 | (viper-characterp event-char) |
| @@ -1017,19 +1017,19 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1017 | ((eq event-char 'backspace) (setq event-char ?\C-h)) | 1017 | ((eq event-char 'backspace) (setq event-char ?\C-h)) |
| 1018 | ((eq event-char 'space) (setq event-char ?\ ))) | 1018 | ((eq event-char 'space) (setq event-char ?\ ))) |
| 1019 | (setq last-command-char (or com event-char)) | 1019 | (setq last-command-char (or com event-char)) |
| 1020 | (setq func (viper-exec-form-in-vi | 1020 | (setq func (viper-exec-form-in-vi |
| 1021 | (` (key-binding (char-to-string (, event-char)))))) | 1021 | `(key-binding (char-to-string ,event-char)))) |
| 1022 | (funcall func prefix-arg) | 1022 | (funcall func prefix-arg) |
| 1023 | (setq prefix-arg nil)) | 1023 | (setq prefix-arg nil)) |
| 1024 | ;; some other command -- let emacs do it in its own way | 1024 | ;; some other command -- let emacs do it in its own way |
| 1025 | (viper-set-unread-command-events event-char)) | 1025 | (viper-set-unread-command-events event-char)) |
| 1026 | )) | 1026 | )) |
| 1027 | 1027 | ||
| 1028 | 1028 | ||
| 1029 | ;; Vi operator as prefix argument." | 1029 | ;; Vi operator as prefix argument." |
| 1030 | (defun viper-prefix-arg-com (char value com) | 1030 | (defun viper-prefix-arg-com (char value com) |
| 1031 | (let ((cont t) | 1031 | (let ((cont t) |
| 1032 | cmd-info | 1032 | cmd-info |
| 1033 | cmd-to-exec-at-end) | 1033 | cmd-to-exec-at-end) |
| 1034 | (while (and cont | 1034 | (while (and cont |
| 1035 | (memq char | 1035 | (memq char |
| @@ -1044,86 +1044,86 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1044 | (if (memq char '(?# ?\")) (error "")) | 1044 | (if (memq char '(?# ?\")) (error "")) |
| 1045 | (setq com (cons char com)) | 1045 | (setq com (cons char com)) |
| 1046 | (setq cont nil)) | 1046 | (setq cont nil)) |
| 1047 | ;; If com is nil we set com as char, and read more. Again, if char is | 1047 | ;; If com is nil we set com as char, and read more. Again, if char is |
| 1048 | ;; ", we read the name of register and store it in viper-use-register. | 1048 | ;; ", we read the name of register and store it in viper-use-register. |
| 1049 | ;; if char is !, =, or #, a complete com is formed so we exit the while | 1049 | ;; if char is !, =, or #, a complete com is formed so we exit the while |
| 1050 | ;; loop. | 1050 | ;; loop. |
| 1051 | (cond ((memq char '(?! ?=)) | 1051 | (cond ((memq char '(?! ?=)) |
| 1052 | (setq com char) | 1052 | (setq com char) |
| 1053 | (setq char (read-char)) | 1053 | (setq char (read-char)) |
| 1054 | (setq cont nil)) | 1054 | (setq cont nil)) |
| 1055 | ((= char ?#) | 1055 | ((= char ?#) |
| 1056 | ;; read a char and encode it as com | 1056 | ;; read a char and encode it as com |
| 1057 | (setq com (+ 128 (read-char))) | 1057 | (setq com (+ 128 (read-char))) |
| 1058 | (setq char (read-char))) | 1058 | (setq char (read-char))) |
| 1059 | ((= char ?\") | 1059 | ((= char ?\") |
| 1060 | (let ((reg (read-char))) | 1060 | (let ((reg (read-char))) |
| 1061 | (if (viper-valid-register reg) | 1061 | (if (viper-valid-register reg) |
| 1062 | (setq viper-use-register reg) | 1062 | (setq viper-use-register reg) |
| 1063 | (error "")) | 1063 | (error "")) |
| 1064 | (setq char (read-char)))) | 1064 | (setq char (read-char)))) |
| 1065 | (t | 1065 | (t |
| 1066 | (setq com char) | 1066 | (setq com char) |
| 1067 | (setq char (read-char)))))) | 1067 | (setq char (read-char)))))) |
| 1068 | 1068 | ||
| 1069 | (if (atom com) | 1069 | (if (atom com) |
| 1070 | ;; `com' is a single char, so we construct the command argument | 1070 | ;; `com' is a single char, so we construct the command argument |
| 1071 | ;; and if `char' is `?', we describe the arg; otherwise | 1071 | ;; and if `char' is `?', we describe the arg; otherwise |
| 1072 | ;; we prepare the command that will be executed at the end. | 1072 | ;; we prepare the command that will be executed at the end. |
| 1073 | (progn | 1073 | (progn |
| 1074 | (setq cmd-info (cons value com)) | 1074 | (setq cmd-info (cons value com)) |
| 1075 | (while (= char ?U) | 1075 | (while (= char ?U) |
| 1076 | (viper-describe-arg cmd-info) | 1076 | (viper-describe-arg cmd-info) |
| 1077 | (setq char (read-char))) | 1077 | (setq char (read-char))) |
| 1078 | ;; `char' is a movement cmd, a digit arg cmd, or a register cmd---so we | 1078 | ;; `char' is a movement cmd, a digit arg cmd, or a register cmd---so we |
| 1079 | ;; execute it at the very end | 1079 | ;; execute it at the very end |
| 1080 | (or (viper-movement-command-p char) | 1080 | (or (viper-movement-command-p char) |
| 1081 | (viper-digit-command-p char) | 1081 | (viper-digit-command-p char) |
| 1082 | (viper-regsuffix-command-p char) | 1082 | (viper-regsuffix-command-p char) |
| 1083 | (= char ?!) ; bang command | 1083 | (= char ?!) ; bang command |
| 1084 | (error "")) | 1084 | (error "")) |
| 1085 | (setq cmd-to-exec-at-end | 1085 | (setq cmd-to-exec-at-end |
| 1086 | (viper-exec-form-in-vi | 1086 | (viper-exec-form-in-vi |
| 1087 | (` (key-binding (char-to-string (, char))))))) | 1087 | `(key-binding (char-to-string ,char))))) |
| 1088 | 1088 | ||
| 1089 | ;; as com is non-nil, this means that we have a command to execute | 1089 | ;; as com is non-nil, this means that we have a command to execute |
| 1090 | (if (memq (car com) '(?r ?R)) | 1090 | (if (memq (car com) '(?r ?R)) |
| 1091 | ;; execute apropriate region command. | 1091 | ;; execute apropriate region command. |
| 1092 | (let ((char (car com)) (com (cdr com))) | 1092 | (let ((char (car com)) (com (cdr com))) |
| 1093 | (setq prefix-arg (cons value com)) | 1093 | (setq prefix-arg (cons value com)) |
| 1094 | (if (= char ?r) (viper-region prefix-arg) | 1094 | (if (= char ?r) (viper-region prefix-arg) |
| 1095 | (viper-Region prefix-arg)) | 1095 | (viper-Region prefix-arg)) |
| 1096 | ;; reset prefix-arg | 1096 | ;; reset prefix-arg |
| 1097 | (setq prefix-arg nil)) | 1097 | (setq prefix-arg nil)) |
| 1098 | ;; otherwise, reset prefix arg and call appropriate command | 1098 | ;; otherwise, reset prefix arg and call appropriate command |
| 1099 | (setq value (if (null value) 1 value)) | 1099 | (setq value (if (null value) 1 value)) |
| 1100 | (setq prefix-arg nil) | 1100 | (setq prefix-arg nil) |
| 1101 | (cond | 1101 | (cond |
| 1102 | ;; If we change ?C to ?c here, then cc will enter replacement mode | 1102 | ;; If we change ?C to ?c here, then cc will enter replacement mode |
| 1103 | ;; rather than deleting lines. However, it will affect 1 less line than | 1103 | ;; rather than deleting lines. However, it will affect 1 less line than |
| 1104 | ;; normal. We decided to not use replacement mode here and follow Vi, | 1104 | ;; normal. We decided to not use replacement mode here and follow Vi, |
| 1105 | ;; since replacement mode on n full lines can be achieved with nC. | 1105 | ;; since replacement mode on n full lines can be achieved with nC. |
| 1106 | ((equal com '(?c . ?c)) (viper-line (cons value ?C))) | 1106 | ((equal com '(?c . ?c)) (viper-line (cons value ?C))) |
| 1107 | ((equal com '(?d . ?d)) (viper-line (cons value ?D))) | 1107 | ((equal com '(?d . ?d)) (viper-line (cons value ?D))) |
| 1108 | ((equal com '(?d . ?y)) (viper-yank-defun)) | 1108 | ((equal com '(?d . ?y)) (viper-yank-defun)) |
| 1109 | ((equal com '(?y . ?y)) (viper-line (cons value ?Y))) | 1109 | ((equal com '(?y . ?y)) (viper-line (cons value ?Y))) |
| 1110 | ((equal com '(?< . ?<)) (viper-line (cons value ?<))) | 1110 | ((equal com '(?< . ?<)) (viper-line (cons value ?<))) |
| 1111 | ((equal com '(?> . ?>)) (viper-line (cons value ?>))) | 1111 | ((equal com '(?> . ?>)) (viper-line (cons value ?>))) |
| 1112 | ((equal com '(?! . ?!)) (viper-line (cons value ?!))) | 1112 | ((equal com '(?! . ?!)) (viper-line (cons value ?!))) |
| 1113 | ((equal com '(?= . ?=)) (viper-line (cons value ?=))) | 1113 | ((equal com '(?= . ?=)) (viper-line (cons value ?=))) |
| 1114 | (t (error ""))))) | 1114 | (t (error ""))))) |
| 1115 | 1115 | ||
| 1116 | (if cmd-to-exec-at-end | 1116 | (if cmd-to-exec-at-end |
| 1117 | (progn | 1117 | (progn |
| 1118 | (setq last-command-char char) | 1118 | (setq last-command-char char) |
| 1119 | (setq last-command-event | 1119 | (setq last-command-event |
| 1120 | (viper-copy-event | 1120 | (viper-copy-event |
| 1121 | (if viper-xemacs-p (character-to-event char) char))) | 1121 | (if viper-xemacs-p (character-to-event char) char))) |
| 1122 | (condition-case nil | 1122 | (condition-case nil |
| 1123 | (funcall cmd-to-exec-at-end cmd-info) | 1123 | (funcall cmd-to-exec-at-end cmd-info) |
| 1124 | (error | 1124 | (error |
| 1125 | (error ""))))) | 1125 | (error ""))))) |
| 1126 | )) | 1126 | )) |
| 1127 | 1127 | ||
| 1128 | (defun viper-describe-arg (arg) | 1128 | (defun viper-describe-arg (arg) |
| 1129 | (let (val com) | 1129 | (let (val com) |
| @@ -1150,7 +1150,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1150 | (let ((viper-intermediate-command 'viper-command-argument)) | 1150 | (let ((viper-intermediate-command 'viper-command-argument)) |
| 1151 | (condition-case nil | 1151 | (condition-case nil |
| 1152 | (viper-prefix-arg-com | 1152 | (viper-prefix-arg-com |
| 1153 | last-command-char | 1153 | last-command-char |
| 1154 | (cond ((null arg) nil) | 1154 | (cond ((null arg) nil) |
| 1155 | ((consp arg) (car arg)) | 1155 | ((consp arg) (car arg)) |
| 1156 | ((integerp arg) arg) | 1156 | ((integerp arg) arg) |
| @@ -1191,18 +1191,18 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1191 | ;; del most recent elt, if identical to the second most-recent | 1191 | ;; del most recent elt, if identical to the second most-recent |
| 1192 | (viper-cleanup-ring viper-command-ring))) | 1192 | (viper-cleanup-ring viper-command-ring))) |
| 1193 | ) | 1193 | ) |
| 1194 | 1194 | ||
| 1195 | (defsubst viper-yank-last-insertion () | 1195 | (defsubst viper-yank-last-insertion () |
| 1196 | "Inserts the text saved by the previous viper-save-last-insertion command." | 1196 | "Inserts the text saved by the previous viper-save-last-insertion command." |
| 1197 | (condition-case nil | 1197 | (condition-case nil |
| 1198 | (insert viper-last-insertion) | 1198 | (insert viper-last-insertion) |
| 1199 | (error nil))) | 1199 | (error nil))) |
| 1200 | 1200 | ||
| 1201 | 1201 | ||
| 1202 | ;; define functions to be executed | 1202 | ;; define functions to be executed |
| 1203 | 1203 | ||
| 1204 | ;; invoked by the `C' command | 1204 | ;; invoked by the `C' command |
| 1205 | (defun viper-exec-change (m-com com) | 1205 | (defun viper-exec-change (m-com com) |
| 1206 | (or (and (markerp viper-com-point) (marker-position viper-com-point)) | 1206 | (or (and (markerp viper-com-point) (marker-position viper-com-point)) |
| 1207 | (set-marker viper-com-point (point) (current-buffer))) | 1207 | (set-marker viper-com-point (point) (current-buffer))) |
| 1208 | ;; handle C cmd at the eol and at eob. | 1208 | ;; handle C cmd at the eol and at eob. |
| @@ -1352,7 +1352,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1352 | (mark t) (point) | 1352 | (mark t) (point) |
| 1353 | (if (= com ?!) | 1353 | (if (= com ?!) |
| 1354 | (setq viper-last-shell-com | 1354 | (setq viper-last-shell-com |
| 1355 | (viper-read-string-with-history | 1355 | (viper-read-string-with-history |
| 1356 | "!" | 1356 | "!" |
| 1357 | nil | 1357 | nil |
| 1358 | 'viper-shell-history | 1358 | 'viper-shell-history |
| @@ -1373,7 +1373,7 @@ as a Meta key and any number of multiple escapes is allowed." | |||
| 1373 | (set-mark viper-com-point) | 1373 | (set-mark viper-com-point) |
| 1374 | (viper-enlarge-region (mark t) (point)) | 1374 | (viper-enlarge-region (mark t) (point)) |
| 1375 | (if (> (mark t) (point)) (exchange-point-and-mark)) | 1375 | (if (> (mark t) (point)) (exchange-point-and-mark)) |
| 1376 | (indent-rigidly (mark t) (point) | 1376 | (indent-rigidly (mark t) (point) |
| 1377 | (if (= com ?>) | 1377 | (if (= com ?>) |
| 1378 | viper-shift-width | 1378 | viper-shift-width |
| 1379 | (- viper-shift-width)))) | 1379 | (- viper-shift-width)))) |
| @@ -1485,7 +1485,7 @@ If the prefix argument, ARG, is non-nil, it is used instead of `val'." | |||
| 1485 | (viper-push-onto-ring viper-d-com 'viper-command-ring)) | 1485 | (viper-push-onto-ring viper-d-com 'viper-command-ring)) |
| 1486 | (viper-deactivate-mark) | 1486 | (viper-deactivate-mark) |
| 1487 | )) | 1487 | )) |
| 1488 | 1488 | ||
| 1489 | (defun viper-repeat-from-history () | 1489 | (defun viper-repeat-from-history () |
| 1490 | "Repeat a destructive command from history. | 1490 | "Repeat a destructive command from history. |
| 1491 | Doesn't change viper-command-ring in any way, so `.' will work as before | 1491 | Doesn't change viper-command-ring in any way, so `.' will work as before |
| @@ -1517,7 +1517,7 @@ invokes the command before that, etc." | |||
| 1517 | (viper-special-ring-rotate1 viper-command-ring 1) | 1517 | (viper-special-ring-rotate1 viper-command-ring 1) |
| 1518 | (setq num (1+ num))) | 1518 | (setq num (1+ num))) |
| 1519 | )) | 1519 | )) |
| 1520 | 1520 | ||
| 1521 | 1521 | ||
| 1522 | ;; The hash-command. It is invoked interactively by the key sequence #<char>. | 1522 | ;; The hash-command. It is invoked interactively by the key sequence #<char>. |
| 1523 | ;; The chars that can follow `#' are determined by viper-hash-command-p | 1523 | ;; The chars that can follow `#' are determined by viper-hash-command-p |
| @@ -1548,24 +1548,24 @@ invokes the command before that, etc." | |||
| 1548 | (before-undo-pt (point-marker)) | 1548 | (before-undo-pt (point-marker)) |
| 1549 | (after-change-functions after-change-functions) | 1549 | (after-change-functions after-change-functions) |
| 1550 | undo-beg-posn undo-end-posn) | 1550 | undo-beg-posn undo-end-posn) |
| 1551 | 1551 | ||
| 1552 | ;; no need to remove this hook, since this var has scope inside a let. | 1552 | ;; no need to remove this hook, since this var has scope inside a let. |
| 1553 | (add-hook 'after-change-functions | 1553 | (add-hook 'after-change-functions |
| 1554 | '(lambda (beg end len) | 1554 | '(lambda (beg end len) |
| 1555 | (setq undo-beg-posn beg | 1555 | (setq undo-beg-posn beg |
| 1556 | undo-end-posn (or end beg)))) | 1556 | undo-end-posn (or end beg)))) |
| 1557 | 1557 | ||
| 1558 | (undo-start) | 1558 | (undo-start) |
| 1559 | (undo-more 2) | 1559 | (undo-more 2) |
| 1560 | (setq undo-beg-posn (or undo-beg-posn before-undo-pt) | 1560 | (setq undo-beg-posn (or undo-beg-posn before-undo-pt) |
| 1561 | undo-end-posn (or undo-end-posn undo-beg-posn)) | 1561 | undo-end-posn (or undo-end-posn undo-beg-posn)) |
| 1562 | 1562 | ||
| 1563 | (goto-char undo-beg-posn) | 1563 | (goto-char undo-beg-posn) |
| 1564 | (sit-for 0) | 1564 | (sit-for 0) |
| 1565 | (if (and viper-keep-point-on-undo | 1565 | (if (and viper-keep-point-on-undo |
| 1566 | (pos-visible-in-window-p before-undo-pt)) | 1566 | (pos-visible-in-window-p before-undo-pt)) |
| 1567 | (progn | 1567 | (progn |
| 1568 | (push-mark (point-marker) t) | 1568 | (push-mark (point-marker) t) |
| 1569 | (viper-sit-for-short 300) | 1569 | (viper-sit-for-short 300) |
| 1570 | (goto-char undo-end-posn) | 1570 | (goto-char undo-end-posn) |
| 1571 | (viper-sit-for-short 300) | 1571 | (viper-sit-for-short 300) |
| @@ -1590,7 +1590,7 @@ invokes the command before that, etc." | |||
| 1590 | 1590 | ||
| 1591 | ;; The following two functions are used to set up undo properly. | 1591 | ;; The following two functions are used to set up undo properly. |
| 1592 | ;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines, | 1592 | ;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines, |
| 1593 | ;; they are undone all at once. | 1593 | ;; they are undone all at once. |
| 1594 | (defun viper-adjust-undo () | 1594 | (defun viper-adjust-undo () |
| 1595 | (if viper-undo-needs-adjustment | 1595 | (if viper-undo-needs-adjustment |
| 1596 | (let ((inhibit-quit t) | 1596 | (let ((inhibit-quit t) |
| @@ -1600,11 +1600,11 @@ invokes the command before that, etc." | |||
| 1600 | (if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list)) | 1600 | (if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list)) |
| 1601 | (progn | 1601 | (progn |
| 1602 | (setq tmp2 (cdr tmp)) ; the part after mark | 1602 | (setq tmp2 (cdr tmp)) ; the part after mark |
| 1603 | 1603 | ||
| 1604 | ;; cut tail from buffer-undo-list temporarily by direct | 1604 | ;; cut tail from buffer-undo-list temporarily by direct |
| 1605 | ;; manipulation with pointers in buffer-undo-list | 1605 | ;; manipulation with pointers in buffer-undo-list |
| 1606 | (setcdr tmp nil) | 1606 | (setcdr tmp nil) |
| 1607 | 1607 | ||
| 1608 | (setq buffer-undo-list (delq nil buffer-undo-list)) | 1608 | (setq buffer-undo-list (delq nil buffer-undo-list)) |
| 1609 | (setq buffer-undo-list | 1609 | (setq buffer-undo-list |
| 1610 | (delq viper-buffer-undo-list-mark buffer-undo-list)) | 1610 | (delq viper-buffer-undo-list-mark buffer-undo-list)) |
| @@ -1612,31 +1612,31 @@ invokes the command before that, etc." | |||
| 1612 | (setq buffer-undo-list (nconc buffer-undo-list tmp2))) | 1612 | (setq buffer-undo-list (nconc buffer-undo-list tmp2))) |
| 1613 | (setq buffer-undo-list (delq nil buffer-undo-list))))) | 1613 | (setq buffer-undo-list (delq nil buffer-undo-list))))) |
| 1614 | )) | 1614 | )) |
| 1615 | |||
| 1616 | 1615 | ||
| 1617 | (defun viper-set-complex-command-for-undo () | 1616 | |
| 1617 | (defun viper-set-complex-command-for-undo () | ||
| 1618 | (if (listp buffer-undo-list) | 1618 | (if (listp buffer-undo-list) |
| 1619 | (if (not viper-undo-needs-adjustment) | 1619 | (if (not viper-undo-needs-adjustment) |
| 1620 | (let ((inhibit-quit t)) | 1620 | (let ((inhibit-quit t)) |
| 1621 | (setq buffer-undo-list | 1621 | (setq buffer-undo-list |
| 1622 | (cons viper-buffer-undo-list-mark buffer-undo-list)) | 1622 | (cons viper-buffer-undo-list-mark buffer-undo-list)) |
| 1623 | (setq viper-undo-needs-adjustment t))))) | 1623 | (setq viper-undo-needs-adjustment t))))) |
| 1624 | 1624 | ||
| 1625 | 1625 | ||
| 1626 | 1626 | ||
| 1627 | 1627 | ||
| 1628 | (defun viper-display-current-destructive-command () | 1628 | (defun viper-display-current-destructive-command () |
| 1629 | (let ((text (nth 4 viper-d-com)) | 1629 | (let ((text (nth 4 viper-d-com)) |
| 1630 | (keys (nth 5 viper-d-com)) | 1630 | (keys (nth 5 viper-d-com)) |
| 1631 | (max-text-len 30)) | 1631 | (max-text-len 30)) |
| 1632 | 1632 | ||
| 1633 | (setq this-command 'viper-display-current-destructive-command) | 1633 | (setq this-command 'viper-display-current-destructive-command) |
| 1634 | 1634 | ||
| 1635 | (message " `.' runs %s%s" | 1635 | (message " `.' runs %s%s" |
| 1636 | (concat "`" (viper-array-to-string keys) "'") | 1636 | (concat "`" (viper-array-to-string keys) "'") |
| 1637 | (viper-abbreviate-string | 1637 | (viper-abbreviate-string |
| 1638 | (if viper-xemacs-p | 1638 | (if viper-xemacs-p |
| 1639 | (replace-in-string | 1639 | (replace-in-string |
| 1640 | (cond ((characterp text) (char-to-string text)) | 1640 | (cond ((characterp text) (char-to-string text)) |
| 1641 | ((stringp text) text) | 1641 | ((stringp text) text) |
| 1642 | (t "")) | 1642 | (t "")) |
| @@ -1645,8 +1645,8 @@ invokes the command before that, etc." | |||
| 1645 | max-text-len | 1645 | max-text-len |
| 1646 | " inserting `" "'" " .......")) | 1646 | " inserting `" "'" " .......")) |
| 1647 | )) | 1647 | )) |
| 1648 | 1648 | ||
| 1649 | 1649 | ||
| 1650 | ;; don't change viper-d-com if it was viper-repeat command invoked with `.' | 1650 | ;; don't change viper-d-com if it was viper-repeat command invoked with `.' |
| 1651 | ;; or in some other way (non-interactively). | 1651 | ;; or in some other way (non-interactively). |
| 1652 | (defun viper-set-destructive-command (list) | 1652 | (defun viper-set-destructive-command (list) |
| @@ -1659,7 +1659,7 @@ invokes the command before that, etc." | |||
| 1659 | (this-command-keys)))) | 1659 | (this-command-keys)))) |
| 1660 | (viper-push-onto-ring viper-d-com 'viper-command-ring))) | 1660 | (viper-push-onto-ring viper-d-com 'viper-command-ring))) |
| 1661 | (setq viper-this-command-keys nil)) | 1661 | (setq viper-this-command-keys nil)) |
| 1662 | 1662 | ||
| 1663 | (defun viper-prev-destructive-command (next) | 1663 | (defun viper-prev-destructive-command (next) |
| 1664 | "Find previous destructive command in the history of destructive commands. | 1664 | "Find previous destructive command in the history of destructive commands. |
| 1665 | With prefix argument, find next destructive command." | 1665 | With prefix argument, find next destructive command." |
| @@ -1670,7 +1670,7 @@ With prefix argument, find next destructive command." | |||
| 1670 | (setq viper-intermediate-command | 1670 | (setq viper-intermediate-command |
| 1671 | 'repeating-display-destructive-command) | 1671 | 'repeating-display-destructive-command) |
| 1672 | ;; first search through command history--set temp ring | 1672 | ;; first search through command history--set temp ring |
| 1673 | (setq viper-temp-command-ring (copy-list viper-command-ring))) | 1673 | (setq viper-temp-command-ring (copy-list viper-command-ring))) |
| 1674 | (setq cmd (if next | 1674 | (setq cmd (if next |
| 1675 | (viper-special-ring-rotate1 viper-temp-command-ring 1) | 1675 | (viper-special-ring-rotate1 viper-temp-command-ring 1) |
| 1676 | (viper-special-ring-rotate1 viper-temp-command-ring -1))) | 1676 | (viper-special-ring-rotate1 viper-temp-command-ring -1))) |
| @@ -1678,12 +1678,12 @@ With prefix argument, find next destructive command." | |||
| 1678 | () | 1678 | () |
| 1679 | (setq viper-d-com cmd)) | 1679 | (setq viper-d-com cmd)) |
| 1680 | (viper-display-current-destructive-command))) | 1680 | (viper-display-current-destructive-command))) |
| 1681 | 1681 | ||
| 1682 | (defun viper-next-destructive-command () | 1682 | (defun viper-next-destructive-command () |
| 1683 | "Find next destructive command in the history of destructive commands." | 1683 | "Find next destructive command in the history of destructive commands." |
| 1684 | (interactive) | 1684 | (interactive) |
| 1685 | (viper-prev-destructive-command 'next)) | 1685 | (viper-prev-destructive-command 'next)) |
| 1686 | 1686 | ||
| 1687 | (defun viper-insert-prev-from-insertion-ring (arg) | 1687 | (defun viper-insert-prev-from-insertion-ring (arg) |
| 1688 | "Cycle through insertion ring in the direction of older insertions. | 1688 | "Cycle through insertion ring in the direction of older insertions. |
| 1689 | Undoes previous insertion and inserts new. | 1689 | Undoes previous insertion and inserts new. |
| @@ -1708,7 +1708,7 @@ to in the global map, instead of cycling through the insertion ring." | |||
| 1708 | (setq buffer-undo-list (cons nil buffer-undo-list)) | 1708 | (setq buffer-undo-list (cons nil buffer-undo-list)) |
| 1709 | (setq viper-last-inserted-string-from-insertion-ring | 1709 | (setq viper-last-inserted-string-from-insertion-ring |
| 1710 | (viper-special-ring-rotate1 viper-temp-insertion-ring (if arg 1 -1))) | 1710 | (viper-special-ring-rotate1 viper-temp-insertion-ring (if arg 1 -1))) |
| 1711 | 1711 | ||
| 1712 | ;; this change of viper-intermediate-command must come after | 1712 | ;; this change of viper-intermediate-command must come after |
| 1713 | ;; viper-special-ring-rotate1, so that the ring will rotate, but before the | 1713 | ;; viper-special-ring-rotate1, so that the ring will rotate, but before the |
| 1714 | ;; insertion. | 1714 | ;; insertion. |
| @@ -1722,7 +1722,7 @@ to in the global map, instead of cycling through the insertion ring." | |||
| 1722 | Undo previous insertion and inserts new." | 1722 | Undo previous insertion and inserts new." |
| 1723 | (interactive) | 1723 | (interactive) |
| 1724 | (viper-insert-prev-from-insertion-ring 'next)) | 1724 | (viper-insert-prev-from-insertion-ring 'next)) |
| 1725 | 1725 | ||
| 1726 | 1726 | ||
| 1727 | ;; some region utilities | 1727 | ;; some region utilities |
| 1728 | 1728 | ||
| @@ -1747,7 +1747,7 @@ Undo previous insertion and inserts new." | |||
| 1747 | (defun viper-enlarge-region (beg end) | 1747 | (defun viper-enlarge-region (beg end) |
| 1748 | (or beg (setq beg end)) ; if beg is nil, set to end | 1748 | (or beg (setq beg end)) ; if beg is nil, set to end |
| 1749 | (or end (setq end beg)) ; if end is nil, set to beg | 1749 | (or end (setq end beg)) ; if end is nil, set to beg |
| 1750 | 1750 | ||
| 1751 | (if (< beg end) | 1751 | (if (< beg end) |
| 1752 | (progn (goto-char beg) (set-mark end)) | 1752 | (progn (goto-char beg) (set-mark end)) |
| 1753 | (goto-char end) | 1753 | (goto-char end) |
| @@ -1808,8 +1808,8 @@ Undo previous insertion and inserts new." | |||
| 1808 | (setq incr 1)) | 1808 | (setq incr 1)) |
| 1809 | (<= (+ incr (count-lines beg end)) 1)))) | 1809 | (<= (+ incr (count-lines beg end)) 1)))) |
| 1810 | )) | 1810 | )) |
| 1811 | 1811 | ||
| 1812 | 1812 | ||
| 1813 | ;; Check if the string ends with a newline. | 1813 | ;; Check if the string ends with a newline. |
| 1814 | (defun viper-end-with-a-newline-p (string) | 1814 | (defun viper-end-with-a-newline-p (string) |
| 1815 | (or (string= string "") | 1815 | (or (string= string "") |
| @@ -1821,23 +1821,23 @@ Undo previous insertion and inserts new." | |||
| 1821 | (insert msg) | 1821 | (insert msg) |
| 1822 | (sit-for 2) | 1822 | (sit-for 2) |
| 1823 | (goto-char savemax) (delete-region (point) (point-max)) | 1823 | (goto-char savemax) (delete-region (point) (point-max)) |
| 1824 | )) | 1824 | )) |
| 1825 | 1825 | ||
| 1826 | 1826 | ||
| 1827 | 1827 | ||
| 1828 | ;;; Minibuffer business | 1828 | ;;; Minibuffer business |
| 1829 | 1829 | ||
| 1830 | (defsubst viper-set-minibuffer-style () | 1830 | (defsubst viper-set-minibuffer-style () |
| 1831 | (add-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)) | 1831 | (add-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)) |
| 1832 | 1832 | ||
| 1833 | 1833 | ||
| 1834 | (defun viper-minibuffer-setup-sentinel () | 1834 | (defun viper-minibuffer-setup-sentinel () |
| 1835 | (let ((hook (if viper-vi-style-in-minibuffer | 1835 | (let ((hook (if viper-vi-style-in-minibuffer |
| 1836 | 'viper-change-state-to-insert | 1836 | 'viper-change-state-to-insert |
| 1837 | 'viper-change-state-to-emacs))) | 1837 | 'viper-change-state-to-emacs))) |
| 1838 | (funcall hook) | 1838 | (funcall hook) |
| 1839 | )) | 1839 | )) |
| 1840 | 1840 | ||
| 1841 | ;; Interpret last event in the local map first; if fails, use exit-minibuffer. | 1841 | ;; Interpret last event in the local map first; if fails, use exit-minibuffer. |
| 1842 | ;; Run viper-minibuffer-exit-hook before exiting. | 1842 | ;; Run viper-minibuffer-exit-hook before exiting. |
| 1843 | (defun viper-exit-minibuffer () | 1843 | (defun viper-exit-minibuffer () |
| @@ -1849,7 +1849,7 @@ Undo previous insertion and inserts new." | |||
| 1849 | (if command | 1849 | (if command |
| 1850 | (command-execute command) | 1850 | (command-execute command) |
| 1851 | (exit-minibuffer)))) | 1851 | (exit-minibuffer)))) |
| 1852 | 1852 | ||
| 1853 | 1853 | ||
| 1854 | (defcustom viper-smart-suffix-list | 1854 | (defcustom viper-smart-suffix-list |
| 1855 | '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "flr" "P" "p") | 1855 | '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "flr" "P" "p") |
| @@ -1867,7 +1867,7 @@ suffixes, the user is asked to confirm. | |||
| 1867 | To turn this feature off, set this variable to nil." | 1867 | To turn this feature off, set this variable to nil." |
| 1868 | :type '(repeat string) | 1868 | :type '(repeat string) |
| 1869 | :group 'viper-misc) | 1869 | :group 'viper-misc) |
| 1870 | 1870 | ||
| 1871 | 1871 | ||
| 1872 | ;; Try to add a suitable suffix to files whose name ends with a `.' | 1872 | ;; Try to add a suitable suffix to files whose name ends with a `.' |
| 1873 | ;; Useful when the user hits RET on a non-completed file name. | 1873 | ;; Useful when the user hits RET on a non-completed file name. |
| @@ -1888,11 +1888,11 @@ To turn this feature off, set this variable to nil." | |||
| 1888 | (progn | 1888 | (progn |
| 1889 | (setq found t) | 1889 | (setq found t) |
| 1890 | (insert suff)))) | 1890 | (insert suff)))) |
| 1891 | 1891 | ||
| 1892 | (if found | 1892 | (if found |
| 1893 | () | 1893 | () |
| 1894 | (viper-tmp-insert-at-eob " [Please complete file name]") | 1894 | (viper-tmp-insert-at-eob " [Please complete file name]") |
| 1895 | (unwind-protect | 1895 | (unwind-protect |
| 1896 | (while (not (memq cmd | 1896 | (while (not (memq cmd |
| 1897 | '(exit-minibuffer viper-exit-minibuffer))) | 1897 | '(exit-minibuffer viper-exit-minibuffer))) |
| 1898 | (setq cmd | 1898 | (setq cmd |
| @@ -1919,20 +1919,20 @@ problems." | |||
| 1919 | (delete-region (point) (point-max))))) | 1919 | (delete-region (point) (point-max))))) |
| 1920 | 1920 | ||
| 1921 | 1921 | ||
| 1922 | ;;; Reading string with history | 1922 | ;;; Reading string with history |
| 1923 | 1923 | ||
| 1924 | (defun viper-read-string-with-history (prompt &optional initial | 1924 | (defun viper-read-string-with-history (prompt &optional initial |
| 1925 | history-var default keymap | 1925 | history-var default keymap |
| 1926 | init-message) | 1926 | init-message) |
| 1927 | ;; Read string, prompting with PROMPT and inserting the INITIAL | 1927 | ;; Read string, prompting with PROMPT and inserting the INITIAL |
| 1928 | ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the | 1928 | ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the |
| 1929 | ;; input is an empty string. | 1929 | ;; input is an empty string. |
| 1930 | ;; Default value is displayed until the user types something in the | 1930 | ;; Default value is displayed until the user types something in the |
| 1931 | ;; minibuffer. | 1931 | ;; minibuffer. |
| 1932 | ;; KEYMAP is used, if given, instead of minibuffer-local-map. | 1932 | ;; KEYMAP is used, if given, instead of minibuffer-local-map. |
| 1933 | ;; INIT-MESSAGE is the message temporarily displayed after entering the | 1933 | ;; INIT-MESSAGE is the message temporarily displayed after entering the |
| 1934 | ;; minibuffer. | 1934 | ;; minibuffer. |
| 1935 | (let ((minibuffer-setup-hook | 1935 | (let ((minibuffer-setup-hook |
| 1936 | (lambda () | 1936 | (lambda () |
| 1937 | (if (stringp init-message) | 1937 | (if (stringp init-message) |
| 1938 | (viper-tmp-insert-at-eob init-message)) | 1938 | (viper-tmp-insert-at-eob init-message)) |
| @@ -1948,15 +1948,15 @@ problems." | |||
| 1948 | (val "") | 1948 | (val "") |
| 1949 | (padding "") | 1949 | (padding "") |
| 1950 | temp-msg) | 1950 | temp-msg) |
| 1951 | 1951 | ||
| 1952 | (setq keymap (or keymap minibuffer-local-map) | 1952 | (setq keymap (or keymap minibuffer-local-map) |
| 1953 | initial (or initial "") | 1953 | initial (or initial "") |
| 1954 | temp-msg (if default | 1954 | temp-msg (if default |
| 1955 | (format "(default: %s) " default) | 1955 | (format "(default: %s) " default) |
| 1956 | "")) | 1956 | "")) |
| 1957 | 1957 | ||
| 1958 | (setq viper-incomplete-ex-cmd nil) | 1958 | (setq viper-incomplete-ex-cmd nil) |
| 1959 | (setq val (read-from-minibuffer prompt | 1959 | (setq val (read-from-minibuffer prompt |
| 1960 | (concat temp-msg initial val padding) | 1960 | (concat temp-msg initial val padding) |
| 1961 | keymap nil history-var)) | 1961 | keymap nil history-var)) |
| 1962 | (setq minibuffer-setup-hook nil | 1962 | (setq minibuffer-setup-hook nil |
| @@ -1969,7 +1969,7 @@ problems." | |||
| 1969 | (string= (nth 0 (eval history-var)) "")) | 1969 | (string= (nth 0 (eval history-var)) "")) |
| 1970 | (set history-var (cdr (eval history-var)))) | 1970 | (set history-var (cdr (eval history-var)))) |
| 1971 | ;; If the user enters nothing but the prev cmd wasn't viper-ex, | 1971 | ;; If the user enters nothing but the prev cmd wasn't viper-ex, |
| 1972 | ;; viper-command-argument, or `! shell-command', this probably means | 1972 | ;; viper-command-argument, or `! shell-command', this probably means |
| 1973 | ;; that the user typed something then erased. Return "" in this case, not | 1973 | ;; that the user typed something then erased. Return "" in this case, not |
| 1974 | ;; the default---the default is too confusing in this case. | 1974 | ;; the default---the default is too confusing in this case. |
| 1975 | (cond ((and (string= val "") | 1975 | (cond ((and (string= val "") |
| @@ -1983,7 +1983,7 @@ problems." | |||
| 1983 | ((string= val "") (or default "")) | 1983 | ((string= val "") (or default "")) |
| 1984 | (t val)) | 1984 | (t val)) |
| 1985 | )) | 1985 | )) |
| 1986 | 1986 | ||
| 1987 | 1987 | ||
| 1988 | 1988 | ||
| 1989 | ;; insertion commands | 1989 | ;; insertion commands |
| @@ -1996,7 +1996,7 @@ problems." | |||
| 1996 | (val (nth 1 viper-d-com)) | 1996 | (val (nth 1 viper-d-com)) |
| 1997 | (char (nth 2 viper-d-com))) | 1997 | (char (nth 2 viper-d-com))) |
| 1998 | (if (and val (> val 1)) ; first check that val is non-nil | 1998 | (if (and val (> val 1)) ; first check that val is non-nil |
| 1999 | (progn | 1999 | (progn |
| 2000 | (setq viper-d-com (list i-com (1- val) ?r nil nil nil)) | 2000 | (setq viper-d-com (list i-com (1- val) ?r nil nil nil)) |
| 2001 | (viper-repeat nil) | 2001 | (viper-repeat nil) |
| 2002 | (setq viper-d-com (list i-com val char nil nil nil)) | 2002 | (setq viper-d-com (list i-com val char nil nil nil)) |
| @@ -2061,7 +2061,7 @@ problems." | |||
| 2061 | (viper-loop val | 2061 | (viper-loop val |
| 2062 | (end-of-line) | 2062 | (end-of-line) |
| 2063 | (newline 1) | 2063 | (newline 1) |
| 2064 | (if viper-auto-indent | 2064 | (if viper-auto-indent |
| 2065 | (progn | 2065 | (progn |
| 2066 | (setq viper-cted t) | 2066 | (setq viper-cted t) |
| 2067 | (if viper-electric-mode | 2067 | (if viper-electric-mode |
| @@ -2091,7 +2091,7 @@ problems." | |||
| 2091 | (viper-loop val | 2091 | (viper-loop val |
| 2092 | (beginning-of-line) | 2092 | (beginning-of-line) |
| 2093 | (open-line 1) | 2093 | (open-line 1) |
| 2094 | (if viper-auto-indent | 2094 | (if viper-auto-indent |
| 2095 | (progn | 2095 | (progn |
| 2096 | (setq viper-cted t) | 2096 | (setq viper-cted t) |
| 2097 | (if viper-electric-mode | 2097 | (if viper-electric-mode |
| @@ -2169,7 +2169,7 @@ problems." | |||
| 2169 | 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local) | 2169 | 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local) |
| 2170 | (if overwrite-mode (overwrite-mode nil)) | 2170 | (if overwrite-mode (overwrite-mode nil)) |
| 2171 | ) | 2171 | ) |
| 2172 | 2172 | ||
| 2173 | 2173 | ||
| 2174 | (defun viper-replace-mode-spy-before (beg end) | 2174 | (defun viper-replace-mode-spy-before (beg end) |
| 2175 | (setq viper-replace-region-chars-deleted (viper-chars-in-region beg end)) | 2175 | (setq viper-replace-region-chars-deleted (viper-chars-in-region beg end)) |
| @@ -2179,17 +2179,17 @@ problems." | |||
| 2179 | ;; deleted. This function may be called several times within a single command, | 2179 | ;; deleted. This function may be called several times within a single command, |
| 2180 | ;; if this command performs several separate buffer changes. Therefore, if | 2180 | ;; if this command performs several separate buffer changes. Therefore, if |
| 2181 | ;; adds up the number of chars inserted and subtracts the number of chars | 2181 | ;; adds up the number of chars inserted and subtracts the number of chars |
| 2182 | ;; deleted. | 2182 | ;; deleted. |
| 2183 | (defun viper-replace-mode-spy-after (beg end length) | 2183 | (defun viper-replace-mode-spy-after (beg end length) |
| 2184 | (if (memq viper-intermediate-command | 2184 | (if (memq viper-intermediate-command |
| 2185 | '(dabbrev-expand hippie-expand repeating-insertion-from-ring)) | 2185 | '(dabbrev-expand hippie-expand repeating-insertion-from-ring)) |
| 2186 | ;; Take special care of text insertion from insertion ring inside | 2186 | ;; Take special care of text insertion from insertion ring inside |
| 2187 | ;; replacement overlays. | 2187 | ;; replacement overlays. |
| 2188 | (progn | 2188 | (progn |
| 2189 | (setq viper-replace-chars-to-delete 0) | 2189 | (setq viper-replace-chars-to-delete 0) |
| 2190 | (viper-move-marker-locally | 2190 | (viper-move-marker-locally |
| 2191 | 'viper-last-posn-in-replace-region (point))) | 2191 | 'viper-last-posn-in-replace-region (point))) |
| 2192 | 2192 | ||
| 2193 | (let* ((real-end (min end (viper-replace-end))) | 2193 | (let* ((real-end (min end (viper-replace-end))) |
| 2194 | (column-shift (- (save-excursion (goto-char real-end) | 2194 | (column-shift (- (save-excursion (goto-char real-end) |
| 2195 | (current-column)) | 2195 | (current-column)) |
| @@ -2202,7 +2202,7 @@ problems." | |||
| 2202 | (setq viper-replace-region-chars-deleted 0) | 2202 | (setq viper-replace-region-chars-deleted 0) |
| 2203 | (setq viper-replace-chars-to-delete | 2203 | (setq viper-replace-chars-to-delete |
| 2204 | (+ viper-replace-chars-to-delete | 2204 | (+ viper-replace-chars-to-delete |
| 2205 | (- | 2205 | (- |
| 2206 | ;; if column shift is bigger, due to a TAB insertion, take | 2206 | ;; if column shift is bigger, due to a TAB insertion, take |
| 2207 | ;; column-shift instead of the number of inserted chars | 2207 | ;; column-shift instead of the number of inserted chars |
| 2208 | (max (viper-chars-in-region beg real-end) | 2208 | (max (viper-chars-in-region beg real-end) |
| @@ -2224,13 +2224,13 @@ problems." | |||
| 2224 | ;; the number of deleted chars | 2224 | ;; the number of deleted chars |
| 2225 | chars-deleted))) | 2225 | chars-deleted))) |
| 2226 | 2226 | ||
| 2227 | (viper-move-marker-locally | 2227 | (viper-move-marker-locally |
| 2228 | 'viper-last-posn-in-replace-region | 2228 | 'viper-last-posn-in-replace-region |
| 2229 | (max (if (> end (viper-replace-end)) (viper-replace-end) end) | 2229 | (max (if (> end (viper-replace-end)) (viper-replace-end) end) |
| 2230 | (or (marker-position viper-last-posn-in-replace-region) | 2230 | (or (marker-position viper-last-posn-in-replace-region) |
| 2231 | (viper-replace-start)) | 2231 | (viper-replace-start)) |
| 2232 | )) | 2232 | )) |
| 2233 | 2233 | ||
| 2234 | ))) | 2234 | ))) |
| 2235 | 2235 | ||
| 2236 | ;; Make sure we don't delete more than needed. | 2236 | ;; Make sure we don't delete more than needed. |
| @@ -2258,20 +2258,20 @@ problems." | |||
| 2258 | (remove-hook | 2258 | (remove-hook |
| 2259 | 'viper-before-change-functions 'viper-replace-mode-spy-before 'local) | 2259 | 'viper-before-change-functions 'viper-replace-mode-spy-before 'local) |
| 2260 | (remove-hook | 2260 | (remove-hook |
| 2261 | 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local) | 2261 | 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local) |
| 2262 | (remove-hook | 2262 | (remove-hook |
| 2263 | 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local) | 2263 | 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local) |
| 2264 | (viper-restore-cursor-color 'after-replace-mode) | 2264 | (viper-restore-cursor-color 'after-replace-mode) |
| 2265 | (setq viper-sitting-in-replace nil) ; just in case we'll need to know it | 2265 | (setq viper-sitting-in-replace nil) ; just in case we'll need to know it |
| 2266 | (save-excursion | 2266 | (save-excursion |
| 2267 | (if (and viper-replace-overlay | 2267 | (if (and viper-replace-overlay |
| 2268 | (viper-pos-within-region viper-last-posn-in-replace-region | 2268 | (viper-pos-within-region viper-last-posn-in-replace-region |
| 2269 | (viper-replace-start) | 2269 | (viper-replace-start) |
| 2270 | (viper-replace-end)) | 2270 | (viper-replace-end)) |
| 2271 | (< (point) (viper-replace-end))) | 2271 | (< (point) (viper-replace-end))) |
| 2272 | (delete-region | 2272 | (delete-region |
| 2273 | viper-last-posn-in-replace-region (viper-replace-end)))) | 2273 | viper-last-posn-in-replace-region (viper-replace-end)))) |
| 2274 | 2274 | ||
| 2275 | (if (eq viper-current-state 'replace-state) | 2275 | (if (eq viper-current-state 'replace-state) |
| 2276 | (viper-downgrade-to-insert)) | 2276 | (viper-downgrade-to-insert)) |
| 2277 | ;; replace mode ended => nullify viper-last-posn-in-replace-region | 2277 | ;; replace mode ended => nullify viper-last-posn-in-replace-region |
| @@ -2294,7 +2294,7 @@ problems." | |||
| 2294 | (remove-hook | 2294 | (remove-hook |
| 2295 | 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local) | 2295 | 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local) |
| 2296 | (viper-downgrade-to-insert)) | 2296 | (viper-downgrade-to-insert)) |
| 2297 | 2297 | ||
| 2298 | (defun viper-start-R-mode () | 2298 | (defun viper-start-R-mode () |
| 2299 | ;; Leave arg as 1, not t: XEmacs insists that it must be a pos number | 2299 | ;; Leave arg as 1, not t: XEmacs insists that it must be a pos number |
| 2300 | (overwrite-mode 1) | 2300 | (overwrite-mode 1) |
| @@ -2308,7 +2308,7 @@ problems." | |||
| 2308 | ) | 2308 | ) |
| 2309 | 2309 | ||
| 2310 | 2310 | ||
| 2311 | 2311 | ||
| 2312 | (defun viper-replace-state-exit-cmd () | 2312 | (defun viper-replace-state-exit-cmd () |
| 2313 | "Binding for keys that cause Replace state to switch to Vi or to Insert. | 2313 | "Binding for keys that cause Replace state to switch to Vi or to Insert. |
| 2314 | These keys are ESC, RET, and LineFeed" | 2314 | These keys are ESC, RET, and LineFeed" |
| @@ -2321,7 +2321,7 @@ These keys are ESC, RET, and LineFeed" | |||
| 2321 | (setq com 'viper-exit-insert-state) | 2321 | (setq com 'viper-exit-insert-state) |
| 2322 | (viper-set-unread-command-events last-input-char) | 2322 | (viper-set-unread-command-events last-input-char) |
| 2323 | (setq com (key-binding (read-key-sequence nil)))) | 2323 | (setq com (key-binding (read-key-sequence nil)))) |
| 2324 | 2324 | ||
| 2325 | (condition-case conds | 2325 | (condition-case conds |
| 2326 | (command-execute com) | 2326 | (command-execute com) |
| 2327 | (error | 2327 | (error |
| @@ -2360,20 +2360,20 @@ These keys are ESC, RET, and LineFeed" | |||
| 2360 | (back-to-indentation) | 2360 | (back-to-indentation) |
| 2361 | )))) | 2361 | )))) |
| 2362 | 2362 | ||
| 2363 | 2363 | ||
| 2364 | ;; This is the function bound to 'R'---unlimited replace. | 2364 | ;; This is the function bound to 'R'---unlimited replace. |
| 2365 | ;; Similar to Emacs's own overwrite-mode. | 2365 | ;; Similar to Emacs's own overwrite-mode. |
| 2366 | (defun viper-overwrite (arg) | 2366 | (defun viper-overwrite (arg) |
| 2367 | "Begin overwrite mode." | 2367 | "Begin overwrite mode." |
| 2368 | (interactive "P") | 2368 | (interactive "P") |
| 2369 | (let ((val (viper-p-val arg)) | 2369 | (let ((val (viper-p-val arg)) |
| 2370 | (com (viper-getcom arg)) (len)) | 2370 | (com (viper-getcom arg)) (len)) |
| 2371 | (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil)) | 2371 | (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil)) |
| 2372 | (if com | 2372 | (if com |
| 2373 | (progn | 2373 | (progn |
| 2374 | ;; Viper saves inserted text in viper-last-insertion | 2374 | ;; Viper saves inserted text in viper-last-insertion |
| 2375 | (setq len (length viper-last-insertion)) | 2375 | (setq len (length viper-last-insertion)) |
| 2376 | (delete-char len) | 2376 | (delete-char len) |
| 2377 | (viper-loop val (viper-yank-last-insertion))) | 2377 | (viper-loop val (viper-yank-last-insertion))) |
| 2378 | (setq last-command 'viper-overwrite) | 2378 | (setq last-command 'viper-overwrite) |
| 2379 | (viper-set-complex-command-for-undo) | 2379 | (viper-set-complex-command-for-undo) |
| @@ -2457,7 +2457,7 @@ These keys are ESC, RET, and LineFeed" | |||
| 2457 | ;; get Intl. characters | 2457 | ;; get Intl. characters |
| 2458 | (progn | 2458 | (progn |
| 2459 | (viper-set-input-method t) | 2459 | (viper-set-input-method t) |
| 2460 | (setq last-command-event | 2460 | (setq last-command-event |
| 2461 | (viper-copy-event | 2461 | (viper-copy-event |
| 2462 | (if viper-xemacs-p (character-to-event char) char))) | 2462 | (if viper-xemacs-p (character-to-event char) char))) |
| 2463 | (delete-char 1 t) | 2463 | (delete-char 1 t) |
| @@ -2488,7 +2488,7 @@ These keys are ESC, RET, and LineFeed" | |||
| 2488 | (viper-set-input-method nil)) | 2488 | (viper-set-input-method nil)) |
| 2489 | (delete-char arg t) | 2489 | (delete-char arg t) |
| 2490 | (setq viper-d-char char) | 2490 | (setq viper-d-char char) |
| 2491 | (viper-loop (if (> arg 0) arg (- arg)) | 2491 | (viper-loop (if (> arg 0) arg (- arg)) |
| 2492 | (insert char))) | 2492 | (insert char))) |
| 2493 | (viper-adjust-undo) | 2493 | (viper-adjust-undo) |
| 2494 | (backward-char arg)))) | 2494 | (backward-char arg)))) |
| @@ -2519,7 +2519,7 @@ On reaching end of line, stop and signal error." | |||
| 2519 | (if com (viper-execute-com 'viper-forward-char val com))))) | 2519 | (if com (viper-execute-com 'viper-forward-char val com))))) |
| 2520 | 2520 | ||
| 2521 | (defun viper-backward-char (arg) | 2521 | (defun viper-backward-char (arg) |
| 2522 | "Move point left ARG characters (right if ARG negative). | 2522 | "Move point left ARG characters (right if ARG negative). |
| 2523 | On reaching beginning of line, stop and signal error." | 2523 | On reaching beginning of line, stop and signal error." |
| 2524 | (interactive "P") | 2524 | (interactive "P") |
| 2525 | (viper-leave-region-active) | 2525 | (viper-leave-region-active) |
| @@ -2532,11 +2532,11 @@ On reaching beginning of line, stop and signal error." | |||
| 2532 | (if com (viper-execute-com 'viper-backward-char val com))) | 2532 | (if com (viper-execute-com 'viper-backward-char val com))) |
| 2533 | (backward-char val) | 2533 | (backward-char val) |
| 2534 | (if com (viper-execute-com 'viper-backward-char val com))))) | 2534 | (if com (viper-execute-com 'viper-backward-char val com))))) |
| 2535 | 2535 | ||
| 2536 | ;; Like forward-char, but doesn't move at end of buffer. | 2536 | ;; Like forward-char, but doesn't move at end of buffer. |
| 2537 | ;; Returns distance traveled | 2537 | ;; Returns distance traveled |
| 2538 | ;; (positive or 0, if arg positive; negative if arg negative). | 2538 | ;; (positive or 0, if arg positive; negative if arg negative). |
| 2539 | (defun viper-forward-char-carefully (&optional arg) | 2539 | (defun viper-forward-char-carefully (&optional arg) |
| 2540 | (setq arg (or arg 1)) | 2540 | (setq arg (or arg 1)) |
| 2541 | (let ((pt (point))) | 2541 | (let ((pt (point))) |
| 2542 | (condition-case nil | 2542 | (condition-case nil |
| @@ -2545,11 +2545,11 @@ On reaching beginning of line, stop and signal error." | |||
| 2545 | (if (< (point) pt) ; arg was negative | 2545 | (if (< (point) pt) ; arg was negative |
| 2546 | (- (viper-chars-in-region pt (point))) | 2546 | (- (viper-chars-in-region pt (point))) |
| 2547 | (viper-chars-in-region pt (point))))) | 2547 | (viper-chars-in-region pt (point))))) |
| 2548 | 2548 | ||
| 2549 | ;; Like backward-char, but doesn't move at beg of buffer. | 2549 | ;; Like backward-char, but doesn't move at beg of buffer. |
| 2550 | ;; Returns distance traveled | 2550 | ;; Returns distance traveled |
| 2551 | ;; (negative or 0, if arg positive; positive if arg negative). | 2551 | ;; (negative or 0, if arg positive; positive if arg negative). |
| 2552 | (defun viper-backward-char-carefully (&optional arg) | 2552 | (defun viper-backward-char-carefully (&optional arg) |
| 2553 | (setq arg (or arg 1)) | 2553 | (setq arg (or arg 1)) |
| 2554 | (let ((pt (point))) | 2554 | (let ((pt (point))) |
| 2555 | (condition-case nil | 2555 | (condition-case nil |
| @@ -2593,7 +2593,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2593 | (if (looking-at "\n") | 2593 | (if (looking-at "\n") |
| 2594 | (viper-skip-all-separators-backward 'within-line) | 2594 | (viper-skip-all-separators-backward 'within-line) |
| 2595 | (or (bobp) (forward-char))))) | 2595 | (or (bobp) (forward-char))))) |
| 2596 | 2596 | ||
| 2597 | (defun viper-forward-word-kernel (val) | 2597 | (defun viper-forward-word-kernel (val) |
| 2598 | (while (> val 0) | 2598 | (while (> val 0) |
| 2599 | (cond ((viper-looking-at-alpha) | 2599 | (cond ((viper-looking-at-alpha) |
| @@ -2644,7 +2644,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2644 | (viper-forward-char-carefully)) | 2644 | (viper-forward-char-carefully)) |
| 2645 | )) | 2645 | )) |
| 2646 | 2646 | ||
| 2647 | 2647 | ||
| 2648 | (defun viper-forward-word (arg) | 2648 | (defun viper-forward-word (arg) |
| 2649 | "Forward word." | 2649 | "Forward word." |
| 2650 | (interactive "P") | 2650 | (interactive "P") |
| @@ -2662,7 +2662,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2662 | ((viper-dotable-command-p com) | 2662 | ((viper-dotable-command-p com) |
| 2663 | (viper-separator-skipback-special nil viper-com-point))) | 2663 | (viper-separator-skipback-special nil viper-com-point))) |
| 2664 | (viper-execute-com 'viper-forward-word val com))))) | 2664 | (viper-execute-com 'viper-forward-word val com))))) |
| 2665 | 2665 | ||
| 2666 | 2666 | ||
| 2667 | (defun viper-forward-Word (arg) | 2667 | (defun viper-forward-Word (arg) |
| 2668 | "Forward word delimited by white characters." | 2668 | "Forward word delimited by white characters." |
| @@ -2685,19 +2685,19 @@ On reaching beginning of line, stop and signal error." | |||
| 2685 | (viper-execute-com 'viper-forward-Word val com))))) | 2685 | (viper-execute-com 'viper-forward-Word val com))))) |
| 2686 | 2686 | ||
| 2687 | 2687 | ||
| 2688 | ;; this is a bit different from Vi, but Vi's end of word | 2688 | ;; this is a bit different from Vi, but Vi's end of word |
| 2689 | ;; makes no sense whatsoever | 2689 | ;; makes no sense whatsoever |
| 2690 | (defun viper-end-of-word-kernel () | 2690 | (defun viper-end-of-word-kernel () |
| 2691 | (if (viper-end-of-word-p) (forward-char)) | 2691 | (if (viper-end-of-word-p) (forward-char)) |
| 2692 | (if (viper-looking-at-separator) | 2692 | (if (viper-looking-at-separator) |
| 2693 | (viper-skip-all-separators-forward)) | 2693 | (viper-skip-all-separators-forward)) |
| 2694 | 2694 | ||
| 2695 | (cond ((viper-looking-at-alpha) (viper-skip-alpha-forward "_")) | 2695 | (cond ((viper-looking-at-alpha) (viper-skip-alpha-forward "_")) |
| 2696 | ((not (viper-looking-at-alphasep)) (viper-skip-nonalphasep-forward))) | 2696 | ((not (viper-looking-at-alphasep)) (viper-skip-nonalphasep-forward))) |
| 2697 | (viper-backward-char-carefully)) | 2697 | (viper-backward-char-carefully)) |
| 2698 | 2698 | ||
| 2699 | (defun viper-end-of-word-p () | 2699 | (defun viper-end-of-word-p () |
| 2700 | (or (eobp) | 2700 | (or (eobp) |
| 2701 | (save-excursion | 2701 | (save-excursion |
| 2702 | (cond ((viper-looking-at-alpha) | 2702 | (cond ((viper-looking-at-alpha) |
| 2703 | (forward-char) | 2703 | (forward-char) |
| @@ -2715,7 +2715,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2715 | (com (viper-getcom arg))) | 2715 | (com (viper-getcom arg))) |
| 2716 | (if com (viper-move-marker-locally 'viper-com-point (point))) | 2716 | (if com (viper-move-marker-locally 'viper-com-point (point))) |
| 2717 | (viper-loop val (viper-end-of-word-kernel)) | 2717 | (viper-loop val (viper-end-of-word-kernel)) |
| 2718 | (if com | 2718 | (if com |
| 2719 | (progn | 2719 | (progn |
| 2720 | (forward-char) | 2720 | (forward-char) |
| 2721 | (viper-execute-com 'viper-end-of-word val com))))) | 2721 | (viper-execute-com 'viper-end-of-word val com))))) |
| @@ -2731,7 +2731,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2731 | (viper-end-of-word-kernel) | 2731 | (viper-end-of-word-kernel) |
| 2732 | (viper-skip-nonseparators 'forward) | 2732 | (viper-skip-nonseparators 'forward) |
| 2733 | (backward-char)) | 2733 | (backward-char)) |
| 2734 | (if com | 2734 | (if com |
| 2735 | (progn | 2735 | (progn |
| 2736 | (forward-char) | 2736 | (forward-char) |
| 2737 | (viper-execute-com 'viper-end-of-Word val com))))) | 2737 | (viper-execute-com 'viper-end-of-Word val com))))) |
| @@ -2821,7 +2821,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2821 | (end-of-line val) | 2821 | (end-of-line val) |
| 2822 | (if com (viper-execute-com 'viper-goto-eol val com)) | 2822 | (if com (viper-execute-com 'viper-goto-eol val com)) |
| 2823 | (if viper-ex-style-motion | 2823 | (if viper-ex-style-motion |
| 2824 | (if (and (eolp) (not (bolp)) | 2824 | (if (and (eolp) (not (bolp)) |
| 2825 | ;; a fix for viper-change-to-eol | 2825 | ;; a fix for viper-change-to-eol |
| 2826 | (not (equal viper-current-state 'insert-state))) | 2826 | (not (equal viper-current-state 'insert-state))) |
| 2827 | (backward-char 1) | 2827 | (backward-char 1) |
| @@ -2848,7 +2848,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2848 | (end-of-line) | 2848 | (end-of-line) |
| 2849 | (if (> val (current-column)) (error ""))) | 2849 | (if (> val (current-column)) (error ""))) |
| 2850 | )) | 2850 | )) |
| 2851 | 2851 | ||
| 2852 | 2852 | ||
| 2853 | (defun viper-next-line (arg) | 2853 | (defun viper-next-line (arg) |
| 2854 | "Go to next line." | 2854 | "Go to next line." |
| @@ -2877,8 +2877,8 @@ On reaching beginning of line, stop and signal error." | |||
| 2877 | (back-to-indentation) | 2877 | (back-to-indentation) |
| 2878 | (if com (viper-execute-com 'viper-next-line-at-bol val com)))) | 2878 | (if com (viper-execute-com 'viper-next-line-at-bol val com)))) |
| 2879 | 2879 | ||
| 2880 | (defun viper-previous-line (arg) | 2880 | (defun viper-previous-line (arg) |
| 2881 | "Go to previous line." | 2881 | "Go to previous line." |
| 2882 | (interactive "P") | 2882 | (interactive "P") |
| 2883 | (viper-leave-region-active) | 2883 | (viper-leave-region-active) |
| 2884 | (let ((val (viper-p-val arg)) | 2884 | (let ((val (viper-p-val arg)) |
| @@ -2935,18 +2935,18 @@ On reaching beginning of line, stop and signal error." | |||
| 2935 | (goto-char (point-max)) | 2935 | (goto-char (point-max)) |
| 2936 | (goto-char (point-min)) | 2936 | (goto-char (point-min)) |
| 2937 | (forward-line (1- val))) | 2937 | (forward-line (1- val))) |
| 2938 | 2938 | ||
| 2939 | ;; positioning is done twice: before and after command execution | 2939 | ;; positioning is done twice: before and after command execution |
| 2940 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 2940 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 2941 | (back-to-indentation) | 2941 | (back-to-indentation) |
| 2942 | 2942 | ||
| 2943 | (if com (viper-execute-com 'viper-goto-line val com)) | 2943 | (if com (viper-execute-com 'viper-goto-line val com)) |
| 2944 | 2944 | ||
| 2945 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 2945 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 2946 | (back-to-indentation) | 2946 | (back-to-indentation) |
| 2947 | )) | 2947 | )) |
| 2948 | 2948 | ||
| 2949 | ;; Find ARG's occurrence of CHAR on the current line. | 2949 | ;; Find ARG's occurrence of CHAR on the current line. |
| 2950 | ;; If FORWARD then search is forward, otherwise backward. OFFSET is used to | 2950 | ;; If FORWARD then search is forward, otherwise backward. OFFSET is used to |
| 2951 | ;; adjust point after search. | 2951 | ;; adjust point after search. |
| 2952 | (defun viper-find-char (arg char forward offset) | 2952 | (defun viper-find-char (arg char forward offset) |
| @@ -2999,7 +2999,7 @@ On reaching beginning of line, stop and signal error." | |||
| 2999 | (forward-char (if offset 1 0))))) | 2999 | (forward-char (if offset 1 0))))) |
| 3000 | 3000 | ||
| 3001 | (defun viper-find-char-forward (arg) | 3001 | (defun viper-find-char-forward (arg) |
| 3002 | "Find char on the line. | 3002 | "Find char on the line. |
| 3003 | If called interactively read the char to find from the terminal, and if | 3003 | If called interactively read the char to find from the terminal, and if |
| 3004 | called from viper-repeat, the char last used is used. This behaviour is | 3004 | called from viper-repeat, the char last used is used. This behaviour is |
| 3005 | controlled by the sign of prefix numeric value." | 3005 | controlled by the sign of prefix numeric value." |
| @@ -3143,15 +3143,15 @@ controlled by the sign of prefix numeric value." | |||
| 3143 | (com (viper-getCom arg))) | 3143 | (com (viper-getCom arg))) |
| 3144 | (viper-leave-region-active) | 3144 | (viper-leave-region-active) |
| 3145 | (if com (viper-move-marker-locally 'viper-com-point (point))) | 3145 | (if com (viper-move-marker-locally 'viper-com-point (point))) |
| 3146 | (push-mark nil t) | 3146 | (push-mark nil t) |
| 3147 | (move-to-window-line (1- val)) | 3147 | (move-to-window-line (1- val)) |
| 3148 | 3148 | ||
| 3149 | ;; positioning is done twice: before and after command execution | 3149 | ;; positioning is done twice: before and after command execution |
| 3150 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3150 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3151 | (back-to-indentation) | 3151 | (back-to-indentation) |
| 3152 | 3152 | ||
| 3153 | (if com (viper-execute-com 'viper-window-top val com)) | 3153 | (if com (viper-execute-com 'viper-window-top val com)) |
| 3154 | 3154 | ||
| 3155 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3155 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3156 | (back-to-indentation) | 3156 | (back-to-indentation) |
| 3157 | )) | 3157 | )) |
| @@ -3163,15 +3163,15 @@ controlled by the sign of prefix numeric value." | |||
| 3163 | (com (viper-getCom arg))) | 3163 | (com (viper-getCom arg))) |
| 3164 | (viper-leave-region-active) | 3164 | (viper-leave-region-active) |
| 3165 | (if com (viper-move-marker-locally 'viper-com-point (point))) | 3165 | (if com (viper-move-marker-locally 'viper-com-point (point))) |
| 3166 | (push-mark nil t) | 3166 | (push-mark nil t) |
| 3167 | (move-to-window-line (+ (/ (1- (window-height)) 2) (1- val))) | 3167 | (move-to-window-line (+ (/ (1- (window-height)) 2) (1- val))) |
| 3168 | 3168 | ||
| 3169 | ;; positioning is done twice: before and after command execution | 3169 | ;; positioning is done twice: before and after command execution |
| 3170 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3170 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3171 | (back-to-indentation) | 3171 | (back-to-indentation) |
| 3172 | 3172 | ||
| 3173 | (if com (viper-execute-com 'viper-window-middle val com)) | 3173 | (if com (viper-execute-com 'viper-window-middle val com)) |
| 3174 | 3174 | ||
| 3175 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3175 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3176 | (back-to-indentation) | 3176 | (back-to-indentation) |
| 3177 | )) | 3177 | )) |
| @@ -3183,15 +3183,15 @@ controlled by the sign of prefix numeric value." | |||
| 3183 | (com (viper-getCom arg))) | 3183 | (com (viper-getCom arg))) |
| 3184 | (viper-leave-region-active) | 3184 | (viper-leave-region-active) |
| 3185 | (if com (viper-move-marker-locally 'viper-com-point (point))) | 3185 | (if com (viper-move-marker-locally 'viper-com-point (point))) |
| 3186 | (push-mark nil t) | 3186 | (push-mark nil t) |
| 3187 | (move-to-window-line (- val)) | 3187 | (move-to-window-line (- val)) |
| 3188 | 3188 | ||
| 3189 | ;; positioning is done twice: before and after command execution | 3189 | ;; positioning is done twice: before and after command execution |
| 3190 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3190 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3191 | (back-to-indentation) | 3191 | (back-to-indentation) |
| 3192 | 3192 | ||
| 3193 | (if com (viper-execute-com 'viper-window-bottom val com)) | 3193 | (if com (viper-execute-com 'viper-window-bottom val com)) |
| 3194 | 3194 | ||
| 3195 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) | 3195 | (if (and (eobp) (bolp) (not (bobp))) (forward-line -1)) |
| 3196 | (back-to-indentation) | 3196 | (back-to-indentation) |
| 3197 | )) | 3197 | )) |
| @@ -3245,7 +3245,7 @@ controlled by the sign of prefix numeric value." | |||
| 3245 | ;; paren match | 3245 | ;; paren match |
| 3246 | ;; must correct this to only match ( to ) etc. On the other hand | 3246 | ;; must correct this to only match ( to ) etc. On the other hand |
| 3247 | ;; it is good that paren match gets confused, because that way you | 3247 | ;; it is good that paren match gets confused, because that way you |
| 3248 | ;; catch _all_ imbalances. | 3248 | ;; catch _all_ imbalances. |
| 3249 | 3249 | ||
| 3250 | (defun viper-paren-match (arg) | 3250 | (defun viper-paren-match (arg) |
| 3251 | "Go to the matching parenthesis." | 3251 | "Go to the matching parenthesis." |
| @@ -3271,7 +3271,7 @@ controlled by the sign of prefix numeric value." | |||
| 3271 | (setq beg-lim (point)) | 3271 | (setq beg-lim (point)) |
| 3272 | (end-of-line) | 3272 | (end-of-line) |
| 3273 | (setq end-lim (point))) | 3273 | (setq end-lim (point))) |
| 3274 | (cond ((re-search-forward "[][(){}]" end-lim t) | 3274 | (cond ((re-search-forward "[][(){}]" end-lim t) |
| 3275 | (backward-char) ) | 3275 | (backward-char) ) |
| 3276 | ((re-search-backward "[][(){}]" beg-lim t)) | 3276 | ((re-search-backward "[][(){}]" beg-lim t)) |
| 3277 | (t | 3277 | (t |
| @@ -3464,10 +3464,10 @@ controlled by the sign of prefix numeric value." | |||
| 3464 | 'viper-search-history | 3464 | 'viper-search-history |
| 3465 | (car viper-search-history)))) | 3465 | (car viper-search-history)))) |
| 3466 | (if (not (string= s "")) | 3466 | (if (not (string= s "")) |
| 3467 | (setq viper-s-string s)))) | 3467 | (setq viper-s-string s)))) |
| 3468 | 3468 | ||
| 3469 | 3469 | ||
| 3470 | (defun viper-toggle-search-style (arg) | 3470 | (defun viper-toggle-search-style (arg) |
| 3471 | "Toggle the value of viper-case-fold-search/viper-re-search. | 3471 | "Toggle the value of viper-case-fold-search/viper-re-search. |
| 3472 | Without prefix argument, will ask which search style to toggle. With prefix | 3472 | Without prefix argument, will ask which search style to toggle. With prefix |
| 3473 | arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search. | 3473 | arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search. |
| @@ -3560,7 +3560,7 @@ With a prefix argument, unsets the macro." | |||
| 3560 | "Set the macros for toggling the search style in Viper's emacs-state. | 3560 | "Set the macros for toggling the search style in Viper's emacs-state. |
| 3561 | The macro that toggles case sensitivity is bound to `//', and the one that | 3561 | The macro that toggles case sensitivity is bound to `//', and the one that |
| 3562 | toggles regexp search is bound to `///'. | 3562 | toggles regexp search is bound to `///'. |
| 3563 | With a prefix argument, this function unsets the macros. | 3563 | With a prefix argument, this function unsets the macros. |
| 3564 | If the optional prefix argument is non-nil and specifies a valid major mode, | 3564 | If the optional prefix argument is non-nil and specifies a valid major mode, |
| 3565 | this sets the macros only in the macros in that major mode. Otherwise, | 3565 | this sets the macros only in the macros in that major mode. Otherwise, |
| 3566 | the macros are set in the current major mode. | 3566 | the macros are set in the current major mode. |
| @@ -3572,7 +3572,7 @@ the macros are set in the current major mode. | |||
| 3572 | ;; toggle case sensitivity in search | 3572 | ;; toggle case sensitivity in search |
| 3573 | (viper-record-kbd-macro | 3573 | (viper-record-kbd-macro |
| 3574 | "//" 'emacs-state | 3574 | "//" 'emacs-state |
| 3575 | [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] | 3575 | [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] |
| 3576 | (or arg-majormode major-mode)) | 3576 | (or arg-majormode major-mode)) |
| 3577 | ;; toggle regexp/vanila search | 3577 | ;; toggle regexp/vanila search |
| 3578 | (viper-record-kbd-macro | 3578 | (viper-record-kbd-macro |
| @@ -3588,7 +3588,7 @@ the macros are set in the current major mode. | |||
| 3588 | 3588 | ||
| 3589 | 3589 | ||
| 3590 | (defun viper-search-forward (arg) | 3590 | (defun viper-search-forward (arg) |
| 3591 | "Search a string forward. | 3591 | "Search a string forward. |
| 3592 | ARG is used to find the ARG's occurrence of the string. | 3592 | ARG is used to find the ARG's occurrence of the string. |
| 3593 | Null string will repeat previous search." | 3593 | Null string will repeat previous search." |
| 3594 | (interactive "P") | 3594 | (interactive "P") |
| @@ -3609,7 +3609,7 @@ Null string will repeat previous search." | |||
| 3609 | (viper-execute-com 'viper-search-next val com))))) | 3609 | (viper-execute-com 'viper-search-next val com))))) |
| 3610 | 3610 | ||
| 3611 | (defun viper-search-backward (arg) | 3611 | (defun viper-search-backward (arg) |
| 3612 | "Search a string backward. | 3612 | "Search a string backward. |
| 3613 | ARG is used to find the ARG's occurrence of the string. | 3613 | ARG is used to find the ARG's occurrence of the string. |
| 3614 | Null string will repeat previous search." | 3614 | Null string will repeat previous search." |
| 3615 | (interactive "P") | 3615 | (interactive "P") |
| @@ -3628,7 +3628,7 @@ Null string will repeat previous search." | |||
| 3628 | (progn | 3628 | (progn |
| 3629 | (viper-move-marker-locally 'viper-com-point (mark t)) | 3629 | (viper-move-marker-locally 'viper-com-point (mark t)) |
| 3630 | (viper-execute-com 'viper-search-next val com))))) | 3630 | (viper-execute-com 'viper-search-next val com))))) |
| 3631 | 3631 | ||
| 3632 | 3632 | ||
| 3633 | ;; Search for COUNT's occurrence of STRING. | 3633 | ;; Search for COUNT's occurrence of STRING. |
| 3634 | ;; Search is forward if FORWARD is non-nil, otherwise backward. | 3634 | ;; Search is forward if FORWARD is non-nil, otherwise backward. |
| @@ -3655,7 +3655,7 @@ Null string will repeat previous search." | |||
| 3655 | (search-forward string nil nil val) | 3655 | (search-forward string nil nil val) |
| 3656 | (search-backward string)) | 3656 | (search-backward string)) |
| 3657 | (if (not (equal start-point (point))) | 3657 | (if (not (equal start-point (point))) |
| 3658 | (push-mark start-point t))) | 3658 | (push-mark start-point t))) |
| 3659 | (search-failed | 3659 | (search-failed |
| 3660 | (if (and (not fail-if-not-found) viper-search-wrap-around-t) | 3660 | (if (and (not fail-if-not-found) viper-search-wrap-around-t) |
| 3661 | (progn | 3661 | (progn |
| @@ -3664,7 +3664,7 @@ Null string will repeat previous search." | |||
| 3664 | (viper-search string forward (cons 1 com) t start-point 'fail) | 3664 | (viper-search string forward (cons 1 com) t start-point 'fail) |
| 3665 | ;; don't wait in macros | 3665 | ;; don't wait in macros |
| 3666 | (or executing-kbd-macro | 3666 | (or executing-kbd-macro |
| 3667 | (memq viper-intermediate-command | 3667 | (memq viper-intermediate-command |
| 3668 | '(viper-repeat | 3668 | '(viper-repeat |
| 3669 | viper-digit-argument | 3669 | viper-digit-argument |
| 3670 | viper-command-argument)) | 3670 | viper-command-argument)) |
| @@ -3684,7 +3684,7 @@ Null string will repeat previous search." | |||
| 3684 | (re-search-backward string nil nil val) | 3684 | (re-search-backward string nil nil val) |
| 3685 | (search-backward string nil nil val)) | 3685 | (search-backward string nil nil val)) |
| 3686 | (if (not (equal start-point (point))) | 3686 | (if (not (equal start-point (point))) |
| 3687 | (push-mark start-point t))) | 3687 | (push-mark start-point t))) |
| 3688 | (search-failed | 3688 | (search-failed |
| 3689 | (if (and (not fail-if-not-found) viper-search-wrap-around-t) | 3689 | (if (and (not fail-if-not-found) viper-search-wrap-around-t) |
| 3690 | (progn | 3690 | (progn |
| @@ -3693,7 +3693,7 @@ Null string will repeat previous search." | |||
| 3693 | (viper-search string forward (cons 1 com) t start-point 'fail) | 3693 | (viper-search string forward (cons 1 com) t start-point 'fail) |
| 3694 | ;; don't wait in macros | 3694 | ;; don't wait in macros |
| 3695 | (or executing-kbd-macro | 3695 | (or executing-kbd-macro |
| 3696 | (memq viper-intermediate-command | 3696 | (memq viper-intermediate-command |
| 3697 | '(viper-repeat | 3697 | '(viper-repeat |
| 3698 | viper-digit-argument | 3698 | viper-digit-argument |
| 3699 | viper-command-argument)) | 3699 | viper-command-argument)) |
| @@ -3711,7 +3711,7 @@ Null string will repeat previous search." | |||
| 3711 | ;; highlight the result of search | 3711 | ;; highlight the result of search |
| 3712 | ;; don't wait and don't highlight in macros | 3712 | ;; don't wait and don't highlight in macros |
| 3713 | (or executing-kbd-macro | 3713 | (or executing-kbd-macro |
| 3714 | (memq viper-intermediate-command | 3714 | (memq viper-intermediate-command |
| 3715 | '(viper-repeat viper-digit-argument viper-command-argument)) | 3715 | '(viper-repeat viper-digit-argument viper-command-argument)) |
| 3716 | (viper-flash-search-pattern)) | 3716 | (viper-flash-search-pattern)) |
| 3717 | ))) | 3717 | ))) |
| @@ -3748,7 +3748,7 @@ Null string will repeat previous search." | |||
| 3748 | ((null viper-buffer-search-char) | 3748 | ((null viper-buffer-search-char) |
| 3749 | (setq viper-buffer-search-char ?g))) | 3749 | (setq viper-buffer-search-char ?g))) |
| 3750 | (define-key viper-vi-basic-map | 3750 | (define-key viper-vi-basic-map |
| 3751 | (cond ((viper-characterp viper-buffer-search-char) | 3751 | (cond ((viper-characterp viper-buffer-search-char) |
| 3752 | (char-to-string viper-buffer-search-char)) | 3752 | (char-to-string viper-buffer-search-char)) |
| 3753 | (t (error "viper-buffer-search-char: wrong value type, %s" | 3753 | (t (error "viper-buffer-search-char: wrong value type, %s" |
| 3754 | viper-buffer-search-char))) | 3754 | viper-buffer-search-char))) |
| @@ -3810,14 +3810,14 @@ Null string will repeat previous search." | |||
| 3810 | (get-buffer buffer-name))) | 3810 | (get-buffer buffer-name))) |
| 3811 | (if (null buffer) (error "`%s': No such buffer" buffer-name)) | 3811 | (if (null buffer) (error "`%s': No such buffer" buffer-name)) |
| 3812 | (if (or (not (buffer-modified-p buffer)) | 3812 | (if (or (not (buffer-modified-p buffer)) |
| 3813 | (y-or-n-p | 3813 | (y-or-n-p |
| 3814 | (format | 3814 | (format |
| 3815 | "Buffer `%s' is modified, are you sure you want to kill it? " | 3815 | "Buffer `%s' is modified, are you sure you want to kill it? " |
| 3816 | buffer-name))) | 3816 | buffer-name))) |
| 3817 | (kill-buffer buffer) | 3817 | (kill-buffer buffer) |
| 3818 | (error "Buffer not killed")))) | 3818 | (error "Buffer not killed")))) |
| 3819 | 3819 | ||
| 3820 | 3820 | ||
| 3821 | 3821 | ||
| 3822 | ;; yank and pop | 3822 | ;; yank and pop |
| 3823 | 3823 | ||
| @@ -3866,7 +3866,7 @@ Null string will repeat previous search." | |||
| 3866 | (message "Inserted %d character(s), %d line(s)" | 3866 | (message "Inserted %d character(s), %d line(s)" |
| 3867 | chars-inserted lines-inserted))) | 3867 | chars-inserted lines-inserted))) |
| 3868 | ;; Vi puts cursor on the last char when the yanked text doesn't contain a | 3868 | ;; Vi puts cursor on the last char when the yanked text doesn't contain a |
| 3869 | ;; newline; it leaves the cursor at the beginning when the text contains | 3869 | ;; newline; it leaves the cursor at the beginning when the text contains |
| 3870 | ;; a newline | 3870 | ;; a newline |
| 3871 | (if (viper-same-line (point) (mark)) | 3871 | (if (viper-same-line (point) (mark)) |
| 3872 | (or (= (point) (mark)) (viper-backward-char-carefully)) | 3872 | (or (= (point) (mark)) (viper-backward-char-carefully)) |
| @@ -3908,7 +3908,7 @@ Null string will repeat previous search." | |||
| 3908 | (message "Inserted %d character(s), %d line(s)" | 3908 | (message "Inserted %d character(s), %d line(s)" |
| 3909 | chars-inserted lines-inserted))) | 3909 | chars-inserted lines-inserted))) |
| 3910 | ;; Vi puts cursor on the last char when the yanked text doesn't contain a | 3910 | ;; Vi puts cursor on the last char when the yanked text doesn't contain a |
| 3911 | ;; newline; it leaves the cursor at the beginning when the text contains | 3911 | ;; newline; it leaves the cursor at the beginning when the text contains |
| 3912 | ;; a newline | 3912 | ;; a newline |
| 3913 | (if (viper-same-line (point) (mark)) | 3913 | (if (viper-same-line (point) (mark)) |
| 3914 | (or (= (point) (mark)) (viper-backward-char-carefully)) | 3914 | (or (= (point) (mark)) (viper-backward-char-carefully)) |
| @@ -3916,7 +3916,7 @@ Null string will repeat previous search." | |||
| 3916 | (if (bolp) | 3916 | (if (bolp) |
| 3917 | (back-to-indentation))) | 3917 | (back-to-indentation))) |
| 3918 | (viper-deactivate-mark)) | 3918 | (viper-deactivate-mark)) |
| 3919 | 3919 | ||
| 3920 | 3920 | ||
| 3921 | ;; Copy region to kill-ring. | 3921 | ;; Copy region to kill-ring. |
| 3922 | ;; If BEG and END do not belong to the same buffer, copy empty region. | 3922 | ;; If BEG and END do not belong to the same buffer, copy empty region. |
| @@ -3924,7 +3924,7 @@ Null string will repeat previous search." | |||
| 3924 | (condition-case nil | 3924 | (condition-case nil |
| 3925 | (copy-region-as-kill beg end) | 3925 | (copy-region-as-kill beg end) |
| 3926 | (error (copy-region-as-kill beg beg)))) | 3926 | (error (copy-region-as-kill beg beg)))) |
| 3927 | 3927 | ||
| 3928 | 3928 | ||
| 3929 | (defun viper-delete-char (arg) | 3929 | (defun viper-delete-char (arg) |
| 3930 | "Delete next character." | 3930 | "Delete next character." |
| @@ -3964,7 +3964,7 @@ Null string will repeat previous search." | |||
| 3964 | end-del-pos) | 3964 | end-del-pos) |
| 3965 | (viper-set-destructive-command | 3965 | (viper-set-destructive-command |
| 3966 | (list 'viper-delete-backward-char val nil nil nil nil)) | 3966 | (list 'viper-delete-backward-char val nil nil nil nil)) |
| 3967 | (if (and | 3967 | (if (and |
| 3968 | viper-ex-style-editing | 3968 | viper-ex-style-editing |
| 3969 | (> val (viper-chars-in-region (viper-line-pos 'start) (point)))) | 3969 | (> val (viper-chars-in-region (viper-line-pos 'start) (point)))) |
| 3970 | (setq val (viper-chars-in-region (viper-line-pos 'start) (point)))) | 3970 | (setq val (viper-chars-in-region (viper-line-pos 'start) (point)))) |
| @@ -3984,14 +3984,14 @@ Null string will repeat previous search." | |||
| 3984 | (if (and (bolp) viper-ex-style-editing) | 3984 | (if (and (bolp) viper-ex-style-editing) |
| 3985 | (ding)) | 3985 | (ding)) |
| 3986 | (delete-backward-char val t))) | 3986 | (delete-backward-char val t))) |
| 3987 | 3987 | ||
| 3988 | (defun viper-del-backward-char-in-insert () | 3988 | (defun viper-del-backward-char-in-insert () |
| 3989 | "Delete 1 char backwards while in insert mode." | 3989 | "Delete 1 char backwards while in insert mode." |
| 3990 | (interactive) | 3990 | (interactive) |
| 3991 | (if (and viper-ex-style-editing (bolp)) | 3991 | (if (and viper-ex-style-editing (bolp)) |
| 3992 | (beep 1) | 3992 | (beep 1) |
| 3993 | (delete-backward-char 1 t))) | 3993 | (delete-backward-char 1 t))) |
| 3994 | 3994 | ||
| 3995 | (defun viper-del-backward-char-in-replace () | 3995 | (defun viper-del-backward-char-in-replace () |
| 3996 | "Delete one character in replace mode. | 3996 | "Delete one character in replace mode. |
| 3997 | If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes | 3997 | If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes |
| @@ -4012,7 +4012,7 @@ cursor move past the beginning of line." | |||
| 4012 | (if (bolp) | 4012 | (if (bolp) |
| 4013 | (beep 1) | 4013 | (beep 1) |
| 4014 | (backward-char 1))) | 4014 | (backward-char 1))) |
| 4015 | (t | 4015 | (t |
| 4016 | (backward-char 1)))) | 4016 | (backward-char 1)))) |
| 4017 | 4017 | ||
| 4018 | 4018 | ||
| @@ -4047,7 +4047,7 @@ cursor move past the beginning of line." | |||
| 4047 | (if (markerp end) (setq end (marker-position end))) | 4047 | (if (markerp end) (setq end (marker-position end))) |
| 4048 | ;; beg is sometimes (mark t), which may be nil | 4048 | ;; beg is sometimes (mark t), which may be nil |
| 4049 | (or beg (setq beg end)) | 4049 | (or beg (setq beg end)) |
| 4050 | 4050 | ||
| 4051 | (viper-set-complex-command-for-undo) | 4051 | (viper-set-complex-command-for-undo) |
| 4052 | (if viper-use-register | 4052 | (if viper-use-register |
| 4053 | (progn | 4053 | (progn |
| @@ -4055,14 +4055,14 @@ cursor move past the beginning of line." | |||
| 4055 | (setq viper-use-register nil))) | 4055 | (setq viper-use-register nil))) |
| 4056 | (viper-set-replace-overlay beg end) | 4056 | (viper-set-replace-overlay beg end) |
| 4057 | (setq last-command nil) ; separate repl text from prev kills | 4057 | (setq last-command nil) ; separate repl text from prev kills |
| 4058 | 4058 | ||
| 4059 | (if (= (viper-replace-start) (point-max)) | 4059 | (if (= (viper-replace-start) (point-max)) |
| 4060 | (error "End of buffer")) | 4060 | (error "End of buffer")) |
| 4061 | 4061 | ||
| 4062 | (setq viper-last-replace-region | 4062 | (setq viper-last-replace-region |
| 4063 | (buffer-substring (viper-replace-start) | 4063 | (buffer-substring (viper-replace-start) |
| 4064 | (viper-replace-end))) | 4064 | (viper-replace-end))) |
| 4065 | 4065 | ||
| 4066 | ;; protect against error while inserting "@" and other disasters | 4066 | ;; protect against error while inserting "@" and other disasters |
| 4067 | ;; (e.g., read-only buff) | 4067 | ;; (e.g., read-only buff) |
| 4068 | (condition-case conds | 4068 | (condition-case conds |
| @@ -4074,9 +4074,9 @@ cursor move past the beginning of line." | |||
| 4074 | (goto-char (viper-replace-end)) | 4074 | (goto-char (viper-replace-end)) |
| 4075 | (insert-before-markers "@") ; put placeholder after the TAB | 4075 | (insert-before-markers "@") ; put placeholder after the TAB |
| 4076 | (untabify (viper-replace-start) (point)) | 4076 | (untabify (viper-replace-start) (point)) |
| 4077 | ;; del @, don't put on kill ring | 4077 | ;; del @, don't put on kill ring |
| 4078 | (delete-backward-char 1) | 4078 | (delete-backward-char 1) |
| 4079 | 4079 | ||
| 4080 | (viper-set-replace-overlay-glyphs | 4080 | (viper-set-replace-overlay-glyphs |
| 4081 | viper-replace-region-start-delimiter | 4081 | viper-replace-region-start-delimiter |
| 4082 | viper-replace-region-end-delimiter) | 4082 | viper-replace-region-end-delimiter) |
| @@ -4129,7 +4129,7 @@ cursor move past the beginning of line." | |||
| 4129 | ;; query replace | 4129 | ;; query replace |
| 4130 | 4130 | ||
| 4131 | (defun viper-query-replace () | 4131 | (defun viper-query-replace () |
| 4132 | "Query replace. | 4132 | "Query replace. |
| 4133 | If a null string is suplied as the string to be replaced, | 4133 | If a null string is suplied as the string to be replaced, |
| 4134 | the query replace mode will toggle between string replace | 4134 | the query replace mode will toggle between string replace |
| 4135 | and regexp replace." | 4135 | and regexp replace." |
| @@ -4199,7 +4199,7 @@ and regexp replace." | |||
| 4199 | ((= char ?D) (mark-defun)) | 4199 | ((= char ?D) (mark-defun)) |
| 4200 | (t (error "")) | 4200 | (t (error "")) |
| 4201 | ))) | 4201 | ))) |
| 4202 | 4202 | ||
| 4203 | ;; Algorithm: If first invocation of this command save mark on ring, goto | 4203 | ;; Algorithm: If first invocation of this command save mark on ring, goto |
| 4204 | ;; mark, M0, and pop the most recent elt from the mark ring into mark, | 4204 | ;; mark, M0, and pop the most recent elt from the mark ring into mark, |
| 4205 | ;; making it into the new mark, M1. | 4205 | ;; making it into the new mark, M1. |
| @@ -4217,8 +4217,8 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4217 | (let* ((sv-pt (point))) | 4217 | (let* ((sv-pt (point))) |
| 4218 | ;; if repeated `m,' command, pop the previously saved mark. | 4218 | ;; if repeated `m,' command, pop the previously saved mark. |
| 4219 | ;; Prev saved mark is actually prev saved point. It is used if the | 4219 | ;; Prev saved mark is actually prev saved point. It is used if the |
| 4220 | ;; user types `` or '' and is discarded | 4220 | ;; user types `` or '' and is discarded |
| 4221 | ;; from the mark ring by the next `m,' command. | 4221 | ;; from the mark ring by the next `m,' command. |
| 4222 | ;; In any case, go to the previous or previously saved mark. | 4222 | ;; In any case, go to the previous or previously saved mark. |
| 4223 | ;; Then push the current mark (popped off the ring) and set current | 4223 | ;; Then push the current mark (popped off the ring) and set current |
| 4224 | ;; point to be the mark. Current pt as mark is discarded by the next | 4224 | ;; point to be the mark. Current pt as mark is discarded by the next |
| @@ -4237,7 +4237,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4237 | (viper-deactivate-mark) | 4237 | (viper-deactivate-mark) |
| 4238 | (setq this-command 'viper-cycle-through-mark-ring) | 4238 | (setq this-command 'viper-cycle-through-mark-ring) |
| 4239 | )) | 4239 | )) |
| 4240 | 4240 | ||
| 4241 | 4241 | ||
| 4242 | (defun viper-goto-mark (arg) | 4242 | (defun viper-goto-mark (arg) |
| 4243 | "Go to mark." | 4243 | "Go to mark." |
| @@ -4254,7 +4254,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4254 | (viper-goto-mark-subr char com t))) | 4254 | (viper-goto-mark-subr char com t))) |
| 4255 | 4255 | ||
| 4256 | (defun viper-goto-mark-subr (char com skip-white) | 4256 | (defun viper-goto-mark-subr (char com skip-white) |
| 4257 | (if (eobp) | 4257 | (if (eobp) |
| 4258 | (if (bobp) | 4258 | (if (bobp) |
| 4259 | (error "Empty buffer") | 4259 | (error "Empty buffer") |
| 4260 | (backward-char 1))) | 4260 | (backward-char 1))) |
| @@ -4267,11 +4267,11 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4267 | (error viper-EmptyTextmarker char)) | 4267 | (error viper-EmptyTextmarker char)) |
| 4268 | (if (and (viper-same-line (point) viper-last-jump) | 4268 | (if (and (viper-same-line (point) viper-last-jump) |
| 4269 | (= (point) viper-last-jump-ignore)) | 4269 | (= (point) viper-last-jump-ignore)) |
| 4270 | (push-mark viper-last-jump t) | 4270 | (push-mark viper-last-jump t) |
| 4271 | (push-mark nil t)) ; no msg | 4271 | (push-mark nil t)) ; no msg |
| 4272 | (viper-register-to-point reg) | 4272 | (viper-register-to-point reg) |
| 4273 | (setq viper-last-jump (point-marker)) | 4273 | (setq viper-last-jump (point-marker)) |
| 4274 | (cond (skip-white | 4274 | (cond (skip-white |
| 4275 | (back-to-indentation) | 4275 | (back-to-indentation) |
| 4276 | (setq viper-last-jump-ignore (point)))) | 4276 | (setq viper-last-jump-ignore (point)))) |
| 4277 | (if com | 4277 | (if com |
| @@ -4307,7 +4307,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4307 | (setq viper-last-jump-ignore (point)) | 4307 | (setq viper-last-jump-ignore (point)) |
| 4308 | (if com (viper-execute-com 'viper-goto-mark-and-skip-white nil com))) | 4308 | (if com (viper-execute-com 'viper-goto-mark-and-skip-white nil com))) |
| 4309 | (t (error viper-InvalidTextmarker char)))) | 4309 | (t (error viper-InvalidTextmarker char)))) |
| 4310 | 4310 | ||
| 4311 | (defun viper-insert-tab () | 4311 | (defun viper-insert-tab () |
| 4312 | (interactive) | 4312 | (interactive) |
| 4313 | (insert-tab)) | 4313 | (insert-tab)) |
| @@ -4383,7 +4383,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4383 | )) | 4383 | )) |
| 4384 | )) | 4384 | )) |
| 4385 | 4385 | ||
| 4386 | 4386 | ||
| 4387 | ;; Viewing registers | 4387 | ;; Viewing registers |
| 4388 | 4388 | ||
| 4389 | (defun viper-ket-function (arg) | 4389 | (defun viper-ket-function (arg) |
| @@ -4421,7 +4421,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4421 | (with-output-to-temp-buffer " *viper-info*" | 4421 | (with-output-to-temp-buffer " *viper-info*" |
| 4422 | (if (and buf pos) | 4422 | (if (and buf pos) |
| 4423 | (progn | 4423 | (progn |
| 4424 | (save-excursion | 4424 | (save-excursion |
| 4425 | (set-buffer buf) | 4425 | (set-buffer buf) |
| 4426 | (setq line-no (1+ (count-lines (point-min) val))) | 4426 | (setq line-no (1+ (count-lines (point-min) val))) |
| 4427 | (goto-char pos) | 4427 | (goto-char pos) |
| @@ -4437,19 +4437,19 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4437 | (end-of-line) | 4437 | (end-of-line) |
| 4438 | (setq e (point)))) | 4438 | (setq e (point)))) |
| 4439 | (setq text (buffer-substring s e)) | 4439 | (setq text (buffer-substring s e)) |
| 4440 | (setq text (format "%s<%c>%s" | 4440 | (setq text (format "%s<%c>%s" |
| 4441 | (substring text 0 (- pos s)) | 4441 | (substring text 0 (- pos s)) |
| 4442 | reg (substring text (- pos s))))) | 4442 | reg (substring text (- pos s))))) |
| 4443 | (princ | 4443 | (princ |
| 4444 | (format | 4444 | (format |
| 4445 | "Textmarker `%c' is in buffer `%s' at line %d.\n" | 4445 | "Textmarker `%c' is in buffer `%s' at line %d.\n" |
| 4446 | reg (buffer-name buf) line-no)) | 4446 | reg (buffer-name buf) line-no)) |
| 4447 | (princ (format "Here is some text around %c:\n\n %s" | 4447 | (princ (format "Here is some text around %c:\n\n %s" |
| 4448 | reg text))) | 4448 | reg text))) |
| 4449 | (princ (format viper-EmptyTextmarker reg)))) | 4449 | (princ (format viper-EmptyTextmarker reg)))) |
| 4450 | )) | 4450 | )) |
| 4451 | (t (error viper-InvalidTextmarker reg))))) | 4451 | (t (error viper-InvalidTextmarker reg))))) |
| 4452 | 4452 | ||
| 4453 | 4453 | ||
| 4454 | 4454 | ||
| 4455 | ;; commands in insertion mode | 4455 | ;; commands in insertion mode |
| @@ -4475,24 +4475,24 @@ meaningless (i.e., not one of 1,2,3,4,5). | |||
| 4475 | 4475 | ||
| 4476 | User level determines the setting of Viper variables that are most | 4476 | User level determines the setting of Viper variables that are most |
| 4477 | sensitive for VI-style look-and-feel." | 4477 | sensitive for VI-style look-and-feel." |
| 4478 | 4478 | ||
| 4479 | (interactive) | 4479 | (interactive) |
| 4480 | 4480 | ||
| 4481 | (if (not (natnump viper-expert-level)) (setq viper-expert-level 0)) | 4481 | (if (not (natnump viper-expert-level)) (setq viper-expert-level 0)) |
| 4482 | 4482 | ||
| 4483 | (save-window-excursion | 4483 | (save-window-excursion |
| 4484 | (delete-other-windows) | 4484 | (delete-other-windows) |
| 4485 | ;; if 0 < viper-expert-level < viper-max-expert-level | 4485 | ;; if 0 < viper-expert-level < viper-max-expert-level |
| 4486 | ;; & dont-change-unless = t -- use it; else ask | 4486 | ;; & dont-change-unless = t -- use it; else ask |
| 4487 | (viper-ask-level dont-change-unless)) | 4487 | (viper-ask-level dont-change-unless)) |
| 4488 | 4488 | ||
| 4489 | (setq viper-always t | 4489 | (setq viper-always t |
| 4490 | viper-ex-style-motion t | 4490 | viper-ex-style-motion t |
| 4491 | viper-ex-style-editing t | 4491 | viper-ex-style-editing t |
| 4492 | viper-want-ctl-h-help nil) | 4492 | viper-want-ctl-h-help nil) |
| 4493 | 4493 | ||
| 4494 | (cond ((eq viper-expert-level 1) ; novice or beginner | 4494 | (cond ((eq viper-expert-level 1) ; novice or beginner |
| 4495 | (global-set-key ; in emacs-state | 4495 | (global-set-key ; in emacs-state |
| 4496 | viper-toggle-key | 4496 | viper-toggle-key |
| 4497 | (if (viper-window-display-p) 'viper-iconify 'suspend-emacs)) | 4497 | (if (viper-window-display-p) 'viper-iconify 'suspend-emacs)) |
| 4498 | (setq viper-no-multiple-ESC t | 4498 | (setq viper-no-multiple-ESC t |
| @@ -4502,7 +4502,7 @@ sensitive for VI-style look-and-feel." | |||
| 4502 | viper-electric-mode nil | 4502 | viper-electric-mode nil |
| 4503 | viper-want-emacs-keys-in-vi nil | 4503 | viper-want-emacs-keys-in-vi nil |
| 4504 | viper-want-emacs-keys-in-insert nil)) | 4504 | viper-want-emacs-keys-in-insert nil)) |
| 4505 | 4505 | ||
| 4506 | ((and (> viper-expert-level 1) (< viper-expert-level 5)) | 4506 | ((and (> viper-expert-level 1) (< viper-expert-level 5)) |
| 4507 | ;; intermediate to guru | 4507 | ;; intermediate to guru |
| 4508 | (setq viper-no-multiple-ESC (if (viper-window-display-p) | 4508 | (setq viper-no-multiple-ESC (if (viper-window-display-p) |
| @@ -4519,15 +4519,15 @@ sensitive for VI-style look-and-feel." | |||
| 4519 | (viper-standard-value 'viper-ex-style-editing) | 4519 | (viper-standard-value 'viper-ex-style-editing) |
| 4520 | viper-ex-style-motion | 4520 | viper-ex-style-motion |
| 4521 | (viper-standard-value 'viper-ex-style-motion)) | 4521 | (viper-standard-value 'viper-ex-style-motion)) |
| 4522 | (setq viper-ex-style-motion | 4522 | (setq viper-ex-style-motion |
| 4523 | (viper-standard-value 'viper-ex-style-motion) | 4523 | (viper-standard-value 'viper-ex-style-motion) |
| 4524 | viper-ex-style-editing | 4524 | viper-ex-style-editing |
| 4525 | (viper-standard-value 'viper-ex-style-editing) | 4525 | (viper-standard-value 'viper-ex-style-editing) |
| 4526 | viper-re-search | 4526 | viper-re-search |
| 4527 | (viper-standard-value 'viper-re-search) | 4527 | (viper-standard-value 'viper-re-search) |
| 4528 | viper-no-multiple-ESC | 4528 | viper-no-multiple-ESC |
| 4529 | (viper-standard-value 'viper-no-multiple-ESC))))) | 4529 | (viper-standard-value 'viper-no-multiple-ESC))))) |
| 4530 | 4530 | ||
| 4531 | ;; A wizard!! | 4531 | ;; A wizard!! |
| 4532 | ;; Ideally, if 5 is selected, a buffer should pop up to let the | 4532 | ;; Ideally, if 5 is selected, a buffer should pop up to let the |
| 4533 | ;; user toggle the values of variables. | 4533 | ;; user toggle the values of variables. |
| @@ -4535,25 +4535,25 @@ sensitive for VI-style look-and-feel." | |||
| 4535 | (viper-standard-value 'viper-ex-style-editing) | 4535 | (viper-standard-value 'viper-ex-style-editing) |
| 4536 | viper-ex-style-motion | 4536 | viper-ex-style-motion |
| 4537 | (viper-standard-value 'viper-ex-style-motion)) | 4537 | (viper-standard-value 'viper-ex-style-motion)) |
| 4538 | (setq viper-want-ctl-h-help | 4538 | (setq viper-want-ctl-h-help |
| 4539 | (viper-standard-value 'viper-want-ctl-h-help) | 4539 | (viper-standard-value 'viper-want-ctl-h-help) |
| 4540 | viper-always | 4540 | viper-always |
| 4541 | (viper-standard-value 'viper-always) | 4541 | (viper-standard-value 'viper-always) |
| 4542 | viper-no-multiple-ESC | 4542 | viper-no-multiple-ESC |
| 4543 | (viper-standard-value 'viper-no-multiple-ESC) | 4543 | (viper-standard-value 'viper-no-multiple-ESC) |
| 4544 | viper-ex-style-motion | 4544 | viper-ex-style-motion |
| 4545 | (viper-standard-value 'viper-ex-style-motion) | 4545 | (viper-standard-value 'viper-ex-style-motion) |
| 4546 | viper-ex-style-editing | 4546 | viper-ex-style-editing |
| 4547 | (viper-standard-value 'viper-ex-style-editing) | 4547 | (viper-standard-value 'viper-ex-style-editing) |
| 4548 | viper-re-search | 4548 | viper-re-search |
| 4549 | (viper-standard-value 'viper-re-search) | 4549 | (viper-standard-value 'viper-re-search) |
| 4550 | viper-electric-mode | 4550 | viper-electric-mode |
| 4551 | (viper-standard-value 'viper-electric-mode) | 4551 | (viper-standard-value 'viper-electric-mode) |
| 4552 | viper-want-emacs-keys-in-vi | 4552 | viper-want-emacs-keys-in-vi |
| 4553 | (viper-standard-value 'viper-want-emacs-keys-in-vi) | 4553 | (viper-standard-value 'viper-want-emacs-keys-in-vi) |
| 4554 | viper-want-emacs-keys-in-insert | 4554 | viper-want-emacs-keys-in-insert |
| 4555 | (viper-standard-value 'viper-want-emacs-keys-in-insert)))) | 4555 | (viper-standard-value 'viper-want-emacs-keys-in-insert)))) |
| 4556 | 4556 | ||
| 4557 | (viper-set-mode-vars-for viper-current-state) | 4557 | (viper-set-mode-vars-for viper-current-state) |
| 4558 | (if (or viper-always | 4558 | (if (or viper-always |
| 4559 | (and (> viper-expert-level 0) (> 5 viper-expert-level))) | 4559 | (and (> viper-expert-level 0) (> 5 viper-expert-level))) |
| @@ -4565,7 +4565,7 @@ sensitive for VI-style look-and-feel." | |||
| 4565 | level-changed repeated) | 4565 | level-changed repeated) |
| 4566 | (save-window-excursion | 4566 | (save-window-excursion |
| 4567 | (switch-to-buffer ask-buffer) | 4567 | (switch-to-buffer ask-buffer) |
| 4568 | 4568 | ||
| 4569 | (while (or (> viper-expert-level viper-max-expert-level) | 4569 | (while (or (> viper-expert-level viper-max-expert-level) |
| 4570 | (< viper-expert-level 1) | 4570 | (< viper-expert-level 1) |
| 4571 | (null dont-change-unless)) | 4571 | (null dont-change-unless)) |
| @@ -4581,10 +4581,10 @@ sensitive for VI-style look-and-feel." | |||
| 4581 | Please specify your level of familiarity with the venomous VI PERil | 4581 | Please specify your level of familiarity with the venomous VI PERil |
| 4582 | (and the VI Plan for Emacs Rescue). | 4582 | (and the VI Plan for Emacs Rescue). |
| 4583 | You can change it at any time by typing `M-x viper-set-expert-level RET' | 4583 | You can change it at any time by typing `M-x viper-set-expert-level RET' |
| 4584 | 4584 | ||
| 4585 | 1 -- BEGINNER: Almost all Emacs features are suppressed. | 4585 | 1 -- BEGINNER: Almost all Emacs features are suppressed. |
| 4586 | Feels almost like straight Vi. File name completion and | 4586 | Feels almost like straight Vi. File name completion and |
| 4587 | command history in the minibuffer are thrown in as a bonus. | 4587 | command history in the minibuffer are thrown in as a bonus. |
| 4588 | To use Emacs productively, you must reach level 3 or higher. | 4588 | To use Emacs productively, you must reach level 3 or higher. |
| 4589 | 2 -- MASTER: C-c now has its standard Emacs meaning in Vi command state, | 4589 | 2 -- MASTER: C-c now has its standard Emacs meaning in Vi command state, |
| 4590 | so most Emacs commands can be used when Viper is in Vi state. | 4590 | so most Emacs commands can be used when Viper is in Vi state. |
| @@ -4597,12 +4597,12 @@ You can change it at any time by typing `M-x viper-set-expert-level RET' | |||
| 4597 | 5 -- WIZARD: Like 4, but user settings are also respected for viper-always, | 4597 | 5 -- WIZARD: Like 4, but user settings are also respected for viper-always, |
| 4598 | viper-electric-mode, viper-want-ctl-h-help, viper-want-emacs-keys-in-vi, | 4598 | viper-electric-mode, viper-want-ctl-h-help, viper-want-emacs-keys-in-vi, |
| 4599 | and viper-want-emacs-keys-in-insert. Adjust these to your taste. | 4599 | and viper-want-emacs-keys-in-insert. Adjust these to your taste. |
| 4600 | 4600 | ||
| 4601 | Please, specify your level now: ") | 4601 | Please, specify your level now: ") |
| 4602 | 4602 | ||
| 4603 | (setq viper-expert-level (- (viper-read-char-exclusive) ?0)) | 4603 | (setq viper-expert-level (- (viper-read-char-exclusive) ?0)) |
| 4604 | ) ; end while | 4604 | ) ; end while |
| 4605 | 4605 | ||
| 4606 | ;; tell the user if level was changed | 4606 | ;; tell the user if level was changed |
| 4607 | (and level-changed | 4607 | (and level-changed |
| 4608 | (progn | 4608 | (progn |
| @@ -4624,8 +4624,8 @@ Please, specify your level now: ") | |||
| 4624 | (defun viper-nil () | 4624 | (defun viper-nil () |
| 4625 | (interactive) | 4625 | (interactive) |
| 4626 | (beep 1)) | 4626 | (beep 1)) |
| 4627 | 4627 | ||
| 4628 | 4628 | ||
| 4629 | ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer | 4629 | ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer |
| 4630 | (defun viper-register-to-point (char &optional enforce-buffer) | 4630 | (defun viper-register-to-point (char &optional enforce-buffer) |
| 4631 | "Like jump-to-register, but switches to another buffer in another window." | 4631 | "Like jump-to-register, but switches to another buffer in another window." |
| @@ -4670,17 +4670,17 @@ Please, specify your level now: ") | |||
| 4670 | color-display-p frame-parameters | 4670 | color-display-p frame-parameters |
| 4671 | minibuffer-emacs-face minibuffer-vi-face minibuffer-insert-face | 4671 | minibuffer-emacs-face minibuffer-vi-face minibuffer-insert-face |
| 4672 | varlist salutation window-config) | 4672 | varlist salutation window-config) |
| 4673 | 4673 | ||
| 4674 | ;; If mode info is needed, add variable to `let' and then set it below, | 4674 | ;; If mode info is needed, add variable to `let' and then set it below, |
| 4675 | ;; like we did with color-display-p. | 4675 | ;; like we did with color-display-p. |
| 4676 | (setq color-display-p (if (viper-window-display-p) | 4676 | (setq color-display-p (if (viper-window-display-p) |
| 4677 | (viper-color-display-p) | 4677 | (viper-color-display-p) |
| 4678 | 'non-x) | 4678 | 'non-x) |
| 4679 | minibuffer-vi-face (if (viper-has-face-support-p) | 4679 | minibuffer-vi-face (if (viper-has-face-support-p) |
| 4680 | (viper-get-face viper-minibuffer-vi-face) | 4680 | (viper-get-face viper-minibuffer-vi-face) |
| 4681 | 'non-x) | 4681 | 'non-x) |
| 4682 | minibuffer-insert-face (if (viper-has-face-support-p) | 4682 | minibuffer-insert-face (if (viper-has-face-support-p) |
| 4683 | (viper-get-face | 4683 | (viper-get-face |
| 4684 | viper-minibuffer-insert-face) | 4684 | viper-minibuffer-insert-face) |
| 4685 | 'non-x) | 4685 | 'non-x) |
| 4686 | minibuffer-emacs-face (if (viper-has-face-support-p) | 4686 | minibuffer-emacs-face (if (viper-has-face-support-p) |
| @@ -4689,27 +4689,27 @@ Please, specify your level now: ") | |||
| 4689 | 'non-x) | 4689 | 'non-x) |
| 4690 | frame-parameters (if (fboundp 'frame-parameters) | 4690 | frame-parameters (if (fboundp 'frame-parameters) |
| 4691 | (frame-parameters (selected-frame)))) | 4691 | (frame-parameters (selected-frame)))) |
| 4692 | 4692 | ||
| 4693 | (setq varlist (list 'viper-vi-minibuffer-minor-mode | 4693 | (setq varlist (list 'viper-vi-minibuffer-minor-mode |
| 4694 | 'viper-insert-minibuffer-minor-mode | 4694 | 'viper-insert-minibuffer-minor-mode |
| 4695 | 'viper-vi-intercept-minor-mode | 4695 | 'viper-vi-intercept-minor-mode |
| 4696 | 'viper-vi-local-user-minor-mode | 4696 | 'viper-vi-local-user-minor-mode |
| 4697 | 'viper-vi-kbd-minor-mode | 4697 | 'viper-vi-kbd-minor-mode |
| 4698 | 'viper-vi-global-user-minor-mode | 4698 | 'viper-vi-global-user-minor-mode |
| 4699 | 'viper-vi-state-modifier-minor-mode | 4699 | 'viper-vi-state-modifier-minor-mode |
| 4700 | 'viper-vi-diehard-minor-mode | 4700 | 'viper-vi-diehard-minor-mode |
| 4701 | 'viper-vi-basic-minor-mode | 4701 | 'viper-vi-basic-minor-mode |
| 4702 | 'viper-replace-minor-mode | 4702 | 'viper-replace-minor-mode |
| 4703 | 'viper-insert-intercept-minor-mode | 4703 | 'viper-insert-intercept-minor-mode |
| 4704 | 'viper-insert-local-user-minor-mode | 4704 | 'viper-insert-local-user-minor-mode |
| 4705 | 'viper-insert-kbd-minor-mode | 4705 | 'viper-insert-kbd-minor-mode |
| 4706 | 'viper-insert-global-user-minor-mode | 4706 | 'viper-insert-global-user-minor-mode |
| 4707 | 'viper-insert-state-modifier-minor-mode | 4707 | 'viper-insert-state-modifier-minor-mode |
| 4708 | 'viper-insert-diehard-minor-mode | 4708 | 'viper-insert-diehard-minor-mode |
| 4709 | 'viper-insert-basic-minor-mode | 4709 | 'viper-insert-basic-minor-mode |
| 4710 | 'viper-emacs-intercept-minor-mode | 4710 | 'viper-emacs-intercept-minor-mode |
| 4711 | 'viper-emacs-local-user-minor-mode | 4711 | 'viper-emacs-local-user-minor-mode |
| 4712 | 'viper-emacs-kbd-minor-mode | 4712 | 'viper-emacs-kbd-minor-mode |
| 4713 | 'viper-emacs-global-user-minor-mode | 4713 | 'viper-emacs-global-user-minor-mode |
| 4714 | 'viper-emacs-state-modifier-minor-mode | 4714 | 'viper-emacs-state-modifier-minor-mode |
| 4715 | 'viper-automatic-iso-accents | 4715 | 'viper-automatic-iso-accents |
| @@ -4766,7 +4766,7 @@ If you are reporting an error message received while executing one of the | |||
| 4766 | Viper commands, type: | 4766 | Viper commands, type: |
| 4767 | 4767 | ||
| 4768 | M-x set-variable <Return> debug-on-error <Return> t <Return> | 4768 | M-x set-variable <Return> debug-on-error <Return> t <Return> |
| 4769 | 4769 | ||
| 4770 | Then reproduce the error. The above command will cause Emacs to produce a | 4770 | Then reproduce the error. The above command will cause Emacs to produce a |
| 4771 | back trace of the execution that leads to the error. Please include this | 4771 | back trace of the execution that leads to the error. Please include this |
| 4772 | trace in your bug report. | 4772 | trace in your bug report. |
| @@ -4775,7 +4775,7 @@ If you believe that one of Viper's commands goes into an infinite loop | |||
| 4775 | \(e.g., Emacs freezes\), type: | 4775 | \(e.g., Emacs freezes\), type: |
| 4776 | 4776 | ||
| 4777 | M-x set-variable <Return> debug-on-quit <Return> t <Return> | 4777 | M-x set-variable <Return> debug-on-quit <Return> t <Return> |
| 4778 | 4778 | ||
| 4779 | Then reproduce the problem. Wait for a few seconds, then type C-g to abort | 4779 | Then reproduce the problem. Wait for a few seconds, then type C-g to abort |
| 4780 | the current command. Include the resulting back trace in the bug report. | 4780 | the current command. Include the resulting back trace in the bug report. |
| 4781 | 4781 | ||
| @@ -4787,17 +4787,17 @@ Mail anyway (y or n)? ") | |||
| 4787 | 4787 | ||
| 4788 | (require 'reporter) | 4788 | (require 'reporter) |
| 4789 | (set-window-configuration window-config) | 4789 | (set-window-configuration window-config) |
| 4790 | 4790 | ||
| 4791 | (reporter-submit-bug-report "kifer@cs.sunysb.edu" | 4791 | (reporter-submit-bug-report "kifer@cs.sunysb.edu" |
| 4792 | (viper-version) | 4792 | (viper-version) |
| 4793 | varlist | 4793 | varlist |
| 4794 | nil 'delete-other-windows | 4794 | nil 'delete-other-windows |
| 4795 | salutation) | 4795 | salutation) |
| 4796 | )) | 4796 | )) |
| 4797 | |||
| 4798 | 4797 | ||
| 4799 | 4798 | ||
| 4800 | 4799 | ||
| 4800 | |||
| 4801 | ;; Smoothes out the difference between Emacs' unread-command-events | 4801 | ;; Smoothes out the difference between Emacs' unread-command-events |
| 4802 | ;; and XEmacs unread-command-event. Arg is a character, an event, a list of | 4802 | ;; and XEmacs unread-command-event. Arg is a character, an event, a list of |
| 4803 | ;; events or a sequence of keys. | 4803 | ;; events or a sequence of keys. |
| @@ -4844,7 +4844,7 @@ Mail anyway (y or n)? ") | |||
| 4844 | "viper-eventify-list-xemacs: can't convert to event, %S" | 4844 | "viper-eventify-list-xemacs: can't convert to event, %S" |
| 4845 | elt)))) | 4845 | elt)))) |
| 4846 | lis)) | 4846 | lis)) |
| 4847 | 4847 | ||
| 4848 | 4848 | ||
| 4849 | 4849 | ||
| 4850 | ;;; viper-cmd.el ends here | 4850 | ;;; viper-cmd.el ends here |
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index a3c658bd088..acc95b1ef05 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | ;; Viper version | 39 | ;; Viper version |
| 40 | (defun viper-version () | 40 | (defun viper-version () |
| 41 | (interactive) | 41 | (interactive) |
| 42 | (message "Viper version is %s" viper-version)) | 42 | (message "Viper version is %s" viper-version)) |
| 43 | 43 | ||
| 44 | ;; Is it XEmacs? | 44 | ;; Is it XEmacs? |
| 45 | (defconst viper-xemacs-p (string-match "XEmacs" emacs-version)) | 45 | (defconst viper-xemacs-p (string-match "XEmacs" emacs-version)) |
| @@ -84,52 +84,48 @@ In all likelihood, you don't need to bother with this setting." | |||
| 84 | ;;; Macros | 84 | ;;; Macros |
| 85 | 85 | ||
| 86 | (defmacro viper-deflocalvar (var default-value &optional documentation) | 86 | (defmacro viper-deflocalvar (var default-value &optional documentation) |
| 87 | (` (progn | 87 | `(progn |
| 88 | (defvar (, var) (, default-value) | 88 | (defvar ,var ,default-value |
| 89 | (, (format "%s\n\(buffer local\)" documentation))) | 89 | ,(format "%s\n\(buffer local\)" documentation)) |
| 90 | (make-variable-buffer-local '(, var)) | 90 | (make-variable-buffer-local ',var))) |
| 91 | ))) | ||
| 92 | 91 | ||
| 93 | ;; (viper-loop COUNT BODY) Execute BODY COUNT times. | 92 | ;; (viper-loop COUNT BODY) Execute BODY COUNT times. |
| 94 | (defmacro viper-loop (count &rest body) | 93 | (defmacro viper-loop (count &rest body) |
| 95 | (` (let ((count (, count))) | 94 | `(let ((count ,count)) |
| 96 | (while (> count 0) | 95 | (while (> count 0) |
| 97 | (progn | 96 | ,@body |
| 98 | (,@ body) | 97 | (setq count (1- count))))) |
| 99 | (setq count (1- count)) | ||
| 100 | )) | ||
| 101 | ))) | ||
| 102 | 98 | ||
| 103 | (defmacro viper-buffer-live-p (buf) | 99 | (defmacro viper-buffer-live-p (buf) |
| 104 | (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) | 100 | `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf)))) |
| 105 | 101 | ||
| 106 | ;; return buffer-specific macro definition, given a full macro definition | 102 | ;; return buffer-specific macro definition, given a full macro definition |
| 107 | (defmacro viper-kbd-buf-alist (macro-elt) | 103 | (defmacro viper-kbd-buf-alist (macro-elt) |
| 108 | (` (nth 1 (, macro-elt)))) | 104 | `(nth 1 ,macro-elt)) |
| 109 | ;; get a pair: (curr-buffer . macro-definition) | 105 | ;; get a pair: (curr-buffer . macro-definition) |
| 110 | (defmacro viper-kbd-buf-pair (macro-elt) | 106 | (defmacro viper-kbd-buf-pair (macro-elt) |
| 111 | (` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt))))) | 107 | `(assoc (buffer-name) (viper-kbd-buf-alist ,macro-elt))) |
| 112 | ;; get macro definition for current buffer | 108 | ;; get macro definition for current buffer |
| 113 | (defmacro viper-kbd-buf-definition (macro-elt) | 109 | (defmacro viper-kbd-buf-definition (macro-elt) |
| 114 | (` (cdr (viper-kbd-buf-pair (, macro-elt))))) | 110 | `(cdr (viper-kbd-buf-pair ,macro-elt))) |
| 115 | 111 | ||
| 116 | ;; return mode-specific macro definitions, given a full macro definition | 112 | ;; return mode-specific macro definitions, given a full macro definition |
| 117 | (defmacro viper-kbd-mode-alist (macro-elt) | 113 | (defmacro viper-kbd-mode-alist (macro-elt) |
| 118 | (` (nth 2 (, macro-elt)))) | 114 | `(nth 2 ,macro-elt)) |
| 119 | ;; get a pair: (major-mode . macro-definition) | 115 | ;; get a pair: (major-mode . macro-definition) |
| 120 | (defmacro viper-kbd-mode-pair (macro-elt) | 116 | (defmacro viper-kbd-mode-pair (macro-elt) |
| 121 | (` (assoc major-mode (viper-kbd-mode-alist (, macro-elt))))) | 117 | `(assoc major-mode (viper-kbd-mode-alist ,macro-elt))) |
| 122 | ;; get macro definition for the current major mode | 118 | ;; get macro definition for the current major mode |
| 123 | (defmacro viper-kbd-mode-definition (macro-elt) | 119 | (defmacro viper-kbd-mode-definition (macro-elt) |
| 124 | (` (cdr (viper-kbd-mode-pair (, macro-elt))))) | 120 | `(cdr (viper-kbd-mode-pair ,macro-elt))) |
| 125 | 121 | ||
| 126 | ;; return global macro definition, given a full macro definition | 122 | ;; return global macro definition, given a full macro definition |
| 127 | (defmacro viper-kbd-global-pair (macro-elt) | 123 | (defmacro viper-kbd-global-pair (macro-elt) |
| 128 | (` (nth 3 (, macro-elt)))) | 124 | `(nth 3 ,macro-elt)) |
| 129 | ;; get global macro definition from an elt of macro-alist | 125 | ;; get global macro definition from an elt of macro-alist |
| 130 | (defmacro viper-kbd-global-definition (macro-elt) | 126 | (defmacro viper-kbd-global-definition (macro-elt) |
| 131 | (` (cdr (viper-kbd-global-pair (, macro-elt))))) | 127 | `(cdr (viper-kbd-global-pair ,macro-elt))) |
| 132 | 128 | ||
| 133 | ;; last elt of a sequence | 129 | ;; last elt of a sequence |
| 134 | (defsubst viper-seq-last-elt (seq) | 130 | (defsubst viper-seq-last-elt (seq) |
| 135 | (elt seq (1- (length seq)))) | 131 | (elt seq (1- (length seq)))) |
| @@ -146,12 +142,12 @@ In all likelihood, you don't need to bother with this setting." | |||
| 146 | (if (eq direction 'forward) | 142 | (if (eq direction 'forward) |
| 147 | (char-after (+ (point) offset)) | 143 | (char-after (+ (point) offset)) |
| 148 | (char-before (- (point) offset)))) | 144 | (char-before (- (point) offset)))) |
| 149 | 145 | ||
| 150 | 146 | ||
| 151 | (defvar viper-minibuffer-overlay-priority 300) | 147 | (defvar viper-minibuffer-overlay-priority 300) |
| 152 | (defvar viper-replace-overlay-priority 400) | 148 | (defvar viper-replace-overlay-priority 400) |
| 153 | (defvar viper-search-overlay-priority 500) | 149 | (defvar viper-search-overlay-priority 500) |
| 154 | 150 | ||
| 155 | 151 | ||
| 156 | ;;; Viper minor modes | 152 | ;;; Viper minor modes |
| 157 | 153 | ||
| @@ -160,7 +156,7 @@ In all likelihood, you don't need to bother with this setting." | |||
| 160 | 156 | ||
| 161 | (viper-deflocalvar viper-vi-basic-minor-mode nil | 157 | (viper-deflocalvar viper-vi-basic-minor-mode nil |
| 162 | "Viper's minor mode for Vi bindings.") | 158 | "Viper's minor mode for Vi bindings.") |
| 163 | 159 | ||
| 164 | (viper-deflocalvar viper-vi-local-user-minor-mode nil | 160 | (viper-deflocalvar viper-vi-local-user-minor-mode nil |
| 165 | "Auxiliary minor mode for user-defined local bindings in Vi state.") | 161 | "Auxiliary minor mode for user-defined local bindings in Vi state.") |
| 166 | 162 | ||
| @@ -211,16 +207,16 @@ the Ex command :map!.") | |||
| 211 | ;; is invoked. So, any new buffer will have C-z defined as switch to Vi, | 207 | ;; is invoked. So, any new buffer will have C-z defined as switch to Vi, |
| 212 | ;; unless we switched states in this buffer | 208 | ;; unless we switched states in this buffer |
| 213 | (viper-deflocalvar viper-emacs-intercept-minor-mode nil) | 209 | (viper-deflocalvar viper-emacs-intercept-minor-mode nil) |
| 214 | 210 | ||
| 215 | (viper-deflocalvar viper-emacs-local-user-minor-mode nil | 211 | (viper-deflocalvar viper-emacs-local-user-minor-mode nil |
| 216 | "Minor mode for local user bindings effective in Emacs state. | 212 | "Minor mode for local user bindings effective in Emacs state. |
| 217 | Users can use it to override Emacs bindings when Viper is in its Emacs | 213 | Users can use it to override Emacs bindings when Viper is in its Emacs |
| 218 | state.") | 214 | state.") |
| 219 | 215 | ||
| 220 | (viper-deflocalvar viper-emacs-global-user-minor-mode nil | 216 | (viper-deflocalvar viper-emacs-global-user-minor-mode nil |
| 221 | "Minor mode for global user bindings in effect in Emacs state. | 217 | "Minor mode for global user bindings in effect in Emacs state. |
| 222 | Users can use it to override Emacs bindings when Viper is in its Emacs | 218 | Users can use it to override Emacs bindings when Viper is in its Emacs |
| 223 | state.") | 219 | state.") |
| 224 | 220 | ||
| 225 | (viper-deflocalvar viper-emacs-kbd-minor-mode nil | 221 | (viper-deflocalvar viper-emacs-kbd-minor-mode nil |
| 226 | "Minor mode for Vi style macros in Emacs state. | 222 | "Minor mode for Vi style macros in Emacs state. |
| @@ -238,7 +234,7 @@ that deletes a file.") | |||
| 238 | 234 | ||
| 239 | (viper-deflocalvar viper-insert-minibuffer-minor-mode nil | 235 | (viper-deflocalvar viper-insert-minibuffer-minor-mode nil |
| 240 | "Minor mode that forces Vi-style when the Minibuffer is in Insert state.") | 236 | "Minor mode that forces Vi-style when the Minibuffer is in Insert state.") |
| 241 | 237 | ||
| 242 | 238 | ||
| 243 | 239 | ||
| 244 | ;; Some common error messages | 240 | ;; Some common error messages |
| @@ -256,7 +252,7 @@ that deletes a file.") | |||
| 256 | (defconst viper-FirstAddrExceedsSecond "First address exceeds second" "") | 252 | (defconst viper-FirstAddrExceedsSecond "First address exceeds second" "") |
| 257 | (defconst viper-NoFileSpecified "No file specified" "") | 253 | (defconst viper-NoFileSpecified "No file specified" "") |
| 258 | 254 | ||
| 259 | ;; Is t until viper-mode executes for the very first time. | 255 | ;; Is t until viper-mode executes for the very first time. |
| 260 | ;; Prevents recursive descend into startup messages. | 256 | ;; Prevents recursive descend into startup messages. |
| 261 | (defvar viper-first-time t) | 257 | (defvar viper-first-time t) |
| 262 | 258 | ||
| @@ -283,13 +279,13 @@ Use `M-x viper-set-expert-level' to change this.") | |||
| 283 | (defsubst viper-set-iso-accents-mode (arg) | 279 | (defsubst viper-set-iso-accents-mode (arg) |
| 284 | (if (boundp 'iso-accents-mode) | 280 | (if (boundp 'iso-accents-mode) |
| 285 | (setq iso-accents-mode arg))) | 281 | (setq iso-accents-mode arg))) |
| 286 | 282 | ||
| 287 | ;; Internal flag used to control when viper mule hooks are run. | 283 | ;; Internal flag used to control when viper mule hooks are run. |
| 288 | ;; Don't change this! | 284 | ;; Don't change this! |
| 289 | (defvar viper-mule-hook-flag t) | 285 | (defvar viper-mule-hook-flag t) |
| 290 | ;; If non-nil, the default intl. input method is turned on. | 286 | ;; If non-nil, the default intl. input method is turned on. |
| 291 | (viper-deflocalvar viper-special-input-method nil "") | 287 | (viper-deflocalvar viper-special-input-method nil "") |
| 292 | 288 | ||
| 293 | ;; viper hook to run on input-method activation | 289 | ;; viper hook to run on input-method activation |
| 294 | (defun viper-activate-input-method-action () | 290 | (defun viper-activate-input-method-action () |
| 295 | (if (null viper-mule-hook-flag) | 291 | (if (null viper-mule-hook-flag) |
| @@ -301,7 +297,7 @@ Use `M-x viper-set-expert-level' to change this.") | |||
| 301 | (if (memq viper-current-state '(vi-state insert-state replace-state)) | 297 | (if (memq viper-current-state '(vi-state insert-state replace-state)) |
| 302 | (message "Viper special input method%s: on" | 298 | (message "Viper special input method%s: on" |
| 303 | (if (or current-input-method default-input-method) | 299 | (if (or current-input-method default-input-method) |
| 304 | (format " %S" | 300 | (format " %S" |
| 305 | (or current-input-method default-input-method)) | 301 | (or current-input-method default-input-method)) |
| 306 | ""))) | 302 | ""))) |
| 307 | )) | 303 | )) |
| @@ -323,7 +319,7 @@ Use `M-x viper-set-expert-level' to change this.") | |||
| 323 | (inactivate-input-method)) | 319 | (inactivate-input-method)) |
| 324 | ((and viper-xemacs-p (boundp 'current-input-method)) | 320 | ((and viper-xemacs-p (boundp 'current-input-method)) |
| 325 | ;; XEmacs had broken quil-mode for some time, so we are working around | 321 | ;; XEmacs had broken quil-mode for some time, so we are working around |
| 326 | ;; it here | 322 | ;; it here |
| 327 | (setq quail-mode nil) | 323 | (setq quail-mode nil) |
| 328 | (if (featurep 'quail) | 324 | (if (featurep 'quail) |
| 329 | (quail-delete-overlays)) | 325 | (quail-delete-overlays)) |
| @@ -367,7 +363,7 @@ This style is different from Emacs and Vi. Try it to see if | |||
| 367 | it better fits your working style." | 363 | it better fits your working style." |
| 368 | :type 'boolean | 364 | :type 'boolean |
| 369 | :tag "Preserve Position of Point After Undo" | 365 | :tag "Preserve Position of Point After Undo" |
| 370 | :group 'viper) | 366 | :group 'viper) |
| 371 | 367 | ||
| 372 | ;; Replace mode and changing text | 368 | ;; Replace mode and changing text |
| 373 | 369 | ||
| @@ -378,7 +374,7 @@ it better fits your working style." | |||
| 378 | ;; viper-set-destructive-command whenever (this-command-keys) doesn't give the | 374 | ;; viper-set-destructive-command whenever (this-command-keys) doesn't give the |
| 379 | ;; right result. For instance, in commands like c/bla<RET>, | 375 | ;; right result. For instance, in commands like c/bla<RET>, |
| 380 | ;; (this-command-keys) will return ^M, which invoked exit-minibuffer, while we | 376 | ;; (this-command-keys) will return ^M, which invoked exit-minibuffer, while we |
| 381 | ;; need "c/" | 377 | ;; need "c/" |
| 382 | (defconst viper-this-command-keys nil) | 378 | (defconst viper-this-command-keys nil) |
| 383 | 379 | ||
| 384 | ;; Indicates that the current destructive command has started in replace mode. | 380 | ;; Indicates that the current destructive command has started in replace mode. |
| @@ -403,7 +399,7 @@ delete the text being replaced, as in standard Vi." | |||
| 403 | 399 | ||
| 404 | ;; internal var, used to remember the default cursor color of emacs frames | 400 | ;; internal var, used to remember the default cursor color of emacs frames |
| 405 | (defvar viper-vi-state-cursor-color nil) | 401 | (defvar viper-vi-state-cursor-color nil) |
| 406 | 402 | ||
| 407 | (viper-deflocalvar viper-replace-overlay nil "") | 403 | (viper-deflocalvar viper-replace-overlay nil "") |
| 408 | (put 'viper-replace-overlay 'permanent-local t) | 404 | (put 'viper-replace-overlay 'permanent-local t) |
| 409 | 405 | ||
| @@ -419,7 +415,7 @@ It is used only with TTYs or if `viper-use-replace-region-delimiters' | |||
| 419 | is non-nil." | 415 | is non-nil." |
| 420 | :type 'string | 416 | :type 'string |
| 421 | :group 'viper) | 417 | :group 'viper) |
| 422 | (defcustom viper-use-replace-region-delimiters | 418 | (defcustom viper-use-replace-region-delimiters |
| 423 | (or (not (viper-has-face-support-p)) | 419 | (or (not (viper-has-face-support-p)) |
| 424 | (and viper-xemacs-p (eq (viper-device-type) 'tty))) | 420 | (and viper-xemacs-p (eq (viper-device-type) 'tty))) |
| 425 | "*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and | 421 | "*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and |
| @@ -432,7 +428,7 @@ color displays. By default, the delimiters are used only on TTYs." | |||
| 432 | "Function to use for prompting the user for a buffer name." | 428 | "Function to use for prompting the user for a buffer name." |
| 433 | :type 'symbol | 429 | :type 'symbol |
| 434 | :group 'viper) | 430 | :group 'viper) |
| 435 | 431 | ||
| 436 | ;; XEmacs requires glyphs | 432 | ;; XEmacs requires glyphs |
| 437 | (if viper-xemacs-p | 433 | (if viper-xemacs-p |
| 438 | (progn | 434 | (progn |
| @@ -443,8 +439,8 @@ color displays. By default, the delimiters are used only on TTYs." | |||
| 443 | (setq viper-replace-region-start-delimiter | 439 | (setq viper-replace-region-start-delimiter |
| 444 | (make-glyph viper-replace-region-start-delimiter))) | 440 | (make-glyph viper-replace-region-start-delimiter))) |
| 445 | )) | 441 | )) |
| 446 | 442 | ||
| 447 | 443 | ||
| 448 | ;; These are local marker that must be initialized to nil and moved with | 444 | ;; These are local marker that must be initialized to nil and moved with |
| 449 | ;; `viper-move-marker-locally' | 445 | ;; `viper-move-marker-locally' |
| 450 | ;; | 446 | ;; |
| @@ -457,7 +453,7 @@ color displays. By default, the delimiters are used only on TTYs." | |||
| 457 | 453 | ||
| 458 | (viper-deflocalvar viper-sitting-in-replace nil "") | 454 | (viper-deflocalvar viper-sitting-in-replace nil "") |
| 459 | (put 'viper-sitting-in-replace 'permanent-local t) | 455 | (put 'viper-sitting-in-replace 'permanent-local t) |
| 460 | 456 | ||
| 461 | ;; Remember the number of characters that have to be deleted in replace | 457 | ;; Remember the number of characters that have to be deleted in replace |
| 462 | ;; mode to compensate for the inserted characters. | 458 | ;; mode to compensate for the inserted characters. |
| 463 | (viper-deflocalvar viper-replace-chars-to-delete 0 "") | 459 | (viper-deflocalvar viper-replace-chars-to-delete 0 "") |
| @@ -559,7 +555,7 @@ This is useful for doing repeated changes with the '.' key. | |||
| 559 | The user can change this to nil, if she likes when the cursor moves | 555 | The user can change this to nil, if she likes when the cursor moves |
| 560 | to a new place after repeating previous Vi command." | 556 | to a new place after repeating previous Vi command." |
| 561 | :type 'boolean | 557 | :type 'boolean |
| 562 | :group 'viper) | 558 | :group 'viper) |
| 563 | 559 | ||
| 564 | ;; Remember insert point as a marker. This is a local marker that must be | 560 | ;; Remember insert point as a marker. This is a local marker that must be |
| 565 | ;; initialized to nil and moved with `viper-move-marker-locally'. | 561 | ;; initialized to nil and moved with `viper-move-marker-locally'. |
| @@ -589,10 +585,10 @@ to a new place after repeating previous Vi command." | |||
| 589 | 585 | ||
| 590 | ;; This is used for saving inserted text. | 586 | ;; This is used for saving inserted text. |
| 591 | (defvar viper-last-insertion nil) | 587 | (defvar viper-last-insertion nil) |
| 592 | 588 | ||
| 593 | ;; Remembers the last replaced region. | 589 | ;; Remembers the last replaced region. |
| 594 | (defvar viper-last-replace-region "") | 590 | (defvar viper-last-replace-region "") |
| 595 | 591 | ||
| 596 | ;; Remember com point as a marker. | 592 | ;; Remember com point as a marker. |
| 597 | ;; This is a local marker. Should be moved with `viper-move-marker-locally' | 593 | ;; This is a local marker. Should be moved with `viper-move-marker-locally' |
| 598 | (viper-deflocalvar viper-com-point nil) | 594 | (viper-deflocalvar viper-com-point nil) |
| @@ -725,7 +721,7 @@ If nil, the cursor will move backwards without deleting anything." | |||
| 725 | :type 'boolean | 721 | :type 'boolean |
| 726 | :tag "Search Wraps Around" | 722 | :tag "Search Wraps Around" |
| 727 | :group 'viper-search) | 723 | :group 'viper-search) |
| 728 | 724 | ||
| 729 | (viper-deflocalvar viper-related-files-and-buffers-ring nil "") | 725 | (viper-deflocalvar viper-related-files-and-buffers-ring nil "") |
| 730 | (defcustom viper-related-files-and-buffers-ring nil | 726 | (defcustom viper-related-files-and-buffers-ring nil |
| 731 | "*List of file and buffer names that are considered to be related to the current buffer. | 727 | "*List of file and buffer names that are considered to be related to the current buffer. |
| @@ -743,7 +739,7 @@ Related buffers can be cycled through via :R and :P commands." | |||
| 743 | (viper-deflocalvar viper-search-overlay nil) | 739 | (viper-deflocalvar viper-search-overlay nil) |
| 744 | 740 | ||
| 745 | 741 | ||
| 746 | (defvar viper-heading-start | 742 | (defvar viper-heading-start |
| 747 | (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp | 743 | (concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp |
| 748 | "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++ | 744 | "^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++ |
| 749 | "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|" | 745 | "^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|" |
| @@ -752,7 +748,7 @@ Related buffers can be cycled through via :R and :P commands." | |||
| 752 | "^.+:-") ; prolog | 748 | "^.+:-") ; prolog |
| 753 | "*Regexps for Headings. Used by \[\[ and \]\].") | 749 | "*Regexps for Headings. Used by \[\[ and \]\].") |
| 754 | 750 | ||
| 755 | (defvar viper-heading-end | 751 | (defvar viper-heading-end |
| 756 | (concat "^}\\|" ; C/C++ | 752 | (concat "^}\\|" ; C/C++ |
| 757 | "^\\\\end{\\|" ; latex | 753 | "^\\\\end{\\|" ; latex |
| 758 | "^@end \\|" ; texinfo | 754 | "^@end \\|" ; texinfo |
| @@ -819,7 +815,7 @@ DO NOT CHANGE this variable. Instead, use the customization widget | |||
| 819 | to customize the actual face object `viper-search-face' | 815 | to customize the actual face object `viper-search-face' |
| 820 | this variable represents.") | 816 | this variable represents.") |
| 821 | (viper-hide-face 'viper-search-face) | 817 | (viper-hide-face 'viper-search-face) |
| 822 | 818 | ||
| 823 | 819 | ||
| 824 | (defface viper-replace-overlay-face | 820 | (defface viper-replace-overlay-face |
| 825 | '((((class color)) (:foreground "Black" :background "darkseagreen2")) | 821 | '((((class color)) (:foreground "Black" :background "darkseagreen2")) |
| @@ -847,7 +843,7 @@ DO NOT CHANGE this variable. Instead, use the customization widget | |||
| 847 | to customize the actual face object `viper-minibuffer-emacs-face' | 843 | to customize the actual face object `viper-minibuffer-emacs-face' |
| 848 | this variable represents.") | 844 | this variable represents.") |
| 849 | (viper-hide-face 'viper-minibuffer-emacs-face) | 845 | (viper-hide-face 'viper-minibuffer-emacs-face) |
| 850 | 846 | ||
| 851 | 847 | ||
| 852 | (defface viper-minibuffer-insert-face | 848 | (defface viper-minibuffer-insert-face |
| 853 | '((((class color)) (:foreground "Black" :background "pink")) | 849 | '((((class color)) (:foreground "Black" :background "pink")) |
| @@ -861,7 +857,7 @@ DO NOT CHANGE this variable. Instead, use the customization widget | |||
| 861 | to customize the actual face object `viper-minibuffer-insert-face' | 857 | to customize the actual face object `viper-minibuffer-insert-face' |
| 862 | this variable represents.") | 858 | this variable represents.") |
| 863 | (viper-hide-face 'viper-minibuffer-insert-face) | 859 | (viper-hide-face 'viper-minibuffer-insert-face) |
| 864 | 860 | ||
| 865 | 861 | ||
| 866 | (defface viper-minibuffer-vi-face | 862 | (defface viper-minibuffer-vi-face |
| 867 | '((((class color)) (:foreground "DarkGreen" :background "grey")) | 863 | '((((class color)) (:foreground "DarkGreen" :background "grey")) |
| @@ -875,7 +871,7 @@ DO NOT CHANGE this variable. Instead, use the customization widget | |||
| 875 | to customize the actual face object `viper-minibuffer-vi-face' | 871 | to customize the actual face object `viper-minibuffer-vi-face' |
| 876 | this variable represents.") | 872 | this variable represents.") |
| 877 | (viper-hide-face 'viper-minibuffer-vi-face) | 873 | (viper-hide-face 'viper-minibuffer-vi-face) |
| 878 | 874 | ||
| 879 | ;; the current face to be used in the minibuffer | 875 | ;; the current face to be used in the minibuffer |
| 880 | (viper-deflocalvar | 876 | (viper-deflocalvar |
| 881 | viper-minibuffer-current-face viper-minibuffer-emacs-face "") | 877 | viper-minibuffer-current-face viper-minibuffer-emacs-face "") |
| @@ -911,7 +907,7 @@ value refers to the number of characters affected." | |||
| 911 | Should be set in `~/.viper' file." | 907 | Should be set in `~/.viper' file." |
| 912 | :type 'boolean | 908 | :type 'boolean |
| 913 | :group 'viper) | 909 | :group 'viper) |
| 914 | 910 | ||
| 915 | ;; overlay used in the minibuffer to indicate which state it is in | 911 | ;; overlay used in the minibuffer to indicate which state it is in |
| 916 | (viper-deflocalvar viper-minibuffer-overlay nil) | 912 | (viper-deflocalvar viper-minibuffer-overlay nil) |
| 917 | (put 'viper-minibuffer-overlay 'permanent-local t) | 913 | (put 'viper-minibuffer-overlay 'permanent-local t) |
| @@ -920,7 +916,7 @@ Should be set in `~/.viper' file." | |||
| 920 | ;; This is needed because beginning with Emacs 19.26, the standard | 916 | ;; This is needed because beginning with Emacs 19.26, the standard |
| 921 | ;; `minibuffer-exit-hook' is run *after* exiting the minibuffer | 917 | ;; `minibuffer-exit-hook' is run *after* exiting the minibuffer |
| 922 | (defvar viper-minibuffer-exit-hook nil) | 918 | (defvar viper-minibuffer-exit-hook nil) |
| 923 | 919 | ||
| 924 | 920 | ||
| 925 | ;; Mode line | 921 | ;; Mode line |
| 926 | (defconst viper-vi-state-id "<V> " | 922 | (defconst viper-vi-state-id "<V> " |
| @@ -954,12 +950,12 @@ Should be set in `~/.viper' file." | |||
| 954 | "*Hooks run just before the switch to Emacs mode is completed." | 950 | "*Hooks run just before the switch to Emacs mode is completed." |
| 955 | :type 'hook | 951 | :type 'hook |
| 956 | :group 'viper-hooks) | 952 | :group 'viper-hooks) |
| 957 | 953 | ||
| 958 | (defcustom viper-load-hook nil | 954 | (defcustom viper-load-hook nil |
| 959 | "Hooks run just after loading Viper." | 955 | "Hooks run just after loading Viper." |
| 960 | :type 'hook | 956 | :type 'hook |
| 961 | :group 'viper-hooks) | 957 | :group 'viper-hooks) |
| 962 | 958 | ||
| 963 | 959 | ||
| 964 | ;;; Local Variables: | 960 | ;;; Local Variables: |
| 965 | ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) | 961 | ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) |