From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#4041: 23.0.92; Emacs 23: buffer point is no longer frame-local Date: Fri, 05 Oct 2012 12:08:24 +0200 Message-ID: <506EB198.5080008@gmx.at> References: <20090805001735.1CC041E844E@localhost> <4E745DAE.5040808@gmx.at> <4E8EA522.9090300@gmx.at> <4E8F3040.1060409@gmx.at> <4E956257.6020501@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090802040807070900070605" X-Trace: ger.gmane.org 1349431740 18811 80.91.229.3 (5 Oct 2012 10:09:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Oct 2012 10:09:00 +0000 (UTC) Cc: Lars Magne Ingebrigtsen , Steve Yegge , 4041@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 05 12:09:03 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 1TK4q6-0007JD-QZ for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Oct 2012 12:09:03 +0200 Original-Received: from localhost ([::1]:44940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TK4q0-00056e-N5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Oct 2012 06:08:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TK4px-00055o-FD for bug-gnu-emacs@gnu.org; Fri, 05 Oct 2012 06:08:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TK4pw-0005us-5C for bug-gnu-emacs@gnu.org; Fri, 05 Oct 2012 06:08:53 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TK4pw-0005ui-1H for bug-gnu-emacs@gnu.org; Fri, 05 Oct 2012 06:08:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TK4q5-0005oX-Hr for bug-gnu-emacs@gnu.org; Fri, 05 Oct 2012 06:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Oct 2012 10:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4041 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 4041-submit@debbugs.gnu.org id=B4041.134943173122333 (code B ref 4041); Fri, 05 Oct 2012 10:09:01 +0000 Original-Received: (at 4041) by debbugs.gnu.org; 5 Oct 2012 10:08:51 +0000 Original-Received: from localhost ([127.0.0.1]:55219 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TK4pu-0005o9-Rh for submit@debbugs.gnu.org; Fri, 05 Oct 2012 06:08:51 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:51480) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1TK4ps-0005nw-65 for 4041@debbugs.gnu.org; Fri, 05 Oct 2012 06:08:49 -0400 Original-Received: (qmail invoked by alias); 05 Oct 2012 10:08:11 -0000 Original-Received: from 62-47-57-32.adsl.highway.telekom.at (EHLO [62.47.57.32]) [62.47.57.32] by mail.gmx.net (mp010) with SMTP; 05 Oct 2012 12:08:11 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+IGMBbJsOIAJ1qiG8dBWZiLqPjnU1o06bBdlrBk0 di4Xf6eBBLKIMq In-Reply-To: X-Y-GMX-Trusted: 0 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:65226 Archived-At: This is a multi-part message in MIME format. --------------090802040807070900070605 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > That looks pretty good. I'd be willing to try and turn it on by default > in something like Emacs-25 or maybe even 24.2. I completely forgot about this. Any objections to install the attached version for 24.3? > One thing bothers me, tho: why not do it in set-window-buffer? I'm still not sure whether this would be safe in all cases. I wouldn't even do that for plain `display-buffer'. The current patch addresses all requests raised in the current thread. If there's real need to provide this option for other functions as well, we can still do that. martin --------------090802040807070900070605 Content-Type: text/plain; name="switch-to-buffer-preserve-window-point.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="switch-to-buffer-preserve-window-point.diff" === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-10-04 12:56:14 +0000 +++ lisp/ChangeLog 2012-10-05 09:40:16 +0000 @@ -1,3 +1,10 @@ +2012-10-05 Martin Rudalics + + * window.el (switch-to-buffer-preserve-window-point): New + option. + (switch-to-buffer): Optionally preserve window point if buffer + appeared earlier in the selected window (Bug#4041). + 2012-10-04 Martin Rudalics * emacs-lisp/edebug.el (edebug-pop-to-buffer): Select window === modified file 'lisp/window.el' --- lisp/window.el 2012-09-30 10:44:43 +0000 +++ lisp/window.el 2012-10-05 09:47:10 +0000 @@ -5812,6 +5812,25 @@ buffer)) (other-buffer))) +(defcustom switch-to-buffer-preserve-window-point nil + "If non-nil, `switch-to-buffer' tries to preserve `window-point'. +If this is nil, `switch-to-buffer' displays the buffer at that +buffer's `point'. If this is `already-displayed', it tries to +display the buffer at its last position in the selected window +provided the buffer is curently displayed in some other window on +a visible or iconified frame. If this is t, it always tries to +display the buffer at its last position in the selected window. + +If the window used for display is either new, or the buffer +already appears in it, or the buffer never appeared in that +window, the setting of this variable has no impact." + :type '(choice + (const :tag "Never" nil) + (const :tag "If already displayed elsewhere" already-displayed) + (const :tag "Always" t)) + :group 'windows + :version "24.3") + (defun switch-to-buffer (buffer-or-name &optional norecord force-same-window) "Switch to buffer BUFFER-OR-NAME in the selected window. If the selected window cannot display the specified @@ -5837,6 +5856,10 @@ must be displayed in the selected window; if that is impossible, signal an error rather than calling `pop-to-buffer'. +The option `switch-to-buffer-preserve-window-point' can be used +to make the buffer appear at its last position in the selected +window. + Return the buffer switched to." (interactive (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window)) @@ -5853,7 +5876,21 @@ (if force-same-window (user-error "Cannot switch buffers in a dedicated window") (pop-to-buffer buffer norecord))) - (t (set-window-buffer nil buffer))) + (t + (let* ((entry (assq buffer (window-prev-buffers))) + (displayed (and (eq switch-to-buffer-preserve-window-point + 'already-displayed) + (get-buffer-window buffer 0))) + (start (and entry (nth 1 entry))) + (pos (and entry (nth 2 entry)))) + (set-window-buffer nil buffer) + (when (and entry + (or (eq switch-to-buffer-preserve-window-point t) + displayed)) + ;; Try to restore start and point of buffer in the selected + ;; window (Bug#4041). + (set-window-start (selected-window) start t) + (set-window-point nil pos))))) (unless norecord (select-window (selected-window))) --------------090802040807070900070605--