Merge branch 'maint'

This commit is contained in:
Kaushal Modi 2019-01-08 11:35:34 -05:00
commit 8a5d8f79a1
2 changed files with 29 additions and 14 deletions

View File

@ -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 According to `org-use-tags-inheritance', tags may be inherited
from parent headlines, and from the whole document, through from parent headlines, and from the whole document, through
`org-file-tags'. However, when optional argument LOCAL is `org-file-tags'. In this case, the returned list of tags
non-nil, only return tags specified at the headline. 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." Inherited tags have the `inherited' text property."
(if (and org-trust-scanner-tags (if (and org-trust-scanner-tags
(or (not pos) (eq pos (point))) (or (not pos) (eq pos (point)))
(not local)) (not local))
org-scanner-tags org-scanner-tags
(org-with-point-at (or pos (point)) (org-with-point-at (or pos (point))
(unless (org-before-first-heading-p) (unless (org-before-first-heading-p)
(org-back-to-heading t) (org-back-to-heading t)
(let ((ltags (org--get-local-tags)) itags) (let ((ltags (org--get-local-tags)) itags)
(if (or local (not org-use-tag-inheritance)) ltags (if (or local (not org-use-tag-inheritance)) ltags
(setq itags org-file-tags) (while (org-up-heading-safe)
(while (org-up-heading-safe) (setq itags (append (mapcar #'org-add-prop-inherited
(setq itags (append (mapcar #'org-add-prop-inherited (org--get-local-tags))
(org--get-local-tags)) itags)))
itags))) (setq itags (append org-file-tags itags))
(delete-dups (delete-dups
(append (org-remove-uninherited-tags itags) ltags)))))))) (append (org-remove-uninherited-tags itags) ltags))))))))
(defun org-get-buffer-tags () (defun org-get-buffer-tags ()
"Get a table of all tags used in the buffer, for completion." "Get a table of all tags used in the buffer, for completion."

View File

@ -6217,6 +6217,17 @@ Paragraph<point>"
(let ((org-use-tag-inheritance t) (let ((org-use-tag-inheritance t)
(org-tags-exclude-from-inheritance '("foo"))) (org-tags-exclude-from-inheritance '("foo")))
(org-get-tags))))) (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. ;; Pathological case: tagged headline with an empty body.
(should (org-test-with-temp-text "* :tag:" (org-get-tags)))) (should (org-test-with-temp-text "* :tag:" (org-get-tags))))