all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: 'Eli Zaretskii' <eliz@gnu.org>, emacs-devel@gnu.org, dmoncayo@gmail.com
Subject: Re: Should ending successful Isearch with C-g restore the relative window position?
Date: Wed, 16 Jan 2013 23:29:15 +0200	[thread overview]
Message-ID: <87hamgker0.fsf_-_@mail.jurta.org> (raw)
In-Reply-To: <3F79EED6372147F5AAC4F6EC7A02A18E@us.oracle.com> (Drew Adams's message of "Wed, 16 Jan 2013 08:55:10 -0800")

> That patch did not fix the problem when searching across Info nodes.

A more general approach would be to save the window start position on
the stack and restore it in `isearch-cancel' like the patch below does.

`isearch-done' already does something like this by restoring
the original window configuration with `set-window-configuration'
from `isearch-window-configuration'.  But it does this only
on slow terminals where baud-rate is less than 1200.  So perhaps
this patch will also make `isearch-window-configuration' obsolete.

The remaining problem is how to take into account the case
when `isearch-allow-scroll' is non-nil and the user scrolled the
window-start to another position.  We should find the right place
to update the window-start of the previous state on the search stack
to be able to restore it later.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-01-02 16:13:04 +0000
+++ lisp/isearch.el	2013-01-16 21:28:52 +0000
@@ -1036,6 +1036,7 @@ (cl-defstruct (isearch--state
                  (string isearch-string)
                  (message isearch-message)
                  (point (point))
+                 (window-start (window-start))
                  (success isearch-success)
                  (forward isearch-forward)
                  (other-end isearch-other-end)
@@ -1049,6 +1050,7 @@ (cl-defstruct (isearch--state
   (string :read-only t)
   (message :read-only t)
   (point :read-only t)
+  (window-start :read-only t)
   (success :read-only t)
   (forward :read-only t)
   (other-end :read-only t)
@@ -1072,7 +1074,9 @@ (defun isearch--set-state (cmd)
 	isearch-case-fold-search (isearch--state-case-fold-search cmd))
   (if (functionp (isearch--state-pop-fun cmd))
       (funcall (isearch--state-pop-fun cmd) cmd))
-  (goto-char (isearch--state-point cmd)))
+  (goto-char (isearch--state-point cmd))
+  (unless (eq (isearch--state-window-start cmd) (window-start))
+    (set-window-start nil (isearch--state-window-start cmd))))
 
 (defun isearch-pop-state ()
   (setq isearch-cmds (cdr isearch-cmds))
@@ -1303,12 +1307,8 @@ (defun isearch-reverse-exit-minibuffer (
 (defun isearch-cancel ()
   "Terminate the search and go back to the starting point."
   (interactive)
-  (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--set-state (car isearch-cmds)))
-    (goto-char isearch-opoint))
+  (let ((isearch-cmds (last isearch-cmds)))
+    (isearch--set-state (car isearch-cmds)))
   (isearch-done t)                      ; Exit isearch..
   (isearch-clean-overlays)
   (signal 'quit nil))                   ; ..and pass on quit signal.
@@ -2646,7 +2646,9 @@ (defun isearch-search ()
     (if (functionp (isearch--state-pop-fun (car isearch-cmds)))
         (funcall (isearch--state-pop-fun (car isearch-cmds))
                  (car isearch-cmds)))
-    (goto-char (isearch--state-point (car isearch-cmds)))))
+    (goto-char (isearch--state-point (car isearch-cmds)))
+    (unless (eq (isearch--state-window-start (car isearch-cmds)) (window-start))
+      (set-window-start nil (isearch--state-window-start (car isearch-cmds))))))
 
 



  reply	other threads:[~2013-01-16 21:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 22:29 Should ending successful Isearch with C-g restore the relative window position? Drew Adams
2013-01-14 23:07 ` Dani Moncayo
2013-01-14 23:17   ` Drew Adams
2013-01-15  3:49     ` Eli Zaretskii
2013-01-15 14:58       ` Drew Adams
2013-01-15 15:09         ` Alan Mackenzie
2013-01-15 16:22           ` Should ending successful Isearch with C-g restore the relativewindow position? Drew Adams
2013-01-15 16:36             ` Alan Mackenzie
2013-01-15 16:54               ` Should ending successful Isearch with C-g restore therelativewindow position? Drew Adams
2013-01-15 16:34         ` Should ending successful Isearch with C-g restore the relative window position? Eli Zaretskii
2013-01-15 16:58           ` Drew Adams
2013-01-15 17:10             ` Eli Zaretskii
2013-01-15 17:59               ` Drew Adams
2013-01-15 18:25                 ` Eli Zaretskii
2013-01-15 22:04               ` Drew Adams
2013-01-16 16:55                 ` Should ending successful Isearch with C-g restore therelative " Drew Adams
2013-01-16 21:29                   ` Juri Linkov [this message]
2013-01-16 22:16                     ` Should ending successful Isearch with C-g restore the relative " Drew Adams
2013-01-17 21:35                       ` Juri Linkov
2013-01-15  9:52   ` Juri Linkov

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=87hamgker0.fsf_-_@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=dmoncayo@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.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.