org-mode agenda view with late recurring tasks at top - emacs

I have some TODO's in my recur.org file which look like this:
** TODO Do this thing every day.
SCHEDULED: <2016-09-19 Mon .+1d>
For me, that . before the +1d means "if you happen to do this job late, then when you mark it as done it will re-schedule itself to the day after when it was marked as done." This is correct, because this job does have the property that if I don't do it for 4 days, then I don't need to do it 4 times to catch up, I just need to do it once. On the other hand, if I don't do it for 4 days then I really need to get this job done and I would hope that it gets flagged up in red when I look at my weekly agenda view with C-c a a in emacs org-mode.
Unfortunately, this does not happen. The standard agenda view lists this task as
[stuff in red here with Sched. 4x etc etc]
recur: Scheduled: TODO [#A] Do this thing every day
and the entry is in green with no indication that I'm late. This is presumably because the fact that it is scheduled every day means in particular that it is scheduled today, and so hang the fact that it's still also scheduled 4 days ago.
This is not the behaviour I want. I would like to be able to make a repeated TODO which, when done, resets the scheduled time to today+[interval], and yet I am still warned if I fail to do the task for a time period which exceeds the interval.
Experiments indicate that jobs with things like .+1w behave the same way -- they're 6 days overdue and then all of a sudden they're not overdue any more.
Could I write a custom agenda command somehow, to ensure these jobs are flagged when they are late?
Added 3rd Oct: Some further experimentation has revealed that the dot isn't the problem -- this is also the default behaviour with recurring TODOs that just are due to be rescheduled after a time delay shorter than the time it's taken me to fail to do them.
However I am now slightly more optimistic that this can somehow be solved with a custom agenda view. For C-c a L gives me a view where the recurring task shows up on the first day it's scheduled and not done, rather than the most recent day it's scheduled and not done. However C-c a L is no good for three reasons: (1) it shows tasks which are DONE (2) it shows priority C tasks which are late (and I am much less interested in these) and (3) it only acts on the current buffer. So if I learn enough about agenda views I feel like I might be able to answer my own question.
Added 9th Oct: Having now read the relevant pages of the org manual I realise that I still do not know how to do this. I am surprised. What I am asking for is an agenda view which encompasses all my org files, gives me a weekly agenda like C-c a a, and which flags the first not-yet-done occurrence of each repeating TODO task which has priority A. From a purely logic/programming point of view I don't see any obstruction to this, and I would be quite surprised if there were no way to do this in org-mode, but I certainly can't find it. Help!

Related

org mode repeated task up to a certain date/after x number of occurrences

I am new to org-mode, and I am currently learning how to use the habit/TODO features. I would like to add a repeated task that will stop after a certain number of occurrences, or up to a certain date.
If I look here, it seems I can use :PROPERTIES: as in
** TODO Shave
SCHEDULED: <2009-10-17 Sat .+2d/4d>
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: [2009-10-19 Mon 00:36]
:END:
However, C-c C-x p does not give me LAST_REPEAT option, and I was wondering what I can do.
The "LAST_REPEAT" property records when the habit was last done, it isn't "repeat up to this date". AFAICT there isn't a way of specifying to repeat something N times or up until a specific date.
When you press TAB at the Property: prompt, you get a list of possible completions, but you are not limited to them. You can always type LAST_REPEAT at the Property: prompt (and it will add it to the completion list as well).

What's a good workflow for keeping track of which TODO items I've worked on in the last week in org-mode?

Right now I'm just using inactive timestamps for some TODO items and updating them when I'm working on that item. I figured out how to get them to show up in the Timeline view.
Is there a better workflow to achieve this? Especially e.g. having a quicker way to update the timestamp on an item.
As already mentionned, you definitely have to use clocking commands for this (C-c C-x C-i/j/o). See the manual.
Then, when jumping on whichever day or week (or ...) of the agenda view, you can ask for seeing those "hidden" past entries by pressing 'v l' (view > log). Press 'v' in the agenda, and have a look at all possible commands ('v [' as well for viewing the inactive timestamps).

To which specific order corresponds the option "todo-state-up" of org-agenda-sorting-strategy

The documentation of org-agenda-sorting-strategy is quite vague when describing the two following sorting strategy. It specifies only how the tags are ordered between done and not done, but does not say anything about how the tags are ordered inside both classes:
todo-state-up Sort by todo state, tasks that are done last.
todo-state-down Sort by todo state, tasks that are done first.
If I list all tasks using a simple agenda command as the following
("z" "TEST" tags-todo ""
(
(org-agenda-sorting-strategy '(todo-state-up)) ;; Sort by todo state, tasks that are done last.
)
)
the (todo) tasks are displayed in the order MAYB TODO NEXT ACTF PAUS WAIT, which does not correspond either to the alphabetical order, neither to the order in my org-todo-keywords:
(sequence "ACTF(a!)" "PAUS(p#)" "WAIT(w#)" "NEXT(n!)" "MAYB(m!)" "TODO(t!)"
"|"
"DONE(d#)" "CANC(c#)"
)
(sequence "KNOW(k#/!)" )
I will get around and program my own org-agenda-cmp-user-defined function to order according to the position of the todo-keyword in org-todo-keywords, but I am surprised that todo-state-up does not already corresponds to this (and I am not feel proficient enough in LISP to dive in the code of org-mode yet).
(I am using Org-mode version 7.7 (release_7.7.615.g02c26.dirty) on GNU Emacs 23.3.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.0) of 2011-04-01)
Actually, after restarting org-mode with the new value of org-todo-keywords, it turns out that todo-state-up does use the order of org-todo-keywords.
So I have my display of tasks ordered by todo-keywords now, which really simplifies the writing of agenda shortcuts, and tremendously speed-up their execution (one single instruction as opposed to one per keyword).
Yay!
I ran into this exact same confusion, and restarting still didn't fix the problem. What I realized eventually was that I had TODO cycling order further customized using #+SEQ_TODO:, which was overriding the order of my global org-todo-keywords variable.

Org-mode: divide agenda by blocks of 20 items

I want to implement Autofocus system in org-mode using agenda views. Autofocus is a time-management system, where you write tasks in a lined notebook with 25-35 lines on a page and you don't start working on the next page until you processed the current page.
By default agenda collects all todos and throws them in a buffer altogether. I want to break these todos by blocks of 20 tasks, for example, so i can process one batch of 20 tasks, then another batch, and so on.
How can i do it? Any solution from using org-mode built-in trick to some emacs lisp snippet is appreciated.
I don't see this going the same way as the agenda usually goes, i.e. chronology, so I don't think there are meant-to-be ways to do that. What comes to my mind, though, is defining your batches with tags (: in the agenda to set tags, say on the first 20), then filtering by tags (/ SPC to filter on tags of the current line).
The first idea I had was basically the same with priorities : S-<up> in the agenda to set them, but then filtering by priority is described here on the mailing list, but doesn't seem that easy.
From the documentation, org-agenda-max-todos and org-agenda-max-entries might be what you are looking for.
Note: I have never used them. I came across these a while ago

How to periodically run a task within emacs?

Is there a way to periodically run an elisp function in a long-running emacs, similar to cron, but within the emacs process?
For example I want to "automatically run (recentf-save-list) every half hour" because it otherwise only runs on exit, which sucks when emacs occasionally crashes. (There are other examples as well so looking for a general solution rather than one in particular for recentf).
Check out run-with-timer.
(run-with-timer 0 (* 30 60) 'recentf-save-list)
You might also find midnight mode useful. One can arbitrarily define 'midnight' and then add hooks as desired.