Commit fbcfee3a authored by Juri Linkov's avatar Juri Linkov

Add prefix arg to more isearch commands (bug#14563)

* lisp/isearch.el (isearch--yank-char-or-syntax)
(isearch-yank-word-or-char, isearch-yank-symbol-or-char)
(isearch-yank-until-char): Add optional prefix arg.
parent e4f49e87
Pipeline #3944 failed with stage
in 90 minutes
...@@ -1458,6 +1458,8 @@ commands repeat the search for the specified occurrence of the search string. ...@@ -1458,6 +1458,8 @@ commands repeat the search for the specified occurrence of the search string.
A negative argument repeats the search in the opposite direction. A negative argument repeats the search in the opposite direction.
This makes possible also to use a prefix argument for 'M-s .' This makes possible also to use a prefix argument for 'M-s .'
('isearch-forward-symbol-at-point') to find the next Nth symbol. ('isearch-forward-symbol-at-point') to find the next Nth symbol.
Also a prefix argument is supported for 'isearch-yank-until-char',
'isearch-yank-word-or-char', 'isearch-yank-symbol-or-char'.
*** To go to the first/last occurrence of the current search string *** To go to the first/last occurrence of the current search string
is possible now with new commands 'isearch-beginning-of-buffer' and is possible now with new commands 'isearch-beginning-of-buffer' and
......
...@@ -2541,25 +2541,28 @@ If optional ARG is non-nil, pull in the next ARG characters." ...@@ -2541,25 +2541,28 @@ If optional ARG is non-nil, pull in the next ARG characters."
(interactive "p") (interactive "p")
(isearch-yank-internal (lambda () (forward-char arg) (point)))) (isearch-yank-internal (lambda () (forward-char arg) (point))))
(defun isearch--yank-char-or-syntax (syntax-list fn) (defun isearch--yank-char-or-syntax (syntax-list fn &optional arg)
(isearch-yank-internal (isearch-yank-internal
(lambda () (lambda ()
(if (or (memq (char-syntax (or (char-after) 0)) syntax-list) (dotimes (_ arg)
(memq (char-syntax (or (char-after (1+ (point))) 0)) (if (or (memq (char-syntax (or (char-after) 0)) syntax-list)
syntax-list)) (memq (char-syntax (or (char-after (1+ (point))) 0))
(funcall fn 1) syntax-list))
(forward-char 1)) (funcall fn 1)
(forward-char 1)))
(point)))) (point))))
(defun isearch-yank-word-or-char () (defun isearch-yank-word-or-char (&optional arg)
"Pull next character or word from buffer into search string." "Pull next character or word from buffer into search string.
(interactive) If optional ARG is non-nil, pull in the next ARG characters/words."
(isearch--yank-char-or-syntax '(?w) 'forward-word)) (interactive "p")
(isearch--yank-char-or-syntax '(?w) 'forward-word arg))
(defun isearch-yank-symbol-or-char () (defun isearch-yank-symbol-or-char (&optional arg)
"Pull next character or symbol from buffer into search string." "Pull next character or symbol from buffer into search string.
(interactive) If optional ARG is non-nil, pull in the next ARG characters/symbols."
(isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol)) (interactive "p")
(isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol arg))
(defun isearch-yank-word (&optional arg) (defun isearch-yank-word (&optional arg)
"Pull next word from buffer into search string. "Pull next word from buffer into search string.
...@@ -2567,17 +2570,18 @@ If optional ARG is non-nil, pull in the next ARG words." ...@@ -2567,17 +2570,18 @@ If optional ARG is non-nil, pull in the next ARG words."
(interactive "p") (interactive "p")
(isearch-yank-internal (lambda () (forward-word arg) (point)))) (isearch-yank-internal (lambda () (forward-word arg) (point))))
(defun isearch-yank-until-char (char) (defun isearch-yank-until-char (char &optional arg)
"Pull everything until next instance of CHAR from buffer into search string. "Pull everything until next instance of CHAR from buffer into search string.
Interactively, prompt for CHAR. Interactively, prompt for CHAR.
If optional ARG is non-nil, pull until next ARGth instance of CHAR.
This is often useful for keyboard macros, for example in programming This is often useful for keyboard macros, for example in programming
languages or markup languages in which CHAR marks a token boundary." languages or markup languages in which CHAR marks a token boundary."
(interactive "cYank until character: ") (interactive "cYank until character: \np")
(isearch-yank-internal (isearch-yank-internal
(lambda () (let ((inhibit-field-text-motion t)) (lambda () (let ((inhibit-field-text-motion t))
(condition-case nil (condition-case nil
(progn (progn
(search-forward (char-to-string char)) (search-forward (char-to-string char) nil nil arg)
(forward-char -1)) (forward-char -1))
(search-failed (search-failed
(message "`%c' not found" char) (message "`%c' not found" char)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment