From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#12253: Restore window start position Date: Sat, 25 Aug 2012 22:29:42 +0300 Organization: JURTA Message-ID: <87r4qun7u1.fsf@mail.jurta.org> References: <878vd7vqji.fsf@mail.jurta.org> <50348568.5060401@gmx.at> <87haru8rxr.fsf@mail.jurta.org> <5035EE75.9090809@gmx.at> <877gsp9sl2.fsf@mail.jurta.org> <50374D30.7090401@gmx.at> <8762874wyk.fsf@mail.jurta.org> <5038D5CA.5000502@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1345924404 15431 80.91.229.3 (25 Aug 2012 19:53:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Aug 2012 19:53:24 +0000 (UTC) Cc: 12253@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 25 21:53:25 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1T5MQ8-0008VA-Ui for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Aug 2012 21:53:25 +0200 Original-Received: from localhost ([::1]:54964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5MQ7-0003gY-3L for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Aug 2012 15:53:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5MQ4-0003gL-IF for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2012 15:53:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T5MQ3-000176-BZ for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2012 15:53:20 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5MQ3-000172-7t for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2012 15:53:19 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T5MQj-0000OU-U8 for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2012 15:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Aug 2012 19:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12253 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12253-submit@debbugs.gnu.org id=B12253.13459244151474 (code B ref 12253); Sat, 25 Aug 2012 19:54:01 +0000 Original-Received: (at 12253) by debbugs.gnu.org; 25 Aug 2012 19:53:35 +0000 Original-Received: from localhost ([127.0.0.1]:48763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T5MQJ-0000Nj-AC for submit@debbugs.gnu.org; Sat, 25 Aug 2012 15:53:35 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:40990 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T5MQG-0000NV-6L for 12253@debbugs.gnu.org; Sat, 25 Aug 2012 15:53:33 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 64849451CB63; Sat, 25 Aug 2012 12:52:47 -0700 (PDT) In-Reply-To: <5038D5CA.5000502@gmx.at> (martin rudalics's message of "Sat, 25 Aug 2012 15:40:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63487 Archived-At: > I agree. How do you handle the case where *info* is not in the selected > window but some other one? We don't need to care about this case. When used programmatically, the caller should handle also the case when *info* is in another window, e.g.: (with-current-buffer "*info*" ... (Info-history-back) (set-window-start (window-in-direction 'below) opoint) ...) or some more specific logic when necessary. But for the normal case, I think the following patch should be enough: === modified file 'lisp/info.el' --- lisp/info.el 2012-08-21 00:12:42 +0000 +++ lisp/info.el 2012-08-25 19:29:04 +0000 @@ -40,11 +40,11 @@ (defgroup info nil (defvar Info-history nil "Stack of Info nodes user has visited. -Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") +Each element of the stack is a list (FILENAME NODENAME BUFFERPOS WINDOWPOS).") (defvar Info-history-forward nil "Stack of Info nodes user has visited with `Info-history-back' command. -Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).") +Each element of the stack is a list (FILENAME NODENAME BUFFERPOS WINDOWPOS).") (defvar Info-history-list nil "List of all Info nodes user has visited. @@ -922,7 +925,9 @@ (defun Info-find-node (filename nodename ;; Record the node we are leaving, if we were in one. (and (not no-going-back) Info-current-file - (push (list Info-current-file Info-current-node (point)) + (push (list Info-current-file Info-current-node (point) + (and (eq (window-buffer) (current-buffer)) + (window-start))) Info-history)) (Info-find-node-2 filename nodename no-going-back)) @@ -956,7 +961,9 @@ (defun Info-revert-find-node (filename n (pline (count-lines (point-min) (line-beginning-position))) (wline (count-lines (point-min) (window-start))) (new-history (and Info-current-file - (list Info-current-file Info-current-node (point))))) + (list Info-current-file Info-current-node (point) + (and (eq (window-buffer) (current-buffer)) + (window-start)))))) ;; When `Info-current-file' is nil, `Info-find-node-2' rereads the file. (setq Info-current-file nil) (Info-find-node filename nodename) @@ -1226,6 +1233,8 @@ (defun Info-find-node-2 (filename nodena (let ((hist (car Info-history))) (setq Info-history (cdr Info-history)) (Info-find-node (nth 0 hist) (nth 1 hist) t) + (when (and (nth 3 hist) (eq (window-buffer) (current-buffer))) + (set-window-start (selected-window) (nth 3 hist) t)) (goto-char (nth 2 hist)))))) ;; Cache the contents of the (virtual) dir file, once we have merged @@ -2002,7 +2013,7 @@ (defun Info-search (regexp &optional bou (equal ofile Info-current-file)) (and isearch-mode isearch-wrapped (eq opoint (if isearch-forward opoint-min opoint-max))) - (setq Info-history (cons (list ofile onode opoint) + (setq Info-history (cons (list ofile onode opoint ostart) Info-history)))))) (defun Info-search-case-sensitively () @@ -2208,16 +2219,21 @@ (defun Info-history-back () (or Info-history (user-error "This is the first Info node you looked at")) (let ((history-forward - (cons (list Info-current-file Info-current-node (point)) + (cons (list Info-current-file Info-current-node (point) + (and (eq (window-buffer) (current-buffer)) + (window-start))) Info-history-forward)) - filename nodename opoint) + filename nodename opoint ostart) (setq filename (car (car Info-history))) (setq nodename (car (cdr (car Info-history)))) (setq opoint (car (cdr (cdr (car Info-history))))) + (setq ostart (car (cdr (cdr (cdr (car Info-history)))))) (setq Info-history (cdr Info-history)) (Info-find-node filename nodename) (setq Info-history (cdr Info-history)) (setq Info-history-forward history-forward) + (when (and ostart (eq (window-buffer) (current-buffer))) + (set-window-start (selected-window) ostart t)) (goto-char opoint))) (defalias 'Info-last 'Info-history-back) @@ -2228,12 +2244,15 @@ (defun Info-history-forward () (or Info-history-forward (user-error "This is the last Info node you looked at")) (let ((history-forward (cdr Info-history-forward)) - filename nodename opoint) + filename nodename opoint ostart) (setq filename (car (car Info-history-forward))) (setq nodename (car (cdr (car Info-history-forward)))) (setq opoint (car (cdr (cdr (car Info-history-forward))))) + (setq ostart (car (cdr (cdr (cdr (car Info-history-forward)))))) (Info-find-node filename nodename) (setq Info-history-forward history-forward) + (when (and ostart (eq (window-buffer) (current-buffer))) + (set-window-start (selected-window) ostart t)) (goto-char opoint))) (add-to-list 'Info-virtual-files @@ -4307,7 +4326,7 @@ (defun Info-find-emacs-command-nodes (co (setq where (cons (list Info-current-file (match-string-no-properties 2) - 0) + 0 0) where)) (setq line-number (and (match-beginning 3) (string-to-number (match-string 3)))))