diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-16 14:36:29 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-16 14:36:29 +0200 |
commit | 169db5f0d95bac2bf9a06918633e91cfbac71408 (patch) | |
tree | 98f50e33f0648c4c33367bbb6cebe999e225a912 | |
parent | d015606e5bbcc7b5503a7d0a2d329709eee1beb5 (diff) | |
download | org-mode-169db5f0d95bac2bf9a06918633e91cfbac71408.tar.gz |
org-lint: Fix wrong-number-of-arguments error
* lisp/org-lint.el (org-lint-invalid-macro-argument-and-template):
Handle macros without any placeholder.
Reported-by: Thomas S. Dye <tsd@tsdye.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/101207>
-rw-r--r-- | lisp/org-lint.el | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 5271dfb..ea29d66 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -611,7 +611,7 @@ Use :header-args: instead" reports)) (t (unless (let ((args (funcall extract-placeholders template))) - (equal (number-sequence 1 (org-last args)) args)) + (equal (number-sequence 1 (or (org-last args) 0)) args)) (push (list (org-element-property :post-affiliated k) (format "Unused placeholders in macro \"%s\"" name)) @@ -630,19 +630,21 @@ Use :header-args: instead" (push (list (org-element-property :begin macro) (format "Undefined macro \"%s\"" name)) reports) - (let ((spurious-args - (nthcdr (apply #'max - (funcall extract-placeholders template)) - (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)))))))) + (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)))))))))) reports)) (defun org-lint-undefined-footnote-reference (ast) |