Fix handling of setup file wrt setting tags

* org.el (org-set-regexps-and-options-for-tags): Return a list
with tag-related variables.
(org-set-regexps-and-options): Append tags from a setup file
to the local tags of the file.
(org-agenda-prepare-buffers): Set tags from a setup file by
calling `org-set-regexps-and-options' when necessary.

Thanks to Anupam Sengupta for reporting this.
This commit is contained in:
Bastien Guerry 2013-05-16 10:33:32 +02:00
parent b70e77343a
commit b83c0309a7
1 changed files with 29 additions and 17 deletions

View File

@ -4865,7 +4865,9 @@ Support for group tags is controlled by the option
(while (setq e (pop tgs)) (while (setq e (pop tgs))
(or (and (stringp (car e)) (or (and (stringp (car e))
(assoc (car e) org-tag-alist)) (assoc (car e) org-tag-alist))
(push e org-tag-alist)))))))) (push e org-tag-alist)))
;; Return a list with tag variables
(list org-file-tags org-tag-alist org-tag-groups-alist))))))
(defun org-set-regexps-and-options () (defun org-set-regexps-and-options ()
"Precompute regular expressions used in the current buffer." "Precompute regular expressions used in the current buffer."
@ -4893,22 +4895,25 @@ Support for group tags is controlled by the option
(save-restriction (save-restriction
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
(while (or (and ext-setup-or-nil (while
(let (ret) (or (and
(with-temp-buffer ext-setup-or-nil
(insert ext-setup-or-nil) (let (ret)
(let ((major-mode 'org-mode)) (with-temp-buffer
(org-set-regexps-and-options-for-tags) (insert ext-setup-or-nil)
(setq ret (list org-file-tags org-tag-alist (let ((major-mode 'org-mode))
org-tag-groups-alist)))) (setq ret (save-match-data
(setq org-file-tags (nth 0 ret) (org-set-regexps-and-options-for-tags)))))
org-tag-alist (nth 1 ret) ;; Append setupfile tags to existing tags
org-tag-groups-alist (nth 2 ret)))) (setq org-file-tags (append org-file-tags (nth 0 ret))
(and ext-setup-or-nil org-tag-alist (append org-tag-alist (nth 1 ret))
(string-match re ext-setup-or-nil start) org-tag-groups-alist
(setq start (match-end 0))) (append org-tag-groups-alist (nth 2 ret)))))
(and (setq ext-setup-or-nil nil start 0) (and ext-setup-or-nil
(re-search-forward re nil t))) (string-match re ext-setup-or-nil start)
(setq start (match-end 0)))
(and (setq ext-setup-or-nil nil start 0)
(re-search-forward re nil t)))
(setq key (upcase (match-string 1 ext-setup-or-nil)) (setq key (upcase (match-string 1 ext-setup-or-nil))
value (org-match-string-no-properties 2 ext-setup-or-nil)) value (org-match-string-no-properties 2 ext-setup-or-nil))
(if (stringp value) (setq value (org-trim value))) (if (stringp value) (setq value (org-trim value)))
@ -17985,6 +17990,13 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
(set-buffer (org-get-agenda-file-buffer file))) (set-buffer (org-get-agenda-file-buffer file)))
(widen) (widen)
(org-set-regexps-and-options-for-tags) (org-set-regexps-and-options-for-tags)
(goto-char (point-min))
(let ((case-fold-search t))
(when (search-forward "#+setupfile" nil t)
;; Don't set all regexps and options systematically as
;; this is only run for setting agenda tags from setup
;; file
(org-set-regexps-and-options)))
(org-refresh-category-properties) (org-refresh-category-properties)
(org-refresh-properties org-effort-property 'org-effort) (org-refresh-properties org-effort-property 'org-effort)
(org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime) (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)