Browse Source

* lisp/org.el (org-set-tags-command): Put local tags on top

See https://orgmode.org/list/7AB4F327-24D0-4BA5-BD20-B329D4CBBF0A@hoowl.se
Ihor Radchenko 2 years ago
parent
commit
a0b21e3f1c
1 changed files with 11 additions and 5 deletions
  1. 11 5
      lisp/org.el

+ 11 - 5
lisp/org.el

@@ -11465,12 +11465,18 @@ in Lisp code use `org-set-tags' instead."
       (save-excursion
       (save-excursion
 	(org-back-to-heading)
 	(org-back-to-heading)
 	(let* ((all-tags (org-get-tags))
 	(let* ((all-tags (org-get-tags))
+               (local-table (or org-current-tag-alist (org-get-buffer-tags)))
 	       (table (setq org-last-tags-completion-table
 	       (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
 	       (current-tags
 		(cl-remove-if (lambda (tag) (get-text-property 0 'inherited tag))
 		(cl-remove-if (lambda (tag) (get-text-property 0 'inherited tag))
 			      all-tags))
 			      all-tags))