mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-24 23:02:52 +00:00
org-lint: Lint malformed timestamps
* lisp/org-lint.el (org-lint-timestamp-syntax): New linter checking timestamp syntax. Link: https://list.orgmode.org/orgmode/87a6c3urkv.fsf@localhost/
This commit is contained in:
parent
30b790f42b
commit
ab542a6532
|
@ -1283,13 +1283,25 @@ Use \"export %s\" instead"
|
|||
bullet (car (last true-number)) bullet-number))))))))
|
||||
|
||||
(defun org-lint-LaTeX-$ (ast)
|
||||
"Report semi-obsolete $...$ LaTeX fragments."
|
||||
"Report semi-obsolete $...$ LaTeX fragments.
|
||||
AST is the buffer parse tree."
|
||||
(org-element-map ast 'latex-fragment
|
||||
(lambda (fragment)
|
||||
(and (string-match-p "^[$][^$]" (org-element-property :value fragment))
|
||||
(list (org-element-property :begin fragment)
|
||||
"Potentially confusing LaTeX fragment format. Prefer using more reliable \\(...\\)")))))
|
||||
|
||||
(defun org-lint-timestamp-syntax (ast)
|
||||
"Report malformed timestamps.
|
||||
AST is the buffer parse tree."
|
||||
(org-element-map ast 'timestamp
|
||||
(lambda (timestamp)
|
||||
(let ((expected (org-element-interpret-data timestamp))
|
||||
(actual (buffer-substring-no-properties
|
||||
(org-element-property :begin timestamp)
|
||||
(org-element-property :end timestamp))))
|
||||
(unless (equal expected actual)
|
||||
(list (org-element-begin timestamp)
|
||||
(format "Potentially malformed timestamp. Recognized: %s" expected)))))))
|
||||
|
||||
;;; Checkers declaration
|
||||
|
||||
|
@ -1527,6 +1539,10 @@ Use \"export %s\" instead"
|
|||
"Report potentially confusing $...$ LaTeX markup."
|
||||
#'org-lint-LaTeX-$
|
||||
:categories '(markup))
|
||||
(org-lint-add-checker 'timestamp-syntax
|
||||
"Report malformed timestamps."
|
||||
#'org-lint-timestamp-syntax
|
||||
:categories '(timestamp) :trust 'low)
|
||||
|
||||
(provide 'org-lint)
|
||||
|
||||
|
|
Loading…
Reference in a new issue