From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: mac@die.spammer.die.dgp.toronto.edu (Maciej Kalisiak) Newsgroups: gmane.emacs.help Subject: Re: placing cursor at *start* of match in incremental search Date: 22 Jan 2003 14:41:32 GMT Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <3E2D7F8E.1050205@ihs.com> Reply-To: mac@dgp.toronto.edu NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1043247357 7367 80.91.224.249 (22 Jan 2003 14:55:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 22 Jan 2003 14:55:57 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18bMIE-0001uO-00 for ; Wed, 22 Jan 2003 15:55:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18bMHc-0000q7-09 for gnu-help-gnu-emacs@m.gmane.org; Wed, 22 Jan 2003 09:55:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!utnut!utcsri!not-for-mail Original-Newsgroups: gnu.emacs.help X-Nntp-Posting-Host: mac.laptop.dgp.toronto.edu User-Agent: slrn/0.9.7.4 (Linux) Original-Lines: 34 Original-Xref: shelby.stanford.edu gnu.emacs.help:109342 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5865 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5865 * Kevin Rodgers : > Maciej Kalisiak wrote: > > > * Greg Hill : > > > >> Put this in your .emacs: > >> > >> (add-hook 'isearch-mode-end-hook > >> (function (lambda () (goto-char (match-beginning 0))))) > >> > > > > Ah, perfect! Thanks. > > > > Is this approach better, or Adrian's method of using "advice"? (I have only > > limited elisp knowledge, and not much experience with advice functions) > > > I'm a big fan of defadvice, but I think it should only be used when there's > no other way to get the behavior you want. If there's a hook available, use > that; and better yet, if there's a user option, use that. Played around a bit with both approaches, and it seems the "defadvice" method is the better of the two, at least as presented so far. The probelm with the hook method, as shown above, is that it breaks the behaviour of an isearch abortion. Usually, on a C-g the cursor goes back to where it was when C-s was pressed; with the hook form above it is placed at the first character of the match... seems the hook is called on *all* methods of ending an isearch. OTOH, the defadvice form works properly. Can the hook form be somehow coaxed to do abortion properly? -- Maciej Kalisiak | | http://www.dgp.toronto.edu/~mac [McQ] PGP->finger|www; (0x39AC36F5) 9F BB 9E 11 F0 1E 5D 20 0B 31 3D 37 47 D0 67 C7