* isearch doesn't seem to set mark where search began
@ 2004-10-02 16:34 Drew Adams
2004-10-02 20:15 ` Juri Linkov
2004-10-03 14:32 ` Richard Stallman
0 siblings, 2 replies; 6+ messages in thread
From: Drew Adams @ 2004-10-02 16:34 UTC (permalink / raw)
>From Info, node Incremental Search:
"When you exit the incremental search, it sets the mark to where point
_was_, before the search. That is convenient for moving back there.
In Transient Mark mode, incremental search sets the mark without
activating it, and does so only if the mark is not already active."
However, this is not the case if you end via Control-g. The doc should
be corrected - or, better, the product changed to set mark _if
different from point_ no matter how the search ends.
Why is this important? 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.
FYI, I use transient-mark-mode, but the remark is independent of this.
-----------8<---------------------------------------------
In GNU Emacs 21.3.50.1 (i386-mingw-nt5.1.2600)
of 2004-07-26 on BERATUNG4
configured using `configure --with-gcc
(3.3) --cflags -I../../jpeg-6b-1/include -I../../libpng-1.2.4-1/include -I..
/../tiff-3.5.7/include -I../../xpm-nox-4.2.0/include -I../../zlib-1.1.4-1/in
clude'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: isearch doesn't seem to set mark where search began
2004-10-02 16:34 isearch doesn't seem to set mark where search began Drew Adams
@ 2004-10-02 20:15 ` Juri Linkov
2004-10-04 15:19 ` Richard Stallman
2004-10-03 14:32 ` Richard Stallman
1 sibling, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2004-10-02 20:15 UTC (permalink / raw)
Cc: emacs-devel
"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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: isearch doesn't seem to set mark where search began
2004-10-02 16:34 isearch doesn't seem to set mark where search began Drew Adams
2004-10-02 20:15 ` Juri Linkov
@ 2004-10-03 14:32 ` Richard Stallman
2004-10-03 17:35 ` Drew Adams
1 sibling, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2004-10-03 14:32 UTC (permalink / raw)
Cc: help-gnu-emacs, emacs-devel
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: isearch doesn't seem to set mark where search began
2004-10-03 14:32 ` Richard Stallman
@ 2004-10-03 17:35 ` Drew Adams
2004-10-04 15:20 ` Richard Stallman
0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2004-10-03 17:35 UTC (permalink / raw)
Cc: help-gnu-emacs, emacs-devel
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" <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)
-----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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: isearch doesn't seem to set mark where search began
2004-10-03 17:35 ` Drew Adams
@ 2004-10-04 15:20 ` Richard Stallman
0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2004-10-04 15:20 UTC (permalink / raw)
Cc: help-gnu-emacs, emacs-devel
I mentioned no customization. I spoke of the case where you add an
isearch-mode-hook that does goto-char isearch-other-end.
That hook is the customization I referred to. Hooks are one method of
customization--an open-ended method. We cannot expect to anticipate
everything you might do with one, so in general adding one hook here
may require making another change there.
However in this case it looks Juri found a solution so that you'll get
what you want in this case.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-10-04 15:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-02 16:34 isearch doesn't seem to set mark where search began Drew Adams
2004-10-02 20:15 ` Juri Linkov
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
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.