GNU bug report logs -
#10971
Problem with `split-window-keep-point' set to `nil'
Previous Next
Reported by: Dani Moncayo <dmoncayo <at> gmail.com>
Date: Thu, 8 Mar 2012 21:15:02 UTC
Severity: normal
Done: martin rudalics <rudalics <at> gmx.at>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 10971 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> 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
[split-window-below.diff (text/plain, inline)]
=== 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
This bug report was last modified 13 years and 135 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.