]> git.eshelyaron.com Git - emacs.git/commitdiff
Add prefix arg to more isearch commands (bug#14563)
authorJuri Linkov <juri@linkov.net>
Tue, 5 Nov 2019 23:35:47 +0000 (01:35 +0200)
committerJuri Linkov <juri@linkov.net>
Tue, 5 Nov 2019 23:35:47 +0000 (01:35 +0200)
* 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.

etc/NEWS
lisp/isearch.el

index db3434f55b0f8bd8565ca902d1b36aef176d4dd6..a5b9dbdebd02eb9be0ad4907044d6f66bb2acd6c 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
 This makes possible also to use a prefix argument for 'M-s .'
 ('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
 is possible now with new commands 'isearch-beginning-of-buffer' and
index 1e4a87ff4819a292699e025dae0296d1a37683b5..a46f4fc3eee66ff42654282235bf3e1624597cbc 100644 (file)
@@ -2541,25 +2541,28 @@ If optional ARG is non-nil, pull in the next ARG characters."
   (interactive "p")
   (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
    (lambda ()
-     (if (or (memq (char-syntax (or (char-after) 0)) syntax-list)
-             (memq (char-syntax (or (char-after (1+ (point))) 0))
-                   syntax-list))
-        (funcall fn 1)
-       (forward-char 1))
+     (dotimes (_ arg)
+       (if (or (memq (char-syntax (or (char-after) 0)) syntax-list)
+               (memq (char-syntax (or (char-after (1+ (point))) 0))
+                     syntax-list))
+          (funcall fn 1)
+         (forward-char 1)))
      (point))))
 
-(defun isearch-yank-word-or-char ()
-  "Pull next character or word from buffer into search string."
-  (interactive)
-  (isearch--yank-char-or-syntax '(?w) 'forward-word))
+(defun isearch-yank-word-or-char (&optional arg)
+  "Pull next character or word from buffer into search string.
+If optional ARG is non-nil, pull in the next ARG characters/words."
+  (interactive "p")
+  (isearch--yank-char-or-syntax '(?w) 'forward-word arg))
 
-(defun isearch-yank-symbol-or-char ()
-  "Pull next character or symbol from buffer into search string."
-  (interactive)
-  (isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol))
+(defun isearch-yank-symbol-or-char (&optional arg)
+  "Pull next character or symbol from buffer into search string.
+If optional ARG is non-nil, pull in the next ARG characters/symbols."
+  (interactive "p")
+  (isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol arg))
 
 (defun isearch-yank-word (&optional arg)
   "Pull next word from buffer into search string.
@@ -2567,17 +2570,18 @@ If optional ARG is non-nil, pull in the next ARG words."
   (interactive "p")
   (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.
 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
 languages or markup languages in which CHAR marks a token boundary."
-  (interactive "cYank until character: ")
+  (interactive "cYank until character: \np")
   (isearch-yank-internal
    (lambda () (let ((inhibit-field-text-motion t))
                 (condition-case nil
                     (progn
-                      (search-forward (char-to-string char))
+                      (search-forward (char-to-string char) nil nil arg)
                       (forward-char -1))
                   (search-failed
                    (message "`%c' not found" char)