I've posted before on using Brent Hansen's amazing org setup. This time around, I'm specifically having a problem with getting org-mode to display my habits.
I had to nuke my emacs and start from scratch recently, so debugging is hard.
I am quite certain that I have habit mode enabled since:
I have enabled in my .emacs (see below)
;; Enable habit tracking
(setq org-modules (quote (org-habit)))
; position the habit graph on the agenda to the right of the default
(setq org-habit-graph-column 50)
(run-at-time "06:00" 86400 '(lambda () (setq org-habit-show-habits t)))
My capture template for habits, seems to set up to include everything needed:
("h" "Habit" entry (file "~/Dropbox/org-new/refile.org")
"* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n")
I have an additional set of properties in my Top Level Header for habits that reads:
* Habits
:PROPERTIES:
:LOGGING: DONE(!)
:ARCHIVE: %s_archive::* Habits
:END:
When I run the agenda, I see (Org-Agenda Day Ddl Grid Habit Wrap) in the Mode line
Despite that, my habits do not show up, nor does a habit graph, when I run the agenda. I've trawled everything I can to try and solve this and I'm now at my wit's end. Any help would be greatly appreciated!
You need to add a :STYLE: property with the value habit to your habits:
** TODO Shave
SCHEDULED: <2009-10-17 Sat .+2d/4d>
- State "DONE" from "TODO" [2009-10-15 Thu]
- State "DONE" from "TODO" [2009-10-12 Mon]
- State "DONE" from "TODO" [2009-10-10 Sat]
- State "DONE" from "TODO" [2009-10-04 Sun]
- State "DONE" from "TODO" [2009-10-02 Fri]
- State "DONE" from "TODO" [2009-09-29 Tue]
- State "DONE" from "TODO" [2009-09-25 Fri]
- State "DONE" from "TODO" [2009-09-19 Sat]
- State "DONE" from "TODO" [2009-09-16 Wed]
- State "DONE" from "TODO" [2009-09-12 Sat]
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: [2009-10-19 Mon 00:36]
:END:
See Tracking your habits.
EDIT: While the STYLE:habit property is necessary, that isn't the problem in this case (as discussed in the comments). However, it might well be that the order of the elements in the headline is the problem. Running org-lint on the following example:
* NEXT Exercise
[2017-07-16 Sun 19:36]
[[file:~/Dropbox/org-new/todo.org::*Write][Write]]
SCHEDULED: <2017-07-16 Sun .+1d/2d>
:PROPERTIES:
:STYLE: habit
:REPEAT_TO_STATE: NEXT
:END:
I get
3 low Link to non-existent local file "~/Dropbox/org-new/todo.org"
4 low Misplaced planning info line
5 high Incorrect location for PROPERTIES drawer
If I reorg the file a bit to this:
* NEXT Exercise
SCHEDULED: <2017-07-16 Sun .+1d/2d>
:PROPERTIES:
:STYLE: habit
:REPEAT_TO_STATE: NEXT
:END:
[2017-07-16 Sun 19:36]
[[file:~/Dropbox/org-new/todo.org::*Write][Write]]
then the high priority warning disappears. I don't know whether that will make habits work, but I'm willing to bet that it would.
The manual states:
When they are associated with a single entry or with a tree they need to be inserted into a special drawer (see Drawers) with the name PROPERTIES, which has to be located right below a headline, and its planning line (see Deadlines and scheduling) when applicable.
Related
I use org-habit to keep track of some of my recurring tasks in org-mode.
By default the habits show up in my agenda view (along with their progress graph) if they are scheduled for the current day. Once I mark a habit task as done, it disappears from the agenda view.
Sometimes I want to see how I'm doing with my all my habits. What I want to see is an agenda view that shows all tasks that are habits (along with their progress graph) and only those tasks (i.e. tasks that aren't habits should be excluded).
How do I construct such an agenda view?
I know I can use org-habit-show-habits-only-for-today to show all habits in the agenda, even if they aren't scheduled today. However, I can't figure out how to exclude those tasks that aren't habits.
An item is a habit if and only if the STYLE property is set to habit. You can search for this using the built-in agenda search (C-c a s) and searching for STYLE="habit".
To exclude non-habits from daily agenda view you can set org-agenda-skip-function variable in your custom agenda view definition (org-agenda-custom-commands) as:
(org-agenda-skip-function
(lambda ()
(unless (string-equal (org-entry-get (point) "style") "habit")
(outline-next-heading))))
Using Emacs Org-mode synchronised with Toodledo I have the variable org-todo-keywords set to
((sequence "TODO" "NEXT" "|" "DONE")
(sequence "WAITING" "HOLD" "SOMEDAY" "|" "CANCELLED"))
When want the built-in agenda view weekly/daily agenda by typing C-c a a I get all task that is not in the todo state DONE.
How can I set Org-mode making the command C-c a a only return tasks of todo states TODO and NEXT?
Of cause I can make a custom agenda view but I guess there is a variable that limits the todo states or an other simple way of modifying org-mode setting the built-in agenda view to fulfil my needs.
Thanks in advance
Here is just one solution -- there are others:
(org-agenda-skip-entry-if 'notregexp "regular expression")
http://orgmode.org/manual/Special-agenda-views.html
see also
http://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.html
Other settings that include filtering out completed tasks for deadline and scheduled are as follows:
(org-agenda-skip-scheduled-if-done t)
(org-agenda-skip-deadline-if-done t)
EDIT (April 26, 2014): Included working example:
(setq org-agenda-custom-commands '(
("1" "Events" agenda "my-calendar" (
(org-agenda-span 365)
(org-agenda-show-all-dates nil)
(org-agenda-entry-types '(:deadline))
(org-agenda-skip-function
'(org-agenda-skip-entry-if 'notregexp "\\* TODO\\|\\* NEXT"))
(org-deadline-warning-days 0) ))))
I've been trying to make an org capture template for storing quick ideas to my current project so I can get back to what I'm working on and evaluating the notes later.
This is the template code:
(setq org-capture-templates '(
("a" "quick notes" entry (file+olp "~/myproject" "NOTES" "IDEAS")
"") ))
When I hit C-c c a *** invent flying light bulb RET this is what I expect the target will look like:
* NOTES
** IDEAS
*** invent flying light bulb
Instead I get:
* NOTES
** IDEAS
*** invent flying light bulb
$THE-HEADING-THAT-THE-CURSOR-IS-ON
That is: whatever headline the cursor touches when 'org-capture is called is inserted along with my note. When I delete that string this appears:
[[file:~/$PATH-TO-FILE-I-WAS-WORKING-ON][]]
I haven't chosen any template expansions so why is this stuff inserted?
When using entry, the last field should not be blank. The example in the frequently asked questions for org-mode uses item when leaving the last field blank.
(setq org-capture-templates '(
("a" "quick notes" entry
(file+olp "~/Desktop/myproject.org" "NOTES" "IDEAS")
"*** %?") ))
With cyclic or repetitive tasks in org-mode, inside this task, if there are several checkboxes and all of them marked as ticked, after the general task is masked as DONE, the checkboxes for the next cycle period stills appear as ticked and it should be unticked. e.g.:
TODO Cyclic monthly home [0/5] SCHEDULED: <2013-11-30 Sat +1m>
[ ] pay sauna
[ ] pay electricity
[ ] pay renting
[ ] pay internet
[ ] pay union
Once I ticked all of them and put it as done, this is what I can see:
WIP Cyclic monthly home [5/5] SCHEDULED: <2014-01-30 Thu +1m>
State "DONE" from "WIP" [2013-11-06 Wed 20:49] :PROPERTIES: :LAST_REPEAT: [2013-11-06 Wed 20:49] :END:
[X] pay sauna <--- this should be unticked
[X] pay electricity <-- this should be unticked
[X] pay renting <-- this should be unticked
[X] pay internet <-- this should be unticked
[X] pay union <-- this should be unticked
Tested in versions:
Emacs version:
*GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars) of 2013-08-30 on apocalipsis*
Org-mode version:
*Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef # /usr/local/share/emacs/24.3/lisp/org/)*
Update: solved following these instructions:
1. In the emacs configuration file .emacs include:
(add-to-list 'load-path (expand-file-name "~/path_to_file_org-checklist.el/"))
(require 'org-checklist)
Note: If you do not have the file, you can download from here
2. Inside the file mytasks.org after the TODO task, but before the checkboxes include those lines:
:PROPERTIES:
:RESET_CHECK_BOXES: t
:END:
3. Verify that it works
Just close the task with C-c C-t and you will see the checkboxes unticked.
If I understand you correctly, the situation is: you have a repeating task with subitems as checkboxes. When the task is completed, all the checkboxes on the subitems should be cleared - so the task can be done at next cyclic time.
Set property RESET_CHECK_BOXES on the task to t
make sure org-checklist is one of the loaded modules (via variable org-modules)
You can untick a range of checkboxes with C-c C-x C-b on selected region.
This calls the org-toggle-checkbox command.
org-checklist.el has been moved to https://git.sr.ht/~bzg/org-contrib before Org 9.5. So if you are using the latest, you have to get it from there. The code works as is. If you've been loading org-mode/contrib/lisp/, you can change it pointing to org-contrib/lisp/ and it should all work as it used to.
(use-package org
:load-path ( "~/src/org-mode/lisp"
"~/src/org-contrib/lisp/")
If you just want to reset your checkboxes, you can copy a portion of it and put it in your init.el:
(defun my-org-reset-checkbox-state-maybe ()
"Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set"
(interactive "*")
(if (org-entry-get (point) "RESET_CHECK_BOXES")
(org-reset-checkbox-state-subtree)))
(defun my-org-reset-checkbox-when-done ()
(when (member org-state org-done-keywords) ;; org-state dynamically bound in org.el/org-todo
(my-org-reset-checkbox-state-maybe)))
(add-hook 'org-after-todo-state-change-hook 'my-org-reset-checkbox-when-done)
The original code is GPLv3+.
Using emacs org mode for about a month now to track all my projects and tasks.
I clock all activities throughout my day, not just work related ones.
My question is- I often forget to clock-in to a new activity (say, taking lunch). When I return and clock back in to a work activity, I need to first clock in to lunch and then adjust the starting time stamp for it. This is fine for the lunch activity, but it doesn't adjust the previous work work related task before I took lunch, so the net is that the previous task overlaps lunch and is inaccurate.
Is there a way to change the behavior so that it does adjust the previous task? I don't wish to use the idle feature to do this; I'd prefer to have the adjustment happen automatically.
ETA: This also came up again on the mailing list and there appears to be a recent commit to the code base that provides another [perhaps better] way to do this. See the mailing list discussion for Bastien's (org-mode maintainer) input:
S-M-[up/down] on a clock timestamp will try to update the previous/next
clock timestamp too.
(Actually, bzg's suggestion below is this exact thing... it just didn't have the shortcut above included, so I think his answer looks harder/less attractive than the above, which is really easy.)
You can also use org-resolve-clocks. See Resolving idle time.
Essentially, you have some headline and are clocked in:
* Work
:LOGBOOK:
CLOCK: [2012-07-25 Wed 8:26]
:END:
I come back from lunch and realize I forgot to clock out of work and into lunch.
I run M-x org-resolve-clocks and get this prompts:
Select a Clock Resolution Command:
i/q/C-g Ignore this question; the same as keeping all the idle time.
k/K Keep X minutes of the idle time (default is all). If this
amount is less than the default, you will be clocked out
that many minutes after the time that idling began, and then
clocked back in at the present time.
g/G Indicate that you "got back" X minutes ago. This is quite
different from 'k': it clocks you out from the beginning of
the idle period and clock you back in X minutes ago.
s/S Subtract the idle time from the current clock. This is the
same as keeping 0 minutes.
C Cancel the open timer altogether. It will be as though you
never clocked in.
j/J Jump to the current clock, to make manual adjustments.
For all these options, using uppercase makes your final state
to be CLOCKED OUT.
Since I want to Keep X minutes of Work, clock out, and then clock into Lunch, I press K, which prompts me with (it's ~1:30p right now):
Keep how many minutes? (default 303)
I can hit enter to keep all of them, but let's say I took lunch around 12p. That's about 3.5hrs of work, so I'll enter 210 RET.
Now, I clock into Lunch and get this prompt:
You stopped another clock 101 minutes ago; start this one from them? (y or n)
I enter y RET and Lunch gets clocked in at 11:56a. If you're back from lunch and working again (or started working and forgot), repeat the process:
M-x org-resolve-clocks
K
____ RET ;; for how many minutes you at lunch
C-c C-x C-i ;; to clock in on Work again
y RET ;; clock in at when you stopped lunch
The final result:
* Work
:LOGBOOK:
CLOCK: [2012-07-25 Wed 12:41]
CLOCK: [2012-07-25 Wed 8:26]--[2012-07-25 Wed 11:56] => 3:30
:END:
* Lunch
:LOGBOOK:
CLOCK: [2012-07-25 Wed 11:56]--[2012-07-25 Wed 12:41] => 0:45
:END:
Hope this helps. The org-mode clocking wizard, Bernt Hansen, explained this to me via an org-mode mailing list thread.
This is now implemented (check http://orgmode.org/w/?p=org-mode.git;a=commit;h=3528fc).
(setq org-clock-continuously t) in your .emacs.el and new clocks will start from the time when the last clock was closed.
C-u C-u C-u M-x org-clock-in RET and C-u C-u M-x org-clock-in-last RET will also do this, even when org-clock-continuously is set to nil.
If I understand your question correctly, you want to adjust the timestamp after clocking out. There is a command for this; you can check out the functions:
org-timestamp-up
org-timestamp-down
I thought these were bound by default, but it appears they are not, so you will want to bind them to a key sequence, maybe something like C-c T u and C-c T d, or whatever floats your boat. Usage is simple, just move the cursor over the field you want to adjust by, and run up or down. It only works on the timestamp itself, NOT the calculated duration that appears on the right.
You might also check out
org-timestamp-change
which the top two functions are wrappers for. You might also need to customize the variable
org-time-stamp-rounding-minutes
By default, it will round timestamps to +/- 5 minutes from the start of your original clock-in, and you might be puzzled when modifying the timestamp.
Personally, I prefer (setq org-time-stamp-rounding-minutes '(0 1)) which will start the timer on the exact minute I clock-in (the zero), and use a granularity of 1 minute(s) for timestamp changes. Also, you can use a prefixes like C-u 4 7 C-c T u on the minute part of timestamps, and org-mode will do the right thing - even rounding up the hour.
Summary:
(setq org-time-stamp-rounding-minutes '(0 1))
(add-hook 'org-mode-hook
'(lambda ()
(local-set-key (kbd "C-c T u") 'org-timestamp-up)
(local-set-key (kbd "C-c T d") 'org-timestamp-down)))