From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: isearch doesn't seem to set mark where search began Date: Sat, 02 Oct 2004 23:15:30 +0300 Organization: JURTA Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <87d600nafx.fsf@mail.jurta.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1096748410 14218 80.91.229.6 (2 Oct 2004 20:20:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 2 Oct 2004 20:20:10 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 02 22:19:52 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 1CDqMB-0005ek-00 for ; Sat, 02 Oct 2004 22:19:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CDqSf-000290-Ll for ged-emacs-devel@m.gmane.org; Sat, 02 Oct 2004 16:26:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CDqSX-00028l-J7 for emacs-devel@gnu.org; Sat, 02 Oct 2004 16:26:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CDqSX-00028Z-4R for emacs-devel@gnu.org; Sat, 02 Oct 2004 16:26:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CDqSX-00028W-29 for emacs-devel@gnu.org; Sat, 02 Oct 2004 16:26:25 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CDqLl-0000C8-9y for emacs-devel@gnu.org; Sat, 02 Oct 2004 16:19:25 -0400 Original-Received: from mail.jurta.org (80-235-37-197-dsl.mus.estpak.ee [80.235.37.197]) by spatula.dreamhost.com (Postfix) with ESMTP id D74FC17D027; Sat, 2 Oct 2004 13:19:18 -0700 (PDT) Original-To: "Drew Adams" In-Reply-To: (Drew Adams's message of "Sat, 2 Oct 2004 09:34:51 -0700") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) 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:27802 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27802 "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) -- Juri Linkov http://www.jurta.org/emacs/