diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2021-04-16 16:37:29 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2021-04-16 16:37:29 +0200 |
commit | 54917a0d739314671580a50ea58df904c8899ae1 (patch) | |
tree | 24d7e1bf773583443c555817aca905cdc20e377a | |
parent | 8abdbbee395f284f2262a89187d662eaf40080b1 (diff) | |
download | org-mode-54917a0d739314671580a50ea58df904c8899ae1.tar.gz |
lint: Update macro checks
* lisp/org-lint.el (org-lint-invalid-macro-argument-and-template):
Ignore `eval' macros when checking spurious placeholders.
-rw-r--r-- | lisp/org-lint.el | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 1380f78..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) |