1 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 ;; This file contains the code for creating and using the Agenda for Org-mode.
37 (declare-function diary-add-to-list "diary-lib"
38 (date string specifier &optional marker globcolor literal))
39 (declare-function calendar-absolute-from-iso "cal-iso" (date))
40 (declare-function calendar-astro-date-string "cal-julian" (&optional date))
41 (declare-function calendar-bahai-date-string "cal-bahai" (&optional date))
42 (declare-function calendar-chinese-date-string "cal-china" (&optional date))
43 (declare-function calendar-coptic-date-string "cal-coptic" (&optional date))
44 (declare-function calendar-ethiopic-date-string "cal-coptic" (&optional date))
45 (declare-function calendar-french-date-string "cal-french" (&optional date))
46 (declare-function calendar-goto-date "cal-move" (date))
47 (declare-function calendar-hebrew-date-string "cal-hebrew" (&optional date))
48 (declare-function calendar-islamic-date-string "cal-islam" (&optional date))
49 (declare-function calendar-iso-date-string "cal-iso" (&optional date))
50 (declare-function calendar-iso-from-absolute "cal-iso" (date))
51 (declare-function calendar-julian-date-string "cal-julian" (&optional date))
52 (declare-function calendar-mayan-date-string "cal-mayan" (&optional date))
53 (declare-function calendar-persian-date-string "cal-persia" (&optional date))
54 (declare-function org-datetree-find-date-create "org-datetree"
55 (date &optional keep-restriction))
56 (declare-function org-columns-quit "org-colview" ())
57 (declare-function diary-date-display-form "diary-lib" (&optional type))
58 (declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file))
59 (declare-function org-habit-insert-consistency-graphs
60 "org-habit" (&optional line))
61 (declare-function org-is-habit-p "org-habit" (&optional pom))
62 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
63 (declare-function org-habit-get-priority "org-habit" (habit &optional moment))
64 (defvar calendar-mode-map)
65 (defvar org-clock-current-task) ; defined in org-clock.el
66 (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
67 (defvar org-habit-show-habits)
68 (defvar org-habit-show-habits-only-for-today)
70 ;; Defined somewhere in this file, but used before definition.
71 (defvar org-agenda-buffer-name)
72 (defvar org-agenda-overriding-header)
73 (defvar org-agenda-title-append nil)
76 (defvar org-agenda-undo-list)
77 (defvar org-agenda-pending-undo-list)
78 (defvar original-date) ; dynamically scoped, calendar.el does scope this
80 (defcustom org-agenda-confirm-kill 1
81 "When set, remote killing from the agenda buffer needs confirmation.
82 When t, a confirmation is always needed. When a number N, confirmation is
83 only needed when the text to be killed contains more than N non-white lines."
86 (const :tag "Never" nil)
87 (const :tag "Always" t)
88 (integer :tag "When more than N lines")))
90 (defcustom org-agenda-compact-blocks nil
91 "Non-nil means make the block agenda more compact.
92 This is done globally by leaving out lines like the agenda span
93 name and week number or the separator lines."
97 (defcustom org-agenda-block-separator ?=
98 "The separator between blocks in the agenda.
99 If this is a string, it will be used as the separator, with a newline added.
100 If it is a character, it will be repeated to fill the window width.
101 If nil the separator is disabled. In `org-agenda-custom-commands' this
102 addresses the separator between the current and the previous block."
105 (const :tag "Disabled" nil)
109 (defgroup org-agenda-export nil
110 "Options concerning exporting agenda views in Org-mode."
111 :tag "Org Agenda Export"
114 (defcustom org-agenda-with-colors t
115 "Non-nil means use colors in agenda views."
116 :group 'org-agenda-export
119 (defcustom org-agenda-exporter-settings nil
120 "Alist of variable/value pairs that should be active during agenda export.
121 This is a good place to set options for ps-print and for htmlize.
122 Note that the way this is implemented, the values will be evaluated
123 before assigned to the variables. So make sure to quote values you do
124 *not* want evaluated, for example
126 (setq org-agenda-exporter-settings
127 '((ps-print-color-p 'black-white)))"
128 :group 'org-agenda-export
132 (sexp :tag "Value"))))
134 (defcustom org-agenda-before-write-hook '(org-agenda-add-entry-text)
135 "Hook run in temporary buffer before writing it to an export file.
136 A useful function is `org-agenda-add-entry-text'."
137 :group 'org-agenda-export
139 :options '(org-agenda-add-entry-text))
141 (defcustom org-agenda-add-entry-text-maxlines 0
142 "Maximum number of entry text lines to be added to agenda.
143 This is only relevant when `org-agenda-add-entry-text' is part of
144 `org-agenda-before-write-hook', which it is by default.
145 When this is 0, nothing will happen. When it is greater than 0, it
146 specifies the maximum number of lines that will be added for each entry
147 that is listed in the agenda view.
149 Note that this variable is not used during display, only when exporting
150 the agenda. For agenda display, see the variables `org-agenda-entry-text-mode'
151 and `org-agenda-entry-text-maxlines'."
155 (defcustom org-agenda-add-entry-text-descriptive-links t
156 "Non-nil means export org-links as descriptive links in agenda added text.
157 This variable applies to the text added to the agenda when
158 `org-agenda-add-entry-text-maxlines' is larger than 0.
159 When this variable nil, the URL will (also) be shown."
163 (defcustom org-agenda-export-html-style ""
164 "The style specification for exported HTML Agenda files.
165 If this variable contains a string, it will replace the default <style>
166 section as produced by `htmlize'.
167 Since there are different ways of setting style information, this variable
168 needs to contain the full HTML structure to provide a style, including the
169 surrounding HTML tags. The style specifications should include definitions
170 the fonts used by the agenda, here is an example:
172 <style type=\"text/css\">
173 p { font-weight: normal; color: gray; }
174 .org-agenda-structure {
189 .title { text-align: center; }
190 .todo, .deadline { color: red; }
191 .done { color: green; }
194 or, if you want to keep the style in a file,
196 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
198 As the value of this option simply gets inserted into the HTML <head> header,
199 you can \"misuse\" it to also add other text to the header. However,
200 <style>...</style> is required, if not present the variable will be ignored."
201 :group 'org-agenda-export
202 :group 'org-export-html
205 (defcustom org-agenda-persistent-filter nil
206 "When set, keep filters from one agenda view to the next."
210 (defgroup org-agenda-custom-commands nil
211 "Options concerning agenda views in Org-mode."
212 :tag "Org Agenda Custom Commands"
215 (defconst org-sorting-choice
217 (const time-up) (const time-down)
218 (const category-keep) (const category-up) (const category-down)
219 (const tag-down) (const tag-up)
220 (const priority-up) (const priority-down)
221 (const todo-state-up) (const todo-state-down)
222 (const effort-up) (const effort-down)
223 (const habit-up) (const habit-down)
224 (const alpha-up) (const alpha-down)
225 (const user-defined-up) (const user-defined-down))
228 (defconst org-agenda-custom-commands-local-options
229 `(repeat :tag "Local settings for this command. Remember to quote values"
230 (choice :tag "Setting"
231 (list :tag "Heading for this block"
232 (const org-agenda-overriding-header)
233 (string :tag "Headline"))
234 (list :tag "Files to be searched"
235 (const org-agenda-files)
237 (const :format "" quote)
239 (list :tag "Sorting strategy"
240 (const org-agenda-sorting-strategy)
242 (const :format "" quote)
244 ,org-sorting-choice)))
245 (list :tag "Prefix format"
246 (const org-agenda-prefix-format :value " %-12:c%?-12t% s")
248 (list :tag "Number of days in agenda"
249 (const org-agenda-span)
250 (choice (const :tag "Day" 'day)
251 (const :tag "Week" 'week)
252 (const :tag "Month" 'month)
253 (const :tag "Year" 'year)
254 (integer :tag "Custom")))
255 (list :tag "Fixed starting date"
256 (const org-agenda-start-day)
257 (string :value "2007-11-01"))
258 (list :tag "Start on day of week"
259 (const org-agenda-start-on-weekday)
261 (const :tag "Today" nil)
262 (integer :tag "Weekday No.")))
263 (list :tag "Include data from diary"
264 (const org-agenda-include-diary)
266 (list :tag "Deadline Warning days"
267 (const org-deadline-warning-days)
269 (list :tag "Tags filter preset"
270 (const org-agenda-filter-preset)
272 (const :format "" quote)
274 (string :tag "+tag or -tag"))))
275 (list :tag "Set daily/weekly entry types"
276 (const org-agenda-entry-types)
277 (set :greedy t :value (:deadline :scheduled :timestamp :sexp)
282 (list :tag "Standard skipping condition"
283 :value (org-agenda-skip-function '(org-agenda-skip-entry-if))
284 (const org-agenda-skip-function)
286 (const :format "" quote)
289 :tag "Skipping range"
290 (const :tag "Skip entry" org-agenda-skip-entry-if)
291 (const :tag "Skip subtree" org-agenda-skip-subtree-if))
292 (repeat :inline t :tag "Conditions for skipping"
294 :tag "Condition type"
295 (list :tag "Regexp matches" :inline t (const :format "" 'regexp) (regexp))
296 (list :tag "Regexp does not match" :inline t (const :format "" 'notregexp) (regexp))
297 (list :tag "TODO state is" :inline t
300 (const :tag "any not-done state" 'todo)
301 (const :tag "any done state" 'done)
302 (const :tag "any state" 'any)
303 (list :tag "Keyword list"
304 (const :format "" quote)
305 (repeat (string :tag "Keyword")))))
306 (list :tag "TODO state is not" :inline t
309 (const :tag "any not-done state" 'todo)
310 (const :tag "any done state" 'done)
311 (const :tag "any state" 'any)
312 (list :tag "Keyword list"
313 (const :format "" quote)
314 (repeat (string :tag "Keyword")))))
315 (const :tag "scheduled" 'scheduled)
316 (const :tag "not scheduled" 'notscheduled)
317 (const :tag "deadline" 'deadline)
318 (const :tag "no deadline" 'notdeadline)
319 (const :tag "timestamp" 'timestamp)
320 (const :tag "no timestamp" 'nottimestamp))))))
321 (list :tag "Non-standard skipping condition"
322 :value (org-agenda-skip-function)
323 (const org-agenda-skip-function)
324 (sexp :tag "Function or form (quoted!)"))
325 (list :tag "Any variable"
326 (variable :tag "Variable")
327 (sexp :tag "Value (sexp)"))))
328 "Selection of examples for agenda command settings.
329 This will be spliced into the custom type of
330 `org-agenda-custom-commands'.")
333 (defcustom org-agenda-custom-commands nil
334 "Custom commands for the agenda.
335 These commands will be offered on the splash screen displayed by the
336 agenda dispatcher \\[org-agenda]. Each entry is a list like this:
338 (key desc type match settings files)
340 key The key (one or more characters as a string) to be associated
342 desc A description of the command, when omitted or nil, a default
343 description is built using MATCH.
344 type The command type, any of the following symbols:
345 agenda The daily/weekly agenda.
346 todo Entries with a specific TODO keyword, in all agenda files.
347 search Entries containing search words entry or headline.
348 tags Tags/Property/TODO match in all agenda files.
349 tags-todo Tags/P/T match in all agenda files, TODO entries only.
350 todo-tree Sparse tree of specific TODO keyword in *current* file.
351 tags-tree Sparse tree with all tags matches in *current* file.
352 occur-tree Occur sparse tree for *current* file.
353 ... A user-defined function.
354 match What to search for:
355 - a single keyword for TODO keyword searches
356 - a tags match expression for tags searches
357 - a word search expression for text searches.
358 - a regular expression for occur searches
359 For all other commands, this should be the empty string.
360 settings A list of option settings, similar to that in a let form, so like
361 this: ((opt1 val1) (opt2 val2) ...). The values will be
362 evaluated at the moment of execution, so quote them when needed.
363 files A list of files file to write the produced agenda buffer to
364 with the command `org-store-agenda-views'.
365 If a file name ends in \".html\", an HTML version of the buffer
366 is written out. If it ends in \".ps\", a postscript version is
367 produced. Otherwise, only the plain text is written to the file.
369 You can also define a set of commands, to create a composite agenda buffer.
370 In this case, an entry looks like this:
372 (key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
376 desc A description string to be displayed in the dispatcher menu.
377 cmd An agenda command, similar to the above. However, tree commands
378 are no allowed, but instead you can get agenda and global todo list.
379 So valid commands for a set are:
380 (agenda \"\" settings)
381 (alltodo \"\" settings)
382 (stuck \"\" settings)
383 (todo \"match\" settings files)
384 (search \"match\" settings files)
385 (tags \"match\" settings files)
386 (tags-todo \"match\" settings files)
388 Each command can carry a list of options, and another set of options can be
389 given for the whole set of commands. Individual command options take
390 precedence over the general options.
392 When using several characters as key to a command, the first characters
393 are prefix commands. For the dispatcher to display useful information, you
394 should provide a description for the prefix, like
396 (setq org-agenda-custom-commands
397 '((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\"
398 (\"hl\" tags \"+HOME+Lisa\")
399 (\"hp\" tags \"+HOME+Peter\")
400 (\"hk\" tags \"+HOME+Kim\")))"
401 :group 'org-agenda-custom-commands
403 (choice :value ("x" "Describe command here" tags "" nil)
404 (list :tag "Single command"
405 (string :tag "Access Key(s) ")
406 (option (string :tag "Description"))
408 (const :tag "Agenda" agenda)
409 (const :tag "TODO list" alltodo)
410 (const :tag "Search words" search)
411 (const :tag "Stuck projects" stuck)
412 (const :tag "Tags/Property match (all agenda files)" tags)
413 (const :tag "Tags/Property match of TODO entries (all agenda files)" tags-todo)
414 (const :tag "TODO keyword search (all agenda files)" todo)
415 (const :tag "Tags sparse tree (current buffer)" tags-tree)
416 (const :tag "TODO keyword tree (current buffer)" todo-tree)
417 (const :tag "Occur tree (current buffer)" occur-tree)
418 (sexp :tag "Other, user-defined function"))
419 (string :tag "Match (only for some commands)")
420 ,org-agenda-custom-commands-local-options
421 (option (repeat :tag "Export" (file :tag "Export to"))))
422 (list :tag "Command series, all agenda files"
423 (string :tag "Access Key(s)")
424 (string :tag "Description ")
425 (repeat :tag "Component"
428 (const :format "" agenda)
429 (const :tag "" :format "" "")
430 ,org-agenda-custom-commands-local-options)
431 (list :tag "TODO list (all keywords)"
432 (const :format "" alltodo)
433 (const :tag "" :format "" "")
434 ,org-agenda-custom-commands-local-options)
435 (list :tag "Search words"
436 (const :format "" search)
437 (string :tag "Match")
438 ,org-agenda-custom-commands-local-options)
439 (list :tag "Stuck projects"
440 (const :format "" stuck)
441 (const :tag "" :format "" "")
442 ,org-agenda-custom-commands-local-options)
443 (list :tag "Tags search"
444 (const :format "" tags)
445 (string :tag "Match")
446 ,org-agenda-custom-commands-local-options)
447 (list :tag "Tags search, TODO entries only"
448 (const :format "" tags-todo)
449 (string :tag "Match")
450 ,org-agenda-custom-commands-local-options)
451 (list :tag "TODO keyword search"
452 (const :format "" todo)
453 (string :tag "Match")
454 ,org-agenda-custom-commands-local-options)
455 (list :tag "Other, user-defined function"
456 (symbol :tag "function")
457 (string :tag "Match")
458 ,org-agenda-custom-commands-local-options)))
460 (repeat :tag "Settings for entire command set"
461 (list (variable :tag "Any variable")
462 (sexp :tag "Value")))
463 (option (repeat :tag "Export" (file :tag "Export to"))))
464 (cons :tag "Prefix key documentation"
465 (string :tag "Access Key(s)")
466 (string :tag "Description ")))))
468 (defcustom org-agenda-query-register ?o
469 "The register holding the current query string.
470 The purpose of this is that if you construct a query string interactively,
471 you can then use it to define a custom command."
472 :group 'org-agenda-custom-commands
475 (defcustom org-stuck-projects
476 '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "")
477 "How to identify stuck projects.
478 This is a list of four items:
479 1. A tags/todo/property matcher string that is used to identify a project.
480 See the manual for a description of tag and property searches.
481 The entire tree below a headline matched by this is considered one project.
482 2. A list of TODO keywords identifying non-stuck projects.
483 If the project subtree contains any headline with one of these todo
484 keywords, the project is considered to be not stuck. If you specify
485 \"*\" as a keyword, any TODO keyword will mark the project unstuck.
486 3. A list of tags identifying non-stuck projects.
487 If the project subtree contains any headline with one of these tags,
488 the project is considered to be not stuck. If you specify \"*\" as
489 a tag, any tag will mark the project unstuck. Note that this is about
490 the explicit presence of a tag somewhere in the subtree, inherited
491 tags to not count here. If inherited tags make a project not stuck,
492 use \"-TAG\" in the tags part of the matcher under (1.) above.
493 4. An arbitrary regular expression matching non-stuck projects.
495 If the project turns out to be not stuck, search continues also in the
496 subtree to see if any of the subtasks have project status.
498 See also the variable `org-tags-match-list-sublevels' which applies
499 to projects matched by this search as well.
501 After defining this variable, you may use \\[org-agenda-list-stuck-projects]
502 or `C-c a #' to produce the list."
503 :group 'org-agenda-custom-commands
505 (string :tag "Tags/TODO match to identify a project")
506 (repeat :tag "Projects are *not* stuck if they have an entry with TODO keyword any of" (string))
507 (repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string))
508 (regexp :tag "Projects are *not* stuck if this regexp matches inside the subtree")))
510 (defcustom org-agenda-filter-effort-default-operator "<"
511 "The default operator for effort estimate filtering.
512 If you select an effort estimate limit without first pressing an operator,
513 this one will be used."
514 :group 'org-agenda-custom-commands
515 :type '(choice (const :tag "less or equal" "<")
516 (const :tag "greater or equal"">")
517 (const :tag "equal" "=")))
519 (defgroup org-agenda-skip nil
520 "Options concerning skipping parts of agenda files."
521 :tag "Org Agenda Skip"
524 (defcustom org-agenda-skip-function-global nil
525 "Function to be called at each match during agenda construction.
526 If this function returns nil, the current match should not be skipped.
527 If the function decided to skip an agenda match, is must return the
528 buffer position from which the search should be continued.
529 This may also be a Lisp form, which will be evaluated.
531 This variable will be applied to every agenda match, including
532 tags/property searches and TODO lists. So try to make the test function
533 do its checking as efficiently as possible. To implement a skipping
534 condition just for specific agenda commands, use the variable
535 `org-agenda-skip-function' which can be set in the options section
536 of custom agenda commands."
537 :group 'org-agenda-skip
540 (defgroup org-agenda-daily/weekly nil
541 "Options concerning the daily/weekly agenda."
542 :tag "Org Agenda Daily/Weekly"
544 (defgroup org-agenda-todo-list nil
545 "Options concerning the global todo list agenda view."
546 :tag "Org Agenda Todo List"
548 (defgroup org-agenda-match-view nil
549 "Options concerning the general tags/property/todo match agenda view."
550 :tag "Org Agenda Match View"
552 (defgroup org-agenda-search-view nil
553 "Options concerning the general tags/property/todo match agenda view."
554 :tag "Org Agenda Match View"
557 (defvar org-agenda-archives-mode nil
558 "Non-nil means the agenda will include archived items.
559 If this is the symbol `trees', trees in the selected agenda scope
560 that are marked with the ARCHIVE tag will be included anyway. When this is
561 t, also all archive files associated with the current selection of agenda
562 files will be included.")
564 (defcustom org-agenda-skip-comment-trees t
565 "Non-nil means skip trees that start with the COMMENT keyword.
566 When nil, these trees are also scanned by agenda commands."
567 :group 'org-agenda-skip
570 (defcustom org-agenda-todo-list-sublevels t
571 "Non-nil means check also the sublevels of a TODO entry for TODO entries.
572 When nil, the sublevels of a TODO entry are not checked, resulting in
573 potentially much shorter TODO lists."
574 :group 'org-agenda-skip
575 :group 'org-agenda-todo-list
578 (defcustom org-agenda-todo-ignore-with-date nil
579 "Non-nil means don't show entries with a date in the global todo list.
580 You can use this if you prefer to mark mere appointments with a TODO keyword,
581 but don't want them to show up in the TODO list.
582 When this is set, it also covers deadlines and scheduled items, the settings
583 of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
585 See also the variable `org-agenda-tags-todo-honor-ignore-options'."
586 :group 'org-agenda-skip
587 :group 'org-agenda-todo-list
590 (defcustom org-agenda-todo-ignore-timestamp nil
591 "Non-nil means don't show entries with a timestamp.
592 This applies when creating the global todo list.
595 past Don't show entries for today or in the past.
597 future Don't show entries with a timestamp in the future.
598 The idea behind this is that if it has a future
599 timestamp, you don't want to think about it until the
602 all Don't show any entries with a timestamp in the global todo list.
603 The idea behind this is that by setting a timestamp, you
604 have already \"taken care\" of this item.
606 This variable can also have an integer as a value. If positive (N),
607 todos with a timestamp N or more days in the future will be ignored. If
608 negative (-N), todos with a timestamp N or more days in the past will be
609 ignored. If 0, todos with a timestamp either today or in the future will
610 be ignored. For example, a value of -1 will exclude todos with a
611 timestamp in the past (yesterday or earlier), while a value of 7 will
612 exclude todos with a timestamp a week or more in the future.
614 See also `org-agenda-todo-ignore-with-date'.
615 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
616 to make his option also apply to the tags-todo list."
617 :group 'org-agenda-skip
618 :group 'org-agenda-todo-list
620 (const :tag "Ignore future timestamp todos" future)
621 (const :tag "Ignore past or present timestamp todos" past)
622 (const :tag "Ignore all timestamp todos" all)
623 (const :tag "Show timestamp todos" nil)
624 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
626 (defcustom org-agenda-todo-ignore-scheduled nil
627 "Non-nil means, ignore some scheduled TODO items when making TODO list.
628 This applies when creating the global todo list.
631 past Don't show entries scheduled today or in the past.
633 future Don't show entries scheduled in the future.
634 The idea behind this is that by scheduling it, you don't want to
635 think about it until the scheduled date.
637 all Don't show any scheduled entries in the global todo list.
638 The idea behind this is that by scheduling it, you have already
639 \"taken care\" of this item.
641 t Same as `all', for backward compatibility.
643 This variable can also have an integer as a value. See
644 `org-agenda-todo-ignore-timestamp' for more details.
646 See also `org-agenda-todo-ignore-with-date'.
647 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
648 to make his option also apply to the tags-todo list."
649 :group 'org-agenda-skip
650 :group 'org-agenda-todo-list
652 (const :tag "Ignore future-scheduled todos" future)
653 (const :tag "Ignore past- or present-scheduled todos" past)
654 (const :tag "Ignore all scheduled todos" all)
655 (const :tag "Ignore all scheduled todos (compatibility)" t)
656 (const :tag "Show scheduled todos" nil)
657 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
659 (defcustom org-agenda-todo-ignore-deadlines nil
660 "Non-nil means ignore some deadlined TODO items when making TODO list.
661 There are different motivations for using different values, please think
662 carefully when configuring this variable.
664 This applies when creating the global todo list.
667 near Don't show near deadline entries. A deadline is near when it is
668 closer than `org-deadline-warning-days' days. The idea behind this
669 is that such items will appear in the agenda anyway.
671 far Don't show TODO entries where a deadline has been defined, but
672 the deadline is not near. This is useful if you don't want to
673 use the todo list to figure out what to do now.
675 past Don't show entries with a deadline timestamp for today or in the past.
677 future Don't show entries with a deadline timestamp in the future, not even
678 when they become `near' ones. Use it with caution.
680 all Ignore all TODO entries that do have a deadline.
682 t Same as `near', for backward compatibility.
684 This variable can also have an integer as a value. See
685 `org-agenda-todo-ignore-timestamp' for more details.
687 See also `org-agenda-todo-ignore-with-date'.
688 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
689 to make his option also apply to the tags-todo list."
690 :group 'org-agenda-skip
691 :group 'org-agenda-todo-list
693 (const :tag "Ignore near deadlines" near)
694 (const :tag "Ignore near deadlines (compatibility)" t)
695 (const :tag "Ignore far deadlines" far)
696 (const :tag "Ignore all TODOs with a deadlines" all)
697 (const :tag "Show all TODOs, even if they have a deadline" nil)
698 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
700 (defcustom org-agenda-tags-todo-honor-ignore-options nil
701 "Non-nil means honor todo-list ...ignore options also in tags-todo search.
703 `org-agenda-todo-ignore-with-date',
704 `org-agenda-todo-ignore-timestamp',
705 `org-agenda-todo-ignore-scheduled',
706 `org-agenda-todo-ignore-deadlines'
707 make the global TODO list skip entries that have time stamps of certain
708 kinds. If this option is set, the same options will also apply for the
709 tags-todo search, which is the general tags/property matcher
710 restricted to unfinished TODO entries only."
711 :group 'org-agenda-skip
712 :group 'org-agenda-todo-list
713 :group 'org-agenda-match-view
716 (defcustom org-agenda-skip-scheduled-if-done nil
717 "Non-nil means don't show scheduled items in agenda when they are done.
718 This is relevant for the daily/weekly agenda, not for the TODO list. And
719 it applies only to the actual date of the scheduling. Warnings about
720 an item with a past scheduling dates are always turned off when the item
722 :group 'org-agenda-skip
723 :group 'org-agenda-daily/weekly
726 (defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
727 "Non-nil means skip scheduling line if same entry shows because of deadline.
728 In the agenda of today, an entry can show up multiple times because
729 it is both scheduled and has a nearby deadline, and maybe a plain time
731 When this variable is t, then only the deadline is shown and the fact that
732 the entry is scheduled today or was scheduled previously is not shown.
733 When this variable is nil, the entry will be shown several times. When
734 the variable is the symbol `not-today', then skip scheduled previously,
735 but not scheduled today."
736 :group 'org-agenda-skip
737 :group 'org-agenda-daily/weekly
739 (const :tag "Never" nil)
740 (const :tag "Always" t)
741 (const :tag "Not when scheduled today" not-today)))
743 (defcustom org-agenda-skip-deadline-if-done nil
744 "Non-nil means don't show deadlines when the corresponding item is done.
745 When nil, the deadline is still shown and should give you a happy feeling.
746 This is relevant for the daily/weekly agenda. And it applied only to the
747 actually date of the deadline. Warnings about approaching and past-due
748 deadlines are always turned off when the item is DONE."
749 :group 'org-agenda-skip
750 :group 'org-agenda-daily/weekly
753 (defcustom org-agenda-skip-deadline-prewarning-if-scheduled nil
754 "Non-nil means skip deadline prewarning when entry is also scheduled.
755 This will apply on all days where a prewarning for the deadline would
756 be shown, but not at the day when the entry is actually due. On that day,
757 the deadline will be shown anyway.
758 This variable may be set to nil, t, or a number which will then give
759 the number of days before the actual deadline when the prewarnings
761 This can be used in a workflow where the first showing of the deadline will
762 trigger you to schedule it, and then you don't want to be reminded of it
763 because you will take care of it on the day when scheduled."
764 :group 'org-agenda-skip
765 :group 'org-agenda-daily/weekly
767 (const :tag "Alwas show prewarning" nil)
768 (const :tag "Remove prewarning if entry is scheduled" t)
769 (integer :tag "Restart prewarning N days before deadline")))
771 (defcustom org-agenda-skip-additional-timestamps-same-entry t
772 "When nil, multiple same-day timestamps in entry make multiple agenda lines.
773 When non-nil, after the search for timestamps has matched once in an
774 entry, the rest of the entry will not be searched."
775 :group 'org-agenda-skip
778 (defcustom org-agenda-skip-timestamp-if-done nil
779 "Non-nil means don't select item by timestamp or -range if it is DONE."
780 :group 'org-agenda-skip
781 :group 'org-agenda-daily/weekly
784 (defcustom org-agenda-dim-blocked-tasks t
785 "Non-nil means dim blocked tasks in the agenda display.
786 This causes some overhead during agenda construction, but if you
787 have turned on `org-enforce-todo-dependencies',
788 `org-enforce-todo-checkbox-dependencies', or any other blocking
789 mechanism, this will create useful feedback in the agenda.
791 Instead of t, this variable can also have the value `invisible'.
792 Then blocked tasks will be invisible and only become visible when
793 they become unblocked. An exemption to this behavior is when a task is
794 blocked because of unchecked checkboxes below it. Since checkboxes do
795 not show up in the agenda views, making this task invisible you remove any
796 trace from agenda views that there is something to do. Therefore, a task
797 that is blocked because of checkboxes will never be made invisible, it
798 will only be dimmed."
799 :group 'org-agenda-daily/weekly
800 :group 'org-agenda-todo-list
802 (const :tag "Do not dim" nil)
803 (const :tag "Dim to a grey face" t)
804 (const :tag "Make invisible" invisible)))
806 (defcustom org-timeline-show-empty-dates 3
807 "Non-nil means `org-timeline' also shows dates without an entry.
808 When nil, only the days which actually have entries are shown.
809 When t, all days between the first and the last date are shown.
810 When an integer, show also empty dates, but if there is a gap of more than
811 N days, just insert a special line indicating the size of the gap."
812 :group 'org-agenda-skip
814 (const :tag "None" nil)
816 (integer :tag "at most")))
818 (defgroup org-agenda-startup nil
819 "Options concerning initial settings in the Agenda in Org Mode."
820 :tag "Org Agenda Startup"
823 (defcustom org-agenda-menu-show-matcher t
824 "Non-nil means show the match string in the agenda dispatcher menu.
825 When nil, the matcher string is not shown, but is put into the help-echo
826 property so than moving the mouse over the command shows it.
827 Setting it to nil is good if matcher strings are very long and/or if
828 you want to use two-column display (see `org-agenda-menu-two-column')."
832 (defcustom org-agenda-menu-two-column nil
833 "Non-nil means, use two columns to show custom commands in the dispatcher.
834 If you use this, you probably want to set `org-agenda-menu-show-matcher'
839 (defcustom org-finalize-agenda-hook nil
840 "Hook run just before displaying an agenda buffer."
841 :group 'org-agenda-startup
844 (defcustom org-agenda-mouse-1-follows-link nil
845 "Non-nil means mouse-1 on a link will follow the link in the agenda.
846 A longer mouse click will still set point. Does not work on XEmacs.
847 Needs to be set before org.el is loaded."
848 :group 'org-agenda-startup
851 (defcustom org-agenda-start-with-follow-mode nil
852 "The initial value of follow mode in a newly created agenda window."
853 :group 'org-agenda-startup
856 (defcustom org-agenda-show-outline-path t
857 "Non-nil means show outline path in echo area after line motion."
858 :group 'org-agenda-startup
861 (defcustom org-agenda-start-with-entry-text-mode nil
862 "The initial value of entry-text-mode in a newly created agenda window."
863 :group 'org-agenda-startup
866 (defcustom org-agenda-entry-text-maxlines 5
867 "Number of text lines to be added when `E' is pressed in the agenda.
869 Note that this variable only used during agenda display. Add add entry text
870 when exporting the agenda, configure the variable
871 `org-agenda-add-entry-ext-maxlines'."
875 (defcustom org-agenda-entry-text-exclude-regexps nil
876 "List of regular expressions to clean up entry text.
877 The complete matches of all regular expressions in this list will be
878 removed from entry text before it is shown in the agenda."
880 :type '(repeat (regexp)))
882 (defvar org-agenda-entry-text-cleanup-hook nil
883 "Hook that is run after basic cleanup of entry text to be shown in agenda.
884 This cleanup is done in a temporary buffer, so the function may inspect and
885 change the entire buffer.
886 Some default stuff like drawers and scheduling/deadline dates will already
887 have been removed when this is called, as will any matches for regular
888 expressions listed in `org-agenda-entry-text-exclude-regexps'.")
890 (defvar org-agenda-include-inactive-timestamps nil
891 "Non-nil means include inactive time stamps in agenda and timeline.")
893 (defgroup org-agenda-windows nil
894 "Options concerning the windows used by the Agenda in Org Mode."
895 :tag "Org Agenda Windows"
898 (defcustom org-agenda-window-setup 'reorganize-frame
899 "How the agenda buffer should be displayed.
900 Possible values for this option are:
902 current-window Show agenda in the current window, keeping all other windows.
903 other-window Use `switch-to-buffer-other-window' to display agenda.
904 reorganize-frame Show only two windows on the current frame, the current
905 window and the agenda.
906 other-frame Use `switch-to-buffer-other-frame' to display agenda.
907 Also, when exiting the agenda, kill that frame.
908 See also the variable `org-agenda-restore-windows-after-quit'."
909 :group 'org-agenda-windows
911 (const current-window)
914 (const reorganize-frame)))
916 (defcustom org-agenda-window-frame-fractions '(0.5 . 0.75)
917 "The min and max height of the agenda window as a fraction of frame height.
918 The value of the variable is a cons cell with two numbers between 0 and 1.
919 It only matters if `org-agenda-window-setup' is `reorganize-frame'."
920 :group 'org-agenda-windows
921 :type '(cons (number :tag "Minimum") (number :tag "Maximum")))
923 (defcustom org-agenda-restore-windows-after-quit nil
924 "Non-nil means restore window configuration upon exiting agenda.
925 Before the window configuration is changed for displaying the agenda,
926 the current status is recorded. When the agenda is exited with
927 `q' or `x' and this option is set, the old state is restored. If
928 `org-agenda-window-setup' is `other-frame', the value of this
929 option will be ignored."
930 :group 'org-agenda-windows
933 (defcustom org-agenda-ndays nil
934 "Number of days to include in overview display.
936 Obsolete, see `org-agenda-span'."
937 :group 'org-agenda-daily/weekly
940 (make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
942 (defcustom org-agenda-span 'week
943 "Number of days to include in overview display.
944 Can be day, week, month, year, or any number of days.
945 Custom commands can set this variable in the options section."
946 :group 'org-agenda-daily/weekly
947 :type '(choice (const :tag "Day" day)
948 (const :tag "Week" week)
949 (const :tag "Month" month)
950 (const :tag "Year" year)
951 (integer :tag "Custom")))
953 (defcustom org-agenda-start-on-weekday 1
954 "Non-nil means start the overview always on the specified weekday.
955 0 denotes Sunday, 1 denotes Monday etc.
956 When nil, always start on the current day.
957 Custom commands can set this variable in the options section."
958 :group 'org-agenda-daily/weekly
959 :type '(choice (const :tag "Today" nil)
960 (integer :tag "Weekday No.")))
962 (defcustom org-agenda-show-all-dates t
963 "Non-nil means `org-agenda' shows every day in the selected range.
964 When nil, only the days which actually have entries are shown."
965 :group 'org-agenda-daily/weekly
968 (defcustom org-agenda-format-date 'org-agenda-format-date-aligned
969 "Format string for displaying dates in the agenda.
970 Used by the daily/weekly agenda and by the timeline. This should be
971 a format string understood by `format-time-string', or a function returning
972 the formatted date as a string. The function must take a single argument,
973 a calendar-style date list like (month day year)."
974 :group 'org-agenda-daily/weekly
976 (string :tag "Format string")
977 (function :tag "Function")))
979 (defun org-agenda-format-date-aligned (date)
980 "Format a date string for display in the daily/weekly agenda, or timeline.
981 This function makes sure that dates are aligned for easy reading."
983 (let* ((dayname (calendar-day-name date))
985 (day-of-week (calendar-day-of-week date))
987 (monthname (calendar-month-name month))
989 (iso-week (org-days-to-iso-week
990 (calendar-absolute-from-gregorian date)))
991 (weekyear (cond ((and (= month 1) (>= iso-week 52))
993 ((and (= month 12) (<= iso-week 1))
996 (weekstring (if (= day-of-week 1)
997 (format " W%02d" iso-week)
999 (format "%-10s %2d %s %4d%s"
1000 dayname day monthname year weekstring)))
1002 (defcustom org-agenda-time-leading-zero nil
1003 "Non-nil means use leading zero for military times in agenda.
1004 For example, 9:30am would become 09:30 rather than 9:30."
1005 :group 'org-agenda-daily/weekly
1008 (defcustom org-agenda-timegrid-use-ampm nil
1009 "When set, show AM/PM style timestamps on the timegrid."
1013 (defun org-agenda-time-of-day-to-ampm (time)
1014 "Convert TIME of a string like '13:45' to an AM/PM style time string."
1015 (let* ((hour-number (string-to-number (substring time 0 -3)))
1016 (minute (substring time -2))
1019 ((equal hour-number 12)
1023 (setq hour-number (- hour-number 12))))
1025 (if org-agenda-time-leading-zero
1026 (format "%02d" hour-number)
1027 (format "%02s" (number-to-string hour-number)))
1030 (defun org-agenda-time-of-day-to-ampm-maybe (time)
1031 "Conditionally convert TIME to AM/PM format
1032 based on `org-agenda-timegrid-use-ampm'"
1033 (if org-agenda-timegrid-use-ampm
1034 (org-agenda-time-of-day-to-ampm time)
1037 (defcustom org-agenda-weekend-days '(6 0)
1038 "Which days are weekend?
1039 These days get the special face `org-agenda-date-weekend' in the agenda
1040 and timeline buffers."
1041 :group 'org-agenda-daily/weekly
1042 :type '(set :greedy t
1043 (const :tag "Monday" 1)
1044 (const :tag "Tuesday" 2)
1045 (const :tag "Wednesday" 3)
1046 (const :tag "Thursday" 4)
1047 (const :tag "Friday" 5)
1048 (const :tag "Saturday" 6)
1049 (const :tag "Sunday" 0)))
1051 (defcustom org-agenda-include-diary nil
1052 "If non-nil, include in the agenda entries from the Emacs Calendar's diary.
1053 Custom commands can set this variable in the options section."
1054 :group 'org-agenda-daily/weekly
1057 (defcustom org-agenda-include-deadlines t
1058 "If non-nil, include entries within their deadline warning period.
1059 Custom commands can set this variable in the options section."
1060 :group 'org-agenda-daily/weekly
1063 (defcustom org-agenda-include-all-todo nil
1064 "Set means weekly/daily agenda will always contain all TODO entries.
1065 The TODO entries will be listed at the top of the agenda, before
1066 the entries for specific days.
1067 This option is deprecated, it is better to define a block agenda instead."
1068 :group 'org-agenda-daily/weekly
1071 (defcustom org-agenda-repeating-timestamp-show-all t
1072 "Non-nil means show all occurrences of a repeating stamp in the agenda.
1073 When set to a list of strings, only show occurrences of repeating
1074 stamps for these TODO keywords. When nil, only one occurrence is
1075 shown, either today or the nearest into the future."
1076 :group 'org-agenda-daily/weekly
1078 (const :tag "Show repeating stamps" t)
1079 (repeat :tag "Show repeating stamps for these TODO keywords"
1080 (string :tag "TODO Keyword"))
1081 (const :tag "Don't show repeating stamps" nil)))
1083 (defcustom org-scheduled-past-days 10000
1084 "No. of days to continue listing scheduled items that are not marked DONE.
1085 When an item is scheduled on a date, it shows up in the agenda on this
1086 day and will be listed until it is marked done for the number of days
1088 :group 'org-agenda-daily/weekly
1091 (defcustom org-agenda-log-mode-items '(closed clock)
1092 "List of items that should be shown in agenda log mode.
1093 This list may contain the following symbols:
1095 closed Show entries that have been closed on that day.
1096 clock Show entries that have received clocked time on that day.
1097 state Show all logged state changes.
1098 Note that instead of changing this variable, you can also press `C-u l' in
1099 the agenda to display all available LOG items temporarily."
1100 :group 'org-agenda-daily/weekly
1101 :type '(set :greedy t (const closed) (const clock) (const state)))
1103 (defcustom org-agenda-clock-consistency-checks
1104 '(:max-duration "10:00" :min-duration 0 :max-gap "0:05"
1105 :gap-ok-around ("4:00")
1106 :default-face ((:background "DarkRed") (:foreground "white"))
1107 :overlap-face nil :gap-face nil :no-end-time-face nil
1108 :long-face nil :short-face nil)
1109 "This is a property list, with the following keys:
1111 :max-duration Mark clocking chunks that are longer than this time.
1112 This is a time string like \"HH:MM\", or the number
1113 of minutes as an integer.
1115 :min-duration Mark clocking chunks that are shorter that this.
1116 This is a time string like \"HH:MM\", or the number
1117 of minutes as an integer.
1119 :max-gap Mark gaps between clocking chunks that are longer than
1120 this duration. A number of minutes, or a string
1123 :gap-ok-around List of times during the day which are usually not working
1124 times. When a gap is detected, but the gap contains any
1125 of these times, the gap is *not* reported. For example,
1126 if this is (\"4:00\" \"13:00\") then gaps that contain
1127 4:00 in the morning (i.e. the night) and 13:00
1128 (i.e. a typical lunch time) do not cause a warning.
1129 You should have at least one time during the night in this
1130 list, or otherwise the first task each morning will trigger
1131 a warning because it follows a long gap.
1133 Furthermore, the following properties can be used to define faces for
1136 :default-face the default face, if the specific face is undefined
1137 :overlap-face face for overlapping clocks
1138 :gap-face face for gaps between clocks
1139 :no-end-time-face face for incomplete clocks
1140 :long-face face for clock intervals that are too long
1141 :short-face face for clock intervals that are too short"
1142 :group 'org-agenda-daily/weekly
1146 (defcustom org-agenda-log-mode-add-notes t
1147 "Non-nil means add first line of notes to log entries in agenda views.
1148 If a log item like a state change or a clock entry is associated with
1149 notes, the first line of these notes will be added to the entry in the
1151 :group 'org-agenda-daily/weekly
1154 (defcustom org-agenda-start-with-log-mode nil
1155 "The initial value of log-mode in a newly created agenda window."
1156 :group 'org-agenda-startup
1157 :group 'org-agenda-daily/weekly
1160 (defcustom org-agenda-start-with-clockreport-mode nil
1161 "The initial value of clockreport-mode in a newly created agenda window."
1162 :group 'org-agenda-startup
1163 :group 'org-agenda-daily/weekly
1166 (defcustom org-agenda-clockreport-parameter-plist '(:link t :maxlevel 2)
1167 "Property list with parameters for the clocktable in clockreport mode.
1168 This is the display mode that shows a clock table in the daily/weekly
1169 agenda, the properties for this dynamic block can be set here.
1170 The usual clocktable parameters are allowed here, but you cannot set
1171 the properties :name, :tstart, :tend, :block, and :scope - these will
1172 be overwritten to make sure the content accurately reflects the
1173 current display in the agenda."
1174 :group 'org-agenda-daily/weekly
1177 (defcustom org-agenda-search-view-always-boolean nil
1178 "Non-nil means the search string is interpreted as individual parts.
1180 The search string for search view can either be interpreted as a phrase,
1181 or as a list of snippets that define a boolean search for a number of
1184 When this is non-nil, the string will be split on whitespace, and each
1185 snippet will be searched individually, and all must match in order to
1186 select an entry. A snippet is then a single string of non-white
1187 characters, or a string in double quotes, or a regexp in {} braces.
1188 If a snippet is preceded by \"-\", the snippet must *not* match.
1189 \"+\" is syntactic sugar for positive selection. Each snippet may
1190 be found as a full word or a partial word, but see the variable
1191 `org-agenda-search-view-force-full-words'.
1193 When this is nil, search will look for the entire search phrase as one,
1194 with each space character matching any amount of whitespace, including
1197 Even when this is nil, you can still switch to Boolean search dynamically
1198 by preceding the first snippet with \"+\" or \"-\". If the first snippet
1199 is a regexp marked with braces like \"{abc}\", this will also switch to
1201 :group 'org-agenda-search-view
1204 (if (fboundp 'defvaralias)
1205 (defvaralias 'org-agenda-search-view-search-words-only
1206 'org-agenda-search-view-always-boolean))
1208 (defcustom org-agenda-search-view-force-full-words nil
1209 "Non-nil means, search words must be matches as complete words.
1210 When nil, they may also match part of a word."
1211 :group 'org-agenda-search-view
1214 (defgroup org-agenda-time-grid nil
1215 "Options concerning the time grid in the Org-mode Agenda."
1216 :tag "Org Agenda Time Grid"
1219 (defcustom org-agenda-search-headline-for-time t
1220 "Non-nil means search headline for a time-of-day.
1221 If the headline contains a time-of-day in one format or another, it will
1222 be used to sort the entry into the time sequence of items for a day.
1223 Some people have time stamps in the headline that refer to the creation
1224 time or so, and then this produces an unwanted side effect. If this is
1225 the case for your, use this variable to turn off searching the headline
1227 :group 'org-agenda-time-grid
1230 (defcustom org-agenda-use-time-grid t
1231 "Non-nil means show a time grid in the agenda schedule.
1232 A time grid is a set of lines for specific times (like every two hours between
1233 8:00 and 20:00). The items scheduled for a day at specific times are
1234 sorted in between these lines.
1235 For details about when the grid will be shown, and what it will look like, see
1236 the variable `org-agenda-time-grid'."
1237 :group 'org-agenda-time-grid
1240 (defcustom org-agenda-time-grid
1241 '((daily today require-timed)
1243 (800 1000 1200 1400 1600 1800 2000))
1245 "The settings for time grid for agenda display.
1246 This is a list of three items. The first item is again a list. It contains
1247 symbols specifying conditions when the grid should be displayed:
1249 daily if the agenda shows a single day
1250 weekly if the agenda shows an entire week
1251 today show grid on current date, independent of daily/weekly display
1252 require-timed show grid only if at least one item has a time specification
1254 The second item is a string which will be placed behind the grid time.
1256 The third item is a list of integers, indicating the times that should have
1258 :group 'org-agenda-time-grid
1261 (set :greedy t :tag "Grid Display Options"
1262 (const :tag "Show grid in single day agenda display" daily)
1263 (const :tag "Show grid in weekly agenda display" weekly)
1264 (const :tag "Always show grid for today" today)
1265 (const :tag "Show grid only if any timed entries are present"
1267 (const :tag "Skip grid times already present in an entry"
1269 (string :tag "Grid String")
1270 (repeat :tag "Grid Times" (integer :tag "Time"))))
1272 (defcustom org-agenda-show-current-time-in-grid t
1273 "Non-nil means show the current time in the time grid."
1274 :group 'org-agenda-time-grid
1277 (defcustom org-agenda-current-time-string
1278 "now - - - - - - - - - - - - - - - - - - - - - - - - -"
1279 "The string for the current time marker in the agenda."
1280 :group 'org-agenda-time-grid
1283 (defgroup org-agenda-sorting nil
1284 "Options concerning sorting in the Org-mode Agenda."
1285 :tag "Org Agenda Sorting"
1288 (defcustom org-agenda-sorting-strategy
1289 '((agenda habit-down time-up priority-down category-keep)
1290 (todo priority-down category-keep)
1291 (tags priority-down category-keep)
1292 (search category-keep))
1293 "Sorting structure for the agenda items of a single day.
1294 This is a list of symbols which will be used in sequence to determine
1295 if an entry should be listed before another entry. The following
1296 symbols are recognized:
1298 time-up Put entries with time-of-day indications first, early first
1299 time-down Put entries with time-of-day indications first, late first
1300 category-keep Keep the default order of categories, corresponding to the
1301 sequence in `org-agenda-files'.
1302 category-up Sort alphabetically by category, A-Z.
1303 category-down Sort alphabetically by category, Z-A.
1304 tag-up Sort alphabetically by last tag, A-Z.
1305 tag-down Sort alphabetically by last tag, Z-A.
1306 priority-up Sort numerically by priority, high priority last.
1307 priority-down Sort numerically by priority, high priority first.
1308 todo-state-up Sort by todo state, tasks that are done last.
1309 todo-state-down Sort by todo state, tasks that are done first.
1310 effort-up Sort numerically by estimated effort, high effort last.
1311 effort-down Sort numerically by estimated effort, high effort first.
1312 user-defined-up Sort according to `org-agenda-cmp-user-defined', high last.
1313 user-defined-down Sort according to `org-agenda-cmp-user-defined', high first.
1314 habit-up Put entries that are habits first
1315 habit-down Put entries that are habits last
1316 alpha-up Sort headlines alphabetically
1317 alpha-down Sort headlines alphabetically, reversed
1319 The different possibilities will be tried in sequence, and testing stops
1320 if one comparison returns a \"not-equal\". For example, the default
1321 '(time-up category-keep priority-down)
1322 means: Pull out all entries having a specified time of day and sort them,
1323 in order to make a time schedule for the current day the first thing in the
1324 agenda listing for the day. Of the entries without a time indication, keep
1325 the grouped in categories, don't sort the categories, but keep them in
1326 the sequence given in `org-agenda-files'. Within each category sort by
1329 Leaving out `category-keep' would mean that items will be sorted across
1330 categories by priority.
1332 Instead of a single list, this can also be a set of list for specific
1333 contents, with a context symbol in the car of the list, any of
1334 `agenda', `todo', `tags', `search' for the corresponding agenda views.
1336 Custom commands can bind this variable in the options section."
1337 :group 'org-agenda-sorting
1339 (repeat :tag "General" ,org-sorting-choice)
1340 (list :tag "Individually"
1341 (cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
1342 (repeat ,org-sorting-choice))
1343 (cons (const :tag "Strategy for TODO lists" todo)
1344 (repeat ,org-sorting-choice))
1345 (cons (const :tag "Strategy for Tags matches" tags)
1346 (repeat ,org-sorting-choice))
1347 (cons (const :tag "Strategy for search matches" search)
1348 (repeat ,org-sorting-choice)))))
1350 (defcustom org-agenda-cmp-user-defined nil
1351 "A function to define the comparison `user-defined'.
1352 This function must receive two arguments, agenda entry a and b.
1353 If a>b, return +1. If a<b, return -1. If they are equal as seen by
1354 the user comparison, return nil.
1355 When this is defined, you can make `user-defined-up' and `user-defined-down'
1356 part of an agenda sorting strategy."
1357 :group 'org-agenda-sorting
1360 (defcustom org-sort-agenda-notime-is-late t
1361 "Non-nil means items without time are considered late.
1362 This is only relevant for sorting. When t, items which have no explicit
1363 time like 15:30 will be considered as 99:01, i.e. later than any items which
1364 do have a time. When nil, the default time is before 0:00. You can use this
1365 option to decide if the schedule for today should come before or after timeless
1367 :group 'org-agenda-sorting
1370 (defcustom org-sort-agenda-noeffort-is-high t
1371 "Non-nil means items without effort estimate are sorted as high effort.
1372 This also applies when filtering an agenda view with respect to the
1373 < or > effort operator. Then, tasks with no effort defined will be treated
1374 as tasks with high effort.
1375 When nil, such items are sorted as 0 minutes effort."
1376 :group 'org-agenda-sorting
1379 (defgroup org-agenda-line-format nil
1380 "Options concerning the entry prefix in the Org-mode agenda display."
1381 :tag "Org Agenda Line Format"
1384 (defcustom org-agenda-prefix-format
1385 '((agenda . " %i %-12:c%?-12t% s")
1387 (todo . " %i %-12:c")
1388 (tags . " %i %-12:c")
1389 (search . " %i %-12:c"))
1390 "Format specifications for the prefix of items in the agenda views.
1391 An alist with four entries, for the different agenda types. The keys to the
1392 sublists are `agenda', `timeline', `todo', `search' and `tags'. The values
1394 This format works similar to a printf format, with the following meaning:
1396 %c the category of the item, \"Diary\" for entries from the diary, or
1397 as given by the CATEGORY keyword or derived from the file name.
1398 %i the icon category of the item, as give in
1399 `org-agenda-category-icon-alist'.
1400 %T the *last* tag of the item. Last because inherited tags come
1402 %t the time-of-day specification if one applies to the entry, in the
1404 %s Scheduling/Deadline information, a short string
1405 %(expression) Eval EXPRESSION and replace the control string
1408 All specifiers work basically like the standard `%s' of printf, but may
1409 contain two additional characters: A question mark just after the `%' and
1410 a whitespace/punctuation character just before the final letter.
1412 If the first character after `%' is a question mark, the entire field
1413 will only be included if the corresponding value applies to the
1414 current entry. This is useful for fields which should have fixed
1415 width when present, but zero width when absent. For example,
1416 \"%?-12t\" will result in a 12 character time field if a time of the
1417 day is specified, but will completely disappear in entries which do
1420 If there is punctuation or whitespace character just before the final
1421 format letter, this character will be appended to the field value if
1422 the value is not empty. For example, the format \"%-12:c\" leads to
1423 \"Diary: \" if the category is \"Diary\". If the category were be
1424 empty, no additional colon would be inserted.
1426 The default value of this option is \" %-12:c%?-12t% s\", meaning:
1427 - Indent the line with two space characters
1428 - Give the category in a 12 chars wide field, padded with whitespace on
1429 the right (because of `-'). Append a colon if there is a category
1431 - If there is a time-of-day, put it into a 12 chars wide field. If no
1432 time, don't put in an empty field, just skip it (because of '?').
1433 - Finally, put the scheduling information and append a whitespace.
1435 As another example, if you don't want the time-of-day of entries in
1436 the prefix, you could use:
1438 (setq org-agenda-prefix-format \" %-11:c% s\")
1440 See also the variables `org-agenda-remove-times-when-in-prefix' and
1441 `org-agenda-remove-tags'.
1443 Custom commands can set this variable in the options section."
1445 (string :tag "General format")
1446 (list :greedy t :tag "View dependent"
1447 (cons (const agenda) (string :tag "Format"))
1448 (cons (const timeline) (string :tag "Format"))
1449 (cons (const todo) (string :tag "Format"))
1450 (cons (const tags) (string :tag "Format"))
1451 (cons (const search) (string :tag "Format"))))
1452 :group 'org-agenda-line-format)
1454 (defvar org-prefix-format-compiled nil
1455 "The compiled version of the most recently used prefix format.
1456 See the variable `org-agenda-prefix-format'.")
1458 (defcustom org-agenda-todo-keyword-format "%-1s"
1459 "Format for the TODO keyword in agenda lines.
1460 Set this to something like \"%-12s\" if you want all TODO keywords
1461 to occupy a fixed space in the agenda display."
1462 :group 'org-agenda-line-format
1465 (defcustom org-agenda-timerange-leaders '("" "(%d/%d): ")
1466 "Text preceding timerange entries in the agenda view.
1467 This is a list with two strings. The first applies when the range
1468 is entirely on one day. The second applies if the range spans several days.
1469 The strings may have two \"%d\" format specifiers which will be filled
1470 with the sequence number of the days, and the total number of days in the
1471 range, respectively."
1472 :group 'org-agenda-line-format
1474 (string :tag "Deadline today ")
1475 (choice :tag "Deadline relative"
1476 (string :tag "Format string")
1479 (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
1480 "Text preceding scheduled items in the agenda view.
1481 This is a list with two strings. The first applies when the item is
1482 scheduled on the current day. The second applies when it has been scheduled
1483 previously, it may contain a %d indicating that this is the nth time that
1484 this item is scheduled, due to automatic rescheduling of unfinished items
1485 for the following day. So this number is one larger than the number of days
1486 that passed since this item was scheduled first."
1487 :group 'org-agenda-line-format
1489 (string :tag "Scheduled today ")
1490 (string :tag "Scheduled previously")))
1492 (defcustom org-agenda-inactive-leader "["
1493 "Text preceding item pulled into the agenda by inactive time stamps.
1494 These entries are added to the agenda when pressing \"[\"."
1495 :group 'org-agenda-line-format
1497 (string :tag "Scheduled today ")
1498 (string :tag "Scheduled previously")))
1500 (defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: ")
1501 "Text preceding deadline items in the agenda view.
1502 This is a list with two strings. The first applies when the item has its
1503 deadline on the current day. The second applies when it is in the past or
1504 in the future, it may contain %d to capture how many days away the deadline
1506 :group 'org-agenda-line-format
1508 (string :tag "Deadline today ")
1509 (choice :tag "Deadline relative"
1510 (string :tag "Format string")
1513 (defcustom org-agenda-remove-times-when-in-prefix t
1514 "Non-nil means remove duplicate time specifications in agenda items.
1515 When the format `org-agenda-prefix-format' contains a `%t' specifier, a
1516 time-of-day specification in a headline or diary entry is extracted and
1517 placed into the prefix. If this option is non-nil, the original specification
1518 \(a timestamp or -range, or just a plain time(range) specification like
1519 11:30-4pm) will be removed for agenda display. This makes the agenda less
1521 The option can be t or nil. It may also be the symbol `beg', indicating
1522 that the time should only be removed when it is located at the beginning of
1523 the headline/diary entry."
1524 :group 'org-agenda-line-format
1526 (const :tag "Always" t)
1527 (const :tag "Never" nil)
1528 (const :tag "When at beginning of entry" beg)))
1530 (defcustom org-agenda-remove-timeranges-from-blocks nil
1531 "Non-nil means remove time ranges specifications in agenda
1532 items that span on several days."
1533 :group 'org-agenda-line-format
1536 (defcustom org-agenda-default-appointment-duration nil
1537 "Default duration for appointments that only have a starting time.
1538 When nil, no duration is specified in such cases.
1539 When non-nil, this must be the number of minutes, e.g. 60 for one hour."
1540 :group 'org-agenda-line-format
1542 (integer :tag "Minutes")
1543 (const :tag "No default duration")))
1545 (defcustom org-agenda-show-inherited-tags t
1546 "Non-nil means show inherited tags in each agenda line."
1547 :group 'org-agenda-line-format
1550 (defcustom org-agenda-hide-tags-regexp nil
1551 "Regular expression used to filter away specific tags in agenda views.
1552 This means that these tags will be present, but not be shown in the agenda
1553 line. Secondary filtering will still work on the hidden tags.
1554 Nil means don't hide any tags."
1555 :group 'org-agenda-line-format
1557 (const :tag "Hide none" nil)
1558 (string :tag "Regexp ")))
1560 (defcustom org-agenda-remove-tags nil
1561 "Non-nil means remove the tags from the headline copy in the agenda.
1562 When this is the symbol `prefix', only remove tags when
1563 `org-agenda-prefix-format' contains a `%T' specifier."
1564 :group 'org-agenda-line-format
1566 (const :tag "Always" t)
1567 (const :tag "Never" nil)
1568 (const :tag "When prefix format contains %T" prefix)))
1570 (if (fboundp 'defvaralias)
1571 (defvaralias 'org-agenda-remove-tags-when-in-prefix
1572 'org-agenda-remove-tags))
1574 (defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
1575 "Shift tags in agenda items to this column.
1576 If this number is positive, it specifies the column. If it is negative,
1577 it means that the tags should be flushright to that column. For example,
1578 -80 works well for a normal 80 character screen."
1579 :group 'org-agenda-line-format
1582 (if (fboundp 'defvaralias)
1583 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
1585 (defcustom org-agenda-fontify-priorities 'cookies
1586 "Non-nil means highlight low and high priorities in agenda.
1587 When t, the highest priority entries are bold, lowest priority italic.
1588 However, settings in `org-priority-faces' will overrule these faces.
1589 When this variable is the symbol `cookies', only fontify the
1590 cookies, not the entire task.
1591 This may also be an association list of priority faces, whose
1592 keys are the character values of `org-highest-priority',
1593 `org-default-priority', and `org-lowest-priority' (the default values
1594 are ?A, ?B, and ?C, respectively). The face may be a named face, a
1595 color as a string, or a list like `(:background \"Red\")'.
1596 If it is a color, the variable `org-faces-easy-properties'
1597 determines if it is a foreground or a background color."
1598 :group 'org-agenda-line-format
1600 (const :tag "Never" nil)
1601 (const :tag "Defaults" t)
1602 (const :tag "Cookies only" cookies)
1603 (repeat :tag "Specify"
1604 (list (character :tag "Priority" :value ?A)
1605 (choice :tag "Face "
1606 (string :tag "Color")
1607 (sexp :tag "Face"))))))
1609 (defcustom org-agenda-day-face-function nil
1610 "Function called to determine what face should be used to display a day.
1611 The only argument passed to that function is the day. It should
1612 returns a face, or nil if does not want to specify a face and let
1613 the normal rules apply."
1614 :group 'org-agenda-line-format
1617 (defcustom org-agenda-category-icon-alist nil
1618 "Alist of category icon to be displayed in agenda views.
1620 Each entry should have the following format:
1622 (CATEGORY-REGEXP FILE-OR-DATA TYPE DATA-P PROPS)
1624 Where CATEGORY-REGEXP is a regexp matching the categories where
1625 the icon should be displayed.
1626 FILE-OR-DATA either a file path or a string containing image data.
1628 The other fields can be omited safely if not needed:
1629 TYPE indicates the image type.
1630 DATA-P is a boolean indicating whether the FILE-OR-DATA string is
1632 PROPS are additional image attributes to assign to the image,
1633 like, e.g. `:ascent center'.
1635 (\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
1637 If you want to set the display properties yourself, just put a
1638 list as second element:
1640 (CATEGORY-REGEXP (MY PROPERTY LIST))
1642 For example, to display a 16px horizontal space for Emacs
1643 category, you can use:
1645 (\"Emacs\" '(space . (:width (16))))"
1646 :group 'org-agenda-line-format
1647 :type '(alist :key-type (string :tag "Regexp matching category")
1648 :value-type (choice (list :tag "Icon"
1649 (string :tag "File or data")
1650 (symbol :tag "Type")
1651 (boolean :tag "Data?")
1652 (repeat :tag "Extra image properties" :inline t symbol))
1653 (list :tag "Display properties" sexp))))
1655 (defgroup org-agenda-column-view nil
1656 "Options concerning column view in the agenda."
1657 :tag "Org Agenda Column View"
1660 (defcustom org-agenda-columns-show-summaries t
1661 "Non-nil means show summaries for columns displayed in the agenda view."
1662 :group 'org-agenda-column-view
1665 (defcustom org-agenda-columns-compute-summary-properties t
1666 "Non-nil means recompute all summary properties before column view.
1667 When column view in the agenda is listing properties that have a summary
1668 operator, it can go to all relevant buffers and recompute the summaries
1669 there. This can mean overhead for the agenda column view, but is necessary
1670 to have thing up to date.
1671 As a special case, a CLOCKSUM property also makes sure that the clock
1672 computations are current."
1673 :group 'org-agenda-column-view
1676 (defcustom org-agenda-columns-add-appointments-to-effort-sum nil
1677 "Non-nil means the duration of an appointment will add to day effort.
1678 The property to which appointment durations will be added is the one given
1679 in the option `org-effort-property'. If an appointment does not have
1680 an end time, `org-agenda-default-appointment-duration' will be used. If that
1681 is not set, an appointment without end time will not contribute to the time
1683 :group 'org-agenda-column-view
1686 (defcustom org-agenda-auto-exclude-function nil
1687 "A function called with a tag to decide if it is filtered on '/ RET'.
1688 The sole argument to the function, which is called once for each
1689 possible tag, is a string giving the name of the tag. The
1690 function should return either nil if the tag should be included
1691 as normal, or \"-<TAG>\" to exclude the tag.
1692 Note that for the purpose of tag filtering, only the lower-case version of
1693 all tags will be considered, so that this function will only ever see
1694 the lower-case version of all tags."
1698 (defcustom org-agenda-bulk-custom-functions nil
1699 "Alist of characters and custom functions for bulk action.
1700 For example, this value makes those two functions available:
1705 With selected entries in an agenda buffer, `B R' will execute
1706 set-category on the selected entries. Note that functions in
1707 this alist don't need to be quoted."
1715 (defmacro org-agenda-with-point-at-orig-entry (string &rest body)
1716 "Execute BODY with point at location given by `org-hd-marker' property.
1717 If STRING is non-nil, the text property will be fetched from position 0
1718 in that string. If STRING is nil, it will be fetched from the beginning
1719 of the current line."
1720 `(let ((marker (get-text-property (if string 0 (point-at-bol))
1721 'org-hd-marker string)))
1722 (with-current-buffer (marker-buffer marker)
1727 (defun org-add-agenda-custom-command (entry)
1728 "Replace or add a command in `org-agenda-custom-commands'.
1729 This is mostly for hacking and trying a new command - once the command
1730 works you probably want to add it to `org-agenda-custom-commands' for good."
1731 (let ((ass (assoc (car entry) org-agenda-custom-commands)))
1733 (setcdr ass (cdr entry))
1734 (push entry org-agenda-custom-commands))))
1736 ;;; Define the Org-agenda-mode
1738 (defvar org-agenda-mode-map (make-sparse-keymap)
1739 "Keymap for `org-agenda-mode'.")
1740 (if (fboundp 'defvaralias)
1741 (defvaralias 'org-agenda-keymap 'org-agenda-mode-map))
1743 (defvar org-agenda-menu) ; defined later in this file.
1744 (defvar org-agenda-restrict) ; defined later in this file.
1745 (defvar org-agenda-follow-mode nil)
1746 (defvar org-agenda-entry-text-mode nil)
1747 (defvar org-agenda-clockreport-mode nil)
1748 (defvar org-agenda-show-log nil)
1749 (defvar org-agenda-redo-command nil)
1750 (defvar org-agenda-query-string nil)
1751 (defvar org-agenda-mode-hook nil
1752 "Hook for `org-agenda-mode', run after the mode is turned on.")
1753 (defvar org-agenda-type nil)
1754 (defvar org-agenda-force-single-file nil)
1755 (defvar org-agenda-bulk-marked-entries) ;; Defined further down in this file
1757 (defun org-agenda-mode ()
1758 "Mode for time-sorted view on action items in Org-mode files.
1760 The following commands are available:
1762 \\{org-agenda-mode-map}"
1764 (kill-all-local-variables)
1765 (setq org-agenda-undo-list nil
1766 org-agenda-pending-undo-list nil
1767 org-agenda-bulk-marked-entries nil)
1768 (setq major-mode 'org-agenda-mode)
1769 ;; Keep global-font-lock-mode from turning on font-lock-mode
1770 (org-set-local 'font-lock-global-modes (list 'not major-mode))
1771 (setq mode-name "Org-Agenda")
1772 (use-local-map org-agenda-mode-map)
1773 (easy-menu-add org-agenda-menu)
1774 (if org-startup-truncated (setq truncate-lines t))
1775 (org-set-local 'line-move-visual nil)
1776 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
1777 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
1778 ;; Make sure properties are removed when copying text
1779 (when (boundp 'buffer-substring-filters)
1780 (org-set-local 'buffer-substring-filters
1782 (set-text-properties 0 (length x) nil x) x)
1783 buffer-substring-filters)))
1784 (unless org-agenda-keep-modes
1785 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
1786 org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
1787 org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
1788 org-agenda-show-log org-agenda-start-with-log-mode))
1791 '("Agenda") "Agenda Files"
1795 (if (get 'org-agenda-files 'org-restrict)
1796 "Restricted to single file"
1798 '(org-edit-agenda-file-list)
1799 (not (get 'org-agenda-files 'org-restrict)))
1801 (mapcar 'org-file-menu-entry (org-agenda-files))))
1802 (org-agenda-set-mode-name)
1804 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
1805 (list 'org-agenda-mode-hook)))
1807 (substitute-key-definition 'undo 'org-agenda-undo
1808 org-agenda-mode-map global-map)
1809 (org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
1810 (org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
1811 (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
1812 (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
1813 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
1814 (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
1815 (org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
1816 (org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
1817 (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-remove-all-marks)
1818 (org-defkey org-agenda-mode-map "A" 'org-agenda-append-agenda)
1819 (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
1820 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
1821 (org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
1822 (org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
1823 (org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
1824 (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
1825 (org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
1826 (org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
1827 (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
1828 (org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up)
1829 (org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down)
1830 (org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down)
1831 (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
1832 (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
1833 (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
1834 (org-defkey org-agenda-mode-map "o" 'delete-other-windows)
1835 (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
1836 (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
1837 (org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
1838 (org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation)
1839 (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
1840 (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
1841 (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
1842 (org-defkey org-agenda-mode-map "j" 'org-agenda-goto-date)
1843 (org-defkey org-agenda-mode-map "d" 'org-agenda-day-view)
1844 (org-defkey org-agenda-mode-map "w" 'org-agenda-week-view)
1845 (org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
1846 (org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
1847 (org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
1848 (org-defkey org-agenda-mode-map "k" 'org-agenda-action)
1849 (org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
1850 (org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
1851 (org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
1852 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
1853 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
1855 (org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
1856 (org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
1857 (org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
1858 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
1859 (while l (org-defkey org-agenda-mode-map
1860 (int-to-string (pop l)) 'digit-argument)))
1862 (org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
1863 (org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
1864 (org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
1865 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
1866 (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
1867 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
1868 (org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines)
1869 (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
1870 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
1871 (org-defkey org-agenda-mode-map "g" 'org-agenda-redo)
1872 (org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
1873 (org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
1874 (org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
1875 'org-clock-modify-effort-estimate)
1876 (org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
1877 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
1878 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
1879 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-write-agenda)
1880 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
1881 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
1882 (org-defkey org-agenda-mode-map "P" 'org-agenda-show-priority)
1883 (org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags)
1884 (org-defkey org-agenda-mode-map "n" 'org-agenda-next-line)
1885 (org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line)
1886 (substitute-key-definition 'next-line 'org-agenda-next-line
1887 org-agenda-mode-map global-map)
1888 (substitute-key-definition 'previous-line 'org-agenda-previous-line
1889 org-agenda-mode-map global-map)
1890 (org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach)
1891 (org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line)
1892 (org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line)
1893 (org-defkey org-agenda-mode-map "," 'org-agenda-priority)
1894 (org-defkey org-agenda-mode-map "\C-c," 'org-agenda-priority)
1895 (org-defkey org-agenda-mode-map "i" 'org-agenda-diary-entry)
1896 (org-defkey org-agenda-mode-map "c" 'org-agenda-goto-calendar)
1897 (org-defkey org-agenda-mode-map "C" 'org-agenda-convert-date)
1898 (org-defkey org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
1899 (org-defkey org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
1900 (org-defkey org-agenda-mode-map "h" 'org-agenda-holidays)
1901 (org-defkey org-agenda-mode-map "H" 'org-agenda-holidays)
1902 (org-defkey org-agenda-mode-map "\C-c\C-x\C-i" 'org-agenda-clock-in)
1903 (org-defkey org-agenda-mode-map "I" 'org-agenda-clock-in)
1904 (org-defkey org-agenda-mode-map "\C-c\C-x\C-o" 'org-agenda-clock-out)
1905 (org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out)
1906 (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
1907 (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel)
1908 (org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
1909 (org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto)
1910 (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up)
1911 (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
1912 (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
1913 (org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
1914 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
1915 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
1916 (org-defkey org-agenda-mode-map "f" 'org-agenda-later)
1917 (org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
1918 (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
1919 (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
1921 (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
1922 (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
1923 (org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
1924 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
1925 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
1926 (org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
1927 (org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
1928 (define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
1929 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
1930 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
1932 (org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse)
1933 (org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse)
1934 (when org-agenda-mouse-1-follows-link
1935 (org-defkey org-agenda-mode-map [follow-link] 'mouse-face))
1936 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
1941 ["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
1942 ["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
1943 ["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
1944 ["Jump to date" org-agenda-goto-date (org-agenda-check-type nil 'agenda)])
1947 ["Day View" org-agenda-day-view
1948 :active (org-agenda-check-type nil 'agenda)
1949 :style radio :selected (eq org-agenda-current-span 'day)
1950 :keys "v d (or just d)"]
1951 ["Week View" org-agenda-week-view
1952 :active (org-agenda-check-type nil 'agenda)
1953 :style radio :selected (eq org-agenda-current-span 'week)
1954 :keys "v w (or just w)"]
1955 ["Month View" org-agenda-month-view
1956 :active (org-agenda-check-type nil 'agenda)
1957 :style radio :selected (eq org-agenda-current-span 'month)
1959 ["Year View" org-agenda-year-view
1960 :active (org-agenda-check-type nil 'agenda)
1961 :style radio :selected (eq org-agenda-current-span 'year)
1964 ["Include Diary" org-agenda-toggle-diary
1965 :style toggle :selected org-agenda-include-diary
1966 :active (org-agenda-check-type nil 'agenda)]
1967 ["Include Deadlines" org-agenda-toggle-deadlines
1968 :style toggle :selected org-agenda-include-deadlines
1969 :active (org-agenda-check-type nil 'agenda)]
1970 ["Use Time Grid" org-agenda-toggle-time-grid
1971 :style toggle :selected org-agenda-use-time-grid
1972 :active (org-agenda-check-type nil 'agenda)]
1974 ["Show clock report" org-agenda-clockreport-mode
1975 :style toggle :selected org-agenda-clockreport-mode
1976 :active (org-agenda-check-type nil 'agenda)]
1977 ["Show some entry text" org-agenda-entry-text-mode
1978 :style toggle :selected org-agenda-entry-text-mode
1981 ["Show Logbook entries" org-agenda-log-mode
1982 :style toggle :selected org-agenda-show-log
1983 :active (org-agenda-check-type nil 'agenda 'timeline)
1984 :keys "v l (or just l)"]
1985 ["Include archived trees" org-agenda-archives-mode
1986 :style toggle :selected org-agenda-archives-mode :active t
1988 ["Include archive files" (org-agenda-archives-mode t)
1989 :style toggle :selected (eq org-agenda-archives-mode t) :active t
1992 ["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict])
1993 ["Write view to file" org-write-agenda t]
1994 ["Rebuild buffer" org-agenda-redo t]
1995 ["Save all Org-mode Buffers" org-save-all-org-buffers t]
1997 ["Show original entry" org-agenda-show t]
1998 ["Go To (other window)" org-agenda-goto t]
1999 ["Go To (this window)" org-agenda-switch-to t]
2000 ["Follow Mode" org-agenda-follow-mode
2001 :style toggle :selected org-agenda-follow-mode :active t]
2002 ; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
2005 ["Cycle TODO" org-agenda-todo t]
2006 ["Next TODO set" org-agenda-todo-nextset t]
2007 ["Previous TODO set" org-agenda-todo-previousset t]
2008 ["Add note" org-agenda-add-note t])
2009 ("Archive/Refile/Delete"
2010 ["Archive default" org-agenda-archive-default t]
2011 ["Archive default" org-agenda-archive-default-with-confirmation t]
2012 ["Toggle ARCHIVE tag" org-agenda-toggle-archive-tag t]
2013 ["Move to archive sibling" org-agenda-archive-to-archive-sibling t]
2014 ["Archive subtree" org-agenda-archive t]
2016 ["Refile" org-agenda-refile t]
2018 ["Delete subtree" org-agenda-kill t])
2020 ["Mark entry" org-agenda-bulk-mark t]
2021 ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
2022 ["Unmark entry" org-agenda-bulk-unmark t]
2023 ["Unmark all entries" org-agenda-bulk-remove-all-marks :active t :keys "C-u s"])
2024 ["Act on all marked" org-agenda-bulk-action t]
2026 ("Tags and Properties"
2027 ["Show all Tags" org-agenda-show-tags t]
2028 ["Set Tags current line" org-agenda-set-tags (not (org-region-active-p))]
2029 ["Change tag in region" org-agenda-set-tags (org-region-active-p)]
2031 ["Column View" org-columns t])
2032 ("Deadline/Schedule"
2033 ["Schedule" org-agenda-schedule t]
2034 ["Set Deadline" org-agenda-deadline t]
2036 ["Mark item" org-agenda-action :active t :keys "k m"]
2037 ["Show mark item" org-agenda-action :active t :keys "k v"]
2038 ["Schedule marked item" org-agenda-action :active t :keys "k s"]
2039 ["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
2041 ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
2042 ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
2043 ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
2044 ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
2045 ["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
2046 ["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
2047 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
2049 ["Clock in" org-agenda-clock-in t]
2050 ["Clock out" org-agenda-clock-out t]
2051 ["Clock cancel" org-agenda-clock-cancel t]
2052 ["Goto running clock" org-clock-goto t]
2054 ["Set Effort" org-agenda-set-effort t]
2055 ["Change clocked effort" org-clock-modify-effort-estimate
2056 (org-clock-is-active)])
2058 ["Set Priority" org-agenda-priority t]
2059 ["Increase Priority" org-agenda-priority-up t]
2060 ["Decrease Priority" org-agenda-priority-down t]
2061 ["Show Priority" org-agenda-show-priority t])
2063 ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
2064 ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
2065 ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
2066 ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
2067 ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
2068 ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
2070 ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
2072 ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
2075 ["Push Files and Views" org-mobile-push t]
2076 ["Get Captured and Flagged" org-mobile-pull t]
2077 ["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"]
2078 ["Show note / unflag" org-agenda-show-the-flagging-note t]
2080 ["Setup" (progn (require 'org-mobile) (customize-group 'org-mobile)) t])
2082 ["Quit" org-agenda-quit t]
2083 ["Exit and Release Buffers" org-agenda-exit t]
2088 (defvar org-agenda-allow-remote-undo t
2089 "Non-nil means allow remote undo from the agenda buffer.")
2090 (defvar org-agenda-undo-list nil
2091 "List of undoable operations in the agenda since last refresh.")
2092 (defvar org-agenda-undo-has-started-in nil
2093 "Buffers that have already seen `undo-start' in the current undo sequence.")
2094 (defvar org-agenda-pending-undo-list nil
2095 "In a series of undo commands, this is the list of remaining undo items.")
2097 (defun org-agenda-undo ()
2098 "Undo a remote editing step in the agenda.
2099 This undoes changes both in the agenda buffer and in the remote buffer
2100 that have been changed along."
2102 (or org-agenda-allow-remote-undo
2103 (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
2104 (if (not (eq this-command last-command))
2105 (setq org-agenda-undo-has-started-in nil
2106 org-agenda-pending-undo-list org-agenda-undo-list))
2107 (if (not org-agenda-pending-undo-list)
2108 (error "No further undo information"))
2109 (let* ((entry (pop org-agenda-pending-undo-list))
2110 buf line cmd rembuf)
2111 (setq cmd (pop entry) line (pop entry))
2112 (setq rembuf (nth 2 entry))
2113 (org-with-remote-undo rembuf
2114 (while (bufferp (setq buf (pop entry)))
2116 (with-current-buffer buf
2117 (let ((last-undo-buffer buf)
2118 (inhibit-read-only t))
2119 (unless (memq buf org-agenda-undo-has-started-in)
2120 (push buf org-agenda-undo-has-started-in)
2121 (make-local-variable 'pending-undo-list)
2123 (while (and pending-undo-list
2124 (listp pending-undo-list)
2125 (not (car pending-undo-list)))
2126 (pop pending-undo-list))
2128 (org-goto-line line)
2129 (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))
2131 (defun org-verify-change-for-undo (l1 l2)
2132 "Verify that a real change occurred between the undo lists L1 and L2."
2133 (while (and l1 (listp l1) (null (car l1))) (pop l1))
2134 (while (and l2 (listp l2) (null (car l2))) (pop l2))
2139 (defvar org-agenda-restrict nil)
2140 (defvar org-agenda-restrict-begin (make-marker))
2141 (defvar org-agenda-restrict-end (make-marker))
2142 (defvar org-agenda-last-dispatch-buffer nil)
2143 (defvar org-agenda-overriding-restriction nil)
2146 (defun org-agenda (&optional arg keys restriction)
2147 "Dispatch agenda commands to collect entries to the agenda buffer.
2148 Prompts for a command to execute. Any prefix arg will be passed
2149 on to the selected command. The default selections are:
2151 a Call `org-agenda-list' to display the agenda for current day or week.
2152 t Call `org-todo-list' to display the global todo list.
2153 T Call `org-todo-list' to display the global todo list, select only
2154 entries with a specific TODO keyword (the user gets a prompt).
2155 m Call `org-tags-view' to display headlines with tags matching
2156 a condition (the user is prompted for the condition).
2157 M Like `m', but select only TODO entries, no ordinary headlines.
2158 L Create a timeline for the current buffer.
2159 e Export views to associated files.
2160 s Search entries for keywords.
2161 / Multi occur across all agenda files and also files listed
2162 in `org-agenda-text-search-extra-files'.
2163 < Restrict agenda commands to buffer, subtree, or region.
2164 Press several times to get the desired effect.
2165 > Remove a previous restriction.
2166 # List \"stuck\" projects.
2167 ! Configure what \"stuck\" means.
2168 C Configure custom agenda commands.
2170 More commands can be added by configuring the variable
2171 `org-agenda-custom-commands'. In particular, specific tags and TODO keyword
2172 searches can be pre-defined in this way.
2174 If the current buffer is in Org-mode and visiting a file, you can also
2175 first press `<' once to indicate that the agenda should be temporarily
2176 \(until the next use of \\[org-agenda]) restricted to the current file.
2177 Pressing `<' twice means to restrict to the current subtree or region
2181 (let* ((prefix-descriptions nil)
2182 (org-agenda-window-setup (if (equal (buffer-name)
2183 org-agenda-buffer-name)
2185 org-agenda-window-setup))
2186 (org-agenda-custom-commands-orig org-agenda-custom-commands)
2187 (org-agenda-custom-commands
2188 ;; normalize different versions
2192 (cond ((stringp (cdr x))
2193 (push x prefix-descriptions)
2195 ((stringp (nth 1 x)) x)
2196 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2197 (t (cons (car x) (cons "" (cdr x))))))
2198 org-agenda-custom-commands)))
2199 (buf (current-buffer))
2200 (bfn (buffer-file-name (buffer-base-buffer)))
2201 entry key type match lprops ans)
2202 ;; Turn off restriction unless there is an overriding one,
2203 (unless org-agenda-overriding-restriction
2204 (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
2205 ;; There is a request to keep the file list in place
2206 (put 'org-agenda-files 'org-restrict nil))
2207 (setq org-agenda-restrict nil)
2208 (move-marker org-agenda-restrict-begin nil)
2209 (move-marker org-agenda-restrict-end nil))
2210 ;; Delete old local properties
2211 (put 'org-agenda-redo-command 'org-lprops nil)
2212 ;; Delete previously set last-arguments
2213 (put 'org-agenda-redo-command 'last-args nil)
2214 ;; Remember where this call originated
2215 (setq org-agenda-last-dispatch-buffer (current-buffer))
2217 (setq ans (org-agenda-get-restriction-and-command prefix-descriptions)
2219 restriction (cdr ans)))
2220 ;; Establish the restriction, if any
2221 (when (and (not org-agenda-overriding-restriction) restriction)
2222 (put 'org-agenda-files 'org-restrict (list bfn))
2224 ((eq restriction 'region)
2225 (setq org-agenda-restrict t)
2226 (move-marker org-agenda-restrict-begin (region-beginning))
2227 (move-marker org-agenda-restrict-end (region-end)))
2228 ((eq restriction 'subtree)
2230 (setq org-agenda-restrict t)
2231 (org-back-to-heading t)
2232 (move-marker org-agenda-restrict-begin (point))
2233 (move-marker org-agenda-restrict-end
2234 (progn (org-end-of-subtree t)))))))
2236 ;; For example the todo list should not need it (but does...)
2238 ((setq entry (assoc keys org-agenda-custom-commands))
2239 (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry)))
2241 (setq type (nth 2 entry) match (eval (nth 3 entry))
2242 lprops (nth 4 entry))
2243 (put 'org-agenda-redo-command 'org-lprops lprops)
2246 (org-let lprops '(org-agenda-list current-prefix-arg)))
2248 (org-let lprops '(org-todo-list current-prefix-arg)))
2250 (org-let lprops '(org-search-view current-prefix-arg match nil)))
2252 (org-let lprops '(org-agenda-list-stuck-projects
2253 current-prefix-arg)))
2255 (org-let lprops '(org-tags-view current-prefix-arg match)))
2256 ((eq type 'tags-todo)
2257 (org-let lprops '(org-tags-view '(4) match)))
2259 (org-let lprops '(org-todo-list match)))
2260 ((eq type 'tags-tree)
2261 (org-check-for-org-mode)
2262 (org-let lprops '(org-match-sparse-tree current-prefix-arg match)))
2263 ((eq type 'todo-tree)
2264 (org-check-for-org-mode)
2266 '(org-occur (concat "^" outline-regexp "[ \t]*"
2267 (regexp-quote match) "\\>"))))
2268 ((eq type 'occur-tree)
2269 (org-check-for-org-mode)
2270 (org-let lprops '(org-occur match)))
2272 (org-let lprops '(funcall type match)))
2274 (org-let lprops '(funcall type match)))
2275 (t (error "Invalid custom agenda command type %s" type))))
2276 (org-agenda-run-series (nth 1 entry) (cddr entry))))
2278 (setq org-agenda-custom-commands org-agenda-custom-commands-orig)
2279 (customize-variable 'org-agenda-custom-commands))
2280 ((equal keys "a") (call-interactively 'org-agenda-list))
2281 ((equal keys "s") (call-interactively 'org-search-view))
2282 ((equal keys "t") (call-interactively 'org-todo-list))
2283 ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
2284 ((equal keys "m") (call-interactively 'org-tags-view))
2285 ((equal keys "M") (org-call-with-arg 'org-tags-view (or arg '(4))))
2286 ((equal keys "e") (call-interactively 'org-store-agenda-views))
2287 ((equal keys "?") (org-tags-view nil "+FLAGGED")
2291 (unless (current-message)
2292 (let* ((m (org-agenda-get-any-marker))
2293 (note (and m (org-entry-get m "THEFLAGGINGNOTE"))))
2296 "FLAGGING-NOTE ([?] for more info): "
2298 (replace-regexp-in-string
2300 (copy-sequence note))
2301 nil 'face 'org-warning)))))))
2304 (unless (org-mode-p)
2305 (error "This is not an Org-mode file"))
2307 (put 'org-agenda-files 'org-restrict (list bfn))
2308 (org-call-with-arg 'org-timeline arg)))
2309 ((equal keys "#") (call-interactively 'org-agenda-list-stuck-projects))
2310 ((equal keys "/") (call-interactively 'org-occur-in-agenda-files))
2311 ((equal keys "!") (customize-variable 'org-stuck-projects))
2312 (t (error "Invalid agenda key"))))))
2314 (defun org-agenda-append-agenda ()
2315 "Append another agenda view to the current one.
2316 This function allows interactive building of block agendas.
2317 Agenda views are separated by `org-agenda-block-separator'."
2319 (unless (string= (buffer-name) org-agenda-buffer-name)
2320 (error "Can only append from within agenda buffer"))
2321 (let ((org-agenda-multi t))
2325 (defun org-agenda-normalize-custom-commands (cmds)
2329 (cond ((stringp (cdr x)) nil)
2330 ((stringp (nth 1 x)) x)
2331 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2332 (t (cons (car x) (cons "" (cdr x))))))
2335 (defun org-agenda-get-restriction-and-command (prefix-descriptions)
2336 "The user interface for selecting an agenda command."
2338 (let* ((bfn (buffer-file-name (buffer-base-buffer)))
2339 (restrict-ok (and bfn (org-mode-p)))
2340 (region-p (org-region-active-p))
2341 (custom org-agenda-custom-commands)
2343 restriction second-time
2344 c entry key type match prefixes rmheader header-end custom1 desc
2345 line lines left right n n1)
2346 (save-window-excursion
2347 (delete-other-windows)
2348 (org-switch-to-buffer-other-window " *Agenda Commands*")
2350 (insert (eval-when-compile
2353 Press key for an agenda command: < Buffer, subtree/region restriction
2354 -------------------------------- > Remove restriction
2355 a Agenda for current week or day e Export agenda views
2356 t List of all TODO entries T Entries with special TODO kwd
2357 m Match a TAGS/PROP/TODO query M Like m, but only TODO entries
2358 L Timeline for current buffer # List stuck projects (!=configure)
2359 s Search for keywords C Configure custom agenda commands
2360 / Multi-occur ? Find :FLAGGED: entries
2363 (while (string-match
2364 "\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)"
2366 (setq start (match-end 0))
2367 (add-text-properties (match-beginning 2) (match-end 2)
2368 '(face bold) header))
2370 (setq header-end (move-marker (make-marker) (point)))
2372 (setq custom1 custom)
2373 (when (eq rmheader t)
2375 (re-search-forward ":" nil t)
2376 (delete-region (match-end 0) (point-at-eol))
2379 (delete-region (match-end 0) (point-at-eol))
2380 (move-marker header-end (match-end 0)))
2381 (goto-char header-end)
2382 (delete-region (point) (point-max))
2384 ;; Produce all the lines that describe custom commands and prefixes
2386 (while (setq entry (pop custom1))
2387 (setq key (car entry) desc (nth 1 entry)
2389 match (nth 3 entry))
2390 (if (> (length key) 1)
2391 (add-to-list 'prefixes (string-to-char key))
2395 (org-add-props (copy-sequence key)
2398 ((string-match "\\S-" desc) desc)
2399 ((eq type 'agenda) "Agenda for current week or day")
2400 ((eq type 'alltodo) "List of all TODO entries")
2401 ((eq type 'search) "Word search")
2402 ((eq type 'stuck) "List of stuck projects")
2403 ((eq type 'todo) "TODO keyword")
2404 ((eq type 'tags) "Tags query")
2405 ((eq type 'tags-todo) "Tags (TODO)")
2406 ((eq type 'tags-tree) "Tags tree")
2407 ((eq type 'todo-tree) "TODO kwd tree")
2408 ((eq type 'occur-tree) "Occur tree")
2409 ((functionp type) (if (symbolp type)
2411 "Lambda expression"))
2413 (if org-agenda-menu-show-matcher
2418 (setq match (copy-sequence match))
2419 (org-add-props match nil 'face 'org-warning))
2421 (format "set of %d commands" (length match)))
2423 (if (org-string-nw-p match)
2424 (add-text-properties
2425 0 (length line) (list 'help-echo
2426 (concat "Matcher: "match)) line)))
2428 (setq lines (nreverse lines))
2433 (org-add-props (char-to-string x)
2435 (or (cdr (assoc (concat selstring
2437 prefix-descriptions))
2442 ;; Check if we should display in two columns
2443 (if org-agenda-menu-two-column
2445 (setq n (length lines)
2446 n1 (+ (/ n 2) (mod n 2))
2447 right (nthcdr n1 lines)
2448 left (copy-sequence lines))
2449 (setcdr (nthcdr (1- n1) left) nil))
2450 (setq left lines right nil))
2452 (insert "\n" (pop left))
2454 (if (< (current-column) 40)
2455 (move-to-column 40 t)
2457 (insert (pop right))))
2459 ;; Make the window the right size
2460 (goto-char (point-min))
2462 (if (not (pos-visible-in-window-p (point-max)))
2463 (org-fit-window-to-buffer))
2464 (setq second-time t)
2465 (org-fit-window-to-buffer))
2467 ;; Ask for selection
2468 (message "Press key for agenda command%s:"
2469 (if (or restrict-ok org-agenda-overriding-restriction)
2470 (if org-agenda-overriding-restriction
2471 " (restriction lock active)"
2473 (format " (restricted to %s)" restriction)
2476 (setq c (read-char-exclusive))
2479 ((assoc (char-to-string c) custom)
2480 (setq selstring (concat selstring (char-to-string c)))
2481 (throw 'exit (cons selstring restriction)))
2483 (setq selstring (concat selstring (char-to-string c))
2485 rmheader (or rmheader t)
2486 custom (delq nil (mapcar
2488 (if (or (= (length (car x)) 1)
2489 (/= (string-to-char (car x)) c))
2491 (cons (substring (car x) 1) (cdr x))))
2493 ((and (not restrict-ok) (memq c '(?1 ?0 ?<)))
2494 (message "Restriction is only possible in Org-mode buffers")
2497 (org-agenda-remove-restriction-lock 'noupdate)
2498 (setq restriction 'buffer))
2500 (org-agenda-remove-restriction-lock 'noupdate)
2501 (setq restriction (if region-p 'region 'subtree)))
2503 (org-agenda-remove-restriction-lock 'noupdate)
2506 ((eq restriction 'buffer)
2507 (if region-p 'region 'subtree))
2508 ((memq restriction '(subtree region))
2512 (org-agenda-remove-restriction-lock 'noupdate)
2513 (setq restriction nil))
2514 ((and (equal selstring "") (memq c '(?s ?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/ ??)))
2515 (throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
2516 ((and (> (length selstring) 0) (eq c ?\d))
2518 (org-agenda-get-restriction-and-command prefix-descriptions))
2520 ((equal c ?q) (error "Abort"))
2521 (t (error "Invalid key %c" c))))))))
2523 (defvar org-agenda-overriding-arguments nil) ; dynamically scoped parameter
2524 (defvar org-agenda-last-arguments nil
2525 "The arguments of the previous call to `org-agenda'.")
2526 (defun org-agenda-run-series (name series)
2527 (org-let (nth 1 series) '(org-prepare-agenda name))
2528 (let* ((org-agenda-multi t)
2529 (redo (list 'org-agenda-run-series name (list 'quote series)))
2530 (org-agenda-overriding-arguments
2531 (or org-agenda-overriding-arguments
2532 (unless (null (delq nil (get 'org-agenda-redo-command 'last-args)))
2533 (get 'org-agenda-redo-command 'last-args))))
2535 (gprops (nth 1 series))
2536 match ;; The byte compiler incorrectly complains about this. Keep it!
2538 (while (setq cmd (pop cmds))
2539 (setq type (car cmd) match (eval (nth 1 cmd)) lprops (nth 2 cmd))
2542 (org-let2 gprops lprops
2543 '(call-interactively 'org-agenda-list)))
2545 (org-let2 gprops lprops
2546 '(call-interactively 'org-todo-list)))
2548 (org-let2 gprops lprops
2549 '(org-search-view current-prefix-arg match nil)))
2551 (org-let2 gprops lprops
2552 '(call-interactively 'org-agenda-list-stuck-projects)))
2554 (org-let2 gprops lprops
2555 '(org-tags-view current-prefix-arg match)))
2556 ((eq type 'tags-todo)
2557 (org-let2 gprops lprops
2558 '(org-tags-view '(4) match)))
2560 (org-let2 gprops lprops
2561 '(org-todo-list match)))
2563 (org-let2 gprops lprops
2564 '(funcall type match)))
2565 (t (error "Invalid type in command series"))))
2567 (setq org-agenda-redo-command redo)
2568 (put 'org-agenda-redo-command 'last-args org-agenda-last-arguments)
2569 (goto-char (point-min)))
2570 (org-fit-agenda-window)
2571 (org-let (nth 1 series) '(org-finalize-agenda)))
2574 (defmacro org-batch-agenda (cmd-key &rest parameters)
2575 "Run an agenda command in batch mode and send the result to STDOUT.
2576 If CMD-KEY is a string of length 1, it is used as a key in
2577 `org-agenda-custom-commands' and triggers this command. If it is a
2578 longer string it is used as a tags/todo match string.
2579 Parameters are alternating variable names and values that will be bound
2580 before running the agenda command."
2583 (push (list (pop parameters) (if parameters (pop parameters))) pars))
2584 (if (> (length cmd-key) 2)
2585 (eval (list 'let (nreverse pars)
2586 (list 'org-tags-view nil cmd-key)))
2587 (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
2588 (set-buffer org-agenda-buffer-name)
2589 (princ (org-encode-for-stdout (buffer-string)))))
2591 ;(defun org-encode-for-stdout (string)
2592 ; (if (fboundp 'encode-coding-string)
2593 ; (encode-coding-string string buffer-file-coding-system)
2596 (defun org-encode-for-stdout (string)
2599 (defvar org-agenda-info nil)
2602 (defmacro org-batch-agenda-csv (cmd-key &rest parameters)
2603 "Run an agenda command in batch mode and send the result to STDOUT.
2604 If CMD-KEY is a string of length 1, it is used as a key in
2605 `org-agenda-custom-commands' and triggers this command. If it is a
2606 longer string it is used as a tags/todo match string.
2607 Parameters are alternating variable names and values that will be bound
2608 before running the agenda command.
2610 The output gives a line for each selected agenda item. Each
2611 item is a list of comma-separated values, like this:
2613 category,head,type,todo,tags,date,time,extra,priority-l,priority-n
2615 category The category of the item
2616 head The headline, without TODO kwd, TAGS and PRIORITY
2617 type The type of the agenda entry, can be
2618 todo selected in TODO match
2619 tagsmatch selected in tags match
2620 diary imported from diary
2621 deadline a deadline on given date
2622 scheduled scheduled on given date
2623 timestamp entry has timestamp on given date
2624 closed entry was closed on given date
2625 upcoming-deadline warning about deadline
2626 past-scheduled forwarded scheduled item
2627 block entry has date block including g. date
2628 todo The todo keyword, if any
2629 tags All tags including inherited ones, separated by colons
2630 date The relevant date, like 2007-2-14
2631 time The time, like 15:00-16:50
2632 extra Sting with extra planning info
2633 priority-l The priority letter if any was given
2634 priority-n The computed numerical priority
2635 agenda-day The day in the agenda where this is listed"
2639 (push (list (pop parameters) (if parameters (pop parameters))) pars))
2640 (push (list 'org-agenda-remove-tags t) pars)
2641 (if (> (length cmd-key) 2)
2642 (eval (list 'let (nreverse pars)
2643 (list 'org-tags-view nil cmd-key)))
2644 (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
2645 (set-buffer org-agenda-buffer-name)
2646 (let* ((lines (org-split-string (buffer-string) "\n"))
2648 (while (setq line (pop lines))
2650 (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
2651 (setq org-agenda-info
2652 (org-fix-agenda-info (text-properties-at 0 line)))
2654 (org-encode-for-stdout
2655 (mapconcat 'org-agenda-export-csv-mapper
2656 '(org-category txt type todo tags date time extra
2657 priority-letter priority agenda-day)
2661 (defun org-fix-agenda-info (props)
2662 "Make sure all properties on an agenda item have a canonical form.
2663 This ensures the export commands can easily use it."
2665 (when (setq tmp (plist-get props 'tags))
2666 (setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
2667 (when (setq tmp (plist-get props 'date))
2668 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
2669 (let ((calendar-date-display-form '(year "-" month "-" day)))
2670 '((format "%4d, %9s %2s, %4s" dayname monthname day year))
2672 (setq tmp (calendar-date-string tmp)))
2673 (setq props (plist-put props 'date tmp)))
2674 (when (setq tmp (plist-get props 'day))
2675 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
2676 (let ((calendar-date-display-form '(year "-" month "-" day)))
2677 (setq tmp (calendar-date-string tmp)))
2678 (setq props (plist-put props 'day tmp))
2679 (setq props (plist-put props 'agenda-day tmp)))
2680 (when (setq tmp (plist-get props 'txt))
2681 (when (string-match "\\[#\\([A-Z0-9]\\)\\] ?" tmp)
2682 (plist-put props 'priority-letter (match-string 1 tmp))
2683 (setq tmp (replace-match "" t t tmp)))
2684 (when (and (setq re (plist-get props 'org-todo-regexp))
2685 (setq re (concat "\\`\\.*" re " ?"))
2686 (string-match re tmp))
2687 (plist-put props 'todo (match-string 1 tmp))
2688 (setq tmp (replace-match "" t t tmp)))
2689 (plist-put props 'txt tmp)))
2692 (defun org-agenda-export-csv-mapper (prop)
2693 (let ((res (plist-get org-agenda-info prop)))
2698 (t (prin1-to-string res))))
2699 (while (string-match "," res)
2700 (setq res (replace-match ";" t t res)))
2705 (defun org-store-agenda-views (&rest parameters)
2707 (eval (list 'org-batch-store-agenda-views)))
2709 ;; FIXME, why is this a macro?????
2711 (defmacro org-batch-store-agenda-views (&rest parameters)
2712 "Run all custom agenda commands that have a file argument."
2713 (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
2715 (dir default-directory)
2716 pars cmd thiscmdkey files opts cmd-or-set)
2718 (push (list (pop parameters) (if parameters (pop parameters))) pars))
2719 (setq pars (reverse pars))
2720 (save-window-excursion
2722 (setq cmd (pop cmds)
2723 thiscmdkey (car cmd)
2724 cmd-or-set (nth 2 cmd)
2725 opts (nth (if (listp cmd-or-set) 3 4) cmd)
2726 files (nth (if (listp cmd-or-set) 4 5) cmd))
2727 (if (stringp files) (setq files (list files)))
2729 (eval (list 'let (append org-agenda-exporter-settings opts pars)
2730 (list 'org-agenda nil thiscmdkey)))
2731 (set-buffer org-agenda-buffer-name)
2733 (eval (list 'let (append org-agenda-exporter-settings opts pars)
2734 (list 'org-write-agenda
2735 (expand-file-name (pop files) dir) nil t))))
2736 (and (get-buffer org-agenda-buffer-name)
2737 (kill-buffer org-agenda-buffer-name)))))))
2739 (defun org-agenda-mark-header-line (pos)
2740 "Mark the line at POS as an agenda structure header."
2743 (put-text-property (point-at-bol) (point-at-eol)
2744 'org-agenda-structural-header t)
2745 (when org-agenda-title-append
2746 (put-text-property (point-at-bol) (point-at-eol)
2747 'org-agenda-title-append org-agenda-title-append))))
2749 (defvar org-mobile-creating-agendas)
2750 (defun org-write-agenda (file &optional open nosettings)
2751 "Write the current buffer (an agenda view) as a file.
2752 Depending on the extension of the file name, plain text (.txt),
2753 HTML (.html or .htm) or Postscript (.ps) is produced.
2754 If the extension is .ics, run icalendar export over all files used
2755 to construct the agenda and limit the export to entries listed in the
2757 With prefix argument OPEN, open the new file immediately.
2758 If NOSETTINGS is given, do not scope the settings of
2759 `org-agenda-exporter-settings' into the export commands. This is used when
2760 the settings have already been scoped and we do not wish to overrule other,
2761 higher priority settings."
2762 (interactive "FWrite agenda to file: \nP")
2763 (if (not (file-writable-p file))
2764 (error "Cannot write agenda to file %s" file))
2765 (org-let (if nosettings nil org-agenda-exporter-settings)
2767 (save-window-excursion
2768 (org-agenda-mark-filtered-text)
2769 (let ((bs (copy-sequence (buffer-string))) beg)
2770 (org-agenda-unmark-filtered-text)
2772 (rename-buffer "Agenda View" t)
2773 (set-buffer-modified-p nil)
2775 (org-agenda-remove-marked-text 'org-filtered)
2776 (while (setq beg (text-property-any (point-min) (point-max)
2779 beg (or (next-single-property-change beg 'org-filtered)
2781 (run-hooks 'org-agenda-before-write-hook)
2783 ((org-bound-and-true-p org-mobile-creating-agendas)
2784 (org-mobile-write-agenda-for-mobile file))
2785 ((string-match "\\.html?\\'" file)
2787 (set-buffer (htmlize-buffer (current-buffer)))
2789 (when (and org-agenda-export-html-style
2790 (string-match "<style>" org-agenda-export-html-style))
2791 ;; replace <style> section with org-agenda-export-html-style
2792 (goto-char (point-min))
2793 (kill-region (- (search-forward "<style") 6)
2794 (search-forward "</style>"))
2795 (insert org-agenda-export-html-style))
2797 (kill-buffer (current-buffer))
2798 (message "HTML written to %s" file))
2799 ((string-match "\\.ps\\'" file)
2801 (ps-print-buffer-with-faces file)
2802 (message "Postscript written to %s" file))
2803 ((string-match "\\.pdf\\'" file)
2805 (ps-print-buffer-with-faces
2806 (concat (file-name-sans-extension file) ".ps"))
2807 (call-process "ps2pdf" nil nil nil
2809 (concat (file-name-sans-extension file) ".ps"))
2810 (expand-file-name file))
2811 (delete-file (concat (file-name-sans-extension file) ".ps"))
2812 (message "PDF written to %s" file))
2813 ((string-match "\\.ics\\'" file)
2814 (require 'org-icalendar)
2815 (let ((org-agenda-marker-table
2816 (org-create-marker-find-array
2817 (org-agenda-collect-markers)))
2818 (org-icalendar-verify-function 'org-check-agenda-marker-table)
2819 (org-combined-agenda-icalendar-file file))
2820 (apply 'org-export-icalendar 'combine
2821 (org-agenda-files nil 'ifmode))))
2823 (let ((bs (buffer-string)))
2828 (kill-buffer (current-buffer))
2829 (message "Plain text written to %s" file))))))))
2830 (set-buffer org-agenda-buffer-name))
2831 (when open (org-open-file file)))
2833 (defvar org-agenda-filter-overlays nil)
2835 (defun org-agenda-mark-filtered-text ()
2836 "Mark all text hidden by filtering with a text property."
2837 (let ((inhibit-read-only t))
2840 (when (equal (overlay-buffer o) (current-buffer))
2842 (overlay-start o) (overlay-end o)
2844 org-agenda-filter-overlays)))
2846 (defun org-agenda-unmark-filtered-text ()
2847 "Remove the filtering text property."
2848 (let ((inhibit-read-only t))
2849 (remove-text-properties (point-min) (point-max) '(org-filtered t))))
2851 (defun org-agenda-remove-marked-text (property &optional value)
2852 "Delete all text marked with VALUE of PROPERTY.
2853 VALUE defaults to t."
2855 (setq value (or value t))
2856 (while (setq beg (text-property-any (point-min) (point-max)
2859 beg (or (next-single-property-change beg 'org-filtered)
2862 (defun org-agenda-add-entry-text ()
2863 "Add entry text to agenda lines.
2864 This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the
2865 entry text following headings shown in the agenda.
2866 Drawers will be excluded, also the line with scheduling/deadline info."
2867 (when (and (> org-agenda-add-entry-text-maxlines 0)
2868 (not (org-bound-and-true-p org-mobile-creating-agendas)))
2870 (goto-char (point-min))
2872 (if (not (setq m (org-get-at-bol 'org-hd-marker)))
2873 (beginning-of-line 2)
2874 (setq txt (org-agenda-get-some-entry-text
2875 m org-agenda-add-entry-text-maxlines " > "))
2877 (if (string-match "\\S-" txt)
2879 (or (eobp) (forward-char 1))))))))
2881 (defun org-agenda-get-some-entry-text (marker n-lines &optional indent
2883 "Extract entry text from MARKER, at most N-LINES lines.
2884 This will ignore drawers etc, just get the text.
2885 If INDENT is given, prefix every line with this string. If KEEP is
2886 given, it is a list of symbols, defining stuff that should not be
2887 removed from the entry content. Currently only `planning' is allowed here."
2888 (let (txt drawer-re kwd-time-re ind)
2890 (with-current-buffer (marker-buffer marker)
2891 (if (not (org-mode-p))
2898 (setq txt (buffer-substring
2899 (min (1+ (point)) (point-max))
2900 (progn (outline-next-heading) (point)))
2901 drawer-re org-drawer-regexp
2902 kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
2906 (when org-agenda-add-entry-text-descriptive-links
2907 (goto-char (point-min))
2908 (while (org-activate-bracket-links (point-max))
2909 (add-text-properties (match-beginning 0) (match-end 0)
2911 (goto-char (point-min))
2912 (while (re-search-forward org-bracket-link-regexp (point-max) t)
2913 (set-text-properties (match-beginning 0) (match-end 0)
2915 (goto-char (point-min))
2916 (while (re-search-forward drawer-re nil t)
2919 (progn (re-search-forward
2920 "^[ \t]*:END:.*\n?" nil 'move)
2922 (unless (member 'planning keep)
2923 (goto-char (point-min))
2924 (while (re-search-forward kwd-time-re nil t)
2925 (replace-match "")))
2926 (goto-char (point-min))
2927 (when org-agenda-entry-text-exclude-regexps
2928 (let ((re-list org-agenda-entry-text-exclude-regexps) re)
2929 (while (setq re (pop re-list))
2930 (goto-char (point-min))
2931 (while (re-search-forward re nil t)
2932 (replace-match "")))))
2933 (goto-char (point-max))
2934 (skip-chars-backward " \t\n")
2935 (if (looking-at "[ \t\n]+\\'") (replace-match ""))
2937 ;; find and remove min common indentation
2938 (goto-char (point-min))
2939 (untabify (point-min) (point-max))
2940 (setq ind (org-get-indentation))
2942 (unless (looking-at "[ \t]*$")
2943 (setq ind (min ind (org-get-indentation))))
2944 (beginning-of-line 2))
2945 (goto-char (point-min))
2947 (unless (looking-at "[ \t]*$")
2948 (move-to-column ind)
2949 (delete-region (point-at-bol) (point)))
2950 (beginning-of-line 2))
2952 (run-hooks 'org-agenda-entry-text-cleanup-hook)
2954 (goto-char (point-min))
2956 (while (and (not (eobp)) (re-search-forward "^" nil t))
2957 (replace-match indent t t)))
2958 (goto-char (point-min))
2959 (while (looking-at "[ \t]*\n") (replace-match ""))
2960 (goto-char (point-max))
2961 (when (> (org-current-line)
2963 (org-goto-line (1+ n-lines))
2965 (setq txt (buffer-substring (point-min) (point)))))))))
2968 (defun org-agenda-collect-markers ()
2969 "Collect the markers pointing to entries in the agenda buffer."
2972 (goto-char (point-min))
2974 (when (setq m (or (org-get-at-bol 'org-hd-marker)
2975 (org-get-at-bol 'org-marker)))
2977 (beginning-of-line 2)))
2978 (nreverse markers)))
2980 (defun org-create-marker-find-array (marker-list)
2981 "Create a alist of files names with all marker positions in that file."
2983 (while (setq m (pop marker-list))
2984 (setq p (marker-position m)
2985 f (buffer-file-name (or (buffer-base-buffer
2987 (marker-buffer m))))
2988 (if (setq a (assoc f tbl))
2989 (push (marker-position m) (cdr a))
2990 (push (list f p) tbl)))
2991 (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
2994 (defvar org-agenda-marker-table nil) ; dynamically scoped parameter
2995 (defun org-check-agenda-marker-table ()
2996 "Check of the current entry is on the marker list."
2997 (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
2999 (and (setq a (assoc file org-agenda-marker-table))
3002 (org-back-to-heading t)
3003 (member (point) (cdr a)))))))
3005 (defun org-check-for-org-mode ()
3006 "Make sure current buffer is in org-mode. Error if not."
3008 (error "Cannot execute org-mode agenda command on buffer in %s"
3011 (defun org-fit-agenda-window ()
3012 "Fit the window to the buffer size."
3013 (and (memq org-agenda-window-setup '(reorganize-frame))
3014 (fboundp 'fit-window-to-buffer)
3015 (org-fit-window-to-buffer
3017 (floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
3018 (floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
3020 ;;; Agenda prepare and finalize
3022 (defvar org-agenda-multi nil) ; dynamically scoped
3023 (defvar org-agenda-buffer-name "*Org Agenda*")
3024 (defvar org-pre-agenda-window-conf nil)
3025 (defvar org-agenda-columns-active nil)
3026 (defvar org-agenda-name nil)
3027 (defvar org-agenda-filter nil)
3028 (defvar org-agenda-filter-while-redo nil)
3029 (defvar org-agenda-filter-preset nil
3030 "A preset of the tags filter used for secondary agenda filtering.
3031 This must be a list of strings, each string must be a single tag preceded
3033 This variable should not be set directly, but agenda custom commands can
3034 bind it in the options section. The preset filter is a global property of
3035 the entire agenda view. In a block agenda, it will not work reliably to
3036 define a filter for one of the individual blocks. You need to set it in
3037 the global options and expect it to be applied to the entire view.")
3039 (defun org-prepare-agenda (&optional name)
3040 (setq org-todo-keywords-for-agenda nil)
3041 (setq org-done-keywords-for-agenda nil)
3042 (setq org-drawers-for-agenda nil)
3043 (unless org-agenda-persistent-filter
3044 (setq org-agenda-filter nil))
3045 (put 'org-agenda-filter :preset-filter org-agenda-filter-preset)
3046 (if org-agenda-multi
3048 (setq buffer-read-only nil)
3049 (goto-char (point-max))
3050 (unless (or (bobp) org-agenda-compact-blocks
3051 (not org-agenda-block-separator))
3053 (if (stringp org-agenda-block-separator)
3054 org-agenda-block-separator
3055 (make-string (window-width) org-agenda-block-separator))
3057 (narrow-to-region (point) (point-max)))
3058 (org-agenda-reset-markers)
3059 (setq org-agenda-contributing-files nil)
3060 (setq org-agenda-columns-active nil)
3061 (org-prepare-agenda-buffers (org-agenda-files nil 'ifmode))
3062 (setq org-todo-keywords-for-agenda
3063 (org-uniquify org-todo-keywords-for-agenda))
3064 (setq org-done-keywords-for-agenda
3065 (org-uniquify org-done-keywords-for-agenda))
3066 (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
3067 (let* ((abuf (get-buffer-create org-agenda-buffer-name))
3068 (awin (get-buffer-window abuf)))
3070 ((equal (current-buffer) abuf) nil)
3071 (awin (select-window awin))
3072 ((not (setq org-pre-agenda-window-conf (current-window-configuration))))
3073 ((equal org-agenda-window-setup 'current-window)
3074 (switch-to-buffer abuf))
3075 ((equal org-agenda-window-setup 'other-window)
3076 (org-switch-to-buffer-other-window abuf))
3077 ((equal org-agenda-window-setup 'other-frame)
3078 (switch-to-buffer-other-frame abuf))
3079 ((equal org-agenda-window-setup 'reorganize-frame)
3080 (delete-other-windows)
3081 (org-switch-to-buffer-other-window abuf)))
3082 ;; additional test in case agenda is invoked from within agenda
3083 ;; buffer via elisp link
3084 (unless (equal (current-buffer) abuf)
3085 (switch-to-buffer abuf)))
3086 (setq buffer-read-only nil)
3087 (let ((inhibit-read-only t)) (erase-buffer))
3089 (and name (not org-agenda-name)
3090 (org-set-local 'org-agenda-name name)))
3091 (setq buffer-read-only nil))
3093 (defun org-finalize-agenda ()
3094 "Finishing touch for the agenda buffer, called just before displaying it."
3095 (unless org-agenda-multi
3097 (let ((inhibit-read-only t))
3098 (goto-char (point-min))
3099 (while (org-activate-bracket-links (point-max))
3100 (add-text-properties (match-beginning 0) (match-end 0)
3102 (org-agenda-align-tags)
3103 (unless org-agenda-with-colors
3104 (remove-text-properties (point-min) (point-max) '(face nil))))
3105 (if (and (boundp 'org-agenda-overriding-columns-format)
3106 org-agenda-overriding-columns-format)
3107 (org-set-local 'org-agenda-overriding-columns-format
3108 org-agenda-overriding-columns-format))
3109 (if (and (boundp 'org-agenda-view-columns-initially)
3110 org-agenda-view-columns-initially)
3111 (org-agenda-columns))
3112 (when org-agenda-fontify-priorities
3113 (org-agenda-fontify-priorities))
3114 (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
3115 (org-agenda-dim-blocked-tasks))
3116 (org-agenda-mark-clocking-task)
3117 (when org-agenda-entry-text-mode
3118 (org-agenda-entry-text-hide)
3119 (org-agenda-entry-text-show))
3120 (if (functionp 'org-habit-insert-consistency-graphs)
3121 (org-habit-insert-consistency-graphs))
3122 (run-hooks 'org-finalize-agenda-hook)
3123 (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
3124 (when (or org-agenda-filter (get 'org-agenda-filter :preset-filter))
3125 (org-agenda-filter-apply org-agenda-filter))
3128 (defun org-agenda-mark-clocking-task ()
3129 "Mark the current clock entry in the agenda if it is present."
3131 (if (eq (overlay-get o 'type) 'org-agenda-clocking)
3132 (delete-overlay o)))
3133 (overlays-in (point-min) (point-max)))
3134 (when (marker-buffer org-clock-hd-marker)
3136 (goto-char (point-min))
3138 (while (setq s (next-single-property-change (point) 'org-hd-marker))
3140 (when (equal (org-get-at-bol 'org-hd-marker)
3141 org-clock-hd-marker)
3142 (setq ov (make-overlay (point-at-bol) (1+ (point-at-eol))))
3143 (overlay-put ov 'type 'org-agenda-clocking)
3144 (overlay-put ov 'face 'org-agenda-clocking)
3145 (overlay-put ov 'help-echo
3146 "The clock is running in this item")))))))
3148 (defun org-agenda-fontify-priorities ()
3149 "Make highest priority lines bold, and lowest italic."
3151 (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-priority)
3152 (delete-overlay o)))
3153 (overlays-in (point-min) (point-max)))
3155 (let ((inhibit-read-only t)
3157 (goto-char (point-min))
3158 (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
3159 (setq h (or (get-char-property (point) 'org-highest-priority)
3160 org-highest-priority)
3161 l (or (get-char-property (point) 'org-lowest-priority)
3162 org-lowest-priority)
3163 p (string-to-char (match-string 1))
3164 b (match-beginning 0)
3165 e (if (eq org-agenda-fontify-priorities 'cookies)
3168 ov (make-overlay b e))
3171 (cond ((org-face-from-face-or-color
3173 (cdr (assoc p org-priority-faces))))
3174 ((and (listp org-agenda-fontify-priorities)
3175 (org-face-from-face-or-color
3177 (cdr (assoc p org-agenda-fontify-priorities)))))
3178 ((equal p l) 'italic)
3179 ((equal p h) 'bold)))
3180 (overlay-put ov 'org-type 'org-priority)))))
3182 (defun org-agenda-dim-blocked-tasks ()
3183 "Dim currently blocked TODO's in the agenda display."
3184 (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-blocked-todo)
3185 (delete-overlay o)))
3186 (overlays-in (point-min) (point-max)))
3188 (let ((inhibit-read-only t)
3189 (org-depend-tag-blocked nil)
3190 (invis (eq org-agenda-dim-blocked-tasks 'invisible))
3191 org-blocked-by-checkboxes
3192 invis1 b e p ov h l)
3193 (goto-char (point-min))
3194 (while (let ((pos (next-single-property-change (point) 'todo-state)))
3195 (and pos (goto-char (1+ pos))))
3196 (setq org-blocked-by-checkboxes nil invis1 invis)
3197 (let ((marker (org-get-at-bol 'org-hd-marker)))
3199 (not (with-current-buffer (marker-buffer marker)
3202 (if (org-entry-get nil "NOBLOCKING")
3203 t ;; Never block this entry
3204 (run-hook-with-args-until-failure
3206 (list :type 'todo-state-change
3210 (if org-blocked-by-checkboxes (setq invis1 nil))
3212 (max (point-min) (1- (point-at-bol)))
3215 ov (make-overlay b e))
3217 (overlay-put ov 'invisible t)
3218 (overlay-put ov 'face 'org-agenda-dimmed-todo-face))
3219 (overlay-put ov 'org-type 'org-blocked-todo)))))))
3221 (defvar org-agenda-skip-function nil
3222 "Function to be called at each match during agenda construction.
3223 If this function returns nil, the current match should not be skipped.
3224 Otherwise, the function must return a position from where the search
3225 should be continued.
3226 This may also be a Lisp form, it will be evaluated.
3227 Never set this variable using `setq' or so, because then it will apply
3228 to all future agenda commands. If you do want a global skipping condition,
3229 use the option `org-agenda-skip-function-global' instead.
3230 The correct usage for `org-agenda-skip-function' is to bind it with
3231 `let' to scope it dynamically into the agenda-constructing command.
3232 A good way to set it is through options in `org-agenda-custom-commands'.")
3234 (defun org-agenda-skip ()
3235 "Throw to `:skip' in places that should be skipped.
3236 Also moves point to the end of the skipped region, so that search can
3237 continue from there."
3238 (let ((p (point-at-bol)) to)
3239 (and org-agenda-skip-archived-trees (not org-agenda-archives-mode)
3240 (get-text-property p :org-archived)
3241 (org-end-of-subtree t)
3243 (and org-agenda-skip-comment-trees
3244 (get-text-property p :org-comment)
3245 (org-end-of-subtree t)
3247 (if (equal (char-after p) ?#) (throw :skip t))
3248 (when (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global)
3249 (org-agenda-skip-eval org-agenda-skip-function)))
3253 (defun org-agenda-skip-eval (form)
3254 "If FORM is a function or a list, call (or eval) is and return result.
3255 `save-excursion' and `save-match-data' are wrapped around the call, so point
3256 and match data are returned to the previous state no matter what these
3260 (or (setq fp (functionp form))
3268 (defvar org-agenda-markers nil
3269 "List of all currently active markers created by `org-agenda'.")
3270 (defvar org-agenda-last-marker-time (org-float-time)
3271 "Creation time of the last agenda marker.")
3273 (defun org-agenda-new-marker (&optional pos)
3274 "Return a new agenda marker.
3275 Org-mode keeps a list of these markers and resets them when they are
3277 (let ((m (copy-marker (or pos (point)))))
3278 (setq org-agenda-last-marker-time (org-float-time))
3279 (push m org-agenda-markers)
3282 (defun org-agenda-reset-markers ()
3283 "Reset markers created by `org-agenda'."
3284 (while org-agenda-markers
3285 (move-marker (pop org-agenda-markers) nil)))
3287 (defun org-agenda-save-markers-for-cut-and-paste (beg end)
3288 "Save relative positions of markers in region."
3289 (mapc (lambda (m) (org-check-and-save-marker m beg end))
3290 org-agenda-markers))
3294 (defun org-agenda-entry-text-show-here ()
3295 "Add some text from the entry as context to the current line."
3297 (setq m (org-get-at-bol 'org-hd-marker))
3298 (unless (marker-buffer m)
3299 (error "No marker points to an entry here"))
3300 (setq txt (concat "\n" (org-no-properties
3301 (org-agenda-get-some-entry-text
3302 m org-agenda-entry-text-maxlines " > "))))
3303 (when (string-match "\\S-" txt)
3304 (setq o (make-overlay (point-at-bol) (point-at-eol)))
3305 (overlay-put o 'evaporate t)
3306 (overlay-put o 'org-overlay-type 'agenda-entry-content)
3307 (overlay-put o 'after-string txt))))
3309 (defun org-agenda-entry-text-show ()
3310 "Add entry context for all agenda lines."
3313 (goto-char (point-max))
3314 (beginning-of-line 1)
3316 (when (org-get-at-bol 'org-hd-marker)
3317 (org-agenda-entry-text-show-here))
3318 (beginning-of-line 0))))
3320 (defun org-agenda-entry-text-hide ()
3321 "Remove any shown entry context."
3324 (if (eq (overlay-get o 'org-overlay-type)
3325 'agenda-entry-content)
3326 (progn (delete-overlay o) t)))
3327 (overlays-in (point-min) (point-max)))))
3329 (defun org-agenda-get-day-face (date)
3330 "Return the face DATE should be displayed with."
3331 (or (and (functionp org-agenda-day-face-function)
3332 (funcall org-agenda-day-face-function date))
3333 (cond ((org-agenda-todayp date)
3334 'org-agenda-date-today)
3335 ((member (calendar-day-of-week date) org-agenda-weekend-days)
3336 'org-agenda-date-weekend)
3337 (t 'org-agenda-date))))
3341 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
3343 (defun org-timeline (&optional include-all)
3344 "Show a time-sorted view of the entries in the current org file.
3345 Only entries with a time stamp of today or later will be listed. With
3346 \\[universal-argument] prefix, all unfinished TODO items will also be shown,
3347 under the current date.
3348 If the buffer contains an active region, only check the region for
3351 (org-compile-prefix-format 'timeline)
3352 (org-set-sorting-strategy 'timeline)
3354 (dotodo include-all)
3355 (doclosed org-agenda-show-log)
3356 (entry (buffer-file-name (or (buffer-base-buffer (current-buffer))
3358 (date (calendar-current-date))
3359 (beg (if (org-region-active-p) (region-beginning) (point-min)))
3360 (end (if (org-region-active-p) (region-end) (point-max)))
3361 (day-numbers (org-get-all-dates beg end 'no-ranges
3362 t doclosed ; always include today
3363 org-timeline-show-empty-dates))
3364 (org-deadline-warning-days 0)
3365 (org-agenda-only-exact-dates t)
3370 (setq org-agenda-redo-command
3372 (list 'org-switch-to-buffer-other-window (current-buffer))
3373 (list 'org-timeline (list 'quote include-all))))
3375 ;; Remove past dates from the list of dates.
3376 (setq day-numbers (delq nil (mapcar (lambda(x)
3377 (if (>= x today) x nil))