diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-27 14:55:04 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-27 14:55:04 +0200 |
commit | 516c038e5f65911c32de1054925ce9e848c3f2d7 (patch) | |
tree | 82f6705505ea15e7653b6268505885233cd7567f | |
parent | 7a2b785d6a2d231e0fe6518f541e466430fb6c1f (diff) | |
download | org-mode-516c038e5f65911c32de1054925ce9e848c3f2d7.tar.gz |
lint: Catch misleading drawers within drawers
* lisp/org-lint.el (org-lint-incomplete-drawer): Catch misleading
drawers within drawers.
* testing/lisp/test-org-lint.el (test-org-lint/incomplete-drawer): Add
test.
-rw-r--r-- | lisp/org-lint.el | 18 | ||||
-rw-r--r-- | testing/lisp/test-org-lint.el | 3 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 0438eab..a515b24 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -794,15 +794,25 @@ Use \"export %s\" instead" (let ((name (org-trim (match-string-no-properties 0))) (element (org-element-at-point))) (pcase (org-element-type element) - ((or `drawer `property-drawer) - (goto-char (org-element-property :end element)) - nil) + (`drawer + ;; Find drawer opening lines within non-empty drawers. + (let ((end (org-element-property :contents-end element))) + (when end + (while (re-search-forward org-drawer-regexp end t) + (let ((n (org-trim (match-string-no-properties 0)))) + (push (list (line-beginning-position) + (format "Possible misleading drawer entry %S" n)) + reports)))) + (goto-char (org-element-property :end element)))) + (`property-drawer + (goto-char (org-element-property :end element))) ((or `comment-block `example-block `export-block `src-block `verse-block) nil) (_ + ;; Find drawer opening lines outside of any drawer. (push (list (line-beginning-position) - (format "Possible incomplete drawer \"%s\"" name)) + (format "Possible incomplete drawer %S" name)) reports))))) reports)) diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el index 82c6627..f5d28b0 100644 --- a/testing/lisp/test-org-lint.el +++ b/testing/lisp/test-org-lint.el @@ -393,6 +393,9 @@ SCHEDULED: <2012-03-29 thu.>" (should (org-test-with-temp-text ":DRAWER:" (org-lint '(incomplete-drawer)))) + (should + (org-test-with-temp-text ":DRAWER:\n:ODD:\n:END:" + (org-lint '(incomplete-drawer)))) (should-not (org-test-with-temp-text ":DRAWER:\n:END:" (org-lint '(incomplete-drawer))))) |