[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/assess af8b3a8d8b 14/95: with-temp-buffers now works li
From: |
ELPA Syncer |
Subject: |
[elpa] externals/assess af8b3a8d8b 14/95: with-temp-buffers now works like let. |
Date: |
Tue, 19 Jul 2022 15:57:29 -0400 (EDT) |
branch: externals/assess
commit af8b3a8d8bb083b6f225ee94ce5bf411f1755050
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
with-temp-buffers now works like let.
It is now possible to evaluate forms within the context of each
generated temp buffer inside the `sisyphus-with-temp-buffers' form.
---
sisyphus.el | 24 ++++++++++++++++++------
test/sisyphus-test.el | 26 +++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/sisyphus.el b/sisyphus.el
index 5a09f643ff..356f89ac61 100644
--- a/sisyphus.el
+++ b/sisyphus.el
@@ -239,17 +239,29 @@ print any messages!"
(-difference (buffer-list)
before-buffer-list)))))
+(defun sisyphus--temp-buffer-let-form (item)
+ (if (not (listp item))
+ (sisyphus--temp-buffer-let-form
+ (list item))
+ `(,(car item)
+ (with-current-buffer
+ (generate-new-buffer "sisyphus-with-temp-buffers")
+ ,@(cdr item)
+ (current-buffer)))))
+
(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."
+VARLIST is of the same form as a `let' binding. Each element is a
+symbol or a list (SYMBOL VALUEFORMS). Each symbol is bound to a
+buffer generated with `generate-new-buffer'. VALUEFORMS are
+evaluated with the buffer current. Buffers are unconditionally
+killed at the end of the form."
(declare (indent 1)
- (debug (sexp body)))
+ (debug let))
(let ((let-form
- (--map
- `(,it (generate-new-buffer "sisyphus-with-temp-buffers"))
+ (-map
+ #'sisyphus--temp-buffer-let-form
varlist)))
`(sisyphus-with-preserved-buffer-list
(let ,let-form
diff --git a/test/sisyphus-test.el b/test/sisyphus-test.el
index b83e561f54..74dd11a69c 100644
--- a/test/sisyphus-test.el
+++ b/test/sisyphus-test.el
@@ -176,4 +176,28 @@ This also tests the advice on string=."
(ert-deftest with-temp-buffers ()
(should
(bufferp
- (sisyphus-with-temp-buffers (a) a))))
+ (sisyphus-with-temp-buffers (a) a)))
+ (should
+ (bufferp
+ (sisyphus-with-temp-buffers
+ (a (insert "hello"))
+ a)))
+ (should
+ (equal
+ "hello"
+ (sisyphus-with-temp-buffers
+ ((a (insert "hello")))
+ (with-current-buffer
+ a
+ (buffer-string)))))
+ (should
+ (=
+ (+ 2 (length (buffer-list)))
+ (sisyphus-with-temp-buffers (a b)
+ (length (buffer-list)))))
+ (should
+ (=
+ (length (buffer-list))
+ (progn
+ (sisyphus-with-temp-buffers (a b))
+ (length (buffer-list))))))
- [elpa] branch externals/assess created (now 44083d94fe), ELPA Syncer, 2022/07/19
- [elpa] externals/assess 41a297b066 01/95: Initial Checkin, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 8eb105f351 02/95: Travis Build status, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 3d659897df 03/95: Require cl-lib, local emacs test override., ELPA Syncer, 2022/07/19
- [elpa] externals/assess af38180b77 10/95: buffer= and file-string= functions added., ELPA Syncer, 2022/07/19
- [elpa] externals/assess eb3336543c 13/95: declare debug for `sisyphus-with-preserved-buffer-list'., ELPA Syncer, 2022/07/19
- [elpa] externals/assess af8b3a8d8b 14/95: with-temp-buffers now works like let.,
ELPA Syncer <=
- [elpa] externals/assess 238d9028e2 19/95: Support for indentation checking., ELPA Syncer, 2022/07/19
- [elpa] externals/assess b3f9a7cf97 04/95: Require cl-lib, local emacs test override., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 196470b1e1 08/95: New function buffer-string=, ELPA Syncer, 2022/07/19
- [elpa] externals/assess dae3a60f7a 09/95: Docstring fix., ELPA Syncer, 2022/07/19
- [elpa] externals/assess c6e666413a 21/95: Merge branch 'master' of github.com:phillord/sisyphus, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 83973f4047 23/95: Add dash as a dependency., ELPA Syncer, 2022/07/19
- [elpa] externals/assess f33b371177 25/95: Specify minimum dash version, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 3e74c4b70d 30/95: Add test for string font-lock comparison., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 6a4aa34ec3 33/95: Fixed multiple string matching for face match., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 5dde98a124 31/95: Merge branch 'master' of github.com:phillord/sisyphus, ELPA Syncer, 2022/07/19