emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/assess 33b6c3c390 12/95: New macro `sisyphus-with-temp-


From: ELPA Syncer
Subject: [elpa] externals/assess 33b6c3c390 12/95: New macro `sisyphus-with-temp-buffers'.
Date: Tue, 19 Jul 2022 15:57:29 -0400 (EDT)

branch: externals/assess
commit 33b6c3c390dfb5c2dd625af115bb34f385f06fc9
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    New macro `sisyphus-with-temp-buffers'.
---
 sisyphus.el           | 17 +++++++++++++++--
 test/sisyphus-test.el |  5 +++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sisyphus.el b/sisyphus.el
index 2ad29d7e06..642ce10e14 100644
--- a/sisyphus.el
+++ b/sisyphus.el
@@ -238,8 +238,21 @@ print any messages!"
         (-difference (buffer-list)
                      before-buffer-list)))))
 
-
-
+(defmacro sisyphus-with-temp-buffers (varlist &rest body)
+  "Bind variables in VARLIST to temp buffers, then eval BODY.
+
+VARLIST is a list of symbols. Each is bound to a buffer generated
+with `generate-new-buffer'. Buffers are unconditionally killed at
+the end of the form."
+  (declare (indent 1)
+           (debug (sexp body)))
+  (let ((let-form
+         (--map
+          `(,it (generate-new-buffer "sisyphus-with-temp-buffers"))
+          varlist)))
+    `(sisyphus-with-preserved-buffer-list
+      (let ,let-form
+        ,@body))))
 
 ;; ** Open files
 
diff --git a/test/sisyphus-test.el b/test/sisyphus-test.el
index 57c4239832..b83e561f54 100644
--- a/test/sisyphus-test.el
+++ b/test/sisyphus-test.el
@@ -172,3 +172,8 @@ This also tests the advice on string=."
          (signal 'deliberate-error nil))
       (deliberate-error
        (length (buffer-list)))))))
+
+(ert-deftest with-temp-buffers ()
+  (should
+   (bufferp
+    (sisyphus-with-temp-buffers (a) a))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]