* window.el (display-buffer-window): Remove.
(display-buffer-record-window): Use help-setup window parameter
instead of variable display-buffer-window.
(display-buffer-function, special-display-buffer-names)
(special-display-function): Mention help-setup parameter instead
of display-buffer-window in doc-string.
* help.el (help-window-setup): New argument help-window. Use
help-window-setup parameter instead of display-buffer-window.
Reword some messages.
(with-help-window): Pass window used for displaying the buffer
to help-window-setup. Don't set display-buffer-window.
+2011-09-14 Martin Rudalics <rudalics@gmx.at>
+
+ * window.el (display-buffer-window): Remove.
+ (display-buffer-record-window): Use help-setup window parameter
+ instead of variable display-buffer-window.
+ (display-buffer-function, special-display-buffer-names)
+ (special-display-function): Mention help-setup parameter instead
+ of display-buffer-window in doc-string.
+ * help.el (help-window-setup): New argument help-window. Use
+ help-window-setup parameter instead of display-buffer-window.
+ Reword some messages.
+ (with-help-window): Pass window used for displaying the buffer
+ to help-window-setup. Don't set display-buffer-window.
+
2011-09-13 Glenn Morris <rgm@gnu.org>
* emacs-lisp/debug.el (debugger-make-xrefs):
(message "%s"
(substitute-command-keys (concat quit-part scroll-part)))))
-(defun help-window-setup ()
+(defun help-window-setup (help-window)
"Set up help window for `with-help-window'.
-This relies on `display-buffer-window' being correctly set up by
-`display-buffer'."
- (let* ((help-window (car-safe display-buffer-window))
- (help-buffer (when (window-live-p help-window)
+HELP-WINDOW is the window used for displaying the help buffer."
+ (let* ((help-buffer (when (window-live-p help-window)
(window-buffer help-window)))
- (help-value (cdr-safe display-buffer-window)))
+ (help-setup (when (window-live-p help-window)
+ (window-parameter help-window 'help-setup))))
(when help-buffer
;; Handle `help-window-point-marker'.
(when (eq (marker-buffer help-window-point-marker) help-buffer)
(cond
((or (eq help-window (selected-window))
(and (or (eq help-window-select t)
+ (eq help-setup 'new-frame)
(and (eq help-window-select 'other)
(eq (window-frame help-window) (selected-frame))
(> (length (window-list nil 'no-mini)) 2)))
;; The help window is or gets selected ...
(help-window-display-message
(cond
- ((eq help-value 'new-window)
+ ((eq help-setup 'new-window)
;; ... and is new, ...
- "Type \"q\" to delete this window")
- ((eq help-value 'new-frame)
- ;; ... is on a new frame ...
- "Type \"q\" to delete this frame")
- ((eq help-value 'reuse-other-window)
+ "Type \"q\" to delete help window")
+ ((eq help-setup 'new-frame)
+ "Type \"q\" to delete help frame")
+ ((eq help-setup 'reuse-other)
;; ... or displayed some other buffer before.
"Type \"q\" to restore previous buffer"))
help-window t))
;; other one is the selected one.
(help-window-display-message
(cond
- ((eq help-value 'new-window)
+ ((eq help-setup 'new-window)
"Type \\[delete-other-windows] to delete the help window")
- ((eq help-value 'reuse-other-window)
- "Type \"q\" in other window to quit"))
+ ((eq help-setup 'reuse-other)
+ "Type \"q\" in help window to restore its previous buffer"))
help-window 'other))
(t
- ;; Not much to say here.
+ ;; The help window is not selected ...
(help-window-display-message
- "Type \"q\" in help window to quit" help-window))))))
+ (cond
+ ((eq help-setup 'new-window)
+ ;; ... and is new, ...
+ "Type \"q\" in help window to delete it")
+ ((eq help-setup 'reuse-other)
+ ;; ... or displayed some other buffer before.
+ "Type \"q\" in help window to restore previous buffer"))
+ help-window))))))
;; `with-help-window' is a wrapper for `with-output-to-temp-buffer'
;; providing the following additional twists:
variable `temp-buffer-show-specifiers' to an appropriate value."
(declare (indent 1) (debug t))
`(progn
- ;; Reset `display-buffer-window': `display-buffer' is
- ;; supposed to set this to the window displaying the buffer plus
- ;; some additional information.
- (setq display-buffer-window nil)
;; Make `help-window-point-marker' point nowhere. The only place
;; where this should be set to a buffer position is within BODY.
(set-marker help-window-point-marker nil)
- (prog1
- ;; Return value returned by `with-output-to-temp-buffer'.
- (with-output-to-temp-buffer ,buffer-name
- (progn ,@body))
- (when display-buffer-window (help-window-setup)))))
+ (let* (help-window
+ (temp-buffer-show-hook
+ (cons (lambda () (setq help-window (selected-window)))
+ temp-buffer-show-hook)))
+ ;; Return value returned by `with-output-to-temp-buffer'.
+ (prog1
+ (with-output-to-temp-buffer ,buffer-name
+ (progn ,@body))
+ (help-window-setup help-window)))))
;; Called from C, on encountering `help-char' when reading a char.
;; Don't print to *Help*; that would clobber Help history.
(window-state-put-2 ignore))
(window-check frame))))
\f
-(defvar display-buffer-window nil
- "Window used by `display-buffer' and related information.
-After `display-buffer' displays a buffer in some window this
-variable is a cons cell whose car denotes the window used to
-display the buffer. The cdr is supposed to be one of the symbols
-`reuse-buffer-window', `reuse-other-window', `new-window' or
-`new-frame'.
-
-See the function `display-buffer-record-window' for how this
-variable can be assigned a value.")
-
(defun display-buffer-record-window (type window buffer)
"Record information for window used by `display-buffer'.
TYPE must be one of the symbols reuse-window, pop-up-window, or
displayed."
(cond
((eq type 'reuse-window)
- ;; In `display-buffer-window' record whether we used a window on the
- ;; same buffer or another one.
- (if (eq (window-buffer window) buffer)
- (setq display-buffer-window
- (cons window 'reuse-buffer-window))
- (setq display-buffer-window
- (cons window 'reuse-other-window)))
- ;; In quit-restore parameter record information about the old buffer
- ;; unless such information exists already.
+ ;; In `help-setup' window parameter record whether we used a window
+ ;; on the same buffer or another one.
+ (set-window-parameter
+ window 'help-setup
+ (if (eq (window-buffer window) buffer) 'reuse-same 'reuse-other))
+ ;; In `quit-restore' parameter record information about the old
+ ;; buffer unless such information exists already.
(unless (window-parameter window 'quit-restore)
(set-window-parameter
window 'quit-restore
(window-point window) buffer
(window-total-size window) (selected-window)))))
((eq type 'pop-up-window)
- ;; In `display-buffer-window' record window as new.
- (setq display-buffer-window (cons window 'new-window))
+ ;; In `help-setup' window parameter record window as new.
+ (set-window-parameter window 'help-setup 'new-window)
;; In `quit-restore' parameter record that we popped up this window,
;; its buffer, and which window was selected before.
(set-window-parameter
window 'quit-restore (list 'new-window buffer (selected-window))))
((eq type 'pop-up-frame)
- ;; In `display-buffer-window' record window as on new frame.
- (setq display-buffer-window (cons window 'new-frame))
+ ;; In `help-setup' window parameter record window as on new frame.
+ (set-window-parameter window 'help-setup 'new-frame)
;; In `quit-restore' parameter record that we popped up this window
;; on a new frame, the buffer, and which window was selected before.
(set-window-parameter
should choose or create a window, display the specified buffer in
it, and return the window.
-The function specified here is responsible for setting the value
-of `display-buffer-window' and the quit-restore parameter of the
-window used."
+The function specified here is responsible for setting the
+quit-restore and help-setup parameters of the window used."
:type '(choice
(const nil)
(function :tag "function"))
function, that function is called with the buffer named
BUFFER-NAME as first, and the element's cdr as second argument.
In any case, that function is responsible for setting the value
-of `display-buffer-window' and the quit-restore parameter of the
-window used.
+The function specified here is responsible for setting the
+quit-restore and help-setup parameters of the window used.
If this variable appears \"not to work\", because you added a
name to it but the corresponding buffer is displayed in the
`special-display-buffer-names' or matches a regexp in
`special-display-regexps'.
-The function specified here is responsible for setting the value
-of `display-buffer-window' and the quit-restore parameter of the
-window used."
+The function specified here is responsible for setting the
+quit-restore and help-setup parameters of the window used."
:type 'function
:group 'frames)