emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Martin Pohlack <mp26@os.inf.tu-dresden.de>
To: "Alan E. Davis" <lngndvs@gmail.com>, org-mode <emacs-orgmode@gnu.org>
Subject: Re: Best way to implement Keywords feature
Date: Tue, 10 Nov 2009 15:47:32 +0100	[thread overview]
Message-ID: <4AF97D04.8050304@os.inf.tu-dresden.de> (raw)
In-Reply-To: <4AF82CA6.8030102@os.inf.tu-dresden.de>

[-- Attachment #1: Type: text/plain, Size: 1707 bytes --]

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

[-- Attachment #2: hide-tags-in-agenda.patch --]
[-- Type: text/x-patch, Size: 2883 bytes --]

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,

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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	other threads:[~2009-11-10 14:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05 22:42 Best way to implement Keywords feature Alan E. Davis
2009-11-05 22:58 ` Samuel Wales
2009-11-05 23:25   ` Alan E. Davis
2009-11-05 23:40     ` Samuel Wales
2009-11-06 11:48       ` Alan E. Davis
2009-11-06 13:28         ` Renzo Been :-)
2009-11-06 13:46           ` Giovanni Ridolfi
2009-11-06  9:09 ` Giovanni Ridolfi
2009-11-08 11:24   ` Paul Mead
2009-11-08 12:03     ` Matt Lundin
2009-11-08 18:18       ` Paul Mead
2009-11-08 18:51         ` Matthew Lundin
2009-11-09  0:00           ` Paul Mead
2009-11-09 12:27             ` Matthew Lundin
2009-11-09 13:05               ` Paul Mead
2009-11-09 14:26               ` Darlan Cavalcante Moreira
2009-11-09 14:52 ` Martin Pohlack
2009-11-10 14:47   ` Martin Pohlack [this message]
2009-11-20 18:06     ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF97D04.8050304@os.inf.tu-dresden.de \
    --to=mp26@os.inf.tu-dresden.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=lngndvs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).