Function: org-get-buffer-tags

org-get-buffer-tags is a byte-compiled function defined in org.el.gz.

Signature

(org-get-buffer-tags)

Documentation

Get a table of all tags used in the buffer, for completion.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(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)))))))