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: Wed, 12 Oct 2011 11:48:07 +0200 Message-ID: <4E956257.6020501@gmx.at> References: <20090805001735.1CC041E844E@localhost> <4E745DAE.5040808@gmx.at> <4E8EA522.9090300@gmx.at> <4E8F3040.1060409@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060609090304090205080403" X-Trace: dough.gmane.org 1318412934 9217 80.91.229.12 (12 Oct 2011 09:48:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2011 09:48:54 +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 Wed Oct 12 11:48:46 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RDvQc-00062t-8H for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2011 11:48:46 +0200 Original-Received: from localhost ([::1]:37675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDvQb-0003tv-AR for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Oct 2011 05:48:45 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDvQY-0003ta-8Q for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2011 05:48:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDvQW-0002WU-SH for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2011 05:48:42 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDvQW-0002UE-PL for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2011 05:48:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RDvQr-0003Dp-SW for bug-gnu-emacs@gnu.org; Wed, 12 Oct 2011 05:49: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: Wed, 12 Oct 2011 09:49: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.131841292212361 (code B ref 4041); Wed, 12 Oct 2011 09:49:01 +0000 Original-Received: (at 4041) by debbugs.gnu.org; 12 Oct 2011 09:48:42 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RDvQY-0003DI-JJ for submit@debbugs.gnu.org; Wed, 12 Oct 2011 05:48:42 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.22]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1RDvQW-0003D5-CI for 4041@debbugs.gnu.org; Wed, 12 Oct 2011 05:48:41 -0400 Original-Received: (qmail invoked by alias); 12 Oct 2011 09:48:11 -0000 Original-Received: from 62-47-62-98.adsl.highway.telekom.at (EHLO [62.47.62.98]) [62.47.62.98] by mail.gmx.net (mp044) with SMTP; 12 Oct 2011 11:48:11 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19MiU9vNoZMcST5uWPEVPPqc4DBhOy2eMDcSOGm4w XHo3IRz30cip1f User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 12 Oct 2011 05:49:01 -0400 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:52578 Archived-At: This is a multi-part message in MIME format. --------------060609090304090205080403 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > I think I generally agree it would be a good change. But without an > actual patch, it's difficult to assess how reliable and backward > compatible we can make it. Attached find a diff with a new option `switch-to-buffer-preserve-window-point'. martin --------------060609090304090205080403 Content-Type: text/plain; name="stbpwp.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stbpwp.diff" === modified file 'lisp/window.el' --- lisp/window.el 2011-10-10 17:52:03 +0000 +++ lisp/window.el 2011-10-12 09:23:47 +0000 @@ -4976,6 +4976,19 @@ buffer)) (other-buffer))) +(defcustom switch-to-buffer-preserve-window-point nil + "If non-nil, `switch-to-buffer' tries to preserve `window-point'. +If nil, `switch-to-buffer' displays the buffer at that buffer's +`point'. If non-nil, it tries to display the buffer at the last +position of `window-point' in the window used for display. + +If the window used for display is either new, or the buffer +already appears in it, or the buffer never appeared in that +window, this variable has no impact." + :type 'boolean + :group 'windows + :version "24.1") + (defun switch-to-buffer (buffer-or-name &optional norecord force-same-window) "Switch to buffer BUFFER-OR-NAME in the selected window. If called interactively, prompt for the buffer name using the @@ -5001,7 +5014,7 @@ Return the buffer switched to." (interactive - (list (read-buffer-to-switch "Switch to buffer: ") nil nil)) + (list (read-buffer-to-switch "Switch to buffer: ") nil t)) (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) (if (null force-same-window) (pop-to-buffer buffer display-buffer--same-window-action norecord) @@ -5013,7 +5026,19 @@ (error "Cannot switch buffers in minibuffer window")) ((eq (window-dedicated-p) t) (error "Cannot switch buffers in a dedicated window")) - (t (set-window-buffer nil buffer))) + (t + (let* ((entry (and switch-to-buffer-preserve-window-point + (assq buffer (window-prev-buffers)))) + (start (and entry (nth 1 entry))) + (pos (and entry (nth 2 entry)))) + (set-window-buffer nil buffer) + (when entry + ;; If BUFFER-OR-NAME (1) was shown in the selected window + ;; before and (2) is currently displayed in some other + ;; visible window, try to restore start and point of buffer + ;; in the selected window. + (set-window-start (selected-window) start t) + (set-window-point-1 nil pos))))) (unless norecord (select-window (selected-window))) --------------060609090304090205080403--