[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 54917a0 2/3: lint: Update macro checks
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 54917a0 2/3: lint: Update macro checks |
Date: |
Fri, 16 Apr 2021 10:57:17 -0400 (EDT) |
branch: externals/org
commit 54917a0d739314671580a50ea58df904c8899ae1
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
lint: Update macro checks
* lisp/org-lint.el (org-lint-invalid-macro-argument-and-template):
Ignore `eval' macros when checking spurious placeholders.
---
lisp/org-lint.el | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 1380f782..db651a5 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -731,25 +731,30 @@ Use \"export %s\" instead"
(lambda (macro)
(let* ((name (org-element-property :key macro))
(template (cdr (assoc-string name templates t))))
- (if (not template)
- (push (list (org-element-property :begin macro)
- (format "Undefined macro \"%s\"" name))
- reports)
- (let ((arg-numbers (funcall extract-placeholders template)))
- (when arg-numbers
- (let ((spurious-args
- (nthcdr (apply #'max arg-numbers)
- (org-element-property :args macro))))
- (when spurious-args
- (push
- (list (org-element-property :begin macro)
- (format "Unused argument%s in macro \"%s\": %s"
- (if (> (length spurious-args) 1) "s" "")
- name
- (mapconcat (lambda (a) (format "\"%s\"" a))
- spurious-args
- ", ")))
- reports))))))))))
+ (pcase template
+ (`nil
+ (push (list (org-element-property :begin macro)
+ (format "Undefined macro %S" name))
+ reports))
+ ((pred functionp) nil) ;ignore it
+ (_
+ (let ((arg-numbers (funcall extract-placeholders template)))
+ (when arg-numbers
+ (let ((spurious-args
+ (nthcdr (apply #'max arg-numbers)
+ (org-element-property :args macro))))
+ (when spurious-args
+ (push
+ (list (org-element-property :begin macro)
+ (pcase spurious-args
+ (`(,arg)
+ (format "Unused argument in macro %S: %s"
+ name arg))
+ (args
+ (format "Unused arguments in macro %S: %s"
+ name
+ (mapconcat #'org-trim spurious-args
", ")))))
+ reports)))))))))))
reports))
(defun org-lint-undefined-footnote-reference (ast)