diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-14 17:41:04 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-14 17:41:04 +0200 |
commit | c46fcd98743536390b7aff9d1b58450f78c501a8 (patch) | |
tree | 458f35eb7ad3bfc00c2faec10c2ba39ef0617a2d | |
parent | 7143ae03555da1bcec97bb04907f9d9d592912b8 (diff) | |
download | org-mode-c46fcd98743536390b7aff9d1b58450f78c501a8.tar.gz |
org-lint: Add checker for spurious colons in tags
* lisp/org-lint.el (org-lint--checkers): Add checker.
(org-lint-spurious-colons): New function.
* testing/lisp/test-org-lint.el (test-org/spurious-colons): New test.
-rw-r--r-- | lisp/org-lint.el | 13 | ||||
-rw-r--r-- | testing/lisp/test-org-lint.el | 12 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index f7a45a8..1b969f0 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -100,6 +100,7 @@ ;; - indented diary-sexps ;; - obsolete QUOTE section ;; - obsolete "file+application" link +;; - spurious colons in tags ;;; Code: @@ -285,7 +286,10 @@ (make-org-lint-checker :name 'file-application :description "Report obsolete \"file+application\" link" - :categories '(link obsolete))) + :categories '(link obsolete)) + (make-org-lint-checker + :name 'spurious-colons + :description "Report spurious colons in tags")) "List of all available checkers.") (defun org-lint--collect-duplicates @@ -1031,6 +1035,13 @@ Use \"export %s\" instead" reports)))))))))))) reports)) +(defun org-lint-spurious-colons (ast) + (org-element-map ast '(headline inlinetask) + (lambda (h) + (when (member "" (org-element-property :tags h)) + (list (org-element-property :begin h) + "Tags contain a spurious colon"))))) + ;;; Reports UI diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el index a75563e..0f4f9a7 100644 --- a/testing/lisp/test-org-lint.el +++ b/testing/lisp/test-org-lint.el @@ -487,6 +487,18 @@ SCHEDULED: <2012-03-29 thu.>" #+end_src" (org-lint '(wrong-header-value))))) +(ert-deftest test-org/spurious-colons () + "Test `org-list-spurious-colons' checker." + (should-not + (org-test-with-temp-text "* H :tag:tag2:" + (org-lint '(spurious-colons)))) + (should + (org-test-with-temp-text "* H :tag::tag2:" + (org-lint '(spurious-colons)))) + (should + (org-test-with-temp-text "* H :tag::" + (org-lint '(spurious-colons))))) + (provide 'test-org-lint) ;;; test-org-lint.el ends here |