[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 74d2701d78: Cleanup: sanity checks for with-advic
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 74d2701d78: Cleanup: sanity checks for with-advice macro |
Date: |
Sun, 16 Jun 2024 22:01:07 -0400 (EDT) |
branch: elpa/spell-fu
commit 74d2701d78c1759074566f150d96a3596072359a
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Cleanup: sanity checks for with-advice macro
---
spell-fu.el | 48 +++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/spell-fu.el b/spell-fu.el
index 4543a54f88..5792612fdb 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -393,28 +393,38 @@ PROMPT is shown to the users completing read."
Advice are triplets of (SYMBOL HOW FUNCTION),
see `advice-add' documentation."
(declare (indent 1))
- (let ((body-let nil)
+ (let ((advice-list advice)
+ (body-let nil)
(body-advice-add nil)
(body-advice-remove nil)
(item nil))
- (while (setq item (pop advice))
- (let ((fn-sym (gensym))
- (fn-advise (pop item))
- (fn-advice-ty (pop item))
- (fn-body (pop item)))
- ;; Build the calls for each type.
- (push (list fn-sym fn-body) body-let)
- (push (list 'advice-add fn-advise fn-advice-ty fn-sym) body-advice-add)
- (push (list 'advice-remove fn-advise fn-sym) body-advice-remove)))
- (setq body-let (nreverse body-let))
- (setq body-advice-add (nreverse body-advice-add))
- ;; Compose the call.
- `(let ,body-let
- (unwind-protect
- (progn
- ,@body-advice-add
- ,@body)
- ,@body-advice-remove))))
+ (unless (listp advice-list)
+ (error "Advice must be a list"))
+ (cond
+ ((null advice-list)
+ (error "Advice must be a list containing at least one item"))
+ (t
+ (while (setq item (pop advice-list))
+ (unless (and (listp item) (eq 3 (length item)))
+ (error "Each advice must be a list of 3 items"))
+ (let ((fn-sym (gensym))
+ (fn-advise (pop item))
+ (fn-advice-ty (pop item))
+ (fn-body (pop item)))
+ ;; Build the calls for each type.
+ (push (list fn-sym fn-body) body-let)
+ (push (list 'advice-add fn-advise fn-advice-ty fn-sym)
body-advice-add)
+ (push (list 'advice-remove fn-advise fn-sym) body-advice-remove)))
+ (setq body-let (nreverse body-let))
+ (setq body-advice-add (nreverse body-advice-add))
+
+ ;; Compose the call.
+ `(let ,body-let
+ (unwind-protect
+ (progn
+ ,@body-advice-add
+ ,@body)
+ ,@body-advice-remove))))))
(defmacro spell-fu--with-message-prefix (prefix &rest body)
"Add text before the message output.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/spell-fu 74d2701d78: Cleanup: sanity checks for with-advice macro,
ELPA Syncer <=