emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org dd173bf 1/2: org-get-buffer-tags: Use cache


From: ELPA Syncer
Subject: [elpa] externals/org dd173bf 1/2: org-get-buffer-tags: Use cache
Date: Tue, 23 Nov 2021 08:57:23 -0500 (EST)

branch: externals/org
commit dd173bf451c0a6bbf7307f275440edc432770f17
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-get-buffer-tags: Use cache
---
 lisp/org.el | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 308bb7d..025513e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12660,12 +12660,21 @@ Inherited tags have the `inherited' text property."
 
 (defun org-get-buffer-tags ()
   "Get a table of all tags used in the buffer, for completion."
-  (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))))))
+  (if (org-element--cache-active-p)
+      ;; `org-element-cache-map' is about 2x faster compared to regexp
+      ;; search.
+      (let ((tags (org-element-cache-map
+                   (lambda (el) (org-element-property :tags el)))))
+        (mapcar #'list (mapcar #'substring-no-properties
+                               (delete-dups
+                                (append org-file-tags
+                                        (apply #'append tags))))))
+    (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)))))))
 
 ;;;; The mapping API
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]