emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Get a list of tasks completed today
@ 2014-02-13 10:35 Sebastien Vauban
  2014-02-16 19:46 ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2014-02-13 10:35 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

To get a list of tasks which I've completed today, I guess we must have:

--8<---------------cut here---------------start------------->8---
  (setq org-log-done t) ; default
--8<---------------cut here---------------end--------------->8---

I mean: I guess it's more dangerous to try and play with the "state
changes" information stored in the LOGBOOK drawer as people can easily
modify them (see `org-log-note-headings').

Under the above assumption, the request becomes:

--8<---------------cut here---------------start------------->8---
(add-to-list 'org-agenda-custom-commands
             '("." "Completed today"
               ((todo "DONE|CANX"
                      ((org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp "CLOSED: \\[2014-02-13"))
                       (org-agenda-sorting-strategy '(priority-down)))))) t)
--8<---------------cut here---------------end--------------->8---

... for today.

But how can I include today's date in a programmatic way (so that it
continues to work tomorrow ;-))?

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-13 10:35 Get a list of tasks completed today Sebastien Vauban
@ 2014-02-16 19:46 ` Sebastien Vauban
  2014-02-17  8:07   ` Loris Bennett
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2014-02-16 19:46 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

"Sebastien Vauban" wrote:
> To get a list of tasks which I've completed today, I guess we must have:
>
>   (setq org-log-done t) ; default
>
> I mean: I guess it's more dangerous to try and play with the "state
> changes" information stored in the LOGBOOK drawer as people can easily
> modify them (see `org-log-note-headings').
>
> Under the above assumption, the request becomes:
>
> (add-to-list 'org-agenda-custom-commands
>              '("." "Completed today"
>                ((todo "DONE|CANX"
>                       ((org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp "CLOSED: \\[2014-02-13"))
>                        (org-agenda-sorting-strategy '(priority-down)))))) t)
>
> ... for today.
>
> But how can I include today's date in a programmatic way (so that it
> continues to work tomorrow ;-))?

That one is solved by doing this:

#+begin_src emacs-lisp
  (add-to-list 'org-agenda-custom-commands
               '("." "Completed today"
                 ((todo ""
                        ((org-agenda-skip-function
                          '(org-agenda-skip-entry-if 'notregexp (format-time-string "CLOSED: \\[%Y-%m-%d")))))
                         (org-agenda-sorting-strategy '(priority-down)))))) t)
#+end_src

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-16 19:46 ` Sebastien Vauban
@ 2014-02-17  8:07   ` Loris Bennett
  2014-02-17 13:40     ` Sebastien Vauban
  2014-02-17 14:12     ` Trevor Murphy
  0 siblings, 2 replies; 7+ messages in thread
From: Loris Bennett @ 2014-02-17  8:07 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

> "Sebastien Vauban" wrote:
>> To get a list of tasks which I've completed today, I guess we must have:
>>
>>   (setq org-log-done t) ; default
>>
>> I mean: I guess it's more dangerous to try and play with the "state
>> changes" information stored in the LOGBOOK drawer as people can easily
>> modify them (see `org-log-note-headings').
>>
>> Under the above assumption, the request becomes:
>>
>> (add-to-list 'org-agenda-custom-commands
>>              '("." "Completed today"
>>                ((todo "DONE|CANX"
>>                       ((org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp "CLOSED: \\[2014-02-13"))
>>                        (org-agenda-sorting-strategy '(priority-down)))))) t)
>>
>> ... for today.
>>
>> But how can I include today's date in a programmatic way (so that it
>> continues to work tomorrow ;-))?
>
> That one is solved by doing this:
>
> #+begin_src emacs-lisp
>   (add-to-list 'org-agenda-custom-commands
>                '("." "Completed today"
>                  ((todo ""
>                         ((org-agenda-skip-function
>                           '(org-agenda-skip-entry-if 'notregexp (format-time-string "CLOSED: \\[%Y-%m-%d")))))
>                          (org-agenda-sorting-strategy '(priority-down)))))) t)
> #+end_src
>
> Best regards,
>   Seb

I don't really understand the lisp, but I'm guessing that %Y, %m, and %d
hold the current year, month, and day, respectively, so I can see how
the regex could be modified to deal with "last year" and "last month".

However, more useful to me would be "last week", so what approach should
I take for that?

Cheers,

Loris

-- 
This signature is currently under construction.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-17  8:07   ` Loris Bennett
@ 2014-02-17 13:40     ` Sebastien Vauban
  2014-02-17 14:12     ` Trevor Murphy
  1 sibling, 0 replies; 7+ messages in thread
From: Sebastien Vauban @ 2014-02-17 13:40 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

"Loris Bennett" wrote:
> "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org> writes:
>> "Sebastien Vauban" wrote:
>>> To get a list of tasks which I've completed today, I guess we must have:
>>>
>>>   (setq org-log-done t) ; default
>>>
>>> I mean: I guess it's more dangerous to try and play with the "state
>>> changes" information stored in the LOGBOOK drawer as people can easily
>>> modify them (see `org-log-note-headings').
>>>
>>> Under the above assumption, the request becomes:
>>>
>>> (add-to-list 'org-agenda-custom-commands
>>>              '("." "Completed today"
>>>                ((todo "DONE|CANX"
>>>                       ((org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp "CLOSED: \\[2014-02-13"))
>>>                        (org-agenda-sorting-strategy '(priority-down)))))) t)
>>>
>>> ... for today.
>>>
>>> But how can I include today's date in a programmatic way (so that it
>>> continues to work tomorrow ;-))?
>>
>> That one is solved by doing this:
>>
>> #+begin_src emacs-lisp
>>   (add-to-list 'org-agenda-custom-commands
>>                '("." "Completed today"
>>                  ((todo ""
>>                         ((org-agenda-skip-function
>>                           '(org-agenda-skip-entry-if 'notregexp (format-time-string "CLOSED: \\[%Y-%m-%d")))))
>>                          (org-agenda-sorting-strategy '(priority-down)))))) t)
>> #+end_src

Note that the above DOES NOT WORK if you don't specify TODO states such as:

--8<---------------cut here---------------start------------->8---
                    ((todo "DONE|CANX"
--8<---------------cut here---------------end--------------->8---

I have the impression this is a bug.

Moreover, you should even add active states such as "TODO" for
repeatable actions which do go back to the "TODO" state; hence, it
becomes:

--8<---------------cut here---------------start------------->8---
                    ((todo "TODO|DONE|CANX"
--8<---------------cut here---------------end--------------->8---

> I don't really understand the lisp, but I'm guessing that %Y, %m, and %d
> hold the current year, month, and day, respectively, so I can see how
> the regex could be modified to deal with "last year" and "last month".
>
> However, more useful to me would be "last week", so what approach should
> I take for that?

I guess you should begin playing with things such as:

--8<---------------cut here---------------start------------->8---
  (time-add (current-time) (seconds-to-time -86400))
--8<---------------cut here---------------end--------------->8---

to point to yesterday, etc.

But I'm not sure this is the right approach...

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-17  8:07   ` Loris Bennett
  2014-02-17 13:40     ` Sebastien Vauban
@ 2014-02-17 14:12     ` Trevor Murphy
  2014-02-17 14:33       ` Trevor Murphy
  2014-02-17 15:27       ` Nick Dokos
  1 sibling, 2 replies; 7+ messages in thread
From: Trevor Murphy @ 2014-02-17 14:12 UTC (permalink / raw)
  To: emacs-orgmode

"Loris Bennett" <loris.bennett@fu-berlin.de> writes:

>> #+begin_src emacs-lisp 
>>   (add-to-list 'org-agenda-custom-commands 
>>                '("." "Completed today" 
>>                  ((todo "" 
>>                         ((org-agenda-skip-function 
>>                           '(org-agenda-skip-entry-if 'notregexp 
>>                           (format-time-string "CLOSED: 
>>                           \\[%Y-%m-%d"))))) 
>>                          (org-agenda-sorting-strategy 
>>                          '(priority-down)))))) t) 
>> #+end_src 
>> 
> 
> However, more useful to me would be "last week", so what 
> approach should I take for that? 

I get pretty decent mileage out of this command (note that it's a 
tags search, not a todo keyword search.)   (add-to-list 
'org-agenda-custom-commands '("." "Closed this week."  tags 
"CLOSED>\"<-1w>\"" ((org-agenda-sorting-strategy 
'(priority-down)))))  Though now I've got a related question.

One thing I'd like to do is run a function over every item that 
was closed this past week.  For sake of example, let's say I've 
added a property ":mood: 5" to several closed items and I'd like 
to delete it (but only from the closed items; I'm not necessarily 
deleting the property globally.)

To do this I tried pulling all the closed items, visiting them in 
turn, and calling (org-delete-property "mood").  But I got stuck 
pulling all the closed items, because `org-tags-view' and friends 
all build an agenda as a side effect.

Is my best bet simply re-implementing the parts of `org-tags-view' 
that I need?

Or is there a more common way to use the org machinery to work 
with items in lisp code? 

Thanks!

--
Trevor Murphy
GnuPG Key: 0x83881C0A

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-17 14:12     ` Trevor Murphy
@ 2014-02-17 14:33       ` Trevor Murphy
  2014-02-17 15:27       ` Nick Dokos
  1 sibling, 0 replies; 7+ messages in thread
From: Trevor Murphy @ 2014-02-17 14:33 UTC (permalink / raw)
  To: emacs-orgmode

Boo, reflowed text or some nonsense.  Let's see if this works 
better:

(add-to-list 'org-agenda-custom-commands
             '("." "Closed this week."
               tags "CLOSED>\"<-1w>\""
               ((org-agenda-sorting-strategy '(priority-down)))))

--
Trevor Murphy
GnuPG Key: 0x83881C0A

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Get a list of tasks completed today
  2014-02-17 14:12     ` Trevor Murphy
  2014-02-17 14:33       ` Trevor Murphy
@ 2014-02-17 15:27       ` Nick Dokos
  1 sibling, 0 replies; 7+ messages in thread
From: Nick Dokos @ 2014-02-17 15:27 UTC (permalink / raw)
  To: emacs-orgmode

Trevor Murphy <trevor.m.murphy@gmail.com> writes:

> ...
> One thing I'd like to do is run a function over every item that was
> closed this past week.  For sake of example, let's say I've added a
> property ":mood: 5" to several closed items and I'd like to delete it
> (but only from the closed items; I'm not necessarily deleting the
> property globally.)
>
> To do this I tried pulling all the closed items, visiting them in
> turn, and calling (org-delete-property "mood").  But I got stuck
> pulling all the closed items, because `org-tags-view' and friends all
> build an agenda as a side effect.
>
> Is my best bet simply re-implementing the parts of `org-tags-view'
> that I need?
>
> Or is there a more common way to use the org machinery to work with
> items in lisp code? 
>

You should be able to do this with the mapping and property APIs:

(info "(org) Using the mapping API")
(info "(org) Using the property API")

--
Nick

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-17 15:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13 10:35 Get a list of tasks completed today Sebastien Vauban
2014-02-16 19:46 ` Sebastien Vauban
2014-02-17  8:07   ` Loris Bennett
2014-02-17 13:40     ` Sebastien Vauban
2014-02-17 14:12     ` Trevor Murphy
2014-02-17 14:33       ` Trevor Murphy
2014-02-17 15:27       ` Nick Dokos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).