[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help-window-select and info-lookup-symbol
From: |
Helmut Eller |
Subject: |
Re: help-window-select and info-lookup-symbol |
Date: |
Tue, 21 Jul 2009 15:51:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
* martin rudalics [2009-07-21 15:27+0200] writes:
>> (defun slime-close-popup-window ()
>> (when slime-popup-restore-data
>> (destructuring-bind (popup-window selected-window old-buffer)
>> slime-popup-restore-data
>> (bury-buffer)
>> (when (eq popup-window (selected-window))
>> (cond ((and (not old-buffer) (not (one-window-p)))
>> (delete-window popup-window))
>> ((and old-buffer (buffer-live-p old-buffer))
>> (set-window-buffer popup-window old-buffer))))
>> (when (window-live-p selected-window)
>> (select-window selected-window)))
>> (kill-local-variable 'slime-popup-restore-data)))
>>
>> popup-window is the window that displays the help content at W2.
>> selected-window was selected at W1.
>> old-buffer was the buffer associated with popup-window at W1.
>
> How do you get the `old-buffer' and `popup-window' values in general?
> By comparing window configurations before and after `display-buffer'?
> My code included for every window a variable telling whether that window
> was split off by `display-buffer' or which buffer the window displayed
> before it was "used" by `display-buffer'.
We do it by walking windows before and after display-buffer. I guess
that window-config objects also contain the information it's just not
accessible from Lisp.
>
> I recall it proved very nasty to save the old buffer value when the
> window is re-used again by `display-buffer' because I had to avoid that
> a "valuable" non-help content buffer value would get overwritten by the
> "uselss" value of a help-content buffer.
That's the code that stashes the data into the buffer-local variable:
(defun slime-display-popup-buffer (select)
"Display the current buffer.
Save the selected-window in a buffer-local variable, so that we
can restore it later."
(let ((selected-window (selected-window))
(old-windows))
(walk-windows (lambda (w) (push (cons w (window-buffer w)) old-windows))
nil t)
(let ((new-window (display-buffer (current-buffer))))
(unless slime-popup-restore-data
(set (make-local-variable 'slime-popup-restore-data)
(list new-window
selected-window
(cdr (find new-window old-windows :key #'car)))))
(when select
(select-window new-window))
(current-buffer))))
Helmut.
- help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/19
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/20
- Re: help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/21
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/21
- Re: help-window-select and info-lookup-symbol,
Helmut Eller <=
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/21
- Re: help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/21
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/22
- Re: help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/22
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/26
- Re: help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/26
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/26
- Re: help-window-select and info-lookup-symbol, Helmut Eller, 2009/07/26
- Re: help-window-select and info-lookup-symbol, martin rudalics, 2009/07/26