diff options
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/isearch.el | 38 |
2 files changed, 23 insertions, 17 deletions
| @@ -1458,6 +1458,8 @@ commands repeat the search for the specified occurrence of the search string. | |||
| 1458 | A negative argument repeats the search in the opposite direction. | 1458 | A negative argument repeats the search in the opposite direction. |
| 1459 | This makes possible also to use a prefix argument for 'M-s .' | 1459 | This 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. |
| 1461 | Also 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 |
| 1463 | is possible now with new commands 'isearch-beginning-of-buffer' and | 1465 | is 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) | 2557 | If 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) | 2563 | If 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. |
| 2572 | Interactively, prompt for CHAR. | 2575 | Interactively, prompt for CHAR. |
| 2576 | If optional ARG is non-nil, pull until next ARGth instance of CHAR. | ||
| 2573 | This is often useful for keyboard macros, for example in programming | 2577 | This is often useful for keyboard macros, for example in programming |
| 2574 | languages or markup languages in which CHAR marks a token boundary." | 2578 | languages 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) |