org.el: Fix bug when adding persistent tags

* lisp/org.el (org-tag-add-to-alist): New function.
(org-set-regexps-and-options): Use the new function to only
append persistent tags if they are not already in the tags
alist.
This commit is contained in:
Bastien 2018-03-20 17:23:18 +01:00
parent b7f350f7ef
commit b0cca9656d
1 changed files with 11 additions and 4 deletions

View File

@ -4903,6 +4903,12 @@ Support for group tags is controlled by the option
(message "Groups tags support has been turned %s"
(if org-group-tags "on" "off")))
(defun org-tag-add-to-alist (alist1 alist2)
"Append ALIST1 elements to ALIST2 if they are not there yet."
(let (to-add)
(dolist (i alist1) (unless (member i alist2) (push i to-add)))
(append to-add alist2)))
(defun org-set-regexps-and-options (&optional tags-only)
"Precompute regular expressions used in the current buffer.
When optional argument TAGS-ONLY is non-nil, only compute tags
@ -4931,10 +4937,11 @@ related expressions."
(mapcar #'org-add-prop-inherited
(cdr (assq 'filetags alist))))
(setq org-current-tag-alist
(append org-tag-persistent-alist
(let ((tags (cdr (assq 'tags alist))))
(if tags (org-tag-string-to-alist tags)
org-tag-alist))))
(org-tag-add-to-alist
org-tag-persistent-alist
(let ((tags (cdr (assq 'tags alist))))
(if tags (org-tag-string-to-alist tags)
org-tag-alist))))
(setq org-tag-groups-alist
(org-tag-alist-to-groups org-current-tag-alist))
(unless tags-only