summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2009-12-07 17:30:01 +0000
committerJuri Linkov <juri@jurta.org>2009-12-07 17:30:01 +0000
commit406374109c9df9fd1a2143f0001fe21562e9644a (patch)
treec475710dde8a019d06d6430544796799cb712e02
parente07278736e3103b4ad0ae01dfa1deaf2c2684e0e (diff)
downloademacs-406374109c9df9fd1a2143f0001fe21562e9644a.tar.gz
Correctly restore original Isearch point. (Bug#4994)
* isearch.el (isearch-mode): Move `isearch-push-state' after `(run-hooks 'isearch-mode-hook)'. (isearch-cancel): When `isearch-push-state-function' is defined, let-bind `isearch-cmds' to the first state (the last element of `isearch-cmds') and call `isearch-top-state' (it calls pop-state function and restores the original point). Otherwise, move point to `isearch-opoint'.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/isearch.el18
2 files changed, 24 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 75f5a9bbac0..464ca87b90b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-07 Juri Linkov <juri@jurta.org>
+
+ Correctly restore original Isearch point. (Bug#4994)
+
+ * isearch.el (isearch-mode): Move `isearch-push-state' after
+ `(run-hooks 'isearch-mode-hook)'.
+ (isearch-cancel): When `isearch-push-state-function' is defined,
+ let-bind `isearch-cmds' to the first state (the last element of
+ `isearch-cmds') and call `isearch-top-state' (it calls pop-state
+ function and restores the original point). Otherwise, move point
+ to `isearch-opoint'.
+
2009-12-07 Stefan Monnier <monnier@iro.umontreal.ca>
* international/mule-cmds.el (ucs-names): Weed out at compile-time the
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 7505d3e4d32..94df2ddfa1b 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -798,10 +798,14 @@ It is called by the function `isearch-forward' and other related functions."
(setq isearch-mode " Isearch") ;; forward? regexp?
(force-mode-line-update)
- (isearch-push-state)
-
(setq overriding-terminal-local-map isearch-mode-map)
(run-hooks 'isearch-mode-hook)
+
+ ;; Pushing the initial state used to be before running isearch-mode-hook,
+ ;; but a hook might set `isearch-push-state-function' used in
+ ;; `isearch-push-state' to save mode-specific initial state. (Bug#4994)
+ (isearch-push-state)
+
(isearch-update)
(add-hook 'mouse-leave-buffer-hook 'isearch-done)
@@ -1212,10 +1216,12 @@ If first char entered is \\[isearch-yank-word-or-char], then do word search inst
(defun isearch-cancel ()
"Terminate the search and go back to the starting point."
(interactive)
- (if (functionp (isearch-pop-fun-state (car (last isearch-cmds))))
- (funcall (isearch-pop-fun-state (car (last isearch-cmds)))
- (car (last isearch-cmds))))
- (goto-char isearch-opoint)
+ (if (and isearch-push-state-function isearch-cmds)
+ ;; For defined push-state function, restore the first state.
+ ;; This calls pop-state function and restores original point.
+ (let ((isearch-cmds (last isearch-cmds)))
+ (isearch-top-state))
+ (goto-char isearch-opoint))
(isearch-done t) ; exit isearch
(isearch-clean-overlays)
(signal 'quit nil)) ; and pass on quit signal