summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2008-11-27 09:25:50 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2008-11-27 09:25:50 +0100
commitf6b9e77ded7b30e6aa80380de778a7bb9c88971b (patch)
treef2f15124a4b4d2200b0a61fa8a35999eca8ad3e1
parenta196eaa15cb3811e07b59ace954fdeda2c88f33b (diff)
downloadorg-mode-f6b9e77ded7b30e6aa80380de778a7bb9c88971b.tar.gz
Show inherited tags in the agenda.
This patch does a lot of things. First, it makes sure that the tags transferred to the agenda as text properties on each line are do carry information about there origin (in the form of an `inherited' text property). Then it modifies the function creating agenda lines so that inherited tags will be listed and identified as such in the agenda. This new feature can be turned off with a new variable, `org-agenda-show-inherited-tags'.
-rw-r--r--ORGWEBPAGE/Changes.org8
-rw-r--r--doc/org.texi5
-rwxr-xr-xlisp/ChangeLog17
-rw-r--r--lisp/org-agenda.el38
-rw-r--r--lisp/org.el14
5 files changed, 78 insertions, 4 deletions
diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org
index 961bce1..f9d42dd 100644
--- a/ORGWEBPAGE/Changes.org
+++ b/ORGWEBPAGE/Changes.org
@@ -69,6 +69,14 @@
Thanks for Richard Riley for the idea and to Andy Stewart for
the implementation.
+*** The agenda shows now all tags, including inherited ones.
+
+ This request has come up often, most recently it was
+ formulated by Tassilo Horn.
+
+ If you prefer the old behavior of only showing the local
+ tags, customize the variable =org-agenda-show-inherited-tags=.
+
* Version 6.13
** Overview
diff --git a/doc/org.texi b/doc/org.texi
index 601a32b..6cf559f 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6192,8 +6192,9 @@ different file.
@c
@kindex T
@item T
-Show all tags associated with the current item. Because of
-inheritance, this may be more than the tags listed in the line itself.
+Show all tags associated with the current item. This is useful if you have
+turned off @code{org-agenda-show-inherited-tags}, but still want to see all
+tags of a headline occasionally.
@c
@kindex :
@item :
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d66132e..a6dc92b 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,20 @@
+2008-11-27 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org-agenda.el (org-agenda-show-inherited-tags): New option.
+ (org-format-agenda-item): Add inherited tags to the agenda line
+ string, and make sure that properties are kept when downcasing the
+ tags list.
+ (org-agenda-add-inherited-tags): New function.
+ (org-downcase-keep-props): New function.
+
+ * org.el (org-scan-tags): Mark inherited tags with a text
+ property.
+ (org-get-tags-at): Mark inherited tags with a text property.
+ (org-add-prop-inherited): New function.
+
+ * org-agenda.el (org-agenda-add-inherited-tags): New function.
+ (org-agenda-show-inherited-tags): New option.
+
2008-11-26 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-modules): Add org-w3m to the default modules.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8eff0a3..2081fd8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -945,6 +945,10 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour."
(integer :tag "Minutes")
(const :tag "No default duration")))
+(defcustom org-agenda-show-inherited-tags t
+ "Non-nil means, show inherited tags in each agenda line."
+ :group 'org-agenda-line-format
+ :type 'boolean)
(defcustom org-agenda-remove-tags nil
"Non-nil means, remove the tags from the headline copy in the agenda.
@@ -3737,6 +3741,9 @@ 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)))
(let* ((category (or category
org-category
(if buffer-file-name
@@ -3836,7 +3843,8 @@ Any match of REMOVE-RE will be removed from TXT."
;; And finally add the text properties
(org-add-props rtn nil
- 'org-category (downcase category) 'tags (mapcar 'downcase tags)
+ 'org-category (downcase category)
+ 'tags (mapcar 'org-downcase-keep-props tags)
'org-highest-priority org-highest-priority
'org-lowest-priority org-lowest-priority
'prefix-length (- (length rtn) (length txt))
@@ -3849,6 +3857,34 @@ Any match of REMOVE-RE will be removed from TXT."
'extra extra
'dotime dotime))))
+(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,
+a double colon separates inherited tags from local tags."
+ (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") txt)
+ (setq txt (substring txt 0 (match-beginning 0))))
+ (when tags
+ (let ((have-i (get-text-property 0 'inherited (car tags)))
+ i)
+ (setq txt (concat txt " :"
+ (mapconcat
+ (lambda (x)
+ (setq i (get-text-property 0 'inherited x))
+ (if (and have-i (not i))
+ (progn
+ (setq have-i nil)
+ (concat ":" x))
+ x))
+ tags ":")
+ (if have-i "::" ":")))))
+ txt)
+
+(defun org-downcase-keep-props (s)
+ (let ((props (text-properties-at 0 s)))
+ (setq s (downcase s))
+ (add-text-properties 0 (length s) props s)
+ s))
+
(defvar org-agenda-sorting-strategy) ;; because the def is in a let form
(defvar org-agenda-sorting-strategy-selected nil)
diff --git a/lisp/org.el b/lisp/org.el
index f3a21d1..6890b1e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9038,8 +9038,14 @@ only lines with a TODO keyword are included in the output."
;; compile tags for current headline
(setq tags-list
(if org-use-tag-inheritance
- (apply 'append (mapcar 'cdr tags-alist))
+ (apply 'append (mapcar 'cdr (reverse tags-alist)))
tags))
+ (when org-use-tag-inheritance
+ (setcdr (car tags-alist)
+ (mapcar (lambda (x)
+ (setq x (copy-sequence x))
+ (org-add-prop-inherited x))
+ (cdar tags-alist))))
(when (and tags org-use-tag-inheritance
(not (eq t org-use-tag-inheritance)))
;; selective inheritance, remove uninherited ones
@@ -9360,6 +9366,8 @@ ignore inherited ones."
(when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
(setq ltags (org-split-string
(org-match-string-no-properties 1) ":"))
+ (when parent
+ (setq ltags (mapcar 'org-add-prop-inherited ltags)))
(setq tags (append
(if parent
(org-remove-uniherited-tags ltags)
@@ -9372,6 +9380,10 @@ ignore inherited ones."
(error nil)))))
(append (org-remove-uniherited-tags org-file-tags) tags))))
+(defun org-add-prop-inherited (s)
+ (add-text-properties 0 (length s) '(inherited t) s)
+ s)
+
(defun org-toggle-tag (tag &optional onoff)
"Toggle the tag TAG for the current line.
If ONOFF is `on' or `off', don't toggle but set to this state."