Browse Source

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.
Carsten Dominik 11 years ago
parent
commit
c5a26208a8
2 changed files with 33 additions and 1 deletions
  1. 7 0
      lisp/ChangeLog
  2. 26 1
      lisp/org-agenda.el

+ 7 - 0
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

+ 26 - 1
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 "    > "))