From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Should ending successful Isearch with C-g restore the relative window position? Date: Wed, 16 Jan 2013 23:29:15 +0200 Organization: JURTA Message-ID: <87hamgker0.fsf_-_@mail.jurta.org> References: <7E5B63603B074626914E5DAEB90E738B@us.oracle.com> <83fw23qf57.fsf@gnu.org> <1712F3B8AF3D49DD9AC9F829FF560543@us.oracle.com> <834niiqubh.fsf@gnu.org> <75F694ACD7DA4E0482195A15331657BA@us.oracle.com> <83zk0ape2h.fsf@gnu.org> <3F79EED6372147F5AAC4F6EC7A02A18E@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1358371879 28525 80.91.229.3 (16 Jan 2013 21:31:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2013 21:31:19 +0000 (UTC) Cc: 'Eli Zaretskii' , emacs-devel@gnu.org, dmoncayo@gmail.com To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 16 22:31:36 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tvaa5-00012n-V4 for ged-emacs-devel@m.gmane.org; Wed, 16 Jan 2013 22:31:34 +0100 Original-Received: from localhost ([::1]:45562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvaZp-0002eJ-Em for ged-emacs-devel@m.gmane.org; Wed, 16 Jan 2013 16:31:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvaZn-0002e7-Nc for emacs-devel@gnu.org; Wed, 16 Jan 2013 16:31:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvaZm-0000ur-LT for emacs-devel@gnu.org; Wed, 16 Jan 2013 16:31:15 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:42289 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvaZg-0000t4-6r; Wed, 16 Jan 2013 16:31:08 -0500 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 48EB0229A8C722; Wed, 16 Jan 2013 13:31:05 -0800 (PST) In-Reply-To: <3F79EED6372147F5AAC4F6EC7A02A18E@us.oracle.com> (Drew Adams's message of "Wed, 16 Jan 2013 08:55:10 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 69.163.218.105 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156433 Archived-At: > 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))))))