• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/emulation/

Lines Matching +defs:viper +defs:array +defs:to +defs:string

0 ;;; viper-cmd.el --- Vi command support for Viper
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 (provide 'viper-cmd)
33 (defvar viper-minibuffer-current-face)
34 (defvar viper-minibuffer-insert-face)
35 (defvar viper-minibuffer-vi-face)
36 (defvar viper-minibuffer-emacs-face)
37 (defvar viper-always)
38 (defvar viper-mode-string)
39 (defvar viper-custom-file-name)
40 (defvar viper--key-maps)
41 (defvar viper--intercept-key-maps)
53 ;; in order to spare non-viperized emacs from being viperized
57 (or (featurep 'viper-util)
58 (load "viper-util.el" nil nil 'nosuffix))
59 (or (featurep 'viper-keym)
60 (load "viper-keym.el" nil nil 'nosuffix))
61 (or (featurep 'viper-mous)
62 (load "viper-mous.el" nil nil 'nosuffix))
63 (or (featurep 'viper-macs)
64 (load "viper-macs.el" nil nil 'nosuffix))
65 (or (featurep 'viper-ex)
66 (load "viper-ex.el" nil nil 'nosuffix))
71 (require 'viper-util)
72 (require 'viper-keym)
73 (require 'viper-mous)
74 (require 'viper-macs)
75 (require 'viper-ex)
87 ;; (macroexpand '(viper-test-com-defun foo))
90 (defmacro viper-test-com-defun (name)
95 (consp (viper-memq-char com ,nms)
100 ;; Modifying commands that can be prefixes to movement commands
101 (defvar viper-prefix-commands '(?c ?d ?y ?! ?= ?# ?< ?> ?\"))
102 ;; define viper-prefix-command-p
103 (viper-test-com-defun viper-prefix-command)
106 (defconst viper-charpair-commands '(?c ?d ?y ?! ?= ?< ?> ?r ?R))
107 ;; define viper-charpair-command-p
108 (viper-test-com-defun viper-charpair-command)
110 (defconst viper-movement-commands '(?b ?B ?e ?E ?f ?F ?G ?h ?H ?j ?k ?l
118 ;; define viper-movement-command-p
119 (viper-test-com-defun viper-movement-command)
122 (defconst viper-digit-commands '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
124 ;; define viper-digit-command-p
125 (viper-test-com-defun viper-digit-command)
128 (defconst viper-dotable-commands '(?c ?d ?C ?s ?S ?D ?> ?<))
129 ;; define viper-dotable-command-p
130 (viper-test-com-defun viper-dotable-command)
133 (defconst viper-hash-commands '(?c ?C ?g ?q ?s))
134 ;; define viper-hash-command-p
135 (viper-test-com-defun viper-hash-command)
138 (defconst viper-regsuffix-commands '(?d ?y ?Y ?D ?p ?P ?x ?X))
139 ;; define viper-regsuffix-command-p
140 (viper-test-com-defun viper-regsuffix-command)
142 (defconst viper-vi-commands (append viper-movement-commands
143 viper-digit-commands
144 viper-dotable-commands
145 viper-charpair-commands
146 viper-hash-commands
147 viper-prefix-commands
148 viper-regsuffix-commands)
150 ;; define viper-vi-command-p
151 (viper-test-com-defun viper-vi-command)
153 ;; Where viper saves mark. This mark is resurrected by m^
154 (defvar viper-saved-mark nil)
156 ;; Contains user settings for vars affected by viper-set-expert-level function.
158 (defvar viper-saved-user-settings nil)
167 ;; Runs viper-after-change-functions inside after-change-functions
168 (defun viper-after-change-sentinel (beg end len)
169 (run-hook-with-args 'viper-after-change-functions beg end len))
171 ;; Runs viper-before-change-functions inside before-change-functions
172 (defun viper-before-change-sentinel (beg end)
173 (run-hook-with-args 'viper-before-change-functions beg end))
175 (defsubst viper-post-command-sentinel ()
177 (run-hooks 'viper-post-command-hooks)
178 (error (viper-message-conditions conds)))
179 (if (eq viper-current-state 'vi-state)
180 (viper-restore-cursor-color 'after-insert-mode)))
182 (defsubst viper-pre-command-sentinel ()
183 (run-hooks 'viper-pre-command-hooks))
185 ;; Needed so that Viper will be able to figure the last inserted
187 (defsubst viper-insert-state-post-command-sentinel ()
188 (if (and (memq viper-current-state '(insert-state replace-state))
189 viper-insert-point
190 (>= (point) viper-insert-point))
191 (setq viper-last-posn-while-in-insert-state (point-marker)))
192 (or (viper-overlay-p viper-replace-overlay)
194 (viper-set-replace-overlay (point-min) (point-min))
195 (viper-hide-replace-overlay)))
196 (if (eq viper-current-state 'insert-state)
198 (stringp (viper-get-saved-cursor-color-in-insert-mode))))
200 (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
202 (viper-save-cursor-color 'before-insert-mode))
204 (viper-change-cursor-color viper-insert-state-cursor-color)))
205 (if (and viper-emacs-state-cursor-color (eq viper-current-state 'emacs-state))
207 (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
209 (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
211 (viper-save-cursor-color 'before-emacs-mode))
213 (viper-change-cursor-color viper-emacs-state-cursor-color)))
216 (integerp viper-pre-command-point)
217 (markerp viper-insert-point)
218 (marker-position viper-insert-point)
219 (> viper-insert-point viper-pre-command-point))
220 (viper-move-marker-locally viper-insert-point viper-pre-command-point))
223 (defsubst viper-preserve-cursor-color ()
225 viper-del-backward-char-in-insert
226 viper-del-backward-char-in-replace
227 viper-delete-backward-char
228 viper-join-lines
229 viper-delete-char))
230 (memq (viper-event-key last-command-event)
234 (defsubst viper-insert-state-pre-command-sentinel ()
235 (or (viper-preserve-cursor-color)
236 (viper-restore-cursor-color 'after-insert-mode))
238 (markerp viper-insert-point)
239 (marker-position viper-insert-point))
240 (setq viper-pre-command-point (marker-position viper-insert-point))))
242 (defsubst viper-R-state-post-command-sentinel ()
244 ;; viper-replace-state-pre-command-sentinel: When you jump to another buffer
245 ;; in another frame, the pre-command hook won't change cursor color to
249 (if (and (<= (viper-replace-start) (point))
250 (<= (point) (viper-replace-end)))
251 (viper-change-cursor-color viper-replace-overlay-cursor-color)
252 (viper-restore-cursor-color 'after-replace-mode)
255 ;; to speed up, don't change cursor color before self-insert
257 (defsubst viper-replace-state-pre-command-sentinel ()
258 (or (viper-preserve-cursor-color)
259 (viper-restore-cursor-color 'after-replace-mode)))
263 ;; This is executed at viper-last-posn-in-replace-region
264 (defsubst viper-trim-replace-chars-to-delete-if-necessary ()
265 (setq viper-replace-chars-to-delete
267 (min viper-replace-chars-to-delete
268 ;; Don't delete more than to the end of repl overlay
269 (viper-chars-in-region
270 (viper-replace-end) viper-last-posn-in-replace-region)
271 ;; point is viper-last-posn-in-replace-region now
272 ;; So, this limits deletion to the end of line
273 (viper-chars-in-region (point) (viper-line-pos 'end))
277 (defun viper-replace-state-post-command-sentinel ()
279 ;; viper-replace-state-pre-command-sentinel: When one jumps to another buffer
280 ;; in another frame, the pre-command hook won't change cursor color to
286 ;; viper-delete-backward-char, etc., since they either don't change
288 ;; in viper-finish-change
289 (or (viper-preserve-cursor-color)
290 (viper-restore-cursor-color 'after-replace-mode))
292 ((eq viper-current-state 'replace-state)
293 ;; delete characters to compensate for inserted chars.
294 (let ((replace-boundary (viper-replace-end)))
296 (goto-char viper-last-posn-in-replace-region)
297 (viper-trim-replace-chars-to-delete-if-necessary)
298 (delete-char viper-replace-chars-to-delete)
299 (setq viper-replace-chars-to-delete 0)
301 (if (= viper-last-posn-in-replace-region (viper-replace-end))
302 (viper-finish-change)))
304 (if (viper-pos-within-region
305 (point) (viper-replace-start) replace-boundary)
307 ;; the state may have changed in viper-finish-change above
308 (if (eq viper-current-state 'replace-state)
309 (viper-change-cursor-color viper-replace-overlay-cursor-color))
310 (setq viper-last-posn-in-replace-region (point-marker))))
313 (t (viper-finish-change))))
318 ;; Change state to NEW-STATE---either emacs-state, vi-state, or insert-state.
319 (defun viper-change-state (new-state)
320 ;; Keep viper-post/pre-command-hooks fresh.
321 ;; We remove then add viper-post/pre-command-sentinel since it is very
322 ;; desirable that viper-pre-command-sentinel is the last hook and
323 ;; viper-post-command-sentinel is the first hook.
325 (viper-cond-compile-for-xemacs-or-emacs
328 (make-local-hook 'viper-after-change-functions)
329 (make-local-hook 'viper-before-change-functions)
330 (make-local-hook 'viper-post-command-hooks)
331 (make-local-hook 'viper-pre-command-hooks))
335 (remove-hook 'post-command-hook 'viper-post-command-sentinel)
336 (add-hook 'post-command-hook 'viper-post-command-sentinel)
337 (remove-hook 'pre-command-hook 'viper-pre-command-sentinel)
338 (add-hook 'pre-command-hook 'viper-pre-command-sentinel t)
339 ;; These hooks will be added back if switching to insert/replace mode
340 (remove-hook 'viper-post-command-hooks
341 'viper-insert-state-post-command-sentinel 'local)
342 (remove-hook 'viper-pre-command-hooks
343 'viper-insert-state-pre-command-sentinel 'local)
344 (setq viper-intermediate-command nil)
346 (cond ((member viper-current-state '(insert-state replace-state))
348 ;; move viper-last-posn-while-in-insert-state
351 ;; nothing. We need to execute it here to make sure that
356 (viper-insert-state-post-command-sentinel)
360 (viper-save-last-insertion
361 viper-insert-point
362 viper-last-posn-while-in-insert-state)
363 (if viper-began-as-replace
364 (setq viper-began-as-replace nil)
367 (viper-repeat-insert-command))))
369 (viper-message-conditions conds)))
371 (if (> (length viper-last-insertion) 0)
372 (viper-push-onto-ring viper-last-insertion
373 'viper-insertion-ring))
375 (if viper-ESC-moves-cursor-back
376 (or (bolp) (viper-beginning-of-field) (backward-char 1))))
381 (if (memq viper-current-state '(emacs-state vi-state))
382 (viper-move-marker-locally 'viper-insert-point (point)))
383 (viper-move-marker-locally
384 'viper-last-posn-while-in-insert-state (point))
385 (add-hook 'viper-post-command-hooks
386 'viper-insert-state-post-command-sentinel t 'local)
387 (add-hook 'viper-pre-command-hooks
388 'viper-insert-state-pre-command-sentinel t 'local))
391 ;; Nothing needs to be done to switch to emacs mode! Just set some
392 ;; variables, which is already done in viper-change-state-to-emacs!
395 ;; always turn off iso-accents-mode in vi-state, or else we won't be able to
397 (cond ((eq new-state 'vi-state) (viper-set-iso-accents-mode nil));accents off
398 (viper-automatic-iso-accents (viper-set-iso-accents-mode t));accents on
399 (t (viper-set-iso-accents-mode nil)))
401 (cond ((eq new-state 'vi-state) (viper-set-input-method nil)) ;intl input off
402 (viper-special-input-method (viper-set-input-method t)) ;intl input on
403 (t (viper-set-input-method nil)))
405 (setq viper-current-state new-state)
407 (viper-update-syntax-classes)
408 (viper-normalize-minor-mode-map-alist)
409 (viper-adjust-keys-for new-state)
410 (viper-set-mode-vars-for new-state)
411 (viper-refresh-mode-line)
415 (defun viper-adjust-keys-for (state)
416 "Make necessary adjustments to keymaps before entering STATE."
418 (if viper-auto-indent
420 (define-key viper-insert-basic-map "\C-m" 'viper-autoindent)
421 (if viper-want-emacs-keys-in-insert
423 (define-key viper-insert-basic-map "\C-j" nil)
425 (define-key viper-insert-basic-map "\C-j" 'viper-autoindent)))
426 (define-key viper-insert-basic-map "\C-m" nil)
427 (define-key viper-insert-basic-map "\C-j" nil))
429 (setq viper-insert-diehard-minor-mode
430 (not viper-want-emacs-keys-in-insert))
432 (if viper-want-ctl-h-help
434 (define-key viper-insert-basic-map "\C-h" 'help-command)
435 (define-key viper-replace-map "\C-h" 'help-command))
436 (define-key viper-insert-basic-map
437 "\C-h" 'viper-del-backward-char-in-insert)
438 (define-key viper-replace-map
439 "\C-h" 'viper-del-backward-char-in-replace))
441 (define-key viper-insert-basic-map
442 [backspace] 'viper-del-backward-char-in-insert)
443 (define-key viper-replace-map
444 [backspace] 'viper-del-backward-char-in-replace)
447 (setq viper-vi-diehard-minor-mode (not viper-want-emacs-keys-in-vi))
448 (if viper-want-ctl-h-help
449 (define-key viper-vi-basic-map "\C-h" 'help-command)
450 (define-key viper-vi-basic-map "\C-h" 'viper-backward-char))
452 (define-key viper-vi-basic-map [backspace] 'viper-backward-char))
459 (defun viper-normalize-minor-mode-map-alist ()
460 (setq viper--intercept-key-maps
462 (cons 'viper-vi-intercept-minor-mode viper-vi-intercept-map)
463 (cons 'viper-insert-intercept-minor-mode viper-insert-intercept-map)
464 (cons 'viper-emacs-intercept-minor-mode viper-emacs-intercept-map)
466 (setq viper--key-maps
467 (list (cons 'viper-vi-minibuffer-minor-mode viper-minibuffer-map)
468 (cons 'viper-vi-local-user-minor-mode viper-vi-local-user-map)
469 (cons 'viper-vi-kbd-minor-mode viper-vi-kbd-map)
470 (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map)
471 (cons 'viper-vi-state-modifier-minor-mode
473 (cdr (assoc major-mode viper-vi-state-modifier-alist)))
474 (cdr (assoc major-mode viper-vi-state-modifier-alist))
475 viper-empty-keymap))
476 (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map)
477 (cons 'viper-vi-basic-minor-mode viper-vi-basic-map)
478 (cons 'viper-replace-minor-mode viper-replace-map)
479 ;; viper-insert-minibuffer-minor-mode must come after
480 ;; viper-replace-minor-mode
481 (cons 'viper-insert-minibuffer-minor-mode
482 viper-minibuffer-map)
483 (cons 'viper-insert-local-user-minor-mode
484 viper-insert-local-user-map)
485 (cons 'viper-insert-kbd-minor-mode viper-insert-kbd-map)
486 (cons 'viper-insert-global-user-minor-mode
487 viper-insert-global-user-map)
488 (cons 'viper-insert-state-modifier-minor-mode
491 viper-insert-state-modifier-alist)))
493 viper-insert-state-modifier-alist))
494 viper-empty-keymap))
495 (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map)
496 (cons 'viper-insert-basic-minor-mode viper-insert-basic-map)
497 (cons 'viper-emacs-local-user-minor-mode
498 viper-emacs-local-user-map)
499 (cons 'viper-emacs-kbd-minor-mode viper-emacs-kbd-map)
500 (cons 'viper-emacs-global-user-minor-mode
501 viper-emacs-global-user-map)
502 (cons 'viper-emacs-state-modifier-minor-mode
505 (assoc major-mode viper-emacs-state-modifier-alist)))
507 (assoc major-mode viper-emacs-state-modifier-alist))
508 viper-empty-keymap))
514 ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have
516 ;; with viper-vi/insert-state-modifier-minor-mode can be different.
518 ;; In emacs with emulation-mode-map-alists, nothing needs to be done
520 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
522 (viper-append-filter-alist
523 (append viper--intercept-key-maps viper--key-maps)
533 (defun viper-refresh-mode-line ()
534 (set (make-local-variable 'viper-mode-string)
535 (cond ((eq viper-current-state 'emacs-state) viper-emacs-state-id)
536 ((eq viper-current-state 'vi-state) viper-vi-state-id)
537 ((eq viper-current-state 'replace-state) viper-replace-state-id)
538 ((eq viper-current-state 'insert-state) viper-insert-state-id)))
540 ;; Sets Viper mode string in global-mode-string
544 ;; Switch from Insert state to Vi state.
545 (defun viper-exit-insert-state ()
547 (viper-change-state-to-vi))
549 (defun viper-set-mode-vars-for (state)
550 "Sets Viper minor mode variables to put Viper's state STATE in effect."
553 (setq viper-vi-minibuffer-minor-mode nil
554 viper-insert-minibuffer-minor-mode nil
555 viper-vi-intercept-minor-mode nil
556 viper-insert-intercept-minor-mode nil
558 viper-vi-local-user-minor-mode nil
559 viper-vi-kbd-minor-mode nil
560 viper-vi-global-user-minor-mode nil
561 viper-vi-state-modifier-minor-mode nil
562 viper-vi-diehard-minor-mode nil
563 viper-vi-basic-minor-mode nil
565 viper-replace-minor-mode nil
567 viper-insert-local-user-minor-mode nil
568 viper-insert-kbd-minor-mode nil
569 viper-insert-global-user-minor-mode nil
570 viper-insert-state-modifier-minor-mode nil
571 viper-insert-diehard-minor-mode nil
572 viper-insert-basic-minor-mode nil
573 viper-emacs-intercept-minor-mode t
574 viper-emacs-local-user-minor-mode t
575 viper-emacs-kbd-minor-mode (not (viper-is-in-minibuffer))
576 viper-emacs-global-user-minor-mode t
577 viper-emacs-state-modifier-minor-mode t
583 viper-vi-intercept-minor-mode t
584 viper-vi-minibuffer-minor-mode (viper-is-in-minibuffer)
585 viper-vi-local-user-minor-mode t
586 viper-vi-kbd-minor-mode (not (viper-is-in-minibuffer))
587 viper-vi-global-user-minor-mode t
588 viper-vi-state-modifier-minor-mode t
591 viper-vi-diehard-minor-mode (not
592 (or viper-want-emacs-keys-in-vi
593 (viper-is-in-minibuffer)))
594 viper-vi-basic-minor-mode t
595 viper-emacs-intercept-minor-mode nil
596 viper-emacs-local-user-minor-mode nil
597 viper-emacs-kbd-minor-mode nil
598 viper-emacs-global-user-minor-mode nil
599 viper-emacs-state-modifier-minor-mode nil
605 viper-insert-intercept-minor-mode t
606 viper-replace-minor-mode (eq state 'replace-state)
607 viper-insert-minibuffer-minor-mode (viper-is-in-minibuffer)
608 viper-insert-local-user-minor-mode t
609 viper-insert-kbd-minor-mode (not (viper-is-in-minibuffer))
610 viper-insert-global-user-minor-mode t
611 viper-insert-state-modifier-minor-mode t
614 viper-insert-diehard-minor-mode (not
616 viper-want-emacs-keys-in-insert
617 (viper-is-in-minibuffer)))
618 viper-insert-basic-minor-mode t
619 viper-emacs-intercept-minor-mode nil
620 viper-emacs-local-user-minor-mode nil
621 viper-emacs-kbd-minor-mode nil
622 viper-emacs-global-user-minor-mode nil
623 viper-emacs-state-modifier-minor-mode nil
627 (if (viper-has-face-support-p)
628 (setq viper-minibuffer-current-face
629 (cond ((eq state 'emacs-state) viper-minibuffer-emacs-face)
630 ((eq state 'vi-state) viper-minibuffer-vi-face)
632 viper-minibuffer-insert-face))))
634 (if (viper-is-in-minibuffer)
635 (viper-set-minibuffer-overlay))
639 ;; Also, this fixes `undo' to work vi-style for complex commands.
640 (defun viper-change-state-to-vi ()
641 "Change Viper state to Vi."
643 (if (and viper-first-time (not (viper-is-in-minibuffer)))
644 (viper-mode)
646 (or (viper-overlay-p viper-replace-overlay)
647 (viper-set-replace-overlay (point-min) (point-min)))
648 (viper-hide-replace-overlay)
654 '(viper-autoindent
655 viper-open-line viper-Open-line
656 viper-replace-state-exit-cmd))
657 (viper-over-whitespace-line))
658 (indent-to-left-margin))
659 (viper-add-newline-at-eob-if-necessary)
660 (viper-adjust-undo)
662 (if (eq viper-current-state 'emacs-state)
663 (viper-restore-cursor-color 'after-emacs-mode)
664 (viper-restore-cursor-color 'after-insert-mode))
666 (viper-change-state 'vi-state)
670 (run-hooks 'viper-vi-state-hook)
672 (viper-message-conditions conds)))))
674 (defun viper-change-state-to-insert ()
675 "Change Viper state to Insert."
677 (viper-change-state 'insert-state)
679 (or (viper-overlay-p viper-replace-overlay)
680 (viper-set-replace-overlay (point-min) (point-min)))
681 (viper-hide-replace-overlay)
684 (stringp (viper-get-saved-cursor-color-in-insert-mode))))
686 (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
687 (viper-save-cursor-color 'before-insert-mode))
688 (viper-change-cursor-color viper-insert-state-cursor-color))
692 (run-hooks 'viper-insert-state-hook)
694 (viper-message-conditions conds))))
696 (defsubst viper-downgrade-to-insert ()
699 (run-hooks 'viper-insert-state-hook)
701 (viper-message-conditions conds)))
702 (setq viper-current-state 'insert-state
703 viper-replace-minor-mode nil))
707 ;; Change to replace state. When the end of replacement region is reached,
708 ;; replace state changes to insert state.
709 (defun viper-change-state-to-replace (&optional non-R-cmd)
710 (viper-change-state 'replace-state)
713 (run-hooks 'viper-insert-state-hook 'viper-replace-state-hook)
715 (viper-message-conditions conds)))
718 (viper-start-replace)
720 (viper-start-R-mode))
724 (defun viper-change-state-to-emacs ()
725 "Change Viper state to Emacs."
727 (or (viper-overlay-p viper-replace-overlay)
728 (viper-set-replace-overlay (point-min) (point-min)))
729 (viper-hide-replace-overlay)
731 (if viper-emacs-state-cursor-color
733 (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
735 (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
736 (viper-save-cursor-color 'before-emacs-mode))
737 (viper-change-cursor-color viper-emacs-state-cursor-color)))
739 (viper-change-state 'emacs-state)
743 (run-hooks 'viper-emacs-state-hook)
745 (viper-message-conditions conds))))
747 ;; escape to emacs mode termporarily
748 (defun viper-escape-to-emacs (arg &optional events)
749 "Escape to Emacs state from Vi state for one Emacs command.
753 (if (viper= last-command-char ?\\)
754 (message "Switched to EMACS state for the next command..."))
755 (viper-escape-to-state arg events 'emacs-state))
757 ;; escape to Vi mode termporarily
758 (defun viper-escape-to-vi (arg)
759 "Escape from Emacs state to Vi state for one Vi 1-character command.
761 Vi's prefix argument will be used. Otherwise, the prefix argument passed to
762 `viper-escape-to-vi' is used."
764 (message "Switched to VI state for the next command...")
765 (viper-escape-to-state arg nil 'vi-state))
767 ;; Escape to STATE mode for one Emacs command.
768 (defun viper-escape-to-state (arg events state)
772 (viper-set-mode-vars-for state)
773 (viper-normalize-minor-mode-map-alist)
774 (if events (viper-set-unread-command-events events))
778 (let (viper-vi-kbd-minor-mode
779 viper-insert-kbd-minor-mode
780 viper-emacs-kbd-minor-mode)
784 (key-binding (setq key (viper-read-key-sequence nil))))
786 ;; Have to do it here because we execute this command under
793 ;; escaped to command, Viper's mode vars will remain those of
794 ;; `state'. When we return to the orig buffer, the bindings will be
796 (viper-set-mode-vars-for viper-current-state)
800 (viper-cond-compile-for-xemacs-or-emacs
803 (viper-copy-event (viper-seq-last-elt key))
804 last-command-char (event-to-character last-command-event))
807 (viper-copy-event (viper-seq-last-elt key))
812 ;; pretend that current state is the state we excaped to
813 (let ((viper-current-state state))
820 (viper-set-mode-vars-for viper-current-state))
822 ;; This is used in order to allow reading characters according to the input
825 ;; cause several characters to be combined into one.
827 (defun viper-special-read-and-insert-char ()
828 (viper-set-mode-vars-for 'emacs-state)
829 (viper-normalize-minor-mode-map-alist)
830 (if viper-special-input-method
831 (viper-set-input-method t))
832 (if viper-automatic-iso-accents
833 (viper-set-iso-accents-mode t))
835 (let (viper-vi-kbd-minor-mode
836 viper-insert-kbd-minor-mode
837 viper-emacs-kbd-minor-mode
839 (cond ((and viper-special-input-method
840 viper-emacs-p
842 ;; (let ...) is used to restore unread-command-events to the
847 ;; The next cmd and viper-set-unread-command-events
848 ;; are intended to prevent the input method
856 (viper-set-unread-command-events ch)
859 (if (and ch (string= quail-current-str ""))
866 ((and viper-special-input-method
867 viper-xemacs-p
878 (viper-set-unread-command-events ch)
881 (if (and ch (string= quail-current-str ""))
899 (if viper-xemacs-p
900 (setq ch (event-to-character ch)))
908 (if viper-xemacs-p
909 (setq ch (event-to-character ch))))
914 (viper-copy-event (if viper-xemacs-p
915 (character-to-event ch) ch)))
920 (viper-set-input-method nil)
921 (viper-set-iso-accents-mode nil)
922 (viper-set-mode-vars-for viper-current-state)
926 (defun viper-exec-form-in-vi (form)
930 (viper-set-mode-vars-for 'vi-state)
933 (let (viper-vi-kbd-minor-mode) ; execute without kbd macros
941 (viper-set-mode-vars-for viper-current-state)))
942 (viper-set-mode-vars-for viper-current-state)
945 (defun viper-exec-form-in-emacs (form)
947 Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
950 (viper-set-mode-vars-for 'emacs-state)
955 (viper-set-mode-vars-for viper-current-state)))
956 (viper-set-mode-vars-for viper-current-state)
959 ;; This executes the last kbd event in emacs mode. Is used when we want to
961 (defun viper-exec-key-in-emacs (arg)
963 (viper-escape-to-emacs arg last-command-event))
968 ;; arrange to reorganize minor-mode-map-alist so that things will work right.
969 (defun viper-harness-minor-mode (load-file)
972 This function is designed to make Viper aware of the packages that define
975 (viper-harness-minor-mode load-file)
982 (eval-after-load load-file '(viper-normalize-minor-mode-map-alist))
985 ;; mode adds its own keymap to the a-list.
987 (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
993 (defun viper-ESC (arg)
995 Prevents multiple escape keystrokes if viper-no-multiple-ESC is true.
996 If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
1000 a Meta key in this case. When viper-no-multiple-ESC is nil, ESC functions
1004 (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state))
1005 (setq char (viper-read-char-exclusive))
1006 (viper-escape-to-emacs arg (list ?\e char) ))
1007 ((and (eq viper-no-multiple-ESC 'twice)
1008 (eq viper-current-state 'vi-state))
1009 (setq char (viper-read-char-exclusive))
1010 (if (= char (string-to-char viper-ESC-key))
1012 (viper-escape-to-emacs arg (list ?\e char) )))
1016 (defun viper-alternate-Meta-key (arg)
1020 (viper-escape-to-emacs arg '(?\e)))
1022 (defun viper-toggle-key-action ()
1023 "Action bound to `viper-toggle-key'."
1025 (if (and (< viper-expert-level 2) (equal viper-toggle-key "\C-z"))
1026 (if (viper-window-display-p)
1027 (viper-iconify)
1029 (viper-change-state-to-emacs)))
1036 ;; Check if last key was ESC and if so try to reread it as a function key.
1037 ;; But only if there are characters to read during a very short time.
1039 (defun viper-envelop-ESC-key ()
1043 (if (viper-ESC-event-p event)
1048 ;; line for the next time the bug reappears, so that will remember to
1050 ;;(if (and (viper-fast-keysequence-p) unread-command-events)
1051 (if (viper-fast-keysequence-p) ;; for Emacsen without the above bug
1054 (viper-set-unread-command-events event)
1073 ;; last-command-event in order to pretend that this key was
1074 ;; pressed. This is needed to allow arrow keys to be bound to
1075 ;; macros. Otherwise, viper-exec-mapped-kbd-macro will think
1077 ;; bound to ESC. (Viper macros can't be bound to
1081 (cond ((and (viper-ESC-event-p first-key)
1082 (not viper-translate-all-ESC-keysequences))
1085 (viper-set-unread-command-events (viper-subseq keyseq 1))
1087 keyseq (if viper-emacs-p
1089 (vector (character-to-event ?\e)))))
1090 ((and viper-xemacs-p
1093 (viper-set-unread-command-events
1095 (character-to-event (event-key first-key)))
1096 (viper-subseq keyseq 1)))
1098 keyseq (vector (character-to-event ?\e))))
1101 (viper-copy-event first-key)))
1107 (viper-set-unread-command-events event)
1116 ;; Listen to ESC key.
1119 (defun viper-intercept-ESC-key ()
1122 (let ((cmd (or (key-binding (viper-envelop-ESC-key))
1125 ;; call the actual function to execute ESC (if no other symbols followed)
1126 ;; or the key bound to the ESC sequence (if the sequence was issued
1128 (if (eq cmd 'viper-intercept-ESC-key)
1130 (cond ((eq viper-current-state 'vi-state)
1131 'viper-ESC)
1132 ((eq viper-current-state 'insert-state)
1133 'viper-exit-insert-state)
1134 ((eq viper-current-state 'replace-state)
1135 'viper-replace-state-exit-cmd)
1136 (t 'viper-change-state-to-vi)
1151 (defsubst viper-p-val (arg)
1159 (defsubst viper-P-val (arg)
1164 (defsubst viper-getcom (arg)
1170 (defun viper-getCom (arg)
1171 (let ((com (viper-getcom arg)))
1172 (cond ((viper= com ?c) ?c)
1173 ;; Previously, ?c was being converted to ?C, but this prevented
1175 ;;((viper= com ?c) ?C)
1176 ((viper= com ?d) ?D)
1177 ((viper= com ?y) ?Y)
1183 (defun viper-prefix-arg-value (event-char com)
1184 (let ((viper-intermediate-command 'viper-digit-argument)
1187 (while (and (viper-characterp event-char)
1190 (setq event-char (viper-read-event-convert-to-char)))
1195 (viper-describe-arg prefix-arg)
1196 (setq event-char (viper-read-event-convert-to-char)))
1198 (if (or com (and (not (eq viper-current-state 'vi-state))
1200 (viper-characterp event-char)
1201 (viper-vi-command-p event-char)
1203 ;; If appears to be one of the vi commands,
1204 ;; then execute it with funcall and clear prefix-arg in order to not
1207 ;; last-command-char is the char we want emacs to think was typed
1208 ;; last. If com is not nil, the viper-digit-argument command was
1209 ;; called from within viper-prefix-arg command, such as `d', `w',
1211 ;; `d', `w', etc. If viper-digit-argument was invoked by
1212 ;; viper-escape-to-vi (which is indicated by the fact that the
1214 ;; vi command to be executed (e.g., `d', `w', etc). Again,
1222 (setq func (viper-exec-form-in-vi
1223 `(key-binding (char-to-string ,event-char))))
1227 (viper-set-unread-command-events event-char))
1232 (defun viper-prefix-arg-com (char value com)
1235 cmd-to-exec-at-end)
1237 (viper-memq-char char
1239 viper-buffer-search-char)))
1246 (if (viper-memq-char char '(?# ?\")) (error ""))
1250 ;; ", we read the name of register and store it in viper-use-register.
1253 (cond ((viper-memq-char char '(?! ?=))
1257 ((viper= char ?#)
1261 ((viper= char ?\")
1263 (if (viper-valid-register reg)
1264 (setq viper-use-register reg)
1277 (while (viper= char ?U)
1278 (viper-describe-arg cmd-info)
1282 (or (viper-movement-command-p char)
1283 (viper-digit-command-p char)
1284 (viper-regsuffix-command-p char)
1285 (viper= char ?!) ; bang command
1286 (viper= char ?g) ; the gg command (like G0)
1288 (setq cmd-to-exec-at-end
1289 (viper-exec-form-in-vi
1290 `(key-binding (char-to-string ,char)))))
1292 ;; as com is non-nil, this means that we have a command to execute
1293 (if (viper-memq-char (car com) '(?r ?R))
1297 (if (viper= char ?r)
1298 (viper-region prefix-arg)
1299 (viper-Region prefix-arg))
1306 ;; If we change ?C to ?c here, then cc will enter replacement mode
1308 ;; than normal. We decided to not use replacement mode here and
1311 ((equal com '(?c . ?c)) (viper-line (cons value ?C)))
1312 ((equal com '(?d . ?d)) (viper-line (cons value ?D)))
1313 ((equal com '(?d . ?y)) (viper-yank-defun))
1314 ((equal com '(?y . ?y)) (viper-line (cons value ?Y)))
1315 ((equal com '(?< . ?<)) (viper-line (cons value ?<)))
1316 ((equal com '(?> . ?>)) (viper-line (cons value ?>)))
1317 ((equal com '(?! . ?!)) (viper-line (cons value ?!)))
1318 ((equal com '(?= . ?=)) (viper-line (cons value ?=)))
1320 ((equal (car com) ?g) (viper-goto-line 0))
1323 (if cmd-to-exec-at-end
1327 (viper-copy-event
1328 (if viper-xemacs-p (character-to-event char) char)))
1330 (funcall cmd-to-exec-at-end cmd-info)
1335 (defun viper-describe-arg (arg)
1337 (setq val (viper-P-val arg)
1338 com (viper-getcom arg))
1347 (defun viper-digit-argument (arg)
1350 (viper-leave-region-active)
1351 (viper-prefix-arg-value
1354 (defun viper-command-argument (arg)
1357 (let ((viper-intermediate-command 'viper-command-argument))
1359 (viper-prefix-arg-com
1364 (t (error viper-InvalidCommandArgument)))
1368 (t (error viper-InvalidCommandArgument))))
1369 (quit (setq viper-use-register nil)
1371 (viper-deactivate-mark)))
1377 ;; Append region to text in register REG.
1378 ;; START and END are buffer positions indicating what to append.
1379 (defsubst viper-append-to-register (reg start end)
1384 ;; Saves last inserted text for possible use by viper-repeat command.
1385 (defun viper-save-last-insertion (beg end)
1387 (setq viper-last-insertion (buffer-substring beg end))
1390 (setq viper-last-insertion nil)))
1391 (setq viper-last-insertion (buffer-substring beg end))
1392 (or (< (length viper-d-com) 5)
1393 (setcar (nthcdr 4 viper-d-com) viper-last-insertion))
1394 (or (null viper-command-ring)
1395 (ring-empty-p viper-command-ring)
1397 (setcar (nthcdr 4 (viper-current-ring-item viper-command-ring))
1398 viper-last-insertion)
1399 ;; del most recent elt, if identical to the second most-recent
1400 (viper-cleanup-ring viper-command-ring)))
1403 (defsubst viper-yank-last-insertion ()
1404 "Inserts the text saved by the previous viper-save-last-insertion command."
1406 (insert viper-last-insertion)
1410 ;; define functions to be executed
1413 (defun viper-exec-change (m-com com)
1414 (or (and (markerp viper-com-point) (marker-position viper-com-point))
1415 (set-marker viper-com-point (point) (current-buffer)))
1417 (if (or (and (eolp) (= viper-com-point (point)))
1418 (= viper-com-point (point-max)))
1421 (if (= viper-com-point (point))
1422 (viper-forward-char-carefully))
1423 (set-mark viper-com-point)
1424 (if (eq m-com 'viper-next-line-at-bol)
1425 (viper-enlarge-region (mark t) (point)))
1429 (viper-backward-char-carefully)) ; give back the newline
1430 (if (eq viper-intermediate-command 'viper-repeat)
1431 (viper-change-subr (mark t) (point))
1432 (viper-change (mark t) (point))
1435 ;; this is invoked by viper-substitute-line
1436 (defun viper-exec-Change (m-com com)
1438 (set-mark viper-com-point)
1439 (viper-enlarge-region (mark t) (point))
1440 (if viper-use-register
1442 (cond ((viper-valid-register viper-use-register '(letter digit))
1443 (copy-to-register
1444 viper-use-register (mark t) (point) nil))
1445 ((viper-valid-register viper-use-register '(Letter))
1446 (viper-append-to-register
1447 (downcase viper-use-register) (mark t) (point)))
1448 (t (setq viper-use-register nil)
1449 (error viper-InvalidRegister viper-use-register)))
1450 (setq viper-use-register nil)))
1453 (if (eq viper-intermediate-command 'viper-repeat)
1454 (viper-yank-last-insertion)
1455 (viper-change-state-to-insert)
1458 (defun viper-exec-delete (m-com com)
1459 (or (and (markerp viper-com-point) (marker-position viper-com-point))
1460 (set-marker viper-com-point (point) (current-buffer)))
1462 (if viper-use-register
1464 (cond ((viper-valid-register viper-use-register '(letter digit))
1465 (copy-to-register
1466 viper-use-register viper-com-point (point) nil))
1467 ((viper-valid-register viper-use-register '(Letter))
1468 (viper-append-to-register
1469 (downcase viper-use-register) viper-com-point (point)))
1470 (t (setq viper-use-register nil)
1471 (error viper-InvalidRegister viper-use-register)))
1472 (setq viper-use-register nil)))
1475 (setq chars-deleted (abs (- (point) viper-com-point)))
1476 (if (> chars-deleted viper-change-notification-threshold)
1477 (unless (viper-is-in-minibuffer)
1479 (kill-region viper-com-point (point))
1481 (if viper-ex-style-motion
1484 (defun viper-exec-Delete (m-com com)
1486 (set-mark viper-com-point)
1487 (viper-enlarge-region (mark t) (point))
1489 (if viper-use-register
1491 (cond ((viper-valid-register viper-use-register '(letter digit))
1492 (copy-to-register
1493 viper-use-register (mark t) (point) nil))
1494 ((viper-valid-register viper-use-register '(Letter))
1495 (viper-append-to-register
1496 (downcase viper-use-register) (mark t) (point)))
1497 (t (setq viper-use-register nil)
1498 (error viper-InvalidRegister viper-use-register)))
1499 (setq viper-use-register nil)))
1502 (setq lines-deleted (count-lines (point) viper-com-point))
1503 (if (> lines-deleted viper-change-notification-threshold)
1504 (unless (viper-is-in-minibuffer)
1507 (if (eq m-com 'viper-line) (setq this-command 'D-command)))
1508 (back-to-indentation)))
1511 (defun viper-exec-yank (m-com com)
1512 (or (and (markerp viper-com-point) (marker-position viper-com-point))
1513 (set-marker viper-com-point (point) (current-buffer)))
1515 (if viper-use-register
1517 (cond ((viper-valid-register viper-use-register '(letter digit))
1518 (copy-to-register
1519 viper-use-register viper-com-point (point) nil))
1520 ((viper-valid-register viper-use-register '(Letter))
1521 (viper-append-to-register
1522 (downcase viper-use-register) viper-com-point (point)))
1523 (t (setq viper-use-register nil)
1524 (error viper-InvalidRegister viper-use-register)))
1525 (setq viper-use-register nil)))
1527 (copy-region-as-kill viper-com-point (point))
1528 (setq chars-saved (abs (- (point) viper-com-point)))
1529 (if (> chars-saved viper-change-notification-threshold)
1530 (unless (viper-is-in-minibuffer)
1532 (goto-char viper-com-point)))
1535 (defun viper-exec-Yank (m-com com)
1537 (set-mark viper-com-point)
1538 (viper-enlarge-region (mark t) (point))
1540 (if viper-use-register
1542 (cond ((viper-valid-register viper-use-register '(letter digit))
1543 (copy-to-register
1544 viper-use-register (mark t) (point) nil))
1545 ((viper-valid-register viper-use-register '(Letter))
1546 (viper-append-to-register
1547 (downcase viper-use-register) (mark t) (point)))
1548 (t (setq viper-use-register nil)
1549 (error viper-InvalidRegister viper-use-register)))
1550 (setq viper-use-register nil)))
1554 (if (> lines-saved viper-change-notification-threshold)
1555 (unless (viper-is-in-minibuffer)
1557 (viper-deactivate-mark)
1558 (goto-char viper-com-point))
1560 (defun viper-exec-bang (m-com com)
1562 (set-mark viper-com-point)
1563 (viper-enlarge-region (mark t) (point))
1567 (if (viper= com ?!)
1568 (setq viper-last-shell-com
1569 (viper-read-string-with-history
1572 'viper-shell-history
1573 (car viper-shell-history)
1575 viper-last-shell-com)
1578 (defun viper-exec-equals (m-com com)
1580 (set-mark viper-com-point)
1581 (viper-enlarge-region (mark t) (point))
1585 (defun viper-exec-shift (m-com com)
1587 (set-mark viper-com-point)
1588 (viper-enlarge-region (mark t) (point))
1591 (if (viper= com ?>)
1592 viper-shift-width
1593 (- viper-shift-width))))
1594 ;; return point to where it was before shift
1595 (goto-char viper-com-point))
1597 ;; this is needed because some commands fake com by setting it to ?r, which
1599 (defsubst viper-exec-dummy (m-com com)
1602 (defun viper-exec-buffer-search (m-com com)
1603 (setq viper-s-string
1604 (regexp-quote (buffer-substring (point) viper-com-point)))
1605 (setq viper-s-forward t)
1606 (setq viper-search-history (cons viper-s-string viper-search-history))
1607 (setq viper-intermediate-command 'viper-exec-buffer-search)
1608 (viper-search viper-s-string viper-s-forward 1))
1610 (defvar viper-exec-array (make-vector 128 nil))
1612 ;; Using a dispatch array allows adding functions like buffer search
1614 ;; to any character.
1616 (aset viper-exec-array ?c 'viper-exec-change)
1617 (aset viper-exec-array ?C 'viper-exec-Change)
1618 (aset viper-exec-array ?d 'viper-exec-delete)
1619 (aset viper-exec-array ?D 'viper-exec-Delete)
1620 (aset viper-exec-array ?y 'viper-exec-yank)
1621 (aset viper-exec-array ?Y 'viper-exec-Yank)
1622 (aset viper-exec-array ?r 'viper-exec-dummy)
1623 (aset viper-exec-array ?! 'viper-exec-bang)
1624 (aset viper-exec-array ?< 'viper-exec-shift)
1625 (aset viper-exec-array ?> 'viper-exec-shift)
1626 (aset viper-exec-array ?= 'viper-exec-equals)
1630 ;; This function is called by various movement commands to execute a
1632 ;; instance, if the user types cw, then the command viper-forward-word will
1633 ;; call viper-execute-com to execute viper-exec-change, which eventually will
1634 ;; call viper-change to invoke the replace mode on the region.
1636 ;; The var viper-d-com is set to (M-COM VAL COM REG INSETED-TEXT COMMAND-KEYS)
1637 ;; via a call to viper-set-destructive-command, for later use by viper-repeat.
1638 (defun viper-execute-com (m-com val com)
1639 (let ((reg viper-use-register))
1642 (viper-special-prefix-com (- com 128))
1643 (let ((fn (aref viper-exec-array com)))
1645 (error "%c: %s" com viper-InvalidViCommand)
1647 (if (viper-dotable-command-p com)
1648 (viper-set-destructive-command
1653 (defun viper-repeat (arg)
1655 Use the info in viper-d-com, which has the form
1657 where `com' is the command to be re-executed, `val' is the
1658 argument to `com', `ch' is a flag for repeat, and `reg' is optional;
1664 ;; This tells viper-set-destructive-command not to update
1665 ;; viper-command-ring
1666 (viper-intermediate-command 'viper-repeat))
1667 (if (eq last-command 'viper-undo)
1668 ;; if the last command was viper-undo, then undo-more
1669 (viper-undo-more)
1670 ;; otherwise execute the command stored in viper-d-com. if arg is
1672 (let ((m-com (car viper-d-com))
1673 (val (viper-P-val arg))
1674 (com (nth 2 viper-d-com))
1675 (reg (nth 3 viper-d-com)))
1676 (if (null val) (setq val (nth 1 viper-d-com)))
1677 (if (null m-com) (error "No previous command to repeat"))
1678 (setq viper-use-register reg)
1679 (if (nth 4 viper-d-com) ; text inserted by command
1680 (setq viper-last-insertion (nth 4 viper-d-com)
1681 viper-d-char (nth 4 viper-d-com)))
1683 (cond ((and (< save-point (point)) viper-keep-point-on-repeat)
1684 (goto-char save-point)) ; go back to before repeat.
1685 ((and (< save-point (point)) viper-ex-style-editing)
1690 (viper-adjust-undo) ; take care of undo
1693 ;; If we are just executing previous command , then don't push viper-d-com
1694 ;; because viper-d-com is not fully constructed in this case (its keys and
1697 (if (eq last-command 'viper-display-current-destructive-command)
1698 (viper-push-onto-ring viper-d-com 'viper-command-ring))
1699 (viper-deactivate-mark)
1702 (defun viper-repeat-from-history ()
1704 Doesn't change viper-command-ring in any way, so `.' will work as before
1706 This command is supposed to be bound to a two-character Vi macro where
1707 the second character is a digit 0 to 9. The digit indicates which
1708 history command to execute. `<char>0' is equivalent to `.', `<char>1'
1711 (let* ((viper-intermediate-command 'repeating-display-destructive-command)
1712 (idx (cond (viper-this-kbd-macro
1713 (string-to-number
1714 (symbol-name (elt viper-this-kbd-macro 1))))
1717 (viper-d-com viper-d-com))
1724 "`viper-repeat-from-history' must be invoked as a Vi macro bound to `<key><digit>'")))
1726 (setq viper-d-com (viper-special-ring-rotate1 viper-command-ring -1))
1728 (viper-repeat nil)
1730 (viper-special-ring-rotate1 viper-command-ring 1)
1736 ;; The chars that can follow `#' are determined by viper-hash-command-p
1737 (defun viper-special-prefix-com (char)
1738 (cond ((viper= char ?c)
1739 (downcase-region (min viper-com-point (point))
1740 (max viper-com-point (point))))
1741 ((viper= char ?C)
1742 (upcase-region (min viper-com-point (point))
1743 (max viper-com-point (point))))
1744 ((viper= char ?g)
1745 (push-mark viper-com-point t)
1747 (viper-global-execute))
1748 ((viper= char ?q)
1749 (push-mark viper-com-point t)
1750 (viper-quote-region))
1751 ((viper= char ?s)
1752 (funcall viper-spell-function viper-com-point (point)))
1753 (t (error "#%c: %s" char viper-InvalidViCommand))))
1760 (defvar viper-undo-functions nil)
1762 ;; Runs viper-before-change-functions inside before-change-functions
1763 (defun viper-undo-sentinel (beg end length)
1764 (run-hook-with-args 'viper-undo-functions beg end length))
1766 (add-hook 'after-change-functions 'viper-undo-sentinel)
1768 ;; Hook used in viper-undo
1769 (defun viper-after-change-undo-hook (beg end len)
1774 ;; the buffer in response to 'undo'; so remove this hook to avoid
1776 (remove-hook 'viper-undo-functions 'viper-after-change-undo-hook 'local)
1779 (defun viper-undo ()
1787 ;; the viper-after-change-undo-hook removes itself after the 1st invocation
1788 (add-hook 'viper-undo-functions 'viper-after-change-undo-hook nil 'local)
1801 (if (and viper-keep-point-on-undo
1805 (viper-sit-for-short 300)
1807 (viper-sit-for-short 300)
1816 (setq this-command 'viper-undo))
1819 (defun viper-undo-more ()
1826 (setq this-command 'viper-undo))
1828 ;; The following two functions are used to set up undo properly.
1831 (defun viper-adjust-undo ()
1832 (if viper-undo-needs-adjustment
1835 (setq viper-undo-needs-adjustment nil)
1837 (if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list))
1847 (delq viper-buffer-undo-list-mark buffer-undo-list))
1854 (defun viper-set-complex-command-for-undo ()
1856 (if (not viper-undo-needs-adjustment)
1859 (cons viper-buffer-undo-list-mark buffer-undo-list))
1860 (setq viper-undo-needs-adjustment t)))))
1865 (defun viper-display-current-destructive-command ()
1866 (let ((text (nth 4 viper-d-com))
1867 (keys (nth 5 viper-d-com))
1870 (setq this-command 'viper-display-current-destructive-command)
1873 (concat "`" (viper-array-to-string keys) "'")
1874 (viper-abbreviate-string
1875 (viper-cond-compile-for-xemacs-or-emacs
1876 (replace-in-string ; xemacs
1877 (cond ((characterp text) (char-to-string text))
1888 ;; don't change viper-d-com if it was viper-repeat command invoked with `.'
1890 (defun viper-set-destructive-command (list)
1891 (or (eq viper-intermediate-command 'viper-repeat)
1893 (setq viper-d-com list)
1894 (setcar (nthcdr 5 viper-d-com)
1895 (viper-array-to-string (if (arrayp viper-this-command-keys)
1896 viper-this-command-keys
1898 (viper-push-onto-ring viper-d-com 'viper-command-ring)))
1899 (setq viper-this-command-keys nil))
1902 (defun viper-prev-destructive-command (next)
1906 (let (cmd viper-intermediate-command)
1907 (if (eq last-command 'viper-display-current-destructive-command)
1909 (setq viper-intermediate-command
1912 (setq viper-temp-command-ring (copy-list viper-command-ring)))
1914 (viper-special-ring-rotate1 viper-temp-command-ring 1)
1915 (viper-special-ring-rotate1 viper-temp-command-ring -1)))
1918 (setq viper-d-com cmd))
1919 (viper-display-current-destructive-command)))
1922 (defun viper-next-destructive-command ()
1925 (viper-prev-destructive-command 'next))
1928 (defun viper-insert-prev-from-insertion-ring (arg)
1933 to in the global map, instead of cycling through the insertion ring."
1935 (let (viper-intermediate-command)
1936 (if (eq last-command 'viper-insert-from-insertion-ring)
1938 (setq viper-intermediate-command 'repeating-insertion-from-ring)
1939 (if (eq viper-current-state 'replace-state)
1941 (if viper-last-inserted-string-from-insertion-ring
1943 (length viper-last-inserted-string-from-insertion-ring))))
1946 (setq viper-temp-insertion-ring (copy-list viper-insertion-ring)))
1947 (setq this-command 'viper-insert-from-insertion-ring)
1950 (setq viper-last-inserted-string-from-insertion-ring
1951 (viper-special-ring-rotate1 viper-temp-insertion-ring (if arg 1 -1)))
1953 ;; this change of viper-intermediate-command must come after
1954 ;; viper-special-ring-rotate1, so that the ring will rotate, but before the
1956 (setq viper-intermediate-command nil)
1957 (if viper-last-inserted-string-from-insertion-ring
1958 (insert viper-last-inserted-string-from-insertion-ring))
1961 (defun viper-insert-next-from-insertion-ring ()
1965 (viper-insert-prev-from-insertion-ring 'next))
1973 (defun viper-add-newline-at-eob-if-necessary ()
1986 (not (viper-is-in-minibuffer))
1995 (defun viper-yank-defun ()
2000 (defun viper-enlarge-region (beg end)
2001 (or beg (setq beg end)) ; if beg is nil, set to end
2002 (or end (setq end beg)) ; if end is nil, set to beg
2015 ;; Quote region by each line with a user supplied string.
2016 (defun viper-quote-region ()
2017 (let ((quote-str viper-quote-string)
2020 (viper-read-string-with-history
2021 "Quote string: "
2023 'viper-quote-region-history
2024 (cond ((string-match "tex.*-mode" (symbol-name major-mode)) "%%")
2025 ((string-match "java.*-mode" (symbol-name major-mode)) "//")
2026 ((string-match "perl.*-mode" (symbol-name major-mode)) "#")
2027 ((string-match "lisp.*-mode" (symbol-name major-mode)) ";;")
2033 (setq viper-quote-string quote-str))
2034 (viper-enlarge-region (point) (mark t))
2046 (defun viper-same-line (beg end)
2060 (if (= (viper-line-pos 'start) end)
2066 ;; Check if the string ends with a newline.
2067 (defun viper-end-with-a-newline-p (string)
2068 (or (string= string "")
2069 (= (viper-seq-last-elt string) ?\n)))
2071 (defun viper-tmp-insert-at-eob (msg)
2084 (defsubst viper-set-minibuffer-style ()
2085 (add-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)
2086 (add-hook 'post-command-hook 'viper-minibuffer-post-command-hook))
2089 (defun viper-minibuffer-setup-sentinel ()
2090 (let ((hook (if viper-vi-style-in-minibuffer
2091 'viper-change-state-to-insert
2092 'viper-change-state-to-emacs)))
2097 (make-local-variable 'viper-d-com)
2098 (make-local-variable 'viper-last-insertion)
2099 (make-local-variable 'viper-command-ring)
2100 (setq viper-d-com nil
2101 viper-last-insertion nil
2102 viper-command-ring nil)
2107 ;; A dirty feature, but it is the simplest way to have it do the right thing.
2109 ;; viper-read-string-with-history
2110 (defun viper-minibuffer-standard-hook ()
2112 (viper-tmp-insert-at-eob init-message))
2124 (defsubst viper-minibuffer-real-start ()
2129 (defun viper-minibuffer-post-command-hook()
2131 (when (< (point) (viper-minibuffer-real-start))
2132 (goto-char (viper-minibuffer-real-start)))))
2136 ;; Run viper-minibuffer-exit-hook before exiting.
2137 (defun viper-exit-minibuffer ()
2141 (setq command (local-key-binding (char-to-string last-command-char)))
2142 (run-hooks 'viper-minibuffer-exit-hook)
2148 (defcustom viper-smart-suffix-list
2151 "*List of suffixes that Viper tries to append to filenames ending with a `.'.
2160 suffixes, the user is asked to confirm.
2162 To turn this feature off, set this variable to nil."
2163 :type '(repeat string)
2164 :group 'viper-misc)
2167 ;; Try to add a suitable suffix to files whose name ends with a `.'
2170 (defun viper-file-add-suffix ()
2172 (len (length viper-smart-suffix-list))
2174 (viper-minibuffer-real-start) (point-max)))
2177 (if (and viper-smart-suffix-list (string-match "\\.$" file))
2180 (setq suff (nth count viper-smart-suffix-list)
2190 (viper-tmp-insert-at-eob " [Please complete file name]")
2193 '(exit-minibuffer viper-exit-minibuffer)))
2197 (viper-cond-compile-for-xemacs-or-emacs
2198 (insert (events-to-keys key)) ; xemacs
2201 ((memq cmd '(exit-minibuffer viper-exit-minibuffer))
2208 (defun viper-minibuffer-trim-tail ()
2210 Remove this function from `viper-minibuffer-exit-hook', if this causes
2212 (if (viper-is-in-minibuffer)
2214 (goto-char (viper-minibuffer-real-start))
2220 ;;; Reading string with history
2222 (defun viper-read-string-with-history (prompt &optional initial
2225 ;; Read string, prompting with PROMPT and inserting the INITIAL
2226 ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
2227 ;; input is an empty string.
2240 'viper-minibuffer-standard-hook
2253 (setq viper-incomplete-ex-cmd nil)
2258 padding (viper-array-to-string (this-command-keys))
2260 ;; the following tries to be smart about what to put in history
2261 (if (not (string= val (car (eval history-var))))
2263 (if (or (string= (nth 0 (eval history-var)) (nth 1 (eval history-var)))
2264 (string= (nth 0 (eval history-var)) ""))
2266 ;; If the user enters nothing but the prev cmd wasn't viper-ex,
2267 ;; viper-command-argument, or `! shell-command', this probably means
2270 (cond ((and (string= val "")
2271 (not (string= prompt "!")) ; was a `! shell-command'
2273 '(viper-ex
2274 viper-command-argument
2278 ((string= val "") (or default ""))
2290 (defun viper-repeat-insert-command ()
2291 (let ((i-com (car viper-d-com))
2292 (val (nth 1 viper-d-com))
2293 (char (nth 2 viper-d-com)))
2296 (setq viper-d-com (list i-com (1- val) ?r nil nil nil))
2297 (viper-repeat nil)
2298 (setq viper-d-com (list i-com val char nil nil nil))
2301 (defun viper-insert (arg)
2304 (viper-set-complex-command-for-undo)
2305 (let ((val (viper-p-val arg))
2306 ;;(com (viper-getcom arg))
2308 (viper-set-destructive-command (list 'viper-insert val ?r nil nil nil))
2309 (if (eq viper-intermediate-command 'viper-repeat)
2310 (viper-loop val (viper-yank-last-insertion))
2311 (viper-change-state-to-insert))))
2313 (defun viper-append (arg)
2316 (viper-set-complex-command-for-undo)
2317 (let ((val (viper-p-val arg))
2318 ;;(com (viper-getcom arg))
2320 (viper-set-destructive-command (list 'viper-append val ?r nil nil nil))
2322 (if (eq viper-intermediate-command 'viper-repeat)
2323 (viper-loop val (viper-yank-last-insertion))
2324 (viper-change-state-to-insert))))
2326 (defun viper-Append (arg)
2329 (viper-set-complex-command-for-undo)
2330 (let ((val (viper-p-val arg))
2331 ;;(com (viper-getcom arg))
2333 (viper-set-destructive-command (list 'viper-Append val ?r nil nil nil))
2335 (if (eq viper-intermediate-command 'viper-repeat)
2336 (viper-loop val (viper-yank-last-insertion))
2337 (viper-change-state-to-insert))))
2339 (defun viper-Insert (arg)
2342 (viper-set-complex-command-for-undo)
2343 (let ((val (viper-p-val arg))
2344 ;;(com (viper-getcom arg))
2346 (viper-set-destructive-command (list 'viper-Insert val ?r nil nil nil))
2347 (back-to-indentation)
2348 (if (eq viper-intermediate-command 'viper-repeat)
2349 (viper-loop val (viper-yank-last-insertion))
2350 (viper-change-state-to-insert))))
2352 (defun viper-open-line (arg)
2355 (viper-set-complex-command-for-undo)
2356 (let ((val (viper-p-val arg))
2357 ;;(com (viper-getcom arg))
2359 (viper-set-destructive-command (list 'viper-open-line val ?r nil nil nil))
2361 (if (eq viper-intermediate-command 'viper-repeat)
2362 (viper-loop val
2365 (viper-indent-line col)
2366 (viper-yank-last-insertion))
2369 (viper-indent-line col)
2370 (viper-change-state-to-insert)))))
2372 (defun viper-Open-line (arg)
2375 (viper-set-complex-command-for-undo)
2376 (let ((val (viper-p-val arg))
2377 ;;(com (viper-getcom arg))
2379 (viper-set-destructive-command (list 'viper-Open-line val ?r nil nil nil))
2381 (if (eq viper-intermediate-command 'viper-repeat)
2382 (viper-loop val
2385 (viper-indent-line col)
2386 (viper-yank-last-insertion))
2389 (viper-indent-line col)
2390 (viper-change-state-to-insert)))))
2392 (defun viper-open-line-at-point (arg)
2395 (viper-set-complex-command-for-undo)
2396 (let ((val (viper-p-val arg))
2397 ;;(com (viper-getcom arg))
2399 (viper-set-destructive-command
2400 (list 'viper-open-line-at-point val ?r nil nil nil))
2401 (if (eq viper-intermediate-command 'viper-repeat)
2402 (viper-loop val
2404 (viper-yank-last-insertion))
2406 (viper-change-state-to-insert))))
2408 ;; bound to s
2409 (defun viper-substitute (arg)
2412 (let ((val (viper-p-val arg))
2413 ;;(com (viper-getcom arg))
2417 (if (eq viper-intermediate-command 'viper-repeat)
2418 (viper-change-subr (mark t) (point))
2419 (viper-change (mark t) (point)))
2420 ;; com is set to ?r when we repeat this comand with dot
2421 (viper-set-destructive-command (list 'viper-substitute val ?r nil nil nil))
2424 ;; Command bound to S
2425 (defun viper-substitute-line (arg)
2428 (viper-set-complex-command-for-undo)
2429 (viper-line (cons arg ?C)))
2432 (defun viper-start-replace ()
2433 (setq viper-began-as-replace t
2434 viper-sitting-in-replace t
2435 viper-replace-chars-to-delete 0)
2437 'viper-after-change-functions 'viper-replace-mode-spy-after t 'local)
2439 'viper-before-change-functions 'viper-replace-mode-spy-before t 'local)
2441 (add-hook 'after-change-functions 'viper-after-change-sentinel t)
2442 (add-hook 'before-change-functions 'viper-before-change-sentinel t)
2443 (viper-move-marker-locally
2444 'viper-last-posn-in-replace-region (viper-replace-start))
2446 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel
2449 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel t 'local)
2450 ;; guard against a smartie who switched from R-replace to normal replace
2452 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local)
2457 (defun viper-replace-mode-spy-before (beg end)
2458 (setq viper-replace-region-chars-deleted (viper-chars-in-region beg end))
2461 ;; Invoked as an after-change-function to calculate how many chars have to be
2466 (defun viper-replace-mode-spy-after (beg end length)
2467 (if (memq viper-intermediate-command
2472 (setq viper-replace-chars-to-delete 0)
2473 (viper-move-marker-locally
2474 'viper-last-posn-in-replace-region (point)))
2476 (let* ((real-end (min end (viper-replace-end)))
2484 (setq chars-deleted viper-replace-region-chars-deleted))
2485 (setq viper-replace-region-chars-deleted 0)
2486 (setq viper-replace-chars-to-delete
2487 (+ viper-replace-chars-to-delete
2489 ;; if column shift is bigger, due to a TAB insertion, take
2491 (max (viper-chars-in-region beg real-end)
2498 ;; Since it is hard to
2500 ;; given region, we decided to treat Eastern and European
2504 quoted-insert viper-insert-tab))
2510 (viper-move-marker-locally
2511 'viper-last-posn-in-replace-region
2512 (max (if (> end (viper-replace-end)) (viper-replace-end) end)
2513 (or (marker-position viper-last-posn-in-replace-region)
2514 (viper-replace-start))
2520 ;; Delete stuff between viper-last-posn-in-replace-region and the end of
2521 ;; viper-replace-overlay-marker, if viper-last-posn-in-replace-region is within
2524 (defun viper-finish-change ()
2526 'viper-after-change-functions 'viper-replace-mode-spy-after 'local)
2528 'viper-before-change-functions 'viper-replace-mode-spy-before 'local)
2530 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local)
2532 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local)
2533 (viper-restore-cursor-color 'after-replace-mode)
2534 (setq viper-sitting-in-replace nil) ; just in case we'll need to know it
2536 (if (and viper-replace-overlay
2537 (viper-pos-within-region viper-last-posn-in-replace-region
2538 (viper-replace-start)
2539 (viper-replace-end))
2540 (< (point) (viper-replace-end)))
2542 viper-last-posn-in-replace-region (viper-replace-end))))
2544 (if (eq viper-current-state 'replace-state)
2545 (viper-downgrade-to-insert))
2546 ;; replace mode ended => nullify viper-last-posn-in-replace-region
2547 (viper-move-marker-locally 'viper-last-posn-in-replace-region nil)
2548 (viper-hide-replace-overlay)
2549 (viper-refresh-mode-line)
2550 (viper-put-string-on-kill-ring viper-last-replace-region)
2554 (defun viper-put-string-on-kill-ring (string)
2555 (setq kill-ring (cons string kill-ring))
2560 (defun viper-finish-R-mode ()
2562 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local)
2564 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local)
2565 (viper-downgrade-to-insert))
2567 (defun viper-start-R-mode ()
2571 'viper-post-command-hooks 'viper-R-state-post-command-sentinel t 'local)
2573 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel t 'local)
2574 ;; guard against a smartie who switched from R-replace to normal replace
2576 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local)
2581 (defun viper-replace-state-exit-cmd ()
2582 "Binding for keys that cause Replace state to switch to Vi or to Insert.
2586 (viper-finish-R-mode)
2587 (viper-finish-change))
2589 (if (eq this-command 'viper-intercept-ESC-key)
2590 (setq com 'viper-exit-insert-state)
2591 (viper-set-unread-command-events last-input-char)
2592 (setq com (key-binding (viper-read-key-sequence nil))))
2597 (viper-message-conditions conds)))
2599 (viper-hide-replace-overlay))
2602 (defun viper-replace-state-carriage-return ()
2606 ;; text-property maps, we could do away with viper-replace-minor-mode and
2607 ;; just have keymap attached to replace overlay. Then the "if part" of this
2609 (if (or (< (point) (viper-replace-start))
2610 (> (point) (viper-replace-end)))
2611 (let (viper-replace-minor-mode com)
2612 (viper-set-unread-command-events last-input-char)
2617 (viper-message-conditions conds))))
2618 (if (not viper-allow-multiline-replace-regions)
2619 (viper-replace-state-exit-cmd)
2620 (if (viper-same-line (point) (viper-replace-end))
2621 (viper-replace-state-exit-cmd)
2623 (delete-region (point) (viper-line-pos 'end))
2627 ;; skip to the next line
2629 (back-to-indentation)
2633 ;; This is the function bound to 'R'---unlimited replace.
2634 ;; Similar to Emacs's own overwrite-mode.
2635 (defun viper-overwrite (arg)
2638 (let ((val (viper-p-val arg))
2639 ;;(com (viper-getcom arg))
2641 (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil))
2642 (if (eq viper-intermediate-command 'viper-repeat)
2644 ;; Viper saves inserted text in viper-last-insertion
2645 (setq len (length viper-last-insertion))
2647 (viper-loop val (viper-yank-last-insertion)))
2648 (setq last-command 'viper-overwrite)
2649 (viper-set-complex-command-for-undo)
2650 (viper-set-replace-overlay (point) (viper-line-pos 'end))
2651 (viper-change-state-to-replace)
2658 (defun viper-line (arg)
2661 (viper-move-marker-locally 'viper-com-point (point))
2663 (viper-next-line-carefully (1- val)))
2666 (viper-add-newline-at-eob-if-necessary)
2667 (viper-execute-com 'viper-line val com))
2671 (defun viper-yank-line (arg)
2674 (let ((val (viper-p-val arg)))
2675 (viper-line (cons val ?Y))))
2681 (defun viper-region (arg)
2684 (let ((val (viper-P-val arg))
2685 (com (viper-getcom arg)))
2686 (viper-move-marker-locally 'viper-com-point (point))
2688 (viper-execute-com 'viper-region val com)))
2690 (defun viper-Region (arg)
2693 (let ((val (viper-P-val arg))
2694 (com (viper-getCom arg)))
2695 (viper-move-marker-locally 'viper-com-point (point))
2697 (viper-execute-com 'viper-Region val com)))
2699 (defun viper-replace-char (arg)
2702 (if (and (eolp) (bolp)) (error "No character to replace here"))
2703 (let ((val (viper-p-val arg))
2704 (com (viper-getcom arg)))
2705 (viper-replace-char-subr com val)
2707 (setq viper-this-command-keys
2709 (viper-set-destructive-command
2710 (list 'viper-replace-char val ?r nil viper-d-char nil))
2713 (defun viper-replace-char-subr (com arg)
2716 (viper-set-complex-command-for-undo)
2717 (or (eq viper-intermediate-command 'viper-repeat)
2718 (viper-special-read-and-insert-char))
2721 (setq char (if com viper-d-char (viper-char-at-pos 'backward)))
2725 (setq viper-d-char char)
2727 (viper-loop (1- (if (> arg 0) arg (- arg)))
2731 (viper-adjust-undo)
2739 (defun viper-forward-char (arg)
2743 (viper-leave-region-active)
2744 (let ((val (viper-p-val arg))
2745 (com (viper-getcom arg)))
2746 (if com (viper-move-marker-locally 'viper-com-point (point)))
2747 (if viper-ex-style-motion
2751 ;; just like 'x' for the last char on a line, so we have to allow
2752 ;; the forward motion before the 'viper-execute-com', but, of
2753 ;; course, 'dl' doesn't work on an empty line, so we have to
2754 ;; catch that condition before 'viper-execute-com'
2756 (if com (viper-execute-com 'viper-forward-char val com))
2759 (if com (viper-execute-com 'viper-forward-char val com)))))
2762 (defun viper-backward-char (arg)
2766 (viper-leave-region-active)
2767 (let ((val (viper-p-val arg))
2768 (com (viper-getcom arg)))
2769 (if com (viper-move-marker-locally 'viper-com-point (point)))
2770 (if viper-ex-style-motion
2773 (if com (viper-execute-com 'viper-backward-char val com)))
2775 (if com (viper-execute-com 'viper-backward-char val com)))))
2781 (defun viper-forward-char-carefully (&optional arg)
2788 (- (viper-chars-in-region pt (point)))
2789 (viper-chars-in-region pt (point)))))
2795 (defun viper-backward-char-carefully (&optional arg)
2802 (viper-chars-in-region pt (point))
2803 (- (viper-chars-in-region pt (point))))))
2805 (defun viper-next-line-carefully (arg)
2817 ;; untouched for the last word. Viper uses syntax table to determine what is a
2819 ;; viper-syntax-preference is 'vi, then `_' is part of the word.
2822 (defun viper-skip-separators (forward)
2825 (viper-skip-all-separators-forward 'within-line)
2829 (viper-skip-all-separators-forward 'within-line))))
2832 (viper-backward-char-carefully)
2833 (viper-looking-at-separator)))
2834 (viper-backward-char-carefully))
2835 (viper-skip-all-separators-backward 'within-line)
2836 (viper-backward-char-carefully)
2838 (viper-skip-all-separators-backward 'within-line)
2839 (or (viper-looking-at-separator) (forward-char)))))
2842 (defun viper-forward-word-kernel (val)
2844 (cond ((viper-looking-at-alpha)
2845 (viper-skip-alpha-forward "_")
2846 (viper-skip-separators t))
2847 ((viper-looking-at-separator)
2848 (viper-skip-separators t))
2849 ((not (viper-looking-at-alphasep))
2850 (viper-skip-nonalphasep-forward)
2851 (viper-skip-separators t)))
2856 (defun viper-separator-skipback-special (twice lim)
2857 (let ((prev-char (viper-char-at-pos 'backward))
2860 (while (and (not (viper-memq-char prev-char '(nil \n)))
2863 (if (eq viper-syntax-preference 'strict-vi)
2864 (viper-memq-char prev-char '(?\ ?\t))
2865 (viper-memq-char (char-syntax prev-char) '(?\ ?-))))
2866 (viper-backward-char-carefully)
2867 (setq prev-char (viper-char-at-pos 'backward)))
2871 ;; If we skipped to the next word and the prefix of this line doesn't
2875 (setq prev-char (viper-char-at-pos 'backward))
2879 (while (and (not (viper-memq-char prev-char '(nil \n)))
2882 (if (eq viper-syntax-preference 'strict-vi)
2883 (viper-memq-char prev-char '(?\ ?\t))
2884 (viper-memq-char (char-syntax prev-char) '(?\ ?-))))
2885 (viper-backward-char-carefully)
2886 (setq prev-char (viper-char-at-pos 'backward))))
2889 (viper-forward-char-carefully))
2893 (defun viper-forward-word (arg)
2896 (viper-leave-region-active)
2897 (let ((val (viper-p-val arg))
2898 (com (viper-getcom arg)))
2899 (if com (viper-move-marker-locally 'viper-com-point (point)))
2900 (viper-forward-word-kernel val)
2903 (cond ((viper-char-equal com ?c)
2904 (viper-separator-skipback-special 'twice viper-com-point))
2906 ((viper-char-equal com ?y)
2907 (viper-separator-skipback-special nil viper-com-point))
2908 ((viper-dotable-command-p com)
2909 (viper-separator-skipback-special nil viper-com-point)))
2910 (viper-execute-com 'viper-forward-word val com)))
2914 (defun viper-forward-Word (arg)
2917 (viper-leave-region-active)
2918 (let ((val (viper-p-val arg))
2919 (com (viper-getcom arg)))
2920 (if com (viper-move-marker-locally 'viper-com-point (point)))
2921 (viper-loop val
2922 (viper-skip-nonseparators 'forward)
2923 (viper-skip-separators t))
2925 (cond ((viper-char-equal com ?c)
2926 (viper-separator-skipback-special 'twice viper-com-point))
2928 ((viper-char-equal com ?y)
2929 (viper-separator-skipback-special nil viper-com-point))
2930 ((viper-dotable-command-p com)
2931 (viper-separator-skipback-special nil viper-com-point)))
2932 (viper-execute-com 'viper-forward-Word val com)))))
2937 (defun viper-end-of-word-kernel ()
2938 (if (viper-end-of-word-p) (forward-char))
2939 (if (viper-looking-at-separator)
2940 (viper-skip-all-separators-forward))
2942 (cond ((viper-looking-at-alpha) (viper-skip-alpha-forward "_"))
2943 ((not (viper-looking-at-alphasep)) (viper-skip-nonalphasep-forward)))
2944 (viper-backward-char-carefully))
2946 (defun viper-end-of-word-p ()
2949 (cond ((viper-looking-at-alpha)
2951 (not (viper-looking-at-alpha)))
2952 ((not (viper-looking-at-alphasep))
2954 (viper-looking-at-alphasep))))))
2957 (defun viper-end-of-word (arg &optional careful)
2958 "Move point to end of current word."
2960 (viper-leave-region-active)
2961 (let ((val (viper-p-val arg))
2962 (com (viper-getcom arg)))
2963 (if com (viper-move-marker-locally 'viper-com-point (point)))
2964 (viper-loop val (viper-end-of-word-kernel))
2968 (viper-execute-com 'viper-end-of-word val com)))))
2970 (defun viper-end-of-Word (arg)
2971 "Forward to end of word delimited by white character."
2973 (viper-leave-region-active)
2974 (let ((val (viper-p-val arg))
2975 (com (viper-getcom arg)))
2976 (if com (viper-move-marker-locally 'viper-com-point (point)))
2977 (viper-loop val
2978 (viper-end-of-word-kernel)
2979 (viper-skip-nonseparators 'forward)
2984 (viper-execute-com 'viper-end-of-Word val com)))))
2986 (defun viper-backward-word-kernel (val)
2988 (viper-backward-char-carefully)
2989 (cond ((viper-looking-at-alpha)
2990 (viper-skip-alpha-backward "_"))
2991 ((viper-looking-at-separator)
2993 (viper-skip-separators nil)
2994 (viper-backward-char-carefully)
2995 (cond ((viper-looking-at-alpha)
2996 (viper-skip-alpha-backward "_"))
2997 ((not (viper-looking-at-alphasep))
2998 (viper-skip-nonalphasep-backward))
3001 ((not (viper-looking-at-alphasep))
3002 (viper-skip-nonalphasep-backward)))
3005 (defun viper-backward-word (arg)
3008 (viper-leave-region-active)
3009 (let ((val (viper-p-val arg))
3010 (com (viper-getcom arg)))
3015 (viper-move-marker-locally 'viper-com-point (point))
3017 (viper-backward-word-kernel val)
3018 (if com (viper-execute-com 'viper-backward-word val com))))
3020 (defun viper-backward-Word (arg)
3023 (viper-leave-region-active)
3024 (let ((val (viper-p-val arg))
3025 (com (viper-getcom arg)))
3030 (viper-move-marker-locally 'viper-com-point (point))
3032 (viper-loop val
3033 (viper-skip-separators nil) ; nil means backward here
3034 (viper-skip-nonseparators 'backward))
3035 (if com (viper-execute-com 'viper-backward-Word val com))))
3042 (defun viper-beginning-of-line (arg)
3043 "Go to beginning of line."
3045 (viper-leave-region-active)
3046 (let ((val (viper-p-val arg))
3047 (com (viper-getcom arg)))
3048 (if com (viper-move-marker-locally 'viper-com-point (point)))
3050 (if com (viper-execute-com 'viper-beginning-of-line val com))))
3052 (defun viper-bol-and-skip-white (arg)
3055 (viper-leave-region-active)
3056 (let ((val (viper-p-val arg))
3057 (com (viper-getcom arg)))
3058 (if com (viper-move-marker-locally 'viper-com-point (point)))
3059 (forward-to-indentation (1- val))
3060 (if com (viper-execute-com 'viper-bol-and-skip-white val com))))
3062 (defun viper-goto-eol (arg)
3063 "Go to end of line."
3065 (viper-leave-region-active)
3066 (let ((val (viper-p-val arg))
3067 (com (viper-getcom arg)))
3068 (if com (viper-move-marker-locally 'viper-com-point (point)))
3070 (if com (viper-execute-com 'viper-goto-eol val com))
3071 (if viper-ex-style-motion
3073 ;; a fix for viper-change-to-eol
3074 (not (equal viper-current-state 'insert-state)))
3079 (defun viper-goto-col (arg)
3080 "Go to ARG's column."
3082 (viper-leave-region-active)
3083 (let ((val (viper-p-val arg))
3084 (com (viper-getcom arg))
3087 (viper-chars-in-region
3088 (viper-line-pos 'start) (viper-line-pos 'end)))
3089 (if com (viper-move-marker-locally 'viper-com-point (point)))
3094 (if com (viper-execute-com 'viper-goto-col val com))
3101 (defun viper-next-line (arg)
3102 "Go to next line."
3104 (viper-leave-region-active)
3105 (let ((val (viper-p-val arg))
3106 (com (viper-getCom arg)))
3107 (if com (viper-move-marker-locally 'viper-com-point (point)))
3109 (if viper-ex-style-motion
3112 (if com (viper-execute-com 'viper-next-line val com))))
3115 (defun viper-next-line-at-bol (arg)
3132 (viper-leave-region-active)
3136 (let ((val (viper-p-val arg))
3137 (com (viper-getCom arg)))
3138 (if com (viper-move-marker-locally 'viper-com-point (point)))
3140 (back-to-indentation)
3141 (if com (viper-execute-com 'viper-next-line-at-bol val com)))))))
3144 (defun viper-previous-line (arg)
3145 "Go to previous line."
3147 (viper-leave-region-active)
3148 (let ((val (viper-p-val arg))
3149 (com (viper-getCom arg)))
3150 (if com (viper-move-marker-locally 'viper-com-point (point)))
3152 (if viper-ex-style-motion
3155 (if com (viper-execute-com 'viper-previous-line val com))))
3158 (defun viper-previous-line-at-bol (arg)
3161 (viper-leave-region-active)
3165 (let ((val (viper-p-val arg))
3166 (com (viper-getCom arg)))
3167 (if com (viper-move-marker-locally 'viper-com-point (point)))
3169 (back-to-indentation)
3170 (if com (viper-execute-com 'viper-previous-line val com))))
3172 (defun viper-change-to-eol (arg)
3173 "Change to end of line."
3175 (viper-goto-eol (cons arg ?c)))
3177 (defun viper-kill-line (arg)
3180 (viper-goto-eol (cons arg ?d)))
3182 (defun viper-erase-line (arg)
3185 (viper-beginning-of-line (cons arg ?d)))
3191 (defun viper-goto-line (arg)
3192 "Go to ARG's line. Without ARG go to end of buffer."
3194 (let ((val (viper-P-val arg))
3195 (com (viper-getCom arg)))
3196 (viper-move-marker-locally 'viper-com-point (point))
3197 (viper-deactivate-mark)
3206 (back-to-indentation)
3208 (if com (viper-execute-com 'viper-goto-line val com))
3211 (back-to-indentation)
3215 ;; If FORWARD then search is forward, otherwise backward. OFFSET is used to
3217 (defun viper-find-char (arg char forward offset)
3218 (or (char-or-string-p char) (error ""))
3220 (cmd (if (eq viper-intermediate-command 'viper-repeat)
3221 (nth 5 viper-d-com)
3222 (viper-array-to-string (this-command-keys))))
3229 (if viper-allow-multiline-replace-regions
3230 (viper-forward-paragraph 1)
3234 (if viper-allow-multiline-replace-regions
3235 (viper-backward-paragraph 1)
3240 (if viper-allow-multiline-replace-regions
3245 (if viper-allow-multiline-replace-regions
3251 (if viper-allow-multiline-replace-regions
3253 (narrow-to-region region-beg region-end)
3258 (search-forward (char-to-string char) nil 0 arg))
3266 (defun viper-find-char-forward (arg)
3268 If called interactively read the char to find from the terminal, and if
3269 called from viper-repeat, the char last used is used. This behavior is
3272 (let ((val (viper-p-val arg))
3273 (com (viper-getcom arg))
3274 (cmd-representation (nth 5 viper-d-com)))
3277 (setq viper-f-char (read-char)
3278 viper-f-forward t
3279 viper-f-offset nil)
3280 ;; viper-repeat --- set viper-F-char from command-keys
3281 (setq viper-F-char (if (stringp cmd-representation)
3282 (viper-seq-last-elt cmd-representation)
3283 viper-F-char)
3284 viper-f-char viper-F-char)
3286 (if com (viper-move-marker-locally 'viper-com-point (point)))
3287 (viper-find-char
3288 val (if (> (viper-p-val arg) 0) viper-f-char viper-F-char) t nil)
3292 (setq viper-F-char viper-f-char) ; set new viper-F-char
3294 (viper-execute-com 'viper-find-char-forward val com)))))
3296 (defun viper-goto-char-forward (arg)
3297 "Go up to char ARG forward on line."
3299 (let ((val (viper-p-val arg))
3300 (com (viper-getcom arg))
3301 (cmd-representation (nth 5 viper-d-com)))
3304 (setq viper-f-char (read-char)
3305 viper-f-forward t
3306 viper-f-offset t)
3307 ;; viper-repeat --- set viper-F-char from command-keys
3308 (setq viper-F-char (if (stringp cmd-representation)
3309 (viper-seq-last-elt cmd-representation)
3310 viper-F-char)
3311 viper-f-char viper-F-char)
3313 (if com (viper-move-marker-locally 'viper-com-point (point)))
3314 (viper-find-char
3315 val (if (> (viper-p-val arg) 0) viper-f-char viper-F-char) t t)
3319 (setq viper-F-char viper-f-char) ; set new viper-F-char
3321 (viper-execute-com 'viper-goto-char-forward val com)))))
3323 (defun viper-find-char-backward (arg)
3326 (let ((val (viper-p-val arg))
3327 (com (viper-getcom arg))
3328 (cmd-representation (nth 5 viper-d-com)))
3331 (setq viper-f-char (read-char)
3332 viper-f-forward nil
3333 viper-f-offset nil)
3334 ;; viper-repeat --- set viper-F-char from command-keys
3335 (setq viper-F-char (if (stringp cmd-representation)
3336 (viper-seq-last-elt cmd-representation)
3337 viper-F-char)
3338 viper-f-char viper-F-char)
3340 (if com (viper-move-marker-locally 'viper-com-point (point)))
3341 (viper-find-char
3342 val (if (> (viper-p-val arg) 0) viper-f-char viper-F-char) nil nil)
3346 (setq viper-F-char viper-f-char) ; set new viper-F-char
3347 (viper-execute-com 'viper-find-char-backward val com)))))
3349 (defun viper-goto-char-backward (arg)
3350 "Go up to char ARG backward on line."
3352 (let ((val (viper-p-val arg))
3353 (com (viper-getcom arg))
3354 (cmd-representation (nth 5 viper-d-com)))
3357 (setq viper-f-char (read-char)
3358 viper-f-forward nil
3359 viper-f-offset t)
3360 ;; viper-repeat --- set viper-F-char from command-keys
3361 (setq viper-F-char (if (stringp cmd-representation)
3362 (viper-seq-last-elt cmd-representation)
3363 viper-F-char)
3364 viper-f-char viper-F-char)
3366 (if com (viper-move-marker-locally 'viper-com-point (point)))
3367 (viper-find-char
3368 val (if (> (viper-p-val arg) 0) viper-f-char viper-F-char) nil t)
3372 (setq viper-F-char viper-f-char) ; set new viper-F-char
3373 (viper-execute-com 'viper-goto-char-backward val com)))))
3375 (defun viper-repeat-find (arg)
3378 (let ((val (viper-p-val arg))
3379 (com (viper-getcom arg)))
3380 (viper-deactivate-mark)
3381 (if com (viper-move-marker-locally 'viper-com-point (point)))
3382 (viper-find-char val viper-f-char viper-f-forward viper-f-offset)
3385 (if viper-f-forward (forward-char))
3386 (viper-execute-com 'viper-repeat-find val com)))))
3388 (defun viper-repeat-find-opposite (arg)
3391 (let ((val (viper-p-val arg))
3392 (com (viper-getcom arg)))
3393 (viper-deactivate-mark)
3394 (if com (viper-move-marker-locally 'viper-com-point (point)))
3395 (viper-find-char val viper-f-char (not viper-f-forward) viper-f-offset)
3398 (if viper-f-forward (forward-char))
3399 (viper-execute-com 'viper-repeat-find-opposite val com)))))
3405 (defun viper-window-top (arg)
3406 "Go to home window line."
3408 (let ((val (viper-p-val arg))
3409 (com (viper-getCom arg)))
3410 (viper-leave-region-active)
3411 (if com (viper-move-marker-locally 'viper-com-point (point)))
3413 (move-to-window-line (1- val))
3417 (back-to-indentation)
3419 (if com (viper-execute-com 'viper-window-top val com))
3422 (back-to-indentation)
3425 (defun viper-window-middle (arg)
3426 "Go to middle window line."
3428 (let ((val (viper-p-val arg))
3429 (com (viper-getCom arg)))
3430 (viper-leave-region-active)
3431 (if com (viper-move-marker-locally 'viper-com-point (point)))
3433 (move-to-window-line (+ (/ (1- (window-height)) 2) (1- val)))
3437 (back-to-indentation)
3439 (if com (viper-execute-com 'viper-window-middle val com))
3442 (back-to-indentation)
3445 (defun viper-window-bottom (arg)
3446 "Go to last window line."
3448 (let ((val (viper-p-val arg))
3449 (com (viper-getCom arg)))
3450 (viper-leave-region-active)
3451 (if com (viper-move-marker-locally 'viper-com-point (point)))
3453 (move-to-window-line (- val))
3457 (back-to-indentation)
3459 (if com (viper-execute-com 'viper-window-bottom val com))
3462 (back-to-indentation)
3465 (defun viper-line-to-top (arg)
3470 (defun viper-line-to-middle (arg)
3475 (defun viper-line-to-bottom (arg)
3480 ;; If point is within viper-search-scroll-threshold of window top or bottom,
3482 ;; bottom or at the top of the window. This function is called by viper-search
3483 ;; (which is called from viper-search-forward/backward/next). If the value of
3484 ;; viper-search-scroll-threshold is negative - don't scroll.
3485 (defun viper-adjust-window ()
3486 (let ((win-height (viper-cond-compile-for-xemacs-or-emacs
3495 (move-to-window-line 0) ; top
3498 viper-search-scroll-threshold))
3499 (move-to-window-line -1) ; bottom
3501 (<= (count-lines pt (point)) viper-search-scroll-threshold))
3503 (cond (at-top-p (setq min-scroll (1- viper-search-scroll-threshold)
3505 (at-bottom-p (setq min-scroll (1+ viper-search-scroll-threshold)
3515 ;; must correct this to only match ( to ) etc. On the other hand
3519 (defun viper-paren-match (arg)
3520 "Go to the matching parenthesis."
3522 (viper-leave-region-active)
3523 (let ((com (viper-getcom arg))
3524 (parse-sexp-ignore-comments viper-parse-sexp-ignore-comments)
3533 (back-to-indentation))
3549 (if com (viper-move-marker-locally 'viper-com-point (point)))
3552 (viper-execute-com 'viper-paren-match nil com)
3557 (viper-move-marker-locally 'viper-com-point anchor-point)
3559 (viper-execute-com 'viper-paren-match nil com)
3563 (if com (viper-move-marker-locally 'viper-com-point (point)))
3565 (if com (viper-execute-com 'viper-paren-match nil com)))
3568 (defun viper-toggle-parse-sexp-ignore-comments ()
3570 (setq viper-parse-sexp-ignore-comments
3571 (not viper-parse-sexp-ignore-comments))
3574 (if viper-parse-sexp-ignore-comments "" "NOT "))))
3580 (defun viper-forward-sentence (arg)
3585 (let ((val (viper-p-val arg))
3586 (com (viper-getcom arg)))
3587 (if com (viper-move-marker-locally 'viper-com-point (point)))
3589 (if com (viper-execute-com 'viper-forward-sentence nil com))))
3591 (defun viper-backward-sentence (arg)
3596 (let ((val (viper-p-val arg))
3597 (com (viper-getcom arg)))
3598 (if com (viper-move-marker-locally 'viper-com-point (point)))
3600 (if com (viper-execute-com 'viper-backward-sentence nil com))))
3602 (defun viper-forward-paragraph (arg)
3607 (let ((val (viper-p-val arg))
3608 ;; if you want d} operate on whole lines, change viper-getcom to
3609 ;; viper-getCom below
3610 (com (viper-getcom arg)))
3611 (if com (viper-move-marker-locally 'viper-com-point (point)))
3616 (viper-execute-com 'viper-forward-paragraph nil com)))))
3618 (defun viper-backward-paragraph (arg)
3623 (let ((val (viper-p-val arg))
3624 ;; if you want d{ operate on whole lines, change viper-getcom to
3625 ;; viper-getCom below
3626 (com (viper-getcom arg)))
3627 (if com (viper-move-marker-locally 'viper-com-point (point)))
3632 (viper-execute-com 'viper-backward-paragraph nil com)
3636 (defun viper-prev-heading (arg)
3638 (let ((val (viper-p-val arg))
3639 (com (viper-getCom arg)))
3640 (if com (viper-move-marker-locally 'viper-com-point (point)))
3641 (re-search-backward viper-heading-start nil t val)
3643 (if com (viper-execute-com 'viper-prev-heading nil com))))
3645 (defun viper-heading-end (arg)
3647 (let ((val (viper-p-val arg))
3648 (com (viper-getCom arg)))
3649 (if com (viper-move-marker-locally 'viper-com-point (point)))
3650 (re-search-forward viper-heading-end nil t val)
3652 (if com (viper-execute-com 'viper-heading-end nil com))))
3654 (defun viper-next-heading (arg)
3656 (let ((val (viper-p-val arg))
3657 (com (viper-getCom arg)))
3658 (if com (viper-move-marker-locally 'viper-com-point (point)))
3660 (re-search-forward viper-heading-start nil t val)
3662 (if com (viper-execute-com 'viper-next-heading nil com))))
3668 (defun viper-scroll-screen (arg)
3669 "Scroll to next screen."
3688 (defun viper-scroll-screen-back (arg)
3689 "Scroll to previous screen."
3691 (viper-scroll-screen (- arg)))
3693 (defun viper-scroll-down (arg)
3704 (defun viper-scroll-down-one (arg)
3709 (defun viper-scroll-up (arg)
3720 (defun viper-scroll-up-one (arg)
3729 (defun viper-if-string (prompt)
3730 (if (memq viper-intermediate-command
3731 '(viper-command-argument viper-digit-argument viper-repeat))
3732 (setq viper-this-command-keys (this-command-keys)))
3733 (let ((s (viper-read-string-with-history
3736 'viper-search-history
3737 (car viper-search-history))))
3738 (if (not (string= s ""))
3739 (setq viper-s-string s))))
3742 (defun viper-toggle-search-style (arg)
3743 "Toggle the value of viper-case-fold-search/viper-re-search.
3744 Without prefix argument, will ask which search style to toggle. With prefix
3745 arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
3747 Although this function is bound to \\[viper-toggle-search-style], the most
3748 convenient way to use it is to bind `//' to the macro
3749 `1 M-x viper-toggle-search-style' and `///' to
3750 `2 M-x viper-toggle-search-style'. In this way, hitting `//' quickly will
3759 (if viper-case-fold-search
3761 (if viper-case-fold-search
3764 (setq viper-case-fold-search (null viper-case-fold-search))
3765 (if viper-case-fold-search
3771 (if viper-re-search
3773 (if viper-re-search
3776 (setq viper-re-search (null viper-re-search))
3777 (if viper-re-search
3784 (defun viper-set-searchstyle-toggling-macros (unset &optional major-mode)
3786 The macro that toggles case sensitivity is bound to `//', and the one that
3787 toggles regexp search is bound to `///'.
3799 (viper-record-kbd-macro
3804 (viper-record-kbd-macro
3811 (viper-unrecord-kbd-macro "//" 'vi-state)
3813 (viper-unrecord-kbd-macro "///" 'vi-state)))
3817 (defun viper-set-parsing-style-toggling-macro (unset)
3818 "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses.
3827 (viper-record-kbd-macro
3834 (viper-unrecord-kbd-macro "%%%" 'vi-state))))
3837 (defun viper-set-emacs-state-searchstyle-macros (unset &optional arg-majormode)
3839 The macro that toggles case sensitivity is bound to `//', and the one that
3840 toggles regexp search is bound to `///'.
3851 (viper-record-kbd-macro
3856 (viper-record-kbd-macro
3863 (viper-unrecord-kbd-macro "//" 'emacs-state)
3865 (viper-unrecord-kbd-macro "///" 'emacs-state))))
3868 (defun viper-search-forward (arg)
3869 "Search a string forward.
3870 ARG is used to find the ARG's occurrence of the string.
3871 Null string will repeat previous search."
3873 (let ((val (viper-P-val arg))
3874 (com (viper-getcom arg))
3875 (old-str viper-s-string)
3877 (setq viper-s-forward t)
3878 (viper-if-string "/")
3880 (if (or (not (equal old-str viper-s-string))
3881 (not (markerp viper-local-search-start-marker))
3882 (not (marker-buffer viper-local-search-start-marker)))
3883 (setq viper-local-search-start-marker (point-marker)))
3884 (viper-search viper-s-string t val)
3887 (viper-move-marker-locally 'viper-com-point (mark t))
3888 (viper-execute-com 'viper-search-next val com)))
3891 (defun viper-search-backward (arg)
3892 "Search a string backward.
3893 ARG is used to find the ARG's occurrence of the string.
3894 Null string will repeat previous search."
3896 (let ((val (viper-P-val arg))
3897 (com (viper-getcom arg))
3898 (old-str viper-s-string)
3900 (setq viper-s-forward nil)
3901 (viper-if-string "?")
3903 (if (or (not (equal old-str viper-s-string))
3904 (not (markerp viper-local-search-start-marker))
3905 (not (marker-buffer viper-local-search-start-marker)))
3906 (setq viper-local-search-start-marker (point-marker)))
3907 (viper-search viper-s-string nil val)
3910 (viper-move-marker-locally 'viper-com-point (mark t))
3911 (viper-execute-com 'viper-search-next val com)))))
3916 ;; INIT-POINT is the position where search is to start.
3919 (defun viper-search (string forward arg
3921 (if (not (equal string ""))
3922 (let ((val (viper-p-val arg))
3923 (com (viper-getcom arg))
3925 (case-fold-search viper-case-fold-search)
3927 (viper-deactivate-mark)
3931 (if offset (viper-forward-char-carefully))
3932 (if viper-re-search
3934 (re-search-forward string nil nil val)
3935 (re-search-backward string))
3936 (search-forward string nil nil val)
3937 (search-backward string))
3941 (if (and (not fail-if-not-found) viper-search-wrap-around-t)
3945 (viper-search string forward (cons 1 com) t start-point 'fail)
3948 (memq viper-intermediate-command
3949 '(viper-repeat
3950 viper-digit-argument
3951 viper-command-argument))
3958 string
3959 (if viper-re-search "Pattern" "String"))
3964 (if viper-re-search
3965 (re-search-backward string nil nil val)
3966 (search-backward string nil nil val))
3970 (if (and (not fail-if-not-found) viper-search-wrap-around-t)
3974 (viper-search string forward (cons 1 com) t start-point 'fail)
3977 (memq viper-intermediate-command
3978 '(viper-repeat
3979 viper-digit-argument
3980 viper-command-argument))
3987 string
3988 (if viper-re-search "Pattern" "String"))
3991 (viper-adjust-window)
3995 (memq viper-intermediate-command
3996 '(viper-repeat viper-digit-argument viper-command-argument))
3997 (viper-flash-search-pattern))
4000 (defun viper-search-next (arg)
4003 (let ((val (viper-p-val arg))
4004 (com (viper-getcom arg))
4006 (if (or (null viper-s-string) (string= viper-s-string ""))
4007 (error viper-NoPrevSearch))
4008 (viper-search viper-s-string viper-s-forward arg)
4011 (viper-move-marker-locally 'viper-com-point (mark t))
4012 (viper-execute-com 'viper-search-next val com)))))
4014 (defun viper-search-Next (arg)
4017 (let ((val (viper-p-val arg))
4018 (com (viper-getcom arg))
4020 (if (null viper-s-string) (error viper-NoPrevSearch))
4021 (viper-search viper-s-string (not viper-s-forward) arg)
4024 (viper-move-marker-locally 'viper-com-point (mark t))
4025 (viper-execute-com 'viper-search-Next val com)))))
4030 (defun viper-buffer-search-enable (&optional c)
4031 (cond (c (setq viper-buffer-search-char c))
4032 ((null viper-buffer-search-char)
4033 ;; ?g acts as a default value for viper-buffer-search-char
4034 (setq viper-buffer-search-char ?g)))
4035 (define-key viper-vi-basic-map
4036 (cond ((viper-characterp viper-buffer-search-char)
4037 (char-to-string viper-buffer-search-char))
4038 (t (error "viper-buffer-search-char: wrong value type, %S"
4039 viper-buffer-search-char)))
4040 'viper-command-argument)
4041 (aset viper-exec-array viper-buffer-search-char 'viper-exec-buffer-search)
4042 (setq viper-prefix-commands
4043 (cons viper-buffer-search-char viper-prefix-commands)))
4046 (defun viper-isearch-forward (arg)
4051 (viper-exec-form-in-emacs (list 'isearch-forward arg)))
4054 (defun viper-isearch-backward (arg)
4059 (viper-exec-form-in-emacs (list 'isearch-backward arg)))
4065 (defun viper-switch-to-buffer ()
4066 "Switch to buffer in the current window."
4071 (funcall viper-read-buffer-function
4072 "Switch to buffer in this window: " other-buffer))
4073 (switch-to-buffer buffer)))
4075 (defun viper-switch-to-buffer-other-window ()
4076 "Switch to buffer in another window."
4081 (funcall viper-read-buffer-function
4082 "Switch to buffer in another window: " other-buffer))
4083 (switch-to-buffer-other-window buffer)))
4085 (defun viper-kill-buffer ()
4090 (funcall viper-read-buffer-function
4101 "Buffer `%s' is modified, are you sure you want to kill it? "
4111 (defsubst viper-yank (text)
4116 (defun viper-put-back (arg)
4119 (let ((val (viper-p-val arg))
4120 (text (if viper-use-register
4121 (cond ((viper-valid-register viper-use-register '(digit))
4123 (- viper-use-register ?1) 'do-not-rotate))
4124 ((viper-valid-register viper-use-register)
4125 (get-register (downcase viper-use-register)))
4126 (t (error viper-InvalidRegister viper-use-register)))
4130 (if viper-use-register
4131 (let ((reg viper-use-register))
4132 (setq viper-use-register nil)
4133 (error viper-EmptyRegister reg))
4135 (setq viper-use-register nil)
4136 (if (viper-end-with-a-newline-p text)
4143 (if (not (eolp)) (viper-forward-char-carefully)))
4144 (set-marker (viper-mark-marker) (point) (current-buffer))
4145 (viper-set-destructive-command
4146 (list 'viper-put-back val nil viper-use-register nil nil))
4148 (viper-loop val (viper-yank text))
4151 (if (or (> chars-inserted viper-change-notification-threshold)
4152 (> lines-inserted viper-change-notification-threshold))
4153 (unless (viper-is-in-minibuffer)
4159 (if (viper-same-line (point) (mark))
4160 (or (= (point) (mark)) (viper-backward-char-carefully))
4163 (back-to-indentation)))
4164 (viper-deactivate-mark))
4166 (defun viper-Put-back (arg)
4169 (let ((val (viper-p-val arg))
4170 (text (if viper-use-register
4171 (cond ((viper-valid-register viper-use-register '(digit))
4173 (- viper-use-register ?1) 'do-not-rotate))
4174 ((viper-valid-register viper-use-register)
4175 (get-register (downcase viper-use-register)))
4176 (t (error viper-InvalidRegister viper-use-register)))
4180 (if viper-use-register
4181 (let ((reg viper-use-register))
4182 (setq viper-use-register nil)
4183 (error viper-EmptyRegister reg))
4185 (setq viper-use-register nil)
4186 (if (viper-end-with-a-newline-p text) (beginning-of-line))
4187 (viper-set-destructive-command
4188 (list 'viper-Put-back val nil viper-use-register nil nil))
4189 (set-marker (viper-mark-marker) (point) (current-buffer))
4191 (viper-loop val (viper-yank text))
4194 (if (or (> chars-inserted viper-change-notification-threshold)
4195 (> lines-inserted viper-change-notification-threshold))
4196 (unless (viper-is-in-minibuffer)
4202 (if (viper-same-line (point) (mark))
4203 (or (= (point) (mark)) (viper-backward-char-carefully))
4206 (back-to-indentation)))
4207 (viper-deactivate-mark))
4210 ;; Copy region to kill-ring.
4211 ;; If BEG and END do not belong to the same buffer, copy empty region.
4212 (defun viper-copy-region-as-kill (beg end)
4218 (defun viper-delete-char (arg)
4221 (let ((val (viper-p-val arg))
4223 (viper-set-destructive-command
4224 (list 'viper-delete-char val nil nil nil nil))
4225 (if (and viper-ex-style-editing
4226 (> val (viper-chars-in-region (point) (viper-line-pos 'end))))
4227 (setq val (viper-chars-in-region (point) (viper-line-pos 'end))))
4228 (if (and viper-ex-style-motion (eolp))
4231 (viper-forward-char-carefully val)
4233 (if viper-use-register
4235 (cond ((viper-valid-register viper-use-register '((Letter)))
4236 (viper-append-to-register
4237 (downcase viper-use-register) (point) end-del-pos))
4238 ((viper-valid-register viper-use-register)
4239 (copy-to-register
4240 viper-use-register (point) end-del-pos nil))
4241 (t (error viper-InvalidRegister viper-use-register)))
4242 (setq viper-use-register nil)))
4245 (if viper-ex-style-motion
4249 (defun viper-delete-backward-char (arg)
4252 (let ((val (viper-p-val arg))
4254 (viper-set-destructive-command
4255 (list 'viper-delete-backward-char val nil nil nil nil))
4257 viper-ex-style-editing
4258 (> val (viper-chars-in-region (viper-line-pos 'start) (point))))
4259 (setq val (viper-chars-in-region (viper-line-pos 'start) (point))))
4261 (viper-backward-char-carefully val)
4263 (if viper-use-register
4265 (cond ((viper-valid-register viper-use-register '(Letter))
4266 (viper-append-to-register
4267 (downcase viper-use-register) end-del-pos (point)))
4268 ((viper-valid-register viper-use-register)
4269 (copy-to-register
4270 viper-use-register end-del-pos (point) nil))
4271 (t (error viper-InvalidRegister viper-use-register)))
4272 (setq viper-use-register nil)))
4273 (if (and (bolp) viper-ex-style-editing)
4278 (defun viper-del-backward-char-in-insert ()
4281 (if (and viper-ex-style-editing (bolp))
4287 (defun viper-del-backward-char-in-replace ()
4289 If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes
4291 to Vi. The variable `viper-ex-style-editing', if t, doesn't let the
4294 (cond (viper-delete-backwards-in-replace
4298 (viper-ex-style-editing
4305 (viper-ex-style-editing
4317 (defun viper-join-lines (arg)
4318 "Join this line to next, if ARG is nil. Otherwise, join ARG lines."
4320 (let ((val (viper-P-val arg)))
4321 (viper-set-destructive-command
4322 (list 'viper-join-lines val nil nil nil nil))
4323 (viper-loop (if (null val) 1 (1- val))
4341 (defun viper-change (beg end)
4347 (viper-set-complex-command-for-undo)
4348 (if viper-use-register
4350 (copy-to-register viper-use-register beg end nil)
4351 (setq viper-use-register nil)))
4352 (viper-set-replace-overlay beg end)
4355 (if (= (viper-replace-start) (point-max))
4358 (setq viper-last-replace-region
4359 (buffer-substring (viper-replace-start)
4360 (viper-replace-end)))
4365 (if (or viper-allow-multiline-replace-regions
4366 (viper-same-line (viper-replace-start)
4367 (viper-replace-end)))
4370 (goto-char (viper-replace-end))
4372 (untabify (viper-replace-start) (point))
4376 (viper-set-replace-overlay-glyphs
4377 viper-replace-region-start-delimiter
4378 viper-replace-region-end-delimiter)
4380 ;; has to be shifted because of insert. We can't simply insert
4384 (viper-move-replace-overlay (viper-replace-start) (point))
4385 (goto-char (viper-replace-start))
4386 (viper-change-state-to-replace t))
4387 (kill-region (viper-replace-start)
4388 (viper-replace-end))
4389 (viper-hide-replace-overlay)
4390 (viper-change-state-to-insert))
4392 ;; go back to the original point
4393 (goto-char (viper-replace-start))
4394 (viper-hide-replace-overlay)
4395 (viper-message-conditions conds))))
4398 (defun viper-change-subr (beg end)
4401 (if viper-use-register
4403 (copy-to-register viper-use-register beg end nil)
4404 (setq viper-use-register nil)))
4406 (setq this-command 'viper-change)
4407 (viper-yank-last-insertion))
4409 (defun viper-toggle-case (arg)
4412 (let ((val (viper-p-val arg)) (c))
4413 (viper-set-destructive-command
4414 (list 'viper-toggle-case val nil nil nil nil))
4428 (defun viper-query-replace ()
4430 If a null string is suplied as the string to be replaced,
4431 the query replace mode will toggle between string replace
4435 (setq str (viper-read-string-with-history
4436 (if viper-re-query-replace "Query replace regexp: "
4439 'viper-replace1-history
4440 (car viper-replace1-history) ; default
4442 (if (string= str "")
4444 (setq viper-re-query-replace (not viper-re-query-replace))
4445 (message "Query replace mode changed to %s"
4446 (if viper-re-query-replace "regexp replace"
4447 "string replace")))
4448 (if viper-re-query-replace
4451 (viper-read-string-with-history
4454 'viper-replace1-history
4455 (car viper-replace1-history) ; default
4459 (viper-read-string-with-history
4462 'viper-replace1-history
4463 (car viper-replace1-history) ; default
4470 (defun viper-mark-beginning-of-buffer ()
4478 (defun viper-mark-end-of-buffer ()
4486 (defun viper-mark-point ()
4491 (point-to-register (viper-int-to-char (1+ (- char ?a)))))
4492 ((viper= char ?<) (viper-mark-beginning-of-buffer))
4493 ((viper= char ?>) (viper-mark-end-of-buffer))
4494 ((viper= char ?.) (viper-set-mark-if-necessary))
4495 ((viper= char ?,) (viper-cycle-through-mark-ring))
4496 ((viper= char ?^) (push-mark viper-saved-mark t t))
4497 ((viper= char ?D) (mark-defun))
4504 ;; Push this mark back and set mark to the original point position, p1.
4505 ;; So, if you hit '' or `` then you can return to p1.
4509 ;; Then we save the current pos, which is M0, jump to M1 and pop M2 from
4510 ;; the ring into mark. Push M2 back on the ring and set mark to M0.
4512 (defun viper-cycle-through-mark-ring ()
4514 One can use `` and '' to temporarily jump 1 step back."
4520 ;; In any case, go to the previous or previously saved mark.
4522 ;; point to be the mark. Current pt as mark is discarded by the next
4524 (if (eq last-command 'viper-cycle-through-mark-ring)
4527 (setq mark-ring (delete (viper-mark-marker) mark-ring))
4533 (setq mark-ring (delete (viper-mark-marker) mark-ring))
4535 (viper-deactivate-mark)
4536 (setq this-command 'viper-cycle-through-mark-ring)
4540 (defun viper-goto-mark (arg)
4541 "Go to mark."
4544 (com (viper-getcom arg)))
4545 (viper-goto-mark-subr char com nil)))
4547 (defun viper-goto-mark-and-skip-white (arg)
4548 "Go to mark and skip to first non-white character on line."
4551 (com (viper-getCom arg)))
4552 (viper-goto-mark-subr char com t)))
4554 (defun viper-goto-mark-subr (char com skip-white)
4559 (cond ((viper-valid-register char '(letter))
4561 (reg (viper-int-to-char (1+ (- char ?a))))
4563 ;; If marker points to file that had markers set (and those markers
4576 (if com (viper-move-marker-locally 'viper-com-point (point)))
4577 (if (not (viper-valid-marker text-marker))
4578 (error viper-EmptyTextmarker char))
4579 (if (and (viper-same-line (point) viper-last-jump)
4580 (= (point) viper-last-jump-ignore))
4581 (push-mark viper-last-jump t)
4583 (viper-register-to-point reg)
4584 (setq viper-last-jump (point-marker))
4586 (back-to-indentation)
4587 (setq viper-last-jump-ignore (point))))
4590 (viper-execute-com (if skip-white
4591 'viper-goto-mark-and-skip-white
4592 'viper-goto-mark)
4594 (switch-to-buffer buff)
4595 (goto-char viper-com-point)
4596 (viper-change-state-to-vi)
4598 ((and (not skip-white) (viper= char ?`))
4599 (if com (viper-move-marker-locally 'viper-com-point (point)))
4600 (if (and (viper-same-line (point) viper-last-jump)
4601 (= (point) viper-last-jump-ignore))
4602 (goto-char viper-last-jump))
4606 (setq viper-last-jump (point-marker)
4607 viper-last-jump-ignore 0)
4608 (if com (viper-execute-com 'viper-goto-mark nil com)))
4609 ((and skip-white (viper= char ?'))
4610 (if com (viper-move-marker-locally 'viper-com-point (point)))
4611 (if (and (viper-same-line (point) viper-last-jump)
4612 (= (point) viper-last-jump-ignore))
4613 (goto-char viper-last-jump))
4616 (setq viper-last-jump (point))
4617 (back-to-indentation)
4618 (setq viper-last-jump-ignore (point))
4619 (if com (viper-execute-com 'viper-goto-mark-and-skip-white nil com)))
4620 (t (error viper-InvalidTextmarker char))))
4622 (defun viper-insert-tab ()
4626 (defun viper-exchange-point-and-mark ()
4629 (back-to-indentation))
4633 ;; Returns t, if the string before point matches the regexp STR.
4634 (defsubst viper-looking-back (str)
4639 (defun viper-forward-indent ()
4642 (setq viper-cted t)
4643 (indent-to (+ (current-column) viper-shift-width)))
4645 (defun viper-backward-indent ()
4648 (if viper-cted
4650 (if (viper-looking-back "[0^]")
4653 (setq viper-preserve-indent t))
4663 (indent-to (- c viper-shift-width)))
4664 (if (or (bolp) (viper-looking-back "[^ \t]"))
4665 (setq viper-cted nil)))))
4668 (defun viper-indent-line (col)
4669 (if viper-auto-indent
4671 (setq viper-cted t)
4672 (if (and viper-electric-mode
4676 (indent-according-to-mode)
4677 (indent-to col)))))
4680 (defun viper-autoindent ()
4685 (if viper-preserve-indent
4686 (setq viper-preserve-indent nil)
4687 (setq viper-current-indent col))
4690 '(viper-autoindent
4691 viper-open-line viper-Open-line
4692 viper-replace-state-exit-cmd))
4693 (indent-to-left-margin))
4697 (viper-indent-line viper-current-indent)
4703 (defun viper-ket-function (arg)
4707 (cond ((viper-valid-register reg '(letter Letter))
4709 ((viper-valid-register reg '(digit))
4711 (with-output-to-temp-buffer " *viper-info*"
4712 (princ (format "Register %c contains the string:\n" reg))
4715 ((viper= ?\] reg)
4716 (viper-next-heading arg))
4718 viper-InvalidRegister reg)))))
4720 (defun viper-brac-function (arg)
4724 (cond ((viper= ?\[ reg)
4725 (viper-prev-heading arg))
4726 ((viper= ?\] reg)
4727 (viper-heading-end arg))
4728 ((viper-valid-register reg '(letter))
4729 (let* ((val (get-register (viper-int-to-char (1+ (- reg ?a)))))
4731 (error viper-EmptyTextmarker reg)
4735 (with-output-to-temp-buffer " *viper-info*"
4763 (princ (format viper-EmptyTextmarker reg))))
4765 (t (error viper-InvalidTextmarker reg)))))
4769 (defun viper-delete-backward-word (arg)
4781 ;; Get viper standard value of SYMBOL. If symbol is customized, get its
4783 ;; STORAGE is nil, use viper-saved-user-settings.
4784 (defun viper-standard-value (symbol &optional storage)
4787 (nth 1 (assoc symbol (or storage viper-saved-user-settings)))))
4791 (defun viper-set-expert-level (&optional dont-change-unless)
4793 Can be called interactively to change (temporarily or permanently) the
4805 (if (not (natnump viper-expert-level)) (setq viper-expert-level 0))
4809 ;; if 0 < viper-expert-level < viper-max-expert-level
4811 (viper-ask-level dont-change-unless))
4813 (setq viper-always t
4814 viper-ex-style-motion t
4815 viper-ex-style-editing t
4816 viper-want-ctl-h-help nil)
4818 (cond ((eq viper-expert-level 1) ; novice or beginner
4820 viper-toggle-key
4821 (if (viper-window-display-p) 'viper-iconify 'suspend-emacs))
4822 (setq viper-no-multiple-ESC t
4823 viper-re-search t
4824 viper-vi-style-in-minibuffer t
4825 viper-search-wrap-around-t t
4826 viper-electric-mode nil
4827 viper-want-emacs-keys-in-vi nil
4828 viper-want-emacs-keys-in-insert nil))
4830 ((and (> viper-expert-level 1) (< viper-expert-level 5))
4831 ;; intermediate to guru
4832 (setq viper-no-multiple-ESC (if (viper-window-display-p)
4834 viper-electric-mode t
4835 viper-want-emacs-keys-in-vi t
4836 viper-want-emacs-keys-in-insert (> viper-expert-level 2))
4838 (if (eq viper-expert-level 4) ; respect user's ex-style motion
4839 ; and viper-no-multiple-ESC
4842 viper-ex-style-editing
4843 (viper-standard-value 'viper-ex-style-editing)
4844 viper-ex-style-motion
4845 (viper-standard-value 'viper-ex-style-motion))
4846 (setq viper-ex-style-motion
4847 (viper-standard-value 'viper-ex-style-motion)
4848 viper-ex-style-editing
4849 (viper-standard-value 'viper-ex-style-editing)
4850 viper-re-search
4851 (viper-standard-value 'viper-re-search)
4852 viper-no-multiple-ESC
4853 (viper-standard-value 'viper-no-multiple-ESC)))))
4856 ;; Ideally, if 5 is selected, a buffer should pop up to let the
4858 (t (setq-default viper-ex-style-editing
4859 (viper-standard-value 'viper-ex-style-editing)
4860 viper-ex-style-motion
4861 (viper-standard-value 'viper-ex-style-motion))
4862 (setq viper-want-ctl-h-help
4863 (viper-standard-value 'viper-want-ctl-h-help)
4864 viper-always
4865 (viper-standard-value 'viper-always)
4866 viper-no-multiple-ESC
4867 (viper-standard-value 'viper-no-multiple-ESC)
4868 viper-ex-style-motion
4869 (viper-standard-value 'viper-ex-style-motion)
4870 viper-ex-style-editing
4871 (viper-standard-value 'viper-ex-style-editing)
4872 viper-re-search
4873 (viper-standard-value 'viper-re-search)
4874 viper-electric-mode
4875 (viper-standard-value 'viper-electric-mode)
4876 viper-want-emacs-keys-in-vi
4877 (viper-standard-value 'viper-want-emacs-keys-in-vi)
4878 viper-want-emacs-keys-in-insert
4879 (viper-standard-value 'viper-want-emacs-keys-in-insert))))
4881 (viper-set-mode-vars-for viper-current-state)
4882 (if (or viper-always
4883 (and (> viper-expert-level 0) (> 5 viper-expert-level)))
4884 (viper-set-hooks)))
4888 (defun viper-ask-level (dont-change-unless)
4889 (let ((ask-buffer " *viper-ask-level*")
4892 (switch-to-buffer ask-buffer)
4894 (while (or (> viper-expert-level viper-max-expert-level)
4895 (< viper-expert-level 1)
4908 You can change it at any time by typing `M-x viper-set-expert-level RET'
4916 Good progress---you are well on the way to level 3!
4919 4 -- GURU: Like 3, but user settings are respected for viper-no-multiple-ESC,
4920 viper-ex-style-motion, viper-ex-style-editing, and
4921 viper-re-search variables. Adjust these settings to your taste.
4922 5 -- WIZARD: Like 4, but user settings are also respected for viper-always,
4923 viper-electric-mode, viper-want-ctl-h-help, viper-want-emacs-keys-in-vi,
4924 and viper-want-emacs-keys-in-insert. Adjust these to your taste.
4928 (setq viper-expert-level (- (viper-read-char-exclusive) ?0))
4936 viper-expert-level))
4937 (if (y-or-n-p "Do you wish to make this change permanent? ")
4938 ;; save the setting for viper-expert-level
4939 (viper-save-setting
4940 'viper-expert-level
4941 (format "Saving user level %d ..." viper-expert-level)
4942 viper-custom-file-name))
4949 (defun viper-nil ()
4955 (defun viper-register-to-point (char &optional enforce-buffer)
4956 "Like jump-to-register, but switches to another buffer in another window."
4957 (interactive "cViper register to point: ")
4965 ((viper-valid-marker val)
4968 (error (concat viper-EmptyTextmarker " in this buffer")
4969 (viper-int-to-char (1- (+ char ?a)))))
4970 (pop-to-buffer (marker-buffer val))
4975 (error viper-EmptyTextmarker (viper-int-to-char (1- (+ char ?a))))))))
4978 (defun viper-save-kill-buffer ()
4981 (if (< viper-expert-level 2)
4991 (defun viper-submit-report ()
4995 (viper-device-type (viper-device-type))
5000 ;; If mode info is needed, add variable to `let' and then set it below,
5002 (setq color-display-p (if (viper-window-display-p)
5003 (viper-color-display-p)
5005 minibuffer-vi-face (if (viper-has-face-support-p)
5006 (viper-get-face viper-minibuffer-vi-face)
5008 minibuffer-insert-face (if (viper-has-face-support-p)
5009 (viper-get-face
5010 viper-minibuffer-insert-face)
5012 minibuffer-emacs-face (if (viper-has-face-support-p)
5013 (viper-get-face
5014 viper-minibuffer-emacs-face)
5019 (setq varlist (list 'viper-vi-minibuffer-minor-mode
5020 'viper-insert-minibuffer-minor-mode
5021 'viper-vi-intercept-minor-mode
5022 'viper-vi-local-user-minor-mode
5023 'viper-vi-kbd-minor-mode
5024 'viper-vi-global-user-minor-mode
5025 'viper-vi-state-modifier-minor-mode
5026 'viper-vi-diehard-minor-mode
5027 'viper-vi-basic-minor-mode
5028 'viper-replace-minor-mode
5029 'viper-insert-intercept-minor-mode
5030 'viper-insert-local-user-minor-mode
5031 'viper-insert-kbd-minor-mode
5032 'viper-insert-global-user-minor-mode
5033 'viper-insert-state-modifier-minor-mode
5034 'viper-insert-diehard-minor-mode
5035 'viper-insert-basic-minor-mode
5036 'viper-emacs-intercept-minor-mode
5037 'viper-emacs-local-user-minor-mode
5038 'viper-emacs-kbd-minor-mode
5039 'viper-emacs-global-user-minor-mode
5040 'viper-emacs-state-modifier-minor-mode
5041 'viper-automatic-iso-accents
5042 'viper-special-input-method
5043 'viper-want-emacs-keys-in-insert
5044 'viper-want-emacs-keys-in-vi
5045 'viper-keep-point-on-undo
5046 'viper-no-multiple-ESC
5047 'viper-electric-mode
5048 'viper-ESC-key
5049 'viper-want-ctl-h-help
5050 'viper-ex-style-editing
5051 'viper-delete-backwards-in-replace
5052 'viper-vi-style-in-minibuffer
5053 'viper-vi-state-hook
5054 'viper-insert-state-hook
5055 'viper-replace-state-hook
5056 'viper-emacs-state-hook
5059 'viper-expert-level
5061 'viper-device-type
5070 Please mail a concise, accurate summary of the problem to the address above.
5074 (with-output-to-temp-buffer " *viper-info*"
5075 (switch-to-buffer " *viper-info*")
5081 Before reporting a bug, please verify that it is related to Viper, and is
5088 those advertised in the manual. Such `customization' is likely to crash
5096 Then reproduce the error. The above command will cause Emacs to produce a
5097 back trace of the execution that leads to the error. Please include this
5105 Then reproduce the problem. Wait for a few seconds, then type C-g to abort
5118 (viper-version)
5128 ;;; viper-cmd.el ends here