From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Fogel Subject: Re: Displaying deadline datestamp in todo agenda list? Date: Mon, 23 May 2016 16:53:13 -0500 Message-ID: <87bn3wo306.fsf@red-bean.com> References: <87oa7wu1si.fsf@red-bean.com> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4xmp-0001eM-Sj for emacs-orgmode@gnu.org; Mon, 23 May 2016 17:53:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4xmm-0005PF-NT for emacs-orgmode@gnu.org; Mon, 23 May 2016 17:53:19 -0400 Received: from mail-ig0-x22b.google.com ([2607:f8b0:4001:c05::22b]:35234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4xmm-0005P8-Fp for emacs-orgmode@gnu.org; Mon, 23 May 2016 17:53:16 -0400 Received: by mail-ig0-x22b.google.com with SMTP id bi2so41834789igb.0 for ; Mon, 23 May 2016 14:53:16 -0700 (PDT) Received: from floss (74-92-190-114-Illinois.hfc.comcastbusiness.net. [74.92.190.114]) by smtp.gmail.com with ESMTPSA id j70sm83072ioi.19.2016.05.23.14.53.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 14:53:13 -0700 (PDT) In-reply-to: <87oa7wu1si.fsf@red-bean.com> 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" To: Org Mode Sigh, sorry. I messed up one important background fact in my original post= , by mistakenly presenting these as the example Org Mode entries I was work= ing with:=20 > * STARTED <2016-05-23> Org Mode scheduling test KIWI. > DEADLINE: <2016-05-23> >=20 > * TODO <2016-05-25> Org Mode scheduling test MELON. > DEADLINE: <2016-05-25> >=20 > * STARTED <2016-05-24> Org Mode scheduling test LIME. > DEADLINE: <2016-05-24> >=20 > * STARTED <2016-06-16> Org Mode scheduling test TARDIGRADE. > SCHEDULED: <2016-05-23> DEADLINE: <2016-06-16> The above is wrong (I copied-and-pasted from a later incarnation that inclu= ded redundant timestamps). The block should look like below, i.e., *withou= t* datestamps in the todo headings: * STARTED Org Mode scheduling test KIWI. DEADLINE: <2016-05-23> =20 * TODO Org Mode scheduling test MELON. DEADLINE: <2016-05-25> =20 * STARTED Org Mode scheduling test LIME. DEADLINE: <2016-05-24> =20 * STARTED Org Mode scheduling test TARDIGRADE. SCHEDULED: <2016-05-23> DEADLINE: <2016-06-16> The rest of the post is as before, and I'll just reproduce it here (with th= e mistake corrected) in case it's easier for people to follow up to: ----------------------------------- Original post, but with correction: ----------------------------------- I'm using the DEADLINE keyword with TODO entries, and I'd like the DEADLINE= date to be displayed as a datestamp next to each TODO item, when I list de= adlined todo items. In other words, I don't want to have to duplicate the = DEADLINE timestamp as a timestamp on the TODO line itself in my Org Mode fi= le -- since the timestamp is already present as the value of the DEADLINE k= eyword, can't Org Mode just use it? Assume I have these Org Mode entries: * STARTED Org Mode scheduling test KIWI. DEADLINE: <2016-05-23> * TODO Org Mode scheduling test MELON. DEADLINE: <2016-05-25> * STARTED Org Mode scheduling test LIME. DEADLINE: <2016-05-24> * STARTED Org Mode scheduling test TARDIGRADE. SCHEDULED: <2016-05-23> DEADLINE: <2016-06-16> And I have this custom code to bind "d" to show just the TODO items that ha= ve deadlines, in my `org-agenda' keymap: (defun ots-org-entry-skip-non-deadline () "Return non-nil iff this org entry does not have the DEADLINE keyword." (if (not (org-entry-get (point) "DEADLINE")) (progn (outline-next-heading) (1- (point))))) =20=20 (defvar ots-org-agenda-custom-commands-updated-p nil "If non-nil, we've already updated `org-agenda-custom-commands', so don't do it again.") =20=20 ;; TBD: Oh, could use `org-add-agenda-custom-command' to do this. (unless ots-org-agenda-custom-commands-updated-p (unless (boundp 'org-agenda-custom-commands) (setq org-agenda-custom-commands ())) (setq org-agenda-custom-commands (cons '("d" "Deadlines and scheduled work" alltodo "" ((org-agenda-skip-function 'ots-org-entry-skip-non-deadli= ne) ;; Add code here to control deadline date display? (org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t%= s") (timeline . " % s") (todo . " %i %-12:c %s") (tags . " %i %-12:c") (search . " %i %-12:c"))) (org-agenda-sorting-strategy '(deadline-up)))) org-agenda-custom-commands)) (setq ots-org-agenda-custom-commands-updated-p t)) Now if I do `M-x org-agenda' and then type `d', the four items are displaye= d like this: Global list of TODO items of type: ALL Available with =E2=80=98N r=E2=80=99: (0)[ALL] (1)TODO (2)STARTED (3)DONE OTS: STARTED Org Mode scheduling test KIWI. OTS: STARTED Org Mode scheduling test LIME. OTS: TODO Org Mode scheduling test MELON. OTS: STARTED Org Mode scheduling test TARDIGRADE. =20=20 But what I want is for each to show its corresponding DEADLINE datestamp, s= ay like this: Global list of TODO items of type: ALL Available with =E2=80=98N r=E2=80=99: (0)[ALL] (1)TODO (2)STARTED (3)DONE OTS: <2016-05-23> STARTED Org Mode scheduling test KIWI. OTS: <2016-05-24> STARTED Org Mode scheduling test LIME. OTS: <2016-05-25> TODO Org Mode scheduling test MELON. OTS: <2016-06-16> STARTED Org Mode scheduling test TARDIGRAD= E. I haven't found any way to make that happen. After reading various Info pa= ges, I started digging into the Org Mode code. Now I'm looking at `org-age= nda-get-todos' in org-agenda.el, which calls `org-agenda-format-item', pass= ing "" as the first argument (EXTRA). The doc string for `org-agenda-forma= t-item' says: "EXTRA must be a string to replace the `%s' specifier in the prefix forma= t." I thought that maybe passing (org-agenda-get-deadlines) there instead of ""= would supply `org-agenda-format-item' with the information it needs, but a= las, that doesn't work and in fact the third call or so of `org-agenda-get-= deadlines' raises an error. (The doc strings for `org-agenda-get-todos and= `org-agenda-get-deadlines' don't say all that much; it's quite possible I'= m misunderstanding what the latter is for.) However, if I pass a hardcoded non-empty value of EXTRA to the call to `org= -agenda-format-item', it works. That is, if I pass the hardcoded string "D= EADLINE: <2016-05-24>" as the EXTRA argument in `org-agenda-get-todos', thu= s changing this line: txt (org-agenda-format-item "" txt level category tags t) to this: txt (org-agenda-format-item "FISH" txt level category tags t) ...I get this result: Global list of TODO items of type: ALL Available with =E2=80=98N r=E2=80=99: (0)[ALL] (1)TODO (2)STARTED (3)DONE OTS: FISH STARTED Org Mode scheduling test KIWI. OTS: FISH STARTED Org Mode scheduling test LIME. OTS: FISH TODO Org Mode scheduling test MELON. OTS: FISH STARTED Org Mode scheduling test TARDIGRADE. Okay, that's roughly what I expected, given that in my custom setting of `o= rg-agenda-custom-commands', I set `org-agenda-prefix-format' so that the `t= odo' entry's value has "%s" at the end. So this looks promising. But now the question is, what is the Right Way to= fetch the value of the DEADLINE keyword for the given TODO entry, at that = point in the code, so I can pass that instead of "FISH"? I had thought `or= g-agenda-get-deadlines' might do it, but that doesn't work. Or am I going about this all wrong? Hints welcome. I hope it's clear what= my goal is here, and I think it's a goal that others who use the DEADLINE = keyword for TODO items might share. This would be a great way to manage de= adlines, if it worked :-). Best regards, -Karl