From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Best way to implement Keywords feature Date: Fri, 20 Nov 2009 19:06:26 +0100 Message-ID: References: <7bef1f890911051442h28d45647h4f128a241d4e0116@mail.gmail.com> <4AF82CA6.8030102@os.inf.tu-dresden.de> <4AF97D04.8050304@os.inf.tu-dresden.de> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBXsS-0001vE-AI for emacs-orgmode@gnu.org; Fri, 20 Nov 2009 13:06:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBXsN-0001q4-SB for emacs-orgmode@gnu.org; Fri, 20 Nov 2009 13:06:35 -0500 Received: from [199.232.76.173] (port=59159 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBXsN-0001pl-Ki for emacs-orgmode@gnu.org; Fri, 20 Nov 2009 13:06:31 -0500 Received: from ey-out-1920.google.com ([74.125.78.149]:52199) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NBXsM-00045P-H8 for emacs-orgmode@gnu.org; Fri, 20 Nov 2009 13:06:31 -0500 Received: by ey-out-1920.google.com with SMTP id 3so1171064eyh.34 for ; Fri, 20 Nov 2009 10:06:29 -0800 (PST) In-Reply-To: <4AF97D04.8050304@os.inf.tu-dresden.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Martin Pohlack Cc: org-mode 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