branch: elpa/emacsql commit 031ec59f18471b0511d3acc2d5fb97e4d2c03430 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@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: