1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

org-lint: Add checker for misspelled export options in properties

* lisp/org-lint.el (org-lint-export-option-keywords): New linter
checking export properties without EXPORT_.

Link: https://orgmode.org/list/87ttv7kp2j.fsf@k-7.ch
This commit is contained in:
Ihor Radchenko 2023-06-17 15:07:02 +03:00
parent 739c8989a7
commit 1ec3a43c58
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -742,6 +742,29 @@ Use \"export %s\" instead"
reports))))))))
reports))
(defun org-lint-export-option-keywords (ast)
"Check for options keyword properties without EXPORT_."
(require 'ox)
(let (options reports)
(dolist (opt org-export-options-alist)
(when (stringp (nth 1 opt))
(cl-pushnew (nth 1 opt) options :test #'equal)))
(dolist (backend org-export-registered-backends)
(dolist (opt (org-export-backend-options backend))
(when (stringp (nth 1 opt))
(cl-pushnew (nth 1 opt) options :test #'equal))))
(org-element-map ast 'node-property
(lambda (node)
(when (member
(org-element-property :key node)
options)
(push (list (org-element-property :post-affiliated node)
(format "Potentially misspelled option \"%s\". Consider \"EXPORT_%s\"."
(org-element-property :key node)
(org-element-property :key node)))
reports))))
reports))
(defun org-lint-invalid-macro-argument-and-template (ast)
(let* ((reports nil)
(extract-placeholders
@ -1443,6 +1466,11 @@ AST is the buffer parse tree."
#'org-lint-unknown-options-item
:categories '(export) :trust 'low)
(org-lint-add-checker 'misspelled-export-option
"Report potentially misspelled export options in properties."
#'org-lint-export-option-keywords
:categories '(export) :trust 'low)
(org-lint-add-checker 'invalid-macro-argument-and-template
"Report spurious macro arguments or invalid macro templates"
#'org-lint-invalid-macro-argument-and-template