aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation/viper-cmd.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emulation/viper-cmd.el')
-rw-r--r--lisp/emulation/viper-cmd.el78
1 files changed, 49 insertions, 29 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index eb5e5ede4c7..8023336b18b 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1063,7 +1063,7 @@ as a Meta key and any number of multiple escapes is allowed."
1063 1063
1064 ;; call the actual function to execute ESC (if no other symbols followed) 1064 ;; call the actual function to execute ESC (if no other symbols followed)
1065 ;; or the key bound to the ESC sequence (if the sequence was issued 1065 ;; or the key bound to the ESC sequence (if the sequence was issued
1066 ;; with very short delay between characters. 1066 ;; with very short delay between characters).
1067 (if (eq cmd 'viper-intercept-ESC-key) 1067 (if (eq cmd 'viper-intercept-ESC-key)
1068 (setq cmd 1068 (setq cmd
1069 (cond ((eq viper-current-state 'vi-state) 1069 (cond ((eq viper-current-state 'vi-state)
@@ -1529,7 +1529,8 @@ as a Meta key and any number of multiple escapes is allowed."
1529 nil) 1529 nil)
1530 1530
1531(defun viper-exec-buffer-search (m-com com) 1531(defun viper-exec-buffer-search (m-com com)
1532 (setq viper-s-string (buffer-substring (point) viper-com-point)) 1532 (setq viper-s-string
1533 (regexp-quote (buffer-substring (point) viper-com-point)))
1533 (setq viper-s-forward t) 1534 (setq viper-s-forward t)
1534 (setq viper-search-history (cons viper-s-string viper-search-history)) 1535 (setq viper-search-history (cons viper-s-string viper-search-history))
1535 (setq viper-intermediate-command 'viper-exec-buffer-search) 1536 (setq viper-intermediate-command 'viper-exec-buffer-search)
@@ -1982,6 +1983,16 @@ Undo previous insertion and inserts new."
1982 (let ((hook (if viper-vi-style-in-minibuffer 1983 (let ((hook (if viper-vi-style-in-minibuffer
1983 'viper-change-state-to-insert 1984 'viper-change-state-to-insert
1984 'viper-change-state-to-emacs))) 1985 'viper-change-state-to-emacs)))
1986 ;; making buffer-local variables so that normal buffers won't affect the
1987 ;; minibuffer and vice versa. Otherwise, command arguments will affect
1988 ;; minibuffer ops and insertions from the minibuffer will change those in
1989 ;; the normal buffers
1990 (make-local-variable 'viper-d-com)
1991 (make-local-variable 'viper-last-insertion)
1992 (make-local-variable 'viper-command-ring)
1993 (setq viper-d-com nil
1994 viper-last-insertion nil
1995 viper-command-ring nil)
1985 (funcall hook) 1996 (funcall hook)
1986 )) 1997 ))
1987 1998
@@ -2707,7 +2718,7 @@ On reaching beginning of line, stop and signal error."
2707 (viper-backward-char-carefully) 2718 (viper-backward-char-carefully)
2708 (if (looking-at "\n") 2719 (if (looking-at "\n")
2709 (viper-skip-all-separators-backward 'within-line) 2720 (viper-skip-all-separators-backward 'within-line)
2710 (or (bobp) (forward-char))))) 2721 (or (viper-looking-at-separator) (forward-char)))))
2711 2722
2712 2723
2713(defun viper-forward-word-kernel (val) 2724(defun viper-forward-word-kernel (val)
@@ -3630,33 +3641,39 @@ the Emacs binding of `/'."
3630 (setq msg "Search style remains unchanged"))) 3641 (setq msg "Search style remains unchanged")))
3631 (princ msg t))) 3642 (princ msg t)))
3632 3643
3633(defun viper-set-searchstyle-toggling-macros (unset) 3644(defun viper-set-searchstyle-toggling-macros (unset &optional major-mode)
3634 "Set the macros for toggling the search style in Viper's vi-state. 3645 "Set the macros for toggling the search style in Viper's vi-state.
3635The macro that toggles case sensitivity is bound to `//', and the one that 3646The macro that toggles case sensitivity is bound to `//', and the one that
3636toggles regexp search is bound to `///'. 3647toggles regexp search is bound to `///'.
3637With a prefix argument, this function unsets the macros. " 3648With a prefix argument, this function unsets the macros.
3649If MAJOR-MODE is set, set the macros only in that major mode."
3638 (interactive "P") 3650 (interactive "P")
3639 (or noninteractive 3651 (let (scope)
3640 (if (not unset) 3652 (if (and major-mode (symbolp major-mode))
3641 (progn 3653 (setq scope major-mode)
3642 ;; toggle case sensitivity in search 3654 (setq scope 't))
3643 (viper-record-kbd-macro 3655 (or noninteractive
3644 "//" 'vi-state 3656 (if (not unset)
3645 [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] 3657 (progn
3646 't) 3658 ;; toggle case sensitivity in search
3647 ;; toggle regexp/vanila search 3659 (viper-record-kbd-macro
3648 (viper-record-kbd-macro 3660 "//" 'vi-state
3649 "///" 'vi-state 3661 [1 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
3650 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] 3662 scope)
3651 't) 3663 ;; toggle regexp/vanila search
3652 (if (interactive-p) 3664 (viper-record-kbd-macro
3653 (message 3665 "///" 'vi-state
3654 "// and /// now toggle case-sensitivity and regexp search"))) 3666 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
3655 (viper-unrecord-kbd-macro "//" 'vi-state) 3667 scope)
3656 (sit-for 2) 3668 (if (interactive-p)
3657 (viper-unrecord-kbd-macro "///" 'vi-state)))) 3669 (message
3658 3670 "// and /// now toggle case-sensitivity and regexp search")))
3659 3671 (viper-unrecord-kbd-macro "//" 'vi-state)
3672 (sit-for 2)
3673 (viper-unrecord-kbd-macro "///" 'vi-state)))
3674 ))
3675
3676
3660(defun viper-set-parsing-style-toggling-macro (unset) 3677(defun viper-set-parsing-style-toggling-macro (unset)
3661 "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses. 3678 "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses.
3662This is used in conjunction with the `%' command. 3679This is used in conjunction with the `%' command.
@@ -4112,7 +4129,8 @@ Null string will repeat previous search."
4112 (interactive) 4129 (interactive)
4113 (if (and viper-ex-style-editing (bolp)) 4130 (if (and viper-ex-style-editing (bolp))
4114 (beep 1) 4131 (beep 1)
4115 (delete-backward-char 1 t))) 4132 ;; don't put on kill ring
4133 (delete-backward-char 1 nil)))
4116 4134
4117 4135
4118(defun viper-del-backward-char-in-replace () 4136(defun viper-del-backward-char-in-replace ()
@@ -4124,13 +4142,15 @@ cursor move past the beginning of line."
4124 (interactive) 4142 (interactive)
4125 (cond (viper-delete-backwards-in-replace 4143 (cond (viper-delete-backwards-in-replace
4126 (cond ((not (bolp)) 4144 (cond ((not (bolp))
4127 (delete-backward-char 1 t)) 4145 ;; don't put on kill ring
4146 (delete-backward-char 1 nil))
4128 (viper-ex-style-editing 4147 (viper-ex-style-editing
4129 (beep 1)) 4148 (beep 1))
4130 ((bobp) 4149 ((bobp)
4131 (beep 1)) 4150 (beep 1))
4132 (t 4151 (t
4133 (delete-backward-char 1 t)))) 4152 ;; don't put on kill ring
4153 (delete-backward-char 1 nil))))
4134 (viper-ex-style-editing 4154 (viper-ex-style-editing
4135 (if (bolp) 4155 (if (bolp)
4136 (beep 1) 4156 (beep 1)