From: martin rudalics <rudalics@gmx.at>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: 10971@debbugs.gnu.org
Subject: bug#10971: Problem with `split-window-keep-point' set to `nil'
Date: Fri, 09 Mar 2012 16:21:02 +0100 [thread overview]
Message-ID: <4F5A1FDE.3020604@gmx.at> (raw)
In-Reply-To: <CAH8Pv0h2AdD+0NTLRHFQX-1KK-Yjxj-8dij6-K7Y10jfjmunKQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 842 bytes --]
> 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
[-- Attachment #2: split-window-below.diff --]
[-- Type: text/plain, Size: 1667 bytes --]
=== 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
next prev parent reply other threads:[~2012-03-09 15:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 21:12 bug#10971: Problem with `split-window-keep-point' set to `nil' Dani Moncayo
2012-03-08 22:44 ` Dani Moncayo
2012-03-09 15:21 ` martin rudalics [this message]
2012-03-09 16:24 ` martin rudalics
2012-03-10 8:48 ` Dani Moncayo
2012-03-11 14:06 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F5A1FDE.3020604@gmx.at \
--to=rudalics@gmx.at \
--cc=10971@debbugs.gnu.org \
--cc=dmoncayo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.