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#10971: Problem with `split-window-keep-point' set to `nil' Date: Fri, 09 Mar 2012 16:21:02 +0100 Message-ID: <4F5A1FDE.3020604@gmx.at> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030706040204040001060009" X-Trace: dough.gmane.org 1331306624 22755 80.91.229.3 (9 Mar 2012 15:23:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Mar 2012 15:23:44 +0000 (UTC) Cc: 10971@debbugs.gnu.org To: Dani Moncayo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 09 16:23:43 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 1S61fR-00052e-4w for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Mar 2012 16:23:41 +0100 Original-Received: from localhost ([::1]:51475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61fP-00005Z-RM for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Mar 2012 10:23:39 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61fH-000051-Lu for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2012 10:23:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S61et-0002sE-5R for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2012 10:23:31 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S61et-0002rw-24 for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2012 10:23:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S61fm-0006Fk-GJ for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2012 10:24:02 -0500 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, 09 Mar 2012 15:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10971 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10971-submit@debbugs.gnu.org id=B10971.133130661723995 (code B ref 10971); Fri, 09 Mar 2012 15:24:02 +0000 Original-Received: (at 10971) by debbugs.gnu.org; 9 Mar 2012 15:23:37 +0000 Original-Received: from localhost ([127.0.0.1]:40659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S61fN-0006Ex-9W for submit@debbugs.gnu.org; Fri, 09 Mar 2012 10:23:37 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:60468) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1S61fK-0006Ep-EQ for 10971@debbugs.gnu.org; Fri, 09 Mar 2012 10:23:35 -0500 Original-Received: (qmail invoked by alias); 09 Mar 2012 15:22:37 -0000 Original-Received: from 62-47-44-92.adsl.highway.telekom.at (EHLO [62.47.44.92]) [62.47.44.92] by mail.gmx.net (mp002) with SMTP; 09 Mar 2012 16:22:37 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18ySw82AL8yL1TFsgZqbxVgkEQKi63SXSx5eXwBGi 2Cgxgk/wD8smo5 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:57584 Archived-At: This is a multi-part message in MIME format. --------------030706040204040001060009 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > 0. emacs -Q > 1. M-: (setq split-window-keep-point nil) RET > 2. Visit the attached file. Vist any file large enough to extend beyond the end of the selected window. > 3. C-x 2 > > The point in the original (top) window has moved (unnecessarily) from > the first line to the last visible one. > > The docstring of the variable `split-window-keep-point' says: > > If non-nil, C-x 2 preserves point in the new window. > If nil, adjust point in the two windows to minimize redisplay. > [...] > > But in this case there was no need to adjust point, because it was in > a position which would remain visible after the splitting. > > This behavior is specially annoying if you are in a Dired buffer and > do `C-o' on a file (the point jumps to the last visible line). Does the attached patch give better results? martin --------------030706040204040001060009 Content-Type: text/plain; name="split-window-below.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="split-window-below.diff" === modified file 'lisp/window.el' --- lisp/window.el 2012-02-12 05:10:30 +0000 +++ lisp/window.el 2012-03-09 15:12:05 +0000 @@ -3282,22 +3282,23 @@ (setq new-window (split-window nil size)) (unless split-window-keep-point (with-current-buffer (window-buffer) - (goto-char (window-start)) - (setq moved (vertical-motion (window-height))) - (set-window-start new-window (point)) - (when (> (point) (window-point new-window)) - (set-window-point new-window (point))) - (when (= moved (window-height)) - (setq moved-by-window-height t) - (vertical-motion -1)) - (setq bottom (point))) - (and moved-by-window-height - (<= bottom (point)) - (set-window-point old-window (1- bottom))) - (and moved-by-window-height - (<= (window-start new-window) old-point) - (set-window-point new-window old-point) - (select-window new-window))) + (save-excursion + (goto-char (window-start)) + (setq moved (vertical-motion (window-height))) + (set-window-start new-window (point)) + (when (> (point) (window-point new-window)) + (set-window-point new-window (point))) + (when (= moved (window-height)) + (setq moved-by-window-height t) + (vertical-motion -1)) + (setq bottom (point))) + (and moved-by-window-height + (<= bottom (point)) + (set-window-point old-window (1- bottom))) + (and moved-by-window-height + (<= (window-start new-window) old-point) + (set-window-point new-window old-point) + (select-window new-window)))) ;; Always copy quit-restore parameter in interactive use. (let ((quit-restore (window-parameter old-window 'quit-restore))) (when quit-restore --------------030706040204040001060009--