mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-21 06:55:35 +00:00
org-lint: Report invalid durations in effort properties
* lisp/org-lint.el (org-lint-invalid-effort-property): New checker. * testing/lisp/test-org-lint.el (test-org-lint/invalid-effort-property): New test.
This commit is contained in:
parent
6341de0117
commit
33b9c42395
@ -87,6 +87,7 @@
|
||||
;; - spurious macro arguments or invalid macro templates
|
||||
;; - special properties in properties drawer
|
||||
;; - obsolete syntax for PROPERTIES drawers
|
||||
;; - Invalid EFFORT property value
|
||||
;; - missing definition for footnote references
|
||||
;; - missing reference for footnote definitions
|
||||
;; - non-footnote definitions in footnote section
|
||||
@ -239,6 +240,10 @@
|
||||
:name 'obsolete-properties-drawer
|
||||
:description "Report obsolete syntax for properties drawers"
|
||||
:categories '(obsolete properties))
|
||||
(make-org-lint-checker
|
||||
:name 'invalid-effort-property
|
||||
:description "Report invalid duration in EFFORT property"
|
||||
:categories '(properties))
|
||||
(make-org-lint-checker
|
||||
:name 'undefined-footnote-reference
|
||||
:description "Report missing definition for footnote references"
|
||||
@ -540,6 +545,16 @@ Use :header-args: instead"
|
||||
"Incorrect contents for PROPERTIES drawer"
|
||||
"Incorrect location for PROPERTIES drawer"))))))))
|
||||
|
||||
(defun org-lint-invalid-effort-property (ast)
|
||||
(org-element-map ast 'node-property
|
||||
(lambda (p)
|
||||
(when (equal "EFFORT" (org-element-property :key p))
|
||||
(let ((value (org-element-property :value p)))
|
||||
(and (org-string-nw-p value)
|
||||
(not (org-duration-p value))
|
||||
(list (org-element-property :begin p)
|
||||
(format "Invalid effort duration format: %S" value))))))))
|
||||
|
||||
(defun org-lint-link-to-local-file (ast)
|
||||
(org-element-map ast 'link
|
||||
(lambda (l)
|
||||
|
@ -221,6 +221,15 @@ This is not a node property
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer)))))
|
||||
|
||||
(ert-deftest test-org-lint/invalid-effort-property ()
|
||||
"Test `org-lint-invalid-effort-property' checker."
|
||||
(should
|
||||
(org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: something\n:END:"
|
||||
(org-lint '(invalid-effort-property))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: 1:23\n:END:"
|
||||
(org-lint '(invalid-effort-property)))))
|
||||
|
||||
(ert-deftest test-org-lint/link-to-local-file ()
|
||||
"Test `org-lint-link-to-local-file' checker."
|
||||
(should
|
||||
|
Loading…
Reference in New Issue
Block a user