0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 06:02:53 +00:00

org-get-buffer-tags: Switch to org-element API

This commit is contained in:
Ihor Radchenko 2023-05-07 12:13:54 +02:00
parent 6938857369
commit 3024e933c0
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -12287,24 +12287,15 @@ Inherited tags have the `inherited' text property."
(defun org-get-buffer-tags ()
"Get a table of all tags used in the buffer, for completion."
(if (org-element--cache-active-p)
;; `org-element-cache-map' is about 2x faster compared to regexp
;; search.
(let ((hashed (make-hash-table :test #'equal)))
(org-element-cache-map
(lambda (el)
(dolist (tag (org-element-property :tags el))
;; Do not carry over the text properties. They may look
;; ugly in the completion.
(puthash (list (substring-no-properties tag)) t hashed))))
(dolist (tag org-file-tags) (puthash (list tag) t hashed))
(hash-table-keys hashed))
(org-with-point-at 1
(let (tags)
(while (re-search-forward org-tag-line-re nil t)
(setq tags (nconc (split-string (match-string-no-properties 2) ":")
tags)))
(mapcar #'list (delete-dups (append org-file-tags tags)))))))
(let ((hashed (make-hash-table :test #'equal)))
(org-element-cache-map
(lambda (el)
(dolist (tag (org-element-property :tags el))
;; Do not carry over the text properties. They may look
;; ugly in the completion.
(puthash (list (substring-no-properties tag)) t hashed))))
(dolist (tag org-file-tags) (puthash (list tag) t hashed))
(hash-table-keys hashed)))
;;;; The mapping API