diff options
author | Matt Lundin <mdl@imapmail.org> | 2018-07-25 07:48:10 -0500 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-08-19 10:28:27 +0200 |
commit | 5e27b2fd326810e4ed876b094df852338909c1f8 (patch) | |
tree | a3d9594af85266d9a25049561a3bad4c9c683498 | |
parent | ab1f7712de98b67f8a7d6c4caf63ba2c1b66aa24 (diff) | |
download | org-mode-5e27b2fd326810e4ed876b094df852338909c1f8.tar.gz |
Ensure that org-get-tags returns all local tags
* lisp/org.el: (org-get-tags) Create a clearer separation between
local and inherited tags in the function, so that
org-remove-uninherited tags is only run on inherited tags. This is
important to avoid destroying existing tags when adding new tags.
* testing/lisp/test-org.el: (test-org/get-tags) Add regression test
-rw-r--r-- | lisp/org.el | 15 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 7 |
2 files changed, 15 insertions, 7 deletions
diff --git a/lisp/org.el b/lisp/org.el index 999575d..9425248 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14722,14 +14722,15 @@ Inherited tags have the `inherited' text property." (org-with-point-at (or pos (point)) (unless (org-before-first-heading-p) (org-back-to-heading t) - (let ((tags (org--get-local-tags))) - (if (or local (not org-use-tag-inheritance)) tags + (let ((ltags (org--get-local-tags)) itags) + (if (or local (not org-use-tag-inheritance)) ltags + (setq itags org-file-tags) (while (org-up-heading-safe) - (setq tags (append (mapcar #'org-add-prop-inherited - (org--get-local-tags)) - tags))) - (org-remove-uninherited-tags - (delete-dups (append org-file-tags tags))))))))) + (setq itags (append (mapcar #'org-add-prop-inherited + (org--get-local-tags)) + itags))) + (delete-dups + (append (org-remove-uninherited-tags itags) ltags)))))))) (defun org-get-buffer-tags () "Get a table of all tags used in the buffer, for completion." diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index a6b2831..20164be 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6190,6 +6190,13 @@ Paragraph<point>" (equal '("foo") (org-test-with-temp-text "* H1 :foo:\n* <point>H2 :bar:" (org-get-tags 1)))) + ;; Make sure tags excluded from inheritance are returned if local + (should + (equal '("foo") + (org-test-with-temp-text "* Test :foo:" + (let ((org-use-tag-inheritance t) + (org-tags-exclude-from-inheritance '("foo"))) + (org-get-tags))))) ;; Pathological case: tagged headline with an empty body. (should (org-test-with-temp-text "* :tag:" (org-get-tags)))) |