aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-11-06 01:35:47 +0200
committerJuri Linkov2019-11-06 01:35:47 +0200
commitfbcfee3ae492922abc34e62381354c7d8b989fea (patch)
tree1ae27d2253e9acaf1a652106954eee025f40869c
parente4f49e87e7251511d9613899d7041ed4626dc28e (diff)
downloademacs-fbcfee3ae492922abc34e62381354c7d8b989fea.tar.gz
emacs-fbcfee3ae492922abc34e62381354c7d8b989fea.zip
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.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/isearch.el38
2 files changed, 23 insertions, 17 deletions
diff --git a/etc/NEWS b/etc/NEWS
index db3434f55b0..a5b9dbdebd0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1458,6 +1458,8 @@ commands repeat the search for the specified occurrence of the search string.
1458A negative argument repeats the search in the opposite direction. 1458A negative argument repeats the search in the opposite direction.
1459This makes possible also to use a prefix argument for 'M-s .' 1459This makes possible also to use a prefix argument for 'M-s .'
1460('isearch-forward-symbol-at-point') to find the next Nth symbol. 1460('isearch-forward-symbol-at-point') to find the next Nth symbol.
1461Also a prefix argument is supported for 'isearch-yank-until-char',
1462'isearch-yank-word-or-char', 'isearch-yank-symbol-or-char'.
1461 1463
1462*** To go to the first/last occurrence of the current search string 1464*** To go to the first/last occurrence of the current search string
1463is possible now with new commands 'isearch-beginning-of-buffer' and 1465is possible now with new commands 'isearch-beginning-of-buffer' and
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 1e4a87ff481..a46f4fc3eee 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2541,25 +2541,28 @@ If optional ARG is non-nil, pull in the next ARG characters."
2541 (interactive "p") 2541 (interactive "p")
2542 (isearch-yank-internal (lambda () (forward-char arg) (point)))) 2542 (isearch-yank-internal (lambda () (forward-char arg) (point))))
2543 2543
2544(defun isearch--yank-char-or-syntax (syntax-list fn) 2544(defun isearch--yank-char-or-syntax (syntax-list fn &optional arg)
2545 (isearch-yank-internal 2545 (isearch-yank-internal
2546 (lambda () 2546 (lambda ()
2547 (if (or (memq (char-syntax (or (char-after) 0)) syntax-list) 2547 (dotimes (_ arg)
2548 (memq (char-syntax (or (char-after (1+ (point))) 0)) 2548 (if (or (memq (char-syntax (or (char-after) 0)) syntax-list)
2549 syntax-list)) 2549 (memq (char-syntax (or (char-after (1+ (point))) 0))
2550 (funcall fn 1) 2550 syntax-list))
2551 (forward-char 1)) 2551 (funcall fn 1)
2552 (forward-char 1)))
2552 (point)))) 2553 (point))))
2553 2554
2554(defun isearch-yank-word-or-char () 2555(defun isearch-yank-word-or-char (&optional arg)
2555 "Pull next character or word from buffer into search string." 2556 "Pull next character or word from buffer into search string.
2556 (interactive) 2557If optional ARG is non-nil, pull in the next ARG characters/words."
2557 (isearch--yank-char-or-syntax '(?w) 'forward-word)) 2558 (interactive "p")
2559 (isearch--yank-char-or-syntax '(?w) 'forward-word arg))
2558 2560
2559(defun isearch-yank-symbol-or-char () 2561(defun isearch-yank-symbol-or-char (&optional arg)
2560 "Pull next character or symbol from buffer into search string." 2562 "Pull next character or symbol from buffer into search string.
2561 (interactive) 2563If optional ARG is non-nil, pull in the next ARG characters/symbols."
2562 (isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol)) 2564 (interactive "p")
2565 (isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol arg))
2563 2566
2564(defun isearch-yank-word (&optional arg) 2567(defun isearch-yank-word (&optional arg)
2565 "Pull next word from buffer into search string. 2568 "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 (interactive "p") 2570 (interactive "p")
2568 (isearch-yank-internal (lambda () (forward-word arg) (point)))) 2571 (isearch-yank-internal (lambda () (forward-word arg) (point))))
2569 2572
2570(defun isearch-yank-until-char (char) 2573(defun isearch-yank-until-char (char &optional arg)
2571 "Pull everything until next instance of CHAR from buffer into search string. 2574 "Pull everything until next instance of CHAR from buffer into search string.
2572Interactively, prompt for CHAR. 2575Interactively, prompt for CHAR.
2576If optional ARG is non-nil, pull until next ARGth instance of CHAR.
2573This is often useful for keyboard macros, for example in programming 2577This is often useful for keyboard macros, for example in programming
2574languages or markup languages in which CHAR marks a token boundary." 2578languages or markup languages in which CHAR marks a token boundary."
2575 (interactive "cYank until character: ") 2579 (interactive "cYank until character: \np")
2576 (isearch-yank-internal 2580 (isearch-yank-internal
2577 (lambda () (let ((inhibit-field-text-motion t)) 2581 (lambda () (let ((inhibit-field-text-motion t))
2578 (condition-case nil 2582 (condition-case nil
2579 (progn 2583 (progn
2580 (search-forward (char-to-string char)) 2584 (search-forward (char-to-string char) nil nil arg)
2581 (forward-char -1)) 2585 (forward-char -1))
2582 (search-failed 2586 (search-failed
2583 (message "`%c' not found" char) 2587 (message "`%c' not found" char)