summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-09-04 13:43:27 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-09-05 07:53:46 +0200
commitc5a26208a8008f744b2407dc6a29d55e93c244e5 (patch)
tree576e5dbc060bd09fdc1b53ae0b6146423266489d
parent206660bc8c02e5025d5f43cd3e5fb36c2fe0c8f3 (diff)
downloadorg-mode-c5a26208a8008f744b2407dc6a29d55e93c244e5.tar.gz
More user options to clean up entry text that will be shown in the agenda.
> > New mode to show some entry body text in the agenda > > ---------------------------------------------------- > > There is now a new agenda sub-mode called > > `org-agenda-entry-text-mode'. It is toggled with the `E' key. > > When active, all entries in the agenda will be accompanied by a > > few lines from the outline entry. The amount of text can be > > customized with the variable `org-agenda-entry-text-maxlines'. > > > this already avoids displaying drawer lines. > I also see lines like: > > - State "DONE" from "WARTEN" [2009-08-04 Di 16:19] > - State "DONE" from "WARTEN" [2009-07-02 Do 09:43] > ... > > and in my remeber templates I always create lines like: > > created: [2009-08-03 Mo 11:46] > > with the creation date of the entry. > Would it be possible and make sense to set up a variable for a > regexp to exclude lines like the ones above from showing? This commit sets up such a variable, and also a hook.
-rwxr-xr-xlisp/ChangeLog7
-rw-r--r--lisp/org-agenda.el27
2 files changed, 33 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dcfe0f2..ebf95ac 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
2009-09-04 Carsten Dominik <carsten.dominik@gmail.com>
+ * org-agenda.el (org-agenda-entry-text-exclude-regexps): New
+ variable.
+ (org-agenda-entry-text-cleanup-hook): New hook.
+ (org-agenda-get-some-entry-text): Remove matches of
+ `org-agenda-entry-text-exclude-regexps' and run the hook
+ `org-agenda-entry-text-cleanup-hook'.
+
* org.el (org-offer-links-in-entry): New argument ZERO to
implement a link with index zero.
(org-cycle-show-empty-lines): Not keep empty line under header
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1709a97..2739e8c 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -669,6 +669,21 @@ when exporting the agenda, configure the variable
:group 'org-agenda
:type 'integer)
+(defcustom org-agenda-entry-text-exclude-regexps nil
+ "List of regular expressions to clean up entry text.
+The complete matches of all regular expressions in this list will be
+removed from entry text before it is shown in the agenda."
+ :group 'org-agenda
+ :type '(repeat (regexp)))
+
+(defvar org-agenda-entry-text-cleanup-hook nil
+ "Hook that is run after basic cleanup of entry text to be shown in agenda.
+This cleanup is done in a temporary buffer, so the function may inspect and
+change the entire buffer.
+Some default stuff like drawers and scheduling/deadline dates will already
+have been removed when this is called, as will any matches for regular
+expressions listed in `org-agenda-entry-text-exclude-regexps'.")
+
(defvar org-agenda-include-inactive-timestamps nil
"Non-nil means, include inactive time stamps in agenda and timeline.")
@@ -2320,7 +2335,14 @@ This will ignore drawers etc, just get the text."
(if (re-search-forward "[ \t\n]+\\'" nil t)
(replace-match ""))
(goto-char (point-min))
- ;; find min indentation
+ (when org-agenda-entry-text-exclude-regexps
+ (let ((re-list org-agenda-entry-text-exclude-regexps) re)
+ (while (setq re (pop re-list))
+ (goto-char (point-min))
+ (while (re-search-forward re nil t)
+ (replace-match "")))))
+
+ ;; find and remove min common indentation
(goto-char (point-min))
(untabify (point-min) (point-max))
(setq ind (org-get-indentation))
@@ -2334,6 +2356,9 @@ This will ignore drawers etc, just get the text."
(move-to-column ind)
(delete-region (point-at-bol) (point)))
(beginning-of-line 2))
+
+ (run-hooks 'org-agenda-entry-text-cleanup-hook)
+
(goto-char (point-min))
(while (and (not (eobp)) (re-search-forward "^" nil t))
(replace-match " > "))