diff options
author | Kaushal Modi <kaushal.modi@gmail.com> | 2019-01-08 11:35:34 -0500 |
---|---|---|
committer | Kaushal Modi <kaushal.modi@gmail.com> | 2019-01-08 11:35:34 -0500 |
commit | 8a5d8f79a163f8f7a6fb308f98dc57773cbdfa19 (patch) | |
tree | 6069b48b1b2bb955042c8a7108ffe5829a317b97 | |
parent | 21d646775b520f6670e01dba45bda9cf92b4c43d (diff) | |
parent | 34e5dcfb06800802a5e06f13340d646b6d829f04 (diff) | |
download | org-mode-8a5d8f79a163f8f7a6fb308f98dc57773cbdfa19.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lisp/org.el | 32 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 11 |
2 files changed, 29 insertions, 14 deletions
diff --git a/lisp/org.el b/lisp/org.el index 38e4218..ea1607d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14601,26 +14601,30 @@ When argument POS is non-nil, retrieve tags for headline at POS. According to `org-use-tags-inheritance', tags may be inherited from parent headlines, and from the whole document, through -`org-file-tags'. However, when optional argument LOCAL is -non-nil, only return tags specified at the headline. +`org-file-tags'. In this case, the returned list of tags +contains tags in this order: file tags, tags inherited from +parent headlines, local tags. + +However, when optional argument LOCAL is non-nil, only return +tags specified at the headline. Inherited tags have the `inherited' text property." (if (and org-trust-scanner-tags - (or (not pos) (eq pos (point))) - (not local)) + (or (not pos) (eq pos (point))) + (not local)) org-scanner-tags (org-with-point-at (or pos (point)) (unless (org-before-first-heading-p) - (org-back-to-heading t) - (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 itags (append (mapcar #'org-add-prop-inherited - (org--get-local-tags)) - itags))) - (delete-dups - (append (org-remove-uninherited-tags itags) ltags)))))))) + (org-back-to-heading t) + (let ((ltags (org--get-local-tags)) itags) + (if (or local (not org-use-tag-inheritance)) ltags + (while (org-up-heading-safe) + (setq itags (append (mapcar #'org-add-prop-inherited + (org--get-local-tags)) + itags))) + (setq itags (append org-file-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 86d8a7d..976b7d8 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6217,6 +6217,17 @@ Paragraph<point>" (let ((org-use-tag-inheritance t) (org-tags-exclude-from-inheritance '("foo"))) (org-get-tags))))) + ;; Test the collection of tags from #+filetags and parent tags. + (should + (equal '("a" "b" "c" "d") + (org-test-with-temp-text (concat "#+filetags: a\n" + "* Level 1 :b:\n" + "** Level 2 :c:\n" + "*** Level 3 :d:\n" + "<point>") + (let ((org-use-tag-inheritance t)) + (org-mode-restart) ;So that `org-file-tags' get populated from #+filetags + (org-get-tags))))) ;; Pathological case: tagged headline with an empty body. (should (org-test-with-temp-text "* :tag:" (org-get-tags)))) |