diff options
| author | Michael Kifer | 1996-12-28 02:53:04 +0000 |
|---|---|---|
| committer | Michael Kifer | 1996-12-28 02:53:04 +0000 |
| commit | bf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01 (patch) | |
| tree | 710e2d34c85a2982384a996efb2ccffb6d523843 /lisp/emulation | |
| parent | 469b44cbf1916dc9502d4356e8fce0081809f585 (diff) | |
| download | emacs-bf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01.tar.gz emacs-bf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01.zip | |
*** empty log message ***
Diffstat (limited to 'lisp/emulation')
| -rw-r--r-- | lisp/emulation/viper-keym.el | 1 | ||||
| -rw-r--r-- | lisp/emulation/viper-mous.el | 6 | ||||
| -rw-r--r-- | lisp/emulation/viper-util.el | 8 | ||||
| -rw-r--r-- | lisp/emulation/viper.el | 228 |
4 files changed, 196 insertions, 47 deletions
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el index 75890aae5eb..f9c09514d79 100644 --- a/lisp/emulation/viper-keym.el +++ b/lisp/emulation/viper-keym.el | |||
| @@ -398,6 +398,7 @@ Useful in some modes, such as Gnus, MH, etc.") | |||
| 398 | (defvar vip-dired-modifier-map (make-sparse-keymap) | 398 | (defvar vip-dired-modifier-map (make-sparse-keymap) |
| 399 | "This map modifies Dired behavior.") | 399 | "This map modifies Dired behavior.") |
| 400 | (define-key vip-dired-modifier-map ":" 'vip-ex) | 400 | (define-key vip-dired-modifier-map ":" 'vip-ex) |
| 401 | (define-key vip-dired-modifier-map "/" 'vip-search-forward) | ||
| 401 | 402 | ||
| 402 | 403 | ||
| 403 | 404 | ||
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 16e20aabda8..73cef2eef85 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el | |||
| @@ -354,8 +354,10 @@ this command." | |||
| 354 | vip-mouse-click-search-limit nil))) | 354 | vip-mouse-click-search-limit nil))) |
| 355 | (goto-char (match-beginning 0)) | 355 | (goto-char (match-beginning 0)) |
| 356 | (message "Searching for: %s" vip-s-string) | 356 | (message "Searching for: %s" vip-s-string) |
| 357 | (if (<= arg 1) | 357 | (if (<= arg 1) ; found the right occurrence of the pattern |
| 358 | (vip-flash-search-pattern)) | 358 | (progn |
| 359 | (vip-adjust-window) | ||
| 360 | (vip-flash-search-pattern))) | ||
| 359 | ) | 361 | ) |
| 360 | (error (beep 1) | 362 | (error (beep 1) |
| 361 | (if (or (not (string= click-word previous-search-string)) | 363 | (if (or (not (string= click-word previous-search-string)) |
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 70daa478bae..059e840d3a4 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el | |||
| @@ -249,9 +249,12 @@ that Viper doesn't know about.") | |||
| 249 | (not (string= color vip-replace-overlay-cursor-color))) | 249 | (not (string= color vip-replace-overlay-cursor-color))) |
| 250 | (vip-overlay-put vip-replace-overlay 'vip-cursor-color color))))) | 250 | (vip-overlay-put vip-replace-overlay 'vip-cursor-color color))))) |
| 251 | 251 | ||
| 252 | (defsubst vip-restore-cursor-color () | 252 | ;; restore cursor color from replace overlay |
| 253 | (defsubst vip-restore-cursor-color-after-replace () | ||
| 253 | (vip-change-cursor-color | 254 | (vip-change-cursor-color |
| 254 | (vip-overlay-get vip-replace-overlay 'vip-cursor-color))) | 255 | (vip-overlay-get vip-replace-overlay 'vip-cursor-color))) |
| 256 | (defsubst vip-restore-cursor-color-after-insert () | ||
| 257 | (vip-change-cursor-color vip-saved-cursor-color)) | ||
| 255 | 258 | ||
| 256 | 259 | ||
| 257 | ;; Check the current version against the major and minor version numbers | 260 | ;; Check the current version against the major and minor version numbers |
| @@ -789,7 +792,8 @@ to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'." | |||
| 789 | 792 | ||
| 790 | (defsubst vip-hide-replace-overlay () | 793 | (defsubst vip-hide-replace-overlay () |
| 791 | (vip-set-replace-overlay-glyphs nil nil) | 794 | (vip-set-replace-overlay-glyphs nil nil) |
| 792 | (vip-restore-cursor-color) | 795 | (vip-restore-cursor-color-after-replace) |
| 796 | (vip-restore-cursor-color-after-insert) | ||
| 793 | (if (vip-has-face-support-p) | 797 | (if (vip-has-face-support-p) |
| 794 | (vip-overlay-put vip-replace-overlay 'face nil))) | 798 | (vip-overlay-put vip-replace-overlay 'face nil))) |
| 795 | 799 | ||
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index f3ede946449..592f15021ac 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el | |||
| @@ -479,7 +479,11 @@ it better fits your working style.") | |||
| 479 | 479 | ||
| 480 | (defvar vip-replace-overlay-cursor-color "Red" | 480 | (defvar vip-replace-overlay-cursor-color "Red" |
| 481 | "*Cursor color to use in Replace state") | 481 | "*Cursor color to use in Replace state") |
| 482 | 482 | (defvar vip-insert-state-cursor-color nil | |
| 483 | "Cursor color for Viper insert state.") | ||
| 484 | (put 'vip-insert-state-cursor-color 'permanent-local t) | ||
| 485 | ;; place to save cursor colow when switching to insert mode | ||
| 486 | (vip-deflocalvar vip-saved-cursor-color nil "") | ||
| 483 | 487 | ||
| 484 | (vip-deflocalvar vip-replace-overlay nil "") | 488 | (vip-deflocalvar vip-replace-overlay nil "") |
| 485 | (put 'vip-replace-overlay 'permanent-local t) | 489 | (put 'vip-replace-overlay 'permanent-local t) |
| @@ -698,10 +702,14 @@ to a new place after repeating previous Vi command.") | |||
| 698 | (defvar vip-s-forward nil) | 702 | (defvar vip-s-forward nil) |
| 699 | 703 | ||
| 700 | (defconst vip-case-fold-search nil | 704 | (defconst vip-case-fold-search nil |
| 701 | "*If t, search ignores cases.") | 705 | "*If not nil, search ignores cases.") |
| 702 | 706 | ||
| 703 | (defconst vip-re-search t | 707 | (defconst vip-re-search t |
| 704 | "*If t, search is reg-exp search, otherwise vanilla search.") | 708 | "*If not nil, search is reg-exp search, otherwise vanilla search.") |
| 709 | |||
| 710 | (defvar vip-adjust-window-after-search t | ||
| 711 | "*If not nil, pull the window up or down, depending on the direction of the | ||
| 712 | search, if search ends up near the bottom or near the top of the window.") | ||
| 705 | 713 | ||
| 706 | (defconst vip-re-query-replace t | 714 | (defconst vip-re-query-replace t |
| 707 | "*If t then do regexp replace, if nil then do string replace.") | 715 | "*If t then do regexp replace, if nil then do string replace.") |
| @@ -983,6 +991,14 @@ Should be set in `~/.vip' file.") | |||
| 983 | vip-insert-point | 991 | vip-insert-point |
| 984 | (>= (point) vip-insert-point)) | 992 | (>= (point) vip-insert-point)) |
| 985 | (setq vip-last-posn-while-in-insert-state (point-marker))) | 993 | (setq vip-last-posn-while-in-insert-state (point-marker))) |
| 994 | (if (eq vip-current-state 'insert-state) | ||
| 995 | (progn | ||
| 996 | (or (stringp vip-saved-cursor-color) | ||
| 997 | (string= (vip-get-cursor-color) vip-insert-state-cursor-color) | ||
| 998 | (setq vip-saved-cursor-color (vip-get-cursor-color))) | ||
| 999 | (if (stringp vip-saved-cursor-color) | ||
| 1000 | (vip-change-cursor-color vip-insert-state-cursor-color)) | ||
| 1001 | )) | ||
| 986 | (if (and (eq this-command 'dabbrev-expand) | 1002 | (if (and (eq this-command 'dabbrev-expand) |
| 987 | (integerp vip-pre-command-point) | 1003 | (integerp vip-pre-command-point) |
| 988 | (> vip-insert-point vip-pre-command-point)) | 1004 | (> vip-insert-point vip-pre-command-point)) |
| @@ -990,6 +1006,11 @@ Should be set in `~/.vip' file.") | |||
| 990 | ) | 1006 | ) |
| 991 | 1007 | ||
| 992 | (defsubst vip-insert-state-pre-command-sentinel () | 1008 | (defsubst vip-insert-state-pre-command-sentinel () |
| 1009 | (or (memq this-command '(self-insert-command)) | ||
| 1010 | (memq (vip-event-key last-command-event) | ||
| 1011 | '(up down left right (meta f) (meta b) | ||
| 1012 | (control n) (control p) (control f) (control b))) | ||
| 1013 | (vip-restore-cursor-color-after-insert)) | ||
| 993 | (if (and (eq this-command 'dabbrev-expand) | 1014 | (if (and (eq this-command 'dabbrev-expand) |
| 994 | (markerp vip-insert-point) | 1015 | (markerp vip-insert-point) |
| 995 | (marker-position vip-insert-point)) | 1016 | (marker-position vip-insert-point)) |
| @@ -1005,7 +1026,7 @@ Should be set in `~/.vip' file.") | |||
| 1005 | (if (and (<= (vip-replace-start) (point)) | 1026 | (if (and (<= (vip-replace-start) (point)) |
| 1006 | (<= (point) (vip-replace-end))) | 1027 | (<= (point) (vip-replace-end))) |
| 1007 | (vip-change-cursor-color vip-replace-overlay-cursor-color) | 1028 | (vip-change-cursor-color vip-replace-overlay-cursor-color) |
| 1008 | (vip-restore-cursor-color) | 1029 | (vip-restore-cursor-color-after-replace) |
| 1009 | )) | 1030 | )) |
| 1010 | 1031 | ||
| 1011 | ;; to speed up, don't change cursor color before self-insert | 1032 | ;; to speed up, don't change cursor color before self-insert |
| @@ -1015,7 +1036,7 @@ Should be set in `~/.vip' file.") | |||
| 1015 | (memq (vip-event-key last-command-event) | 1036 | (memq (vip-event-key last-command-event) |
| 1016 | '(up down left right (meta f) (meta b) | 1037 | '(up down left right (meta f) (meta b) |
| 1017 | (control n) (control p) (control f) (control b))) | 1038 | (control n) (control p) (control f) (control b))) |
| 1018 | (vip-restore-cursor-color))) | 1039 | (vip-restore-cursor-color-after-replace))) |
| 1019 | 1040 | ||
| 1020 | (defun vip-replace-state-post-command-sentinel () | 1041 | (defun vip-replace-state-post-command-sentinel () |
| 1021 | ;; Restoring cursor color is needed despite | 1042 | ;; Restoring cursor color is needed despite |
| @@ -1029,7 +1050,7 @@ Should be set in `~/.vip' file.") | |||
| 1029 | ;; cursor color or, if they terminate replace mode, the color will be changed | 1050 | ;; cursor color or, if they terminate replace mode, the color will be changed |
| 1030 | ;; in vip-finish-change | 1051 | ;; in vip-finish-change |
| 1031 | (or (memq this-command '(self-insert-command)) | 1052 | (or (memq this-command '(self-insert-command)) |
| 1032 | (vip-restore-cursor-color)) | 1053 | (vip-restore-cursor-color-after-replace)) |
| 1033 | (cond | 1054 | (cond |
| 1034 | ((eq vip-current-state 'replace-state) | 1055 | ((eq vip-current-state 'replace-state) |
| 1035 | ;; delete characters to compensate for inserted chars. | 1056 | ;; delete characters to compensate for inserted chars. |
| @@ -1148,18 +1169,18 @@ Should be set in `~/.vip' file.") | |||
| 1148 | 1169 | ||
| 1149 | (if vip-want-ctl-h-help | 1170 | (if vip-want-ctl-h-help |
| 1150 | (progn | 1171 | (progn |
| 1151 | (define-key vip-insert-basic-map "\C-h" 'help-command) | 1172 | (define-key vip-insert-basic-map [(control h)] 'help-command) |
| 1152 | (define-key vip-replace-map "\C-h" 'help-command)) | 1173 | (define-key vip-replace-map [(control h)] 'help-command)) |
| 1153 | (define-key vip-insert-basic-map | 1174 | (define-key vip-insert-basic-map |
| 1154 | "\C-h" 'vip-del-backward-char-in-insert) | 1175 | [(control h)] 'vip-del-backward-char-in-insert) |
| 1155 | (define-key vip-replace-map | 1176 | (define-key vip-replace-map |
| 1156 | "\C-h" 'vip-del-backward-char-in-replace))) | 1177 | [(control h)] 'vip-del-backward-char-in-replace))) |
| 1157 | 1178 | ||
| 1158 | (t | 1179 | (t ; Vi state |
| 1159 | (setq vip-vi-diehard-minor-mode (not vip-want-emacs-keys-in-vi)) | 1180 | (setq vip-vi-diehard-minor-mode (not vip-want-emacs-keys-in-vi)) |
| 1160 | (if vip-want-ctl-h-help | 1181 | (if vip-want-ctl-h-help |
| 1161 | (define-key vip-vi-basic-map "\C-h" 'help-command) | 1182 | (define-key vip-vi-basic-map [(control h)] 'help-command) |
| 1162 | (define-key vip-vi-basic-map "\C-h" 'vip-backward-char))) | 1183 | (define-key vip-vi-basic-map [(control h)] 'vip-backward-char))) |
| 1163 | )) | 1184 | )) |
| 1164 | 1185 | ||
| 1165 | 1186 | ||
| @@ -1429,6 +1450,8 @@ This startup message appears whenever you load Viper, unless you type `y' now." | |||
| 1429 | ;; keys `,',^ in Vi state, as they will do accents instead of Vi actions. | 1450 | ;; keys `,',^ in Vi state, as they will do accents instead of Vi actions. |
| 1430 | (if (and (boundp 'iso-accents-mode) iso-accents-mode) | 1451 | (if (and (boundp 'iso-accents-mode) iso-accents-mode) |
| 1431 | (iso-accents-mode -1)) | 1452 | (iso-accents-mode -1)) |
| 1453 | |||
| 1454 | (vip-restore-cursor-color-after-insert) | ||
| 1432 | 1455 | ||
| 1433 | ;; Protection against user errors in hooks | 1456 | ;; Protection against user errors in hooks |
| 1434 | (condition-case conds | 1457 | (condition-case conds |
| @@ -1443,6 +1466,14 @@ This startup message appears whenever you load Viper, unless you type `y' now." | |||
| 1443 | (if (and vip-automatic-iso-accents (fboundp 'iso-accents-mode)) | 1466 | (if (and vip-automatic-iso-accents (fboundp 'iso-accents-mode)) |
| 1444 | (iso-accents-mode 1)) ; turn iso accents on | 1467 | (iso-accents-mode 1)) ; turn iso accents on |
| 1445 | 1468 | ||
| 1469 | (or (stringp vip-saved-cursor-color) | ||
| 1470 | (string= (vip-get-cursor-color) vip-insert-state-cursor-color) | ||
| 1471 | (setq vip-saved-cursor-color (vip-get-cursor-color))) | ||
| 1472 | ;; Commented out, because if vip-change-state-to-insert is executed | ||
| 1473 | ;; non-interactively then the old cursor color may get lost. Same old Emacs | ||
| 1474 | ;; bug related to local variables? | ||
| 1475 | ;;;(if (stringp vip-saved-cursor-color) | ||
| 1476 | ;;; (vip-change-cursor-color vip-insert-state-cursor-color)) | ||
| 1446 | ;; Protection against user errors in hooks | 1477 | ;; Protection against user errors in hooks |
| 1447 | (condition-case conds | 1478 | (condition-case conds |
| 1448 | (run-hooks 'vip-insert-state-hook) | 1479 | (run-hooks 'vip-insert-state-hook) |
| @@ -2546,20 +2577,23 @@ Undo previous insertion and inserts new." | |||
| 2546 | ;; Tells whether BEG is on the same line as END. | 2577 | ;; Tells whether BEG is on the same line as END. |
| 2547 | ;; If one of the args is nil, it'll return nil. | 2578 | ;; If one of the args is nil, it'll return nil. |
| 2548 | (defun vip-same-line (beg end) | 2579 | (defun vip-same-line (beg end) |
| 2549 | (let ((selective-display nil)) | 2580 | (let ((selective-display nil) |
| 2550 | (cond ((and beg end) | 2581 | (incr 0) |
| 2551 | ;; This 'if' is needed because Emacs treats the next empty line | 2582 | temp) |
| 2552 | ;; as part of the previous line. | 2583 | (if (and beg end (> beg end)) |
| 2553 | (if (or (> beg (point-max)) (> end (point-max))) ; out of range | 2584 | (setq temp beg |
| 2554 | () | 2585 | beg end |
| 2555 | (if (and (> end beg) (= (vip-line-pos 'start) end)) | 2586 | end temp)) |
| 2556 | (setq end (min (1+ end) (point-max)))) | 2587 | (if (and beg end) |
| 2557 | (if (and (> beg end) (= (vip-line-pos 'start) beg)) | 2588 | (cond ((or (> beg (point-max)) (> end (point-max))) ; out of range |
| 2558 | (setq beg (min (1+ beg) (point-max)))) | 2589 | nil) |
| 2559 | (<= (count-lines beg end) 1) )) | 2590 | (t |
| 2560 | 2591 | ;; This 'if' is needed because Emacs treats the next empty line | |
| 2561 | (t nil)) | 2592 | ;; as part of the previous line. |
| 2562 | )) | 2593 | (if (= (vip-line-pos 'start) end) |
| 2594 | (setq incr 1)) | ||
| 2595 | (<= (+ incr (count-lines beg end)) 1)))) | ||
| 2596 | )) | ||
| 2563 | 2597 | ||
| 2564 | 2598 | ||
| 2565 | ;; Check if the string ends with a newline. | 2599 | ;; Check if the string ends with a newline. |
| @@ -3024,7 +3058,7 @@ Undo previous insertion and inserts new." | |||
| 3024 | 'vip-replace-state-post-command-sentinel) | 3058 | 'vip-replace-state-post-command-sentinel) |
| 3025 | (vip-remove-hook | 3059 | (vip-remove-hook |
| 3026 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) | 3060 | 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) |
| 3027 | (vip-restore-cursor-color) | 3061 | (vip-restore-cursor-color-after-replace) |
| 3028 | (setq vip-sitting-in-replace nil) ; just in case we'll need to know it | 3062 | (setq vip-sitting-in-replace nil) ; just in case we'll need to know it |
| 3029 | (save-excursion | 3063 | (save-excursion |
| 3030 | (if (and | 3064 | (if (and |
| @@ -3840,6 +3874,32 @@ controlled by the sign of prefix numeric value." | |||
| 3840 | (interactive "p") | 3874 | (interactive "p") |
| 3841 | (recenter (- (window-height) (1+ arg)))) | 3875 | (recenter (- (window-height) (1+ arg)))) |
| 3842 | 3876 | ||
| 3877 | ;; If vip-adjust-window-after-search is t, scroll up or down 1/4 of window | ||
| 3878 | ;; height, depending on whether we are at the bottom or at the top of the | ||
| 3879 | ;; window. This function is called by vip-search (which is called from | ||
| 3880 | ;; vip-search-forward/backward/next) | ||
| 3881 | (defun vip-adjust-window () | ||
| 3882 | (let ((win-height (if vip-emacs-p | ||
| 3883 | (1- (window-height)) ; adjust for modeline | ||
| 3884 | (window-displayed-height))) | ||
| 3885 | (pt (point)) | ||
| 3886 | at-top-p at-bottom-p | ||
| 3887 | min-scroll direction) | ||
| 3888 | (save-excursion | ||
| 3889 | (move-to-window-line 0) ; top | ||
| 3890 | (setq at-top-p (<= (count-lines pt (point)) 2)) | ||
| 3891 | (move-to-window-line -1) ; bottom | ||
| 3892 | (setq at-bottom-p (<= (count-lines pt (point)) 2)) | ||
| 3893 | ) | ||
| 3894 | (cond (at-top-p (setq min-scroll 1 | ||
| 3895 | direction 1)) | ||
| 3896 | (at-bottom-p (setq min-scroll 2 | ||
| 3897 | direction -1))) | ||
| 3898 | (if (and vip-adjust-window-after-search min-scroll) | ||
| 3899 | (recenter | ||
| 3900 | (* (max min-scroll (/ win-height 7)) direction))) | ||
| 3901 | )) | ||
| 3902 | |||
| 3843 | 3903 | ||
| 3844 | ;; paren match | 3904 | ;; paren match |
| 3845 | ;; must correct this to only match ( to ) etc. On the other hand | 3905 | ;; must correct this to only match ( to ) etc. On the other hand |
| @@ -4091,6 +4151,62 @@ the Emacs binding of `/'." | |||
| 4091 | (setq msg "Search style remains unchanged"))) | 4151 | (setq msg "Search style remains unchanged"))) |
| 4092 | (prin1 msg t))) | 4152 | (prin1 msg t))) |
| 4093 | 4153 | ||
| 4154 | (defun vip-set-vi-search-style-macros (unset) | ||
| 4155 | "Set the macros for toggling the search style in Viper's vi-state. | ||
| 4156 | The macro that toggles case sensitivity is bound to `//', and the one that | ||
| 4157 | toggles regexp search is bound to `///'. | ||
| 4158 | With a prefix argument, this function unsets the macros. " | ||
| 4159 | (interactive "P") | ||
| 4160 | (or noninteractive | ||
| 4161 | (if (not unset) | ||
| 4162 | (progn | ||
| 4163 | ;; toggle case sensitivity in search | ||
| 4164 | (vip-record-kbd-macro | ||
| 4165 | "//" 'vi-state | ||
| 4166 | [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] | ||
| 4167 | 't) | ||
| 4168 | ;; toggle regexp/vanila search | ||
| 4169 | (vip-record-kbd-macro | ||
| 4170 | "///" 'vi-state | ||
| 4171 | [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] | ||
| 4172 | 't) | ||
| 4173 | (if (interactive-p) | ||
| 4174 | (message | ||
| 4175 | "// and /// now toggle case-sensitivity and regexp search."))) | ||
| 4176 | (vip-unrecord-kbd-macro "//" 'vi-state) | ||
| 4177 | (sit-for 2) | ||
| 4178 | (vip-unrecord-kbd-macro "///" 'vi-state)))) | ||
| 4179 | |||
| 4180 | (defun vip-set-emacs-search-style-macros (unset &optional arg-majormode) | ||
| 4181 | "Set the macros for toggling the search style in Viper's emacs-state. | ||
| 4182 | The macro that toggles case sensitivity is bound to `//', and the one that | ||
| 4183 | toggles regexp search is bound to `///'. | ||
| 4184 | With a prefix argument, this function unsets the macros. | ||
| 4185 | If the optional prefix argument is non-nil and specifies a valid major mode, | ||
| 4186 | this sets the macros only in the macros in that major mode. Otherwise, | ||
| 4187 | the macros are set in the current major mode. | ||
| 4188 | \(When unsetting the macros, the second argument has no effect.\)" | ||
| 4189 | (interactive "P") | ||
| 4190 | (or noninteractive | ||
| 4191 | (if (not unset) | ||
| 4192 | (progn | ||
| 4193 | ;; toggle case sensitivity in search | ||
| 4194 | (vip-record-kbd-macro | ||
| 4195 | "//" 'emacs-state | ||
| 4196 | [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] | ||
| 4197 | (or arg-majormode major-mode)) | ||
| 4198 | ;; toggle regexp/vanila search | ||
| 4199 | (vip-record-kbd-macro | ||
| 4200 | "///" 'emacs-state | ||
| 4201 | [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] | ||
| 4202 | (or arg-majormode major-mode)) | ||
| 4203 | (if (interactive-p) | ||
| 4204 | (message | ||
| 4205 | "// and /// now toggle case-sensitivity and regexp search."))) | ||
| 4206 | (vip-unrecord-kbd-macro "//" 'emacs-state) | ||
| 4207 | (sit-for 2) | ||
| 4208 | (vip-unrecord-kbd-macro "///" 'emacs-state)))) | ||
| 4209 | |||
| 4094 | 4210 | ||
| 4095 | (defun vip-search-forward (arg) | 4211 | (defun vip-search-forward (arg) |
| 4096 | "Search a string forward. | 4212 | "Search a string forward. |
| @@ -4159,9 +4275,6 @@ Null string will repeat previous search." | |||
| 4159 | (re-search-backward string)) | 4275 | (re-search-backward string)) |
| 4160 | (search-forward string nil nil val) | 4276 | (search-forward string nil nil val) |
| 4161 | (search-backward string)) | 4277 | (search-backward string)) |
| 4162 | ;; don't wait and don't flash in macros | ||
| 4163 | (or executing-kbd-macro | ||
| 4164 | (vip-flash-search-pattern)) | ||
| 4165 | (if (not (equal start-point (point))) | 4278 | (if (not (equal start-point (point))) |
| 4166 | (push-mark start-point t))) | 4279 | (push-mark start-point t))) |
| 4167 | (search-failed | 4280 | (search-failed |
| @@ -4186,9 +4299,6 @@ Null string will repeat previous search." | |||
| 4186 | (if vip-re-search | 4299 | (if vip-re-search |
| 4187 | (re-search-backward string nil nil val) | 4300 | (re-search-backward string nil nil val) |
| 4188 | (search-backward string nil nil val)) | 4301 | (search-backward string nil nil val)) |
| 4189 | ;; don't wait and don't flash in macros | ||
| 4190 | (or executing-kbd-macro | ||
| 4191 | (vip-flash-search-pattern)) | ||
| 4192 | (if (not (equal start-point (point))) | 4302 | (if (not (equal start-point (point))) |
| 4193 | (push-mark start-point t))) | 4303 | (push-mark start-point t))) |
| 4194 | (search-failed | 4304 | (search-failed |
| @@ -4206,7 +4316,14 @@ Null string will repeat previous search." | |||
| 4206 | (error "`%s': %s not found" | 4316 | (error "`%s': %s not found" |
| 4207 | string | 4317 | string |
| 4208 | (if vip-re-search "Pattern" "String")) | 4318 | (if vip-re-search "Pattern" "String")) |
| 4209 | ))))))) | 4319 | )))) |
| 4320 | ;; pull up or down if at top/bottom of window | ||
| 4321 | (vip-adjust-window) | ||
| 4322 | ;; highlight the result of search | ||
| 4323 | ;; don't wait and don't highlight in macros | ||
| 4324 | (or executing-kbd-macro | ||
| 4325 | (vip-flash-search-pattern)) | ||
| 4326 | ))) | ||
| 4210 | 4327 | ||
| 4211 | (defun vip-search-next (arg) | 4328 | (defun vip-search-next (arg) |
| 4212 | "Repeat previous search." | 4329 | "Repeat previous search." |
| @@ -4412,6 +4529,7 @@ To turn this feature off, set this variable to nil.") | |||
| 4412 | (setq vip-use-register nil) | 4529 | (setq vip-use-register nil) |
| 4413 | (if (vip-end-with-a-newline-p text) | 4530 | (if (vip-end-with-a-newline-p text) |
| 4414 | (progn | 4531 | (progn |
| 4532 | (end-of-line) | ||
| 4415 | (if (eobp) | 4533 | (if (eobp) |
| 4416 | (insert "\n") | 4534 | (insert "\n") |
| 4417 | (forward-line 1)) | 4535 | (forward-line 1)) |
| @@ -5507,6 +5625,11 @@ Mail anyway (y or n)? ") | |||
| 5507 | 5625 | ||
| 5508 | (defvar fortran-mode-hook) | 5626 | (defvar fortran-mode-hook) |
| 5509 | (add-hook 'fortran-mode-hook 'vip-mode) | 5627 | (add-hook 'fortran-mode-hook 'vip-mode) |
| 5628 | |||
| 5629 | (defvar basic-mode-hook) | ||
| 5630 | (add-hook 'basic-mode-hook 'vip-mode) | ||
| 5631 | (defvar bat-mode-hook) | ||
| 5632 | (add-hook 'bat-mode-hook 'vip-mode) | ||
| 5510 | 5633 | ||
| 5511 | (defvar text-mode-hook) | 5634 | (defvar text-mode-hook) |
| 5512 | (add-hook 'text-mode-hook 'viper-mode) | 5635 | (add-hook 'text-mode-hook 'viper-mode) |
| @@ -5567,6 +5690,21 @@ Mail anyway (y or n)? ") | |||
| 5567 | 'comint-mode 'insert-state vip-comint-mode-modifier-map) | 5690 | 'comint-mode 'insert-state vip-comint-mode-modifier-map) |
| 5568 | (vip-modify-major-mode | 5691 | (vip-modify-major-mode |
| 5569 | 'comint-mode 'vi-state vip-comint-mode-modifier-map) | 5692 | 'comint-mode 'vi-state vip-comint-mode-modifier-map) |
| 5693 | (vip-modify-major-mode | ||
| 5694 | 'shell-mode 'insert-state vip-comint-mode-modifier-map) | ||
| 5695 | (vip-modify-major-mode | ||
| 5696 | 'shell-mode 'vi-state vip-comint-mode-modifier-map) | ||
| 5697 | ;; ange-ftp in XEmacs | ||
| 5698 | (vip-modify-major-mode | ||
| 5699 | 'ange-ftp-shell-mode 'insert-state vip-comint-mode-modifier-map) | ||
| 5700 | (vip-modify-major-mode | ||
| 5701 | 'ange-ftp-shell-mode 'vi-state vip-comint-mode-modifier-map) | ||
| 5702 | ;; ange-ftp in Emacs | ||
| 5703 | (vip-modify-major-mode | ||
| 5704 | 'internal-ange-ftp-mode 'insert-state vip-comint-mode-modifier-map) | ||
| 5705 | (vip-modify-major-mode | ||
| 5706 | 'internal-ange-ftp-mode 'vi-state vip-comint-mode-modifier-map) | ||
| 5707 | ;; set hook | ||
| 5570 | (add-hook 'comint-mode-hook 'vip-comint-mode-hook) | 5708 | (add-hook 'comint-mode-hook 'vip-comint-mode-hook) |
| 5571 | 5709 | ||
| 5572 | ;; Shell scripts | 5710 | ;; Shell scripts |
| @@ -5577,18 +5715,26 @@ Mail anyway (y or n)? ") | |||
| 5577 | 5715 | ||
| 5578 | ;; Dired | 5716 | ;; Dired |
| 5579 | (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map) | 5717 | (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map) |
| 5718 | (vip-set-emacs-search-style-macros nil 'dired-mode) | ||
| 5580 | (add-hook 'dired-mode-hook 'vip-change-state-to-emacs) | 5719 | (add-hook 'dired-mode-hook 'vip-change-state-to-emacs) |
| 5581 | 5720 | ||
| 5721 | ;; Tar | ||
| 5722 | (vip-modify-major-mode 'tar-mode 'emacs-state vip-slash-and-colon-map) | ||
| 5723 | (vip-set-emacs-search-style-macros nil 'tar-mode) | ||
| 5724 | |||
| 5582 | ;; MH-E | 5725 | ;; MH-E |
| 5583 | (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map) | 5726 | (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map) |
| 5727 | (vip-set-emacs-search-style-macros nil 'mh-folder-mode) | ||
| 5584 | ;; changing state to emacs is needed so the preceding will take hold | 5728 | ;; changing state to emacs is needed so the preceding will take hold |
| 5585 | (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs) | 5729 | (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs) |
| 5586 | (add-hook 'mh-show-mode-hook 'viper-mode) | 5730 | (add-hook 'mh-show-mode-hook 'viper-mode) |
| 5587 | 5731 | ||
| 5588 | ;; Gnus | 5732 | ;; Gnus |
| 5589 | (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map) | 5733 | (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map) |
| 5734 | (vip-set-emacs-search-style-macros nil 'gnus-group-mode) | ||
| 5590 | (vip-modify-major-mode | 5735 | (vip-modify-major-mode |
| 5591 | 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map) | 5736 | 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map) |
| 5737 | (vip-set-emacs-search-style-macros nil 'gnus-summary-mode) | ||
| 5592 | ;; changing state to emacs is needed so the preceding will take hold | 5738 | ;; changing state to emacs is needed so the preceding will take hold |
| 5593 | (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs) | 5739 | (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs) |
| 5594 | (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs) | 5740 | (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs) |
| @@ -5596,6 +5742,7 @@ Mail anyway (y or n)? ") | |||
| 5596 | 5742 | ||
| 5597 | ;; Info | 5743 | ;; Info |
| 5598 | (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map) | 5744 | (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map) |
| 5745 | (vip-set-emacs-search-style-macros nil 'Info-mode) | ||
| 5599 | ;; Switching to emacs is needed so the above will take hold | 5746 | ;; Switching to emacs is needed so the above will take hold |
| 5600 | (defadvice Info-mode (after vip-Info-ad activate) | 5747 | (defadvice Info-mode (after vip-Info-ad activate) |
| 5601 | "Switch to emacs mode." | 5748 | "Switch to emacs mode." |
| @@ -5604,6 +5751,7 @@ Mail anyway (y or n)? ") | |||
| 5604 | ;; Buffer menu | 5751 | ;; Buffer menu |
| 5605 | (vip-modify-major-mode | 5752 | (vip-modify-major-mode |
| 5606 | 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map) | 5753 | 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map) |
| 5754 | (vip-set-emacs-search-style-macros nil 'Buffer-menu-mode) | ||
| 5607 | ;; Switching to emacs is needed so the above will take hold | 5755 | ;; Switching to emacs is needed so the above will take hold |
| 5608 | (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate) | 5756 | (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate) |
| 5609 | "Switch to emacs mode." | 5757 | "Switch to emacs mode." |
| @@ -5652,14 +5800,8 @@ Mail anyway (y or n)? ") | |||
| 5652 | (vector vip-repeat-from-history-key '\2) 'vi-state | 5800 | (vector vip-repeat-from-history-key '\2) 'vi-state |
| 5653 | [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) | 5801 | [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) |
| 5654 | 5802 | ||
| 5655 | ;; toggle case sensitivity in search | 5803 | ;; set the toggle case sensitivity and regexp search macros |
| 5656 | (vip-record-kbd-macro | 5804 | (vip-set-vi-search-style-macros nil) |
| 5657 | "//" 'vi-state | ||
| 5658 | [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) | ||
| 5659 | ;; toggle regexp/vanila search | ||
| 5660 | (vip-record-kbd-macro | ||
| 5661 | "///" 'vi-state | ||
| 5662 | [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) | ||
| 5663 | 5805 | ||
| 5664 | 5806 | ||
| 5665 | ;; ~/.vip is loaded if it exists | 5807 | ;; ~/.vip is loaded if it exists |