Allow to contextualize capture and agenda commands by checking the name of the buffer
[org-mode.git] / lisp / org-agenda.el
1 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
3 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage:
8 ;;
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
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 <>.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;; Commentary:
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.
46 ;;; Code:
48 (require 'org)
49 (require 'org-macs)
50 (eval-when-compile
51 (require 'cl))
53 (declare-function diary-add-to-list "diary-lib"
54 (date string specifier &optional marker globcolor literal))
55 (declare-function calendar-absolute-from-iso "cal-iso" (date))
56 (declare-function calendar-astro-date-string "cal-julian" (&optional date))
57 (declare-function calendar-bahai-date-string "cal-bahai" (&optional date))
58 (declare-function calendar-chinese-date-string "cal-china" (&optional date))
59 (declare-function calendar-coptic-date-string "cal-coptic" (&optional date))
60 (declare-function calendar-ethiopic-date-string "cal-coptic" (&optional date))
61 (declare-function calendar-french-date-string "cal-french" (&optional date))
62 (declare-function calendar-goto-date "cal-move" (date))
63 (declare-function calendar-hebrew-date-string "cal-hebrew" (&optional date))
64 (declare-function calendar-islamic-date-string "cal-islam" (&optional date))
65 (declare-function calendar-iso-date-string "cal-iso" (&optional date))
66 (declare-function calendar-iso-from-absolute "cal-iso" (date))
67 (declare-function calendar-julian-date-string "cal-julian" (&optional date))
68 (declare-function calendar-mayan-date-string "cal-mayan" (&optional date))
69 (declare-function calendar-persian-date-string "cal-persia" (&optional date))
70 (declare-function calendar-check-holidays "holidays" (date))
72 (declare-function org-datetree-find-date-create "org-datetree"
73 (date &optional keep-restriction))
74 (declare-function org-columns-quit "org-colview" ())
75 (declare-function diary-date-display-form "diary-lib" (&optional type))
76 (declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file))
77 (declare-function org-habit-insert-consistency-graphs
78 "org-habit" (&optional line))
79 (declare-function org-is-habit-p "org-habit" (&optional pom))
80 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
81 (declare-function org-habit-get-priority "org-habit" (habit &optional moment))
82 (declare-function org-pop-to-buffer-same-window "org-compat"
83 (&optional buffer-or-name norecord label))
84 (declare-function org-agenda-columns "org-colview" ())
85 (declare-function org-add-archive-files "org-archive" (files))
86 (declare-function org-capture "org-capture" (&optional goto keys))
88 (defvar calendar-mode-map) ; defined in calendar.el
89 (defvar org-clock-current-task nil) ; defined in org-clock.el
90 (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
91 (defvar org-habit-show-habits) ; defined in org-habit.el
92 (defvar org-habit-show-habits-only-for-today)
93 (defvar org-habit-show-all-today)
95 ;; Defined somewhere in this file, but used before definition.
96 (defvar org-agenda-buffer-name "*Org Agenda*")
97 (defvar org-agenda-overriding-header nil)
98 (defvar org-agenda-title-append nil)
99 (org-no-warnings (defvar entry)) ;; unprefixed, from calendar.el
100 (org-no-warnings (defvar date)) ;; unprefixed, from calendar.el
101 (defvar original-date) ; dynamically scoped, calendar.el does scope this
103 (defvar org-agenda-undo-list nil
104 "List of undoable operations in the agenda since last refresh.")
105 (defvar org-agenda-pending-undo-list nil
106 "In a series of undo commands, this is the list of remaining undo items.")
108 (defcustom org-agenda-confirm-kill 1
109 "When set, remote killing from the agenda buffer needs confirmation.
110 When t, a confirmation is always needed. When a number N, confirmation is
111 only needed when the text to be killed contains more than N non-white lines."
112 :group 'org-agenda
113 :type '(choice
114 (const :tag "Never" nil)
115 (const :tag "Always" t)
116 (integer :tag "When more than N lines")))
118 (defcustom org-agenda-compact-blocks nil
119 "Non-nil means make the block agenda more compact.
120 This is done globally by leaving out lines like the agenda span
121 name and week number or the separator lines."
122 :group 'org-agenda
123 :type 'boolean)
125 (defcustom org-agenda-block-separator ?=
126 "The separator between blocks in the agenda.
127 If this is a string, it will be used as the separator, with a newline added.
128 If it is a character, it will be repeated to fill the window width.
129 If nil the separator is disabled. In `org-agenda-custom-commands' this
130 addresses the separator between the current and the previous block."
131 :group 'org-agenda
132 :type '(choice
133 (const :tag "Disabled" nil)
134 (character)
135 (string)))
137 (defgroup org-agenda-export nil
138 "Options concerning exporting agenda views in Org-mode."
139 :tag "Org Agenda Export"
140 :group 'org-agenda)
142 (defcustom org-agenda-with-colors t
143 "Non-nil means use colors in agenda views."
144 :group 'org-agenda-export
145 :type 'boolean)
147 (defcustom org-agenda-exporter-settings nil
148 "Alist of variable/value pairs that should be active during agenda export.
149 This is a good place to set options for ps-print and for htmlize.
150 Note that the way this is implemented, the values will be evaluated
151 before assigned to the variables. So make sure to quote values you do
152 *not* want evaluated, for example
154 (setq org-agenda-exporter-settings
155 '((ps-print-color-p 'black-white)))"
156 :group 'org-agenda-export
157 :type '(repeat
158 (list
159 (variable)
160 (sexp :tag "Value"))))
162 (defcustom org-agenda-before-write-hook '(org-agenda-add-entry-text)
163 "Hook run in a temporary buffer before writing the agenda to an export file.
164 A useful function for this hook is `org-agenda-add-entry-text'."
165 :group 'org-agenda-export
166 :type 'hook
167 :options '(org-agenda-add-entry-text))
169 (defcustom org-agenda-add-entry-text-maxlines 0
170 "Maximum number of entry text lines to be added to agenda.
171 This is only relevant when `org-agenda-add-entry-text' is part of
172 `org-agenda-before-write-hook', which is the default.
173 When this is 0, nothing will happen. When it is greater than 0, it
174 specifies the maximum number of lines that will be added for each entry
175 that is listed in the agenda view.
177 Note that this variable is not used during display, only when exporting
178 the agenda. For agenda display, see the variables `org-agenda-entry-text-mode'
179 and `org-agenda-entry-text-maxlines'."
180 :group 'org-agenda
181 :type 'integer)
183 (defcustom org-agenda-add-entry-text-descriptive-links t
184 "Non-nil means export org-links as descriptive links in agenda added text.
185 This variable applies to the text added to the agenda when
186 `org-agenda-add-entry-text-maxlines' is larger than 0.
187 When this variable nil, the URL will (also) be shown."
188 :group 'org-agenda
189 :type 'boolean)
191 (defcustom org-agenda-export-html-style nil
192 "The style specification for exported HTML Agenda files.
193 If this variable contains a string, it will replace the default <style>
194 section as produced by `htmlize'.
195 Since there are different ways of setting style information, this variable
196 needs to contain the full HTML structure to provide a style, including the
197 surrounding HTML tags. The style specifications should include definitions
198 the fonts used by the agenda, here is an example:
200 <style type=\"text/css\">
201 p { font-weight: normal; color: gray; }
202 .org-agenda-structure {
203 font-size: 110%;
204 color: #003399;
205 font-weight: 600;
207 .org-todo {
208 color: #cc6666;
209 font-weight: bold;
211 .org-agenda-done {
212 color: #339933;
214 .org-done {
215 color: #339933;
217 .title { text-align: center; }
218 .todo, .deadline { color: red; }
219 .done { color: green; }
220 </style>
222 or, if you want to keep the style in a file,
224 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
226 As the value of this option simply gets inserted into the HTML <head> header,
227 you can \"misuse\" it to also add other text to the header."
228 :group 'org-agenda-export
229 :group 'org-export-html
230 :type 'string)
232 (defcustom org-agenda-persistent-filter nil
233 "When set, keep filters from one agenda view to the next."
234 :group 'org-agenda
235 :type 'boolean)
237 (defgroup org-agenda-custom-commands nil
238 "Options concerning agenda views in Org-mode."
239 :tag "Org Agenda Custom Commands"
240 :group 'org-agenda)
242 (defconst org-sorting-choice
243 '(choice
244 (const time-up) (const time-down)
245 (const category-keep) (const category-up) (const category-down)
246 (const tag-down) (const tag-up)
247 (const priority-up) (const priority-down)
248 (const todo-state-up) (const todo-state-down)
249 (const effort-up) (const effort-down)
250 (const habit-up) (const habit-down)
251 (const alpha-up) (const alpha-down)
252 (const user-defined-up) (const user-defined-down))
253 "Sorting choices.")
255 ;; Keep custom values for `org-agenda-filter-preset' compatible with
256 ;; the new variable `org-agenda-tag-filter-preset'.
257 (if (fboundp 'defvaralias)
258 (defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
259 (defvaralias 'org-agenda-filter 'org-agenda-tag-filter))
261 (defconst org-agenda-custom-commands-local-options
262 `(repeat :tag "Local settings for this command. Remember to quote values"
263 (choice :tag "Setting"
264 (list :tag "Heading for this block"
265 (const org-agenda-overriding-header)
266 (string :tag "Headline"))
267 (list :tag "Files to be searched"
268 (const org-agenda-files)
269 (list
270 (const :format "" quote)
271 (repeat (file))))
272 (list :tag "Sorting strategy"
273 (const org-agenda-sorting-strategy)
274 (list
275 (const :format "" quote)
276 (repeat
277 ,org-sorting-choice)))
278 (list :tag "Prefix format"
279 (const org-agenda-prefix-format :value " %-12:c%?-12t% s")
280 (string))
281 (list :tag "Number of days in agenda"
282 (const org-agenda-span)
283 (choice (const :tag "Day" 'day)
284 (const :tag "Week" 'week)
285 (const :tag "Month" 'month)
286 (const :tag "Year" 'year)
287 (integer :tag "Custom")))
288 (list :tag "Fixed starting date"
289 (const org-agenda-start-day)
290 (string :value "2007-11-01"))
291 (list :tag "Start on day of week"
292 (const org-agenda-start-on-weekday)
293 (choice :value 1
294 (const :tag "Today" nil)
295 (integer :tag "Weekday No.")))
296 (list :tag "Include data from diary"
297 (const org-agenda-include-diary)
298 (boolean))
299 (list :tag "Deadline Warning days"
300 (const org-deadline-warning-days)
301 (integer :value 1))
302 (list :tag "Category filter preset"
303 (const org-agenda-category-filter-preset)
304 (list
305 (const :format "" quote)
306 (repeat
307 (string :tag "+category or -category"))))
308 (list :tag "Tags filter preset"
309 (const org-agenda-tag-filter-preset)
310 (list
311 (const :format "" quote)
312 (repeat
313 (string :tag "+tag or -tag"))))
314 (list :tag "Set daily/weekly entry types"
315 (const org-agenda-entry-types)
316 (list
317 (const :format "" quote)
318 (set :greedy t :value (:deadline :scheduled :timestamp :sexp)
319 (const :deadline)
320 (const :scheduled)
321 (const :timestamp)
322 (const :sexp))))
323 (list :tag "Standard skipping condition"
324 :value (org-agenda-skip-function '(org-agenda-skip-entry-if))
325 (const org-agenda-skip-function)
326 (list
327 (const :format "" quote)
328 (list
329 (choice
330 :tag "Skipping range"
331 (const :tag "Skip entry" org-agenda-skip-entry-if)
332 (const :tag "Skip subtree" org-agenda-skip-subtree-if))
333 (repeat :inline t :tag "Conditions for skipping"
334 (choice
335 :tag "Condition type"
336 (list :tag "Regexp matches" :inline t (const :format "" 'regexp) (regexp))
337 (list :tag "Regexp does not match" :inline t (const :format "" 'notregexp) (regexp))
338 (list :tag "TODO state is" :inline t
339 (const 'todo)
340 (choice
341 (const :tag "any not-done state" 'todo)
342 (const :tag "any done state" 'done)
343 (const :tag "any state" 'any)
344 (list :tag "Keyword list"
345 (const :format "" quote)
346 (repeat (string :tag "Keyword")))))
347 (list :tag "TODO state is not" :inline t
348 (const 'nottodo)
349 (choice
350 (const :tag "any not-done state" 'todo)
351 (const :tag "any done state" 'done)
352 (const :tag "any state" 'any)
353 (list :tag "Keyword list"
354 (const :format "" quote)
355 (repeat (string :tag "Keyword")))))
356 (const :tag "scheduled" 'scheduled)
357 (const :tag "not scheduled" 'notscheduled)
358 (const :tag "deadline" 'deadline)
359 (const :tag "no deadline" 'notdeadline)
360 (const :tag "timestamp" 'timestamp)
361 (const :tag "no timestamp" 'nottimestamp))))))
362 (list :tag "Non-standard skipping condition"
363 :value (org-agenda-skip-function)
364 (const org-agenda-skip-function)
365 (sexp :tag "Function or form (quoted!)"))
366 (list :tag "Any variable"
367 (variable :tag "Variable")
368 (sexp :tag "Value (sexp)"))))
369 "Selection of examples for agenda command settings.
370 This will be spliced into the custom type of
371 `org-agenda-custom-commands'.")
374 (defcustom org-agenda-custom-commands '(("n" "Agenda and all TODO's"
375 ((agenda "") (alltodo))))
376 "Custom commands for the agenda.
377 These commands will be offered on the splash screen displayed by the
378 agenda dispatcher \\[org-agenda]. Each entry is a list like this:
380 (key desc type match settings files)
382 key The key (one or more characters as a string) to be associated
383 with the command.
384 desc A description of the command, when omitted or nil, a default
385 description is built using MATCH.
386 type The command type, any of the following symbols:
387 agenda The daily/weekly agenda.
388 todo Entries with a specific TODO keyword, in all agenda files.
389 search Entries containing search words entry or headline.
390 tags Tags/Property/TODO match in all agenda files.
391 tags-todo Tags/P/T match in all agenda files, TODO entries only.
392 todo-tree Sparse tree of specific TODO keyword in *current* file.
393 tags-tree Sparse tree with all tags matches in *current* file.
394 occur-tree Occur sparse tree for *current* file.
395 ... A user-defined function.
396 match What to search for:
397 - a single keyword for TODO keyword searches
398 - a tags match expression for tags searches
399 - a word search expression for text searches.
400 - a regular expression for occur searches
401 For all other commands, this should be the empty string.
402 settings A list of option settings, similar to that in a let form, so like
403 this: ((opt1 val1) (opt2 val2) ...). The values will be
404 evaluated at the moment of execution, so quote them when needed.
405 files A list of files file to write the produced agenda buffer to
406 with the command `org-store-agenda-views'.
407 If a file name ends in \".html\", an HTML version of the buffer
408 is written out. If it ends in \".ps\", a postscript version is
409 produced. Otherwise, only the plain text is written to the file.
411 You can also define a set of commands, to create a composite agenda buffer.
412 In this case, an entry looks like this:
414 (key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
416 where
418 desc A description string to be displayed in the dispatcher menu.
419 cmd An agenda command, similar to the above. However, tree commands
420 are not allowed, but instead you can get agenda and global todo list.
421 So valid commands for a set are:
422 (agenda \"\" settings)
423 (alltodo \"\" settings)
424 (stuck \"\" settings)
425 (todo \"match\" settings files)
426 (search \"match\" settings files)
427 (tags \"match\" settings files)
428 (tags-todo \"match\" settings files)
430 Each command can carry a list of options, and another set of options can be
431 given for the whole set of commands. Individual command options take
432 precedence over the general options.
434 When using several characters as key to a command, the first characters
435 are prefix commands. For the dispatcher to display useful information, you
436 should provide a description for the prefix, like
438 (setq org-agenda-custom-commands
439 '((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\"
440 (\"hl\" tags \"+HOME+Lisa\")
441 (\"hp\" tags \"+HOME+Peter\")
442 (\"hk\" tags \"+HOME+Kim\")))"
443 :group 'org-agenda-custom-commands
444 :type `(repeat
445 (choice :value ("x" "Describe command here" tags "" nil)
446 (list :tag "Single command"
447 (string :tag "Access Key(s) ")
448 (option (string :tag "Description"))
449 (choice
450 (const :tag "Agenda" agenda)
451 (const :tag "TODO list" alltodo)
452 (const :tag "Search words" search)
453 (const :tag "Stuck projects" stuck)
454 (const :tag "Tags/Property match (all agenda files)" tags)
455 (const :tag "Tags/Property match of TODO entries (all agenda files)" tags-todo)
456 (const :tag "TODO keyword search (all agenda files)" todo)
457 (const :tag "Tags sparse tree (current buffer)" tags-tree)
458 (const :tag "TODO keyword tree (current buffer)" todo-tree)
459 (const :tag "Occur tree (current buffer)" occur-tree)
460 (sexp :tag "Other, user-defined function"))
461 (string :tag "Match (only for some commands)")
462 ,org-agenda-custom-commands-local-options
463 (option (repeat :tag "Export" (file :tag "Export to"))))
464 (list :tag "Command series, all agenda files"
465 (string :tag "Access Key(s)")
466 (string :tag "Description ")
467 (repeat :tag "Component"
468 (choice
469 (list :tag "Agenda"
470 (const :format "" agenda)
471 (const :tag "" :format "" "")
472 ,org-agenda-custom-commands-local-options)
473 (list :tag "TODO list (all keywords)"
474 (const :format "" alltodo)
475 (const :tag "" :format "" "")
476 ,org-agenda-custom-commands-local-options)
477 (list :tag "Search words"
478 (const :format "" search)
479 (string :tag "Match")
480 ,org-agenda-custom-commands-local-options)
481 (list :tag "Stuck projects"
482 (const :format "" stuck)
483 (const :tag "" :format "" "")
484 ,org-agenda-custom-commands-local-options)
485 (list :tag "Tags search"
486 (const :format "" tags)
487 (string :tag "Match")
488 ,org-agenda-custom-commands-local-options)
489 (list :tag "Tags search, TODO entries only"
490 (const :format "" tags-todo)
491 (string :tag "Match")
492 ,org-agenda-custom-commands-local-options)
493 (list :tag "TODO keyword search"
494 (const :format "" todo)
495 (string :tag "Match")
496 ,org-agenda-custom-commands-local-options)
497 (list :tag "Other, user-defined function"
498 (symbol :tag "function")
499 (string :tag "Match")
500 ,org-agenda-custom-commands-local-options)))
502 (repeat :tag "Settings for entire command set"
503 (list (variable :tag "Any variable")
504 (sexp :tag "Value")))
505 (option (repeat :tag "Export" (file :tag "Export to"))))
506 (cons :tag "Prefix key documentation"
507 (string :tag "Access Key(s)")
508 (string :tag "Description ")))))
510 (defcustom org-agenda-query-register ?o
511 "The register holding the current query string.
512 The purpose of this is that if you construct a query string interactively,
513 you can then use it to define a custom command."
514 :group 'org-agenda-custom-commands
515 :type 'character)
517 (defcustom org-stuck-projects
518 '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "")
519 "How to identify stuck projects.
520 This is a list of four items:
521 1. A tags/todo/property matcher string that is used to identify a project.
522 See the manual for a description of tag and property searches.
523 The entire tree below a headline matched by this is considered one project.
524 2. A list of TODO keywords identifying non-stuck projects.
525 If the project subtree contains any headline with one of these todo
526 keywords, the project is considered to be not stuck. If you specify
527 \"*\" as a keyword, any TODO keyword will mark the project unstuck.
528 3. A list of tags identifying non-stuck projects.
529 If the project subtree contains any headline with one of these tags,
530 the project is considered to be not stuck. If you specify \"*\" as
531 a tag, any tag will mark the project unstuck. Note that this is about
532 the explicit presence of a tag somewhere in the subtree, inherited
533 tags do not count here. If inherited tags make a project not stuck,
534 use \"-TAG\" in the tags part of the matcher under (1.) above.
535 4. An arbitrary regular expression matching non-stuck projects.
537 If the project turns out to be not stuck, search continues also in the
538 subtree to see if any of the subtasks have project status.
540 See also the variable `org-tags-match-list-sublevels' which applies
541 to projects matched by this search as well.
543 After defining this variable, you may use \\[org-agenda-list-stuck-projects]
544 or `C-c a #' to produce the list."
545 :group 'org-agenda-custom-commands
546 :type '(list
547 (string :tag "Tags/TODO match to identify a project")
548 (repeat :tag "Projects are *not* stuck if they have an entry with TODO keyword any of" (string))
549 (repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string))
550 (regexp :tag "Projects are *not* stuck if this regexp matches inside the subtree")))
552 (defcustom org-agenda-filter-effort-default-operator "<"
553 "The default operator for effort estimate filtering.
554 If you select an effort estimate limit without first pressing an operator,
555 this one will be used."
556 :group 'org-agenda-custom-commands
557 :type '(choice (const :tag "less or equal" "<")
558 (const :tag "greater or equal"">")
559 (const :tag "equal" "=")))
561 (defgroup org-agenda-skip nil
562 "Options concerning skipping parts of agenda files."
563 :tag "Org Agenda Skip"
564 :group 'org-agenda)
566 (defcustom org-agenda-skip-function-global nil
567 "Function to be called at each match during agenda construction.
568 If this function returns nil, the current match should not be skipped.
569 If the function decided to skip an agenda match, is must return the
570 buffer position from which the search should be continued.
571 This may also be a Lisp form, which will be evaluated.
573 This variable will be applied to every agenda match, including
574 tags/property searches and TODO lists. So try to make the test function
575 do its checking as efficiently as possible. To implement a skipping
576 condition just for specific agenda commands, use the variable
577 `org-agenda-skip-function' which can be set in the options section
578 of custom agenda commands."
579 :group 'org-agenda-skip
580 :type 'sexp)
582 (defgroup org-agenda-daily/weekly nil
583 "Options concerning the daily/weekly agenda."
584 :tag "Org Agenda Daily/Weekly"
585 :group 'org-agenda)
586 (defgroup org-agenda-todo-list nil
587 "Options concerning the global todo list agenda view."
588 :tag "Org Agenda Todo List"
589 :group 'org-agenda)
590 (defgroup org-agenda-match-view nil
591 "Options concerning the general tags/property/todo match agenda view."
592 :tag "Org Agenda Match View"
593 :group 'org-agenda)
594 (defgroup org-agenda-search-view nil
595 "Options concerning the general tags/property/todo match agenda view."
596 :tag "Org Agenda Match View"
597 :group 'org-agenda)
599 (defvar org-agenda-archives-mode nil
600 "Non-nil means the agenda will include archived items.
601 If this is the symbol `trees', trees in the selected agenda scope
602 that are marked with the ARCHIVE tag will be included anyway. When this is
603 t, also all archive files associated with the current selection of agenda
604 files will be included.")
606 (defcustom org-agenda-skip-comment-trees t
607 "Non-nil means skip trees that start with the COMMENT keyword.
608 When nil, these trees are also scanned by agenda commands."
609 :group 'org-agenda-skip
610 :type 'boolean)
612 (defcustom org-agenda-todo-list-sublevels t
613 "Non-nil means check also the sublevels of a TODO entry for TODO entries.
614 When nil, the sublevels of a TODO entry are not checked, resulting in
615 potentially much shorter TODO lists."
616 :group 'org-agenda-skip
617 :group 'org-agenda-todo-list
618 :type 'boolean)
620 (defcustom org-agenda-todo-ignore-with-date nil
621 "Non-nil means don't show entries with a date in the global todo list.
622 You can use this if you prefer to mark mere appointments with a TODO keyword,
623 but don't want them to show up in the TODO list.
624 When this is set, it also covers deadlines and scheduled items, the settings
625 of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
626 will be ignored.
627 See also the variable `org-agenda-tags-todo-honor-ignore-options'."
628 :group 'org-agenda-skip
629 :group 'org-agenda-todo-list
630 :type 'boolean)
632 (defcustom org-agenda-todo-ignore-timestamp nil
633 "Non-nil means don't show entries with a timestamp.
634 This applies when creating the global todo list.
635 Valid values are:
637 past Don't show entries for today or in the past.
639 future Don't show entries with a timestamp in the future.
640 The idea behind this is that if it has a future
641 timestamp, you don't want to think about it until the
642 date.
644 all Don't show any entries with a timestamp in the global todo list.
645 The idea behind this is that by setting a timestamp, you
646 have already \"taken care\" of this item.
648 This variable can also have an integer as a value. If positive (N),
649 todos with a timestamp N or more days in the future will be ignored. If
650 negative (-N), todos with a timestamp N or more days in the past will be
651 ignored. If 0, todos with a timestamp either today or in the future will
652 be ignored. For example, a value of -1 will exclude todos with a
653 timestamp in the past (yesterday or earlier), while a value of 7 will
654 exclude todos with a timestamp a week or more in the future.
656 See also `org-agenda-todo-ignore-with-date'.
657 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
658 to make his option also apply to the tags-todo list."
659 :group 'org-agenda-skip
660 :group 'org-agenda-todo-list
661 :version "24.1"
662 :type '(choice
663 (const :tag "Ignore future timestamp todos" future)
664 (const :tag "Ignore past or present timestamp todos" past)
665 (const :tag "Ignore all timestamp todos" all)
666 (const :tag "Show timestamp todos" nil)
667 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
669 (defcustom org-agenda-todo-ignore-scheduled nil
670 "Non-nil means, ignore some scheduled TODO items when making TODO list.
671 This applies when creating the global todo list.
672 Valid values are:
674 past Don't show entries scheduled today or in the past.
676 future Don't show entries scheduled in the future.
677 The idea behind this is that by scheduling it, you don't want to
678 think about it until the scheduled date.
680 all Don't show any scheduled entries in the global todo list.
681 The idea behind this is that by scheduling it, you have already
682 \"taken care\" of this item.
684 t Same as `all', for backward compatibility.
686 This variable can also have an integer as a value. See
687 `org-agenda-todo-ignore-timestamp' for more details.
689 See also `org-agenda-todo-ignore-with-date'.
690 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
691 to make his option also apply to the tags-todo list."
692 :group 'org-agenda-skip
693 :group 'org-agenda-todo-list
694 :type '(choice
695 (const :tag "Ignore future-scheduled todos" future)
696 (const :tag "Ignore past- or present-scheduled todos" past)
697 (const :tag "Ignore all scheduled todos" all)
698 (const :tag "Ignore all scheduled todos (compatibility)" t)
699 (const :tag "Show scheduled todos" nil)
700 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
702 (defcustom org-agenda-todo-ignore-deadlines nil
703 "Non-nil means ignore some deadlined TODO items when making TODO list.
704 There are different motivations for using different values, please think
705 carefully when configuring this variable.
707 This applies when creating the global todo list.
708 Valid values are:
710 near Don't show near deadline entries. A deadline is near when it is
711 closer than `org-deadline-warning-days' days. The idea behind this
712 is that such items will appear in the agenda anyway.
714 far Don't show TODO entries where a deadline has been defined, but
715 the deadline is not near. This is useful if you don't want to
716 use the todo list to figure out what to do now.
718 past Don't show entries with a deadline timestamp for today or in the past.
720 future Don't show entries with a deadline timestamp in the future, not even
721 when they become `near' ones. Use it with caution.
723 all Ignore all TODO entries that do have a deadline.
725 t Same as `near', for backward compatibility.
727 This variable can also have an integer as a value. See
728 `org-agenda-todo-ignore-timestamp' for more details.
730 See also `org-agenda-todo-ignore-with-date'.
731 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
732 to make his option also apply to the tags-todo list."
733 :group 'org-agenda-skip
734 :group 'org-agenda-todo-list
735 :type '(choice
736 (const :tag "Ignore near deadlines" near)
737 (const :tag "Ignore near deadlines (compatibility)" t)
738 (const :tag "Ignore far deadlines" far)
739 (const :tag "Ignore all TODOs with a deadlines" all)
740 (const :tag "Show all TODOs, even if they have a deadline" nil)
741 (integer :tag "Ignore if N or more days in past(-) or future(+).")))
743 (defcustom org-agenda-todo-ignore-time-comparison-use-seconds nil
744 "Time unit to use when possibly ignoring an agenda item.
746 See the docstring of various `org-agenda-todo-ignore-*' options.
747 The default is to compare time stamps using days. An item is thus
748 considered to be in the future if it is at least one day after today.
749 Non-nil means to compare time stamps using seconds. An item is then
750 considered future if it has a time value later than current time."
751 :group 'org-agenda-skip
752 :group 'org-agenda-todo-list
753 :type '(choice
754 (const :tag "Compare time with days" nil)
755 (const :tag "Compare time with seconds" t)))
757 (defcustom org-agenda-tags-todo-honor-ignore-options nil
758 "Non-nil means honor todo-list ...ignore options also in tags-todo search.
759 The variables
760 `org-agenda-todo-ignore-with-date',
761 `org-agenda-todo-ignore-timestamp',
762 `org-agenda-todo-ignore-scheduled',
763 `org-agenda-todo-ignore-deadlines'
764 make the global TODO list skip entries that have time stamps of certain
765 kinds. If this option is set, the same options will also apply for the
766 tags-todo search, which is the general tags/property matcher
767 restricted to unfinished TODO entries only."
768 :group 'org-agenda-skip
769 :group 'org-agenda-todo-list
770 :group 'org-agenda-match-view
771 :type 'boolean)
773 (defcustom org-agenda-skip-scheduled-if-done nil
774 "Non-nil means don't show scheduled items in agenda when they are done.
775 This is relevant for the daily/weekly agenda, not for the TODO list. And
776 it applies only to the actual date of the scheduling. Warnings about
777 an item with a past scheduling dates are always turned off when the item
778 is DONE."
779 :group 'org-agenda-skip
780 :group 'org-agenda-daily/weekly
781 :type 'boolean)
783 (defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
784 "Non-nil means skip scheduling line if same entry shows because of deadline.
785 In the agenda of today, an entry can show up multiple times because
786 it is both scheduled and has a nearby deadline, and maybe a plain time
787 stamp as well.
788 When this variable is t, then only the deadline is shown and the fact that
789 the entry is scheduled today or was scheduled previously is not shown.
790 When this variable is nil, the entry will be shown several times. When
791 the variable is the symbol `not-today', then skip scheduled previously,
792 but not scheduled today."
793 :group 'org-agenda-skip
794 :group 'org-agenda-daily/weekly
795 :type '(choice
796 (const :tag "Never" nil)
797 (const :tag "Always" t)
798 (const :tag "Not when scheduled today" not-today)))
800 (defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
801 "Non-nil means skip timestamp line if same entry shows because of deadline.
802 In the agenda of today, an entry can show up multiple times
803 because it has both a plain timestamp and has a nearby deadline.
804 When this variable is t, then only the deadline is shown and the
805 fact that the entry has a timestamp for or including today is not
806 shown. When this variable is nil, the entry will be shown
807 several times."
808 :group 'org-agenda-skip
809 :group 'org-agenda-daily/weekly
810 :version "24.1"
811 :type '(choice
812 (const :tag "Never" nil)
813 (const :tag "Always" t)))
815 (defcustom org-agenda-skip-deadline-if-done nil
816 "Non-nil means don't show deadlines when the corresponding item is done.
817 When nil, the deadline is still shown and should give you a happy feeling.
818 This is relevant for the daily/weekly agenda. And it applied only to the
819 actually date of the deadline. Warnings about approaching and past-due
820 deadlines are always turned off when the item is DONE."
821 :group 'org-agenda-skip
822 :group 'org-agenda-daily/weekly
823 :type 'boolean)
825 (defcustom org-agenda-skip-deadline-prewarning-if-scheduled nil
826 "Non-nil means skip deadline prewarning when entry is also scheduled.
827 This will apply on all days where a prewarning for the deadline would
828 be shown, but not at the day when the entry is actually due. On that day,
829 the deadline will be shown anyway.
830 This variable may be set to nil, t, the symbol `pre-scheduled',
831 or a number which will then give the number of days before the actual
832 deadline when the prewarnings should resume. The symbol `pre-scheduled'
833 eliminates the deadline prewarning only prior to the scheduled date.
834 This can be used in a workflow where the first showing of the deadline will
835 trigger you to schedule it, and then you don't want to be reminded of it
836 because you will take care of it on the day when scheduled."
837 :group 'org-agenda-skip
838 :group 'org-agenda-daily/weekly
839 :version "24.1"
840 :type '(choice
841 (const :tag "Always show prewarning" nil)
842 (const :tag "Remove prewarning prior to scheduled date" pre-scheduled)
843 (const :tag "Remove prewarning if entry is scheduled" t)
844 (integer :tag "Restart prewarning N days before deadline")))
846 (defcustom org-agenda-skip-additional-timestamps-same-entry nil
847 "When nil, multiple same-day timestamps in entry make multiple agenda lines.
848 When non-nil, after the search for timestamps has matched once in an
849 entry, the rest of the entry will not be searched."
850 :group 'org-agenda-skip
851 :type 'boolean)
853 (defcustom org-agenda-skip-timestamp-if-done nil
854 "Non-nil means don't select item by timestamp or -range if it is DONE."
855 :group 'org-agenda-skip
856 :group 'org-agenda-daily/weekly
857 :type 'boolean)
859 (defcustom org-agenda-dim-blocked-tasks nil
860 "Non-nil means dim blocked tasks in the agenda display.
861 This causes some overhead during agenda construction, but if you
862 have turned on `org-enforce-todo-dependencies',
863 `org-enforce-todo-checkbox-dependencies', or any other blocking
864 mechanism, this will create useful feedback in the agenda.
866 Instead of t, this variable can also have the value `invisible'.
867 Then blocked tasks will be invisible and only become visible when
868 they become unblocked. An exemption to this behavior is when a task is
869 blocked because of unchecked checkboxes below it. Since checkboxes do
870 not show up in the agenda views, making this task invisible you remove any
871 trace from agenda views that there is something to do. Therefore, a task
872 that is blocked because of checkboxes will never be made invisible, it
873 will only be dimmed."
874 :group 'org-agenda-daily/weekly
875 :group 'org-agenda-todo-list
876 :version "24.3"
877 :type '(choice
878 (const :tag "Do not dim" nil)
879 (const :tag "Dim to a gray face" t)
880 (const :tag "Make invisible" invisible)))
882 (defcustom org-timeline-show-empty-dates 3
883 "Non-nil means `org-timeline' also shows dates without an entry.
884 When nil, only the days which actually have entries are shown.
885 When t, all days between the first and the last date are shown.
886 When an integer, show also empty dates, but if there is a gap of more than
887 N days, just insert a special line indicating the size of the gap."
888 :group 'org-agenda-skip
889 :type '(choice
890 (const :tag "None" nil)
891 (const :tag "All" t)
892 (integer :tag "at most")))
894 (defgroup org-agenda-startup nil
895 "Options concerning initial settings in the Agenda in Org Mode."
896 :tag "Org Agenda Startup"
897 :group 'org-agenda)
899 (defcustom org-agenda-menu-show-matcher t
900 "Non-nil means show the match string in the agenda dispatcher menu.
901 When nil, the matcher string is not shown, but is put into the help-echo
902 property so than moving the mouse over the command shows it.
903 Setting it to nil is good if matcher strings are very long and/or if
904 you want to use two-columns display (see `org-agenda-menu-two-columns')."
905 :group 'org-agenda
906 :version "24.1"
907 :type 'boolean)
909 (define-obsolete-variable-alias 'org-agenda-menu-two-column 'org-agenda-menu-two-columns "24.3")
911 (defcustom org-agenda-menu-two-columns nil
912 "Non-nil means, use two columns to show custom commands in the dispatcher.
913 If you use this, you probably want to set `org-agenda-menu-show-matcher'
914 to nil."
915 :group 'org-agenda
916 :version "24.1"
917 :type 'boolean)
919 (define-obsolete-variable-alias 'org-finalize-agenda-hook 'org-agenda-finalize-hook "24.3")
920 (defcustom org-agenda-finalize-hook nil
921 "Hook run just before displaying an agenda buffer.
922 The buffer is still writable when the hook is called.
924 You can modify some of the buffer substrings but you should be
925 extra careful not to modify the text properties of the agenda
926 headlines as the agenda display heavily relies on them."
927 :group 'org-agenda-startup
928 :type 'hook)
930 (defcustom org-agenda-mouse-1-follows-link nil
931 "Non-nil means mouse-1 on a link will follow the link in the agenda.
932 A longer mouse click will still set point. Does not work on XEmacs.
933 Needs to be set before org.el is loaded."
934 :group 'org-agenda-startup
935 :type 'boolean)
937 (defcustom org-agenda-start-with-follow-mode nil
938 "The initial value of follow mode in a newly created agenda window."
939 :group 'org-agenda-startup
940 :type 'boolean)
942 (defcustom org-agenda-follow-indirect nil
943 "Non-nil means `org-agenda-follow-mode' displays only the
944 current item's tree, in an indirect buffer."
945 :group 'org-agenda
946 :version "24.1"
947 :type 'boolean)
949 (defcustom org-agenda-show-outline-path t
950 "Non-nil means show outline path in echo area after line motion."
951 :group 'org-agenda-startup
952 :type 'boolean)
954 (defcustom org-agenda-start-with-entry-text-mode nil
955 "The initial value of entry-text-mode in a newly created agenda window."
956 :group 'org-agenda-startup
957 :type 'boolean)
959 (defcustom org-agenda-entry-text-maxlines 5
960 "Number of text lines to be added when `E' is pressed in the agenda.
962 Note that this variable only used during agenda display. Add add entry text
963 when exporting the agenda, configure the variable
964 `org-agenda-add-entry-ext-maxlines'."
965 :group 'org-agenda
966 :type 'integer)
968 (defcustom org-agenda-entry-text-exclude-regexps nil
969 "List of regular expressions to clean up entry text.
970 The complete matches of all regular expressions in this list will be
971 removed from entry text before it is shown in the agenda."
972 :group 'org-agenda
973 :type '(repeat (regexp)))
975 (defvar org-agenda-entry-text-cleanup-hook nil
976 "Hook that is run after basic cleanup of entry text to be shown in agenda.
977 This cleanup is done in a temporary buffer, so the function may inspect and
978 change the entire buffer.
979 Some default stuff like drawers and scheduling/deadline dates will already
980 have been removed when this is called, as will any matches for regular
981 expressions listed in `org-agenda-entry-text-exclude-regexps'.")
983 (defvar org-agenda-include-inactive-timestamps nil
984 "Non-nil means include inactive time stamps in agenda and timeline.
985 Dynamically scoped.")
987 (defgroup org-agenda-windows nil
988 "Options concerning the windows used by the Agenda in Org Mode."
989 :tag "Org Agenda Windows"
990 :group 'org-agenda)
992 (defcustom org-agenda-window-setup 'reorganize-frame
993 "How the agenda buffer should be displayed.
994 Possible values for this option are:
996 current-window Show agenda in the current window, keeping all other windows.
997 other-window Use `switch-to-buffer-other-window' to display agenda.
998 reorganize-frame Show only two windows on the current frame, the current
999 window and the agenda.
1000 other-frame Use `switch-to-buffer-other-frame' to display agenda.
1001 Also, when exiting the agenda, kill that frame.
1002 See also the variable `org-agenda-restore-windows-after-quit'."
1003 :group 'org-agenda-windows
1004 :type '(choice
1005 (const current-window)
1006 (const other-frame)
1007 (const other-window)
1008 (const reorganize-frame)))
1010 (defcustom org-agenda-window-frame-fractions '(0.5 . 0.75)
1011 "The min and max height of the agenda window as a fraction of frame height.
1012 The value of the variable is a cons cell with two numbers between 0 and 1.
1013 It only matters if `org-agenda-window-setup' is `reorganize-frame'."
1014 :group 'org-agenda-windows
1015 :type '(cons (number :tag "Minimum") (number :tag "Maximum")))
1017 (defcustom org-agenda-restore-windows-after-quit nil
1018 "Non-nil means restore window configuration upon exiting agenda.
1019 Before the window configuration is changed for displaying the agenda,
1020 the current status is recorded. When the agenda is exited with
1021 `q' or `x' and this option is set, the old state is restored. If
1022 `org-agenda-window-setup' is `other-frame', the value of this
1023 option will be ignored."
1024 :group 'org-agenda-windows
1025 :type 'boolean)
1027 (defcustom org-agenda-ndays nil
1028 "Number of days to include in overview display.
1029 Should be 1 or 7.
1030 Obsolete, see `org-agenda-span'."
1031 :group 'org-agenda-daily/weekly
1032 :type 'integer)
1034 (make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
1036 (defcustom org-agenda-span 'week
1037 "Number of days to include in overview display.
1038 Can be day, week, month, year, or any number of days.
1039 Custom commands can set this variable in the options section."
1040 :group 'org-agenda-daily/weekly
1041 :type '(choice (const :tag "Day" day)
1042 (const :tag "Week" week)
1043 (const :tag "Month" month)
1044 (const :tag "Year" year)
1045 (integer :tag "Custom")))
1047 (defcustom org-agenda-start-on-weekday 1
1048 "Non-nil means start the overview always on the specified weekday.
1049 0 denotes Sunday, 1 denotes Monday etc.
1050 When nil, always start on the current day.
1051 Custom commands can set this variable in the options section."
1052 :group 'org-agenda-daily/weekly
1053 :type '(choice (const :tag "Today" nil)
1054 (integer :tag "Weekday No.")))
1056 (defcustom org-agenda-show-all-dates t
1057 "Non-nil means `org-agenda' shows every day in the selected range.
1058 When nil, only the days which actually have entries are shown."
1059 :group 'org-agenda-daily/weekly
1060 :type 'boolean)
1062 (defcustom org-agenda-format-date 'org-agenda-format-date-aligned
1063 "Format string for displaying dates in the agenda.
1064 Used by the daily/weekly agenda and by the timeline. This should be
1065 a format string understood by `format-time-string', or a function returning
1066 the formatted date as a string. The function must take a single argument,
1067 a calendar-style date list like (month day year)."
1068 :group 'org-agenda-daily/weekly
1069 :type '(choice
1070 (string :tag "Format string")
1071 (function :tag "Function")))
1073 (defun org-agenda-format-date-aligned (date)
1074 "Format a date string for display in the daily/weekly agenda, or timeline.
1075 This function makes sure that dates are aligned for easy reading."
1076 (require 'cal-iso)
1077 (let* ((dayname (calendar-day-name date))
1078 (day (cadr date))
1079 (day-of-week (calendar-day-of-week date))
1080 (month (car date))
1081 (monthname (calendar-month-name month))
1082 (year (nth 2 date))
1083 (iso-week (org-days-to-iso-week
1084 (calendar-absolute-from-gregorian date)))
1085 (weekyear (cond ((and (= month 1) (>= iso-week 52))
1086 (1- year))
1087 ((and (= month 12) (<= iso-week 1))
1088 (1+ year))
1089 (t year)))
1090 (weekstring (if (= day-of-week 1)
1091 (format " W%02d" iso-week)
1092 "")))
1093 (format "%-10s %2d %s %4d%s"
1094 dayname day monthname year weekstring)))
1096 (defcustom org-agenda-time-leading-zero nil
1097 "Non-nil means use leading zero for military times in agenda.
1098 For example, 9:30am would become 09:30 rather than 9:30."
1099 :group 'org-agenda-daily/weekly
1100 :version "24.1"
1101 :type 'boolean)
1103 (defcustom org-agenda-timegrid-use-ampm nil
1104 "When set, show AM/PM style timestamps on the timegrid."
1105 :group 'org-agenda
1106 :version "24.1"
1107 :type 'boolean)
1109 (defun org-agenda-time-of-day-to-ampm (time)
1110 "Convert TIME of a string like '13:45' to an AM/PM style time string."
1111 (let* ((hour-number (string-to-number (substring time 0 -3)))
1112 (minute (substring time -2))
1113 (ampm "am"))
1114 (cond
1115 ((equal hour-number 12)
1116 (setq ampm "pm"))
1117 ((> hour-number 12)
1118 (setq ampm "pm")
1119 (setq hour-number (- hour-number 12))))
1120 (concat
1121 (if org-agenda-time-leading-zero
1122 (format "%02d" hour-number)
1123 (format "%02s" (number-to-string hour-number)))
1124 ":" minute ampm)))
1126 (defun org-agenda-time-of-day-to-ampm-maybe (time)
1127 "Conditionally convert TIME to AM/PM format
1128 based on `org-agenda-timegrid-use-ampm'"
1129 (if org-agenda-timegrid-use-ampm
1130 (org-agenda-time-of-day-to-ampm time)
1131 time))
1133 (defcustom org-agenda-weekend-days '(6 0)
1134 "Which days are weekend?
1135 These days get the special face `org-agenda-date-weekend' in the agenda
1136 and timeline buffers."
1137 :group 'org-agenda-daily/weekly
1138 :type '(set :greedy t
1139 (const :tag "Monday" 1)
1140 (const :tag "Tuesday" 2)
1141 (const :tag "Wednesday" 3)
1142 (const :tag "Thursday" 4)
1143 (const :tag "Friday" 5)
1144 (const :tag "Saturday" 6)
1145 (const :tag "Sunday" 0)))
1147 (defcustom org-agenda-move-date-from-past-immediately-to-today t
1148 "Non-nil means jump to today when moving a past date forward in time.
1149 When using S-right in the agenda to move a a date forward, and the date
1150 stamp currently points to the past, the first key press will move it
1151 to today. WHen nil, just move one day forward even if the date stays
1152 in the past."
1153 :group 'org-agenda-daily/weekly
1154 :version "24.1"
1155 :type 'boolean)
1157 (defcustom org-agenda-include-diary nil
1158 "If non-nil, include in the agenda entries from the Emacs Calendar's diary.
1159 Custom commands can set this variable in the options section."
1160 :group 'org-agenda-daily/weekly
1161 :type 'boolean)
1163 (defcustom org-agenda-include-deadlines t
1164 "If non-nil, include entries within their deadline warning period.
1165 Custom commands can set this variable in the options section."
1166 :group 'org-agenda-daily/weekly
1167 :version "24.1"
1168 :type 'boolean)
1170 (defcustom org-agenda-repeating-timestamp-show-all t
1171 "Non-nil means show all occurrences of a repeating stamp in the agenda.
1172 When set to a list of strings, only show occurrences of repeating
1173 stamps for these TODO keywords. When nil, only one occurrence is
1174 shown, either today or the nearest into the future."
1175 :group 'org-agenda-daily/weekly
1176 :type '(choice
1177 (const :tag "Show repeating stamps" t)
1178 (repeat :tag "Show repeating stamps for these TODO keywords"
1179 (string :tag "TODO Keyword"))
1180 (const :tag "Don't show repeating stamps" nil)))
1182 (defcustom org-scheduled-past-days 10000
1183 "No. of days to continue listing scheduled items that are not marked DONE.
1184 When an item is scheduled on a date, it shows up in the agenda on this
1185 day and will be listed until it is marked done for the number of days
1186 given here."
1187 :group 'org-agenda-daily/weekly
1188 :type 'integer)
1190 (defcustom org-agenda-log-mode-items '(closed clock)
1191 "List of items that should be shown in agenda log mode.
1192 This list may contain the following symbols:
1194 closed Show entries that have been closed on that day.
1195 clock Show entries that have received clocked time on that day.
1196 state Show all logged state changes.
1197 Note that instead of changing this variable, you can also press `C-u l' in
1198 the agenda to display all available LOG items temporarily."
1199 :group 'org-agenda-daily/weekly
1200 :type '(set :greedy t (const closed) (const clock) (const state)))
1202 (defcustom org-agenda-clock-consistency-checks
1203 '(:max-duration "10:00" :min-duration 0 :max-gap "0:05"
1204 :gap-ok-around ("4:00")
1205 :default-face ((:background "DarkRed") (:foreground "white"))
1206 :overlap-face nil :gap-face nil :no-end-time-face nil
1207 :long-face nil :short-face nil)
1208 "This is a property list, with the following keys:
1210 :max-duration Mark clocking chunks that are longer than this time.
1211 This is a time string like \"HH:MM\", or the number
1212 of minutes as an integer.
1214 :min-duration Mark clocking chunks that are shorter that this.
1215 This is a time string like \"HH:MM\", or the number
1216 of minutes as an integer.
1218 :max-gap Mark gaps between clocking chunks that are longer than
1219 this duration. A number of minutes, or a string
1220 like \"HH:MM\".
1222 :gap-ok-around List of times during the day which are usually not working
1223 times. When a gap is detected, but the gap contains any
1224 of these times, the gap is *not* reported. For example,
1225 if this is (\"4:00\" \"13:00\") then gaps that contain
1226 4:00 in the morning (i.e. the night) and 13:00
1227 (i.e. a typical lunch time) do not cause a warning.
1228 You should have at least one time during the night in this
1229 list, or otherwise the first task each morning will trigger
1230 a warning because it follows a long gap.
1232 Furthermore, the following properties can be used to define faces for
1233 issue display.
1235 :default-face the default face, if the specific face is undefined
1236 :overlap-face face for overlapping clocks
1237 :gap-face face for gaps between clocks
1238 :no-end-time-face face for incomplete clocks
1239 :long-face face for clock intervals that are too long
1240 :short-face face for clock intervals that are too short"
1241 :group 'org-agenda-daily/weekly
1242 :group 'org-clock
1243 :version "24.1"
1244 :type 'plist)
1246 (defcustom org-agenda-log-mode-add-notes t
1247 "Non-nil means add first line of notes to log entries in agenda views.
1248 If a log item like a state change or a clock entry is associated with
1249 notes, the first line of these notes will be added to the entry in the
1250 agenda display."
1251 :group 'org-agenda-daily/weekly
1252 :type 'boolean)
1254 (defcustom org-agenda-start-with-log-mode nil
1255 "The initial value of log-mode in a newly created agenda window.
1256 See `org-agenda-log-mode' and `org-agenda-log-mode-items' for further
1257 explanations on the possible values."
1258 :group 'org-agenda-startup
1259 :group 'org-agenda-daily/weekly
1260 :type '(choice (const :tag "Don't show log items" nil)
1261 (const :tag "Show only log items" 'only)
1262 (const :tag "Show all possible log items" 'clockcheck)
1263 (repeat :tag "Choose among possible values for `org-agenda-log-mode-items'"
1264 (choice (const :tag "Show closed log items" 'closed)
1265 (const :tag "Show clocked log items" 'clock)
1266 (const :tag "Show all logged state changes" 'state)))))
1268 (defcustom org-agenda-start-with-clockreport-mode nil
1269 "The initial value of clockreport-mode in a newly created agenda window."
1270 :group 'org-agenda-startup
1271 :group 'org-agenda-daily/weekly
1272 :type 'boolean)
1274 (defcustom org-agenda-clockreport-parameter-plist '(:link t :maxlevel 2)
1275 "Property list with parameters for the clocktable in clockreport mode.
1276 This is the display mode that shows a clock table in the daily/weekly
1277 agenda, the properties for this dynamic block can be set here.
1278 The usual clocktable parameters are allowed here, but you cannot set
1279 the properties :name, :tstart, :tend, :block, and :scope - these will
1280 be overwritten to make sure the content accurately reflects the
1281 current display in the agenda."
1282 :group 'org-agenda-daily/weekly
1283 :type 'plist)
1285 (defcustom org-agenda-search-view-always-boolean nil
1286 "Non-nil means the search string is interpreted as individual parts.
1288 The search string for search view can either be interpreted as a phrase,
1289 or as a list of snippets that define a boolean search for a number of
1290 strings.
1292 When this is non-nil, the string will be split on whitespace, and each
1293 snippet will be searched individually, and all must match in order to
1294 select an entry. A snippet is then a single string of non-white
1295 characters, or a string in double quotes, or a regexp in {} braces.
1296 If a snippet is preceded by \"-\", the snippet must *not* match.
1297 \"+\" is syntactic sugar for positive selection. Each snippet may
1298 be found as a full word or a partial word, but see the variable
1299 `org-agenda-search-view-force-full-words'.
1301 When this is nil, search will look for the entire search phrase as one,
1302 with each space character matching any amount of whitespace, including
1303 line breaks.
1305 Even when this is nil, you can still switch to Boolean search dynamically
1306 by preceding the first snippet with \"+\" or \"-\". If the first snippet
1307 is a regexp marked with braces like \"{abc}\", this will also switch to
1308 boolean search."
1309 :group 'org-agenda-search-view
1310 :version "24.1"
1311 :type 'boolean)
1313 (if (fboundp 'defvaralias)
1314 (defvaralias 'org-agenda-search-view-search-words-only
1315 'org-agenda-search-view-always-boolean))
1317 (defcustom org-agenda-search-view-force-full-words nil
1318 "Non-nil means, search words must be matches as complete words.
1319 When nil, they may also match part of a word."
1320 :group 'org-agenda-search-view
1321 :version "24.1"
1322 :type 'boolean)
1324 (defcustom org-agenda-search-view-max-outline-level nil
1325 "Maximum outline level to display in search view.
1326 E.g. when this is set to 1, the search view will only
1327 show headlines of level 1."
1328 :group 'org-agenda-search-view
1329 :version "24.3"
1330 :type 'integer)
1332 (defgroup org-agenda-time-grid nil
1333 "Options concerning the time grid in the Org-mode Agenda."
1334 :tag "Org Agenda Time Grid"
1335 :group 'org-agenda)
1337 (defcustom org-agenda-search-headline-for-time t
1338 "Non-nil means search headline for a time-of-day.
1339 If the headline contains a time-of-day in one format or another, it will
1340 be used to sort the entry into the time sequence of items for a day.
1341 Some people have time stamps in the headline that refer to the creation
1342 time or so, and then this produces an unwanted side effect. If this is
1343 the case for your, use this variable to turn off searching the headline
1344 for a time."
1345 :group 'org-agenda-time-grid
1346 :type 'boolean)
1348 (defcustom org-agenda-use-time-grid t
1349 "Non-nil means show a time grid in the agenda schedule.
1350 A time grid is a set of lines for specific times (like every two hours between
1351 8:00 and 20:00). The items scheduled for a day at specific times are
1352 sorted in between these lines.
1353 For details about when the grid will be shown, and what it will look like, see
1354 the variable `org-agenda-time-grid'."
1355 :group 'org-agenda-time-grid
1356 :type 'boolean)
1358 (defcustom org-agenda-time-grid
1359 '((daily today require-timed)
1360 "----------------"
1361 (800 1000 1200 1400 1600 1800 2000))
1363 "The settings for time grid for agenda display.
1364 This is a list of three items. The first item is again a list. It contains
1365 symbols specifying conditions when the grid should be displayed:
1367 daily if the agenda shows a single day
1368 weekly if the agenda shows an entire week
1369 today show grid on current date, independent of daily/weekly display
1370 require-timed show grid only if at least one item has a time specification
1372 The second item is a string which will be placed behind the grid time.
1374 The third item is a list of integers, indicating the times that should have
1375 a grid line."
1376 :group 'org-agenda-time-grid
1377 :type
1378 '(list
1379 (set :greedy t :tag "Grid Display Options"
1380 (const :tag "Show grid in single day agenda display" daily)
1381 (const :tag "Show grid in weekly agenda display" weekly)
1382 (const :tag "Always show grid for today" today)
1383 (const :tag "Show grid only if any timed entries are present"
1384 require-timed)
1385 (const :tag "Skip grid times already present in an entry"
1386 remove-match))
1387 (string :tag "Grid String")
1388 (repeat :tag "Grid Times" (integer :tag "Time"))))
1390 (defcustom org-agenda-show-current-time-in-grid t
1391 "Non-nil means show the current time in the time grid."
1392 :group 'org-agenda-time-grid
1393 :version "24.1"
1394 :type 'boolean)
1396 (defcustom org-agenda-current-time-string
1397 "now - - - - - - - - - - - - - - - - - - - - - - - - -"
1398 "The string for the current time marker in the agenda."
1399 :group 'org-agenda-time-grid
1400 :version "24.1"
1401 :type 'string)
1403 (defgroup org-agenda-sorting nil
1404 "Options concerning sorting in the Org-mode Agenda."
1405 :tag "Org Agenda Sorting"
1406 :group 'org-agenda)
1408 (defcustom org-agenda-sorting-strategy
1409 '((agenda habit-down time-up priority-down category-keep)
1410 (todo priority-down category-keep)
1411 (tags priority-down category-keep)
1412 (search category-keep))
1413 "Sorting structure for the agenda items of a single day.
1414 This is a list of symbols which will be used in sequence to determine
1415 if an entry should be listed before another entry. The following
1416 symbols are recognized:
1418 time-up Put entries with time-of-day indications first, early first
1419 time-down Put entries with time-of-day indications first, late first
1420 category-keep Keep the default order of categories, corresponding to the
1421 sequence in `org-agenda-files'.
1422 category-up Sort alphabetically by category, A-Z.
1423 category-down Sort alphabetically by category, Z-A.
1424 tag-up Sort alphabetically by last tag, A-Z.
1425 tag-down Sort alphabetically by last tag, Z-A.
1426 priority-up Sort numerically by priority, high priority last.
1427 priority-down Sort numerically by priority, high priority first.
1428 todo-state-up Sort by todo state, tasks that are done last.
1429 todo-state-down Sort by todo state, tasks that are done first.
1430 effort-up Sort numerically by estimated effort, high effort last.
1431 effort-down Sort numerically by estimated effort, high effort first.
1432 user-defined-up Sort according to `org-agenda-cmp-user-defined', high last.
1433 user-defined-down Sort according to `org-agenda-cmp-user-defined', high first.
1434 habit-up Put entries that are habits first
1435 habit-down Put entries that are habits last
1436 alpha-up Sort headlines alphabetically
1437 alpha-down Sort headlines alphabetically, reversed
1439 The different possibilities will be tried in sequence, and testing stops
1440 if one comparison returns a \"not-equal\". For example, the default
1441 '(time-up category-keep priority-down)
1442 means: Pull out all entries having a specified time of day and sort them,
1443 in order to make a time schedule for the current day the first thing in the
1444 agenda listing for the day. Of the entries without a time indication, keep
1445 the grouped in categories, don't sort the categories, but keep them in
1446 the sequence given in `org-agenda-files'. Within each category sort by
1447 priority.
1449 Leaving out `category-keep' would mean that items will be sorted across
1450 categories by priority.
1452 Instead of a single list, this can also be a set of list for specific
1453 contents, with a context symbol in the car of the list, any of
1454 `agenda', `todo', `tags', `search' for the corresponding agenda views.
1456 Custom commands can bind this variable in the options section."
1457 :group 'org-agenda-sorting
1458 :type `(choice
1459 (repeat :tag "General" ,org-sorting-choice)
1460 (list :tag "Individually"
1461 (cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
1462 (repeat ,org-sorting-choice))
1463 (cons (const :tag "Strategy for TODO lists" todo)
1464 (repeat ,org-sorting-choice))
1465 (cons (const :tag "Strategy for Tags matches" tags)
1466 (repeat ,org-sorting-choice))
1467 (cons (const :tag "Strategy for search matches" search)
1468 (repeat ,org-sorting-choice)))))
1470 (defcustom org-agenda-cmp-user-defined nil
1471 "A function to define the comparison `user-defined'.
1472 This function must receive two arguments, agenda entry a and b.
1473 If a>b, return +1. If a<b, return -1. If they are equal as seen by
1474 the user comparison, return nil.
1475 When this is defined, you can make `user-defined-up' and `user-defined-down'
1476 part of an agenda sorting strategy."
1477 :group 'org-agenda-sorting
1478 :type 'symbol)
1480 (defcustom org-sort-agenda-notime-is-late t
1481 "Non-nil means items without time are considered late.
1482 This is only relevant for sorting. When t, items which have no explicit
1483 time like 15:30 will be considered as 99:01, i.e. later than any items which
1484 do have a time. When nil, the default time is before 0:00. You can use this
1485 option to decide if the schedule for today should come before or after timeless
1486 agenda entries."
1487 :group 'org-agenda-sorting
1488 :type 'boolean)
1490 (defcustom org-sort-agenda-noeffort-is-high t
1491 "Non-nil means items without effort estimate are sorted as high effort.
1492 This also applies when filtering an agenda view with respect to the
1493 < or > effort operator. Then, tasks with no effort defined will be treated
1494 as tasks with high effort.
1495 When nil, such items are sorted as 0 minutes effort."
1496 :group 'org-agenda-sorting
1497 :type 'boolean)
1499 (defgroup org-agenda-line-format nil
1500 "Options concerning the entry prefix in the Org-mode agenda display."
1501 :tag "Org Agenda Line Format"
1502 :group 'org-agenda)
1504 (defcustom org-agenda-prefix-format
1505 '((agenda . " %i %-12:c%?-12t% s")
1506 (timeline . " % s")
1507 (todo . " %i %-12:c")
1508 (tags . " %i %-12:c")
1509 (search . " %i %-12:c"))
1510 "Format specifications for the prefix of items in the agenda views.
1511 An alist with five entries, each for the different agenda types. The
1512 keys of the sublists are `agenda', `timeline', `todo', `search' and `tags'.
1513 The values are format strings.
1515 This format works similar to a printf format, with the following meaning:
1517 %c the category of the item, \"Diary\" for entries from the diary,
1518 or as given by the CATEGORY keyword or derived from the file name
1519 %e the effort required by the item
1520 %l the level of the item (insert X space(s) if item is of level X)
1521 %i the icon category of the item, see `org-agenda-category-icon-alist'
1522 %T the last tag of the item (ignore inherited tags, which come first)
1523 %t the HH:MM time-of-day specification if one applies to the entry
1524 %s Scheduling/Deadline information, a short string
1525 %(expression) Eval EXPRESSION and replace the control string
1526 by the result
1528 All specifiers work basically like the standard `%s' of printf, but may
1529 contain two additional characters: a question mark just after the `%'
1530 and a whitespace/punctuation character just before the final letter.
1532 If the first character after `%' is a question mark, the entire field
1533 will only be included if the corresponding value applies to the current
1534 entry. This is useful for fields which should have fixed width when
1535 present, but zero width when absent. For example, \"%?-12t\" will
1536 result in a 12 character time field if a time of the day is specified,
1537 but will completely disappear in entries which do not contain a time.
1539 If there is punctuation or whitespace character just before the final
1540 format letter, this character will be appended to the field value if
1541 the value is not empty. For example, the format \"%-12:c\" leads to
1542 \"Diary: \" if the category is \"Diary\". If the category were be
1543 empty, no additional colon would be inserted.
1545 The default value for the agenda sublist is \" %-12:c%?-12t% s\",
1546 which means:
1548 - Indent the line with two space characters
1549 - Give the category a 12 chars wide field, padded with whitespace on
1550 the right (because of `-'). Append a colon if there is a category
1551 (because of `:').
1552 - If there is a time-of-day, put it into a 12 chars wide field. If no
1553 time, don't put in an empty field, just skip it (because of '?').
1554 - Finally, put the scheduling information.
1556 See also the variables `org-agenda-remove-times-when-in-prefix' and
1557 `org-agenda-remove-tags'.
1559 Custom commands can set this variable in the options section."
1560 :type '(choice
1561 (string :tag "General format")
1562 (list :greedy t :tag "View dependent"
1563 (cons (const agenda) (string :tag "Format"))
1564 (cons (const timeline) (string :tag "Format"))
1565 (cons (const todo) (string :tag "Format"))
1566 (cons (const tags) (string :tag "Format"))
1567 (cons (const search) (string :tag "Format"))))
1568 :group 'org-agenda-line-format)
1570 (defvar org-prefix-format-compiled nil
1571 "The compiled prefix format and associated variables.
1572 This is a list where first element is a list of variable bindings, and second
1573 element is the compiled format expression. See the variable
1574 `org-agenda-prefix-format'.")
1576 (defcustom org-agenda-todo-keyword-format "%-1s"
1577 "Format for the TODO keyword in agenda lines.
1578 Set this to something like \"%-12s\" if you want all TODO keywords
1579 to occupy a fixed space in the agenda display."
1580 :group 'org-agenda-line-format
1581 :type 'string)
1583 (defcustom org-agenda-diary-sexp-prefix nil
1584 "A regexp that matches part of a diary sexp entry
1585 which should be treated as scheduling/deadline information in
1586 `org-agenda'.
1588 For example, you can use this to extract the `diary-remind-message' from
1589 `diary-remind' entries."
1590 :group 'org-agenda-line-format
1591 :type '(choice (const :tag "None" nil) (regexp :tag "Regexp")))
1593 (defcustom org-agenda-timerange-leaders '("" "(%d/%d): ")
1594 "Text preceding timerange entries in the agenda view.
1595 This is a list with two strings. The first applies when the range
1596 is entirely on one day. The second applies if the range spans several days.
1597 The strings may have two \"%d\" format specifiers which will be filled
1598 with the sequence number of the days, and the total number of days in the
1599 range, respectively."
1600 :group 'org-agenda-line-format
1601 :type '(list
1602 (string :tag "Deadline today ")
1603 (choice :tag "Deadline relative"
1604 (string :tag "Format string")
1605 (function))))
1607 (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
1608 "Text preceding scheduled items in the agenda view.
1609 This is a list with two strings. The first applies when the item is
1610 scheduled on the current day. The second applies when it has been scheduled
1611 previously, it may contain a %d indicating that this is the nth time that
1612 this item is scheduled, due to automatic rescheduling of unfinished items
1613 for the following day. So this number is one larger than the number of days
1614 that passed since this item was scheduled first."
1615 :group 'org-agenda-line-format
1616 :type '(list
1617 (string :tag "Scheduled today ")
1618 (string :tag "Scheduled previously")))
1620 (defcustom org-agenda-inactive-leader "["
1621 "Text preceding item pulled into the agenda by inactive time stamps.
1622 These entries are added to the agenda when pressing \"[\"."
1623 :group 'org-agenda-line-format
1624 :version "24.1"
1625 :type '(list
1626 (string :tag "Scheduled today ")
1627 (string :tag "Scheduled previously")))
1629 (defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: ")
1630 "Text preceding deadline items in the agenda view.
1631 This is a list with two strings. The first applies when the item has its
1632 deadline on the current day. The second applies when it is in the past or
1633 in the future, it may contain %d to capture how many days away the deadline
1634 is (was)."
1635 :group 'org-agenda-line-format
1636 :type '(list
1637 (string :tag "Deadline today ")
1638 (choice :tag "Deadline relative"
1639 (string :tag "Format string")
1640 (function))))
1642 (defcustom org-agenda-remove-times-when-in-prefix t
1643 "Non-nil means remove duplicate time specifications in agenda items.
1644 When the format `org-agenda-prefix-format' contains a `%t' specifier, a
1645 time-of-day specification in a headline or diary entry is extracted and
1646 placed into the prefix. If this option is non-nil, the original specification
1647 \(a timestamp or -range, or just a plain time(range) specification like
1648 11:30-4pm) will be removed for agenda display. This makes the agenda less
1649 cluttered.
1650 The option can be t or nil. It may also be the symbol `beg', indicating
1651 that the time should only be removed when it is located at the beginning of
1652 the headline/diary entry."
1653 :group 'org-agenda-line-format
1654 :type '(choice
1655 (const :tag "Always" t)
1656 (const :tag "Never" nil)
1657 (const :tag "When at beginning of entry" beg)))
1659 (defcustom org-agenda-remove-timeranges-from-blocks nil
1660 "Non-nil means remove time ranges specifications in agenda
1661 items that span on several days."
1662 :group 'org-agenda-line-format
1663 :version "24.1"
1664 :type 'boolean)
1666 (defcustom org-agenda-default-appointment-duration nil
1667 "Default duration for appointments that only have a starting time.
1668 When nil, no duration is specified in such cases.
1669 When non-nil, this must be the number of minutes, e.g. 60 for one hour."
1670 :group 'org-agenda-line-format
1671 :type '(choice
1672 (integer :tag "Minutes")
1673 (const :tag "No default duration")))
1675 (defcustom org-agenda-show-inherited-tags t
1676 "Non-nil means show inherited tags in each agenda line.
1678 When this option is set to 'always, it take precedences over
1679 `org-agenda-use-tag-inheritance' and inherited tags are shown
1680 in every agenda.
1682 When this option is set to t (the default), inherited tags are
1683 shown when they are available, i.e. when the value of
1684 `org-agenda-use-tag-inheritance' has been taken into account.
1686 This can be set to a list of agenda types in which the agenda
1687 must display the inherited tags. Available types are 'todo,
1688 'agenda, 'search and 'timeline.
1690 When set to nil, never show inherited tags in agenda lines."
1691 :group 'org-agenda-line-format
1692 :group 'org-agenda
1693 :version "24.3"
1694 :type '(choice
1695 (const :tag "Show inherited tags when available" t)
1696 (const :tag "Always show inherited tags" 'always)
1697 (repeat :tag "Show inherited tags only in selected agenda types"
1698 (symbol :tag "Agenda type"))))
1700 (defcustom org-agenda-use-tag-inheritance '(todo search timeline agenda)
1701 "List of agenda view types where to use tag inheritance.
1703 In tags/tags-todo/tags-tree agenda views, tag inheritance is
1704 controlled by `org-use-tag-inheritance'. In other agenda types,
1705 `org-use-tag-inheritance' is not used for the selection of the
1706 agenda entries. Still, you may want the agenda to be aware of
1707 the inherited tags anyway, e.g. for later tag filtering.
1709 Allowed value are 'todo, 'search, 'timeline and 'agenda.
1711 This variable has no effect if `org-agenda-show-inherited-tags'
1712 is set to 'always. In that case, the agenda is aware of those
1713 tags.
1715 The default value sets tags in every agenda type. Setting this
1716 option to nil will speed up non-tags agenda view a lot."
1717 :group 'org-agenda
1718 :version "24.3"
1719 :type '(choice
1720 (const :tag "Use tag inheritance in all agenda types" t)
1721 (repeat :tag "Use tag inheritance in selected agenda types"
1722 (symbol :tag "Agenda type"))))
1724 (defcustom org-agenda-hide-tags-regexp nil
1725 "Regular expression used to filter away specific tags in agenda views.
1726 This means that these tags will be present, but not be shown in the agenda
1727 line. Secondary filtering will still work on the hidden tags.
1728 Nil means don't hide any tags."
1729 :group 'org-agenda-line-format
1730 :type '(choice
1731 (const :tag "Hide none" nil)
1732 (string :tag "Regexp ")))
1734 (defcustom org-agenda-remove-tags nil
1735 "Non-nil means remove the tags from the headline copy in the agenda.
1736 When this is the symbol `prefix', only remove tags when
1737 `org-agenda-prefix-format' contains a `%T' specifier."
1738 :group 'org-agenda-line-format
1739 :type '(choice
1740 (const :tag "Always" t)
1741 (const :tag "Never" nil)
1742 (const :tag "When prefix format contains %T" prefix)))
1744 (if (fboundp 'defvaralias)
1745 (defvaralias 'org-agenda-remove-tags-when-in-prefix
1746 'org-agenda-remove-tags))
1748 (defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
1749 "Shift tags in agenda items to this column.
1750 If this number is positive, it specifies the column. If it is negative,
1751 it means that the tags should be flushright to that column. For example,
1752 -80 works well for a normal 80 character screen."
1753 :group 'org-agenda-line-format
1754 :type 'integer)
1756 (if (fboundp 'defvaralias)
1757 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
1759 (defcustom org-agenda-fontify-priorities 'cookies
1760 "Non-nil means highlight low and high priorities in agenda.
1761 When t, the highest priority entries are bold, lowest priority italic.
1762 However, settings in `org-priority-faces' will overrule these faces.
1763 When this variable is the symbol `cookies', only fontify the
1764 cookies, not the entire task.
1765 This may also be an association list of priority faces, whose
1766 keys are the character values of `org-highest-priority',
1767 `org-default-priority', and `org-lowest-priority' (the default values
1768 are ?A, ?B, and ?C, respectively). The face may be a named face, a
1769 color as a string, or a list like `(:background \"Red\")'.
1770 If it is a color, the variable `org-faces-easy-properties'
1771 determines if it is a foreground or a background color."
1772 :group 'org-agenda-line-format
1773 :type '(choice
1774 (const :tag "Never" nil)
1775 (const :tag "Defaults" t)
1776 (const :tag "Cookies only" cookies)
1777 (repeat :tag "Specify"
1778 (list (character :tag "Priority" :value ?A)
1779 (choice :tag "Face "
1780 (string :tag "Color")
1781 (sexp :tag "Face"))))))
1783 (defcustom org-agenda-day-face-function nil
1784 "Function called to determine what face should be used to display a day.
1785 The only argument passed to that function is the day. It should
1786 returns a face, or nil if does not want to specify a face and let
1787 the normal rules apply."
1788 :group 'org-agenda-line-format
1789 :version "24.1"
1790 :type 'function)
1792 (defcustom org-agenda-category-icon-alist nil
1793 "Alist of category icon to be displayed in agenda views.
1795 Each entry should have the following format:
1799 Where CATEGORY-REGEXP is a regexp matching the categories where
1800 the icon should be displayed.
1801 FILE-OR-DATA either a file path or a string containing image data.
1803 The other fields can be omitted safely if not needed:
1804 TYPE indicates the image type.
1805 DATA-P is a boolean indicating whether the FILE-OR-DATA string is
1806 image data.
1807 PROPS are additional image attributes to assign to the image,
1808 like, e.g. `:ascent center'.
1810 (\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
1812 If you want to set the display properties yourself, just put a
1813 list as second element:
1817 For example, to display a 16px horizontal space for Emacs
1818 category, you can use:
1820 (\"Emacs\" '(space . (:width (16))))"
1821 :group 'org-agenda-line-format
1822 :version "24.1"
1823 :type '(alist :key-type (string :tag "Regexp matching category")
1824 :value-type (choice (list :tag "Icon"
1825 (string :tag "File or data")
1826 (symbol :tag "Type")
1827 (boolean :tag "Data?")
1828 (repeat :tag "Extra image properties" :inline t symbol))
1829 (list :tag "Display properties" sexp))))
1831 (defgroup org-agenda-column-view nil
1832 "Options concerning column view in the agenda."
1833 :tag "Org Agenda Column View"
1834 :group 'org-agenda)
1836 (defcustom org-agenda-columns-show-summaries t
1837 "Non-nil means show summaries for columns displayed in the agenda view."
1838 :group 'org-agenda-column-view
1839 :type 'boolean)
1841 (defcustom org-agenda-columns-compute-summary-properties t
1842 "Non-nil means recompute all summary properties before column view.
1843 When column view in the agenda is listing properties that have a summary
1844 operator, it can go to all relevant buffers and recompute the summaries
1845 there. This can mean overhead for the agenda column view, but is necessary
1846 to have thing up to date.
1847 As a special case, a CLOCKSUM property also makes sure that the clock
1848 computations are current."
1849 :group 'org-agenda-column-view
1850 :type 'boolean)
1852 (defcustom org-agenda-columns-add-appointments-to-effort-sum nil
1853 "Non-nil means the duration of an appointment will add to day effort.
1854 The property to which appointment durations will be added is the one given
1855 in the option `org-effort-property'. If an appointment does not have
1856 an end time, `org-agenda-default-appointment-duration' will be used. If that
1857 is not set, an appointment without end time will not contribute to the time
1858 estimate."
1859 :group 'org-agenda-column-view
1860 :type 'boolean)
1862 (defcustom org-agenda-auto-exclude-function nil
1863 "A function called with a tag to decide if it is filtered on '/ RET'.
1864 The sole argument to the function, which is called once for each
1865 possible tag, is a string giving the name of the tag. The
1866 function should return either nil if the tag should be included
1867 as normal, or \"-<TAG>\" to exclude the tag.
1868 Note that for the purpose of tag filtering, only the lower-case version of
1869 all tags will be considered, so that this function will only ever see
1870 the lower-case version of all tags."
1871 :group 'org-agenda
1872 :type 'function)
1874 (defcustom org-agenda-bulk-custom-functions nil
1875 "Alist of characters and custom functions for bulk actions.
1876 For example, this value makes those two functions available:
1878 '((?R set-category)
1879 (?C bulk-cut))
1881 With selected entries in an agenda buffer, `B R' will call
1882 the custom function `set-category' on the selected entries.
1883 Note that functions in this alist don't need to be quoted."
1884 :type 'alist
1885 :version "24.1"
1886 :group 'org-agenda)
1888 (defmacro org-agenda-with-point-at-orig-entry (string &rest body)
1889 "Execute BODY with point at location given by `org-hd-marker' property.
1890 If STRING is non-nil, the text property will be fetched from position 0
1891 in that string. If STRING is nil, it will be fetched from the beginning
1892 of the current line."
1893 (org-with-gensyms (marker)
1894 `(let ((,marker (get-text-property (if string 0 (point-at-bol))
1895 'org-hd-marker ,string)))
1896 (with-current-buffer (marker-buffer ,marker)
1897 (save-excursion
1898 (goto-char ,marker)
1899 ,@body)))))
1900 (def-edebug-spec org-agenda-with-point-at-orig-entry (form body))
1902 (defun org-add-agenda-custom-command (entry)
1903 "Replace or add a command in `org-agenda-custom-commands'.
1904 This is mostly for hacking and trying a new command - once the command
1905 works you probably want to add it to `org-agenda-custom-commands' for good."
1906 (let ((ass (assoc (car entry) org-agenda-custom-commands)))
1907 (if ass
1908 (setcdr ass (cdr entry))
1909 (push entry org-agenda-custom-commands))))
1911 ;;; Define the org-agenda-mode
1913 (defvar org-agenda-mode-map (make-sparse-keymap)
1914 "Keymap for `org-agenda-mode'.")
1915 (if (fboundp 'defvaralias)
1916 (defvaralias 'org-agenda-keymap 'org-agenda-mode-map))
1918 (defvar org-agenda-menu) ; defined later in this file.
1919 (defvar org-agenda-restrict nil) ; defined later in this file.
1920 (defvar org-agenda-follow-mode nil)
1921 (defvar org-agenda-entry-text-mode nil)
1922 (defvar org-agenda-clockreport-mode nil)
1923 (defvar org-agenda-show-log nil)
1924 (defvar org-agenda-redo-command nil)
1925 (defvar org-agenda-query-string nil)
1926 (defvar org-agenda-mode-hook nil
1927 "Hook run after `org-agenda-mode' is turned on.
1928 The buffer is still writable when this hook is called.")
1929 (defvar org-agenda-type nil)
1930 (defvar org-agenda-force-single-file nil)
1931 (defvar org-agenda-bulk-marked-entries nil
1932 "List of markers that refer to marked entries in the agenda.")
1934 ;;; Multiple agenda buffers support
1936 (defcustom org-agenda-sticky nil
1937 "Non-nil means agenda q key will bury agenda buffers.
1938 Agenda commands will then show existing buffer instead of generating new ones.
1939 When nil, `q' will kill the single agenda buffer."
1940 :group 'org-agenda
1941 :version "24.3"
1942 :type 'boolean)
1945 ;;;###autoload
1946 (defun org-toggle-sticky-agenda (&optional arg)
1947 "Toggle `org-agenda-sticky'."
1948 (interactive "P")
1949 (let ((new-value (if arg
1950 (> (prefix-numeric-value arg) 0)
1951 (not org-agenda-sticky))))
1952 (if (equal new-value org-agenda-sticky)
1953 (and (org-called-interactively-p 'interactive)
1954 (message "Sticky agenda was already %s"
1955 (if org-agenda-sticky "enabled" "disabled")))
1956 (setq org-agenda-sticky new-value)
1957 (org-agenda-kill-all-agenda-buffers)
1958 (and (org-called-interactively-p 'interactive)
1959 (message "Sticky agenda was %s"
1960 (if org-agenda-sticky "enabled" "disabled"))))))
1962 (autoload 'org-toggle-sticky-agenda "org-agenda" "\
1963 Toggle `org-agenda-sticky'.
1965 \(fn &optional ARG)" t nil)
1967 (defvar org-agenda-buffer nil
1968 "Agenda buffer currently being generated.")
1970 (defvar org-agenda-last-prefix-arg nil)
1971 (defvar org-agenda-this-buffer-name nil)
1972 (defvar org-agenda-doing-sticky-redo nil)
1973 (defvar org-agenda-this-buffer-is-sticky nil)
1975 (defconst org-agenda-local-vars
1976 '(org-agenda-this-buffer-name
1977 org-agenda-undo-list
1978 org-agenda-pending-undo-list
1979 org-agenda-follow-mode
1980 org-agenda-entry-text-mode
1981 org-agenda-clockreport-mode
1982 org-agenda-show-log
1983 org-agenda-redo-command
1984 org-agenda-query-string
1985 org-agenda-type
1986 org-agenda-bulk-marked-entries
1987 org-agenda-undo-has-started-in
1988 org-agenda-info
1989 org-agenda-tag-filter-overlays
1990 org-agenda-cat-filter-overlays
1991 org-agenda-pre-window-conf
1992 org-agenda-columns-active
1993 org-agenda-tag-filter
1994 org-agenda-category-filter
1995 org-agenda-markers
1996 org-agenda-last-search-view-search-was-boolean
1997 org-agenda-filtered-by-category
1998 org-agenda-filter-form
1999 org-agenda-show-window
2000 org-agenda-cycle-counter
2001 org-agenda-last-prefix-arg)
2002 "Variables that must be local in agenda buffers to allow multiple buffers.")
2004 (defun org-agenda-mode ()
2005 "Mode for time-sorted view on action items in Org-mode files.
2007 The following commands are available:
2009 \\{org-agenda-mode-map}"
2010 (interactive)
2011 (cond (org-agenda-doing-sticky-redo
2012 ;; Refreshing sticky agenda-buffer
2014 ;; Preserve the value of `org-agenda-local-vars' variables,
2015 ;; while letting `kill-all-local-variables' kill the rest
2016 (let ((save (buffer-local-variables)))
2017 (kill-all-local-variables)
2018 (mapc 'make-local-variable org-agenda-local-vars)
2019 (dolist (elem save)
2020 (let ((var (car elem))
2021 (val (cdr elem)))
2022 (when (and val
2023 (member var org-agenda-local-vars))
2024 (set var val)))))
2025 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
2026 (org-agenda-sticky
2027 ;; Creating a sticky Agenda buffer for the first time
2028 (kill-all-local-variables)
2029 (mapc 'make-local-variable org-agenda-local-vars)
2030 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) t))
2032 ;; Creating a non-sticky agenda buffer
2033 (kill-all-local-variables)
2034 (set (make-local-variable 'org-agenda-this-buffer-is-sticky) nil)))
2035 (setq org-agenda-undo-list nil
2036 org-agenda-pending-undo-list nil
2037 org-agenda-bulk-marked-entries nil)
2038 (setq major-mode 'org-agenda-mode)
2039 ;; Keep global-font-lock-mode from turning on font-lock-mode
2040 (org-set-local 'font-lock-global-modes (list 'not major-mode))
2041 (setq mode-name "Org-Agenda")
2042 (use-local-map org-agenda-mode-map)
2043 (easy-menu-add org-agenda-menu)
2044 (if org-startup-truncated (setq truncate-lines t))
2045 (org-set-local 'line-move-visual nil)
2046 (org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
2047 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
2048 ;; Make sure properties are removed when copying text
2049 (make-local-variable 'filter-buffer-substring-functions)
2050 (add-hook 'filter-buffer-substring-functions
2051 (lambda (fun start end delete)
2052 (substring-no-properties (funcall fun start end delete))))
2053 (unless org-agenda-keep-modes
2054 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
2055 org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
2056 org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
2057 org-agenda-show-log org-agenda-start-with-log-mode))
2059 (easy-menu-change
2060 '("Agenda") "Agenda Files"
2061 (append
2062 (list
2063 (vector
2064 (if (get 'org-agenda-files 'org-restrict)
2065 "Restricted to single file"
2066 "Edit File List")
2067 '(org-edit-agenda-file-list)
2068 (not (get 'org-agenda-files 'org-restrict)))
2069 "--")
2070 (mapcar 'org-file-menu-entry (org-agenda-files))))
2071 (org-agenda-set-mode-name)
2072 (apply
2073 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
2074 (list 'org-agenda-mode-hook)))
2076 (substitute-key-definition 'undo 'org-agenda-undo
2077 org-agenda-mode-map global-map)
2078 (org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
2079 (org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
2080 (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
2081 (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
2082 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
2083 (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
2084 (org-defkey org-agenda-mode-map "*" 'org-agenda-bulk-mark-all)
2085 (org-defkey org-agenda-mode-map "#" 'org-agenda-dim-blocked-tasks)
2086 (org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
2087 (org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
2088 (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-unmark-all)
2089 (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
2090 (org-defkey org-agenda-mode-map "k" 'org-agenda-capture)
2091 (org-defkey org-agenda-mode-map "A" 'org-agenda-append-agenda)
2092 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
2093 (org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
2094 (org-defkey org-agenda-mode-map "\C-c\C-xa" 'org-agenda-toggle-archive-tag)
2095 (org-defkey org-agenda-mode-map "\C-c\C-xA" 'org-agenda-archive-to-archive-sibling)
2096 (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
2097 (org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
2098 (org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
2099 (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
2100 (org-defkey org-agenda-mode-map " " 'org-agenda-show-and-scroll-up)
2101 (org-defkey org-agenda-mode-map [backspace] 'org-agenda-show-scroll-down)
2102 (org-defkey org-agenda-mode-map "\d" 'org-agenda-show-scroll-down)
2103 (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
2104 (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
2105 (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
2106 (org-defkey org-agenda-mode-map "o" 'delete-other-windows)
2107 (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
2108 (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
2109 (org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
2110 (org-defkey org-agenda-mode-map "a" 'org-agenda-archive-default-with-confirmation)
2111 (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
2112 (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
2113 (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
2114 (org-defkey org-agenda-mode-map "j" 'org-agenda-goto-date)
2115 (org-defkey org-agenda-mode-map "d" 'org-agenda-day-view)
2116 (org-defkey org-agenda-mode-map "w" 'org-agenda-week-view)
2117 (org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
2118 (org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
2119 (org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
2120 (org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
2121 (org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
2122 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
2123 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-do-date-earlier)
2125 (org-defkey org-agenda-mode-map ">" 'org-agenda-date-prompt)
2126 (org-defkey org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
2127 (org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
2128 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
2129 (while l (org-defkey org-agenda-mode-map
2130 (int-to-string (pop l)) 'digit-argument)))
2132 (org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
2133 (org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
2134 (org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
2135 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
2136 (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
2137 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
2138 (org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines)
2139 (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
2140 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
2141 (org-defkey org-agenda-mode-map "g" (lambda () (interactive) (org-agenda-redo t)))
2142 (org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
2143 (org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
2144 (org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
2145 'org-clock-modify-effort-estimate)
2146 (org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
2147 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
2148 (org-defkey org-agenda-mode-map "Q" 'org-agenda-Quit)
2149 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
2150 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-agenda-write)
2151 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
2152 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
2153 (org-defkey org-agenda-mode-map "T" 'org-agenda-show-tags)
2154 (org-defkey org-agenda-mode-map "n" 'org-agenda-next-line)
2155 (org-defkey org-agenda-mode-map "p" 'org-agenda-previous-line)
2156 (org-defkey org-agenda-mode-map "N" 'org-agenda-next-item)
2157 (org-defkey org-agenda-mode-map "P" 'org-agenda-previous-item)
2158 (substitute-key-definition 'next-line 'org-agenda-next-line
2159 org-agenda-mode-map global-map)
2160 (substitute-key-definition 'previous-line 'org-agenda-previous-line
2161 org-agenda-mode-map global-map)
2162 (org-defkey org-agenda-mode-map "\C-c\C-a" 'org-attach)
2163 (org-defkey org-agenda-mode-map "\C-c\C-n" 'org-agenda-next-date-line)
2164 (org-defkey org-agenda-mode-map "\C-c\C-p" 'org-agenda-previous-date-line)
2165 (org-defkey org-agenda-mode-map "\C-c," 'org-agenda-priority)
2166 (org-defkey org-agenda-mode-map "," 'org-agenda-priority)
2167 (org-defkey org-agenda-mode-map "i" 'org-agenda-diary-entry)
2168 (org-defkey org-agenda-mode-map "c" 'org-agenda-goto-calendar)
2169 (org-defkey org-agenda-mode-map "C" 'org-agenda-convert-date)
2170 (org-defkey org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
2171 (org-defkey org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
2172 (org-defkey org-agenda-mode-map "h" 'org-agenda-holidays)
2173 (org-defkey org-agenda-mode-map "H" 'org-agenda-holidays)
2174 (org-defkey org-agenda-mode-map "\C-c\C-x\C-i" 'org-agenda-clock-in)
2175 (org-defkey org-agenda-mode-map "I" 'org-agenda-clock-in)
2176 (org-defkey org-agenda-mode-map "\C-c\C-x\C-o" 'org-agenda-clock-out)
2177 (org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out)
2178 (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel)
2179 (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel)
2180 (org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
2181 (org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto)
2182 (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up)
2183 (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
2184 (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
2185 (org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
2186 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
2187 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
2188 (org-defkey org-agenda-mode-map "f" 'org-agenda-later)
2189 (org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
2190 (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
2191 (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
2193 (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
2194 (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
2195 (org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
2196 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
2197 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
2198 (org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
2199 (org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
2200 (org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-category)
2201 (org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
2202 (define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
2203 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
2204 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
2206 (org-defkey org-agenda-mode-map [mouse-2] 'org-agenda-goto-mouse)
2207 (org-defkey org-agenda-mode-map [mouse-3] 'org-agenda-show-mouse)
2208 (when org-agenda-mouse-1-follows-link
2209 (org-defkey org-agenda-mode-map [follow-link] 'mouse-face))
2210 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
2211 '("Agenda"
2212 ("Agenda Files")
2213 "--"
2214 ("Agenda Dates"
2215 ["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
2216 ["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
2217 ["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
2218 ["Jump to date" org-agenda-goto-date (org-agenda-check-type nil 'agenda)])
2219 "--"
2220 ("View"
2221 ["Day View" org-agenda-day-view
2222 :active (org-agenda-check-type nil 'agenda)
2223 :style radio :selected (eq org-agenda-current-span 'day)
2224 :keys "v d (or just d)"]
2225 ["Week View" org-agenda-week-view
2226 :active (org-agenda-check-type nil 'agenda)
2227 :style radio :selected (eq org-agenda-current-span 'week)
2228 :keys "v w (or just w)"]
2229 ["Month View" org-agenda-month-view
2230 :active (org-agenda-check-type nil 'agenda)
2231 :style radio :selected (eq org-agenda-current-span 'month)
2232 :keys "v m"]
2233 ["Year View" org-agenda-year-view
2234 :active (org-agenda-check-type nil 'agenda)
2235 :style radio :selected (eq org-agenda-current-span 'year)
2236 :keys "v y"]
2237 "--"
2238 ["Include Diary" org-agenda-toggle-diary
2239 :style toggle :selected org-agenda-include-diary
2240 :active (org-agenda-check-type nil 'agenda)]
2241 ["Include Deadlines" org-agenda-toggle-deadlines
2242 :style toggle :selected org-agenda-include-deadlines
2243 :active (org-agenda-check-type nil 'agenda)]
2244 ["Use Time Grid" org-agenda-toggle-time-grid
2245 :style toggle :selected org-agenda-use-time-grid
2246 :active (org-agenda-check-type nil 'agenda)]
2247 "--"
2248 ["Show clock report" org-agenda-clockreport-mode
2249 :style toggle :selected org-agenda-clockreport-mode
2250 :active (org-agenda-check-type nil 'agenda)]
2251 ["Show some entry text" org-agenda-entry-text-mode
2252 :style toggle :selected org-agenda-entry-text-mode
2253 :active t]
2254 "--"
2255 ["Show Logbook entries" org-agenda-log-mode
2256 :style toggle :selected org-agenda-show-log
2257 :active (org-agenda-check-type nil 'agenda 'timeline)
2258 :keys "v l (or just l)"]
2259 ["Include archived trees" org-agenda-archives-mode
2260 :style toggle :selected org-agenda-archives-mode :active t
2261 :keys "v a"]
2262 ["Include archive files" (org-agenda-archives-mode t)
2263 :style toggle :selected (eq org-agenda-archives-mode t) :active t
2264 :keys "v A"]
2265 "--"
2266 ["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict])
2267 ["Write view to file" org-agenda-write t]
2268 ["Rebuild buffer" org-agenda-redo t]
2269 ["Save all Org-mode Buffers" org-save-all-org-buffers t]
2270 "--"
2271 ["Show original entry" org-agenda-show t]
2272 ["Go To (other window)" org-agenda-goto t]
2273 ["Go To (this window)" org-agenda-switch-to t]
2274 ["Capture with cursor date" org-agenda-capture t]
2275 ["Follow Mode" org-agenda-follow-mode
2276 :style toggle :selected org-agenda-follow-mode :active t]
2277 ;; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
2278 "--"
2279 ("TODO"
2280 ["Cycle TODO" org-agenda-todo t]
2281 ["Next TODO set" org-agenda-todo-nextset t]
2282 ["Previous TODO set" org-agenda-todo-previousset t]
2283 ["Add note" org-agenda-add-note t])
2284 ("Archive/Refile/Delete"
2285 ["Archive default" org-agenda-archive-default t]
2286 ["Archive default" org-agenda-archive-default-with-confirmation t]
2287 ["Toggle ARCHIVE tag" org-agenda-toggle-archive-tag t]
2288 ["Move to archive sibling" org-agenda-archive-to-archive-sibling t]
2289 ["Archive subtree" org-agenda-archive t]
2290 "--"
2291 ["Refile" org-agenda-refile t]
2292 "--"
2293 ["Delete subtree" org-agenda-kill t])
2294 ("Bulk action"
2295 ["Mark entry" org-agenda-bulk-mark t]
2296 ["Mark all" org-agenda-bulk-mark-all t]
2297 ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
2298 ["Unmark entry" org-agenda-bulk-unmark t]
2299 ["Unmark all entries" org-agenda-bulk-unmark-all :active t :keys "U"])
2300 ["Act on all marked" org-agenda-bulk-action t]
2301 "--"
2302 ("Tags and Properties"
2303 ["Show all Tags" org-agenda-show-tags t]
2304 ["Set Tags current line" org-agenda-set-tags (not (org-region-active-p))]
2305 ["Change tag in region" org-agenda-set-tags (org-region-active-p)]
2306 "--"
2307 ["Column View" org-columns t])
2308 ("Deadline/Schedule"
2309 ["Schedule" org-agenda-schedule t]
2310 ["Set Deadline" org-agenda-deadline t]
2311 "--"
2312 ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
2313 ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
2314 ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
2315 ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
2316 ["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
2317 ["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
2318 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
2319 ("Clock and Effort"
2320 ["Clock in" org-agenda-clock-in t]
2321 ["Clock out" org-agenda-clock-out t]
2322 ["Clock cancel" org-agenda-clock-cancel t]
2323 ["Goto running clock" org-clock-goto t]
2324 "--"
2325 ["Set Effort" org-agenda-set-effort t]
2326 ["Change clocked effort" org-clock-modify-effort-estimate
2327 (org-clock-is-active)])
2328 ("Priority"
2329 ["Set Priority" org-agenda-priority t]
2330 ["Increase Priority" org-agenda-priority-up t]
2331 ["Decrease Priority" org-agenda-priority-down t]
2332 ["Show Priority" org-show-priority t])
2333 ("Calendar/Diary"
2334 ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
2335 ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
2336 ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
2337 ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
2338 ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
2339 ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
2340 "--"
2341 ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
2342 "--"
2343 ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
2344 "--"
2345 ("MobileOrg"
2346 ["Push Files and Views" org-mobile-push t]
2347 ["Get Captured and Flagged" org-mobile-pull t]
2348 ["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"]
2349 ["Show note / unflag" org-agenda-show-the-flagging-note t]
2350 "--"
2351 ["Setup" (progn (require 'org-mobile) (customize-group 'org-mobile)) t])
2352 "--"
2353 ["Quit" org-agenda-quit t]
2354 ["Exit and Release Buffers" org-agenda-exit t]
2357 ;;; Agenda undo
2359 (defvar org-agenda-allow-remote-undo t
2360 "Non-nil means allow remote undo from the agenda buffer.")
2361 (defvar org-agenda-undo-has-started-in nil
2362 "Buffers that have already seen `undo-start' in the current undo sequence.")
2364 (defun org-agenda-undo ()
2365 "Undo a remote editing step in the agenda.
2366 This undoes changes both in the agenda buffer and in the remote buffer
2367 that have been changed along."
2368 (interactive)
2369 (or org-agenda-allow-remote-undo
2370 (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
2371 (if (not (eq this-command last-command))
2372 (setq org-agenda-undo-has-started-in nil
2373 org-agenda-pending-undo-list org-agenda-undo-list))
2374 (if (not org-agenda-pending-undo-list)
2375 (error "No further undo information"))
2376 (let* ((entry (pop org-agenda-pending-undo-list))
2377 buf line cmd rembuf)
2378 (setq cmd (pop entry) line (pop entry))
2379 (setq rembuf (nth 2 entry))
2380 (org-with-remote-undo rembuf
2381 (while (bufferp (setq buf (pop entry)))
2382 (if (pop entry)
2383 (with-current-buffer buf
2384 (let ((last-undo-buffer buf)
2385 (inhibit-read-only t))
2386 (unless (memq buf org-agenda-undo-has-started-in)
2387 (push buf org-agenda-undo-has-started-in)
2388 (make-local-variable 'pending-undo-list)
2389 (undo-start))
2390 (while (and pending-undo-list
2391 (listp pending-undo-list)
2392 (not (car pending-undo-list)))
2393 (pop pending-undo-list))
2394 (undo-more 1))))))
2395 (org-goto-line line)
2396 (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))
2398 (defun org-verify-change-for-undo (l1 l2)
2399 "Verify that a real change occurred between the undo lists L1 and L2."
2400 (while (and l1 (listp l1) (null (car l1))) (pop l1))
2401 (while (and l2 (listp l2) (null (car l2))) (pop l2))
2402 (not (eq l1 l2)))
2404 ;;; Agenda dispatch
2406 (defvar org-agenda-restrict-begin (make-marker))
2407 (defvar org-agenda-restrict-end (make-marker))
2408 (defvar org-agenda-last-dispatch-buffer nil)
2409 (defvar org-agenda-overriding-restriction nil)
2411 (defcustom org-agenda-custom-commands-contexts nil
2412 "Alist of custom agenda keys and contextual rules.
2414 For example, if you have a custom agenda command \"p\" and you
2415 want this command to be accessible only from plain text files,
2416 use this:
2418 '((\"p\" ((in-file . \"\\.txt\"))))
2420 Here are the available contexts definitions:
2422 in-file: command displayed only in matching files
2423 in-mode: command displayed only in matching modes
2424 not-in-file: command not displayed in matching files
2425 not-in-mode: command not displayed in matching modes
2426 in-buffer: command displayed only in matching buffers
2427 not-in-buffer: command not displayed in matching buffers
2428 [function]: a custom function taking no argument
2430 If you define several checks, the agenda command will be
2431 accessible if there is at least one valid check.
2433 You can also bind a key to another agenda custom command
2434 depending on contextual rules.
2436 '((\"p\" \"q\" ((in-file . \"\\.txt\"))))
2438 Here it means: in .txt files, use \"p\" as the key for the
2439 agenda command otherwise associated with \"q\". (The command
2440 originally associated with \"q\" is not displayed to avoid
2441 duplicates.)"
2442 :version "24.3"
2443 :group 'org-agenda-custom-commands
2444 :type '(repeat (list :tag "Rule"
2445 (string :tag " Agenda key")
2446 (string :tag "Replace by command")
2447 (repeat :tag "Available when"
2448 (choice
2449 (cons :tag "Condition"
2450 (choice
2451 (const :tag "In file" in-file)
2452 (const :tag "Not in file" not-in-file)
2453 (const :tag "In buffer" in-buffer)
2454 (const :tag "Not in buffer" not-in-buffer)
2455 (const :tag "In mode" in-mode)
2456 (const :tag "Not in mode" not-in-mode))
2457 (regexp))
2458 (function :tag "Custom function"))))))
2460 (defvar org-keys nil)
2461 (defvar org-match nil)
2462 ;;;###autoload
2463 (defun org-agenda (&optional arg org-keys restriction)
2464 "Dispatch agenda commands to collect entries to the agenda buffer.
2465 Prompts for a command to execute. Any prefix arg will be passed
2466 on to the selected command. The default selections are:
2468 a Call `org-agenda-list' to display the agenda for current day or week.
2469 t Call `org-todo-list' to display the global todo list.
2470 T Call `org-todo-list' to display the global todo list, select only
2471 entries with a specific TODO keyword (the user gets a prompt).
2472 m Call `org-tags-view' to display headlines with tags matching
2473 a condition (the user is prompted for the condition).
2474 M Like `m', but select only TODO entries, no ordinary headlines.
2475 L Create a timeline for the current buffer.
2476 e Export views to associated files.
2477 s Search entries for keywords.
2478 S Search entries for keywords, only with TODO keywords.
2479 / Multi occur across all agenda files and also files listed
2480 in `org-agenda-text-search-extra-files'.
2481 < Restrict agenda commands to buffer, subtree, or region.
2482 Press several times to get the desired effect.
2483 > Remove a previous restriction.
2484 # List \"stuck\" projects.
2485 ! Configure what \"stuck\" means.
2486 C Configure custom agenda commands.
2488 More commands can be added by configuring the variable
2489 `org-agenda-custom-commands'. In particular, specific tags and TODO keyword
2490 searches can be pre-defined in this way.
2492 If the current buffer is in Org-mode and visiting a file, you can also
2493 first press `<' once to indicate that the agenda should be temporarily
2494 \(until the next use of \\[org-agenda]) restricted to the current file.
2495 Pressing `<' twice means to restrict to the current subtree or region
2496 \(if active)."
2497 (interactive "P")
2498 (catch 'exit
2499 (let* ((prefix-descriptions nil)
2500 (org-agenda-buffer-name org-agenda-buffer-name)
2501 (org-agenda-window-setup (if (equal (buffer-name)
2502 org-agenda-buffer-name)
2503 'current-window
2504 org-agenda-window-setup))
2505 (org-agenda-custom-commands-orig org-agenda-custom-commands)
2506 (org-agenda-custom-commands
2507 ;; normalize different versions
2508 (delq nil
2509 (mapcar
2510 (lambda (x)
2511 (cond ((stringp (cdr x))
2512 (push x prefix-descriptions)
2513 nil)
2514 ((stringp (nth 1 x)) x)
2515 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2516 (t (cons (car x) (cons "" (cdr x))))))
2517 org-agenda-custom-commands)))
2518 (org-agenda-custom-commands
2519 (org-contextualize-keys
2520 org-agenda-custom-commands org-agenda-custom-commands-contexts))
2521 (buf (current-buffer))
2522 (bfn (buffer-file-name (buffer-base-buffer)))
2523 entry key type org-match lprops ans)
2524 ;; Turn off restriction unless there is an overriding one,
2525 (unless org-agenda-overriding-restriction
2526 (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
2527 ;; There is a request to keep the file list in place
2528 (put 'org-agenda-files 'org-restrict nil))
2529 (setq org-agenda-restrict nil)
2530 (move-marker org-agenda-restrict-begin nil)
2531 (move-marker org-agenda-restrict-end nil))
2532 ;; Delete old local properties
2533 (put 'org-agenda-redo-command 'org-lprops nil)
2534 ;; Delete previously set last-arguments
2535 (put 'org-agenda-redo-command 'last-args nil)
2536 ;; Remember where this call originated
2537 (setq org-agenda-last-dispatch-buffer (current-buffer))
2538 (unless org-keys
2539 (setq ans (org-agenda-get-restriction-and-command prefix-descriptions)
2540 org-keys (car ans)
2541 restriction (cdr ans)))
2542 ;; If we have sticky agenda buffers, set a name for the buffer,
2543 ;; depending on the invoking keys. The user may still set this
2544 ;; as a command option, which will overwrite what we do here.
2545 (if org-agenda-sticky
2546 (setq org-agenda-buffer-name
2547 (format "*Org Agenda(%s)*" org-keys)))
2548 ;; Establish the restriction, if any
2549 (when (and (not org-agenda-overriding-restriction) restriction)
2550 (put 'org-agenda-files 'org-restrict (list bfn))
2551 (cond
2552 ((eq restriction 'region)
2553 (setq org-agenda-restrict t)
2554 (move-marker org-agenda-restrict-begin (region-beginning))
2555 (move-marker org-agenda-restrict-end (region-end)))
2556 ((eq restriction 'subtree)
2557 (save-excursion
2558 (setq org-agenda-restrict t)
2559 (org-back-to-heading t)
2560 (move-marker org-agenda-restrict-begin (point))
2561 (move-marker org-agenda-restrict-end
2562 (progn (org-end-of-subtree t)))))))
2564 ;; For example the todo list should not need it (but does...)
2565 (cond
2566 ((setq entry (assoc org-keys org-agenda-custom-commands))
2567 (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry)))
2568 (progn
2569 (setq type (nth 2 entry) org-match (eval (nth 3 entry))
2570 lprops (nth 4 entry))
2571 (if org-agenda-sticky
2572 (setq org-agenda-buffer-name
2573 (or (and (stringp org-match) (format "*Org Agenda(%s:%s)*" org-keys org-match))
2574 (format "*Org Agenda(%s)*" org-keys))))
2575 (put 'org-agenda-redo-command 'org-lprops lprops)
2576 (cond
2577 ((eq type 'agenda)
2578 (org-let lprops '(org-agenda-list current-prefix-arg)))
2579 ((eq type 'alltodo)
2580 (org-let lprops '(org-todo-list current-prefix-arg)))
2581 ((eq type 'search)
2582 (org-let lprops '(org-search-view current-prefix-arg org-match nil)))
2583 ((eq type 'stuck)
2584 (org-let lprops '(org-agenda-list-stuck-projects
2585 current-prefix-arg)))
2586 ((eq type 'tags)
2587 (org-let lprops '(org-tags-view current-prefix-arg org-match)))
2588 ((eq type 'tags-todo)
2589 (org-let lprops '(org-tags-view '(4) org-match)))
2590 ((eq type 'todo)
2591 (org-let lprops '(org-todo-list org-match)))
2592 ((eq type 'tags-tree)
2593 (org-check-for-org-mode)
2594 (org-let lprops '(org-match-sparse-tree current-prefix-arg org-match)))
2595 ((eq type 'todo-tree)
2596 (org-check-for-org-mode)
2597 (org-let lprops
2598 '(org-occur (concat "^" org-outline-regexp "[ \t]*"
2599 (regexp-quote org-match) "\\>"))))
2600 ((eq type 'occur-tree)
2601 (org-check-for-org-mode)
2602 (org-let lprops '(org-occur org-match)))
2603 ((functionp type)
2604 (org-let lprops '(funcall type org-match)))
2605 ((fboundp type)
2606 (org-let lprops '(funcall type org-match)))
2607 (t (error "Invalid custom agenda command type %s" type))))
2608 (org-agenda-run-series (nth 1 entry) (cddr entry))))
2609 ((equal org-keys "C")
2610 (setq org-agenda-custom-commands org-agenda-custom-commands-orig)
2611 (customize-variable 'org-agenda-custom-commands))
2612 ((equal org-keys "a") (call-interactively 'org-agenda-list))
2613 ((equal org-keys "s") (call-interactively 'org-search-view))
2614 ((equal org-keys "S") (org-call-with-arg 'org-search-view (or arg '(4))))
2615 ((equal org-keys "t") (call-interactively 'org-todo-list))
2616 ((equal org-keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))
2617 ((equal org-keys "m") (call-interactively 'org-tags-view))
2618 ((equal org-keys "M") (org-call-with-arg 'org-tags-view (or arg '(4))))
2619 ((equal org-keys "e") (call-interactively 'org-store-agenda-views))
2620 ((equal org-keys "?") (org-tags-view nil "+FLAGGED")
2621 (org-add-hook
2622 'post-command-hook
2623 (lambda ()
2624 (unless (current-message)
2625 (let* ((m (org-agenda-get-any-marker))
2626 (note (and m (org-entry-get m "THEFLAGGINGNOTE"))))
2627 (when note
2628 (message (concat
2629 "FLAGGING-NOTE ([?] for more info): "
2630 (org-add-props
2631 (replace-regexp-in-string
2632 "\\\\n" "//"
2633 (copy-sequence note))
2634 nil 'face 'org-warning)))))))
2635 t t))
2636 ((equal org-keys "L")
2637 (unless (derived-mode-p 'org-mode)
2638 (error "This is not an Org-mode file"))
2639 (unless restriction
2640 (put 'org-agenda-files 'org-restrict (list bfn))
2641 (org-call-with-arg 'org-timeline arg)))
2642 ((equal org-keys "#") (call-interactively 'org-agenda-list-stuck-projects))
2643 ((equal org-keys "/") (call-interactively 'org-occur-in-agenda-files))
2644 ((equal org-keys "!") (customize-variable 'org-stuck-projects))
2645 (t (error "Invalid agenda key"))))))
2647 (autoload 'org-agenda "org-agenda" "\
2648 Dispatch agenda commands to collect entries to the agenda buffer.
2649 Prompts for a command to execute. Any prefix arg will be passed
2650 on to the selected command. The default selections are:
2652 a Call `org-agenda-list' to display the agenda for current day or week.
2653 t Call `org-todo-list' to display the global todo list.
2654 T Call `org-todo-list' to display the global todo list, select only
2655 entries with a specific TODO keyword (the user gets a prompt).
2656 m Call `org-tags-view' to display headlines with tags matching
2657 a condition (the user is prompted for the condition).
2658 M Like `m', but select only TODO entries, no ordinary headlines.
2659 L Create a timeline for the current buffer.
2660 e Export views to associated files.
2661 s Search entries for keywords.
2662 S Search entries for keywords, only with TODO keywords.
2663 / Multi occur across all agenda files and also files listed
2664 in `org-agenda-text-search-extra-files'.
2665 < Restrict agenda commands to buffer, subtree, or region.
2666 Press several times to get the desired effect.
2667 > Remove a previous restriction.
2668 # List \"stuck\" projects.
2669 ! Configure what \"stuck\" means.
2670 C Configure custom agenda commands.
2672 More commands can be added by configuring the variable
2673 `org-agenda-custom-commands'. In particular, specific tags and TODO keyword
2674 searches can be pre-defined in this way.
2676 If the current buffer is in Org-mode and visiting a file, you can also
2677 first press `<' once to indicate that the agenda should be temporarily
2678 \(until the next use of \\[org-agenda]) restricted to the current file.
2679 Pressing `<' twice means to restrict to the current subtree or region
2680 \(if active).
2682 \(fn &optional ARG ORG-KEYS RESTRICTION)" t nil)
2684 (defun org-agenda-append-agenda ()
2685 "Append another agenda view to the current one.
2686 This function allows interactive building of block agendas.
2687 Agenda views are separated by `org-agenda-block-separator'."
2688 (interactive)
2689 (unless (derived-mode-p 'org-agenda-mode)
2690 (error "Can only append from within agenda buffer"))
2691 (let ((org-agenda-multi t))
2692 (org-agenda)
2693 (widen)
2694 (org-agenda-finalize)
2695 (org-agenda-fit-window-to-buffer)))
2697 (defun org-agenda-normalize-custom-commands (cmds)
2698 (delq nil
2699 (mapcar
2700 (lambda (x)
2701 (cond ((stringp (cdr x)) nil)
2702 ((stringp (nth 1 x)) x)
2703 ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
2704 (t (cons (car x) (cons "" (cdr x))))))
2705 cmds)))
2707 (defun org-agenda-get-restriction-and-command (prefix-descriptions)
2708 "The user interface for selecting an agenda command."
2709 (catch 'exit
2710 (let* ((bfn (buffer-file-name (buffer-base-buffer)))
2711 (restrict-ok (and bfn (derived-mode-p 'org-mode)))
2712 (region-p (org-region-active-p))
2713 (custom org-agenda-custom-commands)
2714 (selstring "")
2715 restriction second-time
2716 c entry key type match prefixes rmheader header-end custom1 desc
2717 line lines left right n n1)
2718 (save-window-excursion
2719 (delete-other-windows)
2720 (org-switch-to-buffer-other-window " *Agenda Commands*")
2721 (erase-buffer)
2722 (insert (eval-when-compile
2723 (let ((header
2724 "Press key for an agenda command: < Buffer, subtree/region restriction
2725 -------------------------------- > Remove restriction
2726 a Agenda for current week or day e Export agenda views
2727 t List of all TODO entries T Entries with special TODO kwd
2728 m Match a TAGS/PROP/TODO query M Like m, but only TODO entries
2729 s Search for keywords S Like s, but only TODO entries
2730 L Timeline for current buffer # List stuck projects (!=configure)
2731 / Multi-occur C Configure custom agenda commands
2732 ? Find :FLAGGED: entries * Toggle sticky agenda views
2734 (start 0))
2735 (while (string-match
2736 "\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)"
2737 header start)
2738 (setq start (match-end 0))
2739 (add-text-properties (match-beginning 2) (match-end 2)
2740 '(face bold) header))
2741 header)))
2742 (setq header-end (point-marker))
2743 (while t
2744 (setq custom1 custom)
2745 (when (eq rmheader t)
2746 (org-goto-line 1)
2747 (re-search-forward ":" nil t)
2748 (delete-region (match-end 0) (point-at-eol))
2749 (forward-char 1)
2750 (looking-at "-+")
2751 (delete-region (match-end 0) (point-at-eol))
2752 (move-marker header-end (match-end 0)))
2753 (goto-char header-end)
2754 (delete-region (point) (point-max))
2756 ;; Produce all the lines that describe custom commands and prefixes
2757 (setq lines nil)
2758 (while (setq entry (pop custom1))
2759 (setq key (car entry) desc (nth 1 entry)
2760 type (nth 2 entry)
2761 match (nth 3 entry))
2762 (if (> (length key) 1)
2763 (add-to-list 'prefixes (string-to-char key))
2764 (setq line
2765 (format
2766 "%-4s%-14s"
2767 (org-add-props (copy-sequence key)
2768 '(face bold))
2769 (cond
2770 ((string-match "\\S-" desc) desc)
2771 ((eq type 'agenda) "Agenda for current week or day")
2772 ((eq type 'alltodo) "List of all TODO entries")
2773 ((eq type 'search) "Word search")
2774 ((eq type 'stuck) "List of stuck projects")
2775 ((eq type 'todo) "TODO keyword")
2776 ((eq type 'tags) "Tags query")
2777 ((eq type 'tags-todo) "Tags (TODO)")
2778 ((eq type 'tags-tree) "Tags tree")
2779 ((eq type 'todo-tree) "TODO kwd tree")
2780 ((eq type 'occur-tree) "Occur tree")
2781 ((functionp type) (if (symbolp type)
2782 (symbol-name type)
2783 "Lambda expression"))
2784 (t "???"))))
2785 (if org-agenda-menu-show-matcher
2786 (setq line
2787 (concat line ": "
2788 (cond
2789 ((stringp match)
2790 (setq match (copy-sequence match))
2791 (org-add-props match nil 'face 'org-warning))
2792 ((listp type)
2793 (format "set of %d commands" (length type))))))
2794 (if (org-string-nw-p match)
2795 (add-text-properties
2796 0 (length line) (list 'help-echo
2797 (concat "Matcher: " match)) line)))
2798 (push line lines)))
2799 (setq lines (nreverse lines))
2800 (when prefixes
2801 (mapc (lambda (x)
2802 (push
2803 (format "%s %s"
2804 (org-add-props (char-to-string x)
2805 nil 'face 'bold)
2806 (or (cdr (assoc (concat selstring
2807 (char-to-string x))
2808 prefix-descriptions))
2809 "Prefix key"))
2810 lines))
2811 prefixes))
2813 ;; Check if we should display in two columns
2814 (if org-agenda-menu-two-columns
2815 (progn
2816 (setq n (length lines)
2817 n1 (+ (/ n 2) (mod n 2))
2818 right (nthcdr n1 lines)
2819 left (copy-sequence lines))
2820 (setcdr (nthcdr (1- n1) left) nil))
2821 (setq left lines right nil))
2822 (while left
2823 (insert "\n" (pop left))
2824 (when right
2825 (if (< (current-column) 40)
2826 (move-to-column 40 t)
2827 (insert " "))
2828 (insert (pop right))))
2830 ;; Make the window the right size
2831 (goto-char (point-min))
2832 (if second-time
2833 (if (not (pos-visible-in-window-p (point-max)))
2834 (org-fit-window-to-buffer))
2835 (setq second-time t)
2836 (org-fit-window-to-buffer))
2838 ;; Ask for selection
2839 (message "Press key for agenda command%s:"
2840 (if (or restrict-ok org-agenda-overriding-restriction)
2841 (if org-agenda-overriding-restriction
2842 " (restriction lock active)"
2843 (if restriction
2844 (format " (restricted to %s)" restriction)
2845 " (unrestricted)"))
2846 ""))
2847 (setq c (read-char-exclusive))
2848 (message "")
2849 (cond
2850 ((assoc (char-to-string c) custom)
2851 (setq selstring (concat selstring (char-to-string c)))
2852 (throw 'exit (cons selstring restriction)))
2853 ((memq c prefixes)
2854 (setq selstring (concat selstring (char-to-string c))
2855 prefixes nil
2856 rmheader (or rmheader t)
2857 custom (delq nil (mapcar
2858 (lambda (x)
2859 (if (or (= (length (car x)) 1)
2860 (/= (string-to-char (car x)) c))
2862 (cons (substring (car x) 1) (cdr x))))
2863 custom))))
2864 ((eq c ?*)
2865 (call-interactively 'org-toggle-sticky-agenda)
2866 (sit-for 2))
2867 ((and (not restrict-ok) (memq c '(?1 ?0 ?<)))
2868 (message "Restriction is only possible in Org-mode buffers")
2869 (ding) (sit-for 1))
2870 ((eq c ?1)
2871 (org-agenda-remove-restriction-lock 'noupdate)
2872 (setq restriction 'buffer))
2873 ((eq c ?0)
2874 (org-agenda-remove-restriction-lock 'noupdate)
2875 (setq restriction (if region-p 'region 'subtree)))
2876 ((eq c ?<)
2877 (org-agenda-remove-restriction-lock 'noupdate)
2878 (setq restriction
2879 (cond
2880 ((eq restriction 'buffer)
2881 (if region-p 'region 'subtree))
2882 ((memq restriction '(subtree region))
2883 nil)
2884 (t 'buffer))))
2885 ((eq c ?>)
2886 (org-agenda-remove-restriction-lock 'noupdate)
2887 (setq restriction nil))
2888 ((and (equal selstring "") (memq c '(?s ?S ?a ?t ?m ?L ?C ?e ?T ?M ?# ?! ?/ ??)))
2889 (throw 'exit (cons (setq selstring (char-to-string c)) restriction)))
2890 ((and (> (length selstring) 0) (eq c ?\d))
2891 (delete-window)
2892 (org-agenda-get-restriction-and-command prefix-descriptions))
2894 ((equal c ?q) (error "Abort"))
2895 (t (error "Invalid key %c" c))))))))
2897 (defun org-agenda-fit-window-to-buffer ()
2898 "Fit the window to the buffer size."
2899 (and (memq org-agenda-window-setup '(reorganize-frame))
2900 (fboundp 'fit-window-to-buffer)
2901 (org-fit-window-to-buffer
2903 (floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
2904 (floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
2906 (defvar org-cmd nil)
2907 (defvar org-agenda-overriding-cmd nil)
2908 (defvar org-agenda-overriding-arguments nil)
2909 (defvar org-agenda-overriding-cmd-arguments nil)
2910 (defun org-agenda-run-series (name series)
2911 (org-let (nth 1 series) '(org-agenda-prepare name))
2912 ;; We need to reset agenda markers here, because when constructing a
2913 ;; block agenda, the individual blocks do not do that.
2914 (org-agenda-reset-markers)
2915 (let* ((org-agenda-multi t)
2916 (redo (list 'org-agenda-run-series name (list 'quote series)))
2917 (cmds (car series))
2918 (gprops (nth 1 series))
2919 match ;; The byte compiler incorrectly complains about this. Keep it!
2920 org-cmd type lprops)
2921 (while (setq org-cmd (pop cmds))
2922 (setq type (car org-cmd)
2923 match (eval (nth 1 org-cmd))
2924 lprops (nth 2 org-cmd))
2925 (let ((org-agenda-overriding-arguments
2926 (if (eq org-agenda-overriding-cmd org-cmd)
2927 (or org-agenda-overriding-arguments
2928 org-agenda-overriding-cmd-arguments))))
2929 (cond
2930 ((eq type 'agenda)
2931 (org-let2 gprops lprops
2932 '(call-interactively 'org-agenda-list)))
2933 ((eq type 'alltodo)
2934 (org-let2 gprops lprops
2935 '(call-interactively 'org-todo-list)))
2936 ((eq type 'search)
2937 (org-let2 gprops lprops
2938 '(org-search-view current-prefix-arg match nil)))
2939 ((eq type 'stuck)
2940 (org-let2 gprops lprops
2941 '(call-interactively 'org-agenda-list-stuck-projects)))
2942 ((eq type 'tags)
2943 (org-let2 gprops lprops
2944 '(org-tags-view current-prefix-arg match)))
2945 ((eq type 'tags-todo)
2946 (org-let2 gprops lprops
2947 '(org-tags-view '(4) match)))
2948 ((eq type 'todo)
2949 (org-let2 gprops lprops
2950 '(org-todo-list match)))
2951 ((fboundp type)
2952 (org-let2 gprops lprops
2953 '(funcall type match)))
2954 (t (error "Invalid type in command series")))))
2955 (widen)
2956 (let ((inhibit-read-only t))
2957 (add-text-properties (point-min) (point-max)
2958 `(org-series t org-series-redo-cmd ,redo)))
2959 (setq org-agenda-redo-command redo)
2960 (goto-char (point-min)))
2961 (org-agenda-fit-window-to-buffer)
2962 (org-let (nth 1 series) '(org-agenda-finalize)))
2964 ;;;###autoload
2965 (defmacro org-batch-agenda (cmd-key &rest parameters)
2966 "Run an agenda command in batch mode and send the result to STDOUT.
2967 If CMD-KEY is a string of length 1, it is used as a key in
2968 `org-agenda-custom-commands' and triggers this command. If it is a
2969 longer string it is used as a tags/todo match string.
2970 Parameters are alternating variable names and values that will be bound
2971 before running the agenda command."
2972 (org-eval-in-environment (org-make-parameter-alist parameters)
2973 (if (> (length cmd-key) 2)
2974 (org-tags-view nil cmd-key)
2975 (org-agenda nil cmd-key)))
2976 (set-buffer org-agenda-buffer-name)
2977 (princ (buffer-string)))
2979 (autoload 'org-batch-agenda "org-agenda" "\
2980 Run an agenda command in batch mode and send the result to STDOUT.
2981 If CMD-KEY is a string of length 1, it is used as a key in
2982 `org-agenda-custom-commands' and triggers this command. If it is a
2983 longer string it is used as a tags/todo match string.
2984 Parameters are alternating variable names and values that will be bound
2985 before running the agenda command.
2987 \(fn CMD-KEY &rest PARAMETERS)" nil t)
2988 (def-edebug-spec org-batch-agenda (form &rest sexp))
2990 (defvar org-agenda-info nil)
2992 ;;;###autoload
2993 (defmacro org-batch-agenda-csv (cmd-key &rest parameters)
2994 "Run an agenda command in batch mode and send the result to STDOUT.
2995 If CMD-KEY is a string of length 1, it is used as a key in
2996 `org-agenda-custom-commands' and triggers this command. If it is a
2997 longer string it is used as a tags/todo match string.
2998 Parameters are alternating variable names and values that will be bound
2999 before running the agenda command.
3001 The output gives a line for each selected agenda item. Each
3002 item is a list of comma-separated values, like this:
3004 category,head,type,todo,tags,date,time,extra,priority-l,priority-n
3006 category The category of the item
3007 head The headline, without TODO kwd, TAGS and PRIORITY
3008 type The type of the agenda entry, can be
3009 todo selected in TODO match
3010 tagsmatch selected in tags match
3011 diary imported from diary
3012 deadline a deadline on given date
3013 scheduled scheduled on given date
3014 timestamp entry has timestamp on given date
3015 closed entry was closed on given date
3016 upcoming-deadline warning about deadline
3017 past-scheduled forwarded scheduled item
3018 block entry has date block including g. date
3019 todo The todo keyword, if any
3020 tags All tags including inherited ones, separated by colons
3021 date The relevant date, like 2007-2-14
3022 time The time, like 15:00-16:50
3023 extra Sting with extra planning info
3024 priority-l The priority letter if any was given
3025 priority-n The computed numerical priority
3026 agenda-day The day in the agenda where this is listed"
3027 (org-eval-in-environment (append '((org-agenda-remove-tags t))
3028 (org-make-parameter-alist parameters))
3029 (if (> (length cmd-key) 2)
3030 (org-tags-view nil cmd-key)
3031 (org-agenda nil cmd-key)))
3032 (set-buffer org-agenda-buffer-name)
3033 (let* ((lines (org-split-string (buffer-string) "\n"))
3034 line)
3035 (while (setq line (pop lines))
3036 (catch 'next
3037 (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
3038 (setq org-agenda-info
3039 (org-fix-agenda-info (text-properties-at 0 line)))
3040 (princ
3041 (mapconcat 'org-agenda-export-csv-mapper
3042 '(org-category txt type todo tags date time extra
3043 priority-letter priority agenda-day)
3044 ","))
3045 (princ "\n")))))
3047 (autoload 'org-batch-agenda-csv "org-agenda" "\
3048 Run an agenda command in batch mode and send the result to STDOUT.
3049 If CMD-KEY is a string of length 1, it is used as a key in
3050 `org-agenda-custom-commands' and triggers this command. If it is a
3051 longer string it is used as a tags/todo match string.
3052 Parameters are alternating variable names and values that will be bound
3053 before running the agenda command.
3055 The output gives a line for each selected agenda item. Each
3056 item is a list of comma-separated values, like this:
3058 category,head,type,todo,tags,date,time,extra,priority-l,priority-n
3060 category The category of the item
3061 head The headline, without TODO kwd, TAGS and PRIORITY
3062 type The type of the agenda entry, can be
3063 todo selected in TODO match
3064 tagsmatch selected in tags match
3065 diary imported from diary
3066 deadline a deadline on given date
3067 scheduled scheduled on given date
3068 timestamp entry has timestamp on given date
3069 closed entry was closed on given date
3070 upcoming-deadline warning about deadline
3071 past-scheduled forwarded scheduled item
3072 block entry has date block including g. date
3073 todo The todo keyword, if any
3074 tags All tags including inherited ones, separated by colons
3075 date The relevant date, like 2007-2-14
3076 time The time, like 15:00-16:50
3077 extra Sting with extra planning info
3078 priority-l The priority letter if any was given
3079 priority-n The computed numerical priority
3080 agenda-day The day in the agenda where this is listed
3082 \(fn CMD-KEY &rest PARAMETERS)" nil t)
3083 (def-edebug-spec org-batch-agenda-csv (form &rest sexp))
3085 (defun org-fix-agenda-info (props)
3086 "Make sure all properties on an agenda item have a canonical form.
3087 This ensures the export commands can easily use it."
3088 (let (tmp re)
3089 (when (setq tmp (plist-get props 'tags))
3090 (setq props (plist-put props 'tags (mapconcat 'identity tmp ":"))))
3091 (when (setq tmp (plist-get props 'date))
3092 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
3093 (let ((calendar-date-display-form '(year "-" month "-" day)))
3094 '((format "%4d, %9s %2s, %4s" dayname monthname day year))
3096 (setq tmp (calendar-date-string tmp)))
3097 (setq props (plist-put props 'date tmp)))
3098 (when (setq tmp (plist-get props 'day))
3099 (if (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
3100 (let ((calendar-date-display-form '(year "-" month "-" day)))
3101 (setq tmp (calendar-date-string tmp)))
3102 (setq props (plist-put props 'day tmp))
3103 (setq props (plist-put props 'agenda-day tmp)))
3104 (when (setq tmp (plist-get props 'txt))
3105 (when (string-match "\\[#\\([A-Z0-9]\\)\\] ?" tmp)
3106 (plist-put props 'priority-letter (match-string 1 tmp))
3107 (setq tmp (replace-match "" t t tmp)))
3108 (when (and (setq re (plist-get props 'org-todo-regexp))
3109 (setq re (concat "\\`\\.*" re " ?"))
3110 (string-match re tmp))
3111 (plist-put props 'todo (match-string 1 tmp))
3112 (setq tmp (replace-match "" t t tmp)))
3113 (plist-put props 'txt tmp)))
3114 props)
3116 (defun org-agenda-export-csv-mapper (prop)
3117 (let ((res (plist-get org-agenda-info prop)))
3118 (setq res
3119 (cond
3120 ((not res) "")
3121 ((stringp res) res)
3122 (t (prin1-to-string res))))
3123 (while (string-match "," res)
3124 (setq res (replace-match ";" t t res)))
3125 (org-trim res)))
3127 ;;;###autoload
3128 (defun org-store-agenda-views (&rest parameters)
3129 (interactive)
3130 (eval (list 'org-batch-store-agenda-views)))
3132 (autoload 'org-store-agenda-views "org-agenda" "\
3135 \(fn &rest PARAMETERS)" t nil)
3137 ;;;###autoload
3138 (defmacro org-batch-store-agenda-views (&rest parameters)
3139 "Run all custom agenda commands that have a file argument."
3140 (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
3141 (pop-up-frames nil)
3142 (dir default-directory)
3143 (pars (org-make-parameter-alist parameters))
3144 cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
3145 (save-window-excursion
3146 (while cmds
3147 (setq cmd (pop cmds)
3148 thiscmdkey (car cmd)
3149 thiscmdcmd (cdr cmd)
3150 match (nth 2 thiscmdcmd)
3151 bufname (if org-agenda-sticky
3152 (or (and (stringp match)
3153 (format "*Org Agenda(%s:%s)*" thiscmdkey match))
3154 (format "*Org Agenda(%s)*" thiscmdkey))
3155 org-agenda-buffer-name)
3156 cmd-or-set (nth 2 cmd)
3157 opts (nth (if (listp cmd-or-set) 3 4) cmd)
3158 files (nth (if (listp cmd-or-set) 4 5) cmd))
3159 (if (stringp files) (setq files (list files)))
3160 (when files
3161 (org-eval-in-environment (append org-agenda-exporter-settings
3162 opts pars)
3163 (org-agenda nil thiscmdkey))
3164 (set-buffer bufname)
3165 (while files
3166 (org-eval-in-environment (append org-agenda-exporter-settings
3167 opts pars)
3168 (org-agenda-write (expand-file-name (pop files) dir) nil t bufname)))
3169 (and (get-buffer bufname)
3170 (kill-buffer bufname)))))))
3172 (autoload 'org-batch-store-agenda-views "org-agenda" "\
3173 Run all custom agenda commands that have a file argument.
3175 \(fn &rest PARAMETERS)" nil t)
3176 (def-edebug-spec org-batch-store-agenda-views (&rest sexp))
3178 (defvar org-agenda-current-span nil
3179 "The current span used in the agenda view.") ; local variable in the agenda buffer
3180 (defun org-agenda-mark-header-line (pos)
3181 "Mark the line at POS as an agenda structure header."
3182 (save-excursion
3183 (goto-char pos)
3184 (put-text-property (point-at-bol) (point-at-eol)
3185 'org-agenda-structural-header t)
3186 (when org-agenda-title-append
3187 (put-text-property (point-at-bol) (point-at-eol)
3188 'org-agenda-title-append org-agenda-title-append))))
3190 (defvar org-mobile-creating-agendas) ; defined in org-mobile.el
3191 (defvar org-agenda-write-buffer-name "Agenda View")
3192 (defun org-agenda-write (file &optional open nosettings agenda-bufname)
3193 "Write the current buffer (an agenda view) as a file.
3194 Depending on the extension of the file name, plain text (.txt),
3195 HTML (.html or .htm) or Postscript (.ps) is produced.
3196 If the extension is .ics, run icalendar export over all files used
3197 to construct the agenda and limit the export to entries listed in the
3198 agenda now.
3199 With prefix argument OPEN, open the new file immediately.
3200 If NOSETTINGS is given, do not scope the settings of
3201 `org-agenda-exporter-settings' into the export commands. This is used when
3202 the settings have already been scoped and we do not wish to overrule other,
3203 higher priority settings.
3204 If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
3205 (interactive "FWrite agenda to file: \nP")
3206 (if (not (file-writable-p file))
3207 (error "Cannot write agenda to file %s" file))
3208 (org-let (if nosettings nil org-agenda-exporter-settings)
3209 '(save-excursion
3210 (save-window-excursion
3211 (org-agenda-mark-filtered-text)
3212 (let ((bs (copy-sequence (buffer-string))) beg)
3213 (org-agenda-unmark-filtered-text)
3214 (with-temp-buffer
3215 (rename-buffer org-agenda-write-buffer-name t)
3216 (set-buffer-modified-p nil)
3217 (insert bs)
3218 (org-agenda-remove-marked-text 'org-filtered)
3219 (while (setq beg (text-property-any (point-min) (point-max)
3220 'org-filtered t))
3221 (delete-region
3222 beg (or (next-single-property-change beg 'org-filtered)
3223 (point-max))))
3224 (run-hooks 'org-agenda-before-write-hook)
3225 (cond
3226 ((org-bound-and-true-p org-mobile-creating-agendas)
3227 (org-mobile-write-agenda-for-mobile file))
3228 ((string-match "\\.html?\\'" file)
3229 (require 'htmlize)
3230 (set-buffer (htmlize-buffer (current-buffer)))
3231 (when org-agenda-export-html-style
3232 ;; replace <style> section with org-agenda-export-html-style
3233 (goto-char (point-min))
3234 (kill-region (- (search-forward "<style") 6)
3235 (search-forward "</style>"))
3236 (insert org-agenda-export-html-style))
3237 (write-file file)
3238 (kill-buffer (current-buffer))
3239 (message "HTML written to %s" file))
3240 ((string-match "\\.ps\\'" file)
3241 (require 'ps-print)
3242 (ps-print-buffer-with-faces file)
3243 (message "Postscript written to %s" file))
3244 ((string-match "\\.pdf\\'" file)
3245 (require 'ps-print)
3246 (ps-print-buffer-with-faces
3247 (concat (file-name-sans-extension file) ".ps"))
3248 (call-process "ps2pdf" nil nil nil
3249 (expand-file-name
3250 (concat (file-name-sans-extension file) ".ps"))
3251 (expand-file-name file))
3252 (delete-file (concat (file-name-sans-extension file) ".ps"))
3253 (message "PDF written to %s" file))
3254 ((string-match "\\.ics\\'" file)
3255 (require 'org-icalendar)
3256 (let ((org-agenda-marker-table
3257 (org-create-marker-find-array
3258 (org-agenda-collect-markers)))
3259 (org-icalendar-verify-function 'org-check-agenda-marker-table)
3260 (org-combined-agenda-icalendar-file file))
3261 (apply 'org-export-icalendar 'combine
3262 (org-agenda-files nil 'ifmode))))
3264 (let ((bs (buffer-string)))
3265 (find-file file)
3266 (erase-buffer)
3267 (insert bs)
3268 (save-buffer 0)
3269 (kill-buffer (current-buffer))
3270 (message "Plain text written to %s" file))))))))
3271 (set-buffer (or agenda-bufname
3272 (and (org-called-interactively-p 'any) (buffer-name))
3273 org-agenda-buffer-name)))
3274 (when open (org-open-file file)))
3276 (defvar org-agenda-tag-filter-overlays nil)
3277 (defvar org-agenda-cat-filter-overlays nil)
3279 (defun org-agenda-mark-filtered-text ()
3280 "Mark all text hidden by filtering with a text property."
3281 (let ((inhibit-read-only t))
3282 (mapc
3283 (lambda (o)
3284 (when (equal (overlay-buffer o) (current-buffer))
3285 (put-text-property
3286 (overlay-start o) (overlay-end o)
3287 'org-filtered t)))
3288 (append org-agenda-tag-filter-overlays
3289 org-agenda-cat-filter-overlays))))
3291 (defun org-agenda-unmark-filtered-text ()
3292 "Remove the filtering text property."
3293 (let ((inhibit-read-only t))
3294 (remove-text-properties (point-min) (point-max) '(org-filtered t))))
3296 (defun org-agenda-remove-marked-text (property &optional value)
3297 "Delete all text marked with VALUE of PROPERTY.
3298 VALUE defaults to t."
3299 (let (beg)
3300 (setq value (or value t))
3301 (while (setq beg (text-property-any (point-min) (point-max)
3302 property value))
3303 (delete-region
3304 beg (or (next-single-property-change beg 'org-filtered)
3305 (point-max))))))
3307 (defun org-agenda-add-entry-text ()
3308 "Add entry text to agenda lines.
3309 This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the
3310 entry text following headings shown in the agenda.
3311 Drawers will be excluded, also the line with scheduling/deadline info."
3312 (when (and (> org-agenda-add-entry-text-maxlines 0)
3313 (not (org-bound-and-true-p org-mobile-creating-agendas)))
3314 (let (m txt)
3315 (goto-char (point-min))
3316 (while (not (eobp))
3317 (if (not (setq m (org-get-at-bol 'org-hd-marker)))
3318 (beginning-of-line 2)
3319 (setq txt (org-agenda-get-some-entry-text
3320 m org-agenda-add-entry-text-maxlines " > "))
3321 (end-of-line 1)
3322 (if (string-match "\\S-" txt)
3323 (insert "\n" txt)
3324 (or (eobp) (forward-char 1))))))))
3326 (defun org-agenda-get-some-entry-text (marker n-lines &optional indent
3327 &rest keep)
3328 "Extract entry text from MARKER, at most N-LINES lines.
3329 This will ignore drawers etc, just get the text.
3330 If INDENT is given, prefix every line with this string. If KEEP is
3331 given, it is a list of symbols, defining stuff that should not be
3332 removed from the entry content. Currently only `planning' is allowed here."
3333 (let (txt drawer-re kwd-time-re ind)
3334 (save-excursion
3335 (with-current-buffer (marker-buffer marker)
3336 (if (not (derived-mode-p 'org-mode))
3337 (setq txt "")
3338 (save-excursion
3339 (save-restriction
3340 (widen)
3341 (goto-char marker)
3342 (end-of-line 1)
3343 (setq txt (buffer-substring
3344 (min (1+ (point)) (point-max))
3345 (progn (outline-next-heading) (point)))
3346 drawer-re org-drawer-regexp
3347 kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
3348 ".*\n?"))
3349 (with-temp-buffer
3350 (insert txt)
3351 (when org-agenda-add-entry-text-descriptive-links
3352 (goto-char (point-min))
3353 (while (org-activate-bracket-links (point-max))
3354 (add-text-properties (match-beginning 0) (match-end 0)
3355 '(face org-link))))
3356 (goto-char (point-min))
3357 (while (re-search-forward org-bracket-link-regexp (point-max) t)
3358 (set-text-properties (match-beginning 0) (match-end 0)
3359 nil))
3360 (goto-char (point-min))
3361 (while (re-search-forward drawer-re nil t)
3362 (delete-region
3363 (match-beginning 0)
3364 (progn (re-search-forward
3365 "^[ \t]*:END:.*\n?" nil 'move)
3366 (point))))
3367 (unless (member 'planning keep)
3368 (goto-char (point-min))
3369 (while (re-search-forward kwd-time-re nil t)
3370 (replace-match "")))
3371 (goto-char (point-min))
3372 (when org-agenda-entry-text-exclude-regexps
3373 (let ((re-list org-agenda-entry-text-exclude-regexps) re)
3374 (while (setq re (pop re-list))
3375 (goto-char (point-min))
3376 (while (re-search-forward re nil t)
3377 (replace-match "")))))
3378 (goto-char (point-max))
3379 (skip-chars-backward " \t\n")
3380 (if (looking-at "[ \t\n]+\\'") (replace-match ""))
3382 ;; find and remove min common indentation
3383 (goto-char (point-min))
3384 (untabify (point-min) (point-max))
3385 (setq ind (org-get-indentation))
3386 (while (not (eobp))
3387 (unless (looking-at "[ \t]*$")
3388 (setq ind (min ind (org-get-indentation))))
3389 (beginning-of-line 2))
3390 (goto-char (point-min))
3391 (while (not (eobp))
3392 (unless (looking-at "[ \t]*$")
3393 (move-to-column ind)
3394 (delete-region (point-at-bol) (point)))
3395 (beginning-of-line 2))
3397 (run-hooks 'org-agenda-entry-text-cleanup-hook)
3399 (goto-char (point-min))
3400 (when indent
3401 (while (and (not (eobp)) (re-search-forward "^" nil t))
3402 (replace-match indent t t)))
3403 (goto-char (point-min))
3404 (while (looking-at "[ \t]*\n") (replace-match ""))
3405 (goto-char (point-max))
3406 (when (> (org-current-line)
3407 n-lines)
3408 (org-goto-line (1+ n-lines))
3409 (backward-char 1))
3410 (setq txt (buffer-substring (point-min) (point)))))))))
3411 txt))
3413 (defun org-agenda-collect-markers ()
3414 "Collect the markers pointing to entries in the agenda buffer."
3415 (let (m markers)
3416 (save-excursion
3417 (goto-char (point-min))
3418 (while (not (eobp))
3419 (when (setq m (or (org-get-at-bol 'org-hd-marker)
3420 (org-get-at-bol 'org-marker)))
3421 (push m markers))
3422 (beginning-of-line 2)))
3423 (nreverse markers)))
3425 (defun org-create-marker-find-array (marker-list)
3426 "Create a alist of files names with all marker positions in that file."
3427 (let (f tbl m a p)
3428 (while (setq m (pop marker-list))
3429 (setq p (marker-position m)
3430 f (buffer-file-name (or (buffer-base-buffer
3431 (marker-buffer m))
3432 (marker-buffer m))))
3433 (if (setq a (assoc f tbl))
3434 (push (marker-position m) (cdr a))
3435 (push (list f p) tbl)))
3436 (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
3437 tbl)))
3439 (defvar org-agenda-marker-table nil) ; dynamically scoped parameter
3440 (defun org-check-agenda-marker-table ()
3441 "Check of the current entry is on the marker list."
3442 (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
3444 (and (setq a (assoc file org-agenda-marker-table))
3445 (save-match-data
3446 (save-excursion
3447 (org-back-to-heading t)
3448 (member (point) (cdr a)))))))
3450 (defun org-check-for-org-mode ()
3451 "Make sure current buffer is in org-mode. Error if not."
3452 (or (derived-mode-p 'org-mode)
3453 (error "Cannot execute org-mode agenda command on buffer in %s"
3454 major-mode)))
3456 ;;; Agenda prepare and finalize
3458 (defvar org-agenda-multi nil) ; dynamically scoped
3459 (defvar org-agenda-pre-window-conf nil)
3460 (defvar org-agenda-columns-active nil)
3461 (defvar org-agenda-name nil)
3462 (defvar org-agenda-tag-filter nil)
3463 (defvar org-agenda-category-filter nil)
3464 (defvar org-agenda-top-category-filter nil)
3465 (defvar org-agenda-tag-filter-while-redo nil)
3466 (defvar org-agenda-tag-filter-preset nil
3467 "A preset of the tags filter used for secondary agenda filtering.
3468 This must be a list of strings, each string must be a single tag preceded
3469 by \"+\" or \"-\".
3470 This variable should not be set directly, but agenda custom commands can
3471 bind it in the options section. The preset filter is a global property of
3472 the entire agenda view. In a block agenda, it will not work reliably to
3473 define a filter for one of the individual blocks. You need to set it in
3474 the global options and expect it to be applied to the entire view.")
3476 (defvar org-agenda-category-filter-preset nil
3477 "A preset of the category filter used for secondary agenda filtering.
3478 This must be a list of strings, each string must be a single category
3479 preceded by \"+\" or \"-\".
3480 This variable should not be set directly, but agenda custom commands can
3481 bind it in the options section. The preset filter is a global property of
3482 the entire agenda view. In a block agenda, it will not work reliably to
3483 define a filter for one of the individual blocks. You need to set it in
3484 the global options and expect it to be applied to the entire view.")
3487 (defun org-agenda-use-sticky-p ()
3488 "Return non-nil if an agenda buffer named
3489 `org-agenda-buffer-name' exists and should be shown instead of
3490 generating a new one."
3491 (and
3492 ;; turned off by user
3493 org-agenda-sticky
3494 ;; For multi-agenda buffer already exists
3495 (not org-agenda-multi)
3496 ;; buffer found
3497 (get-buffer org-agenda-buffer-name)
3498 ;; C-u parameter is same as last call
3499 (with-current-buffer (get-buffer org-agenda-buffer-name)
3500 (and
3501 (equal current-prefix-arg
3502 org-agenda-last-prefix-arg)
3503 ;; In case user turned stickiness on, while having existing
3504 ;; Agenda buffer active, don't reuse that buffer, because it
3505 ;; does not have org variables local
3506 org-agenda-this-buffer-is-sticky))))
3508 (defun org-agenda-prepare-window (abuf)
3509 "Setup agenda buffer in the window."
3510 (let* ((awin (get-buffer-window abuf))
3511 wconf)
3512 (cond
3513 ((equal (current-buffer) abuf) nil)
3514 (awin (select-window awin))
3515 ((not (setq wconf (current-window-configuration))))
3516 ((equal org-agenda-window-setup 'current-window)
3517 (org-pop-to-buffer-same-window abuf))
3518 ((equal org-agenda-window-setup 'other-window)
3519 (org-switch-to-buffer-other-window abuf))
3520 ((equal org-agenda-window-setup 'other-frame)
3521 (switch-to-buffer-other-frame abuf))
3522 ((equal org-agenda-window-setup 'reorganize-frame)
3523 (delete-other-windows)
3524 (org-switch-to-buffer-other-window abuf)))
3525 ;; additional test in case agenda is invoked from within agenda
3526 ;; buffer via elisp link
3527 (unless (equal (current-buffer) abuf)
3528 (org-pop-to-buffer-same-window abuf))
3529 (setq org-agenda-pre-window-conf
3530 (or org-agenda-pre-window-conf wconf))))
3532 (defun org-agenda-prepare (&optional name)
3533 (if (org-agenda-use-sticky-p)
3534 (progn
3535 ;; Popup existing buffer
3536 (org-agenda-prepare-window (get-buffer org-agenda-buffer-name))
3537 (message "Sticky Agenda buffer, use `r' to refresh")
3538 (or org-agenda-multi (org-agenda-fit-window-to-buffer))
3539 (throw 'exit "Sticky Agenda buffer, use `r' to refresh"))
3540 (setq org-todo-keywords-for-agenda nil)
3541 (setq org-drawers-for-agenda nil)
3542 (unless org-agenda-persistent-filter
3543 (setq org-agenda-tag-filter nil
3544 org-agenda-category-filter nil))
3545 (put 'org-agenda-tag-filter :preset-filter
3546 org-agenda-tag-filter-preset)
3547 (put 'org-agenda-category-filter :preset-filter
3548 org-agenda-category-filter-preset)
3549 (if org-agenda-multi
3550 (progn
3551 (setq buffer-read-only nil)
3552 (goto-char (point-max))
3553 (unless (or (bobp) org-agenda-compact-blocks
3554 (not org-agenda-block-separator))
3555 (insert "\n"
3556 (if (stringp org-agenda-block-separator)
3557 org-agenda-block-separator
3558 (make-string (window-width) org-agenda-block-separator))
3559 "\n"))
3560 (narrow-to-region (point) (point-max)))
3561 (setq org-done-keywords-for-agenda nil)
3563 ;; Setting any org variables that are in org-agenda-local-vars
3564 ;; list need to be done after the prepare call
3565 (org-agenda-prepare-window (get-buffer-create org-agenda-buffer-name))
3566 (setq buffer-read-only nil)
3567 (org-agenda-reset-markers)
3568 (let ((inhibit-read-only t)) (erase-buffer))
3569 (org-agenda-mode)
3570 (setq org-agenda-buffer (current-buffer))
3571 (setq org-agenda-contributing-files nil)
3572 (setq org-agenda-columns-active nil)
3573 (org-agenda-prepare-buffers (org-agenda-files nil 'ifmode))
3574 (setq org-todo-keywords-for-agenda
3575 (org-uniquify org-todo-keywords-for-agenda))
3576 (setq org-done-keywords-for-agenda
3577 (org-uniquify org-done-keywords-for-agenda))
3578 (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
3579 (setq org-agenda-last-prefix-arg current-prefix-arg)
3580 (setq org-agenda-this-buffer-name org-agenda-buffer-name)
3581 (and name (not org-agenda-name)
3582 (org-set-local 'org-agenda-name name)))
3583 (setq buffer-read-only nil)))
3585 (defvar org-agenda-overriding-columns-format) ; From org-colview.el
3586 (defun org-agenda-finalize ()
3587 "Finishing touch for the agenda buffer, called just before displaying it."
3588 (unless org-agenda-multi
3589 (save-excursion
3590 (let ((inhibit-read-only t))
3591 (goto-char (point-min))
3592 (save-excursion
3593 (while (org-activate-bracket-links (point-max))
3594 (add-text-properties (match-beginning 0) (match-end 0)
3595 '(face org-link))))
3596 (save-excursion
3597 (while (org-activate-plain-links (point-max))
3598 (add-text-properties (match-beginning 0) (match-end 0)
3599 '(face org-link))))
3600 (unless (eq org-agenda-remove-tags t)
3601 (org-agenda-align-tags))
3602 (unless org-agenda-with-colors
3603 (remove-text-properties (point-min) (point-max) '(face nil)))
3604 (if (and (boundp 'org-agenda-overriding-columns-format)
3605 org-agenda-overriding-columns-format)
3606 (org-set-local 'org-agenda-overriding-columns-format
3607 org-agenda-overriding-columns-format))
3608 (if (and (boundp 'org-agenda-view-columns-initially)
3609 org-agenda-view-columns-initially)
3610 (org-agenda-columns))
3611 (when org-agenda-fontify-priorities
3612 (org-agenda-fontify-priorities))
3613 (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
3614 (org-agenda-dim-blocked-tasks))
3615 ;; We need to widen when `org-agenda-finalize' is called from
3616 ;; `org-agenda-change-all-lines' (e.g. in `org-agenda-clock-in')
3617 (when org-clock-current-task
3618 (save-restriction
3619 (widen)
3620 (org-agenda-mark-clocking-task)))
3621 (when org-agenda-entry-text-mode
3622 (org-agenda-entry-text-hide)
3623 (org-agenda-entry-text-show))
3624 (if (and (functionp 'org-habit-insert-consistency-graphs)
3625 (save-excursion (next-single-property-change (point-min) 'org-habit-p)))
3626 (org-habit-insert-consistency-graphs))
3627 (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
3628 (unless (or (eq org-agenda-show-inherited-tags 'always)
3629 (and (listp org-agenda-show-inherited-tags)
3630 (memq org-agenda-type org-agenda-show-inherited-tags))
3631 (and (eq org-agenda-show-inherited-tags t)
3632 (or (eq org-agenda-use-tag-inheritance t)
3633 (and (listp org-agenda-use-tag-inheritance)
3634 (not (memq org-agenda-type
3635 org-agenda-use-tag-inheritance))))))
3636 (let (mrk)
3637 (save-excursion
3638 (goto-char (point-min))
3639 (while (equal (forward-line) 0)
3640 (when (setq mrk (or (get-text-property (point) 'org-hd-marker)
3641 (get-text-property (point) 'org-hd-marker)))
3642 (put-text-property (point-at-bol) (point-at-eol)
3643 'tags (org-with-point-at mrk
3644 (delete-dups
3645 (mapcar 'downcase (org-get-tags-at))))))))))
3646 (run-hooks 'org-agenda-finalize-hook)
3647 (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
3648 (org-agenda-filter-apply org-agenda-tag-filter 'tag))
3649 (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
3650 (org-agenda-filter-apply org-agenda-category-filter 'category))
3651 (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)))))
3653 (defun org-agenda-mark-clocking-task ()
3654 "Mark the current clock entry in the agenda if it is present."
3655 (mapc (lambda (o)
3656 (if (eq (overlay-get o 'type) 'org-agenda-clocking)
3657 (delete-overlay o)))
3658 (overlays-in (point-min) (point-max)))
3659 (when (marker-buffer org-clock-hd-marker)
3660 (save-excursion
3661 (goto-char (point-min))
3662 (let (s ov)
3663 (while (setq s (next-single-property-change (point) 'org-hd-marker))
3664 (goto-char s)
3665 (when (equal (org-get-at-bol 'org-hd-marker)
3666 org-clock-hd-marker)
3667 (setq ov (make-overlay (point-at-bol) (1+ (point-at-eol))))
3668 (overlay-put ov 'type 'org-agenda-clocking)
3669 (overlay-put ov 'face 'org-agenda-clocking)
3670 (overlay-put ov 'help-echo
3671 "The clock is running in this item")))))))
3673 (defun org-agenda-fontify-priorities ()
3674 "Make highest priority lines bold, and lowest italic."
3675 (interactive)
3676 (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-priority)
3677 (delete-overlay o)))
3678 (overlays-in (point-min) (point-max)))
3679 (save-excursion
3680 (let (b e p ov h l)
3681 (goto-char (point-min))
3682 (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
3683 (setq h (or (get-char-property (point) 'org-highest-priority)
3684 org-highest-priority)
3685 l (or (get-char-property (point) 'org-lowest-priority)
3686 org-lowest-priority)
3687 p (string-to-char (match-string 1))
3688 b (match-beginning 0)
3689 e (if (eq org-agenda-fontify-priorities 'cookies)
3690 (match-end 0)