0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 14:32:52 +00:00

org-lint-export-option-keywords: Improve message and ignore `org-default-properties'

* lisp/org-lint.el (org-lint-export-option-keywords): Mention which
backends the suspicious properties may belong to.  Avoid triggering on
`org-default-properties'.

Reported-by: Fraga, Eric <e.fraga@ucl.ac.uk>
Link: https://orgmode.org/list/87y1iuyb3m.fsf@ucl.ac.uk
This commit is contained in:
Ihor Radchenko 2023-08-02 09:29:57 +03:00
parent f9d2d92f42
commit 20d90b9790
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -769,26 +769,39 @@ Use \"export %s\" instead"
reports))
(defun org-lint-export-option-keywords (ast)
"Check for options keyword properties without EXPORT_."
"Check for options keyword properties without EXPORT in AST."
(require 'ox)
(let (options reports)
(let (options reports common-options options-alist)
(dolist (opt org-export-options-alist)
(when (stringp (nth 1 opt))
(cl-pushnew (nth 1 opt) options :test #'equal)))
(cl-pushnew (nth 1 opt) common-options :test #'equal)))
(dolist (backend org-export-registered-backends)
(dolist (opt (org-export-backend-options backend))
(when (stringp (nth 1 opt))
(cl-pushnew (or (org-export-backend-name backend) 'anonymous)
(alist-get (nth 1 opt) options-alist nil nil #'equal))
(cl-pushnew (nth 1 opt) options :test #'equal))))
(setq options-alist (nreverse options-alist))
(org-element-map ast 'node-property
(lambda (node)
(when (member
(org-element-property :key node)
options)
(push (list (org-element-post-affiliated node)
(format "Potentially misspelled option \"%s\". Consider \"EXPORT_%s\"."
(org-element-property :key node)
(org-element-property :key node)))
reports))))
(let ((prop (org-element-property :key node)))
(when (and (or (member prop options) (member prop common-options))
(not (member prop org-default-properties)))
(push (list (org-element-post-affiliated node)
(format "Potentially misspelled %sexport option \"%s\"%s. Consider \"EXPORT_%s\"."
(when (member prop common-options)
"global ")
prop
(if-let ((backends
(and (not (member prop common-options))
(cdr (assoc-string prop options-alist)))))
(format
" in %S export %s"
(if (= 1 (length backends)) (car backends) backends)
(if (> (length backends) 1) "backends" "backend"))
"")
prop))
reports)))))
reports))
(defun org-lint-invalid-macro-argument-and-template (ast)