[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isearch-yank-word-at-point (was Re: Key map translations)
From: |
Jambunathan K |
Subject: |
Re: isearch-yank-word-at-point (was Re: Key map translations) |
Date: |
Wed, 27 Apr 2011 23:05:34 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) |
Christoph Scholtes <address@hidden> writes:
> 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.
I usually do C-s (C-w)+ while searching for symbols.
This is what I cooked up:
(define-key isearch-mode-map "\C-_" 'isearch-yank-symbol)
(defun isearch-yank-symbol ()
(interactive)
(isearch-yank-internal (lambda ()
(require 'thingatpt)
(forward-symbol 1) (point))))
I chose '_' (underscore) as it stands for symbols in much the same way
as 'w' stands for word.
Searching for symbols is something that I do often and I find it
convenient if some such functionality comes by default with emacs.
Jambunathan K.
--
- 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, 2011/04/13
- 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 <=
- 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