[Top][All Lists]

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

Re: display-buffer-reuse-frames makes View-quit abnormal

From: martin rudalics
Subject: Re: display-buffer-reuse-frames makes View-quit abnormal
Date: Sat, 28 Jul 2007 14:05:35 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> After `(setq display-buffer-reuse-frames t)', `C-h f'(or `C-h v' and the
> alike) to view help, `C-x o' to jump to the help window, `q' to quit view
> mode, then I find `View-quit' does not restore window and buffer to
> previous
> state as usual, instead Emacs pops one of other buffers.

Thank you for reporting this.  The behavior you experience is due to the
following changes:

2000-08-08  Gerd Moellmann  <address@hidden>

        * help.el (print-help-return-message): When
        display-buffer-reuse-frames is set, let the help window been quit,
        instead of deleting it, which might delete a reused frame.


2006-04-18  Richard Stallman  <address@hidden>

        * help-mode.el (help-mode): Set view-exit-action to delete window.


2006-05-01  Richard Stallman  <address@hidden>

        * help-mode.el (help-mode): view-exit-action calls delete-window
        only when it is safe and possible.

Now with `display-buffer-reuse-frames' non-nil
`print-help-return-message' (called by C-h f ...) adds

  (W1 W2 . 'quit-window)

to `view-return-to-alist'.  With `display-buffer-reuse-frames' nil it
would add

  (W1 W2 . t)

instead, where in both cases W1 is the help window, W2 the original
window, and t means delete W1 when done, 'quit-window call that

When you type "q" in window W1 the (contrived code of) `quit-window'
invoked by `view-mode-exit' will do

          (switch-to-buffer (other-buffer))))

switching in W1 to some buffer not shown in W2.

On the other hand invoking `help-mode' after (C-h f ...) has done

  (setq view-exit-action (lambda (buffer)
                           (or (window-minibuffer-p (selected-window))
                               (one-window-p t)

locally in *Help*.  After invoking `quit-window' as described above
`view-mode-exit' does

        (if (window-live-p old-window)  ; still existing window
            (select-window old-window))

where old-window is W2.  Since W2 is still live it gets selected.
Finally, `view-mode-exit' calls `view-exit-action' with BUFFER the still
existing *Help* buffer and W2 selected.  `view-exit-action' does not pay
attention to BUFFER and deletes the selected window W2.  You are left
with W1 showing a completely unrelated buffer.

Reverting the changes above would give the correct behavior in _this_
case.  Keeping Gerd's change means that you would have to live with a
frame with W2 showing the original buffer and W1 the one selected by
`quit-window'.  Richard's change could then be modified by doing

  (setq view-exit-action (lambda (buffer)
                           (or (window-minibuffer-p (selected-window))
                               (one-window-p t)
                               (not (eq (window-buffer) buffer))

though I think that `view-exit-action' should _not_ fiddle with windows.

Comments welcome.

reply via email to

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