branch: elpa/emacsql
commit 6c32f02139d54b989be62fb530ff2e73899ceb74
Author: Christopher Wellons <[email protected]>
Commit: Christopher Wellons <[email protected]>
Add emacsql-thread macro.
---
emacsql.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/emacsql.el b/emacsql.el
index a1986e2e19..6e44c2a2bd 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -161,6 +161,17 @@ CONN-SPEC is a connection specification like the call to
(progn ,@body)
(emacsql-close ,(car conn-spec)))))
+(defmacro emacsql-thread (conn &rest statements)
+ "Thread CONN through STATEMENTS.
+A statement can be a list, containing a statement with its arguments."
+ (declare (indent 1))
+ `(let ((emacsql--conn ,conn))
+ ,@(cl-loop for statement in statements
+ when (vectorp statement)
+ collect (list 'emacsql 'emacsql--conn statement)
+ else
+ collect (append (list 'emacsql 'emacsql--conn) statement))))
+
(defun emacsql-buffer (conn)
"Get proccess buffer for CONN."
(process-buffer (emacsql-process conn)))