Improve docs of functions/variables related to 'display-buffer'

* lisp/window.el (display-buffer, pop-to-buffer-same-window)
(display-buffer-same-window, display-buffer-in-side-window)
(same-window-p, display-buffer-overriding-action)
(display-buffer-base-action)
(display-buffer--same-window-action)
(display-buffer--other-frame-action)
(with-current-buffer-window, with-displayed-buffer-window)
(display-buffer-alist, display-buffer-assq-regexp)
(display-buffer-other-frame): Clarify and improve the doc
strings.  (Bug#32798)
This commit is contained in:
Eli Zaretskii 2018-09-24 18:07:02 +03:00
parent a3639317bc
commit 17766a14cc

View file

@ -201,7 +201,7 @@ argument replaces this)."
(defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body) (defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body)
"Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer. "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer.
This construct is like `with-temp-buffer-window' but unlike that This construct is like `with-temp-buffer-window' but unlike that,
makes the buffer specified by BUFFER-OR-NAME current for running makes the buffer specified by BUFFER-OR-NAME current for running
BODY." BODY."
(declare (debug t)) (declare (debug t))
@ -224,7 +224,7 @@ BODY."
(defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body) (defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body)
"Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer. "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer.
This construct is like `with-current-buffer-window' but unlike that This construct is like `with-current-buffer-window' but unlike that,
displays the buffer specified by BUFFER-OR-NAME before running BODY." displays the buffer specified by BUFFER-OR-NAME before running BODY."
(declare (debug t)) (declare (debug t))
(let ((buffer (make-symbol "buffer")) (let ((buffer (make-symbol "buffer"))
@ -992,16 +992,16 @@ and may be called only if no window on SIDE exists yet."
ALIST is an association list of symbols and values. The ALIST is an association list of symbols and values. The
following special symbols can be used in ALIST. following special symbols can be used in ALIST.
`side' denotes the side of the frame where the new window shall `side' denotes the side of the frame where the new window shall
be located. Valid values are `bottom', `right', `top' and be located. Valid values are `bottom', `right', `top' and
`left'. The default is `bottom'. `left'. The default is `bottom'.
`slot' if non-nil, specifies the window slot where to display `slot' if non-nil, specifies the window slot where to display
BUFFER. A value of zero or nil means use the middle slot on BUFFER. A value of zero or nil means use the middle slot on
the specified side. A negative value means use a slot the specified side. A negative value means use a slot
preceding (that is, above or on the left of) the middle slot. preceding (that is, above or on the left of) the middle slot.
A positive value means use a slot following (that is, below or A positive value means use a slot following (that is, below or
on the right of) the middle slot. The default is zero. on the right of) the middle slot. The default is zero.
If the current frame size or the settings of `window-sides-slots' If the current frame size or the settings of `window-sides-slots'
do not permit making a new window, a suitable existing window may do not permit making a new window, a suitable existing window may
@ -6382,7 +6382,7 @@ See also `same-window-buffer-names'."
:group 'windows) :group 'windows)
(defun same-window-p (buffer-name) (defun same-window-p (buffer-name)
"Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window. "Return non-nil if buffer BUFFER-NAME would be shown in the \"same\" window.
This function returns non-nil if `display-buffer' or This function returns non-nil if `display-buffer' or
`pop-to-buffer' would show a buffer named BUFFER-NAME in the `pop-to-buffer' would show a buffer named BUFFER-NAME in the
selected rather than (as usual) some other window. See selected rather than (as usual) some other window. See
@ -6820,16 +6820,22 @@ The actual non-nil value of this variable will be copied to the
"Custom type for `display-buffer' actions.") "Custom type for `display-buffer' actions.")
(defvar display-buffer-overriding-action '(nil . nil) (defvar display-buffer-overriding-action '(nil . nil)
"Overriding action to perform to display a buffer. "User-defined overriding action to perform to display a buffer.
It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a This action overrides all the other actions in the action variables
function or a list of functions. Each function should accept two and arguments passed to `display-buffer'.
arguments: a buffer to display and an alist similar to ALIST. Value should be a cons cell (FUNCTION . ALIST), where FUNCTION is
a function or a list of functions. Each function should accept
two arguments: a buffer to display and an alist similar to ALIST.
The default value is empty.
See `display-buffer' for details.") See `display-buffer' for details.")
(put 'display-buffer-overriding-action 'risky-local-variable t) (put 'display-buffer-overriding-action 'risky-local-variable t)
(defcustom display-buffer-alist nil (defcustom display-buffer-alist nil
"Alist of conditional actions for `display-buffer'. "Alist of uder-defined conditional actions for `display-buffer'.
This is a list of elements (CONDITION . ACTION), where: Its value takes effect before `display-buffer-base-action'
and `display-buffer-fallback-action', but after
`display-buffer-overriding-action', which see.
If non-nil, this is a list of elements (CONDITION . ACTION), where:
CONDITION is either a regexp matching buffer names, or a CONDITION is either a regexp matching buffer names, or a
function that takes two arguments - a buffer name and the function that takes two arguments - a buffer name and the
@ -6855,9 +6861,13 @@ associated action to the list of actions it will try."
(defcustom display-buffer-base-action '(nil . nil) (defcustom display-buffer-base-action '(nil . nil)
"User-specified default action for `display-buffer'. "User-specified default action for `display-buffer'.
This is the default action used by `display-buffer' if no other
actions are specified or all fail, before falling back on
`display-buffer-fallback-action'.
It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a
function or a list of functions. Each function should accept two function or a list of functions. Each function should accept two
arguments: a buffer to display and an alist similar to ALIST. arguments: a buffer to display and an alist similar to ALIST.
The default value is empty.
See `display-buffer' for details." See `display-buffer' for details."
:type display-buffer--action-custom-type :type display-buffer--action-custom-type
:risky t :risky t
@ -6875,12 +6885,16 @@ See `display-buffer' for details."
"Default fallback action for `display-buffer'. "Default fallback action for `display-buffer'.
This is the action used by `display-buffer' if no other actions This is the action used by `display-buffer' if no other actions
specified, e.g. by the user options `display-buffer-alist' or specified, e.g. by the user options `display-buffer-alist' or
`display-buffer-base-action'. See `display-buffer'.") `display-buffer-base-action', or they all fail. See `display-buffer'.")
(put 'display-buffer-fallback-action 'risky-local-variable t) (put 'display-buffer-fallback-action 'risky-local-variable t)
(defun display-buffer-assq-regexp (buffer-name alist action) (defun display-buffer-assq-regexp (buffer-name alist action)
"Retrieve ALIST entry corresponding to BUFFER-NAME. "Retrieve ALIST entry corresponding to BUFFER-NAME.
ACTION is the action argument passed to `display-buffer'." This returns the cdr of the ALIST entry if either its key is a
string that matches BUFFER-NAME, as reported by `string-match-p';
or if the key is a function that returns a non-nil when called
with 3 arguments: the ALIST key, BUFFER-NAME, and ACTION.
ACTION should have the form of the action argument passed to `display-buffer'."
(catch 'match (catch 'match
(dolist (entry alist) (dolist (entry alist)
(let ((key (car entry))) (let ((key (car entry)))
@ -6893,7 +6907,8 @@ ACTION is the action argument passed to `display-buffer'."
(defvar display-buffer--same-window-action (defvar display-buffer--same-window-action
'(display-buffer-same-window '(display-buffer-same-window
(inhibit-same-window . nil)) (inhibit-same-window . nil))
"A `display-buffer' action for displaying in the same window.") "A `display-buffer' action for displaying in the same window.
Specifies to call `display-buffer-same-window'.")
(put 'display-buffer--same-window-action 'risky-local-variable t) (put 'display-buffer--same-window-action 'risky-local-variable t)
(defvar display-buffer--other-frame-action (defvar display-buffer--other-frame-action
@ -6901,7 +6916,9 @@ ACTION is the action argument passed to `display-buffer'."
display-buffer-pop-up-frame) display-buffer-pop-up-frame)
(reusable-frames . 0) (reusable-frames . 0)
(inhibit-same-window . t)) (inhibit-same-window . t))
"A `display-buffer' action for displaying in another frame.") "A `display-buffer' action for displaying in another frame.
Specifies to call `display-buffer-reuse-window', and if that
fails, call `display-buffer-pop-up-frame'.")
(put 'display-buffer--other-frame-action 'risky-local-variable t) (put 'display-buffer--other-frame-action 'risky-local-variable t)
(defun display-buffer (buffer-or-name &optional action frame) (defun display-buffer (buffer-or-name &optional action frame)
@ -6922,7 +6939,7 @@ If ACTION is non-nil, it should have the form (FUNCTION . ALIST),
where FUNCTION is either a function or a list of functions, and where FUNCTION is either a function or a list of functions, and
ALIST is an arbitrary association list (alist). ALIST is an arbitrary association list (alist).
Each such FUNCTION should accept two arguments: the buffer to Each such function should accept two arguments: the buffer to
display and an alist. Based on those arguments, it should display and an alist. Based on those arguments, it should
display the buffer and return the window. If the caller is display the buffer and return the window. If the caller is
prepared to handle the case of not displaying the buffer prepared to handle the case of not displaying the buffer
@ -7046,6 +7063,9 @@ argument, ACTION is t."
(defun display-buffer-other-frame (buffer) (defun display-buffer-other-frame (buffer)
"Display buffer BUFFER preferably in another frame. "Display buffer BUFFER preferably in another frame.
This function attempts to look for a window displaying BUFFER,
on all the frames on the current terminal, skipping the selected
window; if that fails, it pops up a new frame.
This uses the function `display-buffer' as a subroutine; see This uses the function `display-buffer' as a subroutine; see
its documentation for additional customization information." its documentation for additional customization information."
(interactive "BDisplay buffer in other frame: ") (interactive "BDisplay buffer in other frame: ")
@ -7089,10 +7109,10 @@ that allows the selected frame)."
(defun display-buffer-same-window (buffer alist) (defun display-buffer-same-window (buffer alist)
"Display BUFFER in the selected window. "Display BUFFER in the selected window.
This fails if ALIST has a non-nil `inhibit-same-window' entry, or This fails if ALIST has an `inhibit-same-window' element whose
if the selected window is a minibuffer window or is dedicated to value is non-nil, or if the selected window is a minibuffer
another buffer; in that case, return nil. Otherwise, return the window or is dedicated to another buffer; in that case, return nil.
selected window." Otherwise, return the selected window."
(unless (or (cdr (assq 'inhibit-same-window alist)) (unless (or (cdr (assq 'inhibit-same-window alist))
(window-minibuffer-p) (window-minibuffer-p)
(window-dedicated-p)) (window-dedicated-p))
@ -7557,7 +7577,12 @@ Optional argument NORECORD, if non-nil means do not put this
buffer at the front of the list of recently selected ones. buffer at the front of the list of recently selected ones.
Unlike `pop-to-buffer', this function prefers using the selected Unlike `pop-to-buffer', this function prefers using the selected
window over popping up a new window or frame." window over popping up a new window or frame. Specifically, if
the selected window is neither a minibuffer window (as reported
by `window-minibuffer-p'), nor is dedicated to another buffer
(see `window-dedicated-p'), BUFFER will be displayed in the
currently selected window; otherwise it will be displayed in
another window."
(pop-to-buffer buffer display-buffer--same-window-action norecord)) (pop-to-buffer buffer display-buffer--same-window-action norecord))
(defun read-buffer-to-switch (prompt) (defun read-buffer-to-switch (prompt)