[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: Deniz Dogan
Subject: Re: isearch-yank-word-at-point (was Re: Key map translations)
Date: Thu, 14 Apr 2011 07:21:01 +0200

2011/4/14 Christoph Scholtes <address@hidden>:
> 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

I think it looks pretty good.  However, I'd like it to do something
useful when standing on non-word/symbol constituent characters such as
(. I'd also like to be able to C-a C-a to search for the current word
and the following word.

Thoughts on this?

Deniz Dogan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]