From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: [PATCH] Extract prefix information from diary sexp entries for agenda display Date: Mon, 23 Apr 2012 00:28:38 +0200 Message-ID: <20120422222838.GA12842@c3po.home> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SM5HM-00049a-Gi for emacs-orgmode@gnu.org; Sun, 22 Apr 2012 18:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SM5HK-00071a-3A for emacs-orgmode@gnu.org; Sun, 22 Apr 2012 18:29:12 -0400 Received: from sanddollar.geekisp.com ([216.168.135.167]:23264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SM5HJ-00071D-Tp for emacs-orgmode@gnu.org; Sun, 22 Apr 2012 18:29:09 -0400 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch adds a new org-agenda-diary-sexp-prefix customization option. It can be set to a regexp which is used to match the part of the text produced by a diary sexp entry that should be treated as deadlining/scheduling information (the "prefix"), and displayed as such in agenda views. For example, let's say diary-remind-message is set to '("In " (format "%3d d." days) ": " diary-entry) to match the default format used for upcoming deadlines in org-mode. Then the following diary-remind entry %%(diary-remind '(diary-date t 4 30) -14) Don't forget this birthday will produce a line something like this: In 7 d.: Don't forget this birthday in agenda views. But the "In 7 d.:" part will be displayed as part of the entry, *not* in the "prefix" column where org-mode displays deadline and scheduling information for normal org items, which looks like this: In 2 d.: TODO Important thing to do soon In 7 d.: Don't forget this birthday Deadline: TODO Do this today or else! Setting org-agenda-diary-sexp-prefix to the regexp "^In +[0-9]+ d\\.:" will extract the "In x days:" part of a diary sexp entry, and display it as the prefix (i.e. deadline/scheduling info) for the entry in agenda views, aligning it with the prefixes from org-mode's own deadline entries: In 2 d.: TODO Important thing to do soon In 7 d.: Don't forget this birthday Deadline: TODO Do this today or else! More generally, org-mode has access to a lot of structured information about its own agenda entries. But a diary sexp entry hands org-mode a lump of output text, with no structure to tell it what information is represented by different parts of that text. `org-agenda-diary-sexp-prefix' gives you a way of telling org-mode how to extract scheduling and deadline information from that lump of text. Toby -- Dr T. S. Cubitt Mathematics and Quantum Information group Department of Mathematics Complutense University Madrid, Spain email: tsc25@cantab.net web: www.dr-qubit.org --r5Pyd7+fXNt84Ff3 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-Agenda-Add-org-agenda-diary-sexp-prefix-customizatio.patch" >From 35e623da77892650b8a9ffab89a62a32192eab6c Mon Sep 17 00:00:00 2001 From: "Toby S. Cubitt" Date: Sun, 29 Jan 2012 10:51:46 +0100 Subject: [PATCH] Agenda: Add org-agenda-diary-sexp-prefix customization option * lisp/org-agenda.el (org-agenda-diary-sexp-prefix): Regexp matching deadline/scheduling information to be displayed in diary sexp agenda items. (org-agenda-get-sexps): Extract deadline/scheduling information from diary sexp entries. --- lisp/org-agenda.el | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 796f158..1af37c1 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1516,6 +1516,16 @@ to occupy a fixed space in the agenda display." :group 'org-agenda-line-format :type 'string) +(defcustom org-agenda-diary-sexp-prefix nil + "A regexp that matches part of a diary sexp entry +which should be treated as scheduling/deadline information in +`org-agenda'. + +For example, you can use this to extract the `diary-remind-message' from +`diary-remind' entries." + :group 'org-agenda-line-format + :type '(choice (const :tag "None" nil) (regexp :tag "Regexp"))) + (defcustom org-agenda-timerange-leaders '("" "(%d/%d): ") "Text preceding timerange entries in the agenda view. This is a list with two strings. The first applies when the range @@ -5046,7 +5056,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) (regexp "^&?%%(") - marker category org-category-pos ee txt tags entry + marker category extra org-category-pos ee txt tags entry result beg b sexp sexp-entry todo-state) (goto-char (point-min)) (while (re-search-forward regexp nil t) @@ -5070,12 +5080,16 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', (dolist (r (if (stringp result) (list result) result)) ;; we expect a list here + (when (and org-agenda-diary-sexp-prefix + (string-match org-agenda-diary-sexp-prefix r)) + (setq extra (match-string 0 r) + r (replace-match "" nil nil r))) (if (string-match "\\S-" r) (setq txt r) (setq txt "SEXP entry returned empty string")) (setq txt (org-agenda-format-item - "" txt category tags 'time)) + extra txt category tags 'time)) (org-add-props txt props 'org-marker marker) (org-add-props txt nil 'org-category category 'date date 'todo-state todo-state -- 1.7.8.5 --r5Pyd7+fXNt84Ff3--