summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-03-12 09:08:28 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-03-12 09:08:28 +0100
commit33b9c42395d24d0251651117a686343479bedc15 (patch)
treece0838ec8a1860f3dedb535de8f23cf38d8b7d90
parent6341de0117c84a6d148333a7269c1e6d910f3fc3 (diff)
downloadorg-mode-33b9c42395d24d0251651117a686343479bedc15.tar.gz
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.
-rw-r--r--lisp/org-lint.el15
-rw-r--r--testing/lisp/test-org-lint.el9
2 files changed, 24 insertions, 0 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 89aed4b..735c06e 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -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
@@ -240,6 +241,10 @@
: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"
:categories '(footnote))
@@ -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)
diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el
index 53dd968..005828e 100644
--- a/testing/lisp/test-org-lint.el
+++ b/testing/lisp/test-org-lint.el
@@ -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