help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symbols verses words


From: Andreas Röhler
Subject: Re: symbols verses words
Date: Fri, 04 Mar 2011 10:06:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6

Am 03.03.2011 11:19, schrieb Tassilo Horn:
Perry Smith<pedzsan@gmail.com>  writes:

Hi Perry,

I need some help understanding Emac's design.  I use a lot of "word"
constructs where I *think* I should be using symbol.  For example, if
I'm writing C code and I want to find foo but not foo_bar, I usually
do \<foo\>  but really it seems that I should be doing \_<foo\_>
... fine.  I can make that adjustment.  But when I do incremental
search, I often hit ^w to pull in the next word but what I really want
(often but not always) is to pull in the next symbol (into the search
string).  So if I'm sitting at this_that, I'd ilke to hit ^W (perhaps)
and pull in this_that instead of just this.

I think, something like that should do the trick:

--8<---------------cut here---------------start------------->8---
(defun isearch-yank-symbol-or-char ()
   "Pull next character or symbol from buffer into search string."
   (interactive)
   (isearch-yank-internal
    (lambda ()
      (if (or (memq (char-syntax (or (char-after) 0)) '(?w ?_))
              (memq (char-syntax (or (char-after (1+ (point))) 0)) '(?w ?_)))
          (forward-symbol 1)
        (forward-char 1))
      (point))))

(define-key isearch-mode-map (kbd "C-S-w") 'isearch-yank-symbol-or-char)
--8<---------------cut here---------------end--------------->8---

So when you are on a word constituent (?w) or on a symbol constituent
(?_), then do `forward-symbol', else `forward-char'.

Bye,
Tassilo




Hi Tassilo,

maybe I'm missing the point.

In the case given may just extend input

from `\w+' onto `\w+.\w'

(?)

Andreas



reply via email to

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