Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

10101 lines (9418 sloc) 399.582 kb
;;; org-agenda.el --- Dynamic task and appointment lists for Org
;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;; This file contains the code for creating and using the Agenda for Org-mode.
;;
;; The functions `org-batch-agenda', `org-batch-agenda-csv', and
;; `org-batch-store-agenda-views' are implemented as macros to provide
;; a convenient way for extracting agenda information from the command
;; line. The Lisp does not evaluate parameters of a macro call; thus
;; it is not necessary to quote the parameters passed to one of those
;; functions. E.g. you can write:
;;
;; emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a" org-agenda-span 7)'
;;
;; To export an agenda spanning 7 days. If `org-batch-agenda' would
;; have been implemented as a regular function you'd have to quote the
;; symbol org-agenda-span. Moreover: To use a symbol as parameter
;; value you would have to double quote the symbol.
;;
;; This is a hack, but it works even when running Org byte-compiled.
;;
;;; Code:
(require 'org)
(require 'org-macs)
(eval-when-compile
(require 'cl))
(declare-function diary-add-to-list "diary-lib"
(date string specifier &optional marker globcolor literal))
(declare-function calendar-absolute-from-iso "cal-iso" (date))
(declare-function calendar-astro-date-string "cal-julian" (&optional date))
(declare-function calendar-bahai-date-string "cal-bahai" (&optional date))
(declare-function calendar-chinese-date-string "cal-china" (&optional date))
(declare-function calendar-coptic-date-string "cal-coptic" (&optional date))
(declare-function calendar-ethiopic-date-string "cal-coptic" (&optional date))
(declare-function calendar-french-date-string "cal-french" (&optional date))
(declare-function calendar-goto-date "cal-move" (date))
(declare-function calendar-hebrew-date-string "cal-hebrew" (&optional date))
(declare-function calendar-islamic-date-string "cal-islam" (&optional date))
(declare-function calendar-iso-date-string "cal-iso" (&optional date))
(declare-function calendar-iso-from-absolute "cal-iso" (date))
(declare-function calendar-julian-date-string "cal-julian" (&optional date))
(declare-function calendar-mayan-date-string "cal-mayan" (&optional date))
(declare-function calendar-persian-date-string "cal-persia" (&optional date))
(declare-function calendar-check-holidays "holidays" (date))
(declare-function org-datetree-find-date-create "org-datetree"
(date &optional keep-restriction))
(declare-function org-columns-quit "org-colview" ())
(declare-function diary-date-display-form "diary-lib" (&optional type))
(declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file))
(declare-function org-habit-insert-consistency-graphs
"org-habit" (&optional line))
(declare-function org-is-habit-p "org-habit" (&optional pom))
(declare-function org-habit-parse-todo "org-habit" (&optional pom))
(declare-function org-habit-get-priority "org-habit" (habit &optional moment))
(declare-function org-pop-to-buffer-same-window "org-compat"
(&optional buffer-or-name norecord label))
(declare-function org-agenda-columns "org-colview" ())
(declare-function org-add-archive-files "org-archive" (files))
(declare-function org-capture "org-capture" (&optional goto keys))
(defvar calendar-mode-map) ; defined in calendar.el
(defvar org-clock-current-task nil) ; defined in org-clock.el
(defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
(defvar org-habit-show-habits) ; defined in org-habit.el
(defvar org-habit-show-habits-only-for-today)
(defvar org-habit-show-all-today)
;; Defined somewhere in this file, but used before definition.
(defvar org-agenda-buffer-name "*Org Agenda*")
(defvar org-agenda-overriding-header nil)
(defvar org-agenda-title-append nil)
(org-no-warnings (defvar entry)) ;; unprefixed, from calendar.el
(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el
(defvar original-date) ; dynamically scoped, calendar.el does scope this
(defvar org-agenda-undo-list nil
"List of undoable operations in the agenda since last refresh.")
(defvar org-agenda-pending-undo-list nil
"In a series of undo commands, this is the list of remaining undo items.")
(defcustom org-agenda-confirm-kill 1
"When set, remote killing from the agenda buffer needs confirmation.
When t, a confirmation is always needed. When a number N, confirmation is
only needed when the text to be killed contains more than N non-white lines."
:group 'org-agenda
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)
(integer :tag "When more than N lines")))
(defcustom org-agenda-compact-blocks nil
"Non-nil means make the block agenda more compact.
This is done globally by leaving out lines like the agenda span
name and week number or the separator lines."
:group 'org-agenda
:type 'boolean)
(defcustom org-agenda-block-separator ?=
"The separator between blocks in the agenda.
If this is a string, it will be used as the separator, with a newline added.
If it is a character, it will be repeated to fill the window width.
If nil the separator is disabled. In `org-agenda-custom-commands' this
addresses the separator between the current and the previous block."
:group 'org-agenda
:type '(choice
(const :tag "Disabled" nil)
(character)
(string)))
(defgroup org-agenda-export nil
"Options concerning exporting agenda views in Org-mode."
:tag "Org Agenda Export"
:group 'org-agenda)
(defcustom org-agenda-with-colors t
"Non-nil means use colors in agenda views."
:group 'org-agenda-export
:type 'boolean)
(defcustom org-agenda-exporter-settings nil
"Alist of variable/value pairs that should be active during agenda export.
This is a good place to set options for ps-print and for htmlize.
Note that the way this is implemented, the values will be evaluated
before assigned to the variables. So make sure to quote values you do
*not* want evaluated, for example
(setq org-agenda-exporter-settings
'((ps-print-color-p 'black-white)))"
:group 'org-agenda-export
:type '(repeat
(list
(variable)
(sexp :tag "Value"))))
(defcustom org-agenda-before-write-hook '(org-agenda-add-entry-text)
"Hook run in a temporary buffer before writing the agenda to an export file.
A useful function for this hook is `org-agenda-add-entry-text'."
:group 'org-agenda-export
:type 'hook
:options '(org-agenda-add-entry-text))
(defcustom org-agenda-add-entry-text-maxlines 0
"Maximum number of entry text lines to be added to agenda.
This is only relevant when `org-agenda-add-entry-text' is part of
`org-agenda-before-write-hook', which is the default.
When this is 0, nothing will happen. When it is greater than 0, it
specifies the maximum number of lines that will be added for each entry
that is listed in the agenda view.
Note that this variable is not used during display, only when exporting
the agenda. For agenda display, see the variables `org-agenda-entry-text-mode'
and `org-agenda-entry-text-maxlines'."
:group 'org-agenda
:type 'integer)
(defcustom org-agenda-add-entry-text-descriptive-links t
"Non-nil means export org-links as descriptive links in agenda added text.
This variable applies to the text added to the agenda when
`org-agenda-add-entry-text-maxlines' is larger than 0.
When this variable nil, the URL will (also) be shown."
:group 'org-agenda
:type 'boolean)
(defcustom org-agenda-export-html-style nil
"The style specification for exported HTML Agenda files.
If this variable contains a string, it will replace the default <style>
section as produced by `htmlize'.
Since there are different ways of setting style information, this variable
needs to contain the full HTML structure to provide a style, including the
surrounding HTML tags. The style specifications should include definitions
the fonts used by the agenda, here is an example:
<style type=\"text/css\">
p { font-weight: normal; color: gray; }
.org-agenda-structure {
font-size: 110%;
color: #003399;
font-weight: 600;
}
.org-todo {
color: #cc6666;
font-weight: bold;
}
.org-agenda-done {
color: #339933;
}
.org-done {
color: #339933;
}
.title { text-align: center; }
.todo, .deadline { color: red; }
.done { color: green; }
</style>
or, if you want to keep the style in a file,
<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
As the value of this option simply gets inserted into the HTML <head> header,
you can \"misuse\" it to also add other text to the header."
:group 'org-agenda-export
:group 'org-export-html
:type '(choice
(const nil)
(string)))
(defcustom org-agenda-persistent-filter nil
"When set, keep filters from one agenda view to the next."
:group 'org-agenda
:type 'boolean)
(defgroup org-agenda-custom-commands nil
"Options concerning agenda views in Org-mode."
:tag "Org Agenda Custom Commands"
:group 'org-agenda)
(defconst org-sorting-choice
'(choice
(const time-up) (const time-down)
(const timestamp-up) (const timestamp-down)
(const scheduled-up) (const scheduled-down)
(const deadline-up) (const deadline-down)
(const ts-up) (const ts-down)
(const tsia-up) (const tsia-down)
(const category-keep) (const category-up) (const category-down)
(const tag-down) (const tag-up)
(const priority-up) (const priority-down)
(const todo-state-up) (const todo-state-down)
(const effort-up) (const effort-down)
(const habit-up) (const habit-down)
(const alpha-up) (const alpha-down)
(const user-defined-up) (const user-defined-down))
"Sorting choices.")
;; Keep custom values for `org-agenda-filter-preset' compatible with
;; the new variable `org-agenda-tag-filter-preset'.
(org-defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
(org-defvaralias 'org-agenda-filter 'org-agenda-tag-filter)
(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
"List of types searched for when creating the daily/weekly agenda.
This variable is a list of symbols that controls the types of
items that appear in the daily/weekly agenda. Allowed symbols in this
list are are
:timestamp List items containing a date stamp or date range matching
the selected date. This includes sexp entries in angular
brackets.
:sexp List entries resulting from plain diary-like sexps.
:deadline List deadline due on that date. When the date is today,
also list any deadlines past due, or due within
`org-deadline-warning-days'. `:deadline' must appear before
`:scheduled' if the setting of
`org-agenda-skip-scheduled-if-deadline-is-shown' is to have
any effect.
:deadline* Same as above, but only include the deadline if it has an
hour specification as [h]h:mm.
:scheduled List all items which are scheduled for the given date.
The diary for *today* also contains items which were
scheduled earlier and are not yet marked DONE.
:scheduled* Same as above, but only include the scheduled item if it
has an hour specification as [h]h:mm.
By default, all four non-starred types are turned on.
When :scheduled* or :deadline* are included, :schedule or :deadline
will be ignored.
Never set this variable globally using `setq', because then it
will apply to all future agenda commands. Instead, bind it with
`let' to scope it dynamically into the agenda-constructing
command. A good way to set it is through options in
`org-agenda-custom-commands'. For a more flexible (though
somewhat less efficient) way of determining what is included in
the daily/weekly agenda, see `org-agenda-skip-function'.")
(defconst org-agenda-custom-commands-local-options
`(repeat :tag "Local settings for this command. Remember to quote values"
(choice :tag "Setting"
(list :tag "Heading for this block"
(const org-agenda-overriding-header)
(string :tag "Headline"))
(list :tag "Files to be searched"
(const org-agenda-files)
(list
(const :format "" quote)
(repeat (file))))
(list :tag "Sorting strategy"
(const org-agenda-sorting-strategy)
(list
(const :format "" quote)
(repeat
,org-sorting-choice)))
(list :tag "Prefix format"
(const org-agenda-prefix-format :value " %-12:c%?-12t% s")
(string))
(list :tag "Number of days in agenda"
(const org-agenda-span)
(choice (const :tag "Day" day)
(const :tag "Week" week)
(const :tag "Fortnight" fortnight)
(const :tag "Month" month)
(const :tag "Year" year)
(integer :tag "Custom")))
(list :tag "Fixed starting date"
(const org-agenda-start-day)
(string :value "2007-11-01"))
(list :tag "Start on day of week"
(const org-agenda-start-on-weekday)
(choice :value 1
(const :tag "Today" nil)
(integer :tag "Weekday No.")))
(list :tag "Include data from diary"
(const org-agenda-include-diary)
(boolean))
(list :tag "Deadline Warning days"
(const org-deadline-warning-days)
(integer :value 1))
(list :tag "Category filter preset"
(const org-agenda-category-filter-preset)
(list
(const :format "" quote)
(repeat
(string :tag "+category or -category"))))
(list :tag "Tags filter preset"
(const org-agenda-tag-filter-preset)
(list
(const :format "" quote)
(repeat
(string :tag "+tag or -tag"))))
(list :tag "Regexp filter preset"
(const org-agenda-regexp-filter-preset)
(list
(const :format "" quote)
(repeat
(string :tag "+regexp or -regexp"))))
(list :tag "Set daily/weekly entry types"
(const org-agenda-entry-types)
(list
(const :format "" quote)
(set :greedy t :value ,org-agenda-entry-types
(const :deadline)
(const :scheduled)
(const :deadline*)
(const :scheduled*)
(const :timestamp)
(const :sexp))))
(list :tag "Standard skipping condition"
:value (org-agenda-skip-function '(org-agenda-skip-entry-if))
(const org-agenda-skip-function)
(list
(const :format "" quote)
(list
(choice
:tag "Skipping range"
(const :tag "Skip entry" org-agenda-skip-entry-if)
(const :tag "Skip subtree" org-agenda-skip-subtree-if))
(repeat :inline t :tag "Conditions for skipping"
(choice
:tag "Condition type"
(list :tag "Regexp matches" :inline t
(const :format "" 'regexp)
(regexp))
(list :tag "Regexp does not match" :inline t
(const :format "" 'notregexp)
(regexp))
(list :tag "TODO state is" :inline t
(const 'todo)
(choice
(const :tag "Any not-done state" 'todo)
(const :tag "Any done state" 'done)
(const :tag "Any state" 'any)
(list :tag "Keyword list"
(const :format "" quote)
(repeat (string :tag "Keyword")))))
(list :tag "TODO state is not" :inline t
(const 'nottodo)
(choice
(const :tag "Any not-done state" 'todo)
(const :tag "Any done state" 'done)
(const :tag "Any state" 'any)
(list :tag "Keyword list"
(const :format "" quote)
(repeat (string :tag "Keyword")))))
(const :tag "scheduled" 'scheduled)
(const :tag "not scheduled" 'notscheduled)
(const :tag "deadline" 'deadline)
(const :tag "no deadline" 'notdeadline)
(const :tag "timestamp" 'timestamp)
(const :tag "no timestamp" 'nottimestamp))))))
(list :tag "Non-standard skipping condition"
:value (org-agenda-skip-function)
(const org-agenda-skip-function)
(sexp :tag "Function or form (quoted!)"))
(list :tag "Any variable"
(variable :tag "Variable")
(sexp :tag "Value (sexp)"))))
"Selection of examples for agenda command settings.
This will be spliced into the custom type of
`org-agenda-custom-commands'.")
(defcustom org-agenda-custom-commands
'(("n" "Agenda and all TODO's" ((agenda "") (alltodo ""))))
"Custom commands for the agenda.
These commands will be offered on the splash screen displayed by the
agenda dispatcher \\[org-agenda]. Each entry is a list like this:
(key desc type match settings files)
key The key (one or more characters as a string) to be associated
with the command.
desc A description of the command, when omitted or nil, a default
description is built using MATCH.
type The command type, any of the following symbols:
agenda The daily/weekly agenda.
todo Entries with a specific TODO keyword, in all agenda files.
search Entries containing search words entry or headline.
tags Tags/Property/TODO match in all agenda files.
tags-todo Tags/P/T match in all agenda files, TODO entries only.
todo-tree Sparse tree of specific TODO keyword in *current* file.
tags-tree Sparse tree with all tags matches in *current* file.
occur-tree Occur sparse tree for *current* file.
... A user-defined function.
match What to search for:
- a single keyword for TODO keyword searches
- a tags match expression for tags searches
- a word search expression for text searches.
- a regular expression for occur searches
For all other commands, this should be the empty string.
settings A list of option settings, similar to that in a let form, so like
this: ((opt1 val1) (opt2 val2) ...). The values will be
evaluated at the moment of execution, so quote them when needed.
files A list of files file to write the produced agenda buffer to
with the command `org-store-agenda-views'.
If a file name ends in \".html\", an HTML version of the buffer
is written out. If it ends in \".ps\", a postscript version is
produced. Otherwise, only the plain text is written to the file.
You can also define a set of commands, to create a composite agenda buffer.
In this case, an entry looks like this:
(key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
where
desc A description string to be displayed in the dispatcher menu.
cmd An agenda command, similar to the above. However, tree commands
are not allowed, but instead you can get agenda and global todo list.
So valid commands for a set are:
(agenda \"\" settings)
(alltodo \"\" settings)
(stuck \"\" settings)
(todo \"match\" settings files)
(search \"match\" settings files)
(tags \"match\" settings files)
(tags-todo \"match\" settings files)
Each command can carry a list of options, and another set of options can be
given for the whole set of commands. Individual command options take
precedence over the general options.
When using several characters as key to a command, the first characters
are prefix commands. For the dispatcher to display useful information, you
should provide a description for the prefix, like
(setq org-agenda-custom-commands
'((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\"
(\"hl\" tags \"+HOME+Lisa\")
(\"hp\" tags \"+HOME+Peter\")
(\"hk\" tags \"+HOME+Kim\")))"
:group 'org-agenda-custom-commands
:type `(repeat
(choice :value ("x" "Describe command here" tags "" nil)
(list :tag "Single command"
(string :tag "Access Key(s) ")
(option (string :tag "Description"))
(choice
(const :tag "Agenda" agenda)
(const :tag "TODO list" alltodo)
(const :tag "Search words" search)
(const :tag "Stuck projects" stuck)
(const :tag "Tags/Property match (all agenda files)" tags)
(const :tag "Tags/Property match of TODO entries (all agenda files)" tags-todo)
(const :tag "TODO keyword search (all agenda files)" todo)
(const :tag "Tags sparse tree (current buffer)" tags-tree)
(const :tag "TODO keyword tree (current buffer)" todo-tree)
(const :tag "Occur tree (current buffer)" occur-tree)
(sexp :tag "Other, user-defined function"))
(string :tag "Match (only for some commands)")
,org-agenda-custom-commands-local-options
(option (repeat :tag "Export" (file :tag "Export to"))))
(list :tag "Command series, all agenda files"
(string :tag "Access Key(s)")
(string :tag "Description ")
(repeat :tag "Component"
(choice
(list :tag "Agenda"
(const :format "" agenda)
(const :tag "" :format "" "")
,org-agenda-custom-commands-local-options)
(list :tag "TODO list (all keywords)"
(const :format "" alltodo)
(const :tag "" :format "" "")
,org-agenda-custom-commands-local-options)
(list :tag "Search words"
(const :format "" search)
(string :tag "Match")
,org-agenda-custom-commands-local-options)
(list :tag "Stuck projects"
(const :format "" stuck)
(const :tag "" :format "" "")
,org-agenda-custom-commands-local-options)
(list :tag "Tags search"
(const :format "" tags)
(string :tag "Match")
,org-agenda-custom-commands-local-options)
(list :tag "Tags search, TODO entries only"
(const :format "" tags-todo)
(string :tag "Match")
,org-agenda-custom-commands-local-options)
(list :tag "TODO keyword search"
(const :format "" todo)
(string :tag "Match")
,org-agenda-custom-commands-local-options)
(list :tag "Other, user-defined function"
(symbol :tag "function")
(string :tag "Match")
,org-agenda-custom-commands-local-options)))
(repeat :tag "Settings for entire command set"
(list (variable :tag "Any variable")
(sexp :tag "Value")))
(option (repeat :tag "Export" (file :tag "Export to"))))
(cons :tag "Prefix key documentation"
(string :tag "Access Key(s)")
(string :tag "Description ")))))
(defcustom org-agenda-query-register ?o
"The register holding the current query string.
The purpose of this is that if you construct a query string interactively,
you can then use it to define a custom command."
:group 'org-agenda-custom-commands
:type 'character)
(defcustom org-stuck-projects
'("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "")
"How to identify stuck projects.
This is a list of four items:
1. A tags/todo/property matcher string that is used to identify a project.
See the manual for a description of tag and property searches.
The entire tree below a headline matched by this is considered one project.
2. A list of TODO keywords identifying non-stuck projects.
If the project subtree contains any headline with one of these todo
keywords, the project is considered to be not stuck. If you specify
\"*\" as a keyword, any TODO keyword will mark the project unstuck.
3. A list of tags identifying non-stuck projects.
If the project subtree contains any headline with one of these tags,
the project is considered to be not stuck. If you specify \"*\" as
a tag, any tag will mark the project unstuck. Note that this is about
the explicit presence of a tag somewhere in the subtree, inherited
tags do not count here. If inherited tags make a project not stuck,
use \"-TAG\" in the tags part of the matcher under (1.) above.
4. An arbitrary regular expression matching non-stuck projects.
If the project turns out to be not stuck, search continues also in the
subtree to see if any of the subtasks have project status.
See also the variable `org-tags-match-list-sublevels' which applies
to projects matched by this search as well.
After defining this variable, you may use \\[org-agenda-list-stuck-projects]
or `C-c a #' to produce the list."
:group 'org-agenda-custom-commands
:type '(list
(string :tag "Tags/TODO match to identify a project")
(repeat :tag "Projects are *not* stuck if they have an entry with TODO keyword any of" (string))
(repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string))
(regexp :tag "Projects are *not* stuck if this regexp matches inside the subtree")))
(defcustom org-agenda-filter-effort-default-operator "<"
"The default operator for effort estimate filtering.
If you select an effort estimate limit without first pressing an operator,
this one will be used."
:group 'org-agenda-custom-commands
:type '(choice (const :tag "less or equal" "<")
(const :tag "greater or equal"">")
(const :tag "equal" "=")))
(defgroup org-agenda-skip nil
"Options concerning skipping parts of agenda files."
:tag "Org Agenda Skip"
:group 'org-agenda)
(defcustom org-agenda-skip-function-global nil
"Function to be called at each match during agenda construction.
If this function returns nil, the current match should not be skipped.
If the function decided to skip an agenda match, is must return the
buffer position from which the search should be continued.
This may also be a Lisp form, which will be evaluated.
This variable will be applied to every agenda match, including
tags/property searches and TODO lists. So try to make the test function
do its checking as efficiently as possible. To implement a skipping
condition just for specific agenda commands, use the variable
`org-agenda-skip-function' which can be set in the options section
of custom agenda commands."
:group 'org-agenda-skip
:type 'sexp)
(defgroup org-agenda-daily/weekly nil
"Options concerning the daily/weekly agenda."
:tag "Org Agenda Daily/Weekly"
:group 'org-agenda)
(defgroup org-agenda-todo-list nil
"Options concerning the global todo list agenda view."
:tag "Org Agenda Todo List"
:group 'org-agenda)
(defgroup org-agenda-match-view nil
"Options concerning the general tags/property/todo match agenda view."
:tag "Org Agenda Match View"
:group 'org-agenda)
(defgroup org-agenda-search-view nil
"Options concerning the search agenda view."
:tag "Org Agenda Search View"
:group 'org-agenda)
(defvar org-agenda-archives-mode nil
"Non-nil means the agenda will include archived items.
If this is the symbol `trees', trees in the selected agenda scope
that are marked with the ARCHIVE tag will be included anyway. When this is
t, also all archive files associated with the current selection of agenda
files will be included.")
(defcustom org-agenda-restriction-lock-highlight-subtree t
"Non-nil means highlight the whole subtree when restriction is active.
Otherwise only highlight the headline. Highlighting the whole subtree is
useful to ensure no edits happen beyond the restricted region."
:group 'org-agenda
:type 'boolean)
(defcustom org-agenda-skip-comment-trees t
"Non-nil means skip trees that start with the COMMENT keyword.
When nil, these trees are also scanned by agenda commands."
:group 'org-agenda-skip
:type 'boolean)
(defcustom org-agenda-todo-list-sublevels t
"Non-nil means check also the sublevels of a TODO entry for TODO entries.
When nil, the sublevels of a TODO entry are not checked, resulting in
potentially much shorter TODO lists."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:type 'boolean)
(defcustom org-agenda-todo-ignore-with-date nil
"Non-nil means don't show entries with a date in the global todo list.
You can use this if you prefer to mark mere appointments with a TODO keyword,
but don't want them to show up in the TODO list.
When this is set, it also covers deadlines and scheduled items, the settings
of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
will be ignored.
See also the variable `org-agenda-tags-todo-honor-ignore-options'."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:type 'boolean)
(defcustom org-agenda-todo-ignore-timestamp nil
"Non-nil means don't show entries with a timestamp.
This applies when creating the global todo list.
Valid values are:
past Don't show entries for today or in the past.
future Don't show entries with a timestamp in the future.
The idea behind this is that if it has a future
timestamp, you don't want to think about it until the
date.
all Don't show any entries with a timestamp in the global todo list.
The idea behind this is that by setting a timestamp, you
have already \"taken care\" of this item.
This variable can also have an integer as a value. If positive (N),
todos with a timestamp N or more days in the future will be ignored. If
negative (-N), todos with a timestamp N or more days in the past will be
ignored. If 0, todos with a timestamp either today or in the future will
be ignored. For example, a value of -1 will exclude todos with a
timestamp in the past (yesterday or earlier), while a value of 7 will
exclude todos with a timestamp a week or more in the future.
See also `org-agenda-todo-ignore-with-date'.
See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
to make his option also apply to the tags-todo list."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:version "24.1"
:type '(choice
(const :tag "Ignore future timestamp todos" future)
(const :tag "Ignore past or present timestamp todos" past)
(const :tag "Ignore all timestamp todos" all)
(const :tag "Show timestamp todos" nil)
(integer :tag "Ignore if N or more days in past(-) or future(+).")))
(defcustom org-agenda-todo-ignore-scheduled nil
"Non-nil means, ignore some scheduled TODO items when making TODO list.
This applies when creating the global todo list.
Valid values are:
past Don't show entries scheduled today or in the past.
future Don't show entries scheduled in the future.
The idea behind this is that by scheduling it, you don't want to
think about it until the scheduled date.
all Don't show any scheduled entries in the global todo list.
The idea behind this is that by scheduling it, you have already
\"taken care\" of this item.
t Same as `all', for backward compatibility.
This variable can also have an integer as a value. See
`org-agenda-todo-ignore-timestamp' for more details.
See also `org-agenda-todo-ignore-with-date'.
See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
to make his option also apply to the tags-todo list."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:type '(choice
(const :tag "Ignore future-scheduled todos" future)
(const :tag "Ignore past- or present-scheduled todos" past)
(const :tag "Ignore all scheduled todos" all)
(const :tag "Ignore all scheduled todos (compatibility)" t)
(const :tag "Show scheduled todos" nil)
(integer :tag "Ignore if N or more days in past(-) or future(+).")))
(defcustom org-agenda-todo-ignore-deadlines nil
"Non-nil means ignore some deadline TODO items when making TODO list.
There are different motivations for using different values, please think
carefully when configuring this variable.
This applies when creating the global todo list.
Valid values are:
near Don't show near deadline entries. A deadline is near when it is
closer than `org-deadline-warning-days' days. The idea behind this
is that such items will appear in the agenda anyway.
far Don't show TODO entries where a deadline has been defined, but
the deadline is not near. This is useful if you don't want to
use the todo list to figure out what to do now.
past Don't show entries with a deadline timestamp for today or in the past.
future Don't show entries with a deadline timestamp in the future, not even
when they become `near' ones. Use it with caution.
all Ignore all TODO entries that do have a deadline.
t Same as `near', for backward compatibility.
This variable can also have an integer as a value. See
`org-agenda-todo-ignore-timestamp' for more details.
See also `org-agenda-todo-ignore-with-date'.
See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
to make his option also apply to the tags-todo list."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:type '(choice
(const :tag "Ignore near deadlines" near)
(const :tag "Ignore near deadlines (compatibility)" t)
(const :tag "Ignore far deadlines" far)
(const :tag "Ignore all TODOs with a deadlines" all)
(const :tag "Show all TODOs, even if they have a deadline" nil)
(integer :tag "Ignore if N or more days in past(-) or future(+).")))
(defcustom org-agenda-todo-ignore-time-comparison-use-seconds nil
"Time unit to use when possibly ignoring an agenda item.
See the docstring of various `org-agenda-todo-ignore-*' options.
The default is to compare time stamps using days. An item is thus
considered to be in the future if it is at least one day after today.
Non-nil means to compare time stamps using seconds. An item is then
considered future if it has a time value later than current time."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Compare time with days" nil)
(const :tag "Compare time with seconds" t)))
(defcustom org-agenda-tags-todo-honor-ignore-options nil
"Non-nil means honor todo-list ignores options also in tags-todo search.
The variables
`org-agenda-todo-ignore-with-date',
`org-agenda-todo-ignore-timestamp',
`org-agenda-todo-ignore-scheduled',
`org-agenda-todo-ignore-deadlines'
make the global TODO list skip entries that have time stamps of certain
kinds. If this option is set, the same options will also apply for the
tags-todo search, which is the general tags/property matcher
restricted to unfinished TODO entries only."
:group 'org-agenda-skip
:group 'org-agenda-todo-list
:group 'org-agenda-match-view
:type 'boolean)
(defcustom org-agenda-skip-scheduled-if-done nil
"Non-nil means don't show scheduled items in agenda when they are done.
This is relevant for the daily/weekly agenda, not for the TODO list. And
it applies only to the actual date of the scheduling. Warnings about
an item with a past scheduling dates are always turned off when the item
is DONE."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
"Non-nil means skip scheduling line if same entry shows because of deadline.
In the agenda of today, an entry can show up multiple times
because it is both scheduled and has a nearby deadline, and maybe
a plain time stamp as well.
When this variable is nil, the entry will be shown several times.
When set to t, then only the deadline is shown and the fact that
the entry is scheduled today or was scheduled previously is not
shown.
When set to the symbol `not-today', skip scheduled previously,
but not scheduled today.
When set to the symbol `repeated-after-deadline', skip scheduled
items if they are repeated beyond the current deadline."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)
(const :tag "Not when scheduled today" not-today)
(const :tag "When repeated past deadline" repeated-after-deadline)))
(defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
"Non-nil means skip timestamp line if same entry shows because of deadline.
In the agenda of today, an entry can show up multiple times
because it has both a plain timestamp and has a nearby deadline.
When this variable is t, then only the deadline is shown and the
fact that the entry has a timestamp for or including today is not
shown. When this variable is nil, the entry will be shown
several times."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:version "24.1"
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)))
(defcustom org-agenda-skip-deadline-if-done nil
"Non-nil means don't show deadlines when the corresponding item is done.
When nil, the deadline is still shown and should give you a happy feeling.
This is relevant for the daily/weekly agenda. And it applied only to the
actually date of the deadline. Warnings about approaching and past-due
deadlines are always turned off when the item is DONE."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-skip-deadline-prewarning-if-scheduled nil
"Non-nil means skip deadline prewarning when entry is also scheduled.
This will apply on all days where a prewarning for the deadline would
be shown, but not at the day when the entry is actually due. On that day,
the deadline will be shown anyway.
This variable may be set to nil, t, the symbol `pre-scheduled',
or a number which will then give the number of days before the actual
deadline when the prewarnings should resume. The symbol `pre-scheduled'
eliminates the deadline prewarning only prior to the scheduled date.
This can be used in a workflow where the first showing of the deadline will
trigger you to schedule it, and then you don't want to be reminded of it
because you will take care of it on the day when scheduled."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:version "24.1"
:type '(choice
(const :tag "Always show prewarning" nil)
(const :tag "Remove prewarning prior to scheduled date" pre-scheduled)
(const :tag "Remove prewarning if entry is scheduled" t)
(integer :tag "Restart prewarning N days before deadline")))
(defcustom org-agenda-skip-scheduled-delay-if-deadline nil
"Non-nil means skip scheduled delay when entry also has a deadline.
This variable may be set to nil, t, the symbol `post-deadline',
or a number which will then give the number of days after the actual
scheduled date when the delay should expire. The symbol `post-deadline'
eliminates the schedule delay when the date is posterior to the deadline."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Always honor delay" nil)
(const :tag "Ignore delay if posterior to the deadline" post-deadline)
(const :tag "Ignore delay if entry has a deadline" t)
(integer :tag "Honor delay up until N days after the scheduled date")))
(defcustom org-agenda-skip-additional-timestamps-same-entry nil
"When nil, multiple same-day timestamps in entry make multiple agenda lines.
When non-nil, after the search for timestamps has matched once in an
entry, the rest of the entry will not be searched."
:group 'org-agenda-skip
:type 'boolean)
(defcustom org-agenda-skip-timestamp-if-done nil
"Non-nil means don't select item by timestamp or -range if it is DONE."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-dim-blocked-tasks t
"Non-nil means dim blocked tasks in the agenda display.
This causes some overhead during agenda construction, but if you
have turned on `org-enforce-todo-dependencies',
`org-enforce-todo-checkbox-dependencies', or any other blocking
mechanism, this will create useful feedback in the agenda.
Instead of t, this variable can also have the value `invisible'.
Then blocked tasks will be invisible and only become visible when
they become unblocked. An exemption to this behavior is when a task is
blocked because of unchecked checkboxes below it. Since checkboxes do
not show up in the agenda views, making this task invisible you remove any
trace from agenda views that there is something to do. Therefore, a task
that is blocked because of checkboxes will never be made invisible, it
will only be dimmed."
:group 'org-agenda-daily/weekly
:group 'org-agenda-todo-list
:version "24.3"
:type '(choice
(const :tag "Do not dim" nil)
(const :tag "Dim to a gray face" t)
(const :tag "Make invisible" invisible)))
(defcustom org-timeline-show-empty-dates 3
"Non-nil means `org-timeline' also shows dates without an entry.
When nil, only the days which actually have entries are shown.
When t, all days between the first and the last date are shown.
When an integer, show also empty dates, but if there is a gap of more than
N days, just insert a special line indicating the size of the gap."
:group 'org-agenda-skip
:type '(choice
(const :tag "None" nil)
(const :tag "All" t)
(integer :tag "at most")))
(defgroup org-agenda-startup nil
"Options concerning initial settings in the Agenda in Org Mode."
:tag "Org Agenda Startup"
:group 'org-agenda)
(defcustom org-agenda-menu-show-matcher t
"Non-nil means show the match string in the agenda dispatcher menu.
When nil, the matcher string is not shown, but is put into the help-echo
property so than moving the mouse over the command shows it.
Setting it to nil is good if matcher strings are very long and/or if
you want to use two-columns display (see `org-agenda-menu-two-columns')."
:group 'org-agenda
:version "24.1"
:type 'boolean)
(define-obsolete-variable-alias 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.3")
(defcustom org-agenda-menu-two-columns nil
"Non-nil means, use two columns to show custom commands in the dispatcher.
If you use this, you probably want to set `org-agenda-menu-show-matcher'
to nil."
:group 'org-agenda
:version "24.1"
:type 'boolean)
(define-obsolete-variable-alias 'org-finalize-agenda-hook 'org-agenda-finalize-hook "24.3")
(defcustom org-agenda-finalize-hook nil
"Hook run just before displaying an agenda buffer.
The buffer is still writable when the hook is called.
You can modify some of the buffer substrings but you should be
extra careful not to modify the text properties of the agenda
headlines as the agenda display heavily relies on them."
:group 'org-agenda-startup
:type 'hook)
(defcustom org-agenda-mouse-1-follows-link nil
"Non-nil means mouse-1 on a link will follow the link in the agenda.
A longer mouse click will still set point. Does not work on XEmacs.
Needs to be set before org.el is loaded."
:group 'org-agenda-startup
:type 'boolean)
(defcustom org-agenda-start-with-follow-mode nil
"The initial value of follow mode in a newly created agenda window."
:group 'org-agenda-startup
:type 'boolean)
(defcustom org-agenda-follow-indirect nil
"Non-nil means `org-agenda-follow-mode' displays only the
current item's tree, in an indirect buffer."
:group 'org-agenda
:version "24.1"
:type 'boolean)
(defcustom org-agenda-show-outline-path t
"Non-nil means show outline path in echo area after line motion."
:group 'org-agenda-startup
:type 'boolean)
(defcustom org-agenda-start-with-entry-text-mode nil
"The initial value of entry-text-mode in a newly created agenda window."
:group 'org-agenda-startup
:type 'boolean)
(defcustom org-agenda-entry-text-maxlines 5
"Number of text lines to be added when `E' is pressed in the agenda.
Note that this variable only used during agenda display. Add add entry text
when exporting the agenda, configure the variable
`org-agenda-add-entry-ext-maxlines'."
:group 'org-agenda
:type 'integer)
(defcustom org-agenda-entry-text-exclude-regexps nil
"List of regular expressions to clean up entry text.
The complete matches of all regular expressions in this list will be
removed from entry text before it is shown in the agenda."
:group 'org-agenda
:type '(repeat (regexp)))
(defcustom org-agenda-entry-text-leaders " > "
"Text prepended to the entry text in agenda buffers."
:version "24.4"
:package-version '(Org . "8.0")
:group 'org-agenda
:type 'string)
(defvar org-agenda-entry-text-cleanup-hook nil
"Hook that is run after basic cleanup of entry text to be shown in agenda.
This cleanup is done in a temporary buffer, so the function may inspect and
change the entire buffer.
Some default stuff like drawers and scheduling/deadline dates will already
have been removed when this is called, as will any matches for regular
expressions listed in `org-agenda-entry-text-exclude-regexps'.")
(defvar org-agenda-include-inactive-timestamps nil
"Non-nil means include inactive time stamps in agenda and timeline.
Dynamically scoped.")
(defgroup org-agenda-windows nil
"Options concerning the windows used by the Agenda in Org Mode."
:tag "Org Agenda Windows"
:group 'org-agenda)
(defcustom org-agenda-window-setup 'reorganize-frame
"How the agenda buffer should be displayed.
Possible values for this option are:
current-window Show agenda in the current window, keeping all other windows.
other-window Use `switch-to-buffer-other-window' to display agenda.
reorganize-frame Show only two windows on the current frame, the current
window and the agenda.
other-frame Use `switch-to-buffer-other-frame' to display agenda.
Also, when exiting the agenda, kill that frame.
See also the variable `org-agenda-restore-windows-after-quit'."
:group 'org-agenda-windows
:type '(choice
(const current-window)
(const other-frame)
(const other-window)
(const reorganize-frame)))
(defcustom org-agenda-window-frame-fractions '(0.5 . 0.75)
"The min and max height of the agenda window as a fraction of frame height.
The value of the variable is a cons cell with two numbers between 0 and 1.
It only matters if `org-agenda-window-setup' is `reorganize-frame'."
:group 'org-agenda-windows
:type '(cons (number :tag "Minimum") (number :tag "Maximum")))
(defcustom org-agenda-restore-windows-after-quit nil
"Non-nil means restore window configuration upon exiting agenda.
Before the window configuration is changed for displaying the agenda,
the current status is recorded. When the agenda is exited with
`q' or `x' and this option is set, the old state is restored. If
`org-agenda-window-setup' is `other-frame', the value of this
option will be ignored."
:group 'org-agenda-windows
:type 'boolean)
(defcustom org-agenda-ndays nil
"Number of days to include in overview display.
Should be 1 or 7.
Obsolete, see `org-agenda-span'."
:group 'org-agenda-daily/weekly
:type '(choice (const nil)
(integer)))
(make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
(defcustom org-agenda-span 'week
"Number of days to include in overview display.
Can be day, week, month, year, or any number of days.
Custom commands can set this variable in the options section."
:group 'org-agenda-daily/weekly
:type '(choice (const :tag "Day" day)
(const :tag "Week" week)
(const :tag "Fortnight" fortnight)
(const :tag "Month" month)
(const :tag "Year" year)
(integer :tag "Custom")))
(defcustom org-agenda-start-on-weekday 1
"Non-nil means start the overview always on the specified weekday.
0 denotes Sunday, 1 denotes Monday, etc.
When nil, always start on the current day.
Custom commands can set this variable in the options section."
:group 'org-agenda-daily/weekly
:type '(choice (const :tag "Today" nil)
(integer :tag "Weekday No.")))
(defcustom org-agenda-show-all-dates t
"Non-nil means `org-agenda' shows every day in the selected range.
When nil, only the days which actually have entries are shown."
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-format-date 'org-agenda-format-date-aligned
"Format string for displaying dates in the agenda.
Used by the daily/weekly agenda and by the timeline. This should be
a format string understood by `format-time-string', or a function returning
the formatted date as a string. The function must take a single argument,
a calendar-style date list like (month day year)."
:group 'org-agenda-daily/weekly
:type '(choice
(string :tag "Format string")
(function :tag "Function")))
(defun org-agenda-format-date-aligned (date)
"Format a DATE string for display in the daily/weekly agenda, or timeline.
This function makes sure that dates are aligned for easy reading."
(require 'cal-iso)
(let* ((dayname (calendar-day-name date))
(day (cadr date))
(day-of-week (calendar-day-of-week date))
(month (car date))
(monthname (calendar-month-name month))
(year (nth 2 date))
(iso-week (org-days-to-iso-week
(calendar-absolute-from-gregorian date)))
(weekyear (cond ((and (= month 1) (>= iso-week 52))
(1- year))
((and (= month 12) (<= iso-week 1))
(1+ year))
(t year)))
(weekstring (if (= day-of-week 1)
(format " W%02d" iso-week)
"")))
(format "%-10s %2d %s %4d%s"
dayname day monthname year weekstring)))
(defcustom org-agenda-time-leading-zero nil
"Non-nil means use leading zero for military times in agenda.
For example, 9:30am would become 09:30 rather than 9:30."
:group 'org-agenda-daily/weekly
:version "24.1"
:type 'boolean)
(defcustom org-agenda-timegrid-use-ampm nil
"When set, show AM/PM style timestamps on the timegrid."
:group 'org-agenda
:version "24.1"
:type 'boolean)
(defun org-agenda-time-of-day-to-ampm (time)
"Convert TIME of a string like '13:45' to an AM/PM style time string."
(let* ((hour-number (string-to-number (substring time 0 -3)))
(minute (substring time -2))
(ampm "am"))
(cond
((equal hour-number 12)
(setq ampm "pm"))
((> hour-number 12)
(setq ampm "pm")
(setq hour-number (- hour-number 12))))
(concat
(if org-agenda-time-leading-zero
(format "%02d" hour-number)
(format "%02s" (number-to-string hour-number)))
":" minute ampm)))
(defun org-agenda-time-of-day-to-ampm-maybe (time)
"Conditionally convert TIME to AM/PM format based on `org-agenda-timegrid-use-ampm'."
(if org-agenda-timegrid-use-ampm
(org-agenda-time-of-day-to-ampm time)
time))
(defcustom org-agenda-weekend-days '(6 0)
"Which days are weekend?
These days get the special face `org-agenda-date-weekend' in the agenda
and timeline buffers."
:group 'org-agenda-daily/weekly
:type '(set :greedy t
(const :tag "Monday" 1)
(const :tag "Tuesday" 2)
(const :tag "Wednesday" 3)
(const :tag "Thursday" 4)
(const :tag "Friday" 5)
(const :tag "Saturday" 6)
(const :tag "Sunday" 0)))
(defcustom org-agenda-move-date-from-past-immediately-to-today t
"Non-nil means jump to today when moving a past date forward in time.
When using S-right in the agenda to move a a date forward, and the date
stamp currently points to the past, the first key press will move it
to today. WHen nil, just move one day forward even if the date stays
in the past."
:group 'org-agenda-daily/weekly
:version "24.1"
:type 'boolean)
(defcustom org-agenda-include-diary nil
"If non-nil, include in the agenda entries from the Emacs Calendar's diary.
Custom commands can set this variable in the options section."
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-include-deadlines t
"If non-nil, include entries within their deadline warning period.
Custom commands can set this variable in the options section."
:group 'org-agenda-daily/weekly
:version "24.1"
:type 'boolean)
(defcustom org-agenda-repeating-timestamp-show-all t
"Non-nil means show all occurrences of a repeating stamp in the agenda.
When set to a list of strings, only show occurrences of repeating
stamps for these TODO keywords. When nil, only one occurrence is
shown, either today or the nearest into the future."
:group 'org-agenda-daily/weekly
:type '(choice
(const :tag "Show repeating stamps" t)
(repeat :tag "Show repeating stamps for these TODO keywords"
(string :tag "TODO Keyword"))
(const :tag "Don't show repeating stamps" nil)))
(defcustom org-scheduled-past-days 10000
"Number of days to continue listing scheduled items not marked DONE.
When an item is scheduled on a date, it shows up in the agenda on this
day and will be listed until it is marked done for the number of days
given here."
:group 'org-agenda-daily/weekly
:type 'integer)
(defcustom org-agenda-log-mode-items '(closed clock)
"List of items that should be shown in agenda log mode.
This list may contain the following symbols:
closed Show entries that have been closed on that day.
clock Show entries that have received clocked time on that day.
state Show all logged state changes.
Note that instead of changing this variable, you can also press `C-u l' in
the agenda to display all available LOG items temporarily."
:group 'org-agenda-daily/weekly
:type '(set :greedy t (const closed) (const clock) (const state)))
(defcustom org-agenda-clock-consistency-checks
'(:max-duration "10:00" :min-duration 0 :max-gap "0:05"
:gap-ok-around ("4:00")
:default-face ((:background "DarkRed") (:foreground "white"))
:overlap-face nil :gap-face nil :no-end-time-face nil
:long-face nil :short-face nil)
"This is a property list, with the following keys:
:max-duration Mark clocking chunks that are longer than this time.
This is a time string like \"HH:MM\", or the number
of minutes as an integer.
:min-duration Mark clocking chunks that are shorter that this.
This is a time string like \"HH:MM\", or the number
of minutes as an integer.
:max-gap Mark gaps between clocking chunks that are longer than
this duration. A number of minutes, or a string
like \"HH:MM\".
:gap-ok-around List of times during the day which are usually not working
times. When a gap is detected, but the gap contains any
of these times, the gap is *not* reported. For example,
if this is (\"4:00\" \"13:00\") then gaps that contain
4:00 in the morning (i.e. the night) and 13:00
(i.e. a typical lunch time) do not cause a warning.
You should have at least one time during the night in this
list, or otherwise the first task each morning will trigger
a warning because it follows a long gap.
Furthermore, the following properties can be used to define faces for
issue display.
:default-face the default face, if the specific face is undefined
:overlap-face face for overlapping clocks
:gap-face face for gaps between clocks
:no-end-time-face face for incomplete clocks
:long-face face for clock intervals that are too long
:short-face face for clock intervals that are too short"
:group 'org-agenda-daily/weekly
:group 'org-clock
:version "24.1"
:type 'plist)
(defcustom org-agenda-log-mode-add-notes t
"Non-nil means add first line of notes to log entries in agenda views.
If a log item like a state change or a clock entry is associated with
notes, the first line of these notes will be added to the entry in the
agenda display."
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-start-with-log-mode nil
"The initial value of log-mode in a newly created agenda window.
See `org-agenda-log-mode' and `org-agenda-log-mode-items' for further
explanations on the possible values."
:group 'org-agenda-startup
:group 'org-agenda-daily/weekly
:type '(choice (const :tag "Don't show log items" nil)
(const :tag "Show only log items" only)
(const :tag "Show all possible log items" clockcheck)
(repeat :tag "Choose among possible values for `org-agenda-log-mode-items'"
(choice (const :tag "Show closed log items" closed)
(const :tag "Show clocked log items" clock)
(const :tag "Show all logged state changes" state)))))
(defcustom org-agenda-start-with-clockreport-mode nil
"The initial value of clockreport-mode in a newly created agenda window."
:group 'org-agenda-startup
:group 'org-agenda-daily/weekly
:type 'boolean)
(defcustom org-agenda-clockreport-parameter-plist '(:link t :maxlevel 2)
"Property list with parameters for the clocktable in clockreport mode.
This is the display mode that shows a clock table in the daily/weekly
agenda, the properties for this dynamic block can be set here.
The usual clocktable parameters are allowed here, but you cannot set
the properties :name, :tstart, :tend, :block, and :scope - these will
be overwritten to make sure the content accurately reflects the
current display in the agenda."
:group 'org-agenda-daily/weekly
:type 'plist)
(defcustom org-agenda-search-view-always-boolean nil
"Non-nil means the search string is interpreted as individual parts.
The search string for search view can either be interpreted as a phrase,
or as a list of snippets that define a boolean search for a number of
strings.
When this is non-nil, the string will be split on whitespace, and each
snippet will be searched individually, and all must match in order to
select an entry. A snippet is then a single string of non-white
characters, or a string in double quotes, or a regexp in {} braces.
If a snippet is preceded by \"-\", the snippet must *not* match.
\"+\" is syntactic sugar for positive selection. Each snippet may
be found as a full word or a partial word, but see the variable
`org-agenda-search-view-force-full-words'.
When this is nil, search will look for the entire search phrase as one,
with each space character matching any amount of whitespace, including
line breaks.
Even when this is nil, you can still switch to Boolean search dynamically
by preceding the first snippet with \"+\" or \"-\". If the first snippet
is a regexp marked with braces like \"{abc}\", this will also switch to
boolean search."
:group 'org-agenda-search-view
:version "24.1"
:type 'boolean)
(org-defvaralias 'org-agenda-search-view-search-words-only
'org-agenda-search-view-always-boolean)
(defcustom org-agenda-search-view-force-full-words nil
"Non-nil means, search words must be matches as complete words.
When nil, they may also match part of a word."
:group 'org-agenda-search-view
:version "24.1"
:type 'boolean)
(defcustom org-agenda-search-view-max-outline-level 0
"Maximum outline level to display in search view.
E.g. when this is set to 1, the search view will only
show headlines of level 1. When set to 0, the default
value, don't limit agenda view by outline level."
:group 'org-agenda-search-view
:version "24.4"
:package-version '(Org . "8.3")
:type 'integer)
(defgroup org-agenda-time-grid nil
"Options concerning the time grid in the Org-mode Agenda."
:tag "Org Agenda Time Grid"
:group 'org-agenda)
(defcustom org-agenda-search-headline-for-time t
"Non-nil means search headline for a time-of-day.
If the headline contains a time-of-day in one format or another, it will
be used to sort the entry into the time sequence of items for a day.
Some people have time stamps in the headline that refer to the creation
time or so, and then this produces an unwanted side effect. If this is
the case for your, use this variable to turn off searching the headline
for a time."
:group 'org-agenda-time-grid
:type 'boolean)
(defcustom org-agenda-use-time-grid t
"Non-nil means show a time grid in the agenda schedule.
A time grid is a set of lines for specific times (like every two hours between
8:00 and 20:00). The items scheduled for a day at specific times are
sorted in between these lines.
For details about when the grid will be shown, and what it will look like, see
the variable `org-agenda-time-grid'."
:group 'org-agenda-time-grid
:type 'boolean)
(defcustom org-agenda-time-grid
'((daily today require-timed)
"----------------"
(800 1000 1200 1400 1600 1800 2000))
"The settings for time grid for agenda display.
This is a list of three items. The first item is again a list. It contains
symbols specifying conditions when the grid should be displayed:
daily if the agenda shows a single day
weekly if the agenda shows an entire week
today show grid on current date, independent of daily/weekly display
require-timed show grid only if at least one item has a time specification
remove-match skip grid times already present in an entry
The second item is a string which will be placed behind the grid time.
The third item is a list of integers, indicating the times that should have
a grid line."
:group 'org-agenda-time-grid
:type
'(list
(set :greedy t :tag "Grid Display Options"
(const :tag "Show grid in single day agenda display" daily)
(const :tag "Show grid in weekly agenda display" weekly)
(const :tag "Always show grid for today" today)
(const :tag "Show grid only if any timed entries are present"
require-timed)
(const :tag "Skip grid times already present in an entry"
remove-match))
(string :tag "Grid String")
(repeat :tag "Grid Times" (integer :tag "Time"))))
(defcustom org-agenda-show-current-time-in-grid t
"Non-nil means show the current time in the time grid."
:group 'org-agenda-time-grid
:version "24.1"
:type 'boolean)
(defcustom org-agenda-current-time-string
"now - - - - - - - - - - - - - - - - - - - - - - - - -"
"The string for the current time marker in the agenda."
:group 'org-agenda-time-grid
:version "24.1"
:type 'string)
(defgroup org-agenda-sorting nil
"Options concerning sorting in the Org-mode Agenda."
:tag "Org Agenda Sorting"
:group 'org-agenda)
(defcustom org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
(todo priority-down category-keep)
(tags priority-down category-keep)
(search category-keep))
"Sorting structure for the agenda items of a single day.
This is a list of symbols which will be used in sequence to determine
if an entry should be listed before another entry. The following
symbols are recognized:
time-up Put entries with time-of-day indications first, early first
time-down Put entries with time-of-day indications first, late first
timestamp-up Sort by any timestamp, early first
timestamp-down Sort by any timestamp, late first
scheduled-up Sort by scheduled timestamp, early first
scheduled-down Sort by scheduled timestamp, late first
deadline-up Sort by deadline timestamp, early first
deadline-down Sort by deadline timestamp, late first
ts-up Sort by active timestamp, early first
ts-down Sort by active timestamp, late first
tsia-up Sort by inactive timestamp, early first
tsia-down Sort by inactive timestamp, late first
category-keep Keep the default order of categories, corresponding to the
sequence in `org-agenda-files'.
category-up Sort alphabetically by category, A-Z.
category-down Sort alphabetically by category, Z-A.
tag-up Sort alphabetically by last tag, A-Z.
tag-down Sort alphabetically by last tag, Z-A.
priority-up Sort numerically by priority, high priority last.
priority-down Sort numerically by priority, high priority first.
todo-state-up Sort by todo state, tasks that are done last.
todo-state-down Sort by todo state, tasks that are done first.
effort-up Sort numerically by estimated effort, high effort last.
effort-down Sort numerically by estimated effort, high effort first.
user-defined-up Sort according to `org-agenda-cmp-user-defined', high last.
user-defined-down Sort according to `org-agenda-cmp-user-defined', high first.
habit-up Put entries that are habits first
habit-down Put entries that are habits last
alpha-up Sort headlines alphabetically
alpha-down Sort headlines alphabetically, reversed
The different possibilities will be tried in sequence, and testing stops
if one comparison returns a \"not-equal\". For example, the default
'(time-up category-keep priority-down)
means: Pull out all entries having a specified time of day and sort them,
in order to make a time schedule for the current day the first thing in the
agenda listing for the day. Of the entries without a time indication, keep
the grouped in categories, don't sort the categories, but keep them in
the sequence given in `org-agenda-files'. Within each category sort by
priority.
Leaving out `category-keep' would mean that items will be sorted across
categories by priority.
Instead of a single list, this can also be a set of list for specific
contents, with a context symbol in the car of the list, any of
`agenda', `todo', `tags', `search' for the corresponding agenda views.
Custom commands can bind this variable in the options section."
:group 'org-agenda-sorting
:type `(choice
(repeat :tag "General" ,org-sorting-choice)
(list :tag "Individually"
(cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
(repeat ,org-sorting-choice))
(cons (const :tag "Strategy for TODO lists" todo)
(repeat ,org-sorting-choice))
(cons (const :tag "Strategy for Tags matches" tags)
(repeat ,org-sorting-choice))
(cons (const :tag "Strategy for search matches" search)
(repeat ,org-sorting-choice)))))
(defcustom org-agenda-cmp-user-defined nil
"A function to define the comparison `user-defined'.
This function must receive two arguments, agenda entry a and b.
If a>b, return +1. If a<b, return -1. If they are equal as seen by
the user comparison, return nil.
When this is defined, you can make `user-defined-up' and `user-defined-down'
part of an agenda sorting strategy."
:group 'org-agenda-sorting
:type 'symbol)
(defcustom org-sort-agenda-notime-is-late t
"Non-nil means items without time are considered late.
This is only relevant for sorting. When t, items which have no explicit
time like 15:30 will be considered as 99:01, i.e. later than any items which
do have a time. When nil, the default time is before 0:00. You can use this
option to decide if the schedule for today should come before or after timeless
agenda entries."
:group 'org-agenda-sorting
:type 'boolean)
(defcustom org-sort-agenda-noeffort-is-high t
"Non-nil means items without effort estimate are sorted as high effort.
This also applies when filtering an agenda view with respect to the
< or > effort operator. Then, tasks with no effort defined will be treated
as tasks with high effort.
When nil, such items are sorted as 0 minutes effort."
:group 'org-agenda-sorting
:type 'boolean)
(defgroup org-agenda-line-format nil
"Options concerning the entry prefix in the Org-mode agenda display."
:tag "Org Agenda Line Format"
:group 'org-agenda)
(defcustom org-agenda-prefix-format
'((agenda . " %i %-12:c%?-12t% s")
(timeline . " % s")
(todo . " %i %-12:c")
(tags . " %i %-12:c")
(search . " %i %-12:c"))
"Format specifications for the prefix of items in the agenda views.
An alist with five entries, each for the different agenda types. The
keys of the sublists are `agenda', `timeline', `todo', `search' and `tags'.
The values are format strings.
This format works similar to a printf format, with the following meaning:
%c the category of the item, \"Diary\" for entries from the diary,
or as given by the CATEGORY keyword or derived from the file name
%e the effort required by the item
%l the level of the item (insert X space(s) if item is of level X)
%i the icon category of the item, see `org-agenda-category-icon-alist'
%T the last tag of the item (ignore inherited tags, which come first)
%t the HH:MM time-of-day specification if one applies to the entry
%s Scheduling/Deadline information, a short string
%b show breadcrumbs, i.e., the names of the higher levels
%(expression) Eval EXPRESSION and replace the control string
by the result
All specifiers work basically like the standard `%s' of printf, but may
contain two additional characters: a question mark just after the `%'
and a whitespace/punctuation character just before the final letter.
If the first character after `%' is a question mark, the entire field
will only be included if the corresponding value applies to the current
entry. This is useful for fields which should have fixed width when
present, but zero width when absent. For example, \"%?-12t\" will
result in a 12 character time field if a time of the day is specified,
but will completely disappear in entries which do not contain a time.
If there is punctuation or whitespace character just before the
final format letter, this character will be appended to the field
value if the value is not empty. For example, the format
\"%-12:c\" leads to \"Diary: \" if the category is \"Diary\". If
the category is empty, no additional colon is inserted.
The default value for the agenda sublist is \" %-12:c%?-12t% s\",
which means:
- Indent the line with two space characters
- Give the category a 12 chars wide field, padded with whitespace on
the right (because of `-'). Append a colon if there is a category
(because of `:').
- If there is a time-of-day, put it into a 12 chars wide field. If no
time, don't put in an empty field, just skip it (because of '?').
- Finally, put the scheduling information.
See also the variables `org-agenda-remove-times-when-in-prefix' and
`org-agenda-remove-tags'.
Custom commands can set this variable in the options section."
:type '(choice
(string :tag "General format")
(list :greedy t :tag "View dependent"
(cons (const agenda) (string :tag "Format"))
(cons (const timeline) (string :tag "Format"))
(cons (const todo) (string :tag "Format"))
(cons (const tags) (string :tag "Format"))
(cons (const search) (string :tag "Format"))))
:group 'org-agenda-line-format)
(defvar org-prefix-format-compiled nil
"The compiled prefix format and associated variables.
This is a list where first element is a list of variable bindings, and second
element is the compiled format expression. See the variable
`org-agenda-prefix-format'.")
(defcustom org-agenda-todo-keyword-format "%-1s"
"Format for the TODO keyword in agenda lines.
Set this to something like \"%-12s\" if you want all TODO keywords
to occupy a fixed space in the agenda display."
:group 'org-agenda-line-format
:type 'string)
(defcustom org-agenda-diary-sexp-prefix nil
"A regexp that matches part of a diary sexp entry
which should be treated as scheduling/deadline information in
`org-agenda'.
For example, you can use this to extract the `diary-remind-message' from
`diary-remind' entries."
:group 'org-agenda-line-format
:type '(choice (const :tag "None" nil) (regexp :tag "Regexp")))
(defcustom org-agenda-timerange-leaders '("" "(%d/%d): ")
"Text preceding timerange entries in the agenda view.
This is a list with two strings. The first applies when the range
is entirely on one day. The second applies if the range spans several days.
The strings may have two \"%d\" format specifiers which will be filled
with the sequence number of the days, and the total number of days in the
range, respectively."
:group 'org-agenda-line-format
:type '(list
(string :tag "Deadline today ")
(choice :tag "Deadline relative"
(string :tag "Format string")
(function))))
(defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
"Text preceding scheduled items in the agenda view.
This is a list with two strings. The first applies when the item is
scheduled on the current day. The second applies when it has been scheduled
previously, it may contain a %d indicating that this is the nth time that
this item is scheduled, due to automatic rescheduling of unfinished items
for the following day. So this number is one larger than the number of days
that passed since this item was scheduled first."
:group 'org-agenda-line-format
:version "24.4"
:package-version '(Org . "8.0")
:type '(list
(string :tag "Scheduled today ")
(string :tag "Scheduled previously")))
(defcustom org-agenda-inactive-leader "["
"Text preceding item pulled into the agenda by inactive time stamps.
These entries are added to the agenda when pressing \"[\"."
:group 'org-agenda-line-format
:version "24.1"
:type 'string)
(defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: " "%2d d. ago: ")
"Text preceding deadline items in the agenda view.
This is a list with three strings. The first applies when the item has its
deadline on the current day. The second applies when the deadline is in the
future, the third one when it is in the past. The strings may contain %d
to capture the number of days."
:group 'org-agenda-line-format
:version "24.4"
:package-version '(Org . "8.0")
:type '(list
(string :tag "Deadline today ")
(string :tag "Deadline in the future ")
(string :tag "Deadline in the past ")))
(defcustom org-agenda-remove-times-when-in-prefix t
"Non-nil means remove duplicate time specifications in agenda items.
When the format `org-agenda-prefix-format' contains a `%t' specifier, a
time-of-day specification in a headline or diary entry is extracted and
placed into the prefix. If this option is non-nil, the original specification
\(a timestamp or -range, or just a plain time(range) specification like
11:30-4pm) will be removed for agenda display. This makes the agenda less
cluttered.
The option can be t or nil. It may also be the symbol `beg', indicating
that the time should only be removed when it is located at the beginning of
the headline/diary entry."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Always" t)
(const :tag "Never" nil)
(const :tag "When at beginning of entry" beg)))
(defcustom org-agenda-remove-timeranges-from-blocks nil
"Non-nil means remove time ranges specifications in agenda
items that span on several days."
:group 'org-agenda-line-format
:version "24.1"
:type 'boolean)
(defcustom org-agenda-default-appointment-duration nil
"Default duration for appointments that only have a starting time.
When nil, no duration is specified in such cases.
When non-nil, this must be the number of minutes, e.g. 60 for one hour."
:group 'org-agenda-line-format
:type '(choice
(integer :tag "Minutes")
(const :tag "No default duration")))
(defcustom org-agenda-show-inherited-tags t
"Non-nil means show inherited tags in each agenda line.
When this option is set to 'always, it take precedences over
`org-agenda-use-tag-inheritance' and inherited tags are shown
in every agenda.
When this option is set to t (the default), inherited tags are
shown when they are available, i.e. when the value of
`org-agenda-use-tag-inheritance' has been taken into account.
This can be set to a list of agenda types in which the agenda
must display the inherited tags. Available types are 'todo,
'agenda, 'search and 'timeline.
When set to nil, never show inherited tags in agenda lines."
:group 'org-agenda-line-format
:group 'org-agenda
:version "24.3"
:type '(choice
(const :tag "Show inherited tags when available" t)
(const :tag "Always show inherited tags" always)
(repeat :tag "Show inherited tags only in selected agenda types"
(symbol :tag "Agenda type"))))
(defcustom org-agenda-use-tag-inheritance '(todo search timeline agenda)
"List of agenda view types where to use tag inheritance.
In tags/tags-todo/tags-tree agenda views, tag inheritance is
controlled by `org-use-tag-inheritance'. In other agenda types,
`org-use-tag-inheritance' is not used for the selection of the
agenda entries. Still, you may want the agenda to be aware of
the inherited tags anyway, e.g. for later tag filtering.
Allowed value are 'todo, 'search, 'timeline and 'agenda.
This variable has no effect if `org-agenda-show-inherited-tags'
is set to 'always. In that case, the agenda is aware of those
tags.
The default value sets tags in every agenda type. Setting this
option to nil will speed up non-tags agenda view a lot."
:group 'org-agenda
:version "24.3"
:type '(choice
(const :tag "Use tag inheritance in all agenda types" t)
(repeat :tag "Use tag inheritance in selected agenda types"
(symbol :tag "Agenda type"))))
(defcustom org-agenda-hide-tags-regexp nil
"Regular expression used to filter away specific tags in agenda views.
This means that these tags will be present, but not be shown in the agenda
line. Secondary filtering will still work on the hidden tags.
Nil means don't hide any tags."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Hide none" nil)
(string :tag "Regexp ")))
(defcustom org-agenda-remove-tags nil
"Non-nil means remove the tags from the headline copy in the agenda.
When this is the symbol `prefix', only remove tags when
`org-agenda-prefix-format' contains a `%T' specifier."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Always" t)
(const :tag "Never" nil)
(const :tag "When prefix format contains %T" prefix)))
(org-defvaralias 'org-agenda-remove-tags-when-in-prefix
'org-agenda-remove-tags)
(defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
"Shift tags in agenda items to this column.
If this number is positive, it specifies the column. If it is negative,
it means that the tags should be flushright to that column. For example,
-80 works well for a normal 80 character screen."
:group 'org-agenda-line-format
:type 'integer)
(org-defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
(defcustom org-agenda-fontify-priorities 'cookies
"Non-nil means highlight low and high priorities in agenda.
When t, the highest priority entries are bold, lowest priority italic.
However, settings in `org-priority-faces' will overrule these faces.
When this variable is the symbol `cookies', only fontify the
cookies, not the entire task.
This may also be an association list of priority faces, whose
keys are the character values of `org-highest-priority',
`org-default-priority', and `org-lowest-priority' (the default values
are ?A, ?B, and ?C, respectively). The face may be a named face, a
color as a string, or a list like `(:background \"Red\")'.
If it is a color, the variable `org-faces-easy-properties'
determines if it is a foreground or a background color."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Never" nil)
(const :tag "Defaults" t)
(const :tag "Cookies only" cookies)
(repeat :tag "Specify"
(list (character :tag "Priority" :value ?A)
(choice :tag "Face "
(string :tag "Color")
(sexp :tag "Face"))))))
(defcustom org-agenda-day-face-function nil
"Function called to determine what face should be used to display a day.
The only argument passed to that function is the day. It should
returns a face, or nil if does not want to specify a face and let
the normal rules apply."
:group 'org-agenda-line-format
:version "24.1"
:type '(choice (const nil) (function)))
(defcustom org-agenda-category-icon-alist nil
"Alist of category icon to be displayed in agenda views.
Each entry should have the following format:
(CATEGORY-REGEXP FILE-OR-DATA TYPE DATA-P PROPS)
Where CATEGORY-REGEXP is a regexp matching the categories where
the icon should be displayed.
FILE-OR-DATA either a file path or a string containing image data.
The other fields can be omitted safely if not needed:
TYPE indicates the image type.
DATA-P is a boolean indicating whether the FILE-OR-DATA string is
image data.
PROPS are additional image attributes to assign to the image,
like, e.g. `:ascent center'.
(\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
If you want to set the display properties yourself, just put a
list as second element:
(CATEGORY-REGEXP (MY PROPERTY LIST))
For example, to display a 16px horizontal space for Emacs
category, you can use:
(\"Emacs\" '(space . (:width (16))))"
:group 'org-agenda-line-format
:version "24.1"
:type '(alist :key-type (string :tag "Regexp matching category")
:value-type (choice (list :tag "Icon"
(string :tag "File or data")
(symbol :tag "Type")
(boolean :tag "Data?")
(repeat :tag "Extra image properties" :inline t symbol))
(list :tag "Display properties" sexp))))
(defgroup org-agenda-column-view nil
"Options concerning column view in the agenda."
:tag "Org Agenda Column View"
:group 'org-agenda)
(defcustom org-agenda-columns-show-summaries t
"Non-nil means show summaries for columns displayed in the agenda view."
:group 'org-agenda-column-view
:type 'boolean)
(defcustom org-agenda-columns-compute-summary-properties t
"Non-nil means recompute all summary properties before column view.
When column view in the agenda is listing properties that have a summary
operator, it can go to all relevant buffers and recompute the summaries
there. This can mean overhead for the agenda column view, but is necessary
to have thing up to date.
As a special case, a CLOCKSUM property also makes sure that the clock
computations are current."
:group 'org-agenda-column-view
:type 'boolean)
(defcustom org-agenda-columns-add-appointments-to-effort-sum nil
"Non-nil means the duration of an appointment will add to day effort.
The property to which appointment durations will be added is the one given
in the option `org-effort-property'. If an appointment does not have
an end time, `org-agenda-default-appointment-duration' will be used. If that
is not set, an appointment without end time will not contribute to the time
estimate."
:group 'org-agenda-column-view
:type 'boolean)
(defcustom org-agenda-auto-exclude-function nil
"A function called with a tag to decide if it is filtered on '/ RET'.
The sole argument to the function, which is called once for each
possible tag, is a string giving the name of the tag. The
function should return either nil if the tag should be included
as normal, or \"-<TAG>\" to exclude the tag.
Note that for the purpose of tag filtering, only the lower-case version of
all tags will be considered, so that this function will only ever see
the lower-case version of all tags."
:group 'org-agenda
:type '(choice (const nil) (function)))
(defcustom org-agenda-bulk-custom-functions nil
"Alist of characters and custom functions for bulk actions.
For example, this value makes those two functions available:
'((?R set-category)
(?C bulk-cut))
With selected entries in an agenda buffer, `B R' will call
the custom function `set-category' on the selected entries.
Note that functions in this alist don't need to be quoted."
:type 'alist
:version "24.1"
:group 'org-agenda)
(defmacro org-agenda-with-point-at-orig-entry (string &rest body)
"Execute BODY with point at location given by `org-hd-marker' property.
If STRING is non-nil, the text property will be fetched from position 0
in that string. If STRING is nil, it will be fetched from the beginning
of the current line."
(org-with-gensyms (marker)
`(let ((,marker (get-text-property (if string 0 (point-at-bol))
'org-hd-marker ,string)))
(with-current-buffer (marker-buffer ,marker)
(save-excursion
(goto-char ,marker)
,@body)))))
(def-edebug-spec org-agenda-with-point-at-orig-entry (form body))
(defun org-add-agenda-custom-command (entry)
"Replace or add a command in `org-agenda-custom-commands'.
This is mostly for hacking and trying a new command - once the command
works you probably want to add it to `org-agenda-custom-commands' for good."
(let ((ass (assoc (car entry) org-agenda-custom-commands)))
(if ass
(setcdr ass (cdr entry))
(push entry org-agenda-custom-commands))))
;;; Define the org-agenda-mode
(defvar org-agenda-mode-map (make-sparse-keymap)
"Keymap for `org-agenda-mode'.")
(org-defvaralias 'org-agenda-keymap 'org-agenda-mode-map)
(defvar org-agenda-menu) ; defined later in this file.
(defvar org-agenda-restrict nil) ; defined later in this file.
(defvar org-agenda-follow-mode nil)
(defvar org-agenda-entry-text-mode nil)
(defvar org-agenda-clockreport-mode nil)
(defvar org-agenda-show-log nil)
(defvar org-agenda-redo-command nil)
(defvar org-agenda-query-string nil)
(defvar org-agenda-mode-hook nil
"Hook run after `org-agenda-mode' is turned on.
The buffer is still writable when this hook is called.")
(defvar org-agenda-type nil)
(defvar org-agenda-force-single-file nil)
(defvar org-agenda-bulk-marked-entries nil
"List of markers that refer to marked entries in the agenda.")
;;; Multiple agenda buffers support
(defcustom org-agenda-sticky nil
"Non-nil means agenda q key will bury agenda buffers.
Agenda commands will then show existing buffer instead of generating new ones.
When nil, `q' will kill the single agenda buffer."
:group 'org-agenda
:version "24.3"
:type 'boolean)
;;;###autoload
(defun org-toggle-sticky-agenda (&optional arg)
"Toggle `org-agenda-sticky'."
(interactive "P")
(let ((new-value (if arg
(> (prefix-numeric-value arg) 0)
(not org-agenda-sticky))))
(if (equal new-value org-agenda-sticky)
(and (org-called-interactively-p 'interactive)
(message "Sticky agenda was already %s"
(if org-agenda-sticky "enabled" "disabled")))
(setq org-agenda-sticky new-value)
(org-agenda-kill-all-agenda-buffers)
(and (org-called-interactively-p 'interactive)
(message "Sticky agenda was %s"
(if org-agenda-sticky "enabled" "disabled"))))))
(defvar org-agenda-buffer nil
"Agenda buffer currently being generated.")
(defvar org-agenda-last-prefix-arg nil)
(defvar org-agenda-this-buffer-name nil)
(defvar org-agenda-doing-sticky-redo nil)
(defvar org-agenda-this-buffer-is-sticky nil)
(defconst org-agenda-local-vars
'(org-agenda-this-buffer-name
org-agenda-undo-list
org-agenda-pending-undo-list
org-agenda-follow-mode
org-agenda-entry-text-mode
org-agenda-clockreport-mode
org-agenda-show-log
org-agenda-redo-command
org-agenda-query-string
org-agenda-type
org-agenda-bulk-marked-entries
org-agenda-undo-has-started-in
org-agenda-info
org-agenda-pre-window-conf
org-agenda-columns-active
org-agenda-tag-filter
org-agenda-category-filter
org-agenda-top-headline-filter
org-agenda-regexp-filter
org-agenda-markers
org-agenda-last-search-view-search-was-boolean
org-agenda-filtered-by-category
org-agenda-filter-form
org-agenda-cycle-counter
org-agenda-last-prefix-arg)
"Variables that must be local in agenda buffers to allow multiple buffers.")
(defun org-agenda-mode ()
"Mode for time-sorted view on action items in Org-mode files.
The following commands are available:
\\{org-agenda-mode-map}"
(interactive)
(cond (org-agenda-doing-sticky-redo
;; Refreshing sticky agenda-buffer
;;
;; Preserve the value of `org-agenda-local-vars' variables,
;; while letting `kill-all-local-variables' kill the rest
(let ((save (buffer-local-variables)))
(kill-all-local-variables)
(mapc 'make-local-variable org-agenda-local-vars)
(dolist (elem save)
(let ((var (car elem))
(val (cdr elem)))
(when (and val
(member var org-agenda-local-vars))
(set var val)))))
(set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
(org-agenda-sticky
;; Creating a sticky Agenda buffer for the first time
(kill-all-local-variables)
(mapc 'make-local-variable org-agenda-local-vars)
(set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
(t
;; Creating a non-sticky agenda buffer
(kill-all-local-variables)
(set (make-local-variable 'org-agenda-this-buffer-is-sticky) nil)))
(setq org-agenda-undo-list nil
org-agenda-pending-undo-list nil
org-agenda-bulk-marked-entries nil)
(setq major-mode 'org-agenda-mode)
;; Keep global-font-lock-mode from turning on font-lock-mode
(org-set-local 'font-lock-global-modes (list 'not major-mode))
(setq mode-name "Org-Agenda")
(setq indent-tabs-mode nil)
(use-local-map org-agenda-mode-map)
(easy-menu-add org-agenda-menu)
(if org-startup-truncated (setq truncate-lines t))
(org-set-local 'line-move-visual nil)
(org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
(org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
;; Make sure properties are removed when copying text
(org-add-hook 'filter-buffer-substring-functions
(lambda (fun start end delete)
(substring-no-properties (funcall fun start end delete)))
nil t)
(unless org-agenda-keep-modes
(setq org-agenda-follow-mode org-agenda-start-with-follow-mode
org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode))
(setq org-agenda-show-log org-agenda-start-with-log-mode)
(setq org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode)
(add-to-invisibility-spec '(org-filtered))
(add-to-invisibility-spec '(org-link))
(easy-menu-change
'("Agenda") "Agenda Files"
(append
(list
(vector
(if (get 'org-agenda-files 'org-restrict)
"Restricted to single file"
"Edit File List")
'(org-edit-agenda-file-list)
(not (get 'org-agenda-files 'org-restrict)))
"--")
(mapcar 'org-file-menu-entry (org-agenda-files))))
(org-agenda-set-mode-name)
(apply
(if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
(list 'org-agenda-mode-hook)))
(substitute-key-definition 'undo 'org-agenda-undo
org-agenda-mode-map global-map)
(org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
(org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
(org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
(org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
(org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward)
(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward)
(org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
(org-defkey org-agenda-mode-map "\M-m" 'org-agenda-bulk-toggle)
(org-defkey org-agenda-mode-map "*" 'org-agenda-bulk-mark-all)
(org-defkey org-agenda-mode-map "\M-*" 'org-agenda-bulk-toggle-all)
(org-defkey org-agenda-mode-map "#" 'org-agenda-dim-blocked-tasks)
(org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
(org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
(org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-unmark-all)
(org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
(org-defkey org-agenda-mode-map "k" 'org-agenda-capture)
(org-defkey org-agenda-mode-map "A" 'org-agenda-append-agenda)
(org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
(org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
(org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
(org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
(org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
(org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
(org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up)
(org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down)
(org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down)
(org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
(org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
(org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
(org-defkey org-agenda-mode-map "o" 'delete-other-windows)
(org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
(org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
(org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
(org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation)
(org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
(org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
(org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
(org-defkey org-agenda-mode-map "j" 'org-agenda-goto-date)
(org-defkey org-agenda-mode-map "d" 'org-agenda-day-view)
(org-defkey org-agenda-mode-map "w" 'org-agenda-week-view)
(org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
(org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
(org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
(org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
(org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
(org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
(org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
(let ((l '(1 2 3 4 5 6 7 8 9 0)))
(while l (org-defkey org-agenda-mode-map
(int-to-string (pop l)) 'digit-argument)))
(org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
(org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
(org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
(org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
(org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
(org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
(org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines)
(org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
(org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
(org-defkey org-agenda-mode-map "g" (lambda () (interactive) (org-agenda-redo t)))
(org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
(org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
'org-clock-modify-effort-estimate)
(org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
(org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
(org-defkey org-agenda-mode-map "Q" 'org-agenda-Quit)
(org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
(org-defkey org-agenda-mode-map "\C-x\C-w" 'org-agenda-write)
(org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
(org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
(org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags)
(org-defkey org-agenda-mode-map "n" 'org-agenda-next-line)
(org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line)
(org-defkey org-agenda-mode-map "N" 'org-agenda-next-item)
(org-defkey org-agenda-mode-map "P" 'org-agenda-previous-item)
(substitute-key-definition 'next-line 'org-agenda-next-line
org-agenda-mode-map global-map)
(substitute-key-definition 'previous-line 'org-agenda-previous-line
org-agenda-mode-map global-map)
(org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach)
(org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line)
(org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line)
(org-defkey org-agenda-mode-map "\C-c," 'org-agenda-priority)
(org-defkey org-agenda-mode-map "," 'org-agenda-priority)
(org-defkey org-agenda-mode-map "i" 'org-agenda-diary-entry)
(org-defkey org-agenda-mode-map "c" 'org-agenda-goto-calendar)
(org-defkey org-agenda-mode-map "C" 'org-agenda-convert-date)
(org-defkey org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
(org-defkey org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
(org-defkey org-agenda-mode-map "h" 'org-agenda-holidays)
(org-defkey org-agenda-mode-map "H" 'org-agenda-holidays)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-i" 'org-agenda-clock-in)
(org-defkey org-agenda-mode-map "I" 'org-agenda-clock-in)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-o" 'org-agenda-clock-out)
(org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
(org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
(org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto)
(org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up)
(org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
(org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
(org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
(org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
(org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
(org-defkey org-agenda-mode-map "f" 'org-agenda-later)
(org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
(org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
(org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
(org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
(org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
(org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
(org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
(org-defkey org-agenda-mode-map "=" 'org-agenda-filter-by-regexp)
(org-defkey org-agenda-mode-map "|" 'org-agenda-filter-remove-all)
(org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
(org-defkey org-agenda-mode-map "~" 'org-agenda-limit-interactively)
(org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-headline)
(org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
(define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
(org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse)
(org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse)
(when org-agenda-mouse-1-follows-link
(org-defkey org-agenda-mode-map [follow-link] 'mouse-face))
(easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
'("Agenda"
("Agenda Files")
"--"
("Agenda Dates"
["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
["Jump to date" org-agenda-goto-date (org-agenda-check-type nil 'agenda)])
"--"
("View"
["Day View" org-agenda-day-view
:active (org-agenda-check-type nil 'agenda)
:style radio :selected (eq org-agenda-current-span 'day)
:keys "v d (or just d)"]
["Week View" org-agenda-week-view
:active (org-agenda-check-type nil 'agenda)
:style radio :selected (eq org-agenda-current-span 'week)
:keys "v w"]
["Fortnight View" org-agenda-fortnight-view
:active (org-agenda-check-type nil 'agenda)
:style radio :selected (eq org-agenda-current-span 'fortnight)
:keys "v f"]
["Month View" org-agenda-month-view
:active (org-agenda-check-type nil 'agenda)
:style radio :selected (eq org-agenda-current-span 'month)
:keys "v m"]
["Year View" org-agenda-year-view
:active (org-agenda-check-type nil 'agenda)
:style radio :selected (eq org-agenda-current-span 'year)
:keys "v y"]
"--"
["Include Diary" org-agenda-toggle-diary
:style toggle :selected org-agenda-include-diary
:active (org-agenda-check-type nil 'agenda)]
["Include Deadlines" org-agenda-toggle-deadlines
:style toggle :selected org-agenda-include-deadlines
:active (org-agenda-check-type nil 'agenda)]
["Use Time Grid" org-agenda-toggle-time-grid
:style toggle :selected org-agenda-use-time-grid
:active (org-agenda-check-type nil 'agenda)]
"--"
["Show clock report" org-agenda-clockreport-mode
:style toggle :selected org-agenda-clockreport-mode
:active (org-agenda-check-type nil 'agenda)]
["Show some entry text" org-agenda-entry-text-mode
:style toggle :selected org-agenda-entry-text-mode
:active t]
"--"
["Show Logbook entries" org-agenda-log-mode
:style toggle :selected org-agenda-show-log
:active (org-agenda-check-type nil 'agenda 'timeline)
:keys "v l (or just l)"]
["Include archived trees" org-agenda-archives-mode
:style toggle :selected org-agenda-archives-mode :active t
:keys "v a"]
["Include archive files" (org-agenda-archives-mode t)
:style toggle :selected (eq org-agenda-archives-mode t) :active t
:keys "v A"]
"--"
["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict])
["Write view to file" org-agenda-write t]
["Rebuild buffer" org-agenda-redo t]
["Save all Org-mode Buffers" org-save-all-org-buffers t]
"--"
["Show original entry" org-agenda-show t]
["Go To (other window)" org-agenda-goto t]
["Go To (this window)" org-agenda-switch-to t]
["Capture with cursor date" org-agenda-capture t]
["Follow Mode" org-agenda-follow-mode
:style toggle :selected org-agenda-follow-mode :active t]
;; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
"--"
("TODO"
["Cycle TODO" org-agenda-todo t]
["Next TODO set" org-agenda-todo-nextset t]
["Previous TODO set" org-agenda-todo-previousset t]
["Add note" org-agenda-add-note t])
("Archive/Refile/Delete"
["Archive default" org-agenda-archive-default t]
["Archive default" org-agenda-archive-default-with-confirmation t]
["Toggle ARCHIVE tag" org-agenda-toggle-archive-tag t]
["Move to archive sibling" org-agenda-archive-to-archive-sibling t]
["Archive subtree" org-agenda-archive t]
"--"
["Refile" org-agenda-refile t]
"--"
["Delete subtree" org-agenda-kill t])
("Bulk action"
["Mark entry" org-agenda-bulk-mark t]
["Mark all" org-agenda-bulk-mark-all t]
["Unmark entry" org-agenda-bulk-unmark t]
["Unmark all" org-agenda-bulk-unmark-all :active t :keys "U"]
["Toggle mark" org-agenda-bulk-toggle t]
["Toggle all" org-agenda-bulk-toggle-all t]
["Mark regexp" org-agenda-bulk-mark-regexp t])
["Act on all marked" org-agenda-bulk-action t]
"--"
("Tags and Properties"
["Show all Tags" org-agenda-show-tags t]
["Set Tags current line" org-agenda-set-tags (not (org-region-active-p))]
["Change tag in region" org-agenda-set-tags (org-region-active-p)]
"--"
["Column View" org-columns t])
("Deadline/Schedule"
["Schedule" org-agenda-schedule t]
["Set Deadline" org-agenda-deadline t]
"--"
["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
("Clock and Effort"
["Clock in" org-agenda-clock-in t]
["Clock out" org-agenda-clock-out t]
["Clock cancel" org-agenda-clock-cancel t]
["Goto running clock" org-clock-goto t]
"--"
["Set Effort" org-agenda-set-effort t]
["Change clocked effort" org-clock-modify-effort-estimate
(org-clock-is-active)])
("Priority"
["Set Priority" org-agenda-priority t]
["Increase Priority" org-agenda-priority-up t]
["Decrease Priority" org-agenda-priority-down t]
["Show Priority" org-show-priority t])
("Calendar/Diary"
["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
"--"
["Create iCalendar File" org-icalendar-combine-agenda-files t])
"--"
["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
"--"
("MobileOrg"
["Push Files and Views" org-mobile-push t]
["Get Captured and Flagged" org-mobile-pull t]
["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"]
["Show note / unflag" org-agenda-show-the-flagging-note t]
"--"
["Setup" (progn (require 'org-mobile) (customize-group 'org-mobile)) t])
"--"
["Quit" org-agenda-quit t]
["Exit and Release Buffers" org-agenda-exit t]
))
;;; Agenda undo
(defvar org-agenda-allow-remote-undo t
"Non-nil means allow remote undo from the agenda buffer.")
(defvar org-agenda-undo-has-started-in nil
"Buffers that have already seen `undo-start' in the current undo sequence.")
(defun org-agenda-undo ()
"Undo a remote editing step in the agenda.
This undoes changes both in the agenda buffer and in the remote buffer
that have been changed along."
(interactive)
(or org-agenda-allow-remote-undo
(user-error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
(if (not (eq this-command last-command))
(setq org-agenda-undo-has-started-in nil
org-agenda-pending-undo-list org-agenda-undo-list))
(if (not org-agenda-pending-undo-list)
(user-error "No further undo information"))
(let* ((entry (pop org-agenda-pending-undo-list))
buf line cmd rembuf)
(setq cmd (pop entry) line (pop entry))
(setq rembuf (nth 2 entry))
(org-with-remote-undo rembuf
(while (bufferp (setq buf (pop entry)))
(if (pop entry)
(with-current-buffer buf
(let ((last-undo-buffer buf)
(inhibit-read-only t))
(unless (memq buf org-agenda-undo-has-started-in)
(push buf org-agenda-undo-has-started-in)
(make-local-variable 'pending-undo-list)
(undo-start))
(while (and pending-undo-list
(listp pending-undo-list)
(not (car pending-undo-list)))
(pop pending-undo-list))
(undo-more 1))))))
(org-goto-line line)
(message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))
(defun org-verify-change-for-undo (l1 l2)
"Verify that a real change occurred between the undo lists L1 and L2."
(while (and l1 (listp l1) (null (car l1))) (pop l1))
(while (and l2 (listp l2) (null (car l2))) (pop l2))
(not (eq l1 l2)))
;;; Agenda dispatch
(defvar org-agenda-restrict-begin (make-marker))
(defvar org-agenda-restrict-end (make-marker))
(defvar org-agenda-last-dispatch-buffer nil)
(defvar org-agenda-overriding-restriction nil)
(defcustom org-agenda-custom-commands-contexts nil
"Alist of custom agenda keys and contextual rules.
For example, if you have a custom agenda command \"p\" and you
want this command to be accessible only from plain text files,
use this:
'((\"p\" ((in-file . \"\\.txt\"))))
Here are the available contexts definitions:
in-file: command displayed only in matching files
in-mode: command displayed only in matching modes
not-in-file: command not displayed in matching files
not-in-mode: command not displayed in matching modes
in-buffer: command displayed only in matching buffers
not-in-buffer: command not displayed in matching buffers
[function]: a custom function taking no argument
If you define several checks, the agenda command will be
accessible if there is at least one valid check.
You can also bind a key to another agenda custom command
depending on contextual rules.
'((\"p\" \"q\" ((in-file . \"\\.txt\"))))
Here it means: in .txt files, use \"p\" as the key for the
agenda command otherwise associated with \"q\". (The command
originally associated with \"q\" is not displayed to avoid
duplicates.)"
:version "24.3"
:group 'org-agenda-custom-commands
:type '(repeat (list :tag "Rule"
(string :tag " Agenda key")
(string :tag "Replace by command")
(repeat :tag "Available when"
(choice
(cons :tag "Condition"
(choice
(const :tag "In file" in-file)
(const :tag "Not in file" not-in-file)
(const :tag "In buffer" in-buffer)
(const :tag "Not in buffer" not-in-buffer)
(const :tag "In mode" in-mode)
(const :tag "Not in mode" not-in-mode))
(regexp))
(function :tag "Custom function"))))))
(defcustom org-agenda-max-entries nil
"Maximum number of entries to display in an agenda.
This can be nil (no limit) or an integer or an alist of agenda
types with an associated number of entries to display in this
type."
:version "24.4"
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
(integer :tag "Max number of entries")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
(const todo)
(const tags)
(const search)
(const timeline))
(integer :tag "Max number of entries")))))
(defcustom org-agenda-max-todos nil
"Maximum number of TODOs to display in an agenda.
This can be nil (no limit) or an integer or an alist of agenda
types with an associated number of entries to display in this
type."
:version "24.4"
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
(integer :tag "Max number of TODOs")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
(const todo)
(const tags)
(const search)
(const timeline))
(integer :tag "Max number of TODOs")))))
(defcustom org-agenda-max-tags nil
"Maximum number of tagged entries to display in an agenda.
This can be nil (no limit) or an integer or an alist of agenda
types with an associated number of entries to display in this
type."
:version "24.4"
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
(integer :tag "Max number of tagged entries")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
(const todo)
(const tags)
(const search)
(const timeline))
(integer :tag "Max number of tagged entries")))))
(defcustom org-agenda-max-effort nil
"Maximum cumulated effort duration for the agenda.
This can be nil (no limit) or a number of minutes (as an integer)
or an alist of agenda types with an associated number of minutes
to limit entries to in this type."
:version "24.4"
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
(integer :tag "Max number of minutes")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
(const todo)
(const tags)
(const search)
(const timeline))
(integer :tag "Max number of minutes")))))
(defvar org-keys nil)
(defvar org-match nil)
;;;###autoload
(defun org-agenda (&optional arg org-keys restriction)
"Dispatch agenda commands to collect entries to the agenda buffer.
Prompts for a command to execute. Any prefix arg will be passed
on to the selected command. The default selections are:
a Call `org-agenda-list' to display the agenda for current day or week.
t Call `org-todo-list' to display the global todo list.
T Call `org-todo-list' to display the global todo list, select only
entries with a specific TODO keyword (the user gets a prompt).
m Call `org-tags-view' to display headlines with tags matching
a condition (the user is prompted for the condition).
M Like `m', but select only TODO entries, no ordinary headlines.
L Create a timeline for the current buffer.
e Export views to associated files.
s Search entries for keywords.
S Search entries for keywords, only with TODO keywords.
/ Multi occur across all agenda files and also files listed
in `org-agenda-text-search-extra-files'.
< Restrict agenda commands to buffer, subtree, or region.
Press several times to get the desired effect.
> Remove a previous restriction.
# List \"stuck\" projects.
! Configure what \"stuck\" means.
C Configure custom agenda commands.
More commands can be added by configuring the variable
`org-agenda-custom-commands'. In particular, specific tags and TODO keyword
searches can be pre-defined in this way.
If the current buffer is in Org-mode and visiting a file, you can also
first press `<' once to indicate that the agenda should be temporarily
\(until the next use of \\[org-agenda]) restricted to the current file.
Pressing `<' twice means to restrict to the current subtree or region
\(if active)."
(interactive "P")
(catch 'exit
(let* ((prefix-descriptions nil)
(org-agenda-buffer-name org-agenda-buffer-name)
(org-agenda-window-setup (if (equal (buffer-name)
org-agenda-buffer-name)
'current-window
org-agenda-window-setup))
(org-agenda-custom-commands-orig org-agenda-custom-commands)
(org-agenda-custom-commands
;; normalize different versions
(delq nil
(mapcar
(lambda (x)
(cond ((stringp (cdr x))
(push x prefix-descriptions)
nil)
((stringp (nth 1 x)) x)
((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
(t (cons (car x) (cons "" (cdr x))))))
org-agenda-custom-commands)))
(org-agenda-custom-commands
(org-contextualize-keys
org-agenda-custom-commands org-agenda-custom-commands-contexts))
(buf (current-buffer))
(bfn (buffer-file-name (buffer-base-buffer)))
entry key type org-match lprops ans)
;; Turn off restriction unless there is an overriding one,
(unless org-agenda-overriding-restriction
(unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
;; There is a request to keep the file list in place
(put 'org-agenda-files 'org-restrict nil))
(setq org-agenda-restrict nil)
(move-marker org-agenda-restrict-begin nil)
(move-marker org-agenda-restrict-end nil))
;; Delete old local properties
(put 'org-agenda-redo-command 'org-lprops nil)
;; Delete previously set last-arguments
(put 'org-agenda-redo-command 'last-args nil)
;; Remember where this call originated
(setq org-agenda-last-dispatch-buffer (current-buffer))
(unless org-keys
(setq ans (org-agenda-get-restriction-and-command prefix-descriptions)
org-keys (car ans)
restriction (cdr ans)))
;; If we have sticky agenda buffers, set a name for the buffer,
;; depending on the invoking keys. The user may still set this
;; as a command option, which will overwrite what we do here.
(if org-agenda-sticky
(setq org-agenda-buffer-name
(format "*Org Agenda(%s)*" org-keys)))
;; Establish the restriction, if any
(when (and (not org-agenda-overriding-restriction) restriction)
(put 'org-agenda-files 'org-restrict (list bfn))
(cond
((eq restriction 'region)
(setq org-agenda-restrict (current-buffer))
(move-marker org-agenda-restrict-begin (region-beginning))
(move-marker org-agenda-restrict-end (region-end)))
((eq restriction 'subtree)
(save-excursion
(setq org-agenda-restrict (current-buffer))
(org-back-to-heading t)
(move-marker org-agenda-restrict-begin (point))
(move-marker org-agenda-restrict-end
(progn (org-end-of-subtree t)))))))
;; For example the todo list should not need it (but does...)
(cond
((setq entry (assoc org-keys org-agenda-custom-commands))
(if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry)))
(progn
(setq type (nth 2 entry) org-match (eval (nth 3 entry))
lprops (nth 4 entry))
(if org-agenda-sticky
(setq org-agenda-buffer-name
(or (and (stringp org-match) (format "*Org Agenda(%s:%s)*" org-keys org-match))
(format "*Org Agenda(%s)*" org-keys))))
(put 'org-agenda-redo-command 'org-lprops lprops)
(cond
((eq type 'agenda)
(org-let lprops '(org-agenda-list current-prefix-arg)))
((eq type 'agenda*)
(org-let lprops '(org-agenda-list current-prefix-arg nil nil t)))
((eq type 'alltodo)
(org-let lprops '(org-todo-list current-prefix-arg)))
((eq type 'search)
(org-let lprops '(org-search-view current-prefix-arg org-match nil)))
((eq type 'stuck)
(org-let lprops '(org-agenda-list-stuck-projects
current-prefix-arg)))
((eq type 'tags)
(org-let lprops '(org-tags-view current-prefix-arg org-match)))
((eq type 'tags-todo)
(org-let lprops '(org-tags-view '(4) org-match)))
((eq type 'todo)
(org-let lprops '(org-todo-list org-match)))
((eq type 'tags-tree)
(org-check-for-org-mode)
(org-let lprops '(org-match-sparse-tree current-prefix-arg org-match)))
((eq type 'todo-tree)
(org-check-for-org-mode)
(org-let lprops
'(org-occur (concat "^" org-outline-regexp "[ \t]*"
(regexp-quote org-match) "\\>"))))
((eq type 'occur-tree)
(org-check-for-org-mode)
(org-let lprops '(org-occur org-match)))
((functionp type)
(org-let lprops '(funcall type org-match)))
((fboundp type)
(org-let lprops '(funcall type org-match)))
(t (user-error "Invalid custom agenda command type %s" type))))
(org-agenda-run-series (nth 1 entry) (cddr entry))))
((equal org-keys "C")
(setq org-agenda-custom-commands org-agenda-custom-commands-orig)
(customize-variable 'org-agenda-custom-commands))
((equal org-keys "a") (call-interactively 'org-agenda-list))
((equal org-keys "s") (call-interactively 'org-search-view))
((equal org-keys "S") (org-call-with-arg 'org-search-view (or arg '(4))))
((equal org-keys "t") (call-interactively 'org-todo-list))
((equal org-keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
((equal org-keys "m") (call-interactively 'org-tags-view))
((equal org-keys "M") (org-call-with-arg 'org-tags-view (or arg '(4))))
((equal org-keys "e") (call-interactively 'org-store-agenda-views))
((equal org-keys "?") (org-tags-view nil "+FLAGGED")
(org-add-hook
'post-command-hook
(lambda ()
(unless (current-message)
(let* ((m (org-agenda-get-any-marker))
(note (and m (org-entry-get m "THEFLAGGINGNOTE"))))
(when note
(message (concat
"FLAGGING-NOTE ([?] for more info): "
(org-add-props
(replace-regexp-in-string
"\\\\n" "//"
(copy-sequence note))
nil 'face 'org-warning)))))))
t t))
((equal org-keys "L")
(unless (derived-mode-p 'org-mode)
(user-error "This is not an Org-mode file"))
(unless restriction
(put 'org-agenda-files 'org-restrict (list bfn))
(org-call-with-arg 'org-timeline arg)))
((equal org-keys "#") (call-interactively 'org-agenda-list-stuck-projects))
((equal org-keys "/") (call-interactively 'org-occur-in-agenda-files))
((equal org-keys "!") (customize-variable 'org-stuck-projects))
(t (user-error "Invalid agenda key"))))))
(defvar org-agenda-multi)
(defun org-agenda-append-agenda ()
"Append another agenda view to the current one.
This function allows interactive building of block agendas.
Agenda views are separated by `org-agenda-block-separator'."
(interactive)
(unless (derived-mode-p 'org-agenda-mode)
(user-error "Can only append from within agenda buffer"))
(let ((org-agenda-multi t))
(org-agenda)
(widen)
(org-agenda-finalize)
(setq buffer-read-only t)
(org-agenda-fit-window-to-buffer)))
(defun org-agenda-normalize-custom-commands (cmds)
"Normalize custom commands CMDS."
(delq nil
(mapcar
(lambda (x)
(cond ((stringp (cdr x)) nil)
((stringp (nth 1 x)) x)
((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
(t (cons (car x) (cons "" (cdr x))))))
cmds)))
(defun org-agenda-get-restriction-and-command (prefix-descriptions)
"The user interface for selecting an agenda command."
(catch 'exit
(let* ((bfn (buffer-file-name (buffer-base-buffer)))
(restrict-ok (and bfn (derived-mode-p 'org-mode)))
(region-p (org-region-active-p))
(custom org-agenda-custom-commands)
(selstring "")
restriction second-time
c entry key type match prefixes rmheader header-end custom1 desc
line lines left right n n1)
(save-window-excursion
(delete-other-windows)
(org-switch-to-buffer-other-window " *Agenda Commands*")
(erase-buffer)
(insert (eval-when-compile
(let ((header
"Press key for an agenda command: < Buffer, subtree/region restriction
-------------------------------- > Remove restriction
a Agenda for current week or day e Export agenda views
t List of all TODO entries T Entries with special TODO kwd
m Match a TAGS/PROP/TODO query M Like m, but only TODO entries
s Search for keywords S Like s, but only TODO entries
L Timeline for current buffer # List stuck projects (!=configure)
/ Multi-occur C Configure custom agenda commands
? Find :FLAGGED: entries * Toggle sticky agenda views
")
(start 0))
(while (string-match
"\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)"
header start)
(setq start (match-end 0))
(add-text-properties (match-beginning 2) (match-end 2)
'(face bold) header))
header)))
(setq header-end (point-marker))
(while t
(setq custom1 custom)
(when (eq rmheader t)
(org-goto-line 1)
(re-search-forward ":" nil t)
(delete-region (match-end 0) (point-at-eol))
(forward-char 1)
(looking-at "-+")
(delete-region (match-end 0) (point-at-eol))
(move-marker header-end (match-end 0)))
(goto-char header-end)
(delete-region (point) (point-max))
;; Produce all the lines that describe custom commands and prefixes
(setq lines nil)
(while (setq entry (pop custom1))
(setq key (car entry) desc (nth 1 entry)
type (nth 2 entry)
match (nth 3 entry))
(if (> (length key) 1)
(add-to-list 'prefixes (string-to-char key))
(setq line
(format
"%-4s%-14s"
(org-add-props (copy-sequence key)
'(face bold))
(cond
((string-match "\\S-" desc) desc)
((eq type 'agenda) "Agenda for current week or day")
((eq type 'agenda*) "Appointments for current week or day")
((eq type 'alltodo) "List of all TODO entries")
((eq type 'search) "Word search")
((eq type 'stuck) "List of stuck projects")
((eq type 'todo) "TODO keyword")
((eq type 'tags) "Tags query")
((eq type 'tags-todo) "Tags (TODO)")
((eq type 'tags-tree) "Tags tree")
((eq type 'todo-tree) "TODO kwd tree")
((eq type 'occur-tree) "Occur tree")
((functionp type) (if (symbolp type)
(symbol-name type)
"Lambda expression"))
(t "???"))))
(if org-agenda-menu-show-matcher
(setq line
(concat line ": "
(cond
((stringp match)
(setq match (copy-sequence match))
(org-add-props match nil 'face 'org-warning))
((listp type)
(format "set of %d commands" (length type))))))
(if (org-string-nw-p match)
(add-text-properties
0 (length line) (list 'help-echo
(concat "Matcher: " match)) line)))
(push line lines)))
(setq lines (nreverse lines))
(when prefixes
(mapc (lambda (x)
(push
(format "%s %s"
(org-add-props (char-to-string x)
nil 'face 'bold)
(or (cdr (assoc (concat selstring
(char-to-string x))
prefix-descriptions))
"Prefix key"))
lines))
prefixes))
;; Check if we should display in two columns
(if org-agenda-menu-two-columns
(progn
(setq n (length lines)
n1 (+ (/ n 2) (mod n 2))
right (nthcdr n1 lines)
left (copy-sequence lines))
(setcdr (nthcdr (1- n1) left) nil))
(setq left lines right nil))
(while left
(insert "\n" (pop left))
(when right
(if (< (current-column) 40)
(move-to-column 40 t)
(insert " "))
(insert (pop right))))
;; Make the window the right size
(goto-char (point-min))
(if second-time
(if (not (pos-visible-in-window-p (point-max)))
(org-fit-window-to-buffer))
(setq second-time t)
(org-fit-window-to-buffer))
;; Ask for selection
(message "Press key for agenda command%s:"
(if (or restrict-ok org-agenda-overriding-restriction)
(if org-agenda-overriding-restriction
" (restriction lock active)"
(if restriction
(format " (restricted to %s)" restriction)
" (unrestricted)"))
""))
(setq c (read-char-exclusive))
(message "")
(cond
((assoc (char-to-string c) custom)
(setq selstring (concat selstring (char-to-string c)))
(throw 'exit (cons selstring restriction)))
((memq c prefixes)
(setq selstring (concat selstring (char-to-string c))
prefixes nil
rmheader (or rmheader t)
custom (delq nil (mapcar
(lambda (x)
(if (or (= (length (car x)) 1)
(/= (string-to-char (car x)) c))
nil
(cons (substring (car x) 1) (cdr x))))
custom))))
((eq c ?*)
(call-interactively 'org-toggle-sticky-agenda)
(sit-for 2))
((and (not restrict-ok) (memq c '(?1 ?0 ?<)))
(message "Restriction is only possible in Org-mode buffers")
(ding) (sit-for 1))
((eq c ?1)
(org-agenda-remove-restriction-lock 'noupdate)
(setq restriction 'buffer))
((eq c ?0)
(org-agenda-remove-restriction-lock 'noupdate)
(setq restriction (if region-p 'region 'subtree)))
((eq c ?<)
(org-agenda-remove-restriction-lock 'noupdate)
(setq restriction
(cond
((eq restriction 'buffer)
(if region-p 'region 'subtree))
((memq restriction '(subtree region))
nil)
(t 'buffer))))
((eq c ?>)
(org-agenda-remove-restriction-lock 'noupdate)
(setq restriction nil))
((and (equal selstring "") (memq c '(?s ?S ?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/ ??)))
(throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
((and (> (length selstring) 0) (eq c ?\d))
(delete-window)
(org-agenda-get-restriction-and-command prefix-descriptions))
((equal c ?q) (error "Abort"))
(t (user-error "Invalid key %c" c))))))))
(defun org-agenda-fit-window-to-buffer ()
"Fit the window to the buffer size."
(and (memq org-agenda-window-setup '(reorganize-frame))
(fboundp 'fit-window-to-buffer)
(org-fit-window-to-buffer
nil
(floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
(floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
(defvar org-cmd nil)
(defvar org-agenda-overriding-cmd nil)
(defvar org-agenda-overriding-arguments nil)
(defvar org-agenda-overriding-cmd-arguments nil)
(defun org-agenda-run-series (name series)
"Run agenda NAME as a SERIES of agenda commands."
(org-let (nth 1 series) '(org-agenda-prepare name))
;; We need to reset agenda markers here, because when constructing a
;; block agenda, the individual blocks do not do that.
(org-agenda-reset-markers)
(let* ((org-agenda-multi t)
(redo (list 'org-agenda-run-series name (list 'quote series)))
(cmds (car series))
(gprops (nth 1 series))
match ;; The byte compiler incorrectly complains about this. Keep it!
org-cmd type lprops)
(while (setq org-cmd (pop cmds))
(setq type (car org-cmd)
match (eval (nth 1 org-cmd))
lprops (nth 2 org-cmd))
(let ((org-agenda-overriding-arguments
(if (eq org-agenda-overriding-cmd org-cmd)
(or org-agenda-overriding-arguments
org-agenda-overriding-cmd-arguments))))
(cond
((eq type 'agenda)
(org-let2 gprops lprops
'(call-interactively 'org-agenda-list)))
((eq type 'agenda*)
(org-let2 gprops lprops
'(funcall 'org-agenda-list nil nil t)))
((eq type 'alltodo)
(org-let2 gprops lprops
'(call-interactively 'org-todo-list)))
((eq type 'search)
(org-let2 gprops lprops
'(org-search-view current-prefix-arg match nil)))
((eq type 'stuck)
(org-let2 gprops lprops
'(call-interactively 'org-agenda-list-stuck-projects)))
((eq type 'tags)
(org-let2 gprops lprops
'(org-tags-view current-prefix-arg match)))
((eq type 'tags-todo)
(org-let2 gprops lprops
'(org-tags-view '(4) match)))
((eq type 'todo)
(org-let2 gprops lprops
'(org-todo-list match)))
((fboundp type)
(org-let2 gprops lprops
'(funcall type match)))
(t (error "Invalid type in command series")))))
(widen)
(let ((inhibit-read-only t))
(add-text-properties (point-min) (point-max)
`(org-series t org-series-redo-cmd ,redo)))
(setq org-agenda-redo-command redo)
(goto-char (point-min)))
(org-agenda-fit-window-to-buffer)
(org-let (nth 1 series) '(org-agenda-finalize)))
;;;###autoload
(defmacro org-batch-agenda (cmd-key &rest parameters)
"Run an agenda command in batch mode and send the result to STDOUT.
If CMD-KEY is a string of length 1, it is used as a key in
`org-agenda-custom-commands' and triggers this command. If it is a
longer string it is used as a tags/todo match string.
Parameters are alternating variable names and values that will be bound
before running the agenda command."
(org-eval-in-environment (org-make-parameter-alist parameters)
(let (org-agenda-sticky)
(if (> (length cmd-key) 2)
(org-tags-view nil cmd-key)
(org-agenda nil cmd-key))))
(set-buffer org-agenda-buffer-name)
(princ (buffer-string)))
(defvar org-agenda-info nil)
;;;###autoload
(defmacro org-batch-agenda-csv (cmd-key &rest parameters)
"Run an agenda command in batch mode and send the result to STDOUT.
If CMD-KEY is a string of length 1, it is used as a key in
`org-agenda-custom-commands' and triggers this command. If it is a
longer string it is used as a tags/todo match string.
Parameters are alternating variable names and values that will be bound
before running the agenda command.
The output gives a line for each selected agenda item. Each
item is a list of comma-separated values, like this:
category,head,type,todo,tags,date,time,extra,priority-l,priority-n
category The category of the item
head The headline, without TODO kwd, TAGS and PRIORITY
type The type of the agenda entry, can be
todo selected in TODO match
tagsmatch selected in tags match
diary imported from diary
deadline a deadline on given date
scheduled scheduled on given date
timestamp entry has timestamp on given date
closed entry was closed on given date
upcoming-deadline warning about deadline
past-scheduled forwarded scheduled item
block entry has date block including g. date
todo The todo keyword, if any
tags All tags including inherited ones, separated by colons
date The relevant date, like 2007-2-14
time The time, like 15:00-16:50
extra Sting with extra planning info
priority-l The priority letter if any was given
priority-n The computed numerical priority
agenda-day The day in the agenda where this is listed"
(org-eval-in-environment (append '((org-agenda-remove-tags t))
(org-make-parameter-alist parameters))
(if (> (length cmd-key) 2)
(org-tags-view nil cmd-key)
(org-agenda nil cmd-key)))
(set-buffer org-agenda-buffer-name)
(let* ((lines (org-split-string (buffer-string) "\n"))
line)
(while (setq line (pop lines))
(catch 'next
(if (not (get-text-property 0 'org-category line)) (throw 'next nil))
(setq org-agenda-info
(org-fix-agenda-info (text-properties-at 0 line)))
(princ
(mapconcat 'org-agenda-export-csv-mapper
'(org-category txt type todo tags date time extra
priority-letter priority agenda-day)
","))
(princ "\n")))))
(defun org-fix-agenda-info (props)
"Make sure all properties on an agenda item have a canonical form.
This ensures the export commands can easily use it."
(let (tmp re)
(when (setq tmp (plist-get props 'tags))
(setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
(when (setq tmp (plist-get props 'date))
(if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
(let ((calendar-date-display-form '(year "-" month "-" day)))
'((format "%4d, %9s %2s, %4s" dayname monthname day year))
(setq tmp (calendar-date-string tmp)))
(setq props (plist-put props 'date tmp)))
(when (setq tmp (plist-get props 'day))
(if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
(let ((calendar-date-display-form '(year "-" month "-" day)))
(setq tmp (calendar-date-string tmp)))
(setq props (plist-put props 'day tmp))
(setq props (plist-put props 'agenda-day tmp)))
(when (setq tmp (plist-get props 'txt))
(when (string-match "\\[#\\([A-Z0-9]\\)\\] ?" tmp)
(plist-put props 'priority-letter (match-string 1 tmp))
(setq tmp (replace-match "" t t tmp)))
(when (and (setq re (plist-get props 'org-todo-regexp))
(setq re (concat "\\`\\.*" re " ?"))
(string-match re tmp))
(plist-put props 'todo (match-string 1 tmp))
(setq tmp (replace-match "" t t tmp)))
(plist-put props 'txt tmp)))
props)
(defun org-agenda-export-csv-mapper (prop)
(let ((res (plist-get org-agenda-info prop)))
(setq res
(cond
((not res) "")
((stringp res) res)
(t (prin1-to-string res))))
(while (string-match "," res)
(setq res (replace-match ";" t t res)))
(org-trim res)))
;;;###autoload
(defun org-store-agenda-views (&rest parameters)
"Store agenda views."
(interactive)
(eval (list 'org-batch-store-agenda-views)))
;;;###autoload
(defmacro org-batch-store-agenda-views (&rest parameters)
"Run all custom agenda commands that have a file argument."
(let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
(pop-up-frames nil)
(dir default-directory)
(pars (org-make-parameter-alist parameters))
cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
(save-window-excursion
(while cmds
(setq cmd (pop cmds)
thiscmdkey (car cmd)
thiscmdcmd (cdr cmd)
match (nth 2 thiscmdcmd)
bufname (if org-agenda-sticky
(or (and (stringp match)
(format "*Org Agenda(%s:%s)*" thiscmdkey match))
(format "*Org Agenda(%s)*" thiscmdkey))
org-agenda-buffer-name)
cmd-or-set (nth 2 cmd)
opts (nth (if (listp cmd-or-set) 3 4) cmd)
files (nth (if (listp cmd-or-set) 4 5) cmd))
(if (stringp files) (setq files (list files)))
(when files
(org-eval-in-environment (append org-agenda-exporter-settings
opts pars)
(org-agenda nil thiscmdkey))
(set-buffer bufname)
(while files
(org-eval-in-environment (append org-agenda-exporter-settings
opts pars)
(org-agenda-write (expand-file-name (pop files) dir) nil t bufname)))
(and (get-buffer bufname)
(kill-buffer bufname)))))))
(defvar org-agenda-current-span nil
"The current span used in the agenda view.") ; local variable in the agenda buffer
(defun org-agenda-mark-header-line (pos)
"Mark the line at POS as an agenda structure header."
(save-excursion
(goto-char pos)
(put-text-property (point-at-bol) (point-at-eol)
'org-agenda-structural-header t)
(when org-agenda-title-append
(put-text-property (point-at-bol) (point-at-eol)
'org-agenda-title-append org-agenda-title-append))))
(defvar org-mobile-creating-agendas) ; defined in org-mobile.el
(defvar org-agenda-write-buffer-name "Agenda View")
(defun org-agenda-write (file &optional open nosettings agenda-bufname)
"Write the current buffer (an agenda view) as a file.
Depending on the extension of the file name, plain text (.txt),
HTML (.html or .htm), PDF (.pdf) or Postscript (.ps) is produced.
If the extension is .ics, run icalendar export over all files used
to construct the agenda and limit the export to entries listed in the
agenda now.
If the extension is .org, collect all subtrees corresponding to the
agenda entries and add them in an .org file.
With prefix argument OPEN, open the new file immediately.
If NOSETTINGS is given, do not scope the settings of
`org-agenda-exporter-settings' into the export commands. This is used when
the settings have already been scoped and we do not wish to overrule other,
higher priority settings.
If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(interactive "FWrite agenda to file: \nP")
(if (or (not (file-writable-p file))
(and (file-exists-p file)
(if (org-called-interactively-p 'any)
(not (y-or-n-p (format "Overwrite existing file %s? " file))))))
(user-error "Cannot write agenda to file %s" file))
(org-let (if nosettings nil org-agenda-exporter-settings)
'(save-excursion
(save-window-excursion
(let ((bs (copy-sequence (buffer-string))) beg content)
(with-temp-buffer
(rename-buffer org-agenda-write-buffer-name t)
(set-buffer-modified-p nil)
(insert bs)
(org-agenda-remove-marked-text 'org-filtered)
(run-hooks 'org-agenda-before-write-hook)
(cond
((org-bound-and-true-p org-mobile-creating-agendas)
(org-mobile-write-agenda-for-mobile file))
((string-match "\\.org\\'" file)
(let (content p m message-log-max)
(goto-char (point-min))
(while (setq p (next-single-property-change (point) 'org-hd-marker nil))
(goto-char p)
(setq m (get-text-property (point) 'org-hd-marker))
(when m
(push (save-excursion
(set-buffer (marker-buffer m))
(goto-char m)
(org-copy-subtree 1 nil t t)
org-subtree-clip)
content)))
(find-file file)
(erase-buffer)
(dolist (s content) (org-paste-subtree 1 s))
(write-file file)
(kill-buffer (current-buffer))
(message "Org file written to %s" file)))
((string-match "\\.html?\\'" file)
(require 'htmlize)
(set-buffer (htmlize-buffer (current-buffer)))
(when org-agenda-export-html-style
;; replace <style> section with org-agenda-export-html-style
(goto-char (point-min))
(kill-region (- (search-forward "<style") 6)
(search-forward "</style>"))
(insert org-agenda-export-html-style))
(write-file file)
(kill-buffer (current-buffer))
(message "HTML written to %s" file))
((string-match "\\.ps\\'" file)
(require 'ps-print)
(ps-print-buffer-with-faces file)
(message "Postscript written to %s" file))
((string-match "\\.pdf\\'" file)
(require 'ps-print)
(ps-print-buffer-with-faces
(concat (file-name-sans-extension file) ".ps"))
(call-process "ps2pdf" nil nil nil
(expand-file-name
(concat (file-name-sans-extension file) ".ps"))
(expand-file-name file))
(delete-file (concat (file-name-sans-extension file) ".ps"))
(message "PDF written to %s" file))
((string-match "\\.ics\\'" file)
(require 'ox-icalendar)
(org-icalendar-export-current-agenda (expand-file-name file)))
(t
(let ((bs (buffer-string)))
(find-file file)
(erase-buffer)
(insert bs)
(save-buffer 0)
(kill-buffer (current-buffer))
(message "Plain text written to %s" file))))))))
(set-buffer (or agenda-bufname
(and (org-called-interactively-p 'any) (buffer-name))
org-agenda-buffer-name)))
(when open (org-open-file file)))
(defun org-agenda-remove-marked-text (property &optional value)
"Delete all text marked with VALUE of PROPERTY.
VALUE defaults to t."
(let (beg)
(setq value (or value t))
(while (setq beg (text-property-any (point-min) (point-max)
property value))
(delete-region
beg (or (next-single-property-change beg property)
(point-max))))))
(defun org-agenda-add-entry-text ()
"Add entry text to agenda lines.
This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the
entry text following headings shown in the agenda.
Drawers will be excluded, also the line with scheduling/deadline info."
(when (and (> org-agenda-add-entry-text-maxlines 0)
(not (org-bound-and-true-p org-mobile-creating-agendas)))
(let (m txt)
(goto-char (point-min))
(while (not (eobp))
(if (not (setq m (org-get-at-bol 'org-hd-marker)))
(beginning-of-line 2)
(setq txt (org-agenda-get-some-entry-text
m org-agenda-add-entry-text-maxlines " > "))
(end-of-line 1)
(if (string-match "\\S-" txt)
(insert "\n" txt)
(or (eobp) (forward-char 1))))))))
(defun org-agenda-get-some-entry-text (marker n-lines &optional indent
&rest keep)
"Extract entry text from MARKER, at most N-LINES lines.
This will ignore drawers etc, just get the text.
If INDENT is given, prefix every line with this string. If KEEP is
given, it is a list of symbols, defining stuff that should not be
removed from the entry content. Currently only `planning' is allowed here."
(let (txt drawer-re kwd-time-re ind)
(save-excursion
(with-current-buffer (marker-buffer marker)
(if (not (derived-mode-p 'org-mode))
(setq txt "")
(save-excursion
(save-restriction
(widen)
(goto-char marker)
(end-of-line 1)
(setq txt (buffer-substring
(min (1+ (point)) (point-max))
(progn (outline-next-heading) (point)))
drawer-re org-drawer-regexp
kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
".*\n?"))
(with-temp-buffer
(insert txt)
(when org-agenda-add-entry-text-descriptive-links
(goto-char (point-min))
(while (org-activate-bracket-links (point-max))
(add-text-properties (match-beginning 0) (match-end 0)
'(face org-link))))
(goto-char (point-min))
(while (re-search-forward org-bracket-link-regexp (point-max) t)
(set-text-properties (match-beginning 0) (match-end 0)
nil))
(goto-char (point-min))
(while (re-search-forward drawer-re nil t)
(delete-region
(match-beginning 0)
(progn (re-search-forward
"^[ \t]*:END:.*\n?" nil 'move)
(point))))
(unless (member 'planning keep)
(goto-char (point-min))
(while (re-search-forward kwd-time-re nil t)
(replace-match "")))
(goto-char (point-min))
(when org-agenda-entry-text-exclude-regexps
(let ((re-list org-agenda-entry-text-exclude-regexps) re)
(while (setq re (pop re-list))
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match "")))))
(goto-char (point-max))
(skip-chars-backward " \t\n")
(if (looking-at "[ \t\n]+\\'") (replace-match ""))
;; find and remove min common indentation
(goto-char (point-min))
(untabify (point-min) (point-max))
(setq ind (org-get-indentation))
(while (not (eobp))
(unless (looking-at "[ \t]*$")
(setq ind (min ind (org-get-indentation))))
(beginning-of-line 2))
(goto-char (point-min))
(while (not (eobp))
(unless (looking-at "[ \t]*$")
(move-to-column ind)
(delete-region (point-at-bol) (point)))
(beginning-of-line 2))
(run-hooks 'org-agenda-entry-text-cleanup-hook)
(goto-char (point-min))
(when indent
(while (and (not (eobp)) (re-search-forward "^" nil t))
(replace-match indent t t)))
(goto-char (point-min))
(while (looking-at "[ \t]*\n") (replace-match ""))
(goto-char (point-max))
(when (> (org-current-line)
n-lines)
(org-goto-line (1+ n-lines))
(backward-char 1))
(setq txt (buffer-substring (point-min) (point)))))))))
txt))
(defun org-check-for-org-mode ()
"Make sure current buffer is in org-mode. Error if not."
(or (derived-mode-p 'org-mode)
(error "Cannot execute org-mode agenda command on buffer in %s"
major-mode)))
;;; Agenda prepare and finalize
(defvar org-agenda-multi nil) ; dynamically scoped
(defvar org-agenda-pre-window-conf nil)
(defvar org-agenda-columns-active nil)
(defvar org-agenda-name nil)
(defvar org-agenda-tag-filter nil)
(defvar org-agenda-category-filter nil)
(defvar org-agenda-regexp-filter nil)
(defvar org-agenda-top-headline-filter nil)
(defvar org-agenda-tag-filter-preset nil
"A preset of the tags filter used for secondary agenda filtering.
This must be a list of strings, each string must be a single tag preceded
by \"+\" or \"-\".
This variable should not be set directly, but agenda custom commands can
bind it in the options section. The preset filter is a global property of
the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.")
(defvar org-agenda-category-filter-preset nil
"A preset of the category filter used for secondary agenda filtering.
This must be a list of strings, each string must be a single category
preceded by \"+\" or \"-\".
This variable should not be set directly, but agenda custom commands can
bind it in the options section. The preset filter is a global property of
the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.")
(defvar org-agenda-regexp-filter-preset nil
"A preset of the regexp filter used for secondary agenda filtering.
This must be a list of strings, each string must be a single regexp
preceded by \"+\" or \"-\".
This variable should not be set directly, but agenda custom commands can
bind it in the options section. The preset filter is a global property of
the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.")
(defun org-agenda-use-sticky-p ()
"Return non-nil if an agenda buffer named
`org-agenda-buffer-name' exists and should be shown instead of
generating a new one."
(and
;; turned off by user
org-agenda-sticky
;; For multi-agenda buffer already exists
(not org-agenda-multi)
;; buffer found
(get-buffer org-agenda-buffer-name)
;; C-u parameter is same as last call
(with-current-buffer (get-buffer org-agenda-buffer-name)
(and
(equal current-prefix-arg
org-agenda-last-prefix-arg)
;; In case user turned stickiness on, while having existing
;; Agenda buffer active, don't reuse that buffer, because it
;; does not have org variables local
org-agenda-this-buffer-is-sticky))))
(defun org-agenda-prepare-window (abuf filter-alist)
"Setup agenda buffer in the window.
ABUF is the buffer for the agenda window.
FILTER-ALIST is an alist of filters we need to apply when
`org-agenda-persistent-filter' is non-nil."
(let* ((awin (get-buffer-window abuf)) wconf)
(cond
((equal (current-buffer) abuf) nil)
(awin (select-window awin))
((not (setq wconf (current-window-configuration))))
((equal org-agenda-window-setup 'current-window)
(org-pop-to-buffer-same-window abuf))
((equal org-agenda-window-setup 'other-window)
(org-switch-to-buffer-other-window abuf))
((equal org-agenda-window-setup 'other-frame)
(switch-to-buffer-other-frame abuf))
((equal org-agenda-window-setup 'reorganize-frame)
(delete-other-windows)
(org-switch-to-buffer-other-window abuf)))
(setq org-agenda-tag-filter (cdr (assoc 'tag filter-alist)))
(setq org-agenda-category-filter (cdr (assoc 'cat filter-alist)))
(setq org-agenda-regexp-filter (cdr (assoc 're filter-alist)))
;; Additional test in case agenda is invoked from within agenda
;; buffer via elisp link.
(unless (equal (current-buffer) abuf)
(org-pop-to-buffer-same-window abuf))
(setq org-agenda-pre-window-conf
(or org-agenda-pre-window-conf wconf))))
(defun org-agenda-prepare (&optional name)
(let ((filter-alist (if org-agenda-persistent-filter
(list `(tag . ,org-agenda-tag-filter)
`(re . ,org-agenda-regexp-filter)
`(car . ,org-agenda-category-filter)))))
(if (org-agenda-use-sticky-p)
(progn
(put 'org-agenda-tag-filter :preset-filter nil)
(put 'org-agenda-category-filter :preset-filter nil)
(put 'org-agenda-regexp-filter :preset-filter nil)
;; Popup existing buffer
(org-agenda-prepare-window (get-buffer org-agenda-buffer-name)
filter-alist)
(message "Sticky Agenda buffer, use `r' to refresh")
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(throw 'exit "Sticky Agenda buffer, use `r' to refresh"))
(setq org-todo-keywords-for-agenda nil)
(setq org-drawers-for-agenda nil)
(put 'org-agenda-tag-filter :preset-filter
org-agenda-tag-filter-preset)
(put 'org-agenda-category-filter :preset-filter
org-agenda-category-filter-preset)
(put 'org-agenda-regexp-filter :preset-filter
org-agenda-regexp-filter-preset)
(if org-agenda-multi
(progn
(setq buffer-read-only nil)
(goto-char (point-max))
(unless (or (bobp) org-agenda-compact-blocks
(not org-agenda-block-separator))
(insert "\n"
(if (stringp org-agenda-block-separator)
org-agenda-block-separator
(make-string (window-width) org-agenda-block-separator))
"\n"))
(narrow-to-region (point) (point-max)))
(setq org-done-keywords-for-agenda nil)
;; Setting any org variables that are in org-agenda-local-vars
;; list need to be done after the prepare call
(org-agenda-prepare-window
(get-buffer-create org-agenda-buffer-name) filter-alist)
(setq buffer-read-only nil)
(org-agenda-reset-markers)
(let ((inhibit-read-only t)) (erase-buffer))
(org-agenda-mode)
(setq org-agenda-buffer (current-buffer))
(setq org-agenda-contributing-files nil)
(setq org-agenda-columns-active nil)
(org-agenda-prepare-buffers (org-agenda-files nil 'ifmode))
(setq org-todo-keywords-for-agenda
(org-uniquify org-todo-keywords-for-agenda))
(setq org-done-keywords-for-agenda
(org-uniquify org-done-keywords-for-agenda))
(setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
(setq org-agenda-last-prefix-arg current-prefix-arg)
(setq org-agenda-this-buffer-name org-agenda-buffer-name)
(and name (not org-agenda-name)
(org-set-local 'org-agenda-name name)))
(setq buffer-read-only nil))))
(defvar org-agenda-overriding-columns-format) ; From org-colview.el
(defun org-agenda-finalize ()
"Finishing touch for the agenda buffer, called just before displaying it."
(unless org-agenda-multi
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(save-excursion
(while (org-activate-bracket-links (point-max))
(add-text-properties (match-beginning 0) (match-end 0)
'(face org-link))))
(save-excursion
(while (org-activate-plain-links (point-max))
(add-text-properties (match-beginning 0) (match-end 0)
'(face org-link))))
(unless (eq org-agenda-remove-tags t)
(org-agenda-align-tags))
(unless org-agenda-with-colors
(remove-text-properties (point-min) (point-max) '(face nil)))
(if (and (boundp 'org-agenda-overriding-columns-format)
org-agenda-overriding-columns-format)
(org-set-local 'org-agenda-overriding-columns-format
org-agenda-overriding-columns-format))
(if (and (boundp 'org-agenda-view-columns-initially)
org-agenda-view-columns-initially)
(org-agenda-columns))
(when org-agenda-fontify-priorities
(org-agenda-fontify-priorities))
(when (and org-agenda-dim-blocked-tasks org-blocker-hook)
(org-agenda-dim-blocked-tasks))
(org-agenda-mark-clocking-task)
(when org-agenda-entry-text-mode
(org-agenda-entry-text-hide)
(org-agenda-entry-text-show))
(if (and (functionp 'org-habit-insert-consistency-graphs)
(save-excursion (next-single-property-change (point-min) 'org-habit-p)))
(org-habit-insert-consistency-graphs))
(setq org-agenda-type (org-get-at-bol 'org-agenda-type))
(unless (or (eq org-agenda-show-inherited-tags 'always)
(and (listp org-agenda-show-inherited-tags)
(memq org-agenda-type org-agenda-show-inherited-tags))
(and (eq org-agenda-show-inherited-tags t)
(or (eq org-agenda-use-tag-inheritance t)
(and (listp org-agenda-use-tag-inheritance)
(not (memq org-agenda-type
org-agenda-use-tag-inheritance))))))
(let (mrk)
(save-excursion
(goto-char (point-min))
(while (equal (forward-line) 0)
(when (setq mrk (get-text-property (point) 'org-hd-marker))
(put-text-property (point-at-bol) (point-at-eol)
'tags (org-with-point-at mrk
(delete-dups
(mapcar 'downcase (org-get-tags-at))))))))))
(run-hooks 'org-agenda-finalize-hook)
(when org-agenda-top-headline-filter
(org-agenda-filter-top-headline-apply
org-agenda-top-headline-filter))
(when org-agenda-tag-filter
(org-agenda-filter-apply org-agenda-tag-filter 'tag))
(when (get 'org-agenda-tag-filter :preset-filter)
(org-agenda-filter-apply
(get 'org-agenda-tag-filter :preset-filter) 'tag))
(when org-agenda-category-filter
(org-agenda-filter-apply org-agenda-category-filter 'category))
(when (get 'org-agenda-category-filter :preset-filter)
(org-agenda-filter-apply
(get 'org-agenda-category-filter :preset-filter) 'category))
(when org-agenda-regexp-filter
(org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
(when (get 'org-agenda-regexp-filter :preset-filter)
(org-agenda-filter-apply
(get 'org-agenda-regexp-filter :preset-filter) 'regexp))
(org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)))))
(defun org-agenda-mark-clocking-task ()
"Mark the current clock entry in the agenda if it is present."
;; We need to widen when `org-agenda-finalize' is called from
;; `org-agenda-change-all-lines' (e.g. in `org-agenda-clock-in')
(when org-clock-current-task
(save-restriction
(widen)
(org-agenda-unmark-clocking-task)
(when (marker-buffer org-clock-hd-marker)
(save-excursion
(goto-char (point-min))
(let (s ov)
(while (setq s (next-single-property-change (point) 'org-hd-marker))
(goto-char s)
(when (equal (org-get-at-bol 'org-hd-marker)
org-clock-hd-marker)
(setq ov (make-overlay (point-at-bol) (1+ (point-at-eol))))
(overlay-put ov 'type 'org-agenda-clocking)
(overlay-put ov 'face 'org-agenda-clocking)
(overlay-put ov 'help-echo
"The clock is running in this item")))))))))
(defun org-agenda-unmark-clocking-task ()
"Unmark the current clocking task.