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

    * lisp/org.el (org-set-tags-command): Put local tags on top
    
    See https://orgmode.org/list/7ab4f327-24d0-4ba5-bd20-b329d4cbb...@hoowl.se
---
 lisp/org.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4b14bcbf00..602abf257e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11465,12 +11465,18 @@ in Lisp code use `org-set-tags' instead."
       (save-excursion
        (org-back-to-heading)
        (let* ((all-tags (org-get-tags))
+               (local-table (or org-current-tag-alist (org-get-buffer-tags)))
               (table (setq org-last-tags-completion-table
-                           (org--tag-add-to-alist
-                            (and org-complete-tags-always-offer-all-agenda-tags
-                                 (org-global-tags-completion-table
-                                  (org-agenda-files)))
-                            (or org-current-tag-alist (org-get-buffer-tags)))))
+                            (append
+                             ;; Put local tags in front.
+                             local-table
+                             (cl-set-difference
+                             (org--tag-add-to-alist
+                              (and 
org-complete-tags-always-offer-all-agenda-tags
+                                   (org-global-tags-completion-table
+                                    (org-agenda-files)))
+                              local-table)
+                              local-table))))
               (current-tags
                (cl-remove-if (lambda (tag) (get-text-property 0 'inherited 
tag))
                              all-tags))

Reply via email to