[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Point of wrong window used in read-from-minibuffer?
From: |
Stefan Monnier |
Subject: |
Re: Point of wrong window used in read-from-minibuffer? |
Date: |
Mon, 11 Apr 2005 00:51:17 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
> 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.
I don't think the behavior in my above example is consistent
and predictable: it doesn't happen if the two windows displaying the buffer
are on different frames, it doesn't happen if current-buffer is displayed
in one or zero windows on the frame, ...
The patch below fixes the above buggy behavior.
I think it preserves the current behavior in "all" other cases.
Stefan
--- window.c 02 mar 2005 22:20:12 -0500 1.496
+++ window.c 11 avr 2005 00:50:28 -0400
@@ -5589,7 +5589,20 @@
else
{
if (XBUFFER (new_current_buffer) == current_buffer)
+ {
+ /* The code further down is careful to preserve point in current
+ buffer (if current-buffer is equal to new_current_buffer), but
+ that ends up moving the window's point if the selected-window
+ before and after both display current-buffer but aren't the
+ same window. So to work around this, in this specific case we
+ restore the selected window first. */
+ if (XBUFFER (XWINDOW (data->current_window)->buffer)
+ == current_buffer
+ && WINDOWP (selected_window)
+ && XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
+ Fselect_window (data->current_window, Qnil);
old_point = PT;
+ }
else
old_point = BUF_PT (XBUFFER (new_current_buffer));
}
- Point of wrong window used in read-from-minibuffer?, Ulf Klaperski, 2005/04/04
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/04
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/05
- Re: Point of wrong window used in read-from-minibuffer?, Richard Stallman, 2005/04/13
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/13
- Re: Point of wrong window used in read-from-minibuffer?, Richard Stallman, 2005/04/14
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/14
- Re: Point of wrong window used in read-from-minibuffer?, Richard Stallman, 2005/04/17
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/17
- Re: Point of wrong window used in read-from-minibuffer?, Stefan Monnier, 2005/04/17