[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org ab542a6532 1/2: org-lint: Lint malformed timestamps
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/org ab542a6532 1/2: org-lint: Lint malformed timestamps |
|
Date: |
Sat, 13 May 2023 06:59:23 -0400 (EDT) |
branch: externals/org
commit ab542a65326f786564eec5f0e6358019c1268669
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
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/
---
lisp/org-lint.el | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index dc18b657cd..c146cca92c 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -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)