GNU bug report logs -
#12170
save-excursion fails boundary case with recenter
Previous Next
Reported by: "Bill Brodie" <wbrodie <at> panix.com>
Date: Fri, 10 Aug 2012 02:01:02 UTC
Severity: normal
Tags: notabug
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Date: Sat, 11 Aug 2012 16:22:39 +0200
> From: martin rudalics <rudalics <at> gmx.at>
> CC: wbrodie <at> panix.com, 12170 <at> debbugs.gnu.org
>
> (progn
> (defmacro save-this-window-excursion (&rest body)
> "..."
> (let ((start (make-symbol "start"))
> (point (make-symbol "point")))
> `(let ((,start (copy-marker (window-start)))
> (,point (copy-marker (window-point))))
> (save-selected-window
> (progn ,@body))
> (set-window-start (selected-window) ,start t)
> (with-current-buffer (window-buffer (selected-window))
> (goto-char ,point)))))
>
> (defun f (n)
> (save-this-window-excursion (forward-line (- n)) (recenter 0)))
>
> (let ((buffer (switch-to-buffer "foo"))
> (height (1- (window-height (get-buffer-window "foo")))))
> (insert-char 10 (* height 2))
> (let ((pt (point)))
> (f height)
> (redisplay)
> (message "height %s old %s new %s" height pt (point)))))
>
> I get the same results as with `set-window-point'. IMHO the
> `set-window-start' call makes the difference but I don't understand why.
Maybe. If it's really important, I could try looking at this in the
debugger, although doing so to investigate such situations is
notoriously hard, because redisplay is entered several times.
IMO, save-excursion is simply not designed to make sure display isn't
changed in such cases. It's for excursions into other portions of the
buffer for processing those other parts, without affecting display.
If the processing also scrolls the screen or calls recenter or
otherwise affects the display, all bets are off, because scrolling can
legitimately move point, and when that happens, it is no longer clear
that restoring point should take precedence over window-start etc.
This bug report was last modified 8 years and 62 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.