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 | |
| 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.
| -rw-r--r-- | doc/emacs/search.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/isearch.el | 23 |
3 files changed, 37 insertions, 1 deletions
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 66af5d40162..38ef49ed64d 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi | |||
| @@ -262,11 +262,19 @@ of whether to copy a character or a symbol is heuristic.) | |||
| 262 | 262 | ||
| 263 | @kindex M-s C-e @r{(Incremental search)} | 263 | @kindex M-s C-e @r{(Incremental search)} |
| 264 | @findex isearch-yank-line | 264 | @findex isearch-yank-line |
| 265 | Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest | 265 | @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest |
| 266 | of the current line to the search string. If point is already at the | 266 | of the current line to the search string. If point is already at the |
| 267 | end of a line, it appends the next line. With a prefix argument | 267 | end of a line, it appends the next line. With a prefix argument |
| 268 | @var{n}, it appends the next @var{n} lines. | 268 | @var{n}, it appends the next @var{n} lines. |
| 269 | 269 | ||
| 270 | @kindex C-M-z @r{(Incremental search)} | ||
| 271 | @findex isearch-yank-until-char | ||
| 272 | Similarly, @kbd{C-M-z} (@code{isearch-yank-until-char}) appends to | ||
| 273 | the search string everything from point until the next occurence of | ||
| 274 | a specified character (not including that character). This is especially | ||
| 275 | useful for keyboard macros, for example in programming languages or | ||
| 276 | markup languages in which that character marks a token boundary. | ||
| 277 | |||
| 270 | @kindex C-y @r{(Incremental search)} | 278 | @kindex C-y @r{(Incremental search)} |
| 271 | @kindex M-y @r{(Incremental search)} | 279 | @kindex M-y @r{(Incremental search)} |
| 272 | @kindex mouse-2 @r{in the minibuffer (Incremental search)} | 280 | @kindex mouse-2 @r{in the minibuffer (Incremental search)} |
| @@ -1255,6 +1255,11 @@ highlight in one iteration while processing the full buffer. | |||
| 1255 | +++ | 1255 | +++ |
| 1256 | *** New isearch bindings. | 1256 | *** New isearch bindings. |
| 1257 | 1257 | ||
| 1258 | 'C-M-z' invokes new function 'isearch-yank-until-char', which yanks | ||
| 1259 | everything from point up to but not including the specified | ||
| 1260 | character into the search string. This is especially useful for | ||
| 1261 | keyboard macros. | ||
| 1262 | |||
| 1258 | 'C-M-w' in isearch changed from 'isearch-del-char' to the new function | 1263 | 'C-M-w' in isearch changed from 'isearch-del-char' to the new function |
| 1259 | 'isearch-yank-symbol-or-char'. 'isearch-del-char' is now bound to | 1264 | 'isearch-yank-symbol-or-char'. 'isearch-del-char' is now bound to |
| 1260 | 'C-M-d'. | 1265 | 'C-M-d'. |
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." |