diff options
| author | Philip Kaludercic | 2022-04-17 01:11:06 +0200 |
|---|---|---|
| committer | Philip Kaludercic | 2022-04-17 14:04:44 +0200 |
| commit | b5f70c239e87e5f38fd70181ef75cd28a43a8b41 (patch) | |
| tree | 60b32666643ef40e8826cc4c16487328b7048560 | |
| parent | 5be9a9cacfaae1959c4b95c45c146044a181ad20 (diff) | |
| download | emacs-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.texi | 50 | ||||
| -rw-r--r-- | etc/NEWS | 6 |
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 | |||
| 953 | infinite recursion. | 953 | infinite recursion. |
| 954 | @end defvar | 954 | @end defvar |
| 955 | 955 | ||
| 956 | @defun buffer-match-p condition buffer-or-name &optional arg | ||
| 957 | This function checks if a buffer designated by @code{buffer-or-name} | ||
| 958 | satisfies a @code{condition}. Optional third argument @var{arg} is | ||
| 959 | passed to the predicate function in @var{condition}. A condition can | ||
| 960 | be one of the following: | ||
| 961 | @itemize @bullet{} | ||
| 962 | @item | ||
| 963 | A string, interpreted as a regular expression. The buffer | ||
| 964 | satisfies the condition if the regular expression matches the buffer | ||
| 965 | name. | ||
| 966 | @item | ||
| 967 | A predicate function, which should return non-@code{nil} if the buffer | ||
| 968 | matches. If the function expects one argument, it is called with | ||
| 969 | @var{buffer-or-name} as the argument; if it expects 2 arguments, the | ||
| 970 | first argument is @var{buffer-or-name} and the second is @var{arg} | ||
| 971 | (or @code{nil} if @var{arg} is omitted). | ||
| 972 | @item | ||
| 973 | A cons-cell @code{(@var{oper} . @var{expr})} where @var{oper} is one | ||
| 974 | of | ||
| 975 | @table @code | ||
| 976 | @item not | ||
| 977 | Satisfied if @var{expr} doesn't satisfy @code{buffer-match-p} with | ||
| 978 | the same buffer and @code{arg}. | ||
| 979 | @item or | ||
| 980 | Satisfied 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 | ||
| 984 | Satisfied 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 | ||
| 992 | This function returns a list of all buffers that satisfy a | ||
| 993 | @code{condition}, as defined for @code{buffer-match-p}. By default | ||
| 994 | all buffers are considered, but this can be restricted via the second | ||
| 995 | optional @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 |
| 963 | with the specified name; @code{generate-new-buffer} always creates a new | 1007 | buffer with the specified name; @code{generate-new-buffer} always |
| 964 | buffer and gives it a unique name. | 1008 | creates 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}. |
| 967 | If it is non-@code{nil}, the buffer they create does not run the hooks | 1011 | If it is non-@code{nil}, the buffer they create does not run the hooks |
| @@ -1548,7 +1548,11 @@ This hook is run before 'x-popup-menu' is about to display a | |||
| 1548 | deck-of-cards menu on screen. | 1548 | deck-of-cards menu on screen. |
| 1549 | 1549 | ||
| 1550 | ** New function 'buffer-match-p' | 1550 | ** New function 'buffer-match-p' |
| 1551 | Check if a buffer matches a condition, specified using a DSL. | 1551 | Check if a buffer satisfies some condition. Some examples for |
| 1552 | conditions can be regular expressions that match a buffer name, a | ||
| 1553 | cons-cell like (major-mode . shell-mode) that matches any buffer where | ||
| 1554 | major-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' |
| 1554 | Use 'buffer-match-p' to gather a list of buffers that match a | 1558 | Use 'buffer-match-p' to gather a list of buffers that match a |