emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Point of wrong window used in read-from-minibuffer?


From: Richard Stallman
Subject: Re: Point of wrong window used in read-from-minibuffer?
Date: Sun, 10 Apr 2005 21:57:01 -0400

    I don't know how to fix it, but I've traced it to the following problem:

      % emacs -Q
      [ type in some random text]
      C-x 2
      [ move point elsewhere ]
      M-: (save-window-excursion (select-window (next-window))) RET

    after the M-: command, point in the second window is set back to the same
    position as it is in the first window.

This is not a bug.  It is actually documented:

    DEFUN ("current-window-configuration", Fcurrent_window_configuration,
           Scurrent_window_configuration, 0, 1, 0,
           doc: /* Return an object representing the current window 
configuration of FRAME.
    If FRAME is nil or omitted, use the selected frame.
    This describes the number of windows, their sizes and current buffers,
    and for each displayed buffer, where display starts, and the positions of
    point and mark.  An exception is made for point in the current buffer:
    its value is -not- saved.

This feature is somewhat inconsistent, and one could argue for
changing it.  Removing this exception would certainly make things
simpler.  ISTR that I arrived at this exception in the late 80s
as I was trying to aim for consistent and predictable behavior.

One argument in favor of the exception is that you can always
put save-excursion around the save-window-excursion, if you want
to save the current buffer's point value.  Thus, the existence
of this exception makes it easy to get both behaviors.

One argument in favor of removing the exception is that perhaps the
current behavior of save-window-excursion isn't useful.  Perhaps
removing the exception would make everyone happier.  Another argument
is that the places which benefitted from not saving and restoring
point could now use save-selected-window (which did not exist back then).
And maybe they already do.

However, there is a risk this change would break who-knows-what.  I
think it is better to play safe and not change this.

I added comments to the code which I think will make this clearer.


So could you fix the original bug by adding a call to save-excursion?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]