From 2b22b753485bbb522f1f08902bd37c673b241637 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Wed, 23 Jan 2013 15:21:31 -0800 Subject: [PATCH] added option %b to dispaly breadcrumbs in agenda if org file has the structure * project ** task1 *** TODO item1 then when using %b in org-agenda-prefix-format will display project->taks1->TODO item1 --- lisp/org-agenda.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f48ff6f..9716345 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1522,6 +1522,7 @@ This format works similar to a printf format, with the following meaning: %T the last tag of the item (ignore inherited tags, which come first) %t the HH:MM time-of-day specification if one applies to the entry %s Scheduling/Deadline information, a short string + %b show breadcrumbs, i.e., the names of the higher levels %(expression) Eval EXPRESSION and replace the control string by the result @@ -6301,6 +6302,9 @@ The flag is set if the currently compiled format contains a `%T'.") (defvar org-prefix-has-effort nil "A flag, set by `org-compile-prefix-format'. The flag is set if the currently compiled format contains a `%e'.") +(defvar org-prefix-has-breadcrumbs nil + "A flag, set by `org-compile-prefix-format'. +The flag is set if the currently compiled format contains a `%b'.") (defvar org-prefix-category-length nil "Used by `org-compile-prefix-format' to remember the category field width.") (defvar org-prefix-category-max-length nil @@ -6448,6 +6452,10 @@ Any match of REMOVE-RE will be removed from TXT." "......"))) (t "")) extra (or (and (not habitp) extra) "") + breadcrumbs (let ((m (org-get-at-bol 'org-marker))) + (org-with-point-at m + (let ((s (org-display-outline-path nil nil "->" t))) + (concat s "->")))) category (if (symbolp category) (symbol-name category) category) thecategory (copy-sequence category) level (or level "")) @@ -6478,6 +6486,7 @@ Any match of REMOVE-RE will be removed from TXT." 'duration duration 'effort effort 'effort-minutes neffort + 'breadcrumbs breadcrumbs 'txt txt 'level level 'time time @@ -6577,7 +6586,8 @@ and stored in the variable `org-prefix-format-compiled'." (setq org-prefix-has-time nil org-prefix-has-tag nil org-prefix-category-length nil - org-prefix-has-effort nil) + org-prefix-has-effort nil + org-prefix-has-breadcrumbs nil) (let ((s (cond ((stringp org-agenda-prefix-format) org-agenda-prefix-format) @@ -6586,11 +6596,11 @@ and stored in the variable `org-prefix-format-compiled'." (t " %-12:c%?-12t% s"))) (start 0) varform vars var e c f opt) - (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cltsei]\\|(.+)\\)" + (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cltseib]\\|(.+)\\)" s start) (setq var (or (cdr (assoc (match-string 4 s) '(("c" . category) ("t" . time) ("l" . level) ("s" . extra) - ("i" . category-icon) ("T" . tag) ("e" . effort)))) + ("i" . category-icon) ("T" . tag) ("e" . effort) ("b" . breadcrumbs)))) 'eval) c (or (match-string 3 s) "") opt (match-beginning 1) @@ -6598,6 +6608,7 @@ and stored in the variable `org-prefix-format-compiled'." (if (equal var 'time) (setq org-prefix-has-time t)) (if (equal var 'tag) (setq org-prefix-has-tag t)) (if (equal var 'effort) (setq org-prefix-has-effort t)) + (if (equal var 'breadcrumbs) (setq org-prefix-has-breadcumbs t)) (setq f (concat "%" (match-string 2 s) "s")) (when (equal var 'category) (setq org-prefix-category-length @@ -6624,7 +6635,8 @@ and stored in the variable `org-prefix-format-compiled'." `((org-prefix-has-time ,org-prefix-has-time) (org-prefix-has-tag ,org-prefix-has-tag) (org-prefix-category-length ,org-prefix-category-length) - (org-prefix-has-effort ,org-prefix-has-effort)) + (org-prefix-has-effort ,org-prefix-has-effort) + (org-prefix-has-has-breadcrumbs ,org-prefix-has-breadcrumbs)) `(format ,s ,@vars)))))) (defun org-set-sorting-strategy (key) -- 1.8.1.1