[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
isearch-yank-word-at-point (was Re: Key map translations)
From: |
Christoph Scholtes |
Subject: |
isearch-yank-word-at-point (was Re: Key map translations) |
Date: |
Wed, 13 Apr 2011 17:06:01 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
On 4/13/2011 1:07 AM, Deniz Dogan wrote:
This is something I've been wanting for a long time but never really
realized it. Is there really nothing similar in isearch already? Maybe
we could add it?
I reworked my function a little and the interface is slightly different.
You press `C-s' to enter isearch mode and then `C-a' to select the
entire word at point, much like `C-w' would select the word from point
on. `Word' is in this case defined as a sequence of word and symbol
constituents.
Here is the code:
(defun isearch-yank-word-at-point ()
"Pull word at point into the search string."
(interactive)
;; Only yank if point is on a word constituent or
;; symbol constituent per the syntax table.
(when (or (= (char-syntax (or (char-after) 0)) ?w)
(= (char-syntax (or (char-after) 0)) ?_))
;; If part of the string has been yanked to the search string
;; already, unwind the isearch state stack to the beginning to
;; start over.
(while (not (string= isearch-string ""))
(isearch-pop-state))
;; Go to beginning of word at point
(skip-syntax-backward "w_")
;; and yank entire word into search string.
(isearch-yank-internal
(lambda ()
(skip-syntax-forward "w_")
(point)))))
I bind the command as follows:
(define-key isearch-mode-map (kbd "C-a") 'isearch-yank-word-at-point)
Feedback welcome. I would be happy to add this to isearch.el if people
find it useful.
Christoph
- Key map translations, Christoph Scholtes, 2011/04/11
- Re: Key map translations, Sean Sieger, 2011/04/11
- Re: Key map translations, Christoph Scholtes, 2011/04/12
- Re: Key map translations, Sean Sieger, 2011/04/12
- Re: Key map translations, Christoph Scholtes, 2011/04/12
- Re: Key map translations, Deniz Dogan, 2011/04/13
- isearch-yank-word-at-point (was Re: Key map translations),
Christoph Scholtes <=
- Re: isearch-yank-word-at-point (was Re: Key map translations), Deniz Dogan, 2011/04/14
- Re: isearch-yank-word-at-point (was Re: Key map translations), Jambunathan K, 2011/04/27
- RE: isearch-yank-word-at-point (was Re: Key map translations), Drew Adams, 2011/04/27
Re: Key map translations, Lennart Borgman, 2011/04/12