GNU bug report logs - #12170
save-excursion fails boundary case with recenter

Previous Next

Package: emacs;

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

From: martin rudalics <rudalics <at> gmx.at>
To: Bill Brodie <wbrodie <at> panix.com>
Cc: 12170 <at> debbugs.gnu.org
Subject: bug#12170: save-excursion fails boundary case with recenter
Date: Fri, 10 Aug 2012 11:34:11 +0200
>                 (defun f (n) (save-excursion (forward-line (- n)) (recenter
> 0)))
>
>
>
> Let H be the window height in lines, and suppose that point is positioned at
> the beginning of line L > H.
>
>
>
> Despite 'save-excursion', (f K) moves point if K = H.  It leaves point
> unchanged for any other value of K, 0 <= K < L.

I'm not sure whether I clearly understand your scenario.  Suppose with
emacs -Q I evaluate

(progn
  (defun f (n)
    (save-excursion (forward-line (- n)) (recenter 0)))
  (let ((buffer (switch-to-buffer "foo"))
	(height (window-height (get-buffer-window "foo"))))
    (insert-char 10 (* height 2))
    (let ((pt (point)))
      (f height)
      (message "old %s new %s" pt (point)))))

Then the values printed by the message are equal.  Please elaborate.

Thanks, martin




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.