aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-09-24 18:07:02 +0300
committerEli Zaretskii2018-09-24 18:07:02 +0300
commit17766a14cc2c7fe51040f5d2dadfb8112f175dba (patch)
tree77e27a2d36749bddb8d8a8a17dd2e2f0951ad0db
parenta3639317bc9ba2bf2a92396970beb0ce9c3f446d (diff)
downloademacs-17766a14cc2c7fe51040f5d2dadfb8112f175dba.tar.gz
emacs-17766a14cc2c7fe51040f5d2dadfb8112f175dba.zip
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)
-rw-r--r--lisp/window.el81
1 files changed, 53 insertions, 28 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 2c0ea8e4d56..818bd3dd2bd 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -201,7 +201,7 @@ argument replaces this)."
201 201
202(defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body) 202(defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body)
203 "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer. 203 "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer.
204This construct is like `with-temp-buffer-window' but unlike that 204This construct is like `with-temp-buffer-window' but unlike that,
205makes the buffer specified by BUFFER-OR-NAME current for running 205makes the buffer specified by BUFFER-OR-NAME current for running
206BODY." 206BODY."
207 (declare (debug t)) 207 (declare (debug t))
@@ -224,7 +224,7 @@ BODY."
224 224
225(defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body) 225(defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body)
226 "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer. 226 "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer.
227This construct is like `with-current-buffer-window' but unlike that 227This construct is like `with-current-buffer-window' but unlike that,
228displays the buffer specified by BUFFER-OR-NAME before running BODY." 228displays the buffer specified by BUFFER-OR-NAME before running BODY."
229 (declare (debug t)) 229 (declare (debug t))
230 (let ((buffer (make-symbol "buffer")) 230 (let ((buffer (make-symbol "buffer"))
@@ -992,16 +992,16 @@ and may be called only if no window on SIDE exists yet."
992ALIST is an association list of symbols and values. The 992ALIST is an association list of symbols and values. The
993following special symbols can be used in ALIST. 993following special symbols can be used in ALIST.
994 994
995`side' denotes the side of the frame where the new window shall 995 `side' denotes the side of the frame where the new window shall
996 be located. Valid values are `bottom', `right', `top' and 996 be located. Valid values are `bottom', `right', `top' and
997 `left'. The default is `bottom'. 997 `left'. The default is `bottom'.
998 998
999`slot' if non-nil, specifies the window slot where to display 999 `slot' if non-nil, specifies the window slot where to display
1000 BUFFER. A value of zero or nil means use the middle slot on 1000 BUFFER. A value of zero or nil means use the middle slot on
1001 the specified side. A negative value means use a slot 1001 the specified side. A negative value means use a slot
1002 preceding (that is, above or on the left of) the middle slot. 1002 preceding (that is, above or on the left of) the middle slot.
1003 A positive value means use a slot following (that is, below or 1003 A positive value means use a slot following (that is, below or
1004 on the right of) the middle slot. The default is zero. 1004 on the right of) the middle slot. The default is zero.
1005 1005
1006If the current frame size or the settings of `window-sides-slots' 1006If the current frame size or the settings of `window-sides-slots'
1007do not permit making a new window, a suitable existing window may 1007do not permit making a new window, a suitable existing window may
@@ -6382,7 +6382,7 @@ See also `same-window-buffer-names'."
6382 :group 'windows) 6382 :group 'windows)
6383 6383
6384(defun same-window-p (buffer-name) 6384(defun same-window-p (buffer-name)
6385 "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window. 6385 "Return non-nil if buffer BUFFER-NAME would be shown in the \"same\" window.
6386This function returns non-nil if `display-buffer' or 6386This function returns non-nil if `display-buffer' or
6387`pop-to-buffer' would show a buffer named BUFFER-NAME in the 6387`pop-to-buffer' would show a buffer named BUFFER-NAME in the
6388selected rather than (as usual) some other window. See 6388selected 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
6820 "Custom type for `display-buffer' actions.") 6820 "Custom type for `display-buffer' actions.")
6821 6821
6822(defvar display-buffer-overriding-action '(nil . nil) 6822(defvar display-buffer-overriding-action '(nil . nil)
6823 "Overriding action to perform to display a buffer. 6823 "User-defined overriding action to perform to display a buffer.
6824It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a 6824This action overrides all the other actions in the action variables
6825function or a list of functions. Each function should accept two 6825and arguments passed to `display-buffer'.
6826arguments: a buffer to display and an alist similar to ALIST. 6826Value should be a cons cell (FUNCTION . ALIST), where FUNCTION is
6827a function or a list of functions. Each function should accept
6828two arguments: a buffer to display and an alist similar to ALIST.
6829The default value is empty.
6827See `display-buffer' for details.") 6830See `display-buffer' for details.")
6828(put 'display-buffer-overriding-action 'risky-local-variable t) 6831(put 'display-buffer-overriding-action 'risky-local-variable t)
6829 6832
6830(defcustom display-buffer-alist nil 6833(defcustom display-buffer-alist nil
6831 "Alist of conditional actions for `display-buffer'. 6834 "Alist of uder-defined conditional actions for `display-buffer'.
6832This is a list of elements (CONDITION . ACTION), where: 6835Its value takes effect before `display-buffer-base-action'
6836and `display-buffer-fallback-action', but after
6837`display-buffer-overriding-action', which see.
6838If non-nil, this is a list of elements (CONDITION . ACTION), where:
6833 6839
6834 CONDITION is either a regexp matching buffer names, or a 6840 CONDITION is either a regexp matching buffer names, or a
6835 function that takes two arguments - a buffer name and the 6841 function that takes two arguments - a buffer name and the
@@ -6855,9 +6861,13 @@ associated action to the list of actions it will try."
6855 6861
6856(defcustom display-buffer-base-action '(nil . nil) 6862(defcustom display-buffer-base-action '(nil . nil)
6857 "User-specified default action for `display-buffer'. 6863 "User-specified default action for `display-buffer'.
6864This is the default action used by `display-buffer' if no other
6865actions are specified or all fail, before falling back on
6866`display-buffer-fallback-action'.
6858It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a 6867It should be a cons cell (FUNCTION . ALIST), where FUNCTION is a
6859function or a list of functions. Each function should accept two 6868function or a list of functions. Each function should accept two
6860arguments: a buffer to display and an alist similar to ALIST. 6869arguments: a buffer to display and an alist similar to ALIST.
6870The default value is empty.
6861See `display-buffer' for details." 6871See `display-buffer' for details."
6862 :type display-buffer--action-custom-type 6872 :type display-buffer--action-custom-type
6863 :risky t 6873 :risky t
@@ -6875,12 +6885,16 @@ See `display-buffer' for details."
6875 "Default fallback action for `display-buffer'. 6885 "Default fallback action for `display-buffer'.
6876This is the action used by `display-buffer' if no other actions 6886This is the action used by `display-buffer' if no other actions
6877specified, e.g. by the user options `display-buffer-alist' or 6887specified, e.g. by the user options `display-buffer-alist' or
6878`display-buffer-base-action'. See `display-buffer'.") 6888`display-buffer-base-action', or they all fail. See `display-buffer'.")
6879(put 'display-buffer-fallback-action 'risky-local-variable t) 6889(put 'display-buffer-fallback-action 'risky-local-variable t)
6880 6890
6881(defun display-buffer-assq-regexp (buffer-name alist action) 6891(defun display-buffer-assq-regexp (buffer-name alist action)
6882 "Retrieve ALIST entry corresponding to BUFFER-NAME. 6892 "Retrieve ALIST entry corresponding to BUFFER-NAME.
6883ACTION is the action argument passed to `display-buffer'." 6893This returns the cdr of the ALIST entry if either its key is a
6894string that matches BUFFER-NAME, as reported by `string-match-p';
6895or if the key is a function that returns a non-nil when called
6896with 3 arguments: the ALIST key, BUFFER-NAME, and ACTION.
6897ACTION should have the form of the action argument passed to `display-buffer'."
6884 (catch 'match 6898 (catch 'match
6885 (dolist (entry alist) 6899 (dolist (entry alist)
6886 (let ((key (car entry))) 6900 (let ((key (car entry)))
@@ -6893,7 +6907,8 @@ ACTION is the action argument passed to `display-buffer'."
6893(defvar display-buffer--same-window-action 6907(defvar display-buffer--same-window-action
6894 '(display-buffer-same-window 6908 '(display-buffer-same-window
6895 (inhibit-same-window . nil)) 6909 (inhibit-same-window . nil))
6896 "A `display-buffer' action for displaying in the same window.") 6910 "A `display-buffer' action for displaying in the same window.
6911Specifies to call `display-buffer-same-window'.")
6897(put 'display-buffer--same-window-action 'risky-local-variable t) 6912(put 'display-buffer--same-window-action 'risky-local-variable t)
6898 6913
6899(defvar display-buffer--other-frame-action 6914(defvar display-buffer--other-frame-action
@@ -6901,7 +6916,9 @@ ACTION is the action argument passed to `display-buffer'."
6901 display-buffer-pop-up-frame) 6916 display-buffer-pop-up-frame)
6902 (reusable-frames . 0) 6917 (reusable-frames . 0)
6903 (inhibit-same-window . t)) 6918 (inhibit-same-window . t))
6904 "A `display-buffer' action for displaying in another frame.") 6919 "A `display-buffer' action for displaying in another frame.
6920Specifies to call `display-buffer-reuse-window', and if that
6921fails, call `display-buffer-pop-up-frame'.")
6905(put 'display-buffer--other-frame-action 'risky-local-variable t) 6922(put 'display-buffer--other-frame-action 'risky-local-variable t)
6906 6923
6907(defun display-buffer (buffer-or-name &optional action frame) 6924(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),
6922where FUNCTION is either a function or a list of functions, and 6939where FUNCTION is either a function or a list of functions, and
6923ALIST is an arbitrary association list (alist). 6940ALIST is an arbitrary association list (alist).
6924 6941
6925Each such FUNCTION should accept two arguments: the buffer to 6942Each such function should accept two arguments: the buffer to
6926display and an alist. Based on those arguments, it should 6943display and an alist. Based on those arguments, it should
6927display the buffer and return the window. If the caller is 6944display the buffer and return the window. If the caller is
6928prepared to handle the case of not displaying the buffer 6945prepared to handle the case of not displaying the buffer
@@ -7046,6 +7063,9 @@ argument, ACTION is t."
7046 7063
7047(defun display-buffer-other-frame (buffer) 7064(defun display-buffer-other-frame (buffer)
7048 "Display buffer BUFFER preferably in another frame. 7065 "Display buffer BUFFER preferably in another frame.
7066This function attempts to look for a window displaying BUFFER,
7067on all the frames on the current terminal, skipping the selected
7068window; if that fails, it pops up a new frame.
7049This uses the function `display-buffer' as a subroutine; see 7069This uses the function `display-buffer' as a subroutine; see
7050its documentation for additional customization information." 7070its documentation for additional customization information."
7051 (interactive "BDisplay buffer in other frame: ") 7071 (interactive "BDisplay buffer in other frame: ")
@@ -7089,10 +7109,10 @@ that allows the selected frame)."
7089 7109
7090(defun display-buffer-same-window (buffer alist) 7110(defun display-buffer-same-window (buffer alist)
7091 "Display BUFFER in the selected window. 7111 "Display BUFFER in the selected window.
7092This fails if ALIST has a non-nil `inhibit-same-window' entry, or 7112This fails if ALIST has an `inhibit-same-window' element whose
7093if the selected window is a minibuffer window or is dedicated to 7113value is non-nil, or if the selected window is a minibuffer
7094another buffer; in that case, return nil. Otherwise, return the 7114window or is dedicated to another buffer; in that case, return nil.
7095selected window." 7115Otherwise, return the selected window."
7096 (unless (or (cdr (assq 'inhibit-same-window alist)) 7116 (unless (or (cdr (assq 'inhibit-same-window alist))
7097 (window-minibuffer-p) 7117 (window-minibuffer-p)
7098 (window-dedicated-p)) 7118 (window-dedicated-p))
@@ -7557,7 +7577,12 @@ Optional argument NORECORD, if non-nil means do not put this
7557buffer at the front of the list of recently selected ones. 7577buffer at the front of the list of recently selected ones.
7558 7578
7559Unlike `pop-to-buffer', this function prefers using the selected 7579Unlike `pop-to-buffer', this function prefers using the selected
7560window over popping up a new window or frame." 7580window over popping up a new window or frame. Specifically, if
7581the selected window is neither a minibuffer window (as reported
7582by `window-minibuffer-p'), nor is dedicated to another buffer
7583(see `window-dedicated-p'), BUFFER will be displayed in the
7584currently selected window; otherwise it will be displayed in
7585another window."
7561 (pop-to-buffer buffer display-buffer--same-window-action norecord)) 7586 (pop-to-buffer buffer display-buffer--same-window-action norecord))
7562 7587
7563(defun read-buffer-to-switch (prompt) 7588(defun read-buffer-to-switch (prompt)