From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pohlack Subject: Re: Best way to implement Keywords feature Date: Tue, 10 Nov 2009 15:47:32 +0100 Message-ID: <4AF97D04.8050304@os.inf.tu-dresden.de> References: <7bef1f890911051442h28d45647h4f128a241d4e0116@mail.gmail.com> <4AF82CA6.8030102@os.inf.tu-dresden.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000001050108020705040400" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7s0U-0006Bu-0d for emacs-orgmode@gnu.org; Tue, 10 Nov 2009 09:47:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7s0O-00065K-T6 for emacs-orgmode@gnu.org; Tue, 10 Nov 2009 09:47:41 -0500 Received: from [199.232.76.173] (port=57351 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7s0O-00064u-Bj for emacs-orgmode@gnu.org; Tue, 10 Nov 2009 09:47:36 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]:35509) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N7s0N-0001ls-M2 for emacs-orgmode@gnu.org; Tue, 10 Nov 2009 09:47:36 -0500 In-Reply-To: <4AF82CA6.8030102@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: "Alan E. Davis" , org-mode This is a multi-part message in MIME format. --------------000001050108020705040400 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------000001050108020705040400 Content-Type: text/x-patch; name="hide-tags-in-agenda.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="hide-tags-in-agenda.patch" 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, --------------000001050108020705040400 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --------------000001050108020705040400--