Org-Mode Custom Agenda View: Show Status Of All Current Habits - emacs

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

Related

Make emacs org-mode deadlines and scheduled blocked tasks visible in agenda view

Here are the relevant parts of my .emacs
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
(setq org-agenda-dim-blocked-tasks 'invisible)
When I visit my agenda view I want to see tasks which are scheduled or have a deadline (even if they are blocked by another task and are therefor stricly speaking rightly invisible).
Currently those tasks are not visible whilst they are being blocked by other tasks.
I would however prefer that an exception be made for these tasks which have been scheduled or given a deadline and that they be made visibile so that I maintain active awareness of them.
This could be accomplished by splitting off the scheduled and deadline tasks with a custom agenda view. Only scheduled and deadline items would be shown in the first block, and the setting to make blocked tasks invisible can be applied to uniquely to a the second block. For example:
;; Retain your default settings
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
(setq org-agenda-dim-blocked-tasks t)
;; Create the custom agenda view
(setq org-agenda-custom-commands
'(("c"
"Agenda to show deadlines & hide blocked"
(
(agenda ""
((org-agenda-entry-types '(:deadline :scheduled))))
(tags-todo "-TODO=\"DONE\""
((org-agenda-skip-entry-if 'deadline 'scheduled)
(org-agenda-dim-blocked-tasks 'invisible)))
))))
Isn't it because of your setting:
(setq org-agenda-dim-blocked-tasks 'invisible)
?

How to mark all TODO in emacs org mode as DONE or all "DONE" as "TODO"?

In emacs org mode, we can do task management, but what if I want to write a step-by-step instruction which has a number of TODOs. I will perform those TODOS, then mark them as DONE.
Now If I need to reuse that step-by-step instruction, is it possible if I can mark all the DONE items as TODO in one shot?
This will change all marked DONE to TODO, and ignore other headlines.
(org-map-entries (lambda ()
(when
(string=
(nth 2 (org-heading-components)) "DONE")
(org-todo "TODO"))))
Throwing a couple of ideas:
replace string "DONE" with M-%
narrow to current buffer, display agenda will all "DONE" tasks, select them, and apply a bulk command to change state back to "TODO".
I clone a task for that. You need to have your step-by-step guide always in TODO mode than, when you need to complete a guide, clone the parent task (C-c C-x c) and tick only the cloned tasks.

Limiting todo-keywords returned from Org-mode's built-in weekly/daily agenda

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

How to make org-mode refiled items visible in the logbook agenda view

In my .emacs file, I have the variable setting '(org-log-refile (quote time)). This means that when I refile something with C-c C-w, an inactive timestamp is added, for example:
* TODO a task
- Refiled on [2013-10-13 Sun 15:17]
When I am in an org-mode calendar agenda view, hitting l (that's a lower-case L, not a 1) triggers org-agenda-log-mode. This means that I see clocked items added to my agenda. However, I do not see refiled items, which is not what I would expect. For what it may be worth, I already have the following variable setting in my .emacs file as well: '(org-agenda-log-mode-items (quote (closed clock state)))
So, how do I get refiled items to appear on my agenda when in org-agenda-log-mode?
You need to set org-agenda-include-inactive-timestamps to 't
Either by (setq org-agenda-include-inactive-timestamps 't) or by adding it ot your org-agenda-custom-commands as one of the options, e.g.:
(agenda ""
((org-agenda-span 'day)
(org-agenda-include-inactive-timestamps 't)))
Adding this as part of org-agenda-custom-commands makes the variable let-bound. It will only apply to the current agenda and not set as a default. If you want it set as a default for all agenda commands you can use the following:
(setq org-agenda-include-inactive-timestamps 't)

How to truncate the long task name in the agenda custom view?

In emacs org-mode, I define some org-agenda-custom-commands. But some task names are too long than the screen in the Org Agenda buffer.
How to truncate the long task name in the agenda custom view?
The display of the agenda will reflect the setting of Emacs' truncate-lines variable. The function toggle-truncate-lines is the easiest way to flip this on or off interactively. Org-mode also provides the org-startup-truncated variable which will govern what the default value for truncate-lines should be throughout org-mode:
Non-nil means entering Org-mode will set `truncate-lines'.
This is useful since some lines containing links can be very long and
uninteresting. Also tables look terrible when wrapped.
If you really want to have truncation turned off globally (including in Org-mode buffers) but you want lines in your agenda to wrap then you can add something to org-agenda-mode-hook to disable the option:
(defun my/org-agenda-mode-hook ()
(interactive)
(setq truncate-lines nil))
(add-hook 'org-agenda-mode-hook
'my/org-agenda-mode-hook)