diff options
| author | Michael Kifer | 1995-07-27 19:37:42 +0000 |
|---|---|---|
| committer | Michael Kifer | 1995-07-27 19:37:42 +0000 |
| commit | 27571f905decd3f7f2f7045f7ffcf00481028bd5 (patch) | |
| tree | 93a9a8b7fc81a108183d34b56698abdb5d66af99 /lisp | |
| parent | c8787b81ef88d784f615aa76893b5d858464de23 (diff) | |
| download | emacs-27571f905decd3f7f2f7045f7ffcf00481028bd5.tar.gz emacs-27571f905decd3f7f2f7045f7ffcf00481028bd5.zip | |
(vip-info-file-name): variable removed.
(vip-envelop-ESC-key,vip-start-replace,vip-finish-R-mode,vip-start-R-mode,
vip-insert-state-pre-command-sentinel,vip-R-state-post-command-sentinel,
vip-replace-char): functions modified.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emulation/viper.el | 156 |
1 files changed, 74 insertions, 82 deletions
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 79b385249c5..1ffbc102efd 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el | |||
| @@ -3,10 +3,12 @@ | |||
| 3 | ;; and a venomous VI PERil. | 3 | ;; and a venomous VI PERil. |
| 4 | ;; Viper Is also a Package for Emacs Rebels. | 4 | ;; Viper Is also a Package for Emacs Rebels. |
| 5 | ;; | 5 | ;; |
| 6 | ;; Version: 2.76 | ||
| 7 | ;; Keywords: emulations | 6 | ;; Keywords: emulations |
| 8 | ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 7 | ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
| 9 | 8 | ||
| 9 | (defconst viper-version "2.80 of July 7, 1995" | ||
| 10 | "The current version of Viper") | ||
| 11 | |||
| 10 | ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 12 | ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
| 11 | 13 | ||
| 12 | ;; This file is part of GNU Emacs. | 14 | ;; This file is part of GNU Emacs. |
| @@ -25,9 +27,6 @@ | |||
| 25 | ;; along with GNU Emacs; see the file COPYING. If not, write to | 27 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 26 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 28 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | 29 | ||
| 28 | (defconst viper-version "2.76 of June 9, 1995" | ||
| 29 | "The current version of Viper") | ||
| 30 | |||
| 31 | ;;; Commentary: | 30 | ;;; Commentary: |
| 32 | 31 | ||
| 33 | ;; Viper is a full-featured Vi emulator for Emacs 19. It emulates and | 32 | ;; Viper is a full-featured Vi emulator for Emacs 19. It emulates and |
| @@ -102,28 +101,8 @@ | |||
| 102 | ;;; Acknowledgements: | 101 | ;;; Acknowledgements: |
| 103 | ;; ----------------- | 102 | ;; ----------------- |
| 104 | ;; Bug reports and ideas contributed by the following users | 103 | ;; Bug reports and ideas contributed by the following users |
| 105 | ;; have helped improve Viper and the various versions of VIP: | 104 | ;; have helped improve Viper and the various versions of VIP. |
| 106 | ;; | 105 | ;; See the on-line manual for a complete list of contributors. |
| 107 | ;; jjm@hplb.hpl.hp.com (Jean-Jacques Moreau), jl@cse.ogi.edu (John | ||
| 108 | ;; Launchbury), rxga@ulysses.att.com, jamesm@bga.com (D.J. Miller II), | ||
| 109 | ;; ascott@fws214.intel.com (Andy Scott), toma@convex.convex.com, | ||
| 110 | ;; gvr@cs.brown.edu, dave@hellgate.utah.edu, cook@biostat.wisc.edu | ||
| 111 | ;; (Tom Cook), lindstro@biostat.wisc.edu (Mary Lindstrom), | ||
| 112 | ;; edmonds@edmonds.home.cs.ubc.ca (Brian Edmonds), mveiga@dit.upm.es | ||
| 113 | ;; (Marcelino Veiga Tuimil), dwight@toolucky.llnl.gov (Dwight Shih), | ||
| 114 | ;; phil_brooks@MENTORG.COM (Phil Brooks), kin@isi.com (Kin Cho), | ||
| 115 | ;; ahg@panix.com (Al Gelders), dwallach@cs.princeton.edu (Dan Wallach), | ||
| 116 | ;; hpz@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld), | ||
| 117 | ;; simonb@prl.philips.co.uk (Simon Blanchard), Mark.Bordas@East.Sun.COM | ||
| 118 | ;; (Mark Bordas), gviswana@cs.wisc.edu (Guhan Viswanathan), | ||
| 119 | ;; meyering@comco.com (Jim Meyering), pfister@cs.sunysb.edu (Hanspeter | ||
| 120 | ;; Pfister) | ||
| 121 | ;; | ||
| 122 | ;; Special thanks to Marcelino Veiga Tuimil <mveiga@dit.upm.es> for | ||
| 123 | ;; suggesting a way of intercepting ESC sequences on dumb terminals. Due to | ||
| 124 | ;; this, Viper can now handle arrow keys, F-keys, etc., in Xterm windows | ||
| 125 | ;; and on dumb terminals. This also made it possible to implement Vi-style | ||
| 126 | ;; timeout macros. | ||
| 127 | ;; | 106 | ;; |
| 128 | ;; | 107 | ;; |
| 129 | ;;; Notes: | 108 | ;;; Notes: |
| @@ -468,7 +447,8 @@ it better fits your working style.") | |||
| 468 | 447 | ||
| 469 | ;; Replace mode and changing text | 448 | ;; Replace mode and changing text |
| 470 | 449 | ||
| 471 | ;; Viper's own after/before change functions, which get add-hook'ed to Emacs' | 450 | ;; Viper's own after/before change functions, which get vip-add-hook'ed to |
| 451 | ;; Emacs's | ||
| 472 | (vip-deflocalvar vip-after-change-functions nil "") | 452 | (vip-deflocalvar vip-after-change-functions nil "") |
| 473 | (vip-deflocalvar vip-before-change-functions nil "") | 453 | (vip-deflocalvar vip-before-change-functions nil "") |
| 474 | (vip-deflocalvar vip-post-command-hooks nil "") | 454 | (vip-deflocalvar vip-post-command-hooks nil "") |
| @@ -832,9 +812,6 @@ These buffers can be cycled through via :R and :P commands.") | |||
| 832 | "Viper customisation file. | 812 | "Viper customisation file. |
| 833 | This variable must be set _before_ loading Viper.") | 813 | This variable must be set _before_ loading Viper.") |
| 834 | 814 | ||
| 835 | (defvar vip-info-file-name "viper" | ||
| 836 | "The name prefix for Viper Info files.") | ||
| 837 | |||
| 838 | (defvar vip-spell-function 'ispell-region | 815 | (defvar vip-spell-function 'ispell-region |
| 839 | "Spell function used by #s<move> command to spell.") | 816 | "Spell function used by #s<move> command to spell.") |
| 840 | 817 | ||
| @@ -967,9 +944,9 @@ shell-mode, this is undesirable and must be set to nil. See vip-set-hooks.") | |||
| 967 | (remove-hook 'pre-command-hook 'vip-pre-command-sentinel) | 944 | (remove-hook 'pre-command-hook 'vip-pre-command-sentinel) |
| 968 | (add-hook 'pre-command-hook 'vip-pre-command-sentinel t) | 945 | (add-hook 'pre-command-hook 'vip-pre-command-sentinel t) |
| 969 | ;; These hooks will be added back if switching to insert/replace mode | 946 | ;; These hooks will be added back if switching to insert/replace mode |
| 970 | (remove-hook 'vip-post-command-hooks | 947 | (vip-remove-hook 'vip-post-command-hooks |
| 971 | 'vip-insert-state-post-command-sentinel) | 948 | 'vip-insert-state-post-command-sentinel) |
| 972 | (remove-hook 'vip-pre-command-hooks | 949 | (vip-remove-hook 'vip-pre-command-hooks |
| 973 | 'vip-insert-state-pre-command-sentinel) | 950 | 'vip-insert-state-pre-command-sentinel) |
| 974 | (cond ((eq new-state 'vi-state) | 951 | (cond ((eq new-state 'vi-state) |
| 975 | (cond ((member vip-current-state '(insert-state replace-state)) | 952 | (cond ((member vip-current-state '(insert-state replace-state)) |
| @@ -1010,15 +987,14 @@ shell-mode, this is undesirable and must be set to nil. See vip-set-hooks.") | |||
| 1010 | (if (memq vip-current-state '(emacs-state vi-state)) | 987 | (if (memq vip-current-state '(emacs-state vi-state)) |
| 1011 | (vip-move-marker-locally 'vip-insert-point (point))) | 988 | (vip-move-marker-locally 'vip-insert-point (point))) |
| 1012 | (vip-move-marker-locally 'vip-last-posn-while-in-insert-state (point)) | 989 | (vip-move-marker-locally 'vip-last-posn-while-in-insert-state (point)) |
| 1013 | (add-hook 'vip-post-command-hooks | 990 | (vip-add-hook 'vip-post-command-hooks |
| 1014 | 'vip-insert-state-post-command-sentinel t) | 991 | 'vip-insert-state-post-command-sentinel t) |
| 1015 | (add-hook 'vip-pre-command-hooks | 992 | (vip-add-hook 'vip-pre-command-hooks |
| 1016 | 'vip-insert-state-pre-command-sentinel t) | 993 | 'vip-insert-state-pre-command-sentinel t)) |
| 1017 | ) | ||
| 1018 | ) ; outermost cond | 994 | ) ; outermost cond |
| 1019 | 995 | ||
| 1020 | ;; Nothing needs to be done to switch to emacs mode! Just set some | 996 | ;; Nothing needs to be done to switch to emacs mode! Just set some |
| 1021 | ;; variables, which is done in vip-change-state-to-emacs! | 997 | ;; variables, which is already done in vip-change-state-to-emacs! |
| 1022 | 998 | ||
| 1023 | (setq vip-current-state new-state) | 999 | (setq vip-current-state new-state) |
| 1024 | (vip-normalize-minor-mode-map-alist) | 1000 | (vip-normalize-minor-mode-map-alist) |
| @@ -1064,7 +1040,7 @@ shell-mode, this is undesirable and must be set to nil. See vip-set-hooks.") | |||
| 1064 | ;; Normalizes minor-mode-map-alist by putting Viper keymaps first. | 1040 | ;; Normalizes minor-mode-map-alist by putting Viper keymaps first. |
| 1065 | ;; This ensures that Viper bindings are in effect, regardless of which minor | 1041 | ;; This ensures that Viper bindings are in effect, regardless of which minor |
| 1066 | ;; modes were turned on by the user or by other packages. | 1042 | ;; modes were turned on by the user or by other packages. |
| 1067 | (defun vip-normalize-minor-mode-map-alist () | 1043 | (defun vip-normalize-minor-mode-map-alist () |
| 1068 | (setq minor-mode-map-alist | 1044 | (setq minor-mode-map-alist |
| 1069 | (vip-append-filter-alist | 1045 | (vip-append-filter-alist |
| 1070 | (list | 1046 | (list |
| @@ -1313,7 +1289,10 @@ This startup message appears whenever you load Viper, unless you type `y' now." | |||
| 1313 | (if (and auto-fill-function (> (current-column) fill-column)) | 1289 | (if (and auto-fill-function (> (current-column) fill-column)) |
| 1314 | (funcall auto-fill-function)) | 1290 | (funcall auto-fill-function)) |
| 1315 | ;; don't leave whitespace lines around | 1291 | ;; don't leave whitespace lines around |
| 1316 | (if (and (memq last-command '(vip-autoindent vip-open-line vip-Open-line)) | 1292 | (if (and (memq last-command |
| 1293 | '(vip-autoindent | ||
| 1294 | vip-open-line vip-Open-line | ||
| 1295 | vip-replace-state-exit-cmd)) | ||
| 1317 | (vip-over-whitespace-line)) | 1296 | (vip-over-whitespace-line)) |
| 1318 | (indent-to-left-margin)) | 1297 | (indent-to-left-margin)) |
| 1319 | (vip-add-newline-at-eob-if-necessary) | 1298 | (vip-add-newline-at-eob-if-necessary) |
| @@ -1527,27 +1506,14 @@ behaves as in Emacs, any number of multiple escapes is allowed." | |||
| 1527 | (progn | 1506 | (progn |
| 1528 | (if (vip-fast-keysequence-p) | 1507 | (if (vip-fast-keysequence-p) |
| 1529 | (progn | 1508 | (progn |
| 1530 | (let ((vip-vi-intercept-minor-mode nil) | 1509 | (let (minor-mode-map-alist) |
| 1531 | (vip-insert-intercept-minor-mode nil) | ||
| 1532 | (vip-emacs-intercept-minor-mode nil) | ||
| 1533 | (vip-vi-state-modifier-minor-mode nil) | ||
| 1534 | (vip-vi-global-user-minor-mode nil) | ||
| 1535 | (vip-vi-local-user-minor-mode nil) | ||
| 1536 | (vip-replace-minor-mode nil) ; actually unnecessary | ||
| 1537 | (vip-insert-state-modifier-minor-mode nil) | ||
| 1538 | (vip-insert-global-user-minor-mode nil) | ||
| 1539 | (vip-insert-local-user-minor-mode nil) | ||
| 1540 | (vip-emacs-state-modifier-minor-mode nil) | ||
| 1541 | (vip-emacs-global-user-minor-mode nil) | ||
| 1542 | (vip-emacs-local-user-minor-mode nil) | ||
| 1543 | ) | ||
| 1544 | (vip-set-unread-command-events event) | 1510 | (vip-set-unread-command-events event) |
| 1545 | (setq keyseq | 1511 | (setq keyseq |
| 1546 | (funcall | 1512 | (funcall |
| 1547 | (ad-get-orig-definition 'read-key-sequence) nil)) | 1513 | (ad-get-orig-definition 'read-key-sequence) nil)) |
| 1548 | ) ; let | 1514 | ) ; let |
| 1549 | ;; If keyseq translates into something that still has ESC | 1515 | ;; If keyseq translates into something that still has ESC |
| 1550 | ;; in the beginning, separate ESC from the rest of the seq. | 1516 | ;; at the beginning, separate ESC from the rest of the seq. |
| 1551 | ;; In XEmacs we check for events that are keypress meta-key | 1517 | ;; In XEmacs we check for events that are keypress meta-key |
| 1552 | ;; and convert them into [escape key] | 1518 | ;; and convert them into [escape key] |
| 1553 | ;; | 1519 | ;; |
| @@ -1561,7 +1527,7 @@ behaves as in Emacs, any number of multiple escapes is allowed." | |||
| 1561 | ;; which would translate the escape-sequence generated by | 1527 | ;; which would translate the escape-sequence generated by |
| 1562 | ;; f11 in an xterm window into the symbolic key f11. | 1528 | ;; f11 in an xterm window into the symbolic key f11. |
| 1563 | ;; | 1529 | ;; |
| 1564 | ;; If first-key is not an ESC event, we make it into the | 1530 | ;; If `first-key' is not an ESC event, we make it into the |
| 1565 | ;; last-command-event in order to pretend that this key was | 1531 | ;; last-command-event in order to pretend that this key was |
| 1566 | ;; pressed. This is needed to allow arrow keys to be bound to | 1532 | ;; pressed. This is needed to allow arrow keys to be bound to |
| 1567 | ;; macros. Otherwise, vip-exec-mapped-kbd-macro will think that | 1533 | ;; macros. Otherwise, vip-exec-mapped-kbd-macro will think that |
| @@ -2400,7 +2366,7 @@ Undo previous insertion and inserts new." | |||
| 2400 | 2366 | ||
| 2401 | ;; Make sure the minibufer overlay is kept up-to-date. In XEmacs also | 2367 | ;; Make sure the minibufer overlay is kept up-to-date. In XEmacs also |
| 2402 | ;; guards against the possibility of detaching this overlay. | 2368 | ;; guards against the possibility of detaching this overlay. |
| 2403 | (add-hook 'vip-post-command-hooks 'vip-move-minibuffer-overlay) | 2369 | (vip-add-hook 'vip-post-command-hooks 'vip-move-minibuffer-overlay) |
| 2404 | )) | 2370 | )) |
| 2405 | 2371 | ||
| 2406 | ;; Interpret last event in the local map | 2372 | ;; Interpret last event in the local map |
| @@ -2706,15 +2672,17 @@ Undo previous insertion and inserts new." | |||
| 2706 | vip-sitting-in-replace t | 2672 | vip-sitting-in-replace t |
| 2707 | vip-replace-chars-to-delete 0 | 2673 | vip-replace-chars-to-delete 0 |
| 2708 | vip-replace-chars-deleted 0) | 2674 | vip-replace-chars-deleted 0) |
| 2709 | (add-hook 'vip-after-change-functions 'vip-replace-mode-spy-after t) | 2675 | (vip-add-hook 'vip-after-change-functions 'vip-replace-mode-spy-after t) |
| 2710 | (add-hook 'vip-before-change-functions 'vip-replace-mode-spy-before t) | 2676 | (vip-add-hook 'vip-before-change-functions 'vip-replace-mode-spy-before t) |
| 2711 | ;; this will get added repeatedly, but no harm | 2677 | ;; this will get added repeatedly, but no harm |
| 2712 | (add-hook 'after-change-functions 'vip-after-change-sentinel t) | 2678 | (add-hook 'after-change-functions 'vip-after-change-sentinel t) |
| 2713 | (add-hook 'before-change-functions 'vip-before-change-sentinel t) | 2679 | (add-hook 'before-change-functions 'vip-before-change-sentinel t) |
| 2714 | (vip-move-marker-locally 'vip-last-posn-in-replace-region | 2680 | (vip-move-marker-locally 'vip-last-posn-in-replace-region |
| 2715 | (vip-replace-start)) | 2681 | (vip-replace-start)) |
| 2716 | (add-hook 'vip-post-command-hooks 'vip-replace-state-post-command-sentinel t) | 2682 | (vip-add-hook |
| 2717 | (add-hook 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel t) | 2683 | 'vip-post-command-hooks 'vip-replace-state-post-command-sentinel t) |
| 2684 | (vip-add-hook | ||
| 2685 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel t) | ||
| 2718 | ) | 2686 | ) |
| 2719 | 2687 | ||
| 2720 | ;; Runs vip-after-change-functions inside after-change-functions | 2688 | ;; Runs vip-after-change-functions inside after-change-functions |
| @@ -2731,15 +2699,15 @@ Undo previous insertion and inserts new." | |||
| 2731 | (funcall (car list) beg end) | 2699 | (funcall (car list) beg end) |
| 2732 | (setq list (cdr list))))) | 2700 | (setq list (cdr list))))) |
| 2733 | 2701 | ||
| 2734 | (defun vip-post-command-sentinel () | 2702 | (defsubst vip-post-command-sentinel () |
| 2735 | (run-hooks 'vip-post-command-hooks)) | 2703 | (run-hooks 'vip-post-command-hooks)) |
| 2736 | 2704 | ||
| 2737 | (defun vip-pre-command-sentinel () | 2705 | (defsubst vip-pre-command-sentinel () |
| 2738 | (run-hooks 'vip-pre-command-hooks)) | 2706 | (run-hooks 'vip-pre-command-hooks)) |
| 2739 | 2707 | ||
| 2740 | ;; Needed so that Viper will be able to figure the last inserted | 2708 | ;; Needed so that Viper will be able to figure the last inserted |
| 2741 | ;; chunk of text with reasonable accuracy. | 2709 | ;; chunk of text with reasonable accuracy. |
| 2742 | (defun vip-insert-state-post-command-sentinel () | 2710 | (defsubst vip-insert-state-post-command-sentinel () |
| 2743 | (if (and (memq vip-current-state '(insert-state replace-state)) | 2711 | (if (and (memq vip-current-state '(insert-state replace-state)) |
| 2744 | vip-insert-point | 2712 | vip-insert-point |
| 2745 | (>= (point) vip-insert-point)) | 2713 | (>= (point) vip-insert-point)) |
| @@ -2750,13 +2718,13 @@ Undo previous insertion and inserts new." | |||
| 2750 | (move-marker vip-insert-point vip-pre-command-point)) | 2718 | (move-marker vip-insert-point vip-pre-command-point)) |
| 2751 | ) | 2719 | ) |
| 2752 | 2720 | ||
| 2753 | (defun vip-insert-state-pre-command-sentinel () | 2721 | (defsubst vip-insert-state-pre-command-sentinel () |
| 2754 | (if (and (eq this-command 'dabbrev-expand) | 2722 | (if (and (eq this-command 'dabbrev-expand) |
| 2755 | (markerp vip-insert-point) | 2723 | (markerp vip-insert-point) |
| 2756 | (marker-position vip-insert-point)) | 2724 | (marker-position vip-insert-point)) |
| 2757 | (setq vip-pre-command-point (marker-position vip-insert-point)))) | 2725 | (setq vip-pre-command-point (marker-position vip-insert-point)))) |
| 2758 | 2726 | ||
| 2759 | (defun vip-R-state-post-command-sentinel () | 2727 | (defsubst vip-R-state-post-command-sentinel () |
| 2760 | ;; Restoring cursor color is needed despite | 2728 | ;; Restoring cursor color is needed despite |
| 2761 | ;; vip-replace-state-pre-command-sentinel: When you jump to another buffer in | 2729 | ;; vip-replace-state-pre-command-sentinel: When you jump to another buffer in |
| 2762 | ;; another frame, the pre-command hook won't change cursor color to default | 2730 | ;; another frame, the pre-command hook won't change cursor color to default |
| @@ -2771,7 +2739,7 @@ Undo previous insertion and inserts new." | |||
| 2771 | 2739 | ||
| 2772 | ;; to speed up, don't change cursor color before self-insert | 2740 | ;; to speed up, don't change cursor color before self-insert |
| 2773 | ;; and common move commands | 2741 | ;; and common move commands |
| 2774 | (defun vip-replace-state-pre-command-sentinel () | 2742 | (defsubst vip-replace-state-pre-command-sentinel () |
| 2775 | (or (memq this-command '(self-insert-command)) | 2743 | (or (memq this-command '(self-insert-command)) |
| 2776 | (memq (vip-event-key last-command-event) | 2744 | (memq (vip-event-key last-command-event) |
| 2777 | '(up down left right (meta f) (meta b) | 2745 | '(up down left right (meta f) (meta b) |
| @@ -2784,8 +2752,13 @@ Undo previous insertion and inserts new." | |||
| 2784 | ;; in another frame, the pre-command hook won't change cursor color to | 2752 | ;; in another frame, the pre-command hook won't change cursor color to |
| 2785 | ;; default in that other frame. So, if the second frame cursor was red and | 2753 | ;; default in that other frame. So, if the second frame cursor was red and |
| 2786 | ;; we set the point outside the replacement region, then the cursor color | 2754 | ;; we set the point outside the replacement region, then the cursor color |
| 2787 | ;; will remain red. Restoring the default, below, prevents this. | 2755 | ;; will remain red. Restoring the default, below, fixes this problem. |
| 2788 | (vip-restore-cursor-color) | 2756 | ;; |
| 2757 | ;; We optimize for self-insert-command's here, since they either don't change | ||
| 2758 | ;; cursor color or, if they terminate replace mode, the color will be changed | ||
| 2759 | ;; in vip-finish-change | ||
| 2760 | (or (memq this-command '(self-insert-command)) | ||
| 2761 | (vip-restore-cursor-color)) | ||
| 2789 | (cond | 2762 | (cond |
| 2790 | ((eq vip-current-state 'replace-state) | 2763 | ((eq vip-current-state 'replace-state) |
| 2791 | ;; delete characters to compensate for inserted chars. | 2764 | ;; delete characters to compensate for inserted chars. |
| @@ -2896,11 +2869,12 @@ Undo previous insertion and inserts new." | |||
| 2896 | ;; Delete stuff between posn and the end of vip-replace-overlay-marker, if | 2869 | ;; Delete stuff between posn and the end of vip-replace-overlay-marker, if |
| 2897 | ;; posn is within the overlay. | 2870 | ;; posn is within the overlay. |
| 2898 | (defun vip-finish-change (posn) | 2871 | (defun vip-finish-change (posn) |
| 2899 | (remove-hook 'vip-after-change-functions 'vip-replace-mode-spy-after) | 2872 | (vip-remove-hook 'vip-after-change-functions 'vip-replace-mode-spy-after) |
| 2900 | (remove-hook 'vip-before-change-functions 'vip-replace-mode-spy-before) | 2873 | (vip-remove-hook 'vip-before-change-functions 'vip-replace-mode-spy-before) |
| 2901 | (remove-hook 'vip-post-command-hooks | 2874 | (vip-remove-hook 'vip-post-command-hooks |
| 2902 | 'vip-replace-state-post-command-sentinel) | 2875 | 'vip-replace-state-post-command-sentinel) |
| 2903 | (remove-hook 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) | 2876 | (vip-remove-hook |
| 2877 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) | ||
| 2904 | (vip-restore-cursor-color) | 2878 | (vip-restore-cursor-color) |
| 2905 | (setq vip-sitting-in-replace nil) ; just in case we'll need to know it | 2879 | (setq vip-sitting-in-replace nil) ; just in case we'll need to know it |
| 2906 | (save-excursion | 2880 | (save-excursion |
| @@ -2928,15 +2902,18 @@ Undo previous insertion and inserts new." | |||
| 2928 | (setq kill-ring-yank-pointer kill-ring)) | 2902 | (setq kill-ring-yank-pointer kill-ring)) |
| 2929 | 2903 | ||
| 2930 | (defun vip-finish-R-mode () | 2904 | (defun vip-finish-R-mode () |
| 2931 | (remove-hook 'vip-post-command-hooks 'vip-R-state-post-command-sentinel) | 2905 | (vip-remove-hook 'vip-post-command-hooks 'vip-R-state-post-command-sentinel) |
| 2932 | (remove-hook 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) | 2906 | (vip-remove-hook |
| 2907 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) | ||
| 2933 | (vip-downgrade-to-insert)) | 2908 | (vip-downgrade-to-insert)) |
| 2934 | 2909 | ||
| 2935 | (defun vip-start-R-mode () | 2910 | (defun vip-start-R-mode () |
| 2936 | ;; Leave arg as 1, not t: XEmacs insists that it must be a pos number | 2911 | ;; Leave arg as 1, not t: XEmacs insists that it must be a pos number |
| 2937 | (overwrite-mode 1) | 2912 | (overwrite-mode 1) |
| 2938 | (add-hook 'vip-post-command-hooks 'vip-R-state-post-command-sentinel t) | 2913 | (vip-add-hook |
| 2939 | (add-hook 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel t) | 2914 | 'vip-post-command-hooks 'vip-R-state-post-command-sentinel t) |
| 2915 | (vip-add-hook | ||
| 2916 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel t) | ||
| 2940 | ) | 2917 | ) |
| 2941 | 2918 | ||
| 2942 | 2919 | ||
| @@ -3028,7 +3005,7 @@ These keys are ESC, RET, and LineFeed" | |||
| 3028 | (defun vip-replace-char (arg) | 3005 | (defun vip-replace-char (arg) |
| 3029 | "Replace the following ARG chars by the character read." | 3006 | "Replace the following ARG chars by the character read." |
| 3030 | (interactive "P") | 3007 | (interactive "P") |
| 3031 | (if (and (eolp) (bolp)) (error "I see no character to replace here")) | 3008 | (if (and (eolp) (bolp)) (error "No character to replace here")) |
| 3032 | (let ((val (vip-p-val arg)) | 3009 | (let ((val (vip-p-val arg)) |
| 3033 | (com (vip-getcom arg))) | 3010 | (com (vip-getcom arg))) |
| 3034 | (vip-replace-char-subr (if (equal com ?r) vip-d-char (read-char)) val) | 3011 | (vip-replace-char-subr (if (equal com ?r) vip-d-char (read-char)) val) |
| @@ -4665,7 +4642,7 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4665 | (text-marker (get-register reg))) | 4642 | (text-marker (get-register reg))) |
| 4666 | (if com (vip-move-marker-locally 'vip-com-point (point))) | 4643 | (if com (vip-move-marker-locally 'vip-com-point (point))) |
| 4667 | (if (not (vip-valid-marker text-marker)) | 4644 | (if (not (vip-valid-marker text-marker)) |
| 4668 | (error (format vip-EmptyTextmarker char))) | 4645 | (error (format vip-EmptyTextmarker char))) |
| 4669 | (if (and (vip-same-line (point) vip-last-jump) | 4646 | (if (and (vip-same-line (point) vip-last-jump) |
| 4670 | (= (point) vip-last-jump-ignore)) | 4647 | (= (point) vip-last-jump-ignore)) |
| 4671 | (push-mark vip-last-jump t) | 4648 | (push-mark vip-last-jump t) |
| @@ -4754,7 +4731,10 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4754 | (setq vip-current-indent col) | 4731 | (setq vip-current-indent col) |
| 4755 | (setq vip-preserve-indent nil)) | 4732 | (setq vip-preserve-indent nil)) |
| 4756 | ;; don't leave whitespace lines around | 4733 | ;; don't leave whitespace lines around |
| 4757 | (if (memq last-command '(vip-autoindent vip-open-line vip-Open-line)) | 4734 | (if (memq last-command |
| 4735 | '(vip-autoindent | ||
| 4736 | vip-open-line vip-Open-line | ||
| 4737 | vip-replace-state-exit-cmd)) | ||
| 4758 | (indent-to-left-margin)) | 4738 | (indent-to-left-margin)) |
| 4759 | (newline 1) | 4739 | (newline 1) |
| 4760 | (if vip-auto-indent | 4740 | (if vip-auto-indent |
| @@ -5269,10 +5249,22 @@ Mail anyway (y or n)? ") | |||
| 5269 | ((eventp arg) (list arg)) | 5249 | ((eventp arg) (list arg)) |
| 5270 | ((stringp arg) (mapcar 'character-to-event arg)) | 5250 | ((stringp arg) (mapcar 'character-to-event arg)) |
| 5271 | ((vectorp arg) (append arg nil)) ; turn into list | 5251 | ((vectorp arg) (append arg nil)) ; turn into list |
| 5272 | ((listp arg) arg) | 5252 | ((listp arg) (vip-eventify-list-xemacs arg)) |
| 5273 | (t (error | 5253 | (t (error |
| 5274 | "vip-set-unread-command-events: Invalid argument, %S" arg))) | 5254 | "vip-set-unread-command-events: Invalid argument, %S" arg))) |
| 5275 | unread-command-events)))) | 5255 | unread-command-events)))) |
| 5256 | |||
| 5257 | ;; list is assumed to be a list of events of characters | ||
| 5258 | (defun vip-eventify-list-xemacs (lis) | ||
| 5259 | (mapcar | ||
| 5260 | (function (lambda (elt) | ||
| 5261 | (cond ((numberp elt) (character-to-event elt)) | ||
| 5262 | ((eventp elt) elt) | ||
| 5263 | (t (error | ||
| 5264 | "vip-eventify-list-xemacs: can't convert to event, %S" | ||
| 5265 | elt))))) | ||
| 5266 | lis)) | ||
| 5267 | |||
| 5276 | 5268 | ||
| 5277 | 5269 | ||
| 5278 | ;;; Bring in the rest of the files | 5270 | ;;; Bring in the rest of the files |
| @@ -5370,7 +5362,7 @@ Mail anyway (y or n)? ") | |||
| 5370 | (vip-change-state-to-vi))) | 5362 | (vip-change-state-to-vi))) |
| 5371 | 5363 | ||
| 5372 | ;; passwd.el sets up its own buffer, which turns up in Vi mode, | 5364 | ;; passwd.el sets up its own buffer, which turns up in Vi mode, |
| 5373 | ;; overriding the local map. Noone needs Vi mode here. | 5365 | ;; thus overriding the local map. We don't need Vi mode here. |
| 5374 | (vip-eval-after-load | 5366 | (vip-eval-after-load |
| 5375 | "passwd" | 5367 | "passwd" |
| 5376 | '(defadvice read-passwd-1 (before vip-passwd-ad activate) | 5368 | '(defadvice read-passwd-1 (before vip-passwd-ad activate) |