Hi Martin,

I have finally applied a modified version of you patch.  Thanks!

What I modified is this:

1. Your patch did remove the matching tags from the tag list itself, and not only from the agenda display line. Tis had the consequence that secondary tag filtering on such tags would no longer work. I think it is better
   if that still does work.

2. You can now both add the inherited tags, and remove some tags, not
   just one or the other.

Thanks!

- Carsten

On Nov 10, 2009, at 3:47 PM, Martin Pohlack wrote:

Hi All,

Martin Pohlack wrote:
Alan E. Davis wrote:
In some cases, a single headword entry can relate to a large number of
topics.  I have tried dealing with longer tag lists: automatic
adjustment of tags column (on this list a little utility was posted:
org-adjust-tags-column-reset-tags.  I THINK that a keyword list may
allow more freedom to cross-index, especially if it is easy to use.

Can someone suggest a way to implement a keywording system, perhaps with
a custom agenda search?  Or have others dealt with this issue in
innovative ways?

I would appreciate any ideas.

I still have the feeling that tags are the way to go.  Searching etc.
already works with tags. Their disadvantage seems to be that lines get
cluttered if many tags are used.

Maybe this can be solved with two approaches:
* In agendas, one could have a filter for which tags to show / hide.
This would be useful otherwise too, as it would allow to hide context
 tags in already defined agendas.

 org-agenda-hide-tags-regex

 For example, all my contexts start with "@", so I would set it to be
 "^...@work$" to hide redundant information in my work agendas, or use
 "^@" to remove all context information from a specific agenda.

* For plain view, could we have a soft newline between tags and content
 for an item (like in long-lines-mode)?
Tags would be shown on a new line (with indentation etc.) but would be
 stored on the same line in files?

 For example, the file content ("\" added by me, should be one long
 line):

Please find attached a patch that implements tag filtering for agenda views.

Feedback welcome.

Cheers,
Martin
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,
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten





_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to