From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
To: Christoph Scholtes <cschol2112@googlemail.com>
Cc: emacs-devel@gnu.org
Subject: Re: isearch-yank-word-at-point (was Re: Key map translations)
Date: Thu, 14 Apr 2011 07:21:01 +0200 [thread overview]
Message-ID: <BANLkTinK_COBE=RFZse4GrDx5skVzo_COQ@mail.gmail.com> (raw)
In-Reply-To: <4DA62C59.4040707@gmail.com>
2011/4/14 Christoph Scholtes <cschol2112@googlemail.com>:
> 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
next prev parent reply other threads:[~2011-04-14 5:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-12 1:32 Key map translations Christoph Scholtes
2011-04-12 3:35 ` Sean Sieger
2011-04-13 1:59 ` Christoph Scholtes
2011-04-13 2:53 ` Sean Sieger
2011-04-13 3:16 ` Christoph Scholtes
2011-04-13 7:07 ` Deniz Dogan
2011-04-13 23:06 ` isearch-yank-word-at-point (was Re: Key map translations) Christoph Scholtes
2011-04-14 5:21 ` Deniz Dogan [this message]
2011-04-27 17:35 ` Jambunathan K
2011-04-27 17:45 ` Drew Adams
2011-04-12 8:18 ` Key map translations Lennart Borgman
2011-04-13 1:59 ` Christoph Scholtes
2011-04-15 1:35 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTinK_COBE=RFZse4GrDx5skVzo_COQ@mail.gmail.com' \
--to=deniz.a.m.dogan@gmail.com \
--cc=cschol2112@googlemail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.