diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 708b193..e146bc0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1202,6 +1202,14 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour." :group 'org-agenda-line-format :type 'boolean) +(defcustom org-agenda-hide-tags-regexp nil + "Regular expression used to fitler away specific tags in agenda views. +Nil means hide no tags." + :group 'org-agenda-line-format + :type '(choice + (const :tag "Hide none" nil) + (string :tag "Regexp "))) + (defcustom org-agenda-remove-tags nil "Non-nil means, remove the tags from the headline copy in the agenda. When this is the symbol `prefix', only remove tags when @@ -4507,9 +4515,20 @@ Any match of REMOVE-RE will be removed from TXT." (save-match-data ;; Diary entries sometimes have extra whitespace at the beginning (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt))) - (when org-agenda-show-inherited-tags - ;; Fix the tags part in txt - (setq txt (org-agenda-add-inherited-tags txt tags))) + ;; filter tags here + (when org-agenda-hide-tags-regexp + (setq tags (apply 'append (mapcar + (lambda (x) + (if (string-match org-agenda-hide-tags-regexp x) + nil + (list x))) + tags)))) + ;; Fix the tags part in txt + (if org-agenda-show-inherited-tags + (setq txt (org-agenda-add-inherited-tags txt tags)) + (when org-agenda-hide-tags-regexp + (setq txt (org-agenda-add-local-tags txt tags)))) + (let* ((category (or category org-category (if buffer-file-name @@ -4640,6 +4659,24 @@ Any match of REMOVE-RE will be removed from TXT." 'extra extra 'dotime dotime)))) +(defun org-agenda-add-local-tags (txt tags) + "Remove tags string from TXT, and add non-inherited list of tags. +Inherited tags in TAGS are ignored." + (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") txt) + (setq txt (substring txt 0 (match-beginning 0)))) + (when tags + ;; drop inherited tags + (let ((mytags (apply 'append (mapcar + (lambda (x) + (if (get-text-property 0 'inherited x) + nil + (list x))) + tags)))) + ;; continue with remainder + (when (> (length mytags) 0) + (setq txt (concat txt " :" (mapconcat (lambda (x) x) mytags ":") ":" ))))) + txt) + (defun org-agenda-add-inherited-tags (txt tags) "Remove tags string from TXT, and add complete list of tags. The new list includes inherited tags. If any inherited tags are present,