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

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

[nongnu] elpa/emacsql 031ec59f18 048/427: Add combine function to with-v


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 031ec59f18 048/427: Add combine function to with-vars macro.
Date: Tue, 13 Dec 2022 02:59:27 -0500 (EST)

branch: elpa/emacsql
commit 031ec59f18471b0511d3acc2d5fb97e4d2c03430
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Add combine function to with-vars macro.
---
 emacsql.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/emacsql.el b/emacsql.el
index 97d2638a52..faa727a17d 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -375,14 +375,22 @@ KIND should be :value or :identifier."
       (:auto (emacsql-escape-format
               thing (if (symbolp thing) :identifier :value))))))
 
+(defun emacsql--vars-combine (expanded)
+  "Only use within `emacsql-with-vars'!"
+  (cl-destructuring-bind (string . vars) expanded
+    (setf emacsql--vars (nconc emacsql--vars vars))
+    string))
+
 (defmacro emacsql-with-vars (prefix &rest body)
-  "Evaluate BODY, collecting variables with `var'.
+  "Evaluate BODY, collecting variables with `var' and `combine'.
 BODY should return a string, which will be combined with variable
 definitions for return from a `emacsql-defexpander'."
   (declare (indent 1))
   `(let ((emacsql--vars ()))
      (cl-letf (((emacsql-symbol-function 'var)
-                (symbol-function 'emacsql--vars-collect)))
+                (symbol-function 'emacsql--vars-collect))
+               ((emacsql-symbol-function 'combine)
+                (symbol-function 'emacsql--vars-combine)))
        (cons (concat ,prefix (progn ,@body)) emacsql--vars))))
 
 ;; SQL Expansion Functions:



reply via email to

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