aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew White <mehw.is.me@inventati.org>2021-08-03 00:24:05 +0000
committerMatthew White <mehw.is.me@inventati.org>2021-10-20 23:01:53 +0200
commit34f7348673e3db10ca22d06c62e8c85835012568 (patch)
tree0078beb91046b7aac869386f9f267ff1e8af0fd2 /test
parentd6c7e5e04525fbfaaca6411c144a6dba9415d0f8 (diff)
persp-test-with-persp: kill other perspectives before buffers
Kill other perspectives than the main perspective before cleaning up the buffers. This is to get rid of buffers that aren't found in the main perspective.
Diffstat (limited to 'test')
-rw-r--r--test/test-perspective.el26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/test-perspective.el b/test/test-perspective.el
index a8a847a..73b13eb 100644
--- a/test/test-perspective.el
+++ b/test/test-perspective.el
@@ -47,17 +47,23 @@ perspectives and open buffers."
`(progn
(persp-mode 1)
,@body
- ;; get rid of perspective-specific *scratch* buffers first
- (mapc (lambda (persp)
- ;; `get-buffer' should suffice here, there's no need to
- ;; also call `buffer-live-p' when a string is passed as
- ;; argument to the former, but we do it anyway ;)
- (let* ((scratch-name (format "*scratch* (%s)" persp))
- (scratch-buffer (get-buffer scratch-name)))
- (when (buffer-live-p scratch-buffer)
- (kill-buffer scratch-buffer))))
- (delete persp-initial-frame-name (persp-names)))
+ (let ((other-persps (delete persp-initial-frame-name (persp-names))))
+ ;; Kill other perspectives than the main perspective to get rid
+ ;; of buffers that are not found in the main perspective.
+ (mapc #'persp-kill other-persps)
+ ;; Then get rid of perspective-specific *scratch* buffers which
+ ;; have become part of the main perspective.
+ (mapc (lambda (persp)
+ ;; `get-buffer' should suffice here, there's no need to
+ ;; also call `buffer-live-p' when a string is passed as
+ ;; argument to the former, but we do it anyway ;)
+ (let* ((scratch-name (format "*scratch* (%s)" persp))
+ (scratch-buffer (get-buffer scratch-name)))
+ (when (buffer-live-p scratch-buffer)
+ (kill-buffer scratch-buffer))))
+ other-persps))
(persp-mode -1)
+ ;; Remove live buffers that are not temporaries.
(mapc #'kill-buffer (persp-test-buffer-list-all))))
(defmacro persp-test-with-temp-buffers (vars &rest body)