to search for another occurrence of the text at point. (The decision
of whether to copy a character or a word is heuristic.)
+@kindex C-M-w @r{(Incremental search)}
+@findex isearch-yank-symbol-or-char
+ @kbd{C-M-w} (@code{isearch-yank-symbol-or-char}) appends the next
+character or symbol at point to the search string. This is an easy way
+to search for another occurrence of the symbol at point. (The decision
+of whether to copy a character or a word is heuristic.)
+
@kindex M-s C-e @r{(Incremental search)}
@findex isearch-yank-line
Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest
in the echo area appends the current X selection (@pxref{Primary
Selection}) to the search string (@code{isearch-yank-x-selection}).
-@kindex C-M-w @r{(Incremental search)}
+@kindex C-M-d @r{(Incremental search)}
@kindex C-M-y @r{(Incremental search)}
@findex isearch-del-char
@findex isearch-yank-char
- @kbd{C-M-w} (@code{isearch-del-char}) deletes the last character
+ @kbd{C-M-d} (@code{isearch-del-char}) deletes the last character
from the search string, and @kbd{C-M-y} (@code{isearch-yank-char})
appends the character after point to the search string. An
alternative method to add the character after point is to enter the
\f
* Editing Changes in Emacs 27.1
++++
+** New isearch bindings.
+'C-M-w' in isearch changed from isearch-del-char to the new function
+isearch-yank-symbol-or-char. isearch-del-char is now bound to 'C-M-d'.
+
---
** New variable 'x-wait-for-event-timeout'.
This controls how long Emacs will wait for updates to the graphical
(define-key map [?\S-\ ] 'isearch-printing-char)
(define-key map "\C-w" 'isearch-yank-word-or-char)
- (define-key map "\M-\C-w" 'isearch-del-char)
+ (define-key map "\M-\C-w" 'isearch-yank-symbol-or-char)
+ (define-key map "\M-\C-d" 'isearch-del-char)
(define-key map "\M-\C-y" 'isearch-yank-char)
(define-key map "\C-y" 'isearch-yank-kill)
(define-key map "\M-s\C-e" 'isearch-yank-line)
(interactive "p")
(isearch-yank-internal (lambda () (forward-char arg) (point))))
-(defun isearch-yank-word-or-char ()
- "Pull next character or word from buffer into search string."
- (interactive)
+(defun isearch--yank-char-or-syntax (syntax-list fn)
(isearch-yank-internal
(lambda ()
- (if (or (= (char-syntax (or (char-after) 0)) ?w)
- (= (char-syntax (or (char-after (1+ (point))) 0)) ?w))
- (forward-word 1)
+ (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-symbol-or-char ()
+ "Pull next character or word from buffer into search string."
+ (interactive)
+ (isearch--yank-char-or-syntax '(?w ?_) 'forward-symbol))
+
(defun isearch-yank-word (&optional arg)
"Pull next word from buffer into search string.
If optional ARG is non-nil, pull in the next ARG words."