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

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).

Related

org-mode habit consistency graph not displaying

org-version 8.3.4 (elpa package, 20160530)
emacs 24.4.1 (Debian package, Installed: 24.4+1-4.1~bpo70+1)
When I started using org-mode from elpa, the habit consistency graph stopped showing. I was using a version of org-mode that comes with debian before, with emacs 23 and the graph showed.
I'm a beginner in emacs lisp, but anyway I tried stepping through the org-agenda-list function and found the org-agenda-finalize function where the org habit graph is supposed to be inserted via the org-habit-insert-consistency-graphs function. But it skips over that function, probably because this expression returns false:
(next-single-property-change (point-min) 'org-habit-p))
At this point, I don't know what to do to make habits show. This is the first time I've looked at org-mode code, I don't know what the above test is for.
Help, please?
UPDATE: 2016-06-25. I upgraded the org-mode package to elpa, 20160620 (still org-version 8.3.4). Still have the same behaviour. I am getting the package from elpa.gnu.org.
UPDATE 2: 2016-07-02: I did try pressing K (for org-habit-toggle-habits). It didn't change the contents of the buffer visibly. I also tried refreshing the buffer after typing K. And repeating the experiment, in case the K put emacs in the wrong mode the first time.
UPDATE 3: 2016-07-08: on the emacs-orgmode mailing list, I got advice to ensure that the structure of the entries with habits is:
headline
SCHEDULED
PROPERTIES
everything else
by using this function org-repair-property-drawers from this site:
http://orgmode.org/Changes.html
but that broke my weekly agenda display and also, once I fixed the entries, didn't make the habits work. Probably my entries were in worse shape than the function anticipated. But this method worked for Josiah who sent the advice. Including it here in case it helps someone else.
UPDATE 4: 2016-07-09: thanks Phil for the suggestion to make a minimal example of the problem. With the following .org file and no other, I see the problem:
** TODO daily customer meeting :SUPPORT:CUSTOMER:
:SCHEDULED: <2016-07-06 Wed 10:30 .+1d>
:PROPERTIES:
:LAST_REPEAT: [2016-07-05 Tue 12:00]
:STYLE: habit
:END:
:LOGBOOK:
- State "DONE" from "TODO" [2016-07-05 Tue 12:00]
- State "DONE" from "TODO" [2016-06-30 Thu 16:34]
- State "DONE" from "TODO" [2016-06-29 Wed 20:02]
- State "DONE" from "TODO" [2016-06-28 Tue 10:53]
- State "DONE" from "TODO" [2016-06-27 Mon 10:50]
- State "DONE" from "TODO" [2016-06-23 Thu 12:11]
- State "CANCELLED" from "TODO" [2016-06-21 Tue 13:43] \\
No meeting today, cancelled by Mmmm.
:END:
I'm using the minimal.emacs suggested in the link, namely:
(add-to-list 'load-path (expand-file-name "/home/bjb/.emacs.d/elpa/org-20160620"))
(add-to-list 'auto-mode-alist '("\\.\\(org\\ |org_archive\\|txt\\)$" . org-mode))
(setq org-agenda-files '("/home/bjb/.emacs.d/test/test.org"))
(require 'org-install)
(require 'org-habit)
;(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
;(global-set-key "\C-cb" 'org-iswitchb)
And showing the agenda with C-c a a.
I had added the leading colon to the SCHEDULED line... when I remove it, the graph shows up. However, I had added it (a while ago) because I was trying to solve other problems, which I don't remember what they were.
I will play with this, and see if I can get all my org files to load fully with habit-consistency-graphs. Thanks ... will report back with results.
Must note that when I looked at this particular item (which is a short version of an actual habit in my org-files) there were two PROPERTY drawers, one before LOGBOOK with just the LAST-REPEAT property, and one after LOGBOOK with the habit property. I merged the two property drawers to show you the failure, as I believe the PROPERTY drawer is supposed to be in one piece before the LOGBOOK drawer. So I have some maintenance to do on my org-files. I had tried to merge them into one piece in each habit before, but then agenda weekly view broke badly and I put it back the way it was. Will have to try harder.
UPDATE 5 2016-07-09: I had put in the leading colon before SCHEDULED: because I wanted to see when the 3-monthly items fell in the future ... I wanted to see them as scheduled items. That worked but when I upgraded org-mode the consistency graph went away. When I took off the leading colon on all the habits, the daily habits showed up, and I have confidence that the three-monthly items will show up when they fall on "today". But I won't get any notice of having to pay the interest ... it will just appear on the day it must be paid. Well that is for me to figure out.
Thanks everyone for considering and answering my question.
I had a similar problem today, and it turns out that somehow the habit module was turned off (but the recurrent tasks still stays in the agenda so I didn't make the connection). When I re-enable the module (M-x customize variable org-modules then tick on habit), the consistency graph displays as normal in the agenda's view.
This won't solve your issue but might help a bit:
http://orgmode.org/worg/org-faq.html#minimal-emacs
Maybe you have turned them off somehow? Does pressing 'K' in the agenda help?
I've had the same problem after upgrading org-mode from version 8.2.10 to 9.1.9 (because of this bug).
Here is what an entry was looked like (org-version = 8.2.10) :
** TODO Sleep in time
SCHEDULED: <2019-09-07 sam. 23:00 +1d>
- State "DONE" from "TODO" [2019-09-07 sam. 02:54]
- State "DONE" from "TODO" [2019-09-06 ven. 02:09]
- State "DONE" from "TODO" [2019-09-05 jeu. 00:29]
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: [2019-09-07 sam. 02:54]
:END:
... and what i've done so that the graph show up again (org-version = 9.1.9) :
** TODO Sleep in time
SCHEDULED: <2019-09-07 sam. 23:00 +1d>
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: [2019-09-07 sam. 02:54]
:END:
- State "DONE" from "TODO" [2019-09-07 sam. 02:54]
- State "DONE" from "TODO" [2019-09-06 ven. 02:09]
- State "DONE" from "TODO" [2019-09-05 jeu. 00:29]
As it's showed, I've swapped up the PROPERTIES drawer and the "log" list.
EDIT:
I just realised that this solution is exactly the same as #schmuu suggested (I don't use LOGBOOK drawer). I got the same conclusion by creating a repeating entry and marked it as done in the agenda view. The "log" item list had appeared after the PROPERTIES drawer.

How to avoid logging intermediate process states in Org-mode?

In Org-mode a task can have one of several process states (e.g. TODO, DONE...). The process state list is configurable and the user may either set a task state directly, or they may cycle over all states using the S-Left and S-Right key combinations.
What I find counter-intuitive, however, is the interaction between state change tracking and the use of the S-Left and S-Right keys. More specifically, when using those keys one may go over several states before settling on the one they need, especially if they type too fast and skip a desired state. Unfortunately, Org-mode will happily log every single one of those state changes, despite the fact that they happened within a few seconds and cannot correspond to what happened with an actual real-life task.
Is there a way to have Org-mode filter the generated log entries, so that those intermediate state changes are not inadvertently logged? E.g. a setting that would merge state changes when they happen in less than X seconds?
To select a TODO state and bypass any logging associated with that, use:
(setq org-treat-S-cursor-todo-selection-as-state-change nil)
in your Emacs configuration file.
Call org-todo with a prefix argument using C-u followed by a number. This avoids the extra window.
From M-x describe-function RET org-todo RET:
With C-u prefix arg, use completion to determine the new state. With
numeric prefix arg, switch to that state. With a double C-u prefix,
switch to the next set of TODO keywords (nextset). With a triple C-u
prefix, circumvent any state blocking. With a numeric prefix arg of 0,
inhibit note taking for the change.
So, using the example from the manual you linked, let's say you had the following workflow states defined:
(setq org-todo-keywords
'((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
And you had the following in an org file:
* TODO Go Grocery Shopping
You could go immediate from TODO to DONE by typing C-u 4 C-c C-t. The result should look something like:
* DONE Go Grocery Shopping
:LOGBOOK:
- State "DONE" from "TODO" [2014-10-30 Thu 09:20]
:END:
Assuming you have the following in your init.el / .emacs file (which I highly recommend):
(setq org-log-into-drawer t)
Keep in mind if you have multiple workflow states defined (e.g. one for tasks, one for events, etc.), the prefix number goes in order of the keywords. Org-mode doesn't distinguish between different workflow sequences.

org-mode: Schedule a task multiple times

Suppose I plan to meet with someone multiple times, but not on a regular schedule that would allow me to set it as a repeating task. I can type in something like
** TODO Meeting with Gus
SCHEDULED: <2014-04-25 FRI 10:00-10:30>
SCHEDULED: <2014-04-28 MON 15:30-16:00>
Scheduling the first meeting using C-c C-s (org-schedule) is easy enough. I cannot find a way to schedule the second without typing everything in by hand. If I hit C-c C-s again, it changes the time of the first meeting rather than scheduling a second meeting. Is there a more efficient way to do this?
How about:
** Meet with a dude
<2014-04-25 Fri 13:00-13:30>
<2014-04-27 Sun 14:00-14:30>
<2014-04-29 Tue 10:00-10:30>
<2014-05-02 Fri 08:00-08:30>
This will show up in your agenda at the indicated times.

How to view the taken "Notes" in a new buffer in Emacs Org Mode?

I use Emacs Org mode to deal with my daily staffs. Now I use Emacs to manage some research papers. When reading the papers, I would like to take some notes as the following using the shortcut key C-c C-z or only z in the Agenda View.
When taking a new note it looks like this:
However, after completing the note taking with C-c C-c, the note is stored in the LOGBOOK under where it was taken:
The first problem is that the note itself is not highlight. The second problem is that, if I would like to revise this note, I do not know how to display it as when it was taken(just as in the first picture above, in a new buffer with highlight). It seems that I could only revise this note under the "Note taken on ..." line with no highlight plain text.
However, I am not pleased with this editing method since it should be as the same as the first picture, i.e., when the note was first created.
Thanks for your attention and help.
In addition to using subtasks (as discussed in the comments underneath the initial question in this thread), here is an alternative approach that places the notes at the tail end of a task without any blank lines between sentences. The stock org-mode has the ability to handle this -- i.e., no modifications are required (other than keywords and priority settings)
** Active [#A] 0 # Ender's Game (Orson Scott Card). :lawlist:
DEADLINE: <2014-02-22 Sat 08:00> SCHEDULED: <2014-02-22 Sat>
:PROPERTIES:
:ToodledoID: 353081871
:ToodledoFolder: TASKS
:Hash: 680920196368d9f25c95c09063243a7f
:END:
• This novel was of particular interest because . . .
• Orson Scott Card has written other books . . .
• Compare and contrast Ender's brother and sister.
(source: lawlist.com)
(source: lawlist.com)

Weekly repeating tasks emacs org-mode

I want to track habits using org-mode. For example, I want to do exercise 3 times every week. Is there a way to schedule 3 times a task every week irrespective of the date in org-mode?
You should be able to more or less do that using org habit tracking (See: Org-Habits).
To load org-habits you would need to add it to org-modules
(add-to-list 'org-modules "org-habit")
Then:
Use C-c C-s to set SCHEDULED.
Use C-c C-t to set your exercise TODO.
Use C-c C-x p to have the STYLE Property habit (add in any other properties as desired as well).
Now the lines like this should have be appended after the title:
:PROPERTIES:
:STYLE: habit
:END:
A single habit should suffice, it will not be exactly 3 times per week, but over time it will average out to such. If you use a scheduled repeater that is .+2d/3d you will be prompted to perform the habit no more often than every second day, and no less often than every 3. (This averages out to 2.9 times per week if you continue it long enough. Over 6 weeks (42 days) you would complete it at least 14 times, at most 21, or 17.5 on average. 18 times in 6 weeks would be 3x per week).
Your final habit should look something like this initially, as you complete it DONE logging will be added in and the last-repeat will be kept track of as a property:
** TODO Exercise
SCHEDULED: <2012-01-06 Fri .+2d/3d>
:PROPERTIES:
:STYLE: habit
:END:
Note: If you get the error Symbol's value as variable is void: org-modules when trying to load the org-habit module, you might want to try the following instead:
(require 'org)
(require 'org-install)
(add-to-list 'org-modules "org-habit")
You can use a timestamp with repeater interval as described in the
manual.
A timestamp may contain a _repeater interval_, indicating that it
applies not only on the given date, but again and again after a
certain interval of N days (d), weeks (w), months (m), or years
(y). The following will show up in the agenda every Wednesday:
* Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
I can't see any way to do this with one entry. The way I do similar things is to create a special TODO sequence for is, say (sequence ('HABIT' '|' 'CHECK')) with setq org-todo-keywords
Then simply write three entries, each on a week repeat
* HABIT Monday workout
DEADLINE: <2012-01-09 Mon +1w>
* HABIT Wednessday workout
DEADLINE: <2012-01-11 Wed +1w>
* HABIT Friday workout
DEADLINE: <2012-01-06 Fri +1w>
It's not that clean, but it works.