diff options
| author | Matthew White <mehw.is.me@inventati.org> | 2021-08-13 12:49:30 +0000 |
|---|---|---|
| committer | Matthew White <mehw.is.me@inventati.org> | 2021-10-20 23:01:53 +0200 |
| commit | e03a9876c85f9cf0466e6f867bfeaadffca63a11 (patch) | |
| tree | ca84de4e3e75342345ec1dab4e9b4d4eb2f9c8ec /test | |
| parent | 7a8023c79b19bf66e15a9201430cacc00725ae79 (diff) | |
persp-test-match-scratch-buffers: ert list live scratch buffers
New utility function to return a list of live buffers where all may be
considered scratch buffers. Basically, buffers whose name begins with
the string "*scratch*".
Diffstat (limited to 'test')
| -rw-r--r-- | test/test-perspective.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test-perspective.el b/test/test-perspective.el index 88fd181..e91ce0a 100644 --- a/test/test-perspective.el +++ b/test/test-perspective.el @@ -38,6 +38,26 @@ perspectives), filtering out temporaries." filtering out temporaries." (cl-remove-if-not #'persp-test-interesting-buffer? (persp-buffers persp))) +(defun persp-test-match-scratch-buffers (&rest buffer-or-name) + "Return a list of buffers that are considered *scratch* buffers. +If not nil, verify that BUFFER-OR-NAME are all the buffers that +are in the list of buffers or return nil otherwise. Return nil +if there are no *scratch* buffers to be found. + +Consider buffers being *scratch* buffers when their name begins +with \"*scratch*\". Sort the list by names via `string-lessp'." + (let ((scratch-buffers (mapcar #'get-buffer buffer-or-name)) + (matched-buffers (cl-remove-if-not + (lambda (buffer) + (string-match-p "^\\*scratch\\*.*$" (buffer-name buffer))) + (buffer-list)))) + (when (cl-every (lambda (buffer) + (memq buffer matched-buffers)) + scratch-buffers) + (sort matched-buffers + (lambda (a b) + (string-lessp (buffer-name a) (buffer-name b))))))) + (defmacro persp-test-with-persp (&rest body) "Allow multiple tests to run with reasonable assumption of isolation. This macro assumes persp-mode is turned off, then |
