aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Kaludercic2022-04-17 01:11:06 +0200
committerPhilip Kaludercic2022-04-17 14:04:44 +0200
commitb5f70c239e87e5f38fd70181ef75cd28a43a8b41 (patch)
tree60b32666643ef40e8826cc4c16487328b7048560
parent5be9a9cacfaae1959c4b95c45c146044a181ad20 (diff)
downloademacs-b5f70c239e87e5f38fd70181ef75cd28a43a8b41.tar.gz
emacs-b5f70c239e87e5f38fd70181ef75cd28a43a8b41.zip
Further improve buffer-match-p related documentation
* doc/lispref/buffers.texi (Buffer List): Add entries for * buffer-match-p and match-buffers * etc/NEWS: Give examples for buffer-match-p conditions * lisp/window.el (display-buffer-assq-regexp): Mention what happens when no entry in the alist satisfies a condition.
-rw-r--r--doc/lispref/buffers.texi50
-rw-r--r--etc/NEWS6
2 files changed, 52 insertions, 4 deletions
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 1fe5a60b356..d8cf3d7919b 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -953,15 +953,59 @@ with a @code{nil} @var{norecord} argument since this may lead to
953infinite recursion. 953infinite recursion.
954@end defvar 954@end defvar
955 955
956@defun buffer-match-p condition buffer-or-name &optional arg
957This function checks if a buffer designated by @code{buffer-or-name}
958satisfies a @code{condition}. Optional third argument @var{arg} is
959passed to the predicate function in @var{condition}. A condition can
960be one of the following:
961@itemize @bullet{}
962@item
963A string, interpreted as a regular expression. The buffer
964satisfies the condition if the regular expression matches the buffer
965name.
966@item
967A predicate function, which should return non-@code{nil} if the buffer
968matches. If the function expects one argument, it is called with
969@var{buffer-or-name} as the argument; if it expects 2 arguments, the
970first argument is @var{buffer-or-name} and the second is @var{arg}
971(or @code{nil} if @var{arg} is omitted).
972@item
973A cons-cell @code{(@var{oper} . @var{expr})} where @var{oper} is one
974of
975@table @code
976@item not
977Satisfied if @var{expr} doesn't satisfy @code{buffer-match-p} with
978the same buffer and @code{arg}.
979@item or
980Satisfied if @var{oper} is a list and @emph{any} condition if
981@var{expr} satisfies @code{buffer-match-p}, with the same buffer and
982@code{arg}.
983@item and
984Satisfied if @var{oper} is a list and @emph{all} condition if
985@var{expr} satisfies @code{buffer-match-p}, with the same buffer and
986@code{arg}.
987@end table
988@end itemize
989@end defun
990
991@defun match-buffers condition &optional buffer-list arg
992This function returns a list of all buffers that satisfy a
993@code{condition}, as defined for @code{buffer-match-p}. By default
994all buffers are considered, but this can be restricted via the second
995optional @code{buffer-list} argument. Optional third argument
996@var{arg} will be used by @var{condition} in the same way as
997@code{buffer-match-p} does.
998@end defun
999
956@node Creating Buffers 1000@node Creating Buffers
957@section Creating Buffers 1001@section Creating Buffers
958@cindex creating buffers 1002@cindex creating buffers
959@cindex buffers, creating 1003@cindex buffers, creating
960 1004
961 This section describes the two primitives for creating buffers. 1005 This section describes the two primitives for creating buffers.
962@code{get-buffer-create} creates a buffer if it finds no existing buffer 1006@code{get-buffer-create} creates a buffer if it finds no existing
963with the specified name; @code{generate-new-buffer} always creates a new 1007buffer with the specified name; @code{generate-new-buffer} always
964buffer and gives it a unique name. 1008creates a new buffer and gives it a unique name.
965 1009
966 Both functions accept an optional argument @var{inhibit-buffer-hooks}. 1010 Both functions accept an optional argument @var{inhibit-buffer-hooks}.
967If it is non-@code{nil}, the buffer they create does not run the hooks 1011If it is non-@code{nil}, the buffer they create does not run the hooks
diff --git a/etc/NEWS b/etc/NEWS
index 0245ec8c689..071fdd7aee9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1548,7 +1548,11 @@ This hook is run before 'x-popup-menu' is about to display a
1548deck-of-cards menu on screen. 1548deck-of-cards menu on screen.
1549 1549
1550** New function 'buffer-match-p' 1550** New function 'buffer-match-p'
1551Check if a buffer matches a condition, specified using a DSL. 1551Check if a buffer satisfies some condition. Some examples for
1552conditions can be regular expressions that match a buffer name, a
1553cons-cell like (major-mode . shell-mode) that matches any buffer where
1554major-mode is shell-mode or a combined with a condition like (and
1555"\\`\\*.+\\*\\'" (major-mode . special-mode)).
1552 1556
1553** New function 'match-buffers' 1557** New function 'match-buffers'
1554Use 'buffer-match-p' to gather a list of buffers that match a 1558Use 'buffer-match-p' to gather a list of buffers that match a