diff options
| author | Karl Fogel | 2019-09-12 12:42:13 -0500 |
|---|---|---|
| committer | Karl Fogel | 2019-09-12 12:42:13 -0500 |
| commit | bbadc6e05f4321466fe8bcd91df6b65fbc6c7d69 (patch) | |
| tree | 42c77b5950953710dfac1df2af9ea152192d0f76 /lisp | |
| parent | 5e8d477d63496ada8eb2c42d23735df0cf05ee2d (diff) | |
| download | emacs-bbadc6e05f4321466fe8bcd91df6b65fbc6c7d69.tar.gz emacs-bbadc6e05f4321466fe8bcd91df6b65fbc6c7d69.zip | |
Add `isearch-yank-until-char'
* lisp/isearch.el (isearch-yank-until-char): New function.
(isearch-mode-map, isearch-menu-bar-yank-map): Add it.
(isearch-forward): Document the new binding.
* doc/emacs/search.texi (Isearch Yanking): Document the feature.
* etc/NEWS: Mention the above.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/isearch.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 30f7fc7254c..9401e8c06d3 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -514,6 +514,9 @@ This is like `describe-bindings', but displays only Isearch keys." | |||
| 514 | (define-key map [isearch-yank-kill] | 514 | (define-key map [isearch-yank-kill] |
| 515 | '(menu-item "Current kill" isearch-yank-kill | 515 | '(menu-item "Current kill" isearch-yank-kill |
| 516 | :help "Append current kill to search string")) | 516 | :help "Append current kill to search string")) |
| 517 | (define-key map [isearch-yank-until-char] | ||
| 518 | '(menu-item "Until char..." isearch-yank-until-char | ||
| 519 | :help "Yank from point to specified character into search string")) | ||
| 517 | (define-key map [isearch-yank-line] | 520 | (define-key map [isearch-yank-line] |
| 518 | '(menu-item "Rest of line" isearch-yank-line | 521 | '(menu-item "Rest of line" isearch-yank-line |
| 519 | :help "Yank the rest of the current line on search string")) | 522 | :help "Yank the rest of the current line on search string")) |
| @@ -705,6 +708,7 @@ This is like `describe-bindings', but displays only Isearch keys." | |||
| 705 | (define-key map "\M-\C-d" 'isearch-del-char) | 708 | (define-key map "\M-\C-d" 'isearch-del-char) |
| 706 | (define-key map "\M-\C-y" 'isearch-yank-char) | 709 | (define-key map "\M-\C-y" 'isearch-yank-char) |
| 707 | (define-key map "\C-y" 'isearch-yank-kill) | 710 | (define-key map "\C-y" 'isearch-yank-kill) |
| 711 | (define-key map "\M-\C-z" 'isearch-yank-until-char) | ||
| 708 | (define-key map "\M-s\C-e" 'isearch-yank-line) | 712 | (define-key map "\M-s\C-e" 'isearch-yank-line) |
| 709 | 713 | ||
| 710 | (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer) | 714 | (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer) |
| @@ -998,6 +1002,8 @@ Type \\[isearch-yank-word-or-char] to yank next word or character in buffer | |||
| 998 | Type \\[isearch-del-char] to delete character from end of search string. | 1002 | Type \\[isearch-del-char] to delete character from end of search string. |
| 999 | Type \\[isearch-yank-char] to yank char from buffer onto end of search\ | 1003 | Type \\[isearch-yank-char] to yank char from buffer onto end of search\ |
| 1000 | string and search for it. | 1004 | string and search for it. |
| 1005 | Type \\[isearch-yank-until-char] to yank from point until the next instance of a | ||
| 1006 | specified character onto end of search string and search for it. | ||
| 1001 | Type \\[isearch-yank-line] to yank rest of line onto end of search string\ | 1007 | Type \\[isearch-yank-line] to yank rest of line onto end of search string\ |
| 1002 | and search for it. | 1008 | and search for it. |
| 1003 | Type \\[isearch-yank-kill] to yank the last string of killed text. | 1009 | Type \\[isearch-yank-kill] to yank the last string of killed text. |
| @@ -2562,6 +2568,23 @@ If optional ARG is non-nil, pull in the next ARG words." | |||
| 2562 | (interactive "p") | 2568 | (interactive "p") |
| 2563 | (isearch-yank-internal (lambda () (forward-word arg) (point)))) | 2569 | (isearch-yank-internal (lambda () (forward-word arg) (point)))) |
| 2564 | 2570 | ||
| 2571 | (defun isearch-yank-until-char (char) | ||
| 2572 | "Pull everything until next instance of CHAR from buffer into search string. | ||
| 2573 | Interactively, prompt for CHAR. | ||
| 2574 | This is often useful for keyboard macros, for example in programming | ||
| 2575 | languages or markup languages in which CHAR marks a token boundary." | ||
| 2576 | (interactive "cYank until character: ") | ||
| 2577 | (isearch-yank-internal | ||
| 2578 | (lambda () (let ((inhibit-field-text-motion t)) | ||
| 2579 | (condition-case nil | ||
| 2580 | (progn | ||
| 2581 | (search-forward (char-to-string char)) | ||
| 2582 | (forward-char -1)) | ||
| 2583 | (search-failed | ||
| 2584 | (message "`%c' not found" char) | ||
| 2585 | (sit-for 2))) | ||
| 2586 | (point))))) | ||
| 2587 | |||
| 2565 | (defun isearch-yank-line (&optional arg) | 2588 | (defun isearch-yank-line (&optional arg) |
| 2566 | "Pull rest of line from buffer into search string. | 2589 | "Pull rest of line from buffer into search string. |
| 2567 | If optional ARG is non-nil, yank the next ARG lines." | 2590 | If optional ARG is non-nil, yank the next ARG lines." |