From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: symbols verses words Date: Thu, 03 Mar 2011 11:19:57 +0100 Message-ID: <87ei6opktu.fsf@member.fsf.org> References: <06BF1211-A1CA-4E57-ADF4-8C89EF6ACDE1@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299147912 15763 80.91.229.12 (3 Mar 2011 10:25:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 3 Mar 2011 10:25:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 03 11:25:05 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pv5f4-0001Yr-IW for geh-help-gnu-emacs@m.gmane.org; Thu, 03 Mar 2011 11:25:03 +0100 Original-Received: from localhost ([127.0.0.1]:50866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pv5eT-0006Ij-Fh for geh-help-gnu-emacs@m.gmane.org; Thu, 03 Mar 2011 05:20:57 -0500 Original-Received: from [140.186.70.92] (port=38372 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pv5dq-00064U-OB for help-gnu-emacs@gnu.org; Thu, 03 Mar 2011 05:20:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pv5dm-0008HP-10 for help-gnu-emacs@gnu.org; Thu, 03 Mar 2011 05:20:15 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pv5dl-0008Gb-PJ for help-gnu-emacs@gnu.org; Thu, 03 Mar 2011 05:20:13 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pv5di-0001Aq-Dj for help-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:20:10 +0100 Original-Received: from tsdh.uni-koblenz.de ([141.26.67.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Mar 2011 11:20:10 +0100 Original-Received: from tassilo by tsdh.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Mar 2011 11:20:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: tsdh.uni-koblenz.de User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:3/fqqXoNmeaf/9dcwUYGDANbb1k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79740 Archived-At: Perry Smith 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 \ but really it seems that I should be doing \_ > ... 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