unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Christoph Scholtes <cschol2112@googlemail.com>
Cc: emacs-devel@gnu.org, Deniz Dogan <deniz.a.m.dogan@gmail.com>
Subject: Re: isearch-yank-word-at-point (was Re: Key map translations)
Date: Wed, 27 Apr 2011 23:05:34 +0530	[thread overview]
Message-ID: <81zknbegwp.fsf@gmail.com> (raw)
In-Reply-To: <4DA62C59.4040707@gmail.com> (Christoph Scholtes's message of "Wed, 13 Apr 2011 17:06:01 -0600")

Christoph Scholtes <cschol2112@googlemail.com> 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.
-- 



  parent reply	other threads:[~2011-04-27 17:35 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
2011-04-27 17:35             ` Jambunathan K [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81zknbegwp.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=cschol2112@googlemail.com \
    --cc=deniz.a.m.dogan@gmail.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).