all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: isearch doesn't seem to set mark where search began
Date: Sat, 02 Oct 2004 23:15:30 +0300	[thread overview]
Message-ID: <87d600nafx.fsf@mail.jurta.org> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBKEIECGAA.drew.adams@oracle.com> (Drew Adams's message of "Sat, 2 Oct 2004 09:34:51 -0700")

"Drew Adams" <drew.adams@oracle.com> 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/

  reply	other threads:[~2004-10-02 20:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-02 16:34 isearch doesn't seem to set mark where search began Drew Adams
2004-10-02 20:15 ` Juri Linkov [this message]
2004-10-04 15:19   ` Richard Stallman
2004-10-03 14:32 ` Richard Stallman
2004-10-03 17:35   ` Drew Adams
2004-10-04 15:20     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d600nafx.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.