[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 4718ff4e89 122/427: Simplify all the expanders wit
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 4718ff4e89 122/427: Simplify all the expanders with new local functions. |
Date: |
Tue, 13 Dec 2022 02:59:34 -0500 (EST) |
branch: elpa/emacsql
commit 4718ff4e899a7ce9bd9a662c2ae083e99a128d6a
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Simplify all the expanders with new local functions.
---
emacsql.el | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/emacsql.el b/emacsql.el
index 20b04eb632..9b428ab93f 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -401,13 +401,6 @@ KIND should be :value or :identifier."
(defvar emacsql--vars ()
"For use with `emacsql-with-vars'.")
-(defun emacsql-symbol-function (symbol)
- "Like `symbol-function' but don't return an error."
- (ignore-errors (symbol-function symbol)))
-
-(gv-define-setter emacsql-symbol-function (store symbol)
- `(if ,store (fset ,symbol ,store) (fmakunbound ,symbol)))
-
(defun emacsql--vars-var (thing kind)
"Only use within `emacsql-with-vars'!"
(if (emacsql-var thing)
@@ -424,20 +417,17 @@ KIND should be :value or :identifier."
string))
(defmacro emacsql-with-vars (prefix &rest body)
- "Evaluate BODY, collecting variables with `var' and `combine'.
+ "Evaluate BODY, collecting variables with `var', `combine', `expr', `idents'.
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-var))
- ((emacsql-symbol-function 'combine)
- (symbol-function 'emacsql--vars-combine)))
+ (cl-flet* ((var (thing kind) (emacsql--vars-var thing kind))
+ (combine (expanded) (emacsql--vars-combine expanded))
+ (expr (thing) (combine (emacsql--expr thing)))
+ (idents (thing) (combine (emacsql--idents thing))))
(cons (concat ,prefix (progn ,@body)) emacsql--vars))))
-(declare-function combine nil (expanded))
-(declare-function var nil (thing kind))
-
(defun emacsql--vector (vector)
"Expand VECTOR, making variables as needed."
(emacsql-with-vars ""
@@ -499,8 +489,7 @@ definitions for return from a `emacsql-defexpander'."
(emacsql-with-vars ""
(cl-etypecase idents
(symbol (var idents :identifier))
- (vector (mapconcat (lambda (e) (combine (emacsql--expr e)))
- idents ", ")))))
+ (vector (mapconcat (lambda (e) (expr e)) idents ", ")))))
(defun emacsql-init-font-lock ()
"Add font-lock highlighting for `emacsql-defexpander'."
@@ -516,7 +505,7 @@ definitions for return from a `emacsql-defexpander'."
(emacsql-with-vars "SELECT "
(if (eq '* arg)
"*"
- (combine (emacsql--idents arg)))))
+ (idents arg))))
(emacsql-defexpander :from (table)
"Expands to the FROM keyword."
@@ -536,15 +525,15 @@ definitions for return from a `emacsql-defexpander'."
(symbol (var table :identifier))
(list (cl-destructuring-bind (name columns) table
(format "%s (%s)" (var name :identifier)
- (combine (emacsql--idents columns))))))))
+ (idents columns)))))))
(emacsql-defexpander :where (expr)
(emacsql-with-vars "WHERE "
- (combine (emacsql--expr expr))))
+ (expr expr)))
(emacsql-defexpander :group-by (expr)
(emacsql-with-vars "GROUP BY "
- (combine (emacsql--expr expr))))
+ (expr expr)))
(emacsql-defexpander :ascending-by (columns)
(emacsql-with-vars "ORDER BY "
@@ -585,8 +574,8 @@ definitions for return from a `emacsql-defexpander'."
(emacsql-defexpander :set (set)
(emacsql-with-vars "SET "
(cl-etypecase set
- (vector (combine (emacsql--idents set)))
- (list (combine (emacsql--expr set))))))
+ (vector (idents set))
+ (list (expr set)))))
(emacsql-defexpander :union ()
(list "UNION"))
- [nongnu] elpa/emacsql b3110c9fa9 018/427: Rename .sqlite to .db., (continued)
- [nongnu] elpa/emacsql b3110c9fa9 018/427: Rename .sqlite to .db., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 031ec59f18 048/427: Add combine function to with-vars macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f9820deed7 056/427: Add unary operators., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f9c562b0a4 069/427: Add SQLite link., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 43ecb5a252 071/427: Tweak README names., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 58e31aa3a9 079/427: Add :update and :set expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c9aab20d47 082/427: Add in operator (special case operator)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 25f9817064 094/427: Add work-in-progress note back., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 03295cba37 119/427: Add ORDER BY expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d1c0904564 120/427: Fix missing quotes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4718ff4e89 122/427: Simplify all the expanders with new local functions.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 54247e4b5e 127/427: Add another insertion unit test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql aa9283ca0a 132/427: Allow sub-selects with :from., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c236aa8437 144/427: Remove extra space., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 75ea77c9a0 149/427: Add an "as" operator, greatly simplifying :from., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 213bb71b7a 152/427: Add :having expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8123020ca7 153/427: Make and and or operators variadic., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 76bf0c34dc 038/427: Add rudimentary :where expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql afe64ca63a 040/427: Fix emacsql-add-expander example., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72145a1627 045/427: Allow for multi-arity keyword expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f54142f1eb 062/427: Argument list checking in emacsql-format., ELPA Syncer, 2022/12/13