From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel,gmane.emacs.help Subject: RE: isearch doesn't seem to set mark where search began Date: Sun, 3 Oct 2004 10:35:13 -0700 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1096824955 30100 80.91.229.6 (3 Oct 2004 17:35:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 3 Oct 2004 17:35:55 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 03 19:35:37 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CEAGn-0003m2-00 for ; Sun, 03 Oct 2004 19:35:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CEANK-0000Dw-Vy for ged-emacs-devel@m.gmane.org; Sun, 03 Oct 2004 13:42:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CEAND-0000DJ-6D for emacs-devel@gnu.org; Sun, 03 Oct 2004 13:42:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CEANC-0000D7-MP for emacs-devel@gnu.org; Sun, 03 Oct 2004 13:42:14 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CEANC-0000D4-JF; Sun, 03 Oct 2004 13:42:14 -0400 Original-Received: from [141.146.126.228] (helo=agminet01.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CEAGZ-0005Qp-Tg; Sun, 03 Oct 2004 13:35:24 -0400 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.191.11]) by agminet01.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i93HZMVr030399; Sun, 3 Oct 2004 10:35:22 -0700 Original-Received: from rgmgw2.us.oracle.com (localhost [127.0.0.1]) by rgmgw2.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i93HZLgr016334; Sun, 3 Oct 2004 11:35:21 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw1-141-144-65-21.vpn.oracle.com [141.144.65.21]) by rgmgw2.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id i93HZLjd016283; Sun, 3 Oct 2004 11:35:21 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:27841 gmane.emacs.help:21030 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27841 I mentioned no customization. I spoke of the case where you add an isearch-mode-hook that does goto-char isearch-other-end. This hook moves point to where the search ends (but at the search-string start, rather than end). C-g in this case does _not_ leave point unchanged from the starting point of the search. See email thread below with Juri. As he points out, the isearch code already tries to do the right thing, but the hook is called too late. It no doubt suffices to move the hook call earlier (but this should be tested to be sure it doesn't break anything else). Here is the exchange with Juri: -----Original Message----- From: Drew Adams [mailto:drew.adams@oracle.com] Sent: Saturday, October 02, 2004 1:26 PM To: Juri Linkov Subject: RE: isearch doesn't seem to set mark where search began Right. I noticed the same thing, but wasn't sure if just moving it wouldn't break something else. Thanks, Drew -----Original Message----- From: emacs-devel-bounces+drew.adams=oracle.com@gnu.org [mailto:emacs-devel-bounces+drew.adams=oracle.com@gnu.org]On Behalf Of Juri Linkov Sent: Saturday, October 02, 2004 1:16 PM To: Drew Adams Cc: emacs-devel@gnu.org Subject: Re: isearch doesn't seem to set mark where search began "Drew Adams" writes: > A lot of folks are doing this now: > > (add-hook 'isearch-mode-end-hook 'my-goto-match-beginning) > (defun my-goto-match-beginning () > (when isearch-forward (goto-char isearch-other-end))) > > If you end with Control-g, point is left at the beginning of the last > find. You would like to be able to do C-x C-x to return to the search > start. > > If you end with, say, RET or C-b, no problem. The behavior should > consistently set mark at the search start point, provided point is > different. The behavior you described is already implemented in `isearch-done' even if the search is ended with C-g, but it doesn't work for the case where the point is changed in `isearch-mode-end-hook' because this hook is run too late. I think the code for pushing the mark should be moved below the `(run-hooks 'isearch-mode-end-hook)': Index: lisp/isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.240 diff -u -r1.240 isearch.el --- lisp/isearch.el 13 Sep 2004 08:18:22 -0000 1.240 +++ lisp/isearch.el 2 Oct 2004 20:08:28 -0000 @@ -680,16 +680,7 @@ (if isearch-small-window (goto-char found-point) ;; Exiting the save-window-excursion clobbers window-start; restore it. - (set-window-start (selected-window) found-start t)) - - ;; If there was movement, mark the starting position. - ;; Maybe should test difference between and set mark iff > threshold. - (if (/= (point) isearch-opoint) - (or (and transient-mark-mode mark-active) - (progn - (push-mark isearch-opoint t) - (or executing-kbd-macro (> (minibuffer-depth) 0) - (message "Mark saved where search started")))))) + (set-window-start (selected-window) found-start t))) (setq isearch-mode nil) (if isearch-input-method-local-p @@ -714,6 +705,16 @@ (isearch-update-ring isearch-string isearch-regexp)) (run-hooks 'isearch-mode-end-hook) + + ;; If there was movement, mark the starting position. + ;; Maybe should test difference between and set mark iff > threshold. + (if (/= (point) isearch-opoint) + (or (and transient-mark-mode mark-active) + (progn + (push-mark isearch-opoint t) + (or executing-kbd-macro (> (minibuffer-depth) 0) + (message "Mark saved where search started"))))) + (and (not edit) isearch-recursive-edit (exit-recursive-edit))) (defun isearch-update-ring (string &optional regexp) -----Original Message----- From: emacs-devel-bounces+drew.adams=oracle.com@gnu.org [mailto:emacs-devel-bounces+drew.adams=oracle.com@gnu.org]On Behalf Of Richard Stallman Sent: Sunday, October 03, 2004 7:32 AM To: Drew Adams Cc: help-gnu-emacs@gnu.org; emacs-devel@gnu.org Subject: Re: isearch doesn't seem to set mark where search began Exiting the search with C-g means it does not move. That should not set the mark. I don't want that to change. You say the problem arises because of a customization. If you can suggest a clean patch that won't change the normal behavior but improves matters with your customization, I won't object to that.