1 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
3 ;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;; This file contains the code for creating and using the Agenda for Org-mode.
29 ;; The functions `org-batch-agenda', `org-batch-agenda-csv', and
30 ;; `org-batch-store-agenda-views' are implemented as macros to provide
31 ;; a convenient way for extracting agenda information from the command
32 ;; line. The Lisp does not evaluate parameters of a macro call; thus
33 ;; it is not necessary to quote the parameters passed to one of those
34 ;; functions. E.g. you can write:
36 ;; emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a" org-agenda-span 7)'
38 ;; To export an agenda spanning 7 days. If `org-batch-agenda' would
39 ;; have been implemented as a regular function you'd have to quote the
40 ;; symbol org-agenda-span. Moreover: To use a symbol as parameter
41 ;; value you would have to double quote the symbol.
43 ;; This is a hack, but it works even when running Org byte-compiled.
52 (declare-function diary-add-to-list "diary-lib"
53 (date string specifier &optional marker globcolor literal))
54 (declare-function calendar-absolute-from-iso "cal-iso" (date))
55 (declare-function calendar-astro-date-string "cal-julian" (&optional date))
56 (declare-function calendar-bahai-date-string "cal-bahai" (&optional date))
57 (declare-function calendar-chinese-date-string "cal-china" (&optional date))
58 (declare-function calendar-coptic-date-string "cal-coptic" (&optional date))
59 (declare-function calendar-ethiopic-date-string "cal-coptic" (&optional date))
60 (declare-function calendar-french-date-string "cal-french" (&optional date))
61 (declare-function calendar-goto-date "cal-move" (date))
62 (declare-function calendar-hebrew-date-string "cal-hebrew" (&optional date))
63 (declare-function calendar-islamic-date-string "cal-islam" (&optional date))
64 (declare-function calendar-iso-date-string "cal-iso" (&optional date))
65 (declare-function calendar-iso-from-absolute "cal-iso" (date))
66 (declare-function calendar-julian-date-string "cal-julian" (&optional date))
67 (declare-function calendar-mayan-date-string "cal-mayan" (&optional date))
68 (declare-function calendar-persian-date-string "cal-persia" (&optional date))
69 (declare-function calendar-check-holidays "holidays" (date))
71 (declare-function org-datetree-find-date-create "org-datetree"
72 (date &optional keep-restriction))
73 (declare-function org-columns-quit "org-colview" ())
74 (declare-function diary-date-display-form "diary-lib" (&optional type))
75 (declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file))
76 (declare-function org-habit-insert-consistency-graphs
77 "org-habit" (&optional line))
78 (declare-function org-is-habit-p "org-habit" (&optional pom))
79 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
80 (declare-function org-habit-get-priority "org-habit" (habit &optional moment))
81 (declare-function org-pop-to-buffer-same-window "org-compat"
82 (&optional buffer-or-name norecord label))
84 (defvar calendar-mode-map)
85 (defvar org-clock-current-task) ; defined in org-clock.el
86 (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
87 (defvar org-habit-show-habits)
88 (defvar org-habit-show-habits-only-for-today)
90 ;; Defined somewhere in this file, but used before definition.
91 (defvar org-agenda-buffer-name)
92 (defvar org-agenda-overriding-header)
93 (defvar org-agenda-title-append nil)
96 (defvar org-agenda-undo-list)
97 (defvar org-agenda-pending-undo-list)
98 (defvar original-date) ; dynamically scoped, calendar.el does scope this
100 (defcustom org-agenda-confirm-kill 1
101 "When set, remote killing from the agenda buffer needs confirmation.
102 When t, a confirmation is always needed. When a number N, confirmation is
103 only needed when the text to be killed contains more than N non-white lines."
106 (const :tag "Never" nil)
107 (const :tag "Always" t)
108 (integer :tag "When more than N lines")))
110 (defcustom org-agenda-compact-blocks nil
111 "Non-nil means make the block agenda more compact.
112 This is done globally by leaving out lines like the agenda span
113 name and week number or the separator lines."
117 (defcustom org-agenda-block-separator ?=
118 "The separator between blocks in the agenda.
119 If this is a string, it will be used as the separator, with a newline added.
120 If it is a character, it will be repeated to fill the window width.
121 If nil the separator is disabled. In `org-agenda-custom-commands' this
122 addresses the separator between the current and the previous block."
125 (const :tag "Disabled" nil)
129 (defgroup org-agenda-export nil
130 "Options concerning exporting agenda views in Org-mode."
131 :tag "Org Agenda Export"
134 (defcustom org-agenda-with-colors t
135 "Non-nil means use colors in agenda views."
136 :group 'org-agenda-export
139 (defcustom org-agenda-exporter-settings nil
140 "Alist of variable/value pairs that should be active during agenda export.
141 This is a good place to set options for ps-print and for htmlize.
142 Note that the way this is implemented, the values will be evaluated
143 before assigned to the variables. So make sure to quote values you do
144 *not* want evaluated, for example
146 (setq org-agenda-exporter-settings
147 '((ps-print-color-p 'black-white)))"
148 :group 'org-agenda-export
152 (sexp :tag "Value"))))
154 (defcustom org-agenda-before-write-hook '(org-agenda-add-entry-text)
155 "Hook run in temporary buffer before writing it to an export file.
156 A useful function is `org-agenda-add-entry-text'."
157 :group 'org-agenda-export
159 :options '(org-agenda-add-entry-text))
161 (defcustom org-agenda-add-entry-text-maxlines 0
162 "Maximum number of entry text lines to be added to agenda.
163 This is only relevant when `org-agenda-add-entry-text' is part of
164 `org-agenda-before-write-hook', which it is by default.
165 When this is 0, nothing will happen. When it is greater than 0, it
166 specifies the maximum number of lines that will be added for each entry
167 that is listed in the agenda view.
169 Note that this variable is not used during display, only when exporting
170 the agenda. For agenda display, see the variables `org-agenda-entry-text-mode'
171 and `org-agenda-entry-text-maxlines'."
175 (defcustom org-agenda-add-entry-text-descriptive-links t
176 "Non-nil means export org-links as descriptive links in agenda added text.
177 This variable applies to the text added to the agenda when
178 `org-agenda-add-entry-text-maxlines' is larger than 0.
179 When this variable nil, the URL will (also) be shown."
183 (defcustom org-agenda-export-html-style ""
184 "The style specification for exported HTML Agenda files.
185 If this variable contains a string, it will replace the default <style>
186 section as produced by `htmlize'.
187 Since there are different ways of setting style information, this variable
188 needs to contain the full HTML structure to provide a style, including the
189 surrounding HTML tags. The style specifications should include definitions
190 the fonts used by the agenda, here is an example:
192 <style type=\"text/css\">
193 p { font-weight: normal; color: gray; }
194 .org-agenda-structure {
209 .title { text-align: center; }
210 .todo, .deadline { color: red; }
211 .done { color: green; }
214 or, if you want to keep the style in a file,
216 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
218 As the value of this option simply gets inserted into the HTML <head> header,
219 you can \"misuse\" it to also add other text to the header. However,
220 <style>...</style> is required, if not present the variable will be ignored."
221 :group 'org-agenda-export
222 :group 'org-export-html
225 (defcustom org-agenda-persistent-filter nil
226 "When set, keep filters from one agenda view to the next."
230 (defgroup org-agenda-custom-commands nil
231 "Options concerning agenda views in Org-mode."
232 :tag "Org Agenda Custom Commands"
235 (defconst org-sorting-choice
237 (const time-up) (const time-down)
238 (const category-keep) (const category-up) (const category-down)
239 (const tag-down) (const tag-up)
240 (const priority-up) (const priority-down)
241 (const todo-state-up) (const todo-state-down)
242 (const effort-up) (const effort-down)
243 (const habit-up) (const habit-down)
244 (const alpha-up) (const alpha-down)
245 (const user-defined-up) (const user-defined-down))
248 ;; Keep custom values for `org-agenda-filter-preset' compatible with
249 ;; the new variable `org-agenda-tag-filter-preset'.
250 (if (fboundp 'defvaralias)
251 (defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
252 (defvaralias 'org-agenda-filter 'org-agenda-tag-filter))
254 (defconst org-agenda-custom-commands-local-options
255 `(repeat :tag "Local settings for this command. Remember to quote values"
256 (choice :tag "Setting"
257 (list :tag "Heading for this block"
258 (const org-agenda-overriding-header)
259 (string :tag "Headline"))
260 (list :tag "Files to be searched"
261 (const org-agenda-files)
263 (const :format "" quote)
265 (list :tag "Sorting strategy"
266 (const org-agenda-sorting-strategy)
268 (const :format "" quote)
270 ,org-sorting-choice)))
271 (list :tag "Prefix format"
272 (const org-agenda-prefix-format :value " %-12:c%?-12t% s")
274 (list :tag "Number of days in agenda"
275 (const org-agenda-span)
276 (choice (const :tag "Day" 'day)
277 (const :tag "Week" 'week)
278 (const :tag "Month" 'month)
279 (const :tag "Year" 'year)
280 (integer :tag "Custom")))
281 (list :tag "Fixed starting date"
282 (const org-agenda-start-day)
283 (string :value "2007-11-01"))
284 (list :tag "Start on day of week"
285 (const org-agenda-start-on-weekday)
287 (const :tag "Today" nil)
288 (integer :tag "Weekday No.")))
289 (list :tag "Include data from diary"
290 (const org-agenda-include-diary)
292 (list :tag "Deadline Warning days"
293 (const org-deadline-warning-days)
295 (list :tag "Category filter preset"
296 (const org-agenda-category-filter-preset)
298 (const :format "" quote)
300 (string :tag "+category or -category"))))
301 (list :tag "Tags filter preset"
302 (const org-agenda-tag-filter-preset)
304 (const :format "" quote)
306 (string :tag "+tag or -tag"))))
307 (list :tag "Set daily/weekly entry types"
308 (const org-agenda-entry-types)
310 (const :format "" quote)
311 (set :greedy t :value (:deadline :scheduled :timestamp :sexp)
316 (list :tag "Standard skipping condition"
317 :value (org-agenda-skip-function '(org-agenda-skip-entry-if))
318 (const org-agenda-skip-function)
320 (const :format "" quote)
323 :tag "Skipping range"
324 (const :tag "Skip entry" org-agenda-skip-entry-if)
325 (const :tag "Skip subtree" org-agenda-skip-subtree-if))
326 (repeat :inline t :tag "Conditions for skipping"
328 :tag "Condition type"
329 (list :tag "Regexp matches" :inline t (const :format "" 'regexp) (regexp))
330 (list :tag "Regexp does not match" :inline t (const :format "" 'notregexp) (regexp))
331 (list :tag "TODO state is" :inline t
334 (const :tag "any not-done state" 'todo)
335 (const :tag "any done state" 'done)
336 (const :tag "any state" 'any)
337 (list :tag "Keyword list"
338 (const :format "" quote)
339 (repeat (string :tag "Keyword")))))
340 (list :tag "TODO state is not" :inline t
343 (const :tag "any not-done state" 'todo)
344 (const :tag "any done state" 'done)
345 (const :tag "any state" 'any)
346 (list :tag "Keyword list"
347 (const :format "" quote)
348 (repeat (string :tag "Keyword")))))
349 (const :tag "scheduled" 'scheduled)
350 (const :tag "not scheduled" 'notscheduled)
351 (const :tag "deadline" 'deadline)
352 (const :tag "no deadline" 'notdeadline)
353 (const :tag "timestamp" 'timestamp)
354 (const :tag "no timestamp" 'nottimestamp))))))
355 (list :tag "Non-standard skipping condition"
356 :value (org-agenda-skip-function)
357 (const org-agenda-skip-function)
358 (sexp :tag "Function or form (quoted!)"))
359 (list :tag "Any variable"
360 (variable :tag "Variable")
361 (sexp :tag "Value (sexp)"))))
362 "Selection of examples for agenda command settings.
363 This will be spliced into the custom type of
364 `org-agenda-custom-commands'.")
367 (defcustom org-agenda-custom-commands '(("n" "Agenda and all TODO's"
368 ((agenda "") (alltodo))))
369 "Custom commands for the agenda.
370 These commands will be offered on the splash screen displayed by the
371 agenda dispatcher \\[org-agenda]. Each entry is a list like this:
373 (key desc type match settings files)
375 key The key (one or more characters as a string) to be associated
377 desc A description of the command, when omitted or nil, a default
378 description is built using MATCH.
379 type The command type, any of the following symbols:
380 agenda The daily/weekly agenda.
381 todo Entries with a specific TODO keyword, in all agenda files.
382 search Entries containing search words entry or headline.
383 tags Tags/Property/TODO match in all agenda files.
384 tags-todo Tags/P/T match in all agenda files, TODO entries only.
385 todo-tree Sparse tree of specific TODO keyword in *current* file.
386 tags-tree Sparse tree with all tags matches in *current* file.
387 occur-tree Occur sparse tree for *current* file.
388 ... A user-defined function.
389 match What to search for:
390 - a single keyword for TODO keyword searches
391 - a tags match expression for tags searches
392 - a word search expression for text searches.
393 - a regular expression for occur searches
394 For all other commands, this should be the empty string.
395 settings A list of option settings, similar to that in a let form, so like
396 this: ((opt1 val1) (opt2 val2) ...). The values will be
397 evaluated at the moment of execution, so quote them when needed.
398 files A list of files file to write the produced agenda buffer to
399 with the command `org-store-agenda-views'.
400 If a file name ends in \".html\", an HTML version of the buffer
401 is written out. If it ends in \".ps\", a postscript version is
402 produced. Otherwise, only the plain text is written to the file.
404 You can also define a set of commands, to create a composite agenda buffer.
405 In this case, an entry looks like this:
407 (key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
411 desc A description string to be displayed in the dispatcher menu.
412 cmd An agenda command, similar to the above. However, tree commands
413 are not allowed, but instead you can get agenda and global todo list.
414 So valid commands for a set are:
415 (agenda \"\" settings)
416 (alltodo \"\" settings)
417 (stuck \"\" settings)
418 (todo \"match\" settings files)
419 (search \"match\" settings files)
420 (tags \"match\" settings files)
421 (tags-todo \"match\" settings files)
423 Each command can carry a list of options, and another set of options can be
424 given for the whole set of commands. Individual command options take
425 precedence over the general options.
427 When using several characters as key to a command, the first characters
428 are prefix commands. For the dispatcher to display useful information, you
429 should provide a description for the prefix, like
431 (setq org-agenda-custom-commands
432 '((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\"
433 (\"hl\" tags \"+HOME+Lisa\")
434 (\"hp\" tags \"+HOME+Peter\")
435 (\"hk\" tags \"+HOME+Kim\")))"
436 :group 'org-agenda-custom-commands
438 (choice :value ("x" "Describe command here" tags "" nil)
439 (list :tag "Single command"
440 (string :tag "Access Key(s) ")
441 (option (string :tag "Description"))
443 (const :tag "Agenda" agenda)
444 (const :tag "TODO list" alltodo)
445 (const :tag "Search words" search)
446 (const :tag "Stuck projects" stuck)
447 (const :tag "Tags/Property match (all agenda files)" tags)
448 (const :tag "Tags/Property match of TODO entries (all agenda files)" tags-todo)
449 (const :tag "TODO keyword search (all agenda files)" todo)
450 (const :tag "Tags sparse tree (current buffer)" tags-tree)
451 (const :tag "TODO keyword tree (current buffer)" todo-tree)
452 (const :tag "Occur tree (current buffer)" occur-tree)
453 (sexp :tag "Other, user-defined function"))
454 (string :tag "Match (only for some commands)")
455 ,org-agenda-custom-commands-local-options
456 (option (repeat :tag "Export" (file :tag "Export to"))))
457 (list :tag "Command series, all agenda files"
458 (string :tag "Access Key(s)")
459 (string :tag "Description ")
460 (repeat :tag "Component"
463 (const :format "" agenda)
464 (const :tag "" :format "" "")
465 ,org-agenda-custom-commands-local-options)
466 (list :tag "TODO list (all keywords)"
467 (const :format "" alltodo)
468 (const :tag "" :format "" "")
469 ,org-agenda-custom-commands-local-options)
470 (list :tag "Search words"
471 (const :format "" search)
472 (string :tag "Match")
473 ,org-agenda-custom-commands-local-options)
474 (list :tag "Stuck projects"
475 (const :format "" stuck)
476 (const :tag "" :format "" "")
477 ,org-agenda-custom-commands-local-options)
478 (list :tag "Tags search"
479 (const :format "" tags)
480 (string :tag "Match")
481 ,org-agenda-custom-commands-local-options)
482 (list :tag "Tags search, TODO entries only"
483 (const :format "" tags-todo)
484 (string :tag "Match")
485 ,org-agenda-custom-commands-local-options)
486 (list :tag "TODO keyword search"
487 (const :format "" todo)
488 (string :tag "Match")
489 ,org-agenda-custom-commands-local-options)
490 (list :tag "Other, user-defined function"
491 (symbol :tag "function")
492 (string :tag "Match")
493 ,org-agenda-custom-commands-local-options)))
495 (repeat :tag "Settings for entire command set"
496 (list (variable :tag "Any variable")
497 (sexp :tag "Value")))
498 (option (repeat :tag "Export" (file :tag "Export to"))))
499 (cons :tag "Prefix key documentation"
500 (string :tag "Access Key(s)")
501 (string :tag "Description ")))))
503 (defcustom org-agenda-query-register ?o
504 "The register holding the current query string.
505 The purpose of this is that if you construct a query string interactively,
506 you can then use it to define a custom command."
507 :group 'org-agenda-custom-commands
510 (defcustom org-stuck-projects
511 '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "")
512 "How to identify stuck projects.
513 This is a list of four items:
514 1. A tags/todo/property matcher string that is used to identify a project.
515 See the manual for a description of tag and property searches.
516 The entire tree below a headline matched by this is considered one project.
517 2. A list of TODO keywords identifying non-stuck projects.
518 If the project subtree contains any headline with one of these todo
519 keywords, the project is considered to be not stuck. If you specify
520 \"*\" as a keyword, any TODO keyword will mark the project unstuck.
521 3. A list of tags identifying non-stuck projects.
522 If the project subtree contains any headline with one of these tags,
523 the project is considered to be not stuck. If you specify \"*\" as
524 a tag, any tag will mark the project unstuck. Note that this is about
525 the explicit presence of a tag somewhere in the subtree, inherited
526 tags to not count here. If inherited tags make a project not stuck,
527 use \"-TAG\" in the tags part of the matcher under (1.) above.
528 4. An arbitrary regular expression matching non-stuck projects.
530 If the project turns out to be not stuck, search continues also in the
531 subtree to see if any of the subtasks have project status.
533 See also the variable `org-tags-match-list-sublevels' which applies
534 to projects matched by this search as well.
536 After defining this variable, you may use \\[org-agenda-list-stuck-projects]
537 or `C-c a #' to produce the list."
538 :group 'org-agenda-custom-commands
540 (string :tag "Tags/TODO match to identify a project")
541 (repeat :tag "Projects are *not* stuck if they have an entry with TODO keyword any of" (string))
542 (repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string))
543 (regexp :tag "Projects are *not* stuck if this regexp matches inside the subtree")))
545 (defcustom org-agenda-filter-effort-default-operator "<"
546 "The default operator for effort estimate filtering.
547 If you select an effort estimate limit without first pressing an operator,
548 this one will be used."
549 :group 'org-agenda-custom-commands
550 :type '(choice (const :tag "less or equal" "<")
551 (const :tag "greater or equal"">")
552 (const :tag "equal" "=")))
554 (defgroup org-agenda-skip nil
555 "Options concerning skipping parts of agenda files."
556 :tag "Org Agenda Skip"
559 (defcustom org-agenda-skip-function-global nil
560 "Function to be called at each match during agenda construction.
561 If this function returns nil, the current match should not be skipped.
562 If the function decided to skip an agenda match, is must return the
563 buffer position from which the search should be continued.
564 This may also be a Lisp form, which will be evaluated.
566 This variable will be applied to every agenda match, including
567 tags/property searches and TODO lists. So try to make the test function
568 do its checking as efficiently as possible. To implement a skipping
569 condition just for specific agenda commands, use the variable
570 `org-agenda-skip-function' which can be set in the options section
571 of custom agenda commands."
572 :group 'org-agenda-skip
575 (defgroup org-agenda-daily/weekly nil
576 "Options concerning the daily/weekly agenda."
577 :tag "Org Agenda Daily/Weekly"
579 (defgroup org-agenda-todo-list nil
580 "Options concerning the global todo list agenda view."
581 :tag "Org Agenda Todo List"
583 (defgroup org-agenda-match-view nil
584 "Options concerning the general tags/property/todo match agenda view."
585 :tag "Org Agenda Match View"
587 (defgroup org-agenda-search-view nil
588 "Options concerning the general tags/property/todo match agenda view."
589 :tag "Org Agenda Match View"
592 (defvar org-agenda-archives-mode nil
593 "Non-nil means the agenda will include archived items.
594 If this is the symbol `trees', trees in the selected agenda scope
595 that are marked with the ARCHIVE tag will be included anyway. When this is
596 t, also all archive files associated with the current selection of agenda
597 files will be included.")
599 (defcustom org-agenda-skip-comment-trees t
600 "Non-nil means skip trees that start with the COMMENT keyword.
601 When nil, these trees are also scanned by agenda commands."
602 :group 'org-agenda-skip
605 (defcustom org-agenda-todo-list-sublevels t
606 "Non-nil means check also the sublevels of a TODO entry for TODO entries.
607 When nil, the sublevels of a TODO entry are not checked, resulting in
608 potentially much shorter TODO lists."
609 :group 'org-agenda-skip
610 :group 'org-agenda-todo-list
613 (defcustom org-agenda-todo-ignore-with-date nil
614 "Non-nil means don't show entries with a date in the global todo list.
615 You can use this if you prefer to mark mere appointments with a TODO keyword,
616 but don't want them to show up in the TODO list.
617 When this is set, it also covers deadlines and scheduled items, the settings
618 of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
620 See also the variable `org-agenda-tags-todo-honor-ignore-options'."
621 :group 'org-agenda-skip
622 :group 'org-agenda-todo-list
625 (defcustom org-agenda-todo-ignore-timestamp nil
626 "Non-nil means don't show entries with a timestamp.
627 This applies when creating the global todo list.
630 past Don't show entries for today or in the past.
632 future Don't show entries with a timestamp in the future.
633 The idea behind this is that if it has a future
634 timestamp, you don't want to think about it until the
637 all Don't show any entries with a timestamp in the global todo list.
638 The idea behind this is that by setting a timestamp, you
639 have already \"taken care\" of this item.
641 This variable can also have an integer as a value. If positive (N),
642 todos with a timestamp N or more days in the future will be ignored. If
643 negative (-N), todos with a timestamp N or more days in the past will be
644 ignored. If 0, todos with a timestamp either today or in the future will
645 be ignored. For example, a value of -1 will exclude todos with a
646 timestamp in the past (yesterday or earlier), while a value of 7 will
647 exclude todos with a timestamp a week or more in the future.
649 See also `org-agenda-todo-ignore-with-date'.
650 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
651 to make his option also apply to the tags-todo list."
652 :group 'org-agenda-skip
653 :group 'org-agenda-todo-list
656 (const :tag "Ignore future timestamp todos" future)
657 (const :tag "Ignore past or present timestamp todos" past)
658 (const :tag "Ignore all timestamp todos" all)
659 (const :tag "Show timestamp todos" nil)
660 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
662 (defcustom org-agenda-todo-ignore-scheduled nil
663 "Non-nil means, ignore some scheduled TODO items when making TODO list.
664 This applies when creating the global todo list.
667 past Don't show entries scheduled today or in the past.
669 future Don't show entries scheduled in the future.
670 The idea behind this is that by scheduling it, you don't want to
671 think about it until the scheduled date.
673 all Don't show any scheduled entries in the global todo list.
674 The idea behind this is that by scheduling it, you have already
675 \"taken care\" of this item.
677 t Same as `all', for backward compatibility.
679 This variable can also have an integer as a value. See
680 `org-agenda-todo-ignore-timestamp' for more details.
682 See also `org-agenda-todo-ignore-with-date'.
683 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
684 to make his option also apply to the tags-todo list."
685 :group 'org-agenda-skip
686 :group 'org-agenda-todo-list
688 (const :tag "Ignore future-scheduled todos" future)
689 (const :tag "Ignore past- or present-scheduled todos" past)
690 (const :tag "Ignore all scheduled todos" all)
691 (const :tag "Ignore all scheduled todos (compatibility)" t)
692 (const :tag "Show scheduled todos" nil)
693 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
695 (defcustom org-agenda-todo-ignore-deadlines nil
696 "Non-nil means ignore some deadlined TODO items when making TODO list.
697 There are different motivations for using different values, please think
698 carefully when configuring this variable.
700 This applies when creating the global todo list.
703 near Don't show near deadline entries. A deadline is near when it is
704 closer than `org-deadline-warning-days' days. The idea behind this
705 is that such items will appear in the agenda anyway.
707 far Don't show TODO entries where a deadline has been defined, but
708 the deadline is not near. This is useful if you don't want to
709 use the todo list to figure out what to do now.
711 past Don't show entries with a deadline timestamp for today or in the past.
713 future Don't show entries with a deadline timestamp in the future, not even
714 when they become `near' ones. Use it with caution.
716 all Ignore all TODO entries that do have a deadline.
718 t Same as `near', for backward compatibility.
720 This variable can also have an integer as a value. See
721 `org-agenda-todo-ignore-timestamp' for more details.
723 See also `org-agenda-todo-ignore-with-date'.
724 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
725 to make his option also apply to the tags-todo list."
726 :group 'org-agenda-skip
727 :group 'org-agenda-todo-list
729 (const :tag "Ignore near deadlines" near)
730 (const :tag "Ignore near deadlines (compatibility)" t)
731 (const :tag "Ignore far deadlines" far)
732 (const :tag "Ignore all TODOs with a deadlines" all)
733 (const :tag "Show all TODOs, even if they have a deadline" nil)
734 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
736 (defcustom org-agenda-tags-todo-honor-ignore-options nil
737 "Non-nil means honor todo-list ...ignore options also in tags-todo search.
739 `org-agenda-todo-ignore-with-date',
740 `org-agenda-todo-ignore-timestamp',
741 `org-agenda-todo-ignore-scheduled',
742 `org-agenda-todo-ignore-deadlines'
743 make the global TODO list skip entries that have time stamps of certain
744 kinds. If this option is set, the same options will also apply for the
745 tags-todo search, which is the general tags/property matcher
746 restricted to unfinished TODO entries only."
747 :group 'org-agenda-skip
748 :group 'org-agenda-todo-list
749 :group 'org-agenda-match-view
752 (defcustom org-agenda-skip-scheduled-if-done nil
753 "Non-nil means don't show scheduled items in agenda when they are done.
754 This is relevant for the daily/weekly agenda, not for the TODO list. And
755 it applies only to the actual date of the scheduling. Warnings about
756 an item with a past scheduling dates are always turned off when the item
758 :group 'org-agenda-skip
759 :group 'org-agenda-daily/weekly
762 (defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
763 "Non-nil means skip scheduling line if same entry shows because of deadline.
764 In the agenda of today, an entry can show up multiple times because
765 it is both scheduled and has a nearby deadline, and maybe a plain time
767 When this variable is t, then only the deadline is shown and the fact that
768 the entry is scheduled today or was scheduled previously is not shown.
769 When this variable is nil, the entry will be shown several times. When
770 the variable is the symbol `not-today', then skip scheduled previously,
771 but not scheduled today."
772 :group 'org-agenda-skip
773 :group 'org-agenda-daily/weekly
775 (const :tag "Never" nil)
776 (const :tag "Always" t)
777 (const :tag "Not when scheduled today" not-today)))
779 (defcustom org-agenda-skip-deadline-if-done nil
780 "Non-nil means don't show deadlines when the corresponding item is done.
781 When nil, the deadline is still shown and should give you a happy feeling.
782 This is relevant for the daily/weekly agenda. And it applied only to the
783 actually date of the deadline. Warnings about approaching and past-due
784 deadlines are always turned off when the item is DONE."
785 :group 'org-agenda-skip
786 :group 'org-agenda-daily/weekly
789 (defcustom org-agenda-skip-deadline-prewarning-if-scheduled nil
790 "Non-nil means skip deadline prewarning when entry is also scheduled.
791 This will apply on all days where a prewarning for the deadline would
792 be shown, but not at the day when the entry is actually due. On that day,
793 the deadline will be shown anyway.
794 This variable may be set to nil, t, or a number which will then give
795 the number of days before the actual deadline when the prewarnings
797 This can be used in a workflow where the first showing of the deadline will
798 trigger you to schedule it, and then you don't want to be reminded of it
799 because you will take care of it on the day when scheduled."
800 :group 'org-agenda-skip
801 :group 'org-agenda-daily/weekly
804 (const :tag "Alwas show prewarning" nil)
805 (const :tag "Remove prewarning if entry is scheduled" t)
806 (integer :tag "Restart prewarning N days before deadline")))
808 (defcustom org-agenda-skip-additional-timestamps-same-entry nil
809 "When nil, multiple same-day timestamps in entry make multiple agenda lines.
810 When non-nil, after the search for timestamps has matched once in an
811 entry, the rest of the entry will not be searched."
812 :group 'org-agenda-skip
815 (defcustom org-agenda-skip-timestamp-if-done nil
816 "Non-nil means don't select item by timestamp or -range if it is DONE."
817 :group 'org-agenda-skip
818 :group 'org-agenda-daily/weekly
821 (defcustom org-agenda-dim-blocked-tasks t
822 "Non-nil means dim blocked tasks in the agenda display.
823 This causes some overhead during agenda construction, but if you
824 have turned on `org-enforce-todo-dependencies',
825 `org-enforce-todo-checkbox-dependencies', or any other blocking
826 mechanism, this will create useful feedback in the agenda.
828 Instead of t, this variable can also have the value `invisible'.
829 Then blocked tasks will be invisible and only become visible when
830 they become unblocked. An exemption to this behavior is when a task is
831 blocked because of unchecked checkboxes below it. Since checkboxes do
832 not show up in the agenda views, making this task invisible you remove any
833 trace from agenda views that there is something to do. Therefore, a task
834 that is blocked because of checkboxes will never be made invisible, it
835 will only be dimmed."
836 :group 'org-agenda-daily/weekly
837 :group 'org-agenda-todo-list
839 (const :tag "Do not dim" nil)
840 (const :tag "Dim to a gray face" t)
841 (const :tag "Make invisible" invisible)))
843 (defcustom org-timeline-show-empty-dates 3
844 "Non-nil means `org-timeline' also shows dates without an entry.
845 When nil, only the days which actually have entries are shown.
846 When t, all days between the first and the last date are shown.
847 When an integer, show also empty dates, but if there is a gap of more than
848 N days, just insert a special line indicating the size of the gap."
849 :group 'org-agenda-skip
851 (const :tag "None" nil)
853 (integer :tag "at most")))
855 (defgroup org-agenda-startup nil
856 "Options concerning initial settings in the Agenda in Org Mode."
857 :tag "Org Agenda Startup"
860 (defcustom org-agenda-menu-show-matcher t
861 "Non-nil means show the match string in the agenda dispatcher menu.
862 When nil, the matcher string is not shown, but is put into the help-echo
863 property so than moving the mouse over the command shows it.
864 Setting it to nil is good if matcher strings are very long and/or if
865 you want to use two-column display (see `org-agenda-menu-two-column')."
870 (defcustom org-agenda-menu-two-column nil
871 "Non-nil means, use two columns to show custom commands in the dispatcher.
872 If you use this, you probably want to set `org-agenda-menu-show-matcher'
878 (defcustom org-finalize-agenda-hook nil
879 "Hook run just before displaying an agenda buffer."
880 :group 'org-agenda-startup
883 (defcustom org-agenda-mouse-1-follows-link nil
884 "Non-nil means mouse-1 on a link will follow the link in the agenda.
885 A longer mouse click will still set point. Does not work on XEmacs.
886 Needs to be set before org.el is loaded."
887 :group 'org-agenda-startup
890 (defcustom org-agenda-start-with-follow-mode nil
891 "The initial value of follow mode in a newly created agenda window."
892 :group 'org-agenda-startup
895 (defcustom org-agenda-follow-indirect nil
896 "Non-nil means `org-agenda-follow-mode' displays only the
897 current item's tree, in an indirect buffer."
902 (defcustom org-agenda-show-outline-path t
903 "Non-nil means show outline path in echo area after line motion."
904 :group 'org-agenda-startup
907 (defcustom org-agenda-start-with-entry-text-mode nil
908 "The initial value of entry-text-mode in a newly created agenda window."
909 :group 'org-agenda-startup
912 (defcustom org-agenda-entry-text-maxlines 5
913 "Number of text lines to be added when `E' is pressed in the agenda.
915 Note that this variable only used during agenda display. Add add entry text
916 when exporting the agenda, configure the variable
917 `org-agenda-add-entry-ext-maxlines'."
921 (defcustom org-agenda-entry-text-exclude-regexps nil
922 "List of regular expressions to clean up entry text.
923 The complete matches of all regular expressions in this list will be
924 removed from entry text before it is shown in the agenda."
926 :type '(repeat (regexp)))
928 (defvar org-agenda-entry-text-cleanup-hook nil
929 "Hook that is run after basic cleanup of entry text to be shown in agenda.
930 This cleanup is done in a temporary buffer, so the function may inspect and
931 change the entire buffer.
932 Some default stuff like drawers and scheduling/deadline dates will already
933 have been removed when this is called, as will any matches for regular
934 expressions listed in `org-agenda-entry-text-exclude-regexps'.")
936 (defvar org-agenda-include-inactive-timestamps nil
937 "Non-nil means include inactive time stamps in agenda and timeline.
938 Dynamically scoped.")
940 (defgroup org-agenda-windows nil
941 "Options concerning the windows used by the Agenda in Org Mode."
942 :tag "Org Agenda Windows"
945 (defcustom org-agenda-window-setup 'reorganize-frame
946 "How the agenda buffer should be displayed.
947 Possible values for this option are:
949 current-window Show agenda in the current window, keeping all other windows.
950 other-window Use `switch-to-buffer-other-window' to display agenda.
951 reorganize-frame Show only two windows on the current frame, the current
952 window and the agenda.
953 other-frame Use `switch-to-buffer-other-frame' to display agenda.
954 Also, when exiting the agenda, kill that frame.
955 See also the variable `org-agenda-restore-windows-after-quit'."
956 :group 'org-agenda-windows
958 (const current-window)
961 (const reorganize-frame)))
963 (defcustom org-agenda-window-frame-fractions '(0.5 . 0.75)
964 "The min and max height of the agenda window as a fraction of frame height.
965 The value of the variable is a cons cell with two numbers between 0 and 1.
966 It only matters if `org-agenda-window-setup' is `reorganize-frame'."
967 :group 'org-agenda-windows
968 :type '(cons (number :tag "Minimum") (number :tag "Maximum")))
970 (defcustom org-agenda-restore-windows-after-quit nil
971 "Non-nil means restore window configuration upon exiting agenda.
972 Before the window configuration is changed for displaying the agenda,
973 the current status is recorded. When the agenda is exited with
974 `q' or `x' and this option is set, the old state is restored. If
975 `org-agenda-window-setup' is `other-frame', the value of this
976 option will be ignored."
977 :group 'org-agenda-windows
980 (defcustom org-agenda-ndays nil
981 "Number of days to include in overview display.
983 Obsolete, see `org-agenda-span'."
984 :group 'org-agenda-daily/weekly
987 (make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
989 (defcustom org-agenda-span 'week
990 "Number of days to include in overview display.
991 Can be day, week, month, year, or any number of days.
992 Custom commands can set this variable in the options section."
993 :group 'org-agenda-daily/weekly
994 :type '(choice (const :tag "Day" day)
995 (const :tag "Week" week)
996 (const :tag "Month" month)
997 (const :tag "Year" year)
998 (integer :tag "Custom")))
1000 (defcustom org-agenda-start-on-weekday 1
1001 "Non-nil means start the overview always on the specified weekday.
1002 0 denotes Sunday, 1 denotes Monday etc.
1003 When nil, always start on the current day.
1004 Custom commands can set this variable in the options section."
1005 :group 'org-agenda-daily/weekly
1006 :type '(choice (const :tag "Today" nil)
1007 (integer :tag "Weekday No.")))
1009 (defcustom org-agenda-show-all-dates t
1010 "Non-nil means `org-agenda' shows every day in the selected range.
1011 When nil, only the days which actually have entries are shown."
1012 :group 'org-agenda-daily/weekly
1015 (defcustom org-agenda-format-date 'org-agenda-format-date-aligned
1016 "Format string for displaying dates in the agenda.
1017 Used by the daily/weekly agenda and by the timeline. This should be
1018 a format string understood by `format-time-string', or a function returning
1019 the formatted date as a string. The function must take a single argument,
1020 a calendar-style date list like (month day year)."
1021 :group 'org-agenda-daily/weekly
1023 (string :tag "Format string")
1024 (function :tag "Function")))
1026 (defun org-agenda-format-date-aligned (date)
1027 "Format a date string for display in the daily/weekly agenda, or timeline.
1028 This function makes sure that dates are aligned for easy reading."
1030 (let* ((dayname (calendar-day-name date))
1032 (day-of-week (calendar-day-of-week date))
1034 (monthname (calendar-month-name month))
1036 (iso-week (org-days-to-iso-week
1037 (calendar-absolute-from-gregorian date)))
1038 (weekyear (cond ((and (= month 1) (>= iso-week 52))
1040 ((and (= month 12) (<= iso-week 1))
1043 (weekstring (if (= day-of-week 1)
1044 (format " W%02d" iso-week)
1046 (format "%-10s %2d %s %4d%s"
1047 dayname day monthname year weekstring)))
1049 (defcustom org-agenda-time-leading-zero nil
1050 "Non-nil means use leading zero for military times in agenda.
1051 For example, 9:30am would become 09:30 rather than 9:30."
1052 :group 'org-agenda-daily/weekly
1056 (defcustom org-agenda-timegrid-use-ampm nil
1057 "When set, show AM/PM style timestamps on the timegrid."
1062 (defun org-agenda-time-of-day-to-ampm (time)
1063 "Convert TIME of a string like '13:45' to an AM/PM style time string."
1064 (let* ((hour-number (string-to-number (substring time 0 -3)))
1065 (minute (substring time -2))
1068 ((equal hour-number 12)
1072 (setq hour-number (- hour-number 12))))
1074 (if org-agenda-time-leading-zero
1075 (format "%02d" hour-number)
1076 (format "%02s" (number-to-string hour-number)))
1079 (defun org-agenda-time-of-day-to-ampm-maybe (time)
1080 "Conditionally convert TIME to AM/PM format
1081 based on `org-agenda-timegrid-use-ampm'"
1082 (if org-agenda-timegrid-use-ampm
1083 (org-agenda-time-of-day-to-ampm time)
1086 (defcustom org-agenda-weekend-days '(6 0)
1087 "Which days are weekend?
1088 These days get the special face `org-agenda-date-weekend' in the agenda
1089 and timeline buffers."
1090 :group 'org-agenda-daily/weekly
1091 :type '(set :greedy t
1092 (const :tag "Monday" 1)
1093 (const :tag "Tuesday" 2)
1094 (const :tag "Wednesday" 3)
1095 (const :tag "Thursday" 4)
1096 (const :tag "Friday" 5)
1097 (const :tag "Saturday" 6)
1098 (const :tag "Sunday" 0)))
1100 (defcustom org-agenda-move-date-from-past-immediately-to-today t
1101 "Non-nil means jump to today when moving a past date forward in time.
1102 When using S-right in the agenda to move a a date forward, and the date
1103 stamp currently points to the past, the first key press will move it
1104 to today. WHen nil, just move one day forward even if the date stays
1106 :group 'org-agenda-daily/weekly
1110 (defcustom org-agenda-include-diary nil
1111 "If non-nil, include in the agenda entries from the Emacs Calendar's diary.
1112 Custom commands can set this variable in the options section."
1113 :group 'org-agenda-daily/weekly
1116 (defcustom org-agenda-include-deadlines t
1117 "If non-nil, include entries within their deadline warning period.
1118 Custom commands can set this variable in the options section."
1119 :group 'org-agenda-daily/weekly
1123 (defcustom org-agenda-repeating-timestamp-show-all t
1124 "Non-nil means show all occurrences of a repeating stamp in the agenda.
1125 When set to a list of strings, only show occurrences of repeating
1126 stamps for these TODO keywords. When nil, only one occurrence is
1127 shown, either today or the nearest into the future."
1128 :group 'org-agenda-daily/weekly
1130 (const :tag "Show repeating stamps" t)
1131 (repeat :tag "Show repeating stamps for these TODO keywords"
1132 (string :tag "TODO Keyword"))
1133 (const :tag "Don't show repeating stamps" nil)))
1135 (defcustom org-scheduled-past-days 10000
1136 "No. of days to continue listing scheduled items that are not marked DONE.
1137 When an item is scheduled on a date, it shows up in the agenda on this
1138 day and will be listed until it is marked done for the number of days
1140 :group 'org-agenda-daily/weekly
1143 (defcustom org-agenda-log-mode-items '(closed clock)
1144 "List of items that should be shown in agenda log mode.
1145 This list may contain the following symbols:
1147 closed Show entries that have been closed on that day.
1148 clock Show entries that have received clocked time on that day.
1149 state Show all logged state changes.
1150 Note that instead of changing this variable, you can also press `C-u l' in
1151 the agenda to display all available LOG items temporarily."
1152 :group 'org-agenda-daily/weekly
1153 :type '(set :greedy t (const closed) (const clock) (const state)))
1155 (defcustom org-agenda-clock-consistency-checks
1156 '(:max-duration "10:00" :min-duration 0 :max-gap "0:05"
1157 :gap-ok-around ("4:00")
1158 :default-face ((:background "DarkRed") (:foreground "white"))
1159 :overlap-face nil :gap-face nil :no-end-time-face nil
1160 :long-face nil :short-face nil)
1161 "This is a property list, with the following keys:
1163 :max-duration Mark clocking chunks that are longer than this time.
1164 This is a time string like \"HH:MM\", or the number
1165 of minutes as an integer.
1167 :min-duration Mark clocking chunks that are shorter that this.
1168 This is a time string like \"HH:MM\", or the number
1169 of minutes as an integer.
1171 :max-gap Mark gaps between clocking chunks that are longer than
1172 this duration. A number of minutes, or a string
1175 :gap-ok-around List of times during the day which are usually not working
1176 times. When a gap is detected, but the gap contains any
1177 of these times, the gap is *not* reported. For example,
1178 if this is (\"4:00\" \"13:00\") then gaps that contain
1179 4:00 in the morning (i.e. the night) and 13:00
1180 (i.e. a typical lunch time) do not cause a warning.
1181 You should have at least one time during the night in this
1182 list, or otherwise the first task each morning will trigger
1183 a warning because it follows a long gap.
1185 Furthermore, the following properties can be used to define faces for
1188 :default-face the default face, if the specific face is undefined
1189 :overlap-face face for overlapping clocks
1190 :gap-face face for gaps between clocks
1191 :no-end-time-face face for incomplete clocks
1192 :long-face face for clock intervals that are too long
1193 :short-face face for clock intervals that are too short"
1194 :group 'org-agenda-daily/weekly
1199 (defcustom org-agenda-log-mode-add-notes t
1200 "Non-nil means add first line of notes to log entries in agenda views.
1201 If a log item like a state change or a clock entry is associated with
1202 notes, the first line of these notes will be added to the entry in the
1204 :group 'org-agenda-daily/weekly
1207 (defcustom org-agenda-start-with-log-mode nil
1208 "The initial value of log-mode in a newly created agenda window."
1209 :group 'org-agenda-startup
1210 :group 'org-agenda-daily/weekly
1213 (defcustom org-agenda-start-with-clockreport-mode nil
1214 "The initial value of clockreport-mode in a newly created agenda window."
1215 :group 'org-agenda-startup
1216 :group 'org-agenda-daily/weekly
1219 (defcustom org-agenda-clockreport-parameter-plist '(:link t :maxlevel 2)
1220 "Property list with parameters for the clocktable in clockreport mode.
1221 This is the display mode that shows a clock table in the daily/weekly
1222 agenda, the properties for this dynamic block can be set here.
1223 The usual clocktable parameters are allowed here, but you cannot set
1224 the properties :name, :tstart, :tend, :block, and :scope - these will
1225 be overwritten to make sure the content accurately reflects the
1226 current display in the agenda."
1227 :group 'org-agenda-daily/weekly
1230 (defcustom org-agenda-search-view-always-boolean nil
1231 "Non-nil means the search string is interpreted as individual parts.
1233 The search string for search view can either be interpreted as a phrase,
1234 or as a list of snippets that define a boolean search for a number of
1237 When this is non-nil, the string will be split on whitespace, and each
1238 snippet will be searched individually, and all must match in order to
1239 select an entry. A snippet is then a single string of non-white
1240 characters, or a string in double quotes, or a regexp in {} braces.
1241 If a snippet is preceded by \"-\", the snippet must *not* match.
1242 \"+\" is syntactic sugar for positive selection. Each snippet may
1243 be found as a full word or a partial word, but see the variable
1244 `org-agenda-search-view-force-full-words'.
1246 When this is nil, search will look for the entire search phrase as one,
1247 with each space character matching any amount of whitespace, including
1250 Even when this is nil, you can still switch to Boolean search dynamically
1251 by preceding the first snippet with \"+\" or \"-\". If the first snippet
1252 is a regexp marked with braces like \"{abc}\", this will also switch to
1254 :group 'org-agenda-search-view
1258 (if (fboundp 'defvaralias)
1259 (defvaralias 'org-agenda-search-view-search-words-only
1260 'org-agenda-search-view-always-boolean))
1262 (defcustom org-agenda-search-view-force-full-words nil
1263 "Non-nil means, search words must be matches as complete words.
1264 When nil, they may also match part of a word."
1265 :group 'org-agenda-search-view
1269 (defgroup org-agenda-time-grid nil
1270 "Options concerning the time grid in the Org-mode Agenda."
1271 :tag "Org Agenda Time Grid"
1274 (defcustom org-agenda-search-headline-for-time t
1275 "Non-nil means search headline for a time-of-day.
1276 If the headline contains a time-of-day in one format or another, it will
1277 be used to sort the entry into the time sequence of items for a day.
1278 Some people have time stamps in the headline that refer to the creation
1279 time or so, and then this produces an unwanted side effect. If this is
1280 the case for your, use this variable to turn off searching the headline
1282 :group 'org-agenda-time-grid
1285 (defcustom org-agenda-use-time-grid t
1286 "Non-nil means show a time grid in the agenda schedule.
1287 A time grid is a set of lines for specific times (like every two hours between
1288 8:00 and 20:00). The items scheduled for a day at specific times are
1289 sorted in between these lines.
1290 For details about when the grid will be shown, and what it will look like, see
1291 the variable `org-agenda-time-grid'."
1292 :group 'org-agenda-time-grid
1295 (defcustom org-agenda-time-grid
1296 '((daily today require-timed)
1298 (800 1000 1200 1400 1600 1800 2000))
1300 "The settings for time grid for agenda display.
1301 This is a list of three items. The first item is again a list. It contains
1302 symbols specifying conditions when the grid should be displayed:
1304 daily if the agenda shows a single day
1305 weekly if the agenda shows an entire week
1306 today show grid on current date, independent of daily/weekly display
1307 require-timed show grid only if at least one item has a time specification
1309 The second item is a string which will be placed behind the grid time.
1311 The third item is a list of integers, indicating the times that should have
1313 :group 'org-agenda-time-grid
1316 (set :greedy t :tag "Grid Display Options"
1317 (const :tag "Show grid in single day agenda display" daily)
1318 (const :tag "Show grid in weekly agenda display" weekly)
1319 (const :tag "Always show grid for today" today)
1320 (const :tag "Show grid only if any timed entries are present"
1322 (const :tag "Skip grid times already present in an entry"
1324 (string :tag "Grid String")
1325 (repeat :tag "Grid Times" (integer :tag "Time"))))
1327 (defcustom org-agenda-show-current-time-in-grid t
1328 "Non-nil means show the current time in the time grid."
1329 :group 'org-agenda-time-grid
1333 (defcustom org-agenda-current-time-string
1334 "now - - - - - - - - - - - - - - - - - - - - - - - - -"
1335 "The string for the current time marker in the agenda."
1336 :group 'org-agenda-time-grid
1340 (defgroup org-agenda-sorting nil
1341 "Options concerning sorting in the Org-mode Agenda."
1342 :tag "Org Agenda Sorting"
1345 (defcustom org-agenda-sorting-strategy
1346 '((agenda habit-down time-up priority-down category-keep)
1347 (todo priority-down category-keep)
1348 (tags priority-down category-keep)
1349 (search category-keep))
1350 "Sorting structure for the agenda items of a single day.
1351 This is a list of symbols which will be used in sequence to determine
1352 if an entry should be listed before another entry. The following
1353 symbols are recognized:
1355 time-up Put entries with time-of-day indications first, early first
1356 time-down Put entries with time-of-day indications first, late first
1357 category-keep Keep the default order of categories, corresponding to the
1358 sequence in `org-agenda-files'.
1359 category-up Sort alphabetically by category, A-Z.
1360 category-down Sort alphabetically by category, Z-A.
1361 tag-up Sort alphabetically by last tag, A-Z.
1362 tag-down Sort alphabetically by last tag, Z-A.
1363 priority-up Sort numerically by priority, high priority last.
1364 priority-down Sort numerically by priority, high priority first.
1365 todo-state-up Sort by todo state, tasks that are done last.
1366 todo-state-down Sort by todo state, tasks that are done first.
1367 effort-up Sort numerically by estimated effort, high effort last.
1368 effort-down Sort numerically by estimated effort, high effort first.
1369 user-defined-up Sort according to `org-agenda-cmp-user-defined', high last.
1370 user-defined-down Sort according to `org-agenda-cmp-user-defined', high first.
1371 habit-up Put entries that are habits first
1372 habit-down Put entries that are habits last
1373 alpha-up Sort headlines alphabetically
1374 alpha-down Sort headlines alphabetically, reversed
1376 The different possibilities will be tried in sequence, and testing stops
1377 if one comparison returns a \"not-equal\". For example, the default
1378 '(time-up category-keep priority-down)
1379 means: Pull out all entries having a specified time of day and sort them,
1380 in order to make a time schedule for the current day the first thing in the
1381 agenda listing for the day. Of the entries without a time indication, keep
1382 the grouped in categories, don't sort the categories, but keep them in
1383 the sequence given in `org-agenda-files'. Within each category sort by
1386 Leaving out `category-keep' would mean that items will be sorted across
1387 categories by priority.
1389 Instead of a single list, this can also be a set of list for specific
1390 contents, with a context symbol in the car of the list, any of
1391 `agenda', `todo', `tags', `search' for the corresponding agenda views.
1393 Custom commands can bind this variable in the options section."
1394 :group 'org-agenda-sorting
1396 (repeat :tag "General" ,org-sorting-choice)
1397 (list :tag "Individually"
1398 (cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
1399 (repeat ,org-sorting-choice))
1400 (cons (const :tag "Strategy for TODO lists" todo)
1401 (repeat ,org-sorting-choice))
1402 (cons (const :tag "Strategy for Tags matches" tags)
1403 (repeat ,org-sorting-choice))
1404 (cons (const :tag "Strategy for search matches" search)
1405 (repeat ,org-sorting-choice)))))
1407 (defcustom org-agenda-cmp-user-defined nil
1408 "A function to define the comparison `user-defined'.
1409 This function must receive two arguments, agenda entry a and b.
1410 If a>b, return +1. If a<b, return -1. If they are equal as seen by
1411 the user comparison, return nil.
1412 When this is defined, you can make `user-defined-up' and `user-defined-down'
1413 part of an agenda sorting strategy."
1414 :group 'org-agenda-sorting
1417 (defcustom org-sort-agenda-notime-is-late t
1418 "Non-nil means items without time are considered late.
1419 This is only relevant for sorting. When t, items which have no explicit
1420 time like 15:30 will be considered as 99:01, i.e. later than any items which
1421 do have a time. When nil, the default time is before 0:00. You can use this
1422 option to decide if the schedule for today should come before or after timeless
1424 :group 'org-agenda-sorting
1427 (defcustom org-sort-agenda-noeffort-is-high t
1428 "Non-nil means items without effort estimate are sorted as high effort.
1429 This also applies when filtering an agenda view with respect to the
1430 < or > effort operator. Then, tasks with no effort defined will be treated
1431 as tasks with high effort.
1432 When nil, such items are sorted as 0 minutes effort."
1433 :group 'org-agenda-sorting
1436 (defgroup org-agenda-line-format nil
1437 "Options concerning the entry prefix in the Org-mode agenda display."
1438 :tag "Org Agenda Line Format"
1441 (defcustom org-agenda-prefix-format
1442 '((agenda . " %i %-12:c%?-12t% s")
1444 (todo . " %i %-12:c")
1445 (tags . " %i %-12:c")
1446 (search . " %i %-12:c"))
1447 "Format specifications for the prefix of items in the agenda views.
1448 An alist with five entries, each for the different agenda types. The
1449 keys of the sublists are `agenda', `timeline', `todo', `search' and `tags'.
1450 The values are format strings.
1452 This format works similar to a printf format, with the following meaning:
1454 %c the category of the item, \"Diary\" for entries from the diary,
1455 or as given by the CATEGORY keyword or derived from the file name
1456 %e the effort required by the item
1457 %i the icon category of the item, see `org-agenda-category-icon-alist'
1458 %T the last tag of the item (ignore inherited tags, which come first)
1459 %t the HH:MM time-of-day specification if one applies to the entry
1460 %s Scheduling/Deadline information, a short string
1461 %(expression) Eval EXPRESSION and replace the control string
1464 All specifiers work basically like the standard `%s' of printf, but may
1465 contain two additional characters: a question mark just after the `%'
1466 and a whitespace/punctuation character just before the final letter.
1468 If the first character after `%' is a question mark, the entire field
1469 will only be included if the corresponding value applies to the current
1470 entry. This is useful for fields which should have fixed width when
1471 present, but zero width when absent. For example, \"%?-12t\" will
1472 result in a 12 character time field if a time of the day is specified,
1473 but will completely disappear in entries which do not contain a time.
1475 If there is punctuation or whitespace character just before the final
1476 format letter, this character will be appended to the field value if
1477 the value is not empty. For example, the format \"%-12:c\" leads to
1478 \"Diary: \" if the category is \"Diary\". If the category were be
1479 empty, no additional colon would be inserted.
1481 The default value for the agenda sublist is \" %-12:c%?-12t% s\",
1484 - Indent the line with two space characters
1485 - Give the category a 12 chars wide field, padded with whitespace on
1486 the right (because of `-'). Append a colon if there is a category
1488 - If there is a time-of-day, put it into a 12 chars wide field. If no
1489 time, don't put in an empty field, just skip it (because of '?').
1490 - Finally, put the scheduling information.
1492 See also the variables `org-agenda-remove-times-when-in-prefix' and
1493 `org-agenda-remove-tags'.
1495 Custom commands can set this variable in the options section."
1497 (string :tag "General format")
1498 (list :greedy t :tag "View dependent"
1499 (cons (const agenda) (string :tag "Format"))
1500 (cons (const timeline) (string :tag "Format"))
1501 (cons (const todo) (string :tag "Format"))
1502 (cons (const tags) (string :tag "Format"))
1503 (cons (const search) (string :tag "Format"))))
1504 :group 'org-agenda-line-format)
1506 (defvar org-prefix-format-compiled nil
1507 "The compiled prefix format and associated variables.
1508 This is a list where first element is a list of variable bindings, and second
1509 element is the compiled format expression. See the variable
1510 `org-agenda-prefix-format'.")
1512 (defcustom org-agenda-todo-keyword-format "%-1s"
1513 "Format for the TODO keyword in agenda lines.
1514 Set this to something like \"%-12s\" if you want all TODO keywords
1515 to occupy a fixed space in the agenda display."
1516 :group 'org-agenda-line-format
1519 (defcustom org-agenda-timerange-leaders '("" "(%d/%d): ")
1520 "Text preceding timerange entries in the agenda view.
1521 This is a list with two strings. The first applies when the range
1522 is entirely on one day. The second applies if the range spans several days.
1523 The strings may have two \"%d\" format specifiers which will be filled
1524 with the sequence number of the days, and the total number of days in the
1525 range, respectively."
1526 :group 'org-agenda-line-format
1528 (string :tag "Deadline today ")
1529 (choice :tag "Deadline relative"
1530 (string :tag "Format string")
1533 (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
1534 "Text preceding scheduled items in the agenda view.
1535 This is a list with two strings. The first applies when the item is
1536 scheduled on the current day. The second applies when it has been scheduled
1537 previously, it may contain a %d indicating that this is the nth time that
1538 this item is scheduled, due to automatic rescheduling of unfinished items
1539 for the following day. So this number is one larger than the number of days
1540 that passed since this item was scheduled first."
1541 :group 'org-agenda-line-format
1543 (string :tag "Scheduled today ")
1544 (string :tag "Scheduled previously")))
1546 (defcustom org-agenda-inactive-leader "["
1547 "Text preceding item pulled into the agenda by inactive time stamps.
1548 These entries are added to the agenda when pressing \"[\"."
1549 :group 'org-agenda-line-format
1552 (string :tag "Scheduled today ")
1553 (string :tag "Scheduled previously")))
1555 (defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: ")
1556 "Text preceding deadline items in the agenda view.
1557 This is a list with two strings. The first applies when the item has its
1558 deadline on the current day. The second applies when it is in the past or
1559 in the future, it may contain %d to capture how many days away the deadline
1561 :group 'org-agenda-line-format
1563 (string :tag "Deadline today ")
1564 (choice :tag "Deadline relative"
1565 (string :tag "Format string")
1568 (defcustom org-agenda-remove-times-when-in-prefix t
1569 "Non-nil means remove duplicate time specifications in agenda items.
1570 When the format `org-agenda-prefix-format' contains a `%t' specifier, a
1571 time-of-day specification in a headline or diary entry is extracted and
1572 placed into the prefix. If this option is non-nil, the original specification
1573 \(a timestamp or -range, or just a plain time(range) specification like
1574 11:30-4pm) will be removed for agenda display. This makes the agenda less
1576 The option can be t or nil. It may also be the symbol `beg', indicating
1577 that the time should only be removed when it is located at the beginning of
1578 the headline/diary entry."
1579 :group 'org-agenda-line-format
1581 (const :tag "Always" t)
1582 (const :tag "Never" nil)
1583 (const :tag "When at beginning of entry" beg)))
1585 (defcustom org-agenda-remove-timeranges-from-blocks nil
1586 "Non-nil means remove time ranges specifications in agenda
1587 items that span on several days."
1588 :group 'org-agenda-line-format
1592 (defcustom org-agenda-default-appointment-duration nil
1593 "Default duration for appointments that only have a starting time.
1594 When nil, no duration is specified in such cases.
1595 When non-nil, this must be the number of minutes, e.g. 60 for one hour."
1596 :group 'org-agenda-line-format
1598 (integer :tag "Minutes")
1599 (const :tag "No default duration")))
1601 (defcustom org-agenda-show-inherited-tags t
1602 "Non-nil means show inherited tags in each agenda line."
1603 :group 'org-agenda-line-format
1606 (defcustom org-agenda-hide-tags-regexp nil
1607 "Regular expression used to filter away specific tags in agenda views.
1608 This means that these tags will be present, but not be shown in the agenda
1609 line. Secondary filtering will still work on the hidden tags.
1610 Nil means don't hide any tags."
1611 :group 'org-agenda-line-format
1613 (const :tag "Hide none" nil)
1614 (string :tag "Regexp ")))
1616 (defcustom org-agenda-remove-tags nil
1617 "Non-nil means remove the tags from the headline copy in the agenda.
1618 When this is the symbol `prefix', only remove tags when
1619 `org-agenda-prefix-format' contains a `%T' specifier."
1620 :group 'org-agenda-line-format
1622 (const :tag "Always" t)
1623 (const :tag "Never" nil)
1624 (const :tag "When prefix format contains %T" prefix)))
1626 (if (fboundp 'defvaralias)
1627 (defvaralias 'org-agenda-remove-tags-when-in-prefix
1628 'org-agenda-remove-tags))
1630 (defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
1631 "Shift tags in agenda items to this column.
1632 If this number is positive, it specifies the column. If it is negative,
1633 it means that the tags should be flushright to that column. For example,
1634 -80 works well for a normal 80 character screen."
1635 :group 'org-agenda-line-format
1638 (if (fboundp 'defvaralias)
1639 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
1641 (defcustom org-agenda-fontify-priorities 'cookies
1642 "Non-nil means highlight low and high priorities in agenda.
1643 When t, the highest priority entries are bold, lowest priority italic.
1644 However, settings in `org-priority-faces' will overrule these faces.
1645 When this variable is the symbol `cookies', only fontify the
1646 cookies, not the entire task.
1647 This may also be an association list of priority faces, whose
1648 keys are the character values of `org-highest-priority',
1649 `org-default-priority', and `org-lowest-priority' (the default values
1650 are ?A, ?B, and ?C, respectively). The face may be a named face, a
1651 color as a string, or a list like `(:background \"Red\")'.
1652 If it is a color, the variable `org-faces-easy-properties'
1653 determines if it is a foreground or a background color."
1654 :group 'org-agenda-line-format
1656 (const :tag "Never" nil)
1657 (const :tag "Defaults" t)
1658 (const :tag "Cookies only" cookies)
1659 (repeat :tag "Specify"
1660 (list (character :tag "Priority" :value ?A)
1661 (choice :tag "Face "
1662 (string :tag "Color")
1663 (sexp :tag "Face"))))))
1665 (defcustom org-agenda-day-face-function nil
1666 "Function called to determine what face should be used to display a day.
1667 The only argument passed to that function is the day. It should
1668 returns a face, or nil if does not want to specify a face and let
1669 the normal rules apply."
1670 :group 'org-agenda-line-format
1674 (defcustom org-agenda-category-icon-alist nil
1675 "Alist of category icon to be displayed in agenda views.
1677 Each entry should have the following format:
1679 (CATEGORY-REGEXP FILE-OR-DATA TYPE DATA-P PROPS)
1681 Where CATEGORY-REGEXP is a regexp matching the categories where
1682 the icon should be displayed.
1683 FILE-OR-DATA either a file path or a string containing image data.
1685 The other fields can be omitted safely if not needed:
1686 TYPE indicates the image type.
1687 DATA-P is a boolean indicating whether the FILE-OR-DATA string is
1689 PROPS are additional image attributes to assign to the image,
1690 like, e.g. `:ascent center'.
1692 (\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
1694 If you want to set the display properties yourself, just put a
1695 list as second element:
1697 (CATEGORY-REGEXP (MY PROPERTY LIST))
1699 For example, to display a 16px horizontal space for Emacs
1700 category, you can use:
1702 (\"Emacs\" '(space . (:width (16))))"
1703 :group 'org-agenda-line-format
1705 :type '(alist :key-type (string :tag "Regexp matching category")
1706 :value-type (choice (list :tag "Icon"
1707 (string :tag "File or data")
1708 (symbol :tag "Type")
1709 (boolean :tag "Data?")
1710 (repeat :tag "Extra image properties" :inline t symbol))
1711 (list :tag "Display properties" sexp))))
1713 (defgroup org-agenda-column-view nil
1714 "Options concerning column view in the agenda."
1715 :tag "Org Agenda Column View"
1718 (defcustom org-agenda-columns-show-summaries t
1719 "Non-nil means show summaries for columns displayed in the agenda view."
1720 :group 'org-agenda-column-view
1723 (defcustom org-agenda-columns-compute-summary-properties t
1724 "Non-nil means recompute all summary properties before column view.
1725 When column view in the agenda is listing properties that have a summary
1726 operator, it can go to all relevant buffers and recompute the summaries
1727 there. This can mean overhead for the agenda column view, but is necessary
1728 to have thing up to date.
1729 As a special case, a CLOCKSUM property also makes sure that the clock
1730 computations are current."
1731 :group 'org-agenda-column-view
1734 (defcustom org-agenda-columns-add-appointments-to-effort-sum nil
1735 "Non-nil means the duration of an appointment will add to day effort.
1736 The property to which appointment durations will be added is the one given
1737 in the option `org-effort-property'. If an appointment does not have
1738 an end time, `org-agenda-default-appointment-duration' will be used. If that
1739 is not set, an appointment without end time will not contribute to the time
1741 :group 'org-agenda-column-view
1744 (defcustom org-agenda-auto-exclude-function nil
1745 "A function called with a tag to decide if it is filtered on '/ RET'.
1746 The sole argument to the function, which is called once for each
1747 possible tag, is a string giving the name of the tag. The
1748 function should return either nil if the tag should be included
1749 as normal, or \"-<TAG>\" to exclude the tag.
1750 Note that for the purpose of tag filtering, only the lower-case version of
1751 all tags will be considered, so that this function will only ever see
1752 the lower-case version of all tags."
1756 (defcustom org-agenda-bulk-custom-functions nil
1757 "Alist of characters and custom functions for bulk actions.
1758 For example, this value makes those two functions available:
1763 With selected entries in an agenda buffer, `B R' will call
1764 the custom function `set-category' on the selected entries.
1765 Note that functions in this alist don't need to be quoted."
1774 (defmacro org-agenda-with-point-at-orig-entry (string &rest body)
1775 "Execute BODY with point at location given by `org-hd-marker' property.
1776 If STRING is non-nil, the text property will be fetched from position 0
1777 in that string. If STRING is nil, it will be fetched from the beginning
1778 of the current line."
1779 (org-with-gensyms (marker)
1780 `(let ((,marker (get-text-property (if string 0 (point-at-bol))
1781 'org-hd-marker ,string)))
1782 (with-current-buffer (marker-buffer ,marker)
1786 (def-edebug-spec org-agenda-with-point-at-orig-entry (form body))
1788 (defun org-add-agenda-custom-command (entry)
1789 "Replace or add a command in `org-agenda-custom-commands'.
1790 This is mostly for hacking and trying a new command - once the command
1791 works you probably want to add it to `org-agenda-custom-commands' for good."
1792 (let ((ass (assoc (car entry) org-agenda-custom-commands)))
1794 (setcdr ass (cdr entry))
1795 (push entry org-agenda-custom-commands))))
1797 ;;; Define the org-agenda-mode
1799 (defvar org-agenda-mode-map (make-sparse-keymap)
1800 "Keymap for `org-agenda-mode'.")
1801 (if (fboundp 'defvaralias)
1802 (defvaralias 'org-agenda-keymap 'org-agenda-mode-map))
1804 (defvar org-agenda-menu) ; defined later in this file.
1805 (defvar org-agenda-restrict) ; defined later in this file.
1806 (defvar org-agenda-follow-mode nil)
1807 (defvar org-agenda-entry-text-mode nil)
1808 (defvar org-agenda-clockreport-mode nil)
1809 (defvar org-agenda-show-log nil)
1810 (defvar org-agenda-redo-command nil)
1811 (defvar org-agenda-query-string nil)
1812 (defvar org-agenda-mode-hook nil
1813 "Hook for `org-agenda-mode', run after the mode is turned on.")
1814 (defvar org-agenda-type nil)
1815 (defvar org-agenda-force-single-file nil)
1816 (defvar org-agenda-bulk-marked-entries) ;; Defined further down in this file
1819 ;;; Multiple agenda buffers support
1821 (defcustom org-agenda-sticky nil
1822 "Non-nil means agenda q key will bury agenda buffers.
1823 Agenda commands will then show existing buffer instead of generating new ones.
1824 When nil, `q' will kill the single agenda buffer."
1827 :set (lambda (var val)
1829 (org-toggle-sticky-agenda (if val 1 0))
1832 (defun org-toggle-sticky-agenda (&optional arg)
1833 "Toggle `org-agenda-sticky'."
1835 (let ((new-value (if arg
1836 (> (prefix-numeric-value arg) 0)
1837 (not org-agenda-sticky))))
1838 (if (equal new-value org-agenda-sticky)
1839 (message "Sticky agenda was already %s"
1840 (if org-agenda-sticky "enabled" "disabled"))
1841 (setq org-agenda-sticky new-value)
1842 (org-agenda-kill-all-agenda-buffers)
1843 (message "Sticky agenda was %s"
1844 (if org-agenda-sticky "enabled" "disabled")))))
1846 (defvar org-agenda-buffer nil
1847 "Agenda buffer currently being generated.")
1849 (defvar org-agenda-last-prefix-arg nil)
1850 (defvar org-agenda-this-buffer-name nil)
1851 (defvar org-agenda-doing-sticky-redo nil)
1852 (defvar org-agenda-this-buffer-is-sticky nil)
1854 (defconst org-agenda-local-vars
1855 '(org-agenda-this-buffer-name
1856 org-agenda-undo-list
1857 org-agenda-pending-undo-list
1858 org-agenda-follow-mode
1859 org-agenda-entry-text-mode
1860 org-agenda-clockreport-mode
1862 org-agenda-redo-command
1863 org-agenda-query-string
1865 org-agenda-bulk-marked-entries
1866 org-agenda-undo-has-started-in
1867 org-agenda-last-arguments
1869 org-agenda-tag-filter-overlays
1870 org-agenda-cat-filter-overlays
1871 org-pre-agenda-window-conf
1872 org-agenda-columns-active
1873 org-agenda-tag-filter
1874 org-agenda-category-filter
1876 org-agenda-last-search-view-search-was-boolean
1877 org-agenda-filtered-by-category
1878 org-agenda-filter-form
1879 org-agenda-show-window
1880 org-agenda-cycle-counter
1881 org-agenda-last-prefix-arg)
1882 "Variables that must be local in agenda buffers to allow multiple buffers.")
1884 (defun org-agenda-mode ()
1885 "Mode for time-sorted view on action items in Org-mode files.
1887 The following commands are available:
1889 \\{org-agenda-mode-map}"
1891 (cond (org-agenda-doing-sticky-redo
1892 ;; Refreshing sticky agenda-buffer
1894 ;; Preserve the value of `org-agenda-local-vars' variables,
1895 ;; while letting `kill-all-local-variables' kill the rest
1896 (let ((save (buffer-local-variables)))
1897 (kill-all-local-variables)
1898 (mapc 'make-local-variable org-agenda-local-vars)
1900 (let ((var (car elem))
1903 (member var org-agenda-local-vars))
1905 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
1907 ;; Creating a sticky Agenda buffer for the first time
1908 (kill-all-local-variables)
1909 (mapc 'make-local-variable org-agenda-local-vars)
1910 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
1912 ;; Creating a non-sticky agenda buffer
1913 (kill-all-local-variables)
1914 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) nil)))
1915 (setq org-agenda-undo-list nil
1916 org-agenda-pending-undo-list nil
1917 org-agenda-bulk-marked-entries nil)
1918 (setq major-mode 'org-agenda-mode)
1919 ;; Keep global-font-lock-mode from turning on font-lock-mode
1920 (org-set-local 'font-lock-global-modes (list 'not major-mode))
1921 (setq mode-name "Org-Agenda")
1922 (use-local-map org-agenda-mode-map)
1923 (easy-menu-add org-agenda-menu)
1924 (if org-startup-truncated (setq truncate-lines t))
1925 (org-set-local 'line-move-visual nil)
1926 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
1927 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
1928 ;; Make sure properties are removed when copying text
1929 (when (boundp 'buffer-substring-filters)
1930 (org-set-local 'buffer-substring-filters
1932 (set-text-properties 0 (length x) nil x) x)
1933 buffer-substring-filters)))
1934 (unless org-agenda-keep-modes
1935 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
1936 org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
1937 org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
1938 org-agenda-show-log org-agenda-start-with-log-mode))
1941 '("Agenda") "Agenda Files"
1945 (if (get 'org-agenda-files 'org-restrict)
1946 "Restricted to single file"
1948 '(org-edit-agenda-file-list)
1949 (not (get 'org-agenda-files 'org-restrict)))
1951 (mapcar 'org-file-menu-entry (org-agenda-files))))
1952 (org-agenda-set-mode-name)
1954 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
1955 (list 'org-agenda-mode-hook)))
1957 (substitute-key-definition 'undo 'org-agenda-undo
1958 org-agenda-mode-map global-map)
1959 (org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
1960 (org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
1961 (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
1962 (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
1963 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
1964 (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
1965 (org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
1966 (org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
1967 (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-remove-all-marks)
1968 (org-defkey org-agenda-mode-map "A" 'org-agenda-append-agenda)
1969 (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
1970 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
1971 (org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
1972 (org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
1973 (org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
1974 (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
1975 (org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
1976 (org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
1977 (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
1978 (org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up)
1979 (org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down)
1980 (org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down)
1981 (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
1982 (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
1983 (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
1984 (org-defkey org-agenda-mode-map "o" 'delete-other-windows)
1985 (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
1986 (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
1987 (org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
1988 (org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation)
1989 (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
1990 (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
1991 (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
1992 (org-defkey org-agenda-mode-map "j" 'org-agenda-goto-date)
1993 (org-defkey org-agenda-mode-map "d" 'org-agenda-day-view)
1994 (org-defkey org-agenda-mode-map "w" 'org-agenda-week-view)
1995 (org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
1996 (org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
1997 (org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
1998 (org-defkey org-agenda-mode-map "k" 'org-agenda-action)
1999 (org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
2000 (org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
2001 (org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
2002 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
2003 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
2005 (org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
2006 (org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
2007 (org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
2008 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
2009 (while l (org-defkey org-agenda-mode-map
2010 (int-to-string (pop l)) 'digit-argument)))
2012 (org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
2013 (org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
2014 (org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
2015 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
2016 (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
2017 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
2018 (org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines)
2019 (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
2020 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
2021 (org-defkey org-agenda-mode-map "g" 'org-agenda-redo)
2022 (org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
2023 (org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
2024 (org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
2025 'org-clock-modify-effort-estimate)
2026 (org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
2027 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
2028 (org-defkey org-agenda-mode-map "Q" 'org-agenda-Quit)
2029 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
2030 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-agenda-write)
2031 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
2032 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
2033 (org-defkey org-agenda-mode-map "P" 'org-agenda-show-priority)
2034 (org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags)
2035 (org-defkey org-agenda-mode-map "n" 'org-agenda-next-line)
2036 (org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line)
2037 (substitute-key-definition 'next-line 'org-agenda-next-line
2038 org-agenda-mode-map global-map)
2039 (substitute-key-definition 'previous-line 'org-agenda-previous-line
2040 org-agenda-mode-map global-map)
2041 (org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach)
2042 (org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line)
2043 (org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line)
2044 (org-defkey org-agenda-mode-map "," 'org-agenda-priority)
2045 (org-defkey org-agenda-mode-map "\C-c," 'org-agenda-priority)
2046 (org-defkey org-agenda-mode-map "i" 'org-agenda-diary-entry)
2047 (org-defkey org-agenda-mode-map "c" 'org-agenda-goto-calendar)
2048 (org-defkey org-agenda-mode-map "C" 'org-agenda-convert-date)
2049 (org-defkey org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
2050 (org-defkey org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
2051 (org-defkey org-agenda-mode-map "h" 'org-agenda-holidays)
2052 (org-defkey org-agenda-mode-map "H" 'org-agenda-holidays)
2053 (org-defkey org-agenda-mode-map "\C-c\C-x\C-i" 'org-agenda-clock-in)
2054 (org-defkey org-agenda-mode-map "I" 'org-agenda-clock-in)
2055 (org-defkey org-agenda-mode-map "\C-c\C-x\C-o" 'org-agenda-clock-out)
2056 (org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out)
2057 (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
2058 (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel)
2059 (org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
2060 (org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto)
2061 (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up)
2062 (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
2063 (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
2064 (org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
2065 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
2066 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
2067 (org-defkey org-agenda-mode-map "f" 'org-agenda-later)
2068 (org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
2069 (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
2070 (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
2072 (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
2073 (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
2074 (org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
2075 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
2076 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
2077 (org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
2078 (org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
2079 (org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-category)
2080 (org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
2081 (define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
2082 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
2083 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
2085 (org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse)
2086 (org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse)
2087 (when org-agenda-mouse-1-follows-link
2088 (org-defkey org-agenda-mode-map [follow-link] 'mouse-face))
2089 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
2094 ["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
2095 ["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
2096 ["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
2097 ["Jump to date" org-agenda-goto-date (org-agenda-check-type nil 'agenda)])
2100 ["Day View" org-agenda-day-view
2101 :active (org-agenda-check-type nil 'agenda)
2102 :style radio :selected (eq org-agenda-current-span 'day)
2103 :keys "v d (or just d)"]
2104 ["Week View" org-agenda-week-view
2105 :active (org-agenda-check-type nil 'agenda)
2106 :style radio :selected (eq org-agenda-current-span 'week)
2107 :keys "v w (or just w)"]
2108 ["Month View" org-agenda-month-view
2109 :active (org-agenda-check-type nil 'agenda)
2110 :style radio :selected (eq org-agenda-current-span 'month)
2112 ["Year View" org-agenda-year-view
2113 :active (org-agenda-check-type nil 'agenda)
2114 :style radio :selected (eq org-agenda-current-span 'year)
2117 ["Include Diary" org-agenda-toggle-diary
2118 :style toggle :selected org-agenda-include-diary
2119 :active (org-agenda-check-type nil 'agenda)]
2120 ["Include Deadlines" org-agenda-toggle-deadlines
2121 :style toggle :selected org-agenda-include-deadlines
2122 :active (org-agenda-check-type nil 'agenda)]
2123 ["Use Time Grid" org-agenda-toggle-time-grid
2124 :style toggle :selected org-agenda-use-time-grid
2125 :active (org-agenda-check-type nil 'agenda)]
2127 ["Show clock report" org-agenda-clockreport-mode
2128 :style toggle :selected org-agenda-clockreport-mode
2129 :active (org-agenda-check-type nil 'agenda)]
2130 ["Show some entry text" org-agenda-entry-text-mode
2131 :style toggle :selected org-agenda-entry-text-mode
2134 ["Show Logbook entries" org-agenda-log-mode
2135 :style toggle :selected org-agenda-show-log
2136 :active (org-agenda-check-type nil 'agenda 'timeline)
2137 :keys "v l (or just l)"]
2138 ["Include archived trees" org-agenda-archives-mode
2139 :style toggle :selected org-agenda-archives-mode :active t
2141 ["Include archive files" (org-agenda-archives-mode t)
2142 :style toggle :selected (eq org-agenda-archives-mode t) :active t
2145 ["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict])
2146 ["Write view to file" org-agenda-write t]
2147 ["Rebuild buffer" org-agenda-redo t]
2148 ["Save all Org-mode Buffers" org-save-all-org-buffers t]
2150 ["Show original entry" org-agenda-show t]
2151 ["Go To (other window)" org-agenda-goto t]
2152 ["Go To (this window)" org-agenda-switch-to t]
2153 ["Follow Mode" org-agenda-follow-mode
2154 :style toggle :selected org-agenda-follow-mode :active t]
2155 ; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
2158 ["Cycle TODO" org-agenda-todo t]
2159 ["Next TODO set" org-agenda-todo-nextset t]
2160 ["Previous TODO set" org-agenda-todo-previousset t]
2161 ["Add note" org-agenda-add-note t])
2162 ("Archive/Refile/Delete"
2163 ["Archive default" org-agenda-archive-default t]
2164 ["Archive default" org-agenda-archive-default-with-confirmation t]
2165 ["Toggle ARCHIVE tag" org-agenda-toggle-archive-tag t]
2166 ["Move to archive sibling" org-agenda-archive-to-archive-sibling t]
2167 ["Archive subtree" org-agenda-archive t]
2169 ["Refile" org-agenda-refile t]
2171 ["Delete subtree" org-agenda-kill t])
2173 ["Mark entry" org-agenda-bulk-mark t]
2174 ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
2175 ["Unmark entry" org-agenda-bulk-unmark t]
2176 ["Unmark all entries" org-agenda-bulk-remove-all-marks :active t :keys "C-u s"])
2177 ["Act on all marked" org-agenda-bulk-action t]
2179 ("Tags and Properties"
2180 ["Show all Tags" org-agenda-show-tags t]
2181 ["Set Tags current line" org-agenda-set-tags (not (org-region-active-p))]
2182 ["Change tag in region" org-agenda-set-tags (org-region-active-p)]
2184 ["Column View" org-columns t])
2185 ("Deadline/Schedule"
2186 ["Schedule" org-agenda-schedule t]
2187 ["Set Deadline" org-agenda-deadline t]
2189 ["Mark item" org-agenda-action :active t :keys "k m"]
2190 ["Show mark item" org-agenda-action :active t :keys "k v"]
2191 ["Schedule marked item" org-agenda-action :active t :keys "k s"]
2192 ["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
2194 ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
2195 ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
2196 ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
2197 ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
2198 ["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
2199 ["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
2200 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
2202 ["Clock in" org-agenda-clock-in t]
2203 ["Clock out" org-agenda-clock-out t]
2204 ["Clock cancel" org-agenda-clock-cancel t]
2205 ["Goto running clock" org-clock-goto t]
2207 ["Set Effort" org-agenda-set-effort t]
2208 ["Change clocked effort" org-clock-modify-effort-estimate
2209 (org-clock-is-active)])
2211 ["Set Priority" org-agenda-priority t]
2212 ["Increase Priority" org-agenda-priority-up t]
2213 ["Decrease Priority" org-agenda-priority-down t]
2214 ["Show Priority" org-agenda-show-priority t])
2216 ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
2217 ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
2218 ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
2219 ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
2220 ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
2221 ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
2223 ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
2225 ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
2228 ["Push Files and Views" org-mobile-push t]
2229 ["Get Captured and Flagged" org-mobile-pull t]
2230 ["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"]
2231 ["Show note / unflag" org-agenda-show-the-flagging-note t]
2233 ["Setup" (progn (require 'org-mobile) (customize-group 'org-mobile)) t])
2235 ["Quit" org-agenda-quit t]
2236 ["Exit and Release Buffers" org-agenda-exit t]
2241 (defvar org-agenda-allow-remote-undo t
2242 "Non-nil means allow remote undo from the agenda buffer.")
2243 (defvar org-agenda-undo-list nil
2244 "List of undoable operations in the agenda since last refresh.")
2245 (defvar org-agenda-undo-has-started-in nil
2246 "Buffers that have already seen `undo-start' in the current undo sequence.")
2247 (defvar org-agenda-pending-undo-list nil
2248 "In a series of undo commands, this is the list of remaining undo items.")
2250 (defun org-agenda-undo ()
2251 "Undo a remote editing step in the agenda.
2252 This undoes changes both in the agenda buffer and in the remote buffer
2253 that have been changed along."
2255 (or org-agenda-allow-remote-undo
2256 (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
2257 (if (not (eq this-command last-command))
2258 (setq org-agenda-undo-has-started-in nil
2259 org-agenda-pending-undo-list org-agenda-undo-list))
2260 (if (not org-agenda-pending-undo-list)
2261 (error "No further undo information"))
2262 (let* ((entry (pop org-agenda-pending-undo-list))
2263 buf line cmd rembuf)
2264 (setq cmd (pop entry) line (pop entry))
2265 (setq rembuf (nth 2 entry))
2266 (org-with-remote-undo rembuf
2267 (while (bufferp (setq buf (pop entry)))
2269 (with-current-buffer buf
2270 (let ((last-undo-buffer buf)
2271 (inhibit-read-only t))
2272 (unless (memq buf org-agenda-undo-has-started-in)
2273 (push buf org-agenda-undo-has-started-in)
2274 (make-local-variable 'pending-undo-list)
2276 (while (and pending-undo-list
2277 (listp pending-undo-list)
2278 (not (car pending-undo-list)))
2279 (pop pending-undo-list))
2281 (org-goto-line line)
2282 (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))
2284 (defun org-verify-change-for-undo (l1 l2)
2285 "Verify that a real change occurred between the undo lists L1 and L2."
2286 (while (and l1 (listp l1) (null (car l1))) (pop l1))
2287 (while (and l2 (listp l2) (null (car l2))) (pop l2))
2292 (defvar org-agenda-restrict nil)
2293 (defvar org-agenda-restrict-begin (make-marker))
2294 (defvar org-agenda-restrict-end (make-marker))
2295 (defvar org-agenda-last-dispatch-buffer nil)
2296 (defvar org-agenda-overriding-restriction nil)
2299 (defun org-agenda (&optional arg keys restriction)
2300 "Dispatch agenda commands to collect entries to the agenda buffer.
2301 Prompts for a command to execute. Any prefix arg will be passed
2302 on to the selected command. The default selections are:
2304 a Call `org-agenda-list' to display the agenda for current day or week.
2305 t Call `org-todo-list' to display the global todo list.
2306 T Call `org-todo-list' to display the global todo list, select only
2307 entries with a specific TODO keyword (the user gets a prompt).
2308 m Call `org-tags-view' to display headlines with tags matching
2309 a condition (the user is prompted for the condition).
2310 M Like `m', but select only TODO entries, no ordinary headlines.
2311 L Create a timeline for the current buffer.
2312 e Export views to associated files.
2313 s Search entries for keywords.
2314 / Multi occur across all agenda files and also files listed
2315 in `org-agenda-text-search-extra-files'.
2316 < Restrict agenda commands to buffer, subtree, or region.
2317 Press several times to get the desired effect.
2318 > Remove a previous restriction.
2319 # List \"stuck\" projects.
2320 ! Configure what \"stuck\" means.
2321 C Configure custom agenda commands.
2323 More commands can be added by configuring the variable
2324 `org-agenda-custom-commands'. In particular, specific tags and TODO keyword
2325 searches can be pre-defined in this way.
2327 If the current buffer is in Org-mode and visiting a file, you can also
2328 first press `<' once to indicate that the agenda should be temporarily
2329 \(until the next use of \\[org-agenda]) restricted to the current file.
2330 Pressing `<' twice means to restrict to the current subtree or region
2334 (let* ((prefix-descriptions nil)
2335 (org-agenda-buffer-name org-agenda-buffer-name)
2336 (org-agenda-window-setup (if (equal (buffer-name)
2337 org-agenda-buffer-name)
2339 org-agenda-window-setup))
2340 (org-agenda-custom-commands-orig org-agenda-custom-commands)
2341 (org-agenda-custom-commands
2342 ;; normalize different versions
2346 (cond ((stringp (cdr x))
2347 (push x prefix-descriptions)
2349 ((stringp (nth 1 x)) x)
2350 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2351 (t (cons (car x) (cons "" (cdr x))))))
2352 org-agenda-custom-commands)))
2353 (buf (current-buffer))
2354 (bfn (buffer-file-name (buffer-base-buffer)))
2355 entry key type match lprops ans)
2356 ;; Turn off restriction unless there is an overriding one,
2357 (unless org-agenda-overriding-restriction
2358 (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
2359 ;; There is a request to keep the file list in place
2360 (put 'org-agenda-files 'org-restrict nil))
2361 (setq org-agenda-restrict nil)
2362 (move-marker org-agenda-restrict-begin nil)
2363 (move-marker org-agenda-restrict-end nil))
2364 ;; Delete old local properties
2365 (put 'org-agenda-redo-command 'org-lprops nil)
2366 ;; Delete previously set last-arguments
2367 (put 'org-agenda-redo-command 'last-args nil)
2368 ;; Remember where this call originated
2369 (setq org-agenda-last-dispatch-buffer (current-buffer))
2371 (setq ans (org-agenda-get-restriction-and-command prefix-descriptions)
2373 restriction (cdr ans)))
2374 ;; If we have sticky agenda buffers, set a name for the buffer,
2375 ;; depending on the invoking keys. The user may still set this
2376 ;; as a command option, which will overwrite what we do here.
2377 (if org-agenda-sticky
2378 (setq org-agenda-buffer-name (format "*Org Agenda(%s)*" keys)))
2379 ;; Establish the restriction, if any
2380 (when (and (not org-agenda-overriding-restriction) restriction)
2381 (put 'org-agenda-files 'org-restrict (list bfn))
2383 ((eq restriction 'region)
2384 (setq org-agenda-restrict t)
2385 (move-marker org-agenda-restrict-begin (region-beginning))
2386 (move-marker org-agenda-restrict-end (region-end)))
2387 ((eq restriction 'subtree)
2389 (setq org-agenda-restrict t)
2390 (org-back-to-heading t)
2391 (move-marker org-agenda-restrict-begin (point))
2392 (move-marker org-agenda-restrict-end
2393 (progn (org-end-of-subtree t)))))))
2395 ;; For example the todo list should not need it (but does...)
2397 ((setq entry (assoc keys org-agenda-custom-commands))
2398 (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry)))
2400 (setq type (nth 2 entry) match (eval (nth 3 entry))
2401 lprops (nth 4 entry))
2402 (put 'org-agenda-redo-command 'org-lprops lprops)
2405 (org-let lprops '(org-agenda-list current-prefix-arg)))
2407 (org-let lprops '(org-todo-list current-prefix-arg)))
2409 (org-let lprops '(org-search-view current-prefix-arg match nil)))
2411 (org-let lprops '(org-agenda-list-stuck-projects
2412 current-prefix-arg)))
2414 (org-let lprops '(org-tags-view current-prefix-arg match)))
2415 ((eq type 'tags-todo)
2416 (org-let lprops '(org-tags-view '(4) match)))
2418 (org-let lprops '(org-todo-list match)))
2419 ((eq type 'tags-tree)
2420 (org-check-for-org-mode)
2421 (org-let lprops '(org-match-sparse-tree current-prefix-arg match)))
2422 ((eq type 'todo-tree)
2423 (org-check-for-org-mode)
2425 '(org-occur (concat "^" org-outline-regexp "[ \t]*"
2426 (regexp-quote match) "\\>"))))
2427 ((eq type 'occur-tree)
2428 (org-check-for-org-mode)
2429 (org-let lprops '(org-occur match)))
2431 (org-let lprops '(funcall type match)))
2433 (org-let lprops '(funcall type match)))
2434 (t (error "Invalid custom agenda command type %s" type))))
2435 (org-agenda-run-series (nth 1 entry) (cddr entry))))
2437 (setq org-agenda-custom-commands org-agenda-custom-commands-orig)
2438 (customize-variable 'org-agenda-custom-commands))
2439 ((equal keys "a") (call-interactively 'org-agenda-list))
2440 ((equal keys "s") (call-interactively 'org-search-view))
2441 ((equal keys "t") (call-interactively 'org-todo-list))
2442 ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
2443 ((equal keys "m") (call-interactively 'org-tags-view))
2444 ((equal keys "M") (org-call-with-arg 'org-tags-view (or arg '(4))))
2445 ((equal keys "e") (call-interactively 'org-store-agenda-views))
2446 ((equal keys "?") (org-tags-view nil "+FLAGGED")
2450 (unless (current-message)
2451 (let* ((m (org-agenda-get-any-marker))
2452 (note (and m (org-entry-get m "THEFLAGGINGNOTE"))))
2455 "FLAGGING-NOTE ([?] for more info): "
2457 (replace-regexp-in-string
2459 (copy-sequence note))
2460 nil 'face 'org-warning)))))))
2463 (unless (eq major-mode 'org-mode)
2464 (error "This is not an Org-mode file"))
2466 (put 'org-agenda-files 'org-restrict (list bfn))
2467 (org-call-with-arg 'org-timeline arg)))
2468 ((equal keys "#") (call-interactively 'org-agenda-list-stuck-projects))
2469 ((equal keys "/") (call-interactively 'org-occur-in-agenda-files))
2470 ((equal keys "!") (customize-variable 'org-stuck-projects))
2471 (t (error "Invalid agenda key"))))))
2473 (defun org-agenda-append-agenda ()
2474 "Append another agenda view to the current one.
2475 This function allows interactive building of block agendas.
2476 Agenda views are separated by `org-agenda-block-separator'."
2478 (unless (string= (buffer-name) org-agenda-buffer-name)
2479 (error "Can only append from within agenda buffer"))
2480 (let ((org-agenda-multi t))
2484 (defun org-agenda-normalize-custom-commands (cmds)
2488 (cond ((stringp (cdr x)) nil)
2489 ((stringp (nth 1 x)) x)
2490 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2491 (t (cons (car x) (cons "" (cdr x))))))
2494 (defun org-agenda-get-restriction-and-command (prefix-descriptions)
2495 "The user interface for selecting an agenda command."
2497 (let* ((bfn (buffer-file-name (buffer-base-buffer)))
2498 (restrict-ok (and bfn (eq major-mode 'org-mode)))
2499 (region-p (org-region-active-p))
2500 (custom org-agenda-custom-commands)
2502 restriction second-time
2503 c entry key type match prefixes rmheader header-end custom1 desc
2504 line lines left right n n1)
2505 (save-window-excursion
2506 (delete-other-windows)
2507 (org-switch-to-buffer-other-window " *Agenda Commands*")
2509 (insert (eval-when-compile
2511 "Press key for an agenda command: < Buffer, subtree/region restriction
2512 -------------------------------- > Remove restriction
2513 a Agenda for current week or day e Export agenda views
2514 t List of all TODO entries T Entries with special TODO kwd
2515 m Match a TAGS/PROP/TODO query M Like m, but only TODO entries
2516 L Timeline for current buffer # List stuck projects (!=configure)
2517 s Search for keywords * Toggle sticky agenda views
2518 / Multi-occur ? Find :FLAGGED: entries
2519 C Configure custom agenda commands
2522 (while (string-match
2523 "\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)"
2525 (setq start (match-end 0))
2526 (add-text-properties (match-beginning 2) (match-end 2)
2527 '(face bold) header))
2529 (setq header-end (move-marker (make-marker) (point)))
2531 (setq custom1 custom)
2532 (when (eq rmheader t)
2534 (re-search-forward ":" nil t)
2535 (delete-region (match-end 0) (point-at-eol))
2538 (delete-region (match-end 0) (point-at-eol))
2539 (move-marker header-end (match-end 0)))
2540 (goto-char header-end)
2541 (delete-region (point) (point-max))
2543 ;; Produce all the lines that describe custom commands and prefixes
2545 (while (setq entry (pop custom1))
2546 (setq key (car entry) desc (nth 1 entry)
2548 match (nth 3 entry))
2549 (if (> (length key) 1)
2550 (add-to-list 'prefixes (string-to-char key))
2554 (org-add-props (copy-sequence key)
2557 ((string-match "\\S-" desc) desc)
2558 ((eq type 'agenda) "Agenda for current week or day")
2559 ((eq type 'alltodo) "List of all TODO entries")
2560 ((eq type 'search) "Word search")
2561 ((eq type 'stuck) "List of stuck projects")
2562 ((eq type 'todo) "TODO keyword")
2563 ((eq type 'tags) "Tags query")
2564 ((eq type 'tags-todo) "Tags (TODO)")
2565 ((eq type 'tags-tree) "Tags tree")
2566 ((eq type 'todo-tree) "TODO kwd tree")
2567 ((eq type 'occur-tree) "Occur tree")
2568 ((functionp type) (if (symbolp type)
2570 "Lambda expression"))
2572 (if org-agenda-menu-show-matcher
2577 (setq match (copy-sequence match))
2578 (org-add-props match nil 'face 'org-warning))
2580 (format "set of %d commands" (length match)))
2582 (if (org-string-nw-p match)
2583 (add-text-properties
2584 0 (length line) (list 'help-echo
2585 (concat "Matcher: "match)) line)))
2587 (setq lines (nreverse lines))
2592 (org-add-props (char-to-string x)
2594 (or (cdr (assoc (concat selstring
2596 prefix-descriptions))
2601 ;; Check if we should display in two columns
2602 (if org-agenda-menu-two-column
2604 (setq n (length lines)
2605 n1 (+ (/ n 2) (mod n 2))
2606 right (nthcdr n1 lines)
2607 left (copy-sequence lines))
2608 (setcdr (nthcdr (1- n1) left) nil))
2609 (setq left lines right nil))
2611 (insert "\n" (pop left))
2613 (if (< (current-column) 40)
2614 (move-to-column 40 t)
2616 (insert (pop right))))
2618 ;; Make the window the right size
2619 (goto-char (point-min))
2621 (if (not (pos-visible-in-window-p (point-max)))
2622 (org-fit-window-to-buffer))
2623 (setq second-time t)
2624 (org-fit-window-to-buffer))
2626 ;; Ask for selection
2627 (message "Press key for agenda command%s:"
2628 (if (or restrict-ok org-agenda-overriding-restriction)
2629 (if org-agenda-overriding-restriction
2630 " (restriction lock active)"
2632 (format " (restricted to %s)" restriction)
2635 (setq c (read-char-exclusive))
2638 ((assoc (char-to-string c) custom)
2639 (setq selstring (concat selstring (char-to-string c)))
2640 (throw 'exit (cons selstring restriction)))
2642 (setq selstring (concat selstring (char-to-string c))
2644 rmheader (or rmheader t)
2645 custom (delq nil (mapcar
2647 (if (or (= (length (car x)) 1)
2648 (/= (string-to-char (car x)) c))
2650 (cons (substring (car x) 1) (cdr x))))
2653 (org-toggle-sticky-agenda)
2655 ((and (not restrict-ok) (memq c '(?1 ?0 ?<)))
2656 (message "Restriction is only possible in Org-mode buffers")
2659 (org-agenda-remove-restriction-lock 'noupdate)
2660 (setq restriction 'buffer))
2662 (org-agenda-remove-restriction-lock 'noupdate)
2663 (setq restriction (if region-p 'region 'subtree)))
2665 (org-agenda-remove-restriction-lock 'noupdate)
2668 ((eq restriction 'buffer)
2669 (if region-p 'region 'subtree))
2670 ((memq restriction '(subtree region))
2674 (org-agenda-remove-restriction-lock 'noupdate)
2675 (setq restriction nil))
2676 ((and (equal selstring "") (memq c '(?s ?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/ ??)))
2677 (throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
2678 ((and (> (length selstring) 0) (eq c ?\d))
2680 (org-agenda-get-restriction-and-command prefix-descriptions))
2682 ((equal c ?q) (error "Abort"))
2683 (t (error "Invalid key %c" c))))))))
2685 (defvar org-agenda-overriding-arguments nil) ; dynamically scoped parameter
2686 (defvar org-agenda-last-arguments nil
2687 "The arguments of the previous call to `org-agenda'.")
2688 (defun org-agenda-run-series (name series)
2689 (org-let (nth 1 series) '(org-prepare-agenda name))
2690 ;; We need to reset agenda markers here, because when constructing a
2691 ;; block agenda, the individual blocks do not do that.
2692 (org-agenda-reset-markers)
2693 (let* ((org-agenda-multi t)
2694 (redo (list 'org-agenda-run-series name (list 'quote series)))
2695 (org-agenda-overriding-arguments
2696 (or org-agenda-overriding-arguments
2697 (unless (null (delq nil (get 'org-agenda-redo-command 'last-args)))
2698 (get 'org-agenda-redo-command 'last-args))))
2700 (gprops (nth 1 series))
2701 match ;; The byte compiler incorrectly complains about this. Keep it!
2703 (while (setq cmd (pop cmds))
2704 (setq type (car cmd) match (eval (nth 1 cmd)) lprops (nth 2 cmd))
2707 (org-let2 gprops lprops
2708 '(call-interactively 'org-agenda-list)))
2710 (org-let2 gprops lprops
2711 '(call-interactively 'org-todo-list)))
2713 (org-let2 gprops lprops
2714 '(org-search-view current-prefix-arg match nil)))
2716 (org-let2 gprops lprops
2717 '(call-interactively 'org-agenda-list-stuck-projects)))
2719 (org-let2 gprops lprops
2720 '(org-tags-view current-prefix-arg match)))
2721 ((eq type 'tags-todo)
2722 (org-let2 gprops lprops
2723 '(org-tags-view '(4) match)))
2725 (org-let2 gprops lprops
2726 '(org-todo-list match)))
2728 (org-let2 gprops lprops
2729 '(funcall type match)))
2730 (t (error "Invalid type in command series"))))
2732 (setq org-agenda-redo-command redo)
2733 (put 'org-agenda-redo-command 'last-args org-agenda-last-arguments)
2734 (goto-char (point-min)))
2735 (org-fit-agenda-window)
2736 (org-let (nth 1 series) '(org-finalize-agenda)))
2739 (defmacro org-batch-agenda (cmd-key &rest parameters)
2740 "Run an agenda command in batch mode and send the result to STDOUT.
2741 If CMD-KEY is a string of length 1, it is used as a key in
2742 `org-agenda-custom-commands' and triggers this command. If it is a
2743 longer string it is used as a tags/todo match string.
2744 Parameters are alternating variable names and values that will be bound
2745 before running the agenda command."
2746 (org-eval-in-environment (org-make-parameter-alist parameters)
2747 (if (> (length cmd-key) 2)
2748 (org-tags-view nil cmd-key)
2749 (org-agenda nil cmd-key)))
2750 (set-buffer org-agenda-buffer-name)
2751 (princ (buffer-string)))
2752 (def-edebug-spec org-batch-agenda (form &rest sexp))
2754 (defvar org-agenda-info nil)
2757 (defmacro org-batch-agenda-csv (cmd-key &rest parameters)
2758 "Run an agenda command in batch mode and send the result to STDOUT.
2759 If CMD-KEY is a string of length 1, it is used as a key in
2760 `org-agenda-custom-commands' and triggers this command. If it is a
2761 longer string it is used as a tags/todo match string.
2762 Parameters are alternating variable names and values that will be bound
2763 before running the agenda command.
2765 The output gives a line for each selected agenda item. Each
2766 item is a list of comma-separated values, like this:
2768 category,head,type,todo,tags,date,time,extra,priority-l,priority-n
2770 category The category of the item
2771 head The headline, without TODO kwd, TAGS and PRIORITY
2772 type The type of the agenda entry, can be
2773 todo selected in TODO match
2774 tagsmatch selected in tags match
2775 diary imported from diary
2776 deadline a deadline on given date
2777 scheduled scheduled on given date
2778 timestamp entry has timestamp on given date
2779 closed entry was closed on given date
2780 upcoming-deadline warning about deadline
2781 past-scheduled forwarded scheduled item
2782 block entry has date block including g. date
2783 todo The todo keyword, if any
2784 tags All tags including inherited ones, separated by colons
2785 date The relevant date, like 2007-2-14
2786 time The time, like 15:00-16:50
2787 extra Sting with extra planning info
2788 priority-l The priority letter if any was given
2789 priority-n The computed numerical priority
2790 agenda-day The day in the agenda where this is listed"
2791 (org-eval-in-environment (append '((org-agenda-remove-tags t))
2792 (org-make-parameter-alist parameters))
2793 (if (> (length cmd-key) 2)
2794 (org-tags-view nil cmd-key)
2795 (org-agenda nil cmd-key)))
2796 (set-buffer org-agenda-buffer-name)
2797 (let* ((lines (org-split-string (buffer-string) "\n"))
2799 (while (setq line (pop lines))
2801 (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
2802 (setq org-agenda-info
2803 (org-fix-agenda-info (text-properties-at 0 line)))
2805 (mapconcat 'org-agenda-export-csv-mapper
2806 '(org-category txt type todo tags date time extra
2807 priority-letter priority agenda-day)
2810 (def-edebug-spec org-batch-agenda-csv (form &rest sexp))
2812 (defun org-fix-agenda-info (props)
2813 "Make sure all properties on an agenda item have a canonical form.
2814 This ensures the export commands can easily use it."
2816 (when (setq tmp (plist-get props 'tags))
2817 (setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
2818 (when (setq tmp (plist-get props 'date))
2819 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
2820 (let ((calendar-date-display-form '(year "-" month "-" day)))
2821 '((format "%4d, %9s %2s, %4s" dayname monthname day year))
2823 (setq tmp (calendar-date-string tmp)))
2824 (setq props (plist-put props 'date tmp)))
2825 (when (setq tmp (plist-get props 'day))
2826 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
2827 (let ((calendar-date-display-form '(year "-" month "-" day)))
2828 (setq tmp (calendar-date-string tmp)))
2829 (setq props (plist-put props 'day tmp))
2830 (setq props (plist-put props 'agenda-day tmp)))
2831 (when (setq tmp (plist-get props 'txt))
2832 (when (string-match "\\[#\\([A-Z0-9]\\)\\] ?" tmp)
2833 (plist-put props 'priority-letter (match-string 1 tmp))
2834 (setq tmp (replace-match "" t t tmp)))
2835 (when (and (setq re (plist-get props 'org-todo-regexp))
2836 (setq re (concat "\\`\\.*" re " ?"))
2837 (string-match re tmp))
2838 (plist-put props 'todo (match-string 1 tmp))
2839 (setq tmp (replace-match "" t t tmp)))
2840 (plist-put props 'txt tmp)))
2843 (defun org-agenda-export-csv-mapper (prop)
2844 (let ((res (plist-get org-agenda-info prop)))
2849 (t (prin1-to-string res))))
2850 (while (string-match "," res)
2851 (setq res (replace-match ";" t t res)))
2856 (defun org-store-agenda-views (&rest parameters)
2858 (eval (list 'org-batch-store-agenda-views)))
2861 (defmacro org-batch-store-agenda-views (&rest parameters)
2862 "Run all custom agenda commands that have a file argument."
2863 (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
2865 (dir default-directory)
2866 (pars (org-make-parameter-alist parameters))
2867 cmd thiscmdkey files opts cmd-or-set)
2868 (save-window-excursion
2870 (setq cmd (pop cmds)
2871 thiscmdkey (car cmd)
2872 cmd-or-set (nth 2 cmd)
2873 opts (nth (if (listp cmd-or-set) 3 4) cmd)
2874 files (nth (if (listp cmd-or-set) 4 5) cmd))
2875 (if (stringp files) (setq files (list files)))
2877 (org-eval-in-environment (append org-agenda-exporter-settings
2879 (org-agenda nil thiscmdkey))
2880 (set-buffer org-agenda-buffer-name)
2882 (org-eval-in-environment (append org-agenda-exporter-settings
2884 (org-agenda-write (expand-file-name (pop files) dir) nil t)))
2885 (and (get-buffer org-agenda-buffer-name)
2886 (kill-buffer org-agenda-buffer-name)))))))
2887 (def-edebug-spec org-batch-store-agenda-views (&rest sexp))
2889 (defun org-agenda-mark-header-line (pos)
2890 "Mark the line at POS as an agenda structure header."
2893 (put-text-property (point-at-bol) (point-at-eol)
2894 'org-agenda-structural-header t)
2895 (when org-agenda-title-append
2896 (put-text-property (point-at-bol) (point-at-eol)
2897 'org-agenda-title-append org-agenda-title-append))))
2899 (defvar org-mobile-creating-agendas)
2900 (defvar org-agenda-write-buffer-name "Agenda View")
2901 (defun org-agenda-write (file &optional open nosettings)
2902 "Write the current buffer (an agenda view) as a file.
2903 Depending on the extension of the file name, plain text (.txt),
2904 HTML (.html or .htm) or Postscript (.ps) is produced.
2905 If the extension is .ics, run icalendar export over all files used
2906 to construct the agenda and limit the export to entries listed in the
2908 With prefix argument OPEN, open the new file immediately.
2909 If NOSETTINGS is given, do not scope the settings of
2910 `org-agenda-exporter-settings' into the export commands. This is used when
2911 the settings have already been scoped and we do not wish to overrule other,
2912 higher priority settings."
2913 (interactive "FWrite agenda to file: \nP")
2914 (if (not (file-writable-p file))
2915 (error "Cannot write agenda to file %s" file))
2916 (org-let (if nosettings nil org-agenda-exporter-settings)
2918 (save-window-excursion
2919 (org-agenda-mark-filtered-text)
2920 (let ((bs (copy-sequence (buffer-string))) beg)
2921 (org-agenda-unmark-filtered-text)
2923 (rename-buffer org-agenda-write-buffer-name t)
2924 (set-buffer-modified-p nil)
2926 (org-agenda-remove-marked-text 'org-filtered)
2927 (while (setq beg (text-property-any (point-min) (point-max)
2930 beg (or (next-single-property-change beg 'org-filtered)
2932 (run-hooks 'org-agenda-before-write-hook)
2934 ((org-bound-and-true-p org-mobile-creating-agendas)
2935 (org-mobile-write-agenda-for-mobile file))
2936 ((string-match "\\.html?\\'" file)
2938 (set-buffer (htmlize-buffer (current-buffer)))
2940 (when (and org-agenda-export-html-style
2941 (string-match "<style>" org-agenda-export-html-style))
2942 ;; replace <style> section with org-agenda-export-html-style
2943 (goto-char (point-min))
2944 (kill-region (- (search-forward "<style") 6)
2945 (search-forward "</style>"))
2946 (insert org-agenda-export-html-style))
2948 (kill-buffer (current-buffer))
2949 (message "HTML written to %s" file))
2950 ((string-match "\\.ps\\'" file)
2952 (ps-print-buffer-with-faces file)
2953 (message "Postscript written to %s" file))
2954 ((string-match "\\.pdf\\'" file)
2956 (ps-print-buffer-with-faces
2957 (concat (file-name-sans-extension file) ".ps"))
2958 (call-process "ps2pdf" nil nil nil
2960 (concat (file-name-sans-extension file) ".ps"))
2961 (expand-file-name file))
2962 (delete-file (concat (file-name-sans-extension file) ".ps"))
2963 (message "PDF written to %s" file))
2964 ((string-match "\\.ics\\'" file)
2965 (require 'org-icalendar)
2966 (let ((org-agenda-marker-table
2967 (org-create-marker-find-array
2968 (org-agenda-collect-markers)))
2969 (org-icalendar-verify-function 'org-check-agenda-marker-table)
2970 (org-combined-agenda-icalendar-file file))
2971 (apply 'org-export-icalendar 'combine
2972 (org-agenda-files nil 'ifmode))))
2974 (let ((bs (buffer-string)))
2979 (kill-buffer (current-buffer))
2980 (message "Plain text written to %s" file))))))))
2981 (set-buffer org-agenda-buffer-name))
2982 (when open (org-open-file file)))
2984 (defvar org-agenda-tag-filter-overlays nil)
2985 (defvar org-agenda-cat-filter-overlays nil)
2987 (defun org-agenda-mark-filtered-text ()
2988 "Mark all text hidden by filtering with a text property."
2989 (let ((inhibit-read-only t))
2992 (when (equal (overlay-buffer o) (current-buffer))
2994 (overlay-start o) (overlay-end o)
2996 (append org-agenda-tag-filter-overlays
2997 org-agenda-cat-filter-overlays))))
2999 (defun org-agenda-unmark-filtered-text ()
3000 "Remove the filtering text property."
3001 (let ((inhibit-read-only t))
3002 (remove-text-properties (point-min) (point-max) '(org-filtered t))))
3004 (defun org-agenda-remove-marked-text (property &optional value)
3005 "Delete all text marked with VALUE of PROPERTY.
3006 VALUE defaults to t."
3008 (setq value (or value t))
3009 (while (setq beg (text-property-any (point-min) (point-max)
3012 beg (or (next-single-property-change beg 'org-filtered)
3015 (defun org-agenda-add-entry-text ()
3016 "Add entry text to agenda lines.
3017 This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the
3018 entry text following headings shown in the agenda.
3019 Drawers will be excluded, also the line with scheduling/deadline info."
3020 (when (and (> org-agenda-add-entry-text-maxlines 0)
3021 (not (org-bound-and-true-p org-mobile-creating-agendas)))
3023 (goto-char (point-min))
3025 (if (not (setq m (org-get-at-bol 'org-hd-marker)))
3026 (beginning-of-line 2)
3027 (setq txt (org-agenda-get-some-entry-text
3028 m org-agenda-add-entry-text-maxlines " > "))
3030 (if (string-match "\\S-" txt)
3032 (or (eobp) (forward-char 1))))))))
3034 (defun org-agenda-get-some-entry-text (marker n-lines &optional indent
3036 "Extract entry text from MARKER, at most N-LINES lines.
3037 This will ignore drawers etc, just get the text.
3038 If INDENT is given, prefix every line with this string. If KEEP is
3039 given, it is a list of symbols, defining stuff that should not be
3040 removed from the entry content. Currently only `planning' is allowed here."
3041 (let (txt drawer-re kwd-time-re ind)
3043 (with-current-buffer (marker-buffer marker)
3044 (if (not (eq major-mode 'org-mode))
3051 (setq txt (buffer-substring
3052 (min (1+ (point)) (point-max))
3053 (progn (outline-next-heading) (point)))
3054 drawer-re org-drawer-regexp
3055 kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
3059 (when org-agenda-add-entry-text-descriptive-links
3060 (goto-char (point-min))
3061 (while (org-activate-bracket-links (point-max))
3062 (add-text-properties (match-beginning 0) (match-end 0)
3064 (goto-char (point-min))
3065 (while (re-search-forward org-bracket-link-regexp (point-max) t)
3066 (set-text-properties (match-beginning 0) (match-end 0)
3068 (goto-char (point-min))
3069 (while (re-search-forward drawer-re nil t)
3072 (progn (re-search-forward
3073 "^[ \t]*:END:.*\n?" nil 'move)
3075 (unless (member 'planning keep)
3076 (goto-char (point-min))
3077 (while (re-search-forward kwd-time-re nil t)
3078 (replace-match "")))
3079 (goto-char (point-min))
3080 (when org-agenda-entry-text-exclude-regexps
3081 (let ((re-list org-agenda-entry-text-exclude-regexps) re)
3082 (while (setq re (pop re-list))
3083 (goto-char (point-min))
3084 (while (re-search-forward re nil t)
3085 (replace-match "")))))
3086 (goto-char (point-max))
3087 (skip-chars-backward " \t\n")
3088 (if (looking-at "[ \t\n]+\\'") (replace-match ""))
3090 ;; find and remove min common indentation
3091 (goto-char (point-min))
3092 (untabify (point-min) (point-max))
3093 (setq ind (org-get-indentation))
3095 (unless (looking-at "[ \t]*$")
3096 (setq ind (min ind (org-get-indentation))))
3097 (beginning-of-line 2))
3098 (goto-char (point-min))
3100 (unless (looking-at "[ \t]*$")
3101 (move-to-column ind)
3102 (delete-region (point-at-bol) (point)))
3103 (beginning-of-line 2))
3105 (run-hooks 'org-agenda-entry-text-cleanup-hook)
3107 (goto-char (point-min))
3109 (while (and (not (eobp)) (re-search-forward "^" nil t))
3110 (replace-match indent t t)))
3111 (goto-char (point-min))
3112 (while (looking-at "[ \t]*\n") (replace-match ""))
3113 (goto-char (point-max))
3114 (when (> (org-current-line)
3116 (org-goto-line (1+ n-lines))
3118 (setq txt (buffer-substring (point-min) (point)))))))))
3121 (defun org-agenda-collect-markers ()
3122 "Collect the markers pointing to entries in the agenda buffer."
3125 (goto-char (point-min))
3127 (when (setq m (or (org-get-at-bol 'org-hd-marker)
3128 (org-get-at-bol 'org-marker)))
3130 (beginning-of-line 2)))
3131 (nreverse markers)))
3133 (defun org-create-marker-find-array (marker-list)
3134 "Create a alist of files names with all marker positions in that file."
3136 (while (setq m (pop marker-list))
3137 (setq p (marker-position m)
3138 f (buffer-file-name (or (buffer-base-buffer
3140 (marker-buffer m))))
3141 (if (setq a (assoc f tbl))
3142 (push (marker-position m) (cdr a))
3143 (push (list f p) tbl)))
3144 (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
3147 (defvar org-agenda-marker-table nil) ; dynamically scoped parameter
3148 (defun org-check-agenda-marker-table ()
3149 "Check of the current entry is on the marker list."
3150 (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
3152 (and (setq a (assoc file org-agenda-marker-table))
3155 (org-back-to-heading t)
3156 (member (point) (cdr a)))))))
3158 (defun org-check-for-org-mode ()
3159 "Make sure current buffer is in org-mode. Error if not."
3160 (or (eq major-mode 'org-mode)
3161 (error "Cannot execute org-mode agenda command on buffer in %s"
3164 (defun org-fit-agenda-window ()
3165 "Fit the window to the buffer size."
3166 (and (memq org-agenda-window-setup '(reorganize-frame))
3167 (fboundp 'fit-window-to-buffer)
3168 (org-fit-window-to-buffer
3170 (floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
3171 (floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
3173 ;;; Agenda prepare and finalize
3175 (defvar org-agenda-multi nil) ; dynamically scoped
3176 (defvar org-agenda-buffer-name "*Org Agenda*")
3177 (defvar org-pre-agenda-window-conf nil)
3178 (defvar org-agenda-columns-active nil)
3179 (defvar org-agenda-name nil)
3180 (defvar org-agenda-tag-filter nil)
3181 (defvar org-agenda-category-filter nil)
3182 (defvar org-agenda-tag-filter-while-redo nil)
3183 (defvar org-agenda-tag-filter-preset nil
3184 "A preset of the tags filter used for secondary agenda filtering.
3185 This must be a list of strings, each string must be a single tag preceded
3187 This variable should not be set directly, but agenda custom commands can
3188 bind it in the options section. The preset filter is a global property of
3189 the entire agenda view. In a block agenda, it will not work reliably to
3190 define a filter for one of the individual blocks. You need to set it in
3191 the global options and expect it to be applied to the entire view.")
3193 (defvar org-agenda-category-filter-preset nil
3194 "A preset of the category filter used for secondary agenda filtering.
3195 This must be a list of strings, each string must be a single category
3196 preceded by \"+\" or \"-\".
3197 This variable should not be set directly, but agenda custom commands can
3198 bind it in the options section. The preset filter is a global property of
3199 the entire agenda view. In a block agenda, it will not work reliably to
3200 define a filter for one of the individual blocks. You need to set it in
3201 the global options and expect it to be applied to the entire view.")
3204 (defun org-agenda-use-sticky-p ()
3205 "Return non-NIL if existing agenda buffer named
3206 `org-agenda-buffer-name' exists, and should be shown instead of
3207 generating a new one"
3209 ;; turned off by user
3211 ;; For multi-agenda buffer already exists
3212 (not org-agenda-multi)
3214 (get-buffer org-agenda-buffer-name)
3215 ;; C-u parameter is same as last call
3216 (with-current-buffer (get-buffer org-agenda-buffer-name)
3218 (equal current-prefix-arg
3219 org-agenda-last-prefix-arg)
3220 ;; In case user turned stickiness on, while having existing
3221 ;; Agenda buffer active, don't reuse that buffer, because it
3222 ;; does not have org variables local
3223 org-agenda-this-buffer-is-sticky))))
3225 (defun org-prepare-agenda-window (abuf)
3226 "Setup agenda buffer in the window"
3227 (let* ((awin (get-buffer-window abuf))
3230 ((equal (current-buffer) abuf) nil)
3231 (awin (select-window awin))
3232 ((not (setq wconf (current-window-configuration))))
3233 ((equal org-agenda-window-setup 'current-window)
3234 (org-pop-to-buffer-same-window abuf))
3235 ((equal org-agenda-window-setup 'other-window)
3236 (org-switch-to-buffer-other-window abuf))
3237 ((equal org-agenda-window-setup 'other-frame)
3238 (switch-to-buffer-other-frame abuf))
3239 ((equal org-agenda-window-setup 'reorganize-frame)
3240 (delete-other-windows)
3241 (org-switch-to-buffer-other-window abuf)))
3242 ;; additional test in case agenda is invoked from within agenda
3243 ;; buffer via elisp link
3244 (unless (equal (current-buffer) abuf)
3245 (org-pop-to-buffer-same-window abuf))
3246 (setq org-pre-agenda-window-conf wconf)))
3248 (defun org-prepare-agenda (&optional name)
3249 (if (org-agenda-use-sticky-p)
3251 ;; Popup existing buffer
3252 (org-prepare-agenda-window (get-buffer org-agenda-buffer-name))
3253 (message "Sticky Agenda buffer, use `r' to refresh")
3255 (setq org-todo-keywords-for-agenda nil)
3256 (setq org-drawers-for-agenda nil)
3257 (unless org-agenda-persistent-filter
3258 (setq org-agenda-tag-filter nil
3259 org-agenda-category-filter nil))
3260 (put 'org-agenda-tag-filter :preset-filter org-agenda-tag-filter-preset)
3261 (put 'org-agenda-category-filter :preset-filter
3262 org-agenda-category-filter-preset)
3263 (if org-agenda-multi
3265 (setq buffer-read-only nil)
3266 (goto-char (point-max))
3267 (unless (or (bobp) org-agenda-compact-blocks
3268 (not org-agenda-block-separator))
3270 (if (stringp org-agenda-block-separator)
3271 org-agenda-block-separator
3272 (make-string (window-width) org-agenda-block-separator))
3274 (narrow-to-region (point) (point-max)))
3275 (setq org-done-keywords-for-agenda nil)
3277 ;; Setting any org variables that are in org-agenda-local-vars
3278 ;; list need to be done after the prepare call
3279 (org-prepare-agenda-window (get-buffer-create org-agenda-buffer-name))
3280 (setq buffer-read-only nil)
3281 (org-agenda-reset-markers)
3282 (let ((inhibit-read-only t)) (erase-buffer))
3284 (setq org-agenda-buffer (current-buffer))
3285 (setq org-agenda-contributing-files nil)
3286 (setq org-agenda-columns-active nil)
3287 (org-prepare-agenda-buffers (org-agenda-files nil 'ifmode))
3288 (setq org-todo-keywords-for-agenda
3289 (org-uniquify org-todo-keywords-for-agenda))
3290 (setq org-done-keywords-for-agenda
3291 (org-uniquify org-done-keywords-for-agenda))
3292 (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
3293 (setq org-agenda-last-prefix-arg current-prefix-arg)
3294 (setq org-agenda-this-buffer-name org-agenda-buffer-name)
3295 (and name (not org-agenda-name)
3296 (org-set-local 'org-agenda-name name)))
3297 (setq buffer-read-only nil)))
3299 (defun org-finalize-agenda ()
3300 "Finishing touch for the agenda buffer, called just before displaying it."
3301 (unless org-agenda-multi
3303 (let ((inhibit-read-only t))
3304 (goto-char (point-min))
3305 (while (org-activate-bracket-links (point-max))
3306 (add-text-properties (match-beginning 0) (match-end 0)
3308 (org-agenda-align-tags)
3309 (unless org-agenda-with-colors
3310 (remove-text-properties (point-min) (point-max) '(face nil))))
3311 (if (and (boundp 'org-agenda-overriding-columns-format)
3312 org-agenda-overriding-columns-format)
3313 (org-set-local 'org-agenda-overriding-columns-format
3314 org-agenda-overriding-columns-format))
3315 (if (and (boundp 'org-agenda-view-columns-initially)
3316 org-agenda-view-columns-initially)
3317 (org-agenda-columns))
3318 (when org-agenda-fontify-priorities
3319 (org-agenda-fontify-priorities))
3320 (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
3321 (org-agenda-dim-blocked-tasks))
3322 (org-agenda-mark-clocking-task)
3323 (when org-agenda-entry-text-mode
3324 (org-agenda-entry-text-hide)
3325 (org-agenda-entry-text-show))
3326 (if (functionp 'org-habit-insert-consistency-graphs)
3327 (org-habit-insert-consistency-graphs))
3328 (run-hooks 'org-finalize-agenda-hook)
3329 (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
3330 (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
3331 (org-agenda-filter-apply org-agenda-tag-filter 'tag))
3332 (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
3333 (org-agenda-filter-apply org-agenda-category-filter 'category))
3334 (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)
3337 (defun org-agenda-mark-clocking-task ()
3338 "Mark the current clock entry in the agenda if it is present."
3340 (if (eq (overlay-get o 'type) 'org-agenda-clocking)
3341 (delete-overlay o)))
3342 (overlays-in (point-min) (point-max)))
3343 (when (marker-buffer org-clock-hd-marker)
3345 (goto-char (point-min))
3347 (while (setq s (next-single-property-change (point) 'org-hd-marker))
3349 (when (equal (org-get-at-bol 'org-hd-marker)
3350 org-clock-hd-marker)
3351 (setq ov (make-overlay (point-at-bol) (1+ (point-at-eol))))
3352 (overlay-put ov 'type 'org-agenda-clocking)
3353 (overlay-put ov 'face 'org-agenda-clocking)
3354 (overlay-put ov 'help-echo
3355 "The clock is running in this item")))))))
3357 (defun org-agenda-fontify-priorities ()
3358 "Make highest priority lines bold, and lowest italic."
3360 (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-priority)
3361 (delete-overlay o)))
3362 (overlays-in (point-min) (point-max)))
3364 (let ((inhibit-read-only t)
3366 (goto-char (point-min))
3367 (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
3368 (setq h (or (get-char-property (point) 'org-highest-priority)
3369 org-highest-priority)
3370 l (or (get-char-property (point) 'org-lowest-priority)
3371 org-lowest-priority)
3372 p (string-to-char (match-string 1))
3373 b (match-beginning 0)
3374 e (if (eq org-agenda-fontify-priorities 'cookies)
3377 ov (make-overlay b e))
3380 (cond ((org-face-from-face-or-color
3382 (cdr (assoc p org-priority-faces))))
3383 ((and (listp org-agenda-fontify-priorities)
3384 (org-face-from-face-or-color
3386 (cdr (assoc p org-agenda-fontify-priorities)))))
3387 ((equal p l) 'italic)
3388 ((equal p h) 'bold)))
3389 (overlay-put ov 'org-type 'org-priority)))))
3391 (defun org-agenda-dim-blocked-tasks ()
3392 "Dim currently blocked TODO's in the agenda display."
3393 (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-blocked-todo)
3394 (delete-overlay o)))
3395 (overlays-in (point-min) (point-max)))
3397 (let ((inhibit-read-only t)
3398 (org-depend-tag-blocked nil)
3399 (invis (eq org-agenda-dim-blocked-tasks 'invisible))
3400 org-blocked-by-checkboxes
3401 invis1 b e p ov h l)
3402 (goto-char (point-min))
3403 (while (let ((pos (next-single-property-change (point) 'todo-state)))
3404 (and pos (goto-char (1+ pos))))
3405 (setq org-blocked-by-checkboxes nil invis1 invis)
3406 (let ((marker (org-get-at-bol 'org-hd-marker)))
3408 (with-current-buffer (marker-buffer marker)
3409 (save-excursion (goto-char marker)
3410 (org-entry-blocked-p))))
3411 (if org-blocked-by-checkboxes (setq invis1 nil))
3413 (max (point-min) (1- (point-at-bol)))
3416 ov (make-overlay b e))
3418 (overlay-put ov 'invisible t)
3419 (overlay-put ov 'face 'org-agenda-dimmed-todo-face))
3420 (overlay-put ov 'org-type 'org-blocked-todo)))))))
3422 (defvar org-agenda-skip-function nil
3423 "Function to be called at each match during agenda construction.
3424 If this function returns nil, the current match should not be skipped.
3425 Otherwise, the function must return a position from where the search
3426 should be continued.
3427 This may also be a Lisp form, it will be evaluated.
3428 Never set this variable using `setq' or so, because then it will apply
3429 to all future agenda commands. If you do want a global skipping condition,
3430 use the option `org-agenda-skip-function-global' instead.
3431 The correct usage for `org-agenda-skip-function' is to bind it with
3432 `let' to scope it dynamically into the agenda-constructing command.
3433 A good way to set it is through options in `org-agenda-custom-commands'.")
3435 (defun org-agenda-skip ()
3436 "Throw to `:skip' in places that should be skipped.
3437 Also moves point to the end of the skipped region, so that search can
3438 continue from there."
3439 (let ((p (point-at-bol)) to)
3440 (and org-agenda-skip-archived-trees (not org-agenda-archives-mode)
3441 (get-text-property p :org-archived)
3442 (org-end-of-subtree t)
3444 (and org-agenda-skip-comment-trees
3445 (get-text-property p :org-comment)
3446 (org-end-of-subtree t)
3448 (if (equal (char-after p) ?#) (throw :skip t))
3449 (when (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global)
3450 (org-agenda-skip-eval org-agenda-skip-function)))
3454 (defun org-agenda-skip-eval (form)
3455 "If FORM is a function or a list, call (or eval) is and return result.
3456 `save-excursion' and `save-match-data' are wrapped around the call, so point
3457 and match data are returned to the previous state no matter what these
3461 (or (setq fp (functionp form))
3469 (defvar org-agenda-markers nil
3470 "List of all currently active markers created by `org-agenda'.")
3471 (defvar org-agenda-last-marker-time (org-float-time)
3472 "Creation time of the last agenda marker.")
3474 (defun org-agenda-new-marker (&optional pos)
3475 "Return a new agenda marker.
3476 Org-mode keeps a list of these markers and resets them when they are
3478 (let ((m (copy-marker (or pos (point)))))
3479 (setq org-agenda-last-marker-time (org-float-time))
3480 (if org-agenda-buffer
3481 (with-current-buffer org-agenda-buffer
3482 (push m org-agenda-markers))
3483 (push m org-agenda-markers))
3486 (defun org-agenda-reset-markers ()
3487 "Reset markers created by `org-agenda'."
3488 (while org-agenda-markers
3489 (move-marker (pop org-agenda-markers) nil)))
3491 (defun org-agenda-save-markers-for-cut-and-paste (beg end)
3492 "Save relative positions of markers in region.
3493 This check for agenda markers in all agenda buffers currently active."
3494 (dolist (buf (buffer-list))
3495 (with-current-buffer buf
3496 (when (eq major-mode 'org-agenda-mode)
3497 (mapc (lambda (m) (org-check-and-save-marker m beg end))
3498 org-agenda-markers)))))
3502 (defun org-agenda-entry-text-show-here ()
3503 "Add some text from the entry as context to the current line."
3505 (setq m (org-get-at-bol 'org-hd-marker))
3506 (unless (marker-buffer m)
3507 (error "No marker points to an entry here"))
3508 (setq txt (concat "\n" (org-no-properties
3509 (org-agenda-get-some-entry-text
3510 m org-agenda-entry-text-maxlines " > "))))
3511 (when (string-match "\\S-" txt)
3512 (setq o (make-overlay (point-at-bol) (point-at-eol)))
3513 (overlay-put o 'evaporate t)
3514 (overlay-put o 'org-overlay-type 'agenda-entry-content)
3515 (overlay-put o 'after-string txt))))
3517 (defun org-agenda-entry-text-show ()
3518 "Add entry context for all agenda lines."
3521 (goto-char (point-max))
3522 (beginning-of-line 1)
3524 (when (org-get-at-bol 'org-hd-marker)
3525 (org-agenda-entry-text-show-here))
3526 (beginning-of-line 0))))
3528 (defun org-agenda-entry-text-hide ()
3529 "Remove any shown entry context."
3532 (if (eq (overlay-get o 'org-overlay-type)
3533 'agenda-entry-content)
3534 (progn (delete-overlay o) t)))
3535 (overlays-in (point-min) (point-max)))))
3537 (defun org-agenda-get-day-face (date)
3538 "Return the face DATE should be displayed with."
3539 (or (and (functionp org-agenda-day-face-function)
3540 (funcall org-agenda-day-face-function date))
3541 (cond ((org-agenda-todayp date)
3542 'org-agenda-date-today)
3543 ((member (calendar-day-of-week date) org-agenda-weekend-days)
3544 'org-agenda-date-weekend)
3545 (t 'org-agenda-date))))
3549 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
3551 (defun org-timeline (&optional dotodo)
3552 "Show a time-sorted view of the entries in the current org file.
3553 Only entries with a time stamp of today or later will be listed. With
3554 \\[universal-argument] prefix, all unfinished TODO items will also be shown,
3555 under the current date.
3556 If the buffer contains an active region, only check the region for
3560 (org-agenda-show-log-scoped org-agenda-show-log)
3561 (entry (buffer-file-name (or (buffer-base-buffer (current-buffer))
3563 (date (calendar-current-date))
3564 (beg (if (org-region-active-p) (region-beginning) (point-min)))
3565 (end (if (org-region-active-p) (region-end) (point-max)))
3566 (day-numbers (org-get-all-dates
3568 t org-agenda-show-log-scoped ; always include today
3569 org-timeline-show-empty-dates))
3570 (org-deadline-warning-days 0)
3571 (org-agenda-only-exact-dates t)
3576 (setq org-agenda-redo-command
3578 (list 'org-switch-to-buffer-other-window (current-buffer))
3579 (list 'org-timeline (list 'quote dotodo))))
3581 ;; Remove past dates from the list of dates.
3582 (setq day-numbers (delq nil (mapcar (lambda(x)
3583 (if (>= x today) x nil))
3585 (org-prepare-agenda (concat "Timeline " (file-name-nondirectory entry)))
3586 (org-compile-prefix-format 'timeline)
3587 (org-set-sorting-strategy 'timeline)
3588 (if org-agenda-show-log-scoped (push :closed args))
3589 (push :timestamp args)
3590 (push :deadline args)
3591 (push :scheduled args)
3593 (if dotodo (push :todo args))
3594 (insert "Timeline of file " entry "\n")
3595 (add-text-properties (point-min) (point)
3596 (list 'face 'org-agenda-structure))
3597 (org-agenda-mark-header-line (point-min))
3598 (while (setq d (pop day-numbers))
3599 (if (and (listp d) (eq (car d) :omitted))
3602 (insert (format "\n[... %d empty days omitted]\n\n" (cdr d)))
3603 (put-text-property s (1- (point)) 'face 'org-agenda-structure))
3604 (if (listp d) (setq d (car d) emptyp t) (setq emptyp nil))
3605 (if (and (>= d today)
3610 (insert (make-string 79 ?-) "\n")))
3611 (setq date (calendar-gregorian-from-absolute d))
3613 (setq rtn (and (not emptyp)
3614 (apply 'org-agenda-get-day-entries entry
3616 (if (or rtn (equal d today) org-timeline-show-empty-dates)
3619 (if (stringp org-agenda-format-date)
3620 (format-time-string org-agenda-format-date
3621 (org-time-from-absolute date))
3622 (funcall org-agenda-format-date date))
3624 (put-text-property s (1- (point)) 'face
3625 (org-agenda-get-day-face date))
3626 (put-text-property s (1- (point)) 'org-date-line t)
3627 (put-text-property s (1- (point)) 'org-agenda-date-header t)
3629 (put-text-property s (1- (point)) 'org-today t))
3630 (and rtn (insert (org-finalize-agenda-entries rtn) "\n"))
3631 (put-text-property s (1- (point)) 'day d)))))
3632 (goto-char (point-min))
3633 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
3635 (add-text-properties (point-min) (point-max) '(org-agenda-type timeline))
3636 (org-finalize-agenda)
3637 (setq buffer-read-only t)))
3639 (defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty pre-re)
3640 "Return a list of all relevant day numbers from BEG to END buffer positions.
3641 If NO-RANGES is non-nil, include only the start and end dates of a range,
3642 not every single day in the range. If FORCE-TODAY is non-nil, make
3643 sure that TODAY is included in the list. If INACTIVE is non-nil, also
3644 inactive time stamps (those in square brackets) are included.
3645 When EMPTY is non-nil, also include days without any entries."
3647 (if pre-re pre-re "")
3648 (if inactive org-ts-regexp-both org-ts-regexp)))
3649 dates dates1 date day day1 day2 ts1 ts2 pos)
3651 (setq dates (list (org-today))))
3654 (while (re-search-forward re end t)
3655 (setq day (time-to-days (org-time-string-to-time
3656 (substring (match-string 1) 0 10)
3657 (current-buffer) (match-beginning 0))))
3658 (or (memq day dates) (push day dates)))
3661 (while (re-search-forward org-tr-regexp end t)
3662 (setq pos (match-beginning 0))
3663 (setq ts1 (substring (match-string 1) 0 10)
3664 ts2 (substring (match-string 2) 0 10)
3665 day1 (time-to-days (org-time-string-to-time
3666 ts1 (current-buffer) pos))
3667 day2 (time-to-days (org-time-string-to-time
3668 ts2 (current-buffer) pos)))
3669 (while (< (setq day1 (1+ day1)) day2)
3670 (or (memq day1 dates) (push day1 dates)))))
3671 (setq dates (sort dates '<))
3673 (while (setq day (pop dates))
3674 (setq day2 (car dates))
3676 (when (and day2 empty)
3677 (if (or (eq empty t)
3678 (and (numberp empty) (<= (- day2 day) empty)))
3679 (while (< (setq day (1+ day)) day2)
3680 (push (list day) dates1))
3681 (push (cons :omitted (- day2 day)) dates1))))
3682 (setq dates (nreverse dates1)))
3685 ;;; Agenda Daily/Weekly
3687 (defvar org-agenda-start-day nil ; dynamically scoped parameter
3688 "Start day for the agenda view.
3689 Custom commands can set this variable in the options section.")
3690 (defvar org-starting-day nil) ; local variable in the agenda buffer
3691 (defvar org-agenda-current-span nil
3692 "The current span used in the agenda view.") ; local variable in the agenda buffer
3693 (defvar org-arg-loc nil) ; local variable
3695 (defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
3696 "List of types searched for when creating the daily/weekly agenda.
3697 This variable is a list of symbols that controls the types of
3698 items that appear in the daily/weekly agenda. Allowed symbols in this
3701 :timestamp List items containing a date stamp or date range matching
3702 the selected date. This includes sexp entries in
3705 :sexp List entries resulting from plain diary-like sexps.
3707 :deadline List deadline due on that date. When the date is today,
3708 also list any deadlines past due, or due within
3709 `org-deadline-warning-days'. `:deadline' must appear before
3710 `:scheduled' if the setting of
3711 `org-agenda-skip-scheduled-if-deadline-is-shown' is to have
3714 :scheduled List all items which are scheduled for the given date.
3715 The diary for *today* also contains items which were
3716 scheduled earlier and are not yet marked DONE.
3718 By default, all four types are turned on.
3720 Never set this variable globally using `setq', because then it
3721 will apply to all future agenda commands. Instead, bind it with
3722 `let' to scope it dynamically into the agenda-constructing
3723 command. A good way to set it is through options in
3724 `org-agenda-custom-commands'. For a more flexible (though
3725 somewhat less efficient) way of determining what is included in
3726 the daily/weekly agenda, see `org-agenda-skip-function'.")
3729 (defun org-agenda-list (&optional arg start-day span)
3730 "Produce a daily/weekly view from all files in variable `org-agenda-files'.
3731 The view will be for the current day or week, but from the overview buffer
3732 you will be able to go to other days/weeks.
3734 With a numeric prefix argument in an interactive call, the agenda will
3735 span ARG days. Lisp programs should instead specify SPAN to change
3736 the number of days. SPAN defaults to `org-agenda-span'.
3738 START-DAY defaults to TODAY, or to the most recent match for the weekday
3739 given in `org-agenda-start-on-weekday'."
3741 (if (and (integerp arg) (> arg 0))
3742 (setq span arg arg nil))
3743 (org-prepare-agenda "Day/Week")
3744 (setq start-day (or start-day org-agenda-start-day))
3745 (if org-agenda-overriding-arguments
3746 (setq arg (car org-agenda-overriding-arguments)
3747 start-day (nth 1 org-agenda-overriding-arguments)
3748 span (nth 2 org-agenda-overriding-arguments)))
3749 (if (stringp start-day)
3750 ;; Convert to an absolute day number
3751 (setq start-day (time-to-days (org-read-date nil t start-day))))
3752 (setq org-agenda-last-arguments (list arg start-day span))
3753 (org-compile-prefix-format 'agenda)
3754 (org-set-sorting-strategy 'agenda)
3755 (let* ((span (org-agenda-ndays-to-span
3756 (or span org-agenda-ndays org-agenda-span)))
3758 (sd (or start-day today))
3759 (ndays (org-agenda-span-to-ndays span sd))
3760 (org-agenda-start-on-weekday
3762 org-agenda-start-on-weekday))
3763 (thefiles (org-agenda-files nil 'ifmode))
3765 (start (if (or (null org-agenda-start-on-weekday)
3768 (let* ((nt (calendar-day-of-week
3769 (calendar-gregorian-from-absolute sd)))
3770 (n1 org-agenda-start-on-weekday)
3772 (- sd (+ (if (< d 0) 7 0) d)))))
3773 (day-numbers (list start))
3775 (inhibit-redisplay (not debug-on-error))
3776 (org-agenda-show-log-scoped org-agenda-show-log)
3777 s e rtn rtnall file date d start-pos end-pos todayp
3778 clocktable-start clocktable-end filter)
3779 (setq org-agenda-redo-command
3780 (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span)))
3781 (dotimes (n (1- ndays))
3782 (push (1+ (car day-numbers)) day-numbers))
3783 (setq day-numbers (nreverse day-numbers))
3784 (setq clocktable-start (car day-numbers)
3785 clocktable-end (1+ (or (org-last day-numbers) 0)))
3786 (org-set-local 'org-starting-day (car day-numbers))
3787 (org-set-local 'org-arg-loc arg)
3788 (org-set-local 'org-agenda-current-span (org-agenda-ndays-to-span span))
3789 (unless org-agenda-compact-blocks
3790 (let* ((d1 (car day-numbers))
3791 (d2 (org-last day-numbers))
3792 (w1 (org-days-to-iso-week d1))
3793 (w2 (org-days-to-iso-week d2)))
3795 (if org-agenda-overriding-header
3796 (insert (org-add-props (copy-sequence org-agenda-overriding-header)
3797 nil 'face 'org-agenda-structure) "\n")
3798 (insert (org-agenda-span-name span)
3800 (if (< (- d2 d1) 350)
3802 (format " (W%02d)" w1)
3803 (format " (W%02d-W%02d)" w1 w2))
3806 (add-text-properties s (1- (point)) (list 'face 'org-agenda-structure
3808 (org-agenda-mark-header-line s))
3809 (while (setq d (pop day-numbers))
3810 (setq date (calendar-gregorian-from-absolute d)
3812 (if (or (setq todayp (= d today))
3813 (and (not start-pos) (= d sd)))
3814 (setq start-pos (point))
3815 (if (and start-pos (not end-pos))
3816 (setq end-pos (point))))
3817 (setq files thefiles
3819 (while (setq file (pop files))