diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-02-17 13:23:26 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-02-17 13:23:26 +0100 |
commit | 013c0af8b095210191651c71638206ff0ba6ebe1 (patch) | |
tree | b1893bb728c1da28cb580837323e83f80c86cb55 | |
parent | b5a67ebddd0afe24126fedcd10017d92502c6f10 (diff) | |
download | org-mode-013c0af8b095210191651c71638206ff0ba6ebe1.tar.gz |
org-lint: Add checker for empty headlines with tags
* lisp/org-lint.el (org-lint--checkers): Add checker.
(org-lint-empty-headline-with-tags): New function.
* testing/lisp/test-org-lint.el (test-org-lint/empty-headline-with-tags):
New test.
-rw-r--r-- | lisp/org-lint.el | 17 | ||||
-rw-r--r-- | testing/lisp/test-org-lint.el | 12 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index b734a37..89aed4b 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -97,6 +97,7 @@ ;; - indented diary-sexps ;; - obsolete QUOTE section ;; - obsolete "file+application" link +;; - blank headlines with tags ;;; Code: @@ -278,7 +279,12 @@ (make-org-lint-checker :name 'file-application :description "Report obsolete \"file+application\" link" - :categories '(link obsolete))) + :categories '(link obsolete)) + (make-org-lint-checker + :name 'empty-headline-with-tags + :description "Report ambiguous empty headlines with tags" + :categories '(headline) + :trust 'low)) "List of all available checkers.") (defun org-lint--collect-duplicates @@ -1014,6 +1020,15 @@ Use \"export %s\" instead" reports)))))))))))) reports)) +(defun org-lint-empty-headline-with-tags (ast) + (org-element-map ast '(headline inlinetask) + (lambda (h) + (let ((title (org-element-property :raw-value h))) + (and (string-match-p "\\`:[[:alnum:]_@#%:]+:\\'" title) + (list (org-element-property :begin h) + (format "Headline containing only tags is ambiguous: %S" + title))))))) + ;;; Reports UI diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el index d274848..3ae42c7 100644 --- a/testing/lisp/test-org-lint.el +++ b/testing/lisp/test-org-lint.el @@ -475,5 +475,17 @@ SCHEDULED: <2012-03-29 thu.>" #+end_src" (org-lint '(wrong-header-value))))) +(ert-deftest test-org-lint/empty-headline-with-tags () + "Test `org-lint-empty-headline-with-tags' checker." + (should + (org-test-with-temp-text "* :tag:" + (org-lint '(empty-headline-with-tags)))) + (should + (org-test-with-temp-text "* :tag: " + (org-lint '(empty-headline-with-tags)))) + (should-not + (org-test-with-temp-text "* notag: " + (org-lint '(empty-headline-with-tags))))) + (provide 'test-org-lint) ;;; test-org-lint.el ends here |