summaryrefslogtreecommitdiff
path: root/lisp/org-agenda.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org-agenda.el')
-rw-r--r--[-rwxr-xr-x]lisp/org-agenda.el2098
1 files changed, 1474 insertions, 624 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 97241b6..270a73d 100755..100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1,6 +1,6 @@
;;; org-agenda.el --- Dynamic task and appointment lists for Org
-;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
@@ -242,6 +242,11 @@ you can \"misuse\" it to also add other text to the header."
(defconst org-sorting-choice
'(choice
(const time-up) (const time-down)
+ (const timestamp-up) (const timestamp-down)
+ (const scheduled-up) (const scheduled-down)
+ (const deadline-up) (const deadline-down)
+ (const ts-up) (const ts-down)
+ (const tsia-up) (const tsia-down)
(const category-keep) (const category-up) (const category-down)
(const tag-down) (const tag-up)
(const priority-up) (const priority-down)
@@ -254,9 +259,50 @@ you can \"misuse\" it to also add other text to the header."
;; Keep custom values for `org-agenda-filter-preset' compatible with
;; the new variable `org-agenda-tag-filter-preset'.
-(if (fboundp 'defvaralias)
- (defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
- (defvaralias 'org-agenda-filter 'org-agenda-tag-filter))
+(org-defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
+(org-defvaralias 'org-agenda-filter 'org-agenda-tag-filter)
+
+(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
+ "List of types searched for when creating the daily/weekly agenda.
+This variable is a list of symbols that controls the types of
+items that appear in the daily/weekly agenda. Allowed symbols in this
+list are are
+
+ :timestamp List items containing a date stamp or date range matching
+ the selected date. This includes sexp entries in angular
+ brackets.
+
+ :sexp List entries resulting from plain diary-like sexps.
+
+ :deadline List deadline due on that date. When the date is today,
+ also list any deadlines past due, or due within
+ `org-deadline-warning-days'. `:deadline' must appear before
+ `:scheduled' if the setting of
+ `org-agenda-skip-scheduled-if-deadline-is-shown' is to have
+ any effect.
+
+ :deadline* Same as above, but only include the deadline if it has an
+ hour specification as [h]h:mm.
+
+ :scheduled List all items which are scheduled for the given date.
+ The diary for *today* also contains items which were
+ scheduled earlier and are not yet marked DONE.
+
+ :scheduled* Same as above, but only include the scheduled item if it
+ has an hour specification as [h]h:mm.
+
+By default, all four non-starred types are turned on.
+
+When :scheduled* or :deadline* are included, :schedule or :deadline
+will be ignored.
+
+Never set this variable globally using `setq', because then it
+will apply to all future agenda commands. Instead, bind it with
+`let' to scope it dynamically into the agenda-constructing
+command. A good way to set it is through options in
+`org-agenda-custom-commands'. For a more flexible (though
+somewhat less efficient) way of determining what is included in
+the daily/weekly agenda, see `org-agenda-skip-function'.")
(defconst org-agenda-custom-commands-local-options
`(repeat :tag "Local settings for this command. Remember to quote values"
@@ -311,13 +357,21 @@ you can \"misuse\" it to also add other text to the header."
(const :format "" quote)
(repeat
(string :tag "+tag or -tag"))))
+ (list :tag "Regexp filter preset"
+ (const org-agenda-regexp-filter-preset)
+ (list
+ (const :format "" quote)
+ (repeat
+ (string :tag "+regexp or -regexp"))))
(list :tag "Set daily/weekly entry types"
(const org-agenda-entry-types)
(list
(const :format "" quote)
- (set :greedy t :value (:deadline :scheduled :timestamp :sexp)
+ (set :greedy t :value ,org-agenda-entry-types
(const :deadline)
(const :scheduled)
+ (const :deadline*)
+ (const :scheduled*)
(const :timestamp)
(const :sexp))))
(list :tag "Standard skipping condition"
@@ -371,8 +425,8 @@ This will be spliced into the custom type of
`org-agenda-custom-commands'.")
-(defcustom org-agenda-custom-commands '(("n" "Agenda and all TODO's"
- ((agenda "") (alltodo))))
+(defcustom org-agenda-custom-commands
+ '(("n" "Agenda and all TODO's" ((agenda "") (alltodo ""))))
"Custom commands for the agenda.
These commands will be offered on the splash screen displayed by the
agenda dispatcher \\[org-agenda]. Each entry is a list like this:
@@ -530,7 +584,7 @@ This is a list of four items:
the project is considered to be not stuck. If you specify \"*\" as
a tag, any tag will mark the project unstuck. Note that this is about
the explicit presence of a tag somewhere in the subtree, inherited
- tags to not count here. If inherited tags make a project not stuck,
+ tags do not count here. If inherited tags make a project not stuck,
use \"-TAG\" in the tags part of the matcher under (1.) above.
4. An arbitrary regular expression matching non-stuck projects.
@@ -603,6 +657,13 @@ that are marked with the ARCHIVE tag will be included anyway. When this is
t, also all archive files associated with the current selection of agenda
files will be included.")
+(defcustom org-agenda-restriction-lock-highlight-subtree t
+ "Non-nil means highlight the whole subtree when restriction is active.
+Otherwise only highlight the headline. Highlighting the whole subtree is
+useful to ensure no edits happen beyond the restricted region."
+ :group 'org-agenda
+ :type 'boolean)
+
(defcustom org-agenda-skip-comment-trees t
"Non-nil means skip trees that start with the COMMENT keyword.
When nil, these trees are also scanned by agenda commands."
@@ -740,8 +801,24 @@ to make his option also apply to the tags-todo list."
(const :tag "Show all TODOs, even if they have a deadline" nil)
(integer :tag "Ignore if N or more days in past(-) or future(+).")))
+(defcustom org-agenda-todo-ignore-time-comparison-use-seconds nil
+ "Time unit to use when possibly ignoring an agenda item.
+
+See the docstring of various `org-agenda-todo-ignore-*' options.
+The default is to compare time stamps using days. An item is thus
+considered to be in the future if it is at least one day after today.
+Non-nil means to compare time stamps using seconds. An item is then
+considered future if it has a time value later than current time."
+ :group 'org-agenda-skip
+ :group 'org-agenda-todo-list
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :type '(choice
+ (const :tag "Compare time with days" nil)
+ (const :tag "Compare time with seconds" t)))
+
(defcustom org-agenda-tags-todo-honor-ignore-options nil
- "Non-nil means honor todo-list ...ignore options also in tags-todo search.
+ "Non-nil means honor todo-list ignores options also in tags-todo search.
The variables
`org-agenda-todo-ignore-with-date',
`org-agenda-todo-ignore-timestamp',
@@ -768,20 +845,29 @@ is DONE."
(defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
"Non-nil means skip scheduling line if same entry shows because of deadline.
-In the agenda of today, an entry can show up multiple times because
-it is both scheduled and has a nearby deadline, and maybe a plain time
-stamp as well.
-When this variable is t, then only the deadline is shown and the fact that
-the entry is scheduled today or was scheduled previously is not shown.
-When this variable is nil, the entry will be shown several times. When
-the variable is the symbol `not-today', then skip scheduled previously,
-but not scheduled today."
+
+In the agenda of today, an entry can show up multiple times
+because it is both scheduled and has a nearby deadline, and maybe
+a plain time stamp as well.
+
+When this variable is nil, the entry will be shown several times.
+
+When set to t, then only the deadline is shown and the fact that
+the entry is scheduled today or was scheduled previously is not
+shown.
+
+When set to the symbol `not-today', skip scheduled previously,
+but not scheduled today.
+
+When set to the symbol `repeated-after-deadline', skip scheduled
+items if they are repeated beyond the current dealine."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)
- (const :tag "Not when scheduled today" not-today)))
+ (const :tag "Not when scheduled today" not-today)
+ (const :tag "When repeated past deadline" repeated-after-deadline)))
(defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
"Non-nil means skip timestamp line if same entry shows because of deadline.
@@ -813,9 +899,10 @@ deadlines are always turned off when the item is DONE."
This will apply on all days where a prewarning for the deadline would
be shown, but not at the day when the entry is actually due. On that day,
the deadline will be shown anyway.
-This variable may be set to nil, t, or a number which will then give
-the number of days before the actual deadline when the prewarnings
-should resume.
+This variable may be set to nil, t, the symbol `pre-scheduled',
+or a number which will then give the number of days before the actual
+deadline when the prewarnings should resume. The symbol `pre-scheduled'
+eliminates the deadline prewarning only prior to the scheduled date.
This can be used in a workflow where the first showing of the deadline will
trigger you to schedule it, and then you don't want to be reminded of it
because you will take care of it on the day when scheduled."
@@ -823,10 +910,27 @@ because you will take care of it on the day when scheduled."
:group 'org-agenda-daily/weekly
:version "24.1"
:type '(choice
- (const :tag "Alwas show prewarning" nil)
+ (const :tag "Always show prewarning" nil)
+ (const :tag "Remove prewarning prior to scheduled date" pre-scheduled)
(const :tag "Remove prewarning if entry is scheduled" t)
(integer :tag "Restart prewarning N days before deadline")))
+(defcustom org-agenda-skip-scheduled-delay-if-deadline nil
+ "Non-nil means skip scheduled delay when entry also has a deadline.
+This variable may be set to nil, t, the symbol `post-deadline',
+or a number which will then give the number of days after the actual
+scheduled date when the delay should expire. The symbol `post-deadline'
+eliminates the schedule delay when the date is posterior to the deadline."
+ :group 'org-agenda-skip
+ :group 'org-agenda-daily/weekly
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :type '(choice
+ (const :tag "Always honor delay" nil)
+ (const :tag "Ignore delay if posterior to the deadline" post-deadline)
+ (const :tag "Ignore delay if entry has a deadline" t)
+ (integer :tag "Honor delay up until N days after the scheduled date")))
+
(defcustom org-agenda-skip-additional-timestamps-same-entry nil
"When nil, multiple same-day timestamps in entry make multiple agenda lines.
When non-nil, after the search for timestamps has matched once in an
@@ -857,6 +961,7 @@ that is blocked because of checkboxes will never be made invisible, it
will only be dimmed."
:group 'org-agenda-daily/weekly
:group 'org-agenda-todo-list
+ :version "24.3"
:type '(choice
(const :tag "Do not dim" nil)
(const :tag "Dim to a gray face" t)
@@ -955,6 +1060,13 @@ removed from entry text before it is shown in the agenda."
:group 'org-agenda
:type '(repeat (regexp)))
+(defcustom org-agenda-entry-text-leaders " > "
+ "Text prepended to the entry text in agenda buffers."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-agenda
+ :type 'string)
+
(defvar org-agenda-entry-text-cleanup-hook nil
"Hook that is run after basic cleanup of entry text to be shown in agenda.
This cleanup is done in a temporary buffer, so the function may inspect and
@@ -1029,7 +1141,7 @@ Custom commands can set this variable in the options section."
(defcustom org-agenda-start-on-weekday 1
"Non-nil means start the overview always on the specified weekday.
-0 denotes Sunday, 1 denotes Monday etc.
+0 denotes Sunday, 1 denotes Monday, etc.
When nil, always start on the current day.
Custom commands can set this variable in the options section."
:group 'org-agenda-daily/weekly
@@ -1054,7 +1166,7 @@ a calendar-style date list like (month day year)."
(function :tag "Function")))
(defun org-agenda-format-date-aligned (date)
- "Format a date string for display in the daily/weekly agenda, or timeline.
+ "Format a DATE string for display in the daily/weekly agenda, or timeline.
This function makes sure that dates are aligned for easy reading."
(require 'cal-iso)
(let* ((dayname (calendar-day-name date))
@@ -1107,8 +1219,7 @@ For example, 9:30am would become 09:30 rather than 9:30."
":" minute ampm)))
(defun org-agenda-time-of-day-to-ampm-maybe (time)
- "Conditionally convert TIME to AM/PM format
-based on `org-agenda-timegrid-use-ampm'"
+ "Conditionally convert TIME to AM/PM format based on `org-agenda-timegrid-use-ampm'."
(if org-agenda-timegrid-use-ampm
(org-agenda-time-of-day-to-ampm time)
time))
@@ -1163,7 +1274,7 @@ shown, either today or the nearest into the future."
(const :tag "Don't show repeating stamps" nil)))
(defcustom org-scheduled-past-days 10000
- "No. of days to continue listing scheduled items that are not marked DONE.
+ "Number of days to continue listing scheduled items not marked DONE.
When an item is scheduled on a date, it shows up in the agenda on this
day and will be listed until it is marked done for the number of days
given here."
@@ -1293,9 +1404,8 @@ boolean search."
:version "24.1"
:type 'boolean)
-(if (fboundp 'defvaralias)
- (defvaralias 'org-agenda-search-view-search-words-only
- 'org-agenda-search-view-always-boolean))
+(org-defvaralias 'org-agenda-search-view-search-words-only
+ 'org-agenda-search-view-always-boolean)
(defcustom org-agenda-search-view-force-full-words nil
"Non-nil means, search words must be matches as complete words.
@@ -1304,6 +1414,15 @@ When nil, they may also match part of a word."
:version "24.1"
:type 'boolean)
+(defcustom org-agenda-search-view-max-outline-level nil
+ "Maximum outline level to display in search view.
+E.g. when this is set to 1, the search view will only
+show headlines of level 1."
+ :group 'org-agenda-search-view
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :type 'integer)
+
(defgroup org-agenda-time-grid nil
"Options concerning the time grid in the Org-mode Agenda."
:tag "Org Agenda Time Grid"
@@ -1392,6 +1511,16 @@ symbols are recognized:
time-up Put entries with time-of-day indications first, early first
time-down Put entries with time-of-day indications first, late first
+timestamp-up Sort by any timestamp, early first
+timestamp-down Sort by any timestamp, late first
+scheduled-up Sort by scheduled timestamp, early first
+scheduled-down Sort by scheduled timestamp, late first
+deadline-up Sort by deadline timestamp, early first
+deadline-down Sort by deadline timestamp, late first
+ts-up Sort by active timestamp, early first
+ts-down Sort by active timestamp, late first
+tsia-up Sort by inactive timestamp, early first
+tsia-down Sort by inactive timestamp, late first
category-keep Keep the default order of categories, corresponding to the
sequence in `org-agenda-files'.
category-up Sort alphabetically by category, A-Z.
@@ -1492,15 +1621,17 @@ This format works similar to a printf format, with the following meaning:
%c the category of the item, \"Diary\" for entries from the diary,
or as given by the CATEGORY keyword or derived from the file name
%e the effort required by the item
+ %l the level of the item (insert X space(s) if item is of level X)
%i the icon category of the item, see `org-agenda-category-icon-alist'
%T the last tag of the item (ignore inherited tags, which come first)
%t the HH:MM time-of-day specification if one applies to the entry
%s Scheduling/Deadline information, a short string
+ %b show breadcrumbs, i.e., the names of the higher levels
%(expression) Eval EXPRESSION and replace the control string
by the result
All specifiers work basically like the standard `%s' of printf, but may
-contain two additional characters: a question mark just after the `%'
+contain two additional characters: a question mark just after the `%'
and a whitespace/punctuation character just before the final letter.
If the first character after `%' is a question mark, the entire field
@@ -1510,11 +1641,11 @@ present, but zero width when absent. For example, \"%?-12t\" will
result in a 12 character time field if a time of the day is specified,
but will completely disappear in entries which do not contain a time.
-If there is punctuation or whitespace character just before the final
-format letter, this character will be appended to the field value if
-the value is not empty. For example, the format \"%-12:c\" leads to
-\"Diary: \" if the category is \"Diary\". If the category were be
-empty, no additional colon would be inserted.
+If there is punctuation or whitespace character just before the
+final format letter, this character will be appended to the field
+value if the value is not empty. For example, the format
+\"%-12:c\" leads to \"Diary: \" if the category is \"Diary\". If
+the category is empty, no additional colon is inserted.
The default value for the agenda sublist is \" %-12:c%?-12t% s\",
which means:
@@ -1587,6 +1718,8 @@ this item is scheduled, due to automatic rescheduling of unfinished items
for the following day. So this number is one larger than the number of days
that passed since this item was scheduled first."
:group 'org-agenda-line-format
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type '(list
(string :tag "Scheduled today ")
(string :tag "Scheduled previously")))
@@ -1600,13 +1733,15 @@ These entries are added to the agenda when pressing \"[\"."
(string :tag "Scheduled today ")
(string :tag "Scheduled previously")))
-(defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: ")
+(defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: " "%2d d. ago: ")
"Text preceding deadline items in the agenda view.
-This is a list with two strings. The first applies when the item has its
-deadline on the current day. The second applies when it is in the past or
-in the future, it may contain %d to capture how many days away the deadline
-is (was)."
+This is a list with three strings. The first applies when the item has its
+deadline on the current day. The second applies when the deadline is in the
+future, the third one when it is in the past. The strings may contain %d
+to capture the number of days."
:group 'org-agenda-line-format
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type '(list
(string :tag "Deadline today ")
(choice :tag "Deadline relative"
@@ -1647,9 +1782,53 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour."
(const :tag "No default duration")))
(defcustom org-agenda-show-inherited-tags t
- "Non-nil means show inherited tags in each agenda line."
+ "Non-nil means show inherited tags in each agenda line.
+
+When this option is set to 'always, it take precedences over
+`org-agenda-use-tag-inheritance' and inherited tags are shown
+in every agenda.
+
+When this option is set to t (the default), inherited tags are
+shown when they are available, i.e. when the value of
+`org-agenda-use-tag-inheritance' has been taken into account.
+
+This can be set to a list of agenda types in which the agenda
+must display the inherited tags. Available types are 'todo,
+'agenda, 'search and 'timeline.
+
+When set to nil, never show inherited tags in agenda lines."
:group 'org-agenda-line-format
- :type 'boolean)
+ :group 'org-agenda
+ :version "24.3"
+ :type '(choice
+ (const :tag "Show inherited tags when available" t)
+ (const :tag "Always show inherited tags" 'always)
+ (repeat :tag "Show inherited tags only in selected agenda types"
+ (symbol :tag "Agenda type"))))
+
+(defcustom org-agenda-use-tag-inheritance '(todo search timeline agenda)
+ "List of agenda view types where to use tag inheritance.
+
+In tags/tags-todo/tags-tree agenda views, tag inheritance is
+controlled by `org-use-tag-inheritance'. In other agenda types,
+`org-use-tag-inheritance' is not used for the selection of the
+agenda entries. Still, you may want the agenda to be aware of
+the inherited tags anyway, e.g. for later tag filtering.
+
+Allowed value are 'todo, 'search, 'timeline and 'agenda.
+
+This variable has no effect if `org-agenda-show-inherited-tags'
+is set to 'always. In that case, the agenda is aware of those
+tags.
+
+The default value sets tags in every agenda type. Setting this
+option to nil will speed up non-tags agenda view a lot."
+ :group 'org-agenda
+ :version "24.3"
+ :type '(choice
+ (const :tag "Use tag inheritance in all agenda types" t)
+ (repeat :tag "Use tag inheritance in selected agenda types"
+ (symbol :tag "Agenda type"))))
(defcustom org-agenda-hide-tags-regexp nil
"Regular expression used to filter away specific tags in agenda views.
@@ -1671,9 +1850,8 @@ When this is the symbol `prefix', only remove tags when
(const :tag "Never" nil)
(const :tag "When prefix format contains %T" prefix)))
-(if (fboundp 'defvaralias)
- (defvaralias 'org-agenda-remove-tags-when-in-prefix
- 'org-agenda-remove-tags))
+(org-defvaralias 'org-agenda-remove-tags-when-in-prefix
+ 'org-agenda-remove-tags)
(defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
"Shift tags in agenda items to this column.
@@ -1683,8 +1861,7 @@ it means that the tags should be flushright to that column. For example,
:group 'org-agenda-line-format
:type 'integer)
-(if (fboundp 'defvaralias)
- (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
+(org-defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
(defcustom org-agenda-fontify-priorities 'cookies
"Non-nil means highlight low and high priorities in agenda.
@@ -1842,8 +2019,7 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
(defvar org-agenda-mode-map (make-sparse-keymap)
"Keymap for `org-agenda-mode'.")
-(if (fboundp 'defvaralias)
- (defvaralias 'org-agenda-keymap 'org-agenda-mode-map))
+(org-defvaralias 'org-agenda-keymap 'org-agenda-mode-map)
(defvar org-agenda-menu) ; defined later in this file.
(defvar org-agenda-restrict nil) ; defined later in this file.
@@ -1871,6 +2047,7 @@ When nil, `q' will kill the single agenda buffer."
:version "24.3"
:type 'boolean)
+
;;;###autoload
(defun org-toggle-sticky-agenda (&optional arg)
"Toggle `org-agenda-sticky'."
@@ -1910,17 +2087,18 @@ When nil, `q' will kill the single agenda buffer."
org-agenda-bulk-marked-entries
org-agenda-undo-has-started-in
org-agenda-info
- org-agenda-tag-filter-overlays
- org-agenda-cat-filter-overlays
org-agenda-pre-window-conf
org-agenda-columns-active
+ org-agenda-tag-filter-overlays
org-agenda-tag-filter
+ org-agenda-cat-filter-overlays
org-agenda-category-filter
+ org-agenda-re-filter-overlays
+ org-agenda-regexp-filter
org-agenda-markers
org-agenda-last-search-view-search-was-boolean
org-agenda-filtered-by-category
org-agenda-filter-form
- org-agenda-show-window
org-agenda-cycle-counter
org-agenda-last-prefix-arg)
"Variables that must be local in agenda buffers to allow multiple buffers.")
@@ -1970,10 +2148,10 @@ The following commands are available:
(org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
(org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
;; Make sure properties are removed when copying text
- (make-local-variable 'filter-buffer-substring-functions)
- (add-hook 'filter-buffer-substring-functions
- (lambda (fun start end delete)
- (substring-no-properties (funcall fun start end delete))))
+ (org-add-hook 'filter-buffer-substring-functions
+ (lambda (fun start end delete)
+ (substring-no-properties (funcall fun start end delete)))
+ nil t)
(unless org-agenda-keep-modes
(setq org-agenda-follow-mode org-agenda-start-with-follow-mode
org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
@@ -2004,8 +2182,13 @@ The following commands are available:
(org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
(org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
(org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
+(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward)
+(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward)
(org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
+(org-defkey org-agenda-mode-map "\M-m" 'org-agenda-bulk-toggle)
(org-defkey org-agenda-mode-map "*" 'org-agenda-bulk-mark-all)
+(org-defkey org-agenda-mode-map "\M-*" 'org-agenda-bulk-toggle-all)
+(org-defkey org-agenda-mode-map "#" 'org-agenda-dim-blocked-tasks)
(org-defkey org-agenda-mode-map "%" 'org-agenda-bulk-mark-regexp)
(org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
(org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-unmark-all)
@@ -2118,9 +2301,12 @@ The following commands are available:
(org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
(org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
(org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
+(org-defkey org-agenda-mode-map "=" 'org-agenda-filter-by-regexp)
+(org-defkey org-agenda-mode-map "|" 'org-agenda-filter-remove-all)
(org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
+(org-defkey org-agenda-mode-map "~" 'org-agenda-limit-interactively)
(org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
-(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-category)
+(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-headline)
(org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
(define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
(org-defkey org-agenda-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
@@ -2217,9 +2403,11 @@ The following commands are available:
("Bulk action"
["Mark entry" org-agenda-bulk-mark t]
["Mark all" org-agenda-bulk-mark-all t]
- ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
["Unmark entry" org-agenda-bulk-unmark t]
- ["Unmark all entries" org-agenda-bulk-unmark-all :active t :keys "U"])
+ ["Unmark all" org-agenda-bulk-unmark-all :active t :keys "U"]
+ ["Toggle mark" org-agenda-bulk-toggle t]
+ ["Toggle all" org-agenda-bulk-toggle-all t]
+ ["Mark regexp" org-agenda-bulk-mark-regexp t])
["Act on all marked" org-agenda-bulk-action t]
"--"
("Tags and Properties"
@@ -2261,7 +2449,7 @@ The following commands are available:
["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
"--"
- ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
+ ["Create iCalendar File" org-icalendar-combine-agenda-files t])
"--"
["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
"--"
@@ -2290,12 +2478,12 @@ This undoes changes both in the agenda buffer and in the remote buffer
that have been changed along."
(interactive)
(or org-agenda-allow-remote-undo
- (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
+ (user-error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
(if (not (eq this-command last-command))
(setq org-agenda-undo-has-started-in nil
org-agenda-pending-undo-list org-agenda-undo-list))
(if (not org-agenda-pending-undo-list)
- (error "No further undo information"))
+ (user-error "No further undo information"))
(let* ((entry (pop org-agenda-pending-undo-list))
buf line cmd rembuf)
(setq cmd (pop entry) line (pop entry))
@@ -2338,7 +2526,7 @@ For example, if you have a custom agenda command \"p\" and you
want this command to be accessible only from plain text files,
use this:
- '((\"p\" (in-file . \"\\.txt\")))
+ '((\"p\" ((in-file . \"\\.txt\"))))
Here are the available contexts definitions:
@@ -2346,6 +2534,8 @@ Here are the available contexts definitions:
in-mode: command displayed only in matching modes
not-in-file: command not displayed in matching files
not-in-mode: command not displayed in matching modes
+ in-buffer: command displayed only in matching buffers
+not-in-buffer: command not displayed in matching buffers
[function]: a custom function taking no argument
If you define several checks, the agenda command will be
@@ -2354,7 +2544,7 @@ accessible if there is at least one valid check.
You can also bind a key to another agenda custom command
depending on contextual rules.
- '((\"p\" \"q\" (in-file . \"\\.txt\")))
+ '((\"p\" \"q\" ((in-file . \"\\.txt\"))))
Here it means: in .txt files, use \"p\" as the key for the
agenda command otherwise associated with \"q\". (The command
@@ -2371,11 +2561,89 @@ duplicates.)"
(choice
(const :tag "In file" in-file)
(const :tag "Not in file" not-in-file)
+ (const :tag "In buffer" in-buffer)
+ (const :tag "Not in buffer" not-in-buffer)
(const :tag "In mode" in-mode)
(const :tag "Not in mode" not-in-mode))
(regexp))
(function :tag "Custom function"))))))
+(defcustom org-agenda-max-entries nil
+ "Maximum number of entries to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-agenda-custom-commands
+ :type '(choice (symbol :tag "No limit" nil)
+ (integer :tag "Max number of entries")
+ (repeat
+ (cons (choice :tag "Agenda type"
+ (const agenda)
+ (const todo)
+ (const tags)
+ (const search)
+ (const timeline))
+ (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-todos nil
+ "Maximum number of TODOs to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-agenda-custom-commands
+ :type '(choice (symbol :tag "No limit" nil)
+ (integer :tag "Max number of entries")
+ (repeat
+ (cons (choice :tag "Agenda type"
+ (const agenda)
+ (const todo)
+ (const tags)
+ (const search)
+ (const timeline))
+ (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-tags nil
+ "Maximum number of tagged entries to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-agenda-custom-commands
+ :type '(choice (symbol :tag "No limit" nil)
+ (integer :tag "Max number of entries")
+ (repeat
+ (cons (choice :tag "Agenda type"
+ (const agenda)
+ (const todo)
+ (const tags)
+ (const search)
+ (const timeline))
+ (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-effort nil
+ "Maximum cumulated effort duration for the agenda.
+This can be nil (no limit) or a number of minutes (as an integer)
+or an alist of agenda types with an associated number of minutes
+to limit entries to in this type."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-agenda-custom-commands
+ :type '(choice (symbol :tag "No limit" nil)
+ (integer :tag "Max number of entries")
+ (repeat
+ (cons (choice :tag "Agenda type"
+ (const agenda)
+ (const todo)
+ (const tags)
+ (const search)
+ (const timeline))
+ (integer :tag "Max number of entries")))))
+
(defvar org-keys nil)
(defvar org-match nil)
;;;###autoload
@@ -2469,12 +2737,12 @@ Pressing `<' twice means to restrict to the current subtree or region
(put 'org-agenda-files 'org-restrict (list bfn))
(cond
((eq restriction 'region)
- (setq org-agenda-restrict t)
+ (setq org-agenda-restrict (current-buffer))
(move-marker org-agenda-restrict-begin (region-beginning))
(move-marker org-agenda-restrict-end (region-end)))
((eq restriction 'subtree)
(save-excursion
- (setq org-agenda-restrict t)
+ (setq org-agenda-restrict (current-buffer))
(org-back-to-heading t)
(move-marker org-agenda-restrict-begin (point))
(move-marker org-agenda-restrict-end
@@ -2495,6 +2763,8 @@ Pressing `<' twice means to restrict to the current subtree or region
(cond
((eq type 'agenda)
(org-let lprops '(org-agenda-list current-prefix-arg)))
+ ((eq type 'agenda*)
+ (org-let lprops '(org-agenda-list current-prefix-arg nil nil t)))
((eq type 'alltodo)
(org-let lprops '(org-todo-list current-prefix-arg)))
((eq type 'search)
@@ -2523,7 +2793,7 @@ Pressing `<' twice means to restrict to the current subtree or region
(org-let lprops '(funcall type org-match)))
((fboundp type)
(org-let lprops '(funcall type org-match)))
- (t (error "Invalid custom agenda command type %s" type))))
+ (t (user-error "Invalid custom agenda command type %s" type))))
(org-agenda-run-series (nth 1 entry) (cddr entry))))
((equal org-keys "C")
(setq org-agenda-custom-commands org-agenda-custom-commands-orig)
@@ -2554,14 +2824,14 @@ Pressing `<' twice means to restrict to the current subtree or region
t t))
((equal org-keys "L")
(unless (derived-mode-p 'org-mode)
- (error "This is not an Org-mode file"))
+ (user-error "This is not an Org-mode file"))
(unless restriction
(put 'org-agenda-files 'org-restrict (list bfn))
(org-call-with-arg 'org-timeline arg)))
((equal org-keys "#") (call-interactively 'org-agenda-list-stuck-projects))
((equal org-keys "/") (call-interactively 'org-occur-in-agenda-files))
((equal org-keys "!") (customize-variable 'org-stuck-projects))
- (t (error "Invalid agenda key"))))))
+ (t (user-error "Invalid agenda key"))))))
(defun org-agenda-append-agenda ()
"Append another agenda view to the current one.
@@ -2569,14 +2839,16 @@ This function allows interactive building of block agendas.
Agenda views are separated by `org-agenda-block-separator'."
(interactive)
(unless (derived-mode-p 'org-agenda-mode)
- (error "Can only append from within agenda buffer"))
+ (user-error "Can only append from within agenda buffer"))
(let ((org-agenda-multi t))
(org-agenda)
(widen)
(org-agenda-finalize)
+ (setq buffer-read-only t)
(org-agenda-fit-window-to-buffer)))
(defun org-agenda-normalize-custom-commands (cmds)
+ "Normalize custom commands CMDS."
(delq nil
(mapcar
(lambda (x)
@@ -2621,7 +2893,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
(add-text-properties (match-beginning 2) (match-end 2)
'(face bold) header))
header)))
- (setq header-end (move-marker (make-marker) (point)))
+ (setq header-end (point-marker))
(while t
(setq custom1 custom)
(when (eq rmheader t)
@@ -2651,6 +2923,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
(cond
((string-match "\\S-" desc) desc)
((eq type 'agenda) "Agenda for current week or day")
+ ((eq type 'agenda*) "Appointments for current week or day")
((eq type 'alltodo) "List of all TODO entries")
((eq type 'search) "Word search")
((eq type 'stuck) "List of stuck projects")
@@ -2774,7 +3047,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
(org-agenda-get-restriction-and-command prefix-descriptions))
((equal c ?q) (error "Abort"))
- (t (error "Invalid key %c" c))))))))
+ (t (user-error "Invalid key %c" c))))))))
(defun org-agenda-fit-window-to-buffer ()
"Fit the window to the buffer size."
@@ -2790,6 +3063,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
(defvar org-agenda-overriding-arguments nil)
(defvar org-agenda-overriding-cmd-arguments nil)
(defun org-agenda-run-series (name series)
+ "Run agenda NAME as a SERIES of agenda commands."
(org-let (nth 1 series) '(org-agenda-prepare name))
;; We need to reset agenda markers here, because when constructing a
;; block agenda, the individual blocks do not do that.
@@ -2812,6 +3086,9 @@ L Timeline for current buffer # List stuck projects (!=configure)
((eq type 'agenda)
(org-let2 gprops lprops
'(call-interactively 'org-agenda-list)))
+ ((eq type 'agenda*)
+ (org-let2 gprops lprops
+ '(funcall 'org-agenda-list nil nil t)))
((eq type 'alltodo)
(org-let2 gprops lprops
'(call-interactively 'org-todo-list)))
@@ -2837,7 +3114,7 @@ L Timeline for current buffer # List stuck projects (!=configure)
(widen)
(let ((inhibit-read-only t))
(add-text-properties (point-min) (point-max)
- `(org-serie t org-serie-redo-cmd ,redo)))
+ `(org-series t org-series-redo-cmd ,redo)))
(setq org-agenda-redo-command redo)
(goto-char (point-min)))
(org-agenda-fit-window-to-buffer)
@@ -2852,12 +3129,12 @@ longer string it is used as a tags/todo match string.
Parameters are alternating variable names and values that will be bound
before running the agenda command."
(org-eval-in-environment (org-make-parameter-alist parameters)
- (if (> (length cmd-key) 2)
- (org-tags-view nil cmd-key)
- (org-agenda nil cmd-key)))
+ (let (org-agenda-sticky)
+ (if (> (length cmd-key) 2)
+ (org-tags-view nil cmd-key)
+ (org-agenda nil cmd-key))))
(set-buffer org-agenda-buffer-name)
(princ (buffer-string)))
-(def-edebug-spec org-batch-agenda (form &rest sexp))
(defvar org-agenda-info nil)
@@ -2915,7 +3192,6 @@ agenda-day The day in the agenda where this is listed"
priority-letter priority agenda-day)
","))
(princ "\n")))))
-(def-edebug-spec org-batch-agenda-csv (form &rest sexp))
(defun org-fix-agenda-info (props)
"Make sure all properties on an agenda item have a canonical form.
@@ -2961,6 +3237,7 @@ This ensures the export commands can easily use it."
;;;###autoload
(defun org-store-agenda-views (&rest parameters)
+ "Store agenda views."
(interactive)
(eval (list 'org-batch-store-agenda-views)))
@@ -2998,7 +3275,6 @@ This ensures the export commands can easily use it."
(org-agenda-write (expand-file-name (pop files) dir) nil t bufname)))
(and (get-buffer bufname)
(kill-buffer bufname)))))))
-(def-edebug-spec org-batch-store-agenda-views (&rest sexp))
(defvar org-agenda-current-span nil
"The current span used in the agenda view.") ; local variable in the agenda buffer
@@ -3017,10 +3293,12 @@ This ensures the export commands can easily use it."
(defun org-agenda-write (file &optional open nosettings agenda-bufname)
"Write the current buffer (an agenda view) as a file.
Depending on the extension of the file name, plain text (.txt),
-HTML (.html or .htm) or Postscript (.ps) is produced.
+HTML (.html or .htm), PDF (.pdf) or Postscript (.ps) is produced.
If the extension is .ics, run icalendar export over all files used
to construct the agenda and limit the export to entries listed in the
agenda now.
+If the extension is .org, collect all subtrees corresponding to the
+agenda entries and add them in an .org file.
With prefix argument OPEN, open the new file immediately.
If NOSETTINGS is given, do not scope the settings of
`org-agenda-exporter-settings' into the export commands. This is used when
@@ -3028,13 +3306,16 @@ the settings have already been scoped and we do not wish to overrule other,
higher priority settings.
If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(interactive "FWrite agenda to file: \nP")
- (if (not (file-writable-p file))
- (error "Cannot write agenda to file %s" file))
+ (if (or (not (file-writable-p file))
+ (and (file-exists-p file)
+ (if (org-called-interactively-p 'any)
+ (not (y-or-n-p (format "Overwrite existing file %s? " file))))))
+ (user-error "Cannot write agenda to file %s" file))
(org-let (if nosettings nil org-agenda-exporter-settings)
'(save-excursion
(save-window-excursion
(org-agenda-mark-filtered-text)
- (let ((bs (copy-sequence (buffer-string))) beg)
+ (let ((bs (copy-sequence (buffer-string))) beg content)
(org-agenda-unmark-filtered-text)
(with-temp-buffer
(rename-buffer org-agenda-write-buffer-name t)
@@ -3050,6 +3331,25 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(cond
((org-bound-and-true-p org-mobile-creating-agendas)
(org-mobile-write-agenda-for-mobile file))
+ ((string-match "\\.org\\'" file)
+ (let (content p m message-log-max)
+ (goto-char (point-min))
+ (while (setq p (next-single-property-change (point) 'org-hd-marker nil))
+ (goto-char p)
+ (setq m (get-text-property (point) 'org-hd-marker))
+ (when m
+ (push (save-excursion
+ (set-buffer (marker-buffer m))
+ (goto-char m)
+ (org-copy-subtree 1 nil t t)
+ org-subtree-clip)
+ content)))
+ (find-file file)
+ (erase-buffer)
+ (mapcar (lambda (s) (org-paste-subtree 1 s)) (reverse content))
+ (write-file file)
+ (kill-buffer (current-buffer))
+ (message "Org file written to %s" file)))
((string-match "\\.html?\\'" file)
(require 'htmlize)
(set-buffer (htmlize-buffer (current-buffer)))
@@ -3077,14 +3377,8 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(delete-file (concat (file-name-sans-extension file) ".ps"))
(message "PDF written to %s" file))
((string-match "\\.ics\\'" file)
- (require 'org-icalendar)
- (let ((org-agenda-marker-table
- (org-create-marker-find-array
- (org-agenda-collect-markers)))
- (org-icalendar-verify-function 'org-check-agenda-marker-table)
- (org-combined-agenda-icalendar-file file))
- (apply 'org-export-icalendar 'combine
- (org-agenda-files nil 'ifmode))))
+ (require 'ox-icalendar)
+ (org-icalendar-export-current-agenda (expand-file-name file)))
(t
(let ((bs (buffer-string)))
(find-file file)
@@ -3094,12 +3388,13 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(kill-buffer (current-buffer))
(message "Plain text written to %s" file))))))))
(set-buffer (or agenda-bufname
- (and (called-interactively-p 'any) (buffer-name))
+ (and (org-called-interactively-p 'any) (buffer-name))
org-agenda-buffer-name)))
(when open (org-open-file file)))
(defvar org-agenda-tag-filter-overlays nil)
(defvar org-agenda-cat-filter-overlays nil)
+(defvar org-agenda-re-filter-overlays nil)
(defun org-agenda-mark-filtered-text ()
"Mark all text hidden by filtering with a text property."
@@ -3111,7 +3406,8 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(overlay-start o) (overlay-end o)
'org-filtered t)))
(append org-agenda-tag-filter-overlays
- org-agenda-cat-filter-overlays))))
+ org-agenda-cat-filter-overlays
+ org-agenda-re-filter-overlays))))
(defun org-agenda-unmark-filtered-text ()
"Remove the filtering text property."
@@ -3235,43 +3531,6 @@ removed from the entry content. Currently only `planning' is allowed here."
(setq txt (buffer-substring (point-min) (point)))))))))
txt))
-(defun org-agenda-collect-markers ()
- "Collect the markers pointing to entries in the agenda buffer."
- (let (m markers)
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (when (setq m (or (org-get-at-bol 'org-hd-marker)
- (org-get-at-bol 'org-marker)))
- (push m markers))
- (beginning-of-line 2)))
- (nreverse markers)))
-
-(defun org-create-marker-find-array (marker-list)
- "Create a alist of files names with all marker positions in that file."
- (let (f tbl m a p)
- (while (setq m (pop marker-list))
- (setq p (marker-position m)
- f (buffer-file-name (or (buffer-base-buffer
- (marker-buffer m))
- (marker-buffer m))))
- (if (setq a (assoc f tbl))
- (push (marker-position m) (cdr a))
- (push (list f p) tbl)))
- (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
- tbl)))
-
-(defvar org-agenda-marker-table nil) ; dynamically scoped parameter
-(defun org-check-agenda-marker-table ()
- "Check of the current entry is on the marker list."
- (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
- a)
- (and (setq a (assoc file org-agenda-marker-table))
- (save-match-data
- (save-excursion
- (org-back-to-heading t)
- (member (point) (cdr a)))))))
-
(defun org-check-for-org-mode ()
"Make sure current buffer is in org-mode. Error if not."
(or (derived-mode-p 'org-mode)
@@ -3286,7 +3545,8 @@ removed from the entry content. Currently only `planning' is allowed here."
(defvar org-agenda-name nil)
(defvar org-agenda-tag-filter nil)
(defvar org-agenda-category-filter nil)
-(defvar org-agenda-top-category-filter nil)
+(defvar org-agenda-regexp-filter nil)
+(defvar org-agenda-top-headline-filter nil)
(defvar org-agenda-tag-filter-while-redo nil)
(defvar org-agenda-tag-filter-preset nil
"A preset of the tags filter used for secondary agenda filtering.
@@ -3308,6 +3568,15 @@ the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.")
+(defvar org-agenda-regexp-filter-preset nil
+ "A preset of the regexp filter used for secondary agenda filtering.
+This must be a list of strings, each string must be a single category
+preceded by \"+\" or \"-\".
+This variable should not be set directly, but agenda custom commands can
+bind it in the options section. The preset filter is a global property of
+the entire agenda view. In a block agenda, it will not work reliably to
+define a filter for one of the individual blocks. You need to set it in
+the global options and expect it to be applied to the entire view.")
(defun org-agenda-use-sticky-p ()
"Return non-nil if an agenda buffer named
@@ -3366,11 +3635,14 @@ generating a new one."
(setq org-drawers-for-agenda nil)
(unless org-agenda-persistent-filter
(setq org-agenda-tag-filter nil
- org-agenda-category-filter nil))
+ org-agenda-category-filter nil
+ org-agenda-regexp-filter nil))
(put 'org-agenda-tag-filter :preset-filter
org-agenda-tag-filter-preset)
(put 'org-agenda-category-filter :preset-filter
org-agenda-category-filter-preset)
+ (put 'org-agenda-regexp-filter :preset-filter
+ org-agenda-regexp-filter-preset)
(if org-agenda-multi
(progn
(setq buffer-read-only nil)
@@ -3414,44 +3686,72 @@ generating a new one."
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
- (while (org-activate-bracket-links (point-max))
- (add-text-properties (match-beginning 0) (match-end 0)
- '(face org-link)))
- (org-agenda-align-tags)
+ (save-excursion
+ (while (org-activate-bracket-links (point-max))
+ (add-text-properties (match-beginning 0) (match-end 0)
+ '(face org-link))))
+ (save-excursion
+ (while (org-activate-plain-links (point-max))
+ (add-text-properties (match-beginning 0) (match-end 0)
+ '(face org-link))))
+ (unless (eq org-agenda-remove-tags t)
+ (org-agenda-align-tags))
(unless org-agenda-with-colors
- (remove-text-properties (point-min) (point-max) '(face nil))))
- (if (and (boundp 'org-agenda-overriding-columns-format)
- org-agenda-overriding-columns-format)
- (org-set-local 'org-agenda-overriding-columns-format
- org-agenda-overriding-columns-format))
- (if (and (boundp 'org-agenda-view-columns-initially)
- org-agenda-view-columns-initially)
- (org-agenda-columns))
- (when org-agenda-fontify-priorities
- (org-agenda-fontify-priorities))
- (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
- (org-agenda-dim-blocked-tasks))
- (org-agenda-mark-clocking-task)
- (when org-agenda-entry-text-mode
- (org-agenda-entry-text-hide)
- (org-agenda-entry-text-show))
- (if (functionp 'org-habit-insert-consistency-graphs)
- (org-habit-insert-consistency-graphs))
- (let ((inhibit-read-only t))
- (run-hooks 'org-agenda-finalize-hook))
- (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
- (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
- (org-agenda-filter-apply org-agenda-tag-filter 'tag))
- (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
- (org-agenda-filter-apply org-agenda-category-filter 'category))
- (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local))))
+ (remove-text-properties (point-min) (point-max) '(face nil)))
+ (if (and (boundp 'org-agenda-overriding-columns-format)
+ org-agenda-overriding-columns-format)
+ (org-set-local 'org-agenda-overriding-columns-format
+ org-agenda-overriding-columns-format))
+ (if (and (boundp 'org-agenda-view-columns-initially)
+ org-agenda-view-columns-initially)
+ (org-agenda-columns))
+ (when org-agenda-fontify-priorities
+ (org-agenda-fontify-priorities))
+ (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
+ (org-agenda-dim-blocked-tasks))
+ ;; We need to widen when `org-agenda-finalize' is called from
+ ;; `org-agenda-change-all-lines' (e.g. in `org-agenda-clock-in')
+ (when org-clock-current-task
+ (save-restriction
+ (widen)
+ (org-agenda-mark-clocking-task)))
+ (when org-agenda-entry-text-mode
+ (org-agenda-entry-text-hide)
+ (org-agenda-entry-text-show))
+ (if (and (functionp 'org-habit-insert-consistency-graphs)
+ (save-excursion (next-single-property-change (point-min) 'org-habit-p)))
+ (org-habit-insert-consistency-graphs))
+ (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
+ (unless (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq org-agenda-type org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (and (listp org-agenda-use-tag-inheritance)
+ (not (memq org-agenda-type
+ org-agenda-use-tag-inheritance))))))
+ (let (mrk)
+ (save-excursion
+ (goto-char (point-min))
+ (while (equal (forward-line) 0)
+ (when (setq mrk (or (get-text-property (point) 'org-hd-marker)
+ (get-text-property (point) 'org-hd-marker)))
+ (put-text-property (point-at-bol) (point-at-eol)
+ 'tags (org-with-point-at mrk
+ (delete-dups
+ (mapcar 'downcase (org-get-tags-at))))))))))
+ (run-hooks 'org-agenda-finalize-hook)
+ (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
+ (org-agenda-filter-apply org-agenda-tag-filter 'tag))
+ (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
+ (org-agenda-filter-apply org-agenda-category-filter 'category))
+ (when (or org-agenda-regexp-filter (get 'org-agenda-regexp-filter :preset-filter))
+ (org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
+ (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)))))
(defun org-agenda-mark-clocking-task ()
"Mark the current clock entry in the agenda if it is present."
- (mapc (lambda (o)
- (if (eq (overlay-get o 'type) 'org-agenda-clocking)
- (delete-overlay o)))
- (overlays-in (point-min) (point-max)))
+ (org-agenda-unmark-clocking-task)
(when (marker-buffer org-clock-hd-marker)
(save-excursion
(goto-char (point-min))
@@ -3466,6 +3766,13 @@ generating a new one."
(overlay-put ov 'help-echo
"The clock is running in this item")))))))
+(defun org-agenda-unmark-clocking-task ()
+ "Unmark the current clocking task."
+ (mapc (lambda (o)
+ (if (eq (overlay-get o 'type) 'org-agenda-clocking)
+ (delete-overlay o)))
+ (overlays-in (point-min) (point-max))))
+
(defun org-agenda-fontify-priorities ()
"Make highest priority lines bold, and lowest italic."
(interactive)
@@ -3473,8 +3780,7 @@ generating a new one."
(delete-overlay o)))
(overlays-in (point-min) (point-max)))
(save-excursion
- (let ((inhibit-read-only t)
- b e p ov h l)
+ (let (b e p ov h l)
(goto-char (point-min))
(while (re-search-forward "\\[#\\(.\\)\\]" nil t)
(setq h (or (get-char-property (point) 'org-highest-priority)
@@ -3489,26 +3795,33 @@ generating a new one."
ov (make-overlay b e))
(overlay-put
ov 'face
- (cond ((org-face-from-face-or-color
- 'priority nil
- (cdr (assoc p org-priority-faces))))
- ((and (listp org-agenda-fontify-priorities)
- (org-face-from-face-or-color
- 'priority nil
- (cdr (assoc p org-agenda-fontify-priorities)))))
- ((equal p l) 'italic)
- ((equal p h) 'bold)))
+ (cons (cond ((org-face-from-face-or-color
+ 'priority nil
+ (cdr (assoc p org-priority-faces))))
+ ((and (listp org-agenda-fontify-priorities)
+ (org-face-from-face-or-color
+ 'priority nil
+ (cdr (assoc p org-agenda-fontify-priorities)))))
+ ((equal p l) 'italic)
+ ((equal p h) 'bold))
+ 'org-priority))
(overlay-put ov 'org-type 'org-priority)))))
-(defun org-agenda-dim-blocked-tasks ()
- "Dim currently blocked TODO's in the agenda display."
+(defun org-agenda-dim-blocked-tasks (&optional invisible)
+ "Dim currently blocked TODO's in the agenda display.
+When INVISIBLE is non-nil, hide currently blocked TODO instead of
+dimming them."
+ (interactive "P")
+ (when (org-called-interactively-p 'interactive)
+ (message "Dim or hide blocked tasks..."))
(mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-blocked-todo)
(delete-overlay o)))
(overlays-in (point-min) (point-max)))
(save-excursion
(let ((inhibit-read-only t)
(org-depend-tag-blocked nil)
- (invis (eq org-agenda-dim-blocked-tasks 'invisible))
+ (invis (or (not (null invisible))
+ (eq org-agenda-dim-blocked-tasks 'invisible)))
org-blocked-by-checkboxes
invis1 b e p ov h l)
(goto-char (point-min))
@@ -3529,7 +3842,9 @@ generating a new one."
(if invis1
(overlay-put ov 'invisible t)
(overlay-put ov 'face 'org-agenda-dimmed-todo-face))
- (overlay-put ov 'org-type 'org-blocked-todo)))))))
+ (overlay-put ov 'org-type 'org-blocked-todo))))))
+ (when (org-called-interactively-p 'interactive)
+ (message "Dim or hide blocked tasks...done")))
(defvar org-agenda-skip-function nil
"Function to be called at each match during agenda construction.
@@ -3549,23 +3864,22 @@ A good way to set it is through options in `org-agenda-custom-commands'.")
Also moves point to the end of the skipped region, so that search can
continue from there."
(let ((p (point-at-bol)) to)
- (when (org-in-src-block-p) (throw :skip t))
- (and org-agenda-skip-archived-trees (not org-agenda-archives-mode)
- (get-text-property p :org-archived)
- (org-end-of-subtree t)
- (throw :skip t))
- (and org-agenda-skip-comment-trees
- (get-text-property p :org-comment)
- (org-end-of-subtree t)
- (throw :skip t))
- (if (equal (char-after p) ?#) (throw :skip t))
- (when (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global)
- (org-agenda-skip-eval org-agenda-skip-function)))
- (goto-char to)
+ (when (or
+ (save-excursion (goto-char p) (looking-at comment-start-skip))
+ (and org-agenda-skip-archived-trees (not org-agenda-archives-mode)
+ (get-text-property p :org-archived)
+ (org-end-of-subtree t))
+ (and org-agenda-skip-comment-trees
+ (get-text-property p :org-comment)
+ (org-end-of-subtree t))
+ (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global)
+ (org-agenda-skip-eval org-agenda-skip-function)))
+ (goto-char to))
+ (org-in-src-block-p t))
(throw :skip t))))
(defun org-agenda-skip-eval (form)
- "If FORM is a function or a list, call (or eval) is and return result.
+ "If FORM is a function or a list, call (or eval) it and return the result.
`save-excursion' and `save-match-data' are wrapped around the call, so point
and match data are returned to the previous state no matter what these
functions do."
@@ -3620,7 +3934,8 @@ This check for agenda markers in all agenda buffers currently active."
(error "No marker points to an entry here"))
(setq txt (concat "\n" (org-no-properties
(org-agenda-get-some-entry-text
- m org-agenda-entry-text-maxlines " > "))))
+ m org-agenda-entry-text-maxlines
+ org-agenda-entry-text-leaders))))
(when (string-match "\\S-" txt)
(setq o (make-overlay (point-at-bol) (point-at-eol)))
(overlay-put o 'evaporate t)
@@ -3671,6 +3986,7 @@ dates."
(interactive "P")
(let* ((dopast t)
(org-agenda-show-log-scoped org-agenda-show-log)
+ (org-agenda-show-log org-agenda-show-log-scoped)
(entry (buffer-file-name (or (buffer-base-buffer (current-buffer))
(current-buffer))))
(date (calendar-current-date))
@@ -3687,9 +4003,11 @@ dates."
args
s e rtn d emptyp)
(setq org-agenda-redo-command
- (list 'progn
- (list 'org-switch-to-buffer-other-window (current-buffer))
- (list 'org-timeline (list 'quote dotodo))))
+ (list 'let
+ (list (list 'org-agenda-show-log 'org-agenda-show-log))
+ (list 'org-switch-to-buffer-other-window (current-buffer))
+ (list 'org-timeline (list 'quote dotodo))))
+ (put 'org-agenda-redo-command 'org-lprops nil)
(if (not dopast)
;; Remove past dates from the list of dates.
(setq day-numbers (delq nil (mapcar (lambda(x)
@@ -3740,12 +4058,13 @@ dates."
(put-text-property s (1- (point)) 'org-agenda-date-header t)
(if (equal d today)
(put-text-property s (1- (point)) 'org-today t))
- (and rtn (insert (org-agenda-finalize-entries rtn) "\n"))
+ (and rtn (insert (org-agenda-finalize-entries rtn 'timeline) "\n"))
(put-text-property s (1- (point)) 'day d)))))
- (goto-char (point-min))
(goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
(point-min)))
- (add-text-properties (point-min) (point-max) '(org-agenda-type timeline))
+ (add-text-properties
+ (point-min) (point-max)
+ `(org-agenda-type timeline org-redo-cmd ,org-agenda-redo-command))
(org-agenda-finalize)
(setq buffer-read-only t)))
@@ -3799,46 +4118,16 @@ When EMPTY is non-nil, also include days without any entries."
(defvar org-agenda-start-day nil ; dynamically scoped parameter
"Start day for the agenda view.
-Custom commands can set this variable in the options section.")
+Custom commands can set this variable in the options section.
+This is usually a string like \"2007-11-01\", \"+2d\" or any other
+input allowed when reading a date through the Org calendar.
+See the docstring of `org-read-date' for details.")
(defvar org-starting-day nil) ; local variable in the agenda buffer
(defvar org-arg-loc nil) ; local variable
-(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
- "List of types searched for when creating the daily/weekly agenda.
-This variable is a list of symbols that controls the types of
-items that appear in the daily/weekly agenda. Allowed symbols in this
-list are are
-
- :timestamp List items containing a date stamp or date range matching
- the selected date. This includes sexp entries in
- angular brackets.
-
- :sexp List entries resulting from plain diary-like sexps.
-
- :deadline List deadline due on that date. When the date is today,
- also list any deadlines past due, or due within
- `org-deadline-warning-days'. `:deadline' must appear before
- `:scheduled' if the setting of
- `org-agenda-skip-scheduled-if-deadline-is-shown' is to have
- any effect.
-
- :scheduled List all items which are scheduled for the given date.
- The diary for *today* also contains items which were
- scheduled earlier and are not yet marked DONE.
-
-By default, all four types are turned on.
-
-Never set this variable globally using `setq', because then it
-will apply to all future agenda commands. Instead, bind it with
-`let' to scope it dynamically into the agenda-constructing
-command. A good way to set it is through options in
-`org-agenda-custom-commands'. For a more flexible (though
-somewhat less efficient) way of determining what is included in
-the daily/weekly agenda, see `org-agenda-skip-function'.")
-
(defvar org-agenda-buffer-tmp-name nil)
;;;###autoload
-(defun org-agenda-list (&optional arg start-day span)
+(defun org-agenda-list (&optional arg start-day span with-hour)
"Produce a daily/weekly view from all files in variable `org-agenda-files'.
The view will be for the current day or week, but from the overview buffer
you will be able to go to other days/weeks.
@@ -3848,7 +4137,10 @@ span ARG days. Lisp programs should instead specify SPAN to change
the number of days. SPAN defaults to `org-agenda-span'.
START-DAY defaults to TODAY, or to the most recent match for the weekday
-given in `org-agenda-start-on-weekday'."
+given in `org-agenda-start-on-weekday'.
+
+When WITH-HOUR is non-nil, only include scheduled and deadline
+items if they have an hour specification like [h]h:mm."
(interactive "P")
(if org-agenda-overriding-arguments
(setq arg (car org-agenda-overriding-arguments)
@@ -3898,7 +4190,7 @@ given in `org-agenda-start-on-weekday'."
s e rtn rtnall file date d start-pos end-pos todayp
clocktable-start clocktable-end filter)
(setq org-agenda-redo-command
- (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span)))
+ (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span) with-hour))
(dotimes (n (1- ndays))
(push (1+ (car day-numbers)) day-numbers))
(setq day-numbers (nreverse day-numbers))
@@ -3941,9 +4233,26 @@ given in `org-agenda-start-on-weekday'."
(catch 'nextfile
(org-check-agenda-file file)
(let ((org-agenda-entry-types org-agenda-entry-types))
- (unless org-agenda-include-deadlines
+ ;; Starred types override non-starred equivalents
+ (when (member :deadline* org-agenda-entry-types)
(setq org-agenda-entry-types
(delq :deadline org-agenda-entry-types)))
+ (when (member :scheduled* org-agenda-entry-types)
+ (setq org-agenda-entry-types
+ (delq :scheduled org-agenda-entry-types)))
+ ;; Honor with-hour
+ (when with-hour
+ (when (member :deadline org-agenda-entry-types)
+ (setq org-agenda-entry-types
+ (delq :deadline org-agenda-entry-types))
+ (push :deadline* org-agenda-entry-types))
+ (when (member :scheduled org-agenda-entry-types)
+ (setq org-agenda-entry-types
+ (delq :scheduled org-agenda-entry-types))
+ (push :scheduled* org-agenda-entry-types)))
+ (unless org-agenda-include-deadlines
+ (setq org-agenda-entry-types
+ (delq :deadline* (delq :deadline org-agenda-entry-types))))
(cond
((memq org-agenda-show-log-scoped '(only clockcheck))
(setq rtn (org-agenda-get-day-entries
@@ -3981,7 +4290,7 @@ given in `org-agenda-start-on-weekday'."
(setq rtnall
(org-agenda-add-time-grid-maybe rtnall ndays todayp))
(if rtnall (insert ;; all entries
- (org-agenda-finalize-entries rtnall)
+ (org-agenda-finalize-entries rtnall 'agenda)
"\n"))
(put-text-property s (1- (point)) 'day d)
(put-text-property s (1- (point)) 'org-day-cnt day-cnt))))
@@ -4002,7 +4311,7 @@ given in `org-agenda-start-on-weekday'."
""
x))
filter ""))))
- (setq tbl (apply 'org-get-clocktable p))
+ (setq tbl (apply 'org-clock-get-clocktable p))
(insert tbl)))
(goto-char (point-min))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
@@ -4019,7 +4328,7 @@ given in `org-agenda-start-on-weekday'."
`(org-agenda-type agenda
org-last-args (,arg ,start-day ,span)
org-redo-cmd ,org-agenda-redo-command
- org-serie-cmd ,org-cmd))
+ org-series-cmd ,org-cmd))
(if (eq org-agenda-show-log-scoped 'clockcheck)
(org-agenda-show-clocking-issues))
(org-agenda-finalize)
@@ -4034,7 +4343,8 @@ given in `org-agenda-start-on-weekday'."
(t n)))
(defun org-agenda-span-to-ndays (span &optional start-day)
- "Return ndays from SPAN, possibly starting at START-DAY."
+ "Return ndays from SPAN, possibly starting at START-DAY.
+START-DAY is an absolute time value."
(cond ((numberp span) span)
((eq span 'day) 1)
((eq span 'week) 7)
@@ -4130,8 +4440,8 @@ in `org-agenda-text-search-extra-files'."
'help-echo (format "mouse-2 or RET jump to location")))
(full-words org-agenda-search-view-force-full-words)
(org-agenda-text-search-extra-files org-agenda-text-search-extra-files)
- regexp rtn rtnall files file pos
- marker category category-pos tags c neg re boolean
+ regexp rtn rtnall files file pos inherited-tags
+ marker category category-pos level tags c neg re boolean
ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str)
(unless (and (not edit-at)
(stringp string)
@@ -4248,7 +4558,7 @@ in `org-agenda-text-search-extra-files'."
(let ((case-fold-search t))
(save-excursion
(save-restriction
- (if org-agenda-restrict
+ (if (eq buffer org-agenda-restrict)
(narrow-to-region org-agenda-restrict-begin
org-agenda-restrict-end)
(widen))
@@ -4259,10 +4569,23 @@ in `org-agenda-text-search-extra-files'."
(goto-char (max (point-min) (1- (point))))
(while (re-search-forward regexp nil t)
(org-back-to-heading t)
+ (while (and org-agenda-search-view-max-outline-level
+ (> (org-reduced-level (org-outline-level))
+ org-agenda-search-view-max-outline-level)
+ (forward-line -1)
+ (outline-back-to-heading t)))
(skip-chars-forward "* ")
(setq beg (point-at-bol)
beg1 (point)
- end (progn (outline-next-heading) (point)))
+ end (progn
+ (outline-next-heading)
+ (while (and org-agenda-search-view-max-outline-level
+ (> (org-reduced-level (org-outline-level))
+ org-agenda-search-view-max-outline-level)
+ (forward-line 1)
+ (outline-next-heading)))
+ (point)))
+
(catch :skip
(goto-char beg)
(org-agenda-skip)
@@ -4283,16 +4606,25 @@ in `org-agenda-text-search-extra-files'."
(goto-char beg)
(setq marker (org-agenda-new-marker (point))
category (org-get-category)
+ level (make-string (org-reduced-level (org-outline-level)) ? )
category-pos (get-text-property (point) 'org-category-position)
- tags (org-get-tags-at (point))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'todo org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'todo org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at nil (not inherited-tags))
txt (org-agenda-format-item
""
(buffer-substring-no-properties
beg1 (point-at-eol))
- category tags t))
+ level category tags t))
(org-add-props txt props
'org-marker marker 'org-hd-marker marker
'org-todo-regexp org-todo-regexp
+ 'level level
'org-complex-heading-regexp org-complex-heading-regexp
'priority 1000 'org-category category
'org-category-position category-pos
@@ -4317,19 +4649,31 @@ in `org-agenda-text-search-extra-files'."
(list 'face 'org-agenda-structure))))
(org-agenda-mark-header-line (point-min))
(when rtnall
- (insert (org-agenda-finalize-entries rtnall) "\n"))
+ (insert (org-agenda-finalize-entries rtnall 'search) "\n"))
(goto-char (point-min))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type search
org-last-args (,todo-only ,string ,edit-at)
org-redo-cmd ,org-agenda-redo-command
- org-serie-cmd ,org-cmd))
+ org-series-cmd ,org-cmd))
(org-agenda-finalize)
(setq buffer-read-only t))))
;;; Agenda TODO list
+(defun org-agenda-propertize-selected-todo-keywords (keywords)
+ "Use `org-todo-keyword-faces' for the selected todo KEYWORDS."
+ (concat
+ (if (or (equal keywords "ALL") (not keywords))
+ (propertize "ALL" 'face 'warning)
+ (mapconcat
+ (lambda (kw)
+ (propertize kw 'face (org-get-todo-face kw)))
+ (org-split-string keywords "|")
+ "|"))
+ "\n"))
+
(defvar org-select-this-todo-keyword nil)
(defvar org-last-arg nil)
@@ -4390,9 +4734,8 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
(concat "ToDo: "
(or org-select-this-todo-keyword "ALL"))))
(org-agenda-mark-header-line (point-min))
- (setq pos (point))
- (insert (or org-select-this-todo-keyword "ALL") "\n")
- (add-text-properties pos (1- (point)) (list 'face 'org-warning))
+ (insert (org-agenda-propertize-selected-todo-keywords
+ org-select-this-todo-keyword))
(setq pos (point))
(unless org-agenda-multi
(insert "Available with `N r': (0)[ALL]")
@@ -4407,14 +4750,14 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
(add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))
(org-agenda-mark-header-line (point-min))
(when rtnall
- (insert (org-agenda-finalize-entries rtnall) "\n"))
+ (insert (org-agenda-finalize-entries rtnall 'todo) "\n"))
(goto-char (point-min))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type todo
org-last-args ,arg
org-redo-cmd ,org-agenda-redo-command
- org-serie-cmd ,org-cmd))
+ org-series-cmd ,org-cmd))
(org-agenda-finalize)
(setq buffer-read-only t))))
@@ -4435,8 +4778,6 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
buffer)
(when (and (stringp match) (not (string-match "\\S-" match)))
(setq match nil))
- (setq matcher (org-make-tags-matcher match)
- match (car matcher) matcher (cdr matcher))
(catch 'exit
(if org-agenda-sticky
(setq org-agenda-buffer-name
@@ -4444,7 +4785,11 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
(format "*Org Agenda(%s:%s)*"
(or org-keys (or (and todo-only "M") "m")) match)
(format "*Org Agenda(%s)*" (or (and todo-only "M") "m")))))
+ ;; Prepare agendas (and `org-tag-alist-for-agenda') before
+ ;; expanding tags within `org-make-tags-matcher'
(org-agenda-prepare (concat "TAGS " match))
+ (setq matcher (org-make-tags-matcher match)
+ match (car matcher) matcher (cdr matcher))
(org-compile-prefix-format 'tags)
(org-set-sorting-strategy 'tags)
(setq org-agenda-query-string match)
@@ -4469,7 +4814,7 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
(error "Agenda file %s is not in `org-mode'" file))
(save-excursion
(save-restriction
- (if org-agenda-restrict
+ (if (eq buffer org-agenda-restrict)
(narrow-to-region org-agenda-restrict-begin
org-agenda-restrict-end)
(widen))
@@ -4492,14 +4837,14 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
(add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))
(org-agenda-mark-header-line (point-min))
(when rtnall
- (insert (org-agenda-finalize-entries rtnall) "\n"))
+ (insert (org-agenda-finalize-entries rtnall 'tags) "\n"))
(goto-char (point-min))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type tags
org-last-args (,todo-only ,match)
org-redo-cmd ,org-agenda-redo-command
- org-serie-cmd ,org-cmd))
+ org-series-cmd ,org-cmd))
(org-agenda-finalize)
(setq buffer-read-only t))))
@@ -4745,7 +5090,7 @@ of what a project is and how to check if it stuck, customize the variable
(pop-up-frames nil)
(diary-list-entries-hook
(cons 'org-diary-default-entry diary-list-entries-hook))
- (diary-file-name-prefix-function nil) ; turn this feature off
+ (diary-file-name-prefix nil) ; turn this feature off
(diary-modify-entry-list-string-function 'org-modify-diary-entry-string)
entries
(org-disable-agenda-to-diary t))
@@ -4781,7 +5126,7 @@ of what a project is and how to check if it stuck, customize the variable
(setq entries
(mapcar
(lambda (x)
- (setq x (org-agenda-format-item "" x "Diary" nil 'time))
+ (setq x (org-agenda-format-item "" x nil "Diary" nil 'time))
;; Extend the text properties to the beginning of the line
(org-add-props x (text-properties-at (1- (length x)) x)
'type "diary" 'date date 'face 'org-agenda-diary))
@@ -4871,8 +5216,8 @@ all files listed in `org-agenda-files' will be checked automatically:
&%%(org-diary)
-If you don't give any arguments (as in the example above), the default
-arguments (:deadline :scheduled :timestamp :sexp) are used.
+If you don't give any arguments (as in the example above), the default value
+of `org-agenda-entry-types' is used: (:deadline :scheduled :timestamp :sexp).
So the example above may also be written as
&%%(org-diary :deadline :timestamp :sexp :scheduled)
@@ -4888,7 +5233,7 @@ function from a program - use `org-agenda-get-day-entries' instead."
(org-agenda-reset-markers))
(org-compile-prefix-format 'agenda)
(org-set-sorting-strategy 'agenda)
- (setq args (or args '(:deadline :scheduled :timestamp :sexp)))
+ (setq args (or args org-agenda-entry-types))
(let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
(list entry)
(org-agenda-files t)))
@@ -4906,8 +5251,11 @@ function from a program - use `org-agenda-get-day-entries' instead."
(while (setq file (pop files))
(setq rtn (apply 'org-agenda-get-day-entries file date args))
(setq results (append results rtn)))
- (if results
- (concat (org-agenda-finalize-entries results) "\n"))))
+ (when results
+ (setq results
+ (mapcar (lambda (i) (replace-regexp-in-string
+ org-bracket-link-regexp "\\3" i)) results))
+ (concat (org-agenda-finalize-entries results) "\n"))))
;;; Agenda entry finders
@@ -4917,7 +5265,7 @@ FILE is the path to a file to be checked for entries. DATE is date like
the one returned by `calendar-current-date'. ARGS are symbols indicating
which kind of entries should be extracted. For details about these, see
the documentation of `org-diary'."
- (setq args (or args '(:deadline :scheduled :timestamp :sexp)))
+ (setq args (or args org-agenda-entry-types))
(let* ((org-startup-folded nil)
(org-startup-align-all-tables nil)
(buffer (if (file-exists-p file)
@@ -4934,7 +5282,7 @@ the documentation of `org-diary'."
(let ((case-fold-search nil))
(save-excursion
(save-restriction
- (if org-agenda-restrict
+ (if (eq buffer org-agenda-restrict)
(narrow-to-region org-agenda-restrict-begin
org-agenda-restrict-end)
(widen))
@@ -4957,16 +5305,29 @@ the documentation of `org-diary'."
((eq arg :scheduled)
(setq rtn (org-agenda-get-scheduled deadline-results))
(setq results (append results rtn)))
+ ((eq arg :scheduled*)
+ (setq rtn (org-agenda-get-scheduled deadline-results t))
+ (setq results (append results rtn)))
((eq arg :closed)
(setq rtn (org-agenda-get-progress))
(setq results (append results rtn)))
((eq arg :deadline)
(setq rtn (org-agenda-get-deadlines))
(setq deadline-results (copy-sequence rtn))
+ (setq results (append results rtn)))
+ ((eq arg :deadline*)
+ (setq rtn (org-agenda-get-deadlines t))
+ (setq deadline-results (copy-sequence rtn))
(setq results (append results rtn))))))))
results))))
+(defsubst org-em (x y list)
+ "Is X or Y a member of LIST?"
+ (or (memq x list) (memq y list)))
+
(defvar org-heading-keyword-regexp-format) ; defined in org.el
+(defvar org-agenda-sorting-strategy-selected nil)
+
(defun org-agenda-get-todos ()
"Return the TODO information for agenda display."
(let* ((props (list 'face nil
@@ -4991,8 +5352,8 @@ the documentation of `org-diary'."
"|")
"\\|") "\\)"))
(t org-not-done-regexp))))
- marker priority category category-pos tags todo-state
- ee txt beg end)
+ marker priority category category-pos level tags todo-state ts-date ts-date-type
+ ee txt beg end inherited-tags todo-state-end-pos)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5000,6 +5361,10 @@ the documentation of `org-diary'."
(beginning-of-line)
(org-agenda-skip)
(setq beg (point) end (save-excursion (outline-next-heading) (point)))
+ (unless (and (setq todo-state (org-get-todo-state))
+ (setq todo-state-end-pos (match-end 2)))
+ (goto-char end)
+ (throw :skip nil))
(when (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item end)
(goto-char (1+ beg))
(or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
@@ -5007,21 +5372,57 @@ the documentation of `org-diary'."
(goto-char (match-beginning 2))
(setq marker (org-agenda-new-marker (match-beginning 0))
category (org-get-category)
+ ts-date (let (ts)
+ (save-match-data
+ (cond ((org-em 'scheduled-up 'scheduled-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "SCHEDULED")
+ ts-date-type " scheduled"))
+ ((org-em 'deadline-up 'deadline-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "DEADLINE")
+ ts-date-type " deadline"))
+ ((org-em 'ts-up 'ts-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "TIMESTAMP")
+ ts-date-type " timestamp"))
+ ((org-em 'tsia-up 'tsia-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (org-entry-get (point) "TIMESTAMP_IA")
+ ts-date-type " timestamp_ia"))
+ ((org-em 'timestamp-up 'timestamp-down
+ org-agenda-sorting-strategy-selected)
+ (setq ts (or (org-entry-get (point) "SCHEDULED")
+ (org-entry-get (point) "DEADLINE")
+ (org-entry-get (point) "TIMESTAMP")
+ (org-entry-get (point) "TIMESTAMP_IA"))
+ ts-date-type ""))
+ (t (setq ts-date-type "")))
+ (when ts (ignore-errors (org-time-string-to-absolute ts)))))
category-pos (get-text-property (point) 'org-category-position)
txt (org-trim
(buffer-substring (match-beginning 2) (match-end 0)))
- tags (org-get-tags-at (point))
- txt (org-agenda-format-item "" txt category tags t)
- priority (1+ (org-get-priority txt))
- todo-state (org-get-todo-state))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'todo org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'todo org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at nil (not inherited-tags))
+ level (make-string (org-reduced-level (org-outline-level)) ? )
+ txt (org-agenda-format-item "" txt level category tags t)
+ priority (1+ (org-get-priority txt)))
(org-add-props txt props
'org-marker marker 'org-hd-marker marker
'priority priority 'org-category category
+ 'level level
+ 'ts-date ts-date
'org-category-position category-pos
- 'type "todo" 'todo-state todo-state)
+ 'type (concat "todo" ts-date-type) 'todo-state todo-state)
(push txt ee)
(if org-agenda-todo-list-sublevels
- (goto-char (match-end 2))
+ (goto-char todo-state-end-pos)
(org-end-of-subtree 'invisible))))
(nreverse ee)))
@@ -5030,12 +5431,12 @@ the documentation of `org-diary'."
This function is invoked if `org-agenda-todo-ignore-deadlines',
`org-agenda-todo-ignore-scheduled' or
`org-agenda-todo-ignore-timestamp' is set to an integer."
- (let ((days (org-days-to-time time)))
+ (let ((days (org-time-stamp-to-now
+ time org-agenda-todo-ignore-time-comparison-use-seconds)))
(if (>= n 0)
(>= days n)
(<= days n))))
-;;;###autoload
(defun org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
(&optional end)
"Do we have a reason to ignore this TODO entry because it has a time stamp?"
@@ -5051,9 +5452,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(re-search-forward org-scheduled-time-regexp end t)
(cond
((eq org-agenda-todo-ignore-scheduled 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-scheduled 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-scheduled)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-scheduled))
@@ -5065,9 +5468,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
((eq org-agenda-todo-ignore-deadlines 'far)
(not (org-deadline-close (match-string 1))))
((eq org-agenda-todo-ignore-deadlines 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-deadlines 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-deadlines)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-deadlines))
@@ -5090,17 +5495,16 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(when (re-search-forward org-ts-regexp nil t)
(cond
((eq org-agenda-todo-ignore-timestamp 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-timestamp 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-timestamp)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-timestamp))
(t))))))))))
-(defconst org-agenda-no-heading-message
- "No heading for this item in buffer or region.")
-
(defun org-agenda-get-timestamps (&optional deadline-results)
"Return the date stamp information for agenda display."
(let* ((props (list 'face 'org-agenda-calendar-event
@@ -5132,13 +5536,15 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
"\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
"\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
marker hdmarker deadlinep scheduledp clockp closedp inactivep
- donep tmp priority category category-pos ee txt timestr tags
- b0 b3 e3 head todo-state end-of-match show-all warntime)
+ donep tmp priority category category-pos level ee txt timestr tags
+ b0 b3 e3 head todo-state end-of-match show-all warntime habitp
+ inherited-tags ts-date)
(goto-char (point-min))
(while (setq end-of-match (re-search-forward regexp nil t))
(setq b0 (match-beginning 0)
b3 (match-beginning 3) e3 (match-end 3)
todo-state (save-match-data (ignore-errors (org-get-todo-state)))
+ habitp (and (functionp 'org-is-habit-p) (save-match-data (org-is-habit-p)))
show-all (or (eq org-agenda-repeating-timestamp-show-all t)
(member todo-state
org-agenda-repeating-timestamp-show-all)))
@@ -5165,7 +5571,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
clockp (and org-agenda-include-inactive-timestamps
(or (string-match org-clock-string tmp)
(string-match "]-+\\'" tmp)))
- warntime (org-entry-get (point) "APPT_WARNTIME")
+ warntime (get-text-property (point) 'org-appt-warntime)
donep (member todo-state org-done-keywords))
(if (or scheduledp deadlinep closedp clockp
(and donep org-agenda-skip-timestamp-if-done))
@@ -5178,24 +5584,34 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
category-pos (get-text-property b0 'org-category-position))
(save-excursion
(if (not (re-search-backward org-outline-regexp-bol nil t))
- (setq txt org-agenda-no-heading-message)
+ (throw :skip nil)
(goto-char (match-beginning 0))
(if (and (eq t org-agenda-skip-timestamp-if-deadline-is-shown)
(assoc (point) deadline-position-alist))
(throw :skip nil))
(setq hdmarker (org-agenda-new-marker)
- tags (org-get-tags-at))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'agenda org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'agenda org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at nil (not inherited-tags))
+ level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq head (or (match-string 1) ""))
(setq txt (org-agenda-format-item
(if inactivep org-agenda-inactive-leader nil)
- head category tags timestr
- remove-re t)))
+ head level category tags timestr
+ remove-re habitp)))
(setq priority (org-get-priority txt))
- (org-add-props txt props
- 'org-marker marker 'org-hd-marker hdmarker)
- (org-add-props txt nil 'priority priority
+ (org-add-props txt props 'priority priority
+ 'org-marker marker 'org-hd-marker hdmarker
'org-category category 'date date
+ 'level level
+ 'ts-date
+ (ignore-errors (org-time-string-to-absolute timestr))
'org-category-position category-pos
'todo-state todo-state
'warntime warntime
@@ -5215,8 +5631,8 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
(regexp "^&?%%(")
- marker category extra category-pos ee txt tags entry
- result beg b sexp sexp-entry todo-state warntime)
+ marker category extra category-pos level ee txt tags entry
+ result beg b sexp sexp-entry todo-state warntime inherited-tags)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5232,12 +5648,20 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(setq result (org-diary-sexp-entry sexp sexp-entry date))
(when result
(setq marker (org-agenda-new-marker beg)
+ level (make-string (org-reduced-level (org-outline-level)) ? )
category (org-get-category beg)
category-pos (get-text-property beg 'org-category-position)
- tags (save-excursion (org-backward-heading-same-level 0)
- (org-get-tags-at))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'agenda org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'agenda org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at nil (not inherited-tags))
todo-state (org-get-todo-state)
- warntime (org-entry-get (point) "APPT_WARNTIME"))
+ warntime (get-text-property (point) 'org-appt-warntime)
+ extra nil)
(dolist (r (if (stringp result)
(list result)
@@ -5249,13 +5673,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(if (string-match "\\S-" r)
(setq txt r)
(setq txt "SEXP entry returned empty string"))
-
- (setq txt (org-agenda-format-item
- extra txt category tags 'time))
- (org-add-props txt props 'org-marker marker)
- (org-add-props txt nil
+ (setq txt (org-agenda-format-item extra txt level category tags 'time))
+ (org-add-props txt props 'org-marker marker
'org-category category 'date date 'todo-state todo-state
'org-category-position category-pos 'tags tags
+ 'level level
'type "sexp" 'warntime warntime)
(push txt ee)))))
(nreverse ee)))
@@ -5285,7 +5707,6 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(org-no-warnings
(let ((calendar-date-style 'european) (european-calendar-style t))
(diary-date day month year mark))))
-(defalias 'org-float 'diary-float)
;; Define the` org-class' function
(defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks)
@@ -5294,10 +5715,12 @@ DAYNAME is a number between 0 (Sunday) and 6 (Saturday).
SKIP-WEEKS is any number of ISO weeks in the block period for which the
item should be skipped. If any of the SKIP-WEEKS arguments is the symbol
`holidays', then any date that is known by the Emacs calendar to be a
-holiday will also be skipped."
+holiday will also be skipped. If SKIP-WEEKS arguments are holiday strings,
+then those holidays will be skipped."
(let* ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1)))
(date2 (calendar-absolute-from-gregorian (list m2 d2 y2)))
- (d (calendar-absolute-from-gregorian date)))
+ (d (calendar-absolute-from-gregorian date))
+ (h (when skip-weeks (calendar-check-holidays date))))
(and
(<= date1 d)
(<= d date2)
@@ -5306,8 +5729,8 @@ holiday will also be skipped."
(progn
(require 'cal-iso)
(not (member (car (calendar-iso-from-absolute d)) skip-weeks))))
- (not (and (memq 'holidays skip-weeks)
- (calendar-check-holidays date)))
+ (not (or (and h (memq 'holidays skip-weeks))
+ (delq nil (mapcar (lambda(g) (member g skip-weeks)) h))))
entry)))
(defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks)
@@ -5365,8 +5788,8 @@ please use `org-class' instead."
(list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
1 11))))
(org-agenda-search-headline-for-time nil)
- marker hdmarker priority category category-pos tags closedp
- statep clockp state ee txt extra timestr rest clocked)
+ marker hdmarker priority category category-pos level tags closedp
+ statep clockp state ee txt extra timestr rest clocked inherited-tags)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5401,10 +5824,18 @@ please use `org-class' instead."
(and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
(match-string 1)))))
(if (not (re-search-backward org-outline-regexp-bol nil t))
- (setq txt org-agenda-no-heading-message)
+ (throw :skip nil)
(goto-char (match-beginning 0))
(setq hdmarker (org-agenda-new-marker)
- tags (org-get-tags-at))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'todo org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'todo org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at nil (not inherited-tags))
+ level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq txt (match-string 1))
(when extra
@@ -5417,12 +5848,13 @@ please use `org-class' instead."
(closedp "Closed: ")
(statep (concat "State: (" state ")"))
(t (concat "Clocked: (" clocked ")")))
- txt category tags timestr)))
+ txt level category tags timestr)))
(setq priority 100000)
(org-add-props txt props
'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done
'priority priority 'org-category category
'org-category-position category-pos
+ 'level level
'type "closed" 'date date
'undone-face 'org-warning 'done-face 'org-agenda-done)
(push txt ee))
@@ -5433,7 +5865,8 @@ please use `org-class' instead."
"Add overlays, showing issues with clocking.
See also the user option `org-agenda-clock-consistency-checks'."
(interactive)
- (let* ((pl org-agenda-clock-consistency-checks)
+ (let* ((org-time-clocksum-use-effort-durations nil)
+ (pl org-agenda-clock-consistency-checks)
(re (concat "^[ \t]*"
org-clock-string
"[ \t]+"
@@ -5482,13 +5915,13 @@ See also the user option `org-agenda-clock-consistency-checks'."
((> dt (* 60 maxtime))
;; a very long clocking chunk
(setq issue (format "Clocking interval is very long: %s"
- (org-minutes-to-hh:mm-string
+ (org-minutes-to-clocksum-string
(floor (/ (float dt) 60.))))
face (or (plist-get pl :long-face) face)))
((< dt (* 60 mintime))
;; a very short clocking chunk
(setq issue (format "Clocking interval is very short: %s"
- (org-minutes-to-hh:mm-string
+ (org-minutes-to-clocksum-string
(floor (/ (float dt) 60.))))
face (or (plist-get pl :short-face) face)))
((and (> tlend 0) (< ts tlend))
@@ -5548,8 +5981,10 @@ See also the user option `org-agenda-clock-consistency-checks'."
;; Nope, this gap is not OK
nil)))
-(defun org-agenda-get-deadlines ()
- "Return the deadline information for agenda display."
+(defun org-agenda-get-deadlines (&optional with-hour)
+ "Return the deadline information for agenda display.
+When WITH-HOUR is non-nil, only return deadlines with an hour
+specification like [h]h:mm."
(let* ((props (list 'mouse-face 'highlight
'org-not-done-regexp org-not-done-regexp
'org-todo-regexp org-todo-regexp
@@ -5557,26 +5992,21 @@ See also the user option `org-agenda-clock-consistency-checks'."
'help-echo
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
- (regexp org-deadline-time-regexp)
+ (regexp (if with-hour
+ org-deadline-time-hour-regexp
+ org-deadline-time-regexp))
(todayp (org-agenda-todayp date)) ; DATE bound by calendar
- (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
- d2 diff dfrac wdays pos pos1 category category-pos
+ (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
+ (dl0 (car org-agenda-deadline-leaders))
+ (dl1 (nth 1 org-agenda-deadline-leaders))
+ (dl2 (or (nth 2 org-agenda-deadline-leaders) dl1))
+ d2 diff dfrac wdays pos pos1 category category-pos level
tags suppress-prewarning ee txt head face s todo-state
- show-all upcomingp donep timestr warntime)
+ show-all upcomingp donep timestr warntime inherited-tags ts-date)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
- (setq suppress-prewarning nil)
(catch :skip
(org-agenda-skip)
- (when (and org-agenda-skip-deadline-prewarning-if-scheduled
- (save-match-data
- (string-match org-scheduled-time-regexp
- (buffer-substring (point-at-bol)
- (point-at-eol)))))
- (setq suppress-prewarning
- (if (integerp org-agenda-skip-deadline-prewarning-if-scheduled)
- org-agenda-skip-deadline-prewarning-if-scheduled
- 0)))
(setq s (match-string 1)
txt nil
pos (1- (match-beginning 1))
@@ -5585,10 +6015,32 @@ See also the user option `org-agenda-clock-consistency-checks'."
(member todo-state
org-agenda-repeating-timestamp-show-all))
d2 (org-time-string-to-absolute
- (match-string 1) d1 'past show-all
- (current-buffer) pos)
- diff (- d2 d1)
- wdays (if suppress-prewarning
+ s d1 'past show-all (current-buffer) pos)
+ diff (- d2 d1))
+ (setq suppress-prewarning
+ (let ((ds (and org-agenda-skip-deadline-prewarning-if-scheduled
+ (let ((item (buffer-substring (point-at-bol)
+ (point-at-eol))))
+ (save-match-data
+ (and (string-match
+ org-scheduled-time-regexp item)
+ (match-string 1 item)))))))
+ (cond
+ ((not ds) nil)
+ ;; The current item has a scheduled date (in ds), so
+ ;; evaluate its prewarning lead time.
+ ((integerp org-agenda-skip-deadline-prewarning-if-scheduled)
+ ;; Use global prewarning-restart lead time.
+ org-agenda-skip-deadline-prewarning-if-scheduled)
+ ((eq org-agenda-skip-deadline-prewarning-if-scheduled
+ 'pre-scheduled)
+ ;; Set prewarning to no earlier than scheduled.
+ (min (- d2 (org-time-string-to-absolute
+ ds d1 'past show-all (current-buffer) pos))
+ org-deadline-warning-days))
+ ;; Set prewarning to deadline.
+ (t 0))))
+ (setq wdays (if suppress-prewarning
(let ((org-deadline-warning-days suppress-prewarning))
(org-get-wdays s))
(org-get-wdays s))
@@ -5608,14 +6060,22 @@ See also the user option `org-agenda-clock-consistency-checks'."
(not (= diff 0))))
(setq txt nil)
(setq category (org-get-category)
- warntime (org-entry-get (point) "APPT_WARNTIME")
+ warntime (get-text-property (point) 'org-appt-warntime)
category-pos (get-text-property (point) 'org-category-position))
(if (not (re-search-backward "^\\*+[ \t]+" nil t))
- (setq txt org-agenda-no-heading-message)
+ (throw :skip nil)
(goto-char (match-end 0))
(setq pos1 (match-beginning 0))
- (setq tags (org-get-tags-at pos1))
- (setq head (buffer-substring-no-properties
+ (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
+ (setq inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'agenda org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'agenda org-agenda-use-tag-inheritance))))
+ tags (org-get-tags-at pos1 (not inherited-tags)))
+ (setq head (buffer-substring
(point)
(progn (skip-chars-forward "^\r\n")
(point))))
@@ -5624,22 +6084,25 @@ See also the user option `org-agenda-clock-consistency-checks'."
(concat (substring s (match-beginning 1)) " "))
(setq timestr 'time))
(setq txt (org-agenda-format-item
- (if (= diff 0)
- (car org-agenda-deadline-leaders)
- (if (functionp
- (nth 1 org-agenda-deadline-leaders))
- (funcall
- (nth 1 org-agenda-deadline-leaders)
- diff date)
- (format (nth 1 org-agenda-deadline-leaders)
- diff)))
- head category tags
+ (cond ((= diff 0) dl0)
+ ((> diff 0)
+ (if (functionp dl1)
+ (funcall dl1 diff date)
+ (format dl1 diff)))
+ (t
+ (if (functionp dl2)
+ (funcall dl2 diff date)
+ (format dl2 (if (string= dl2 dl1)
+ diff (abs diff))))))
+ head level category tags
(if (not (= diff 0)) nil timestr)))))
(when txt
(setq face (org-agenda-deadline-face dfrac))
(org-add-props txt props
'org-marker (org-agenda-new-marker pos)
'warntime warntime
+ 'level level
+ 'ts-date d2
'org-hd-marker (org-agenda-new-marker pos1)
'priority (+ (- diff)
(org-get-priority txt))
@@ -5661,8 +6124,10 @@ FRACTION is what fraction of the head-warning time has passed."
(while (setq f (pop faces))
(if (>= fraction (car f)) (throw 'exit (cdr f)))))))
-(defun org-agenda-get-scheduled (&optional deadline-results)
- "Return the scheduled information for agenda display."
+(defun org-agenda-get-scheduled (&optional deadline-results with-hour)
+ "Return the scheduled information for agenda display.
+When WITH-HOUR is non-nil, only return scheduled items with
+an hour specification like [h]h:mm."
(let* ((props (list 'org-not-done-regexp org-not-done-regexp
'org-todo-regexp org-todo-regexp
'org-complex-heading-regexp org-complex-heading-regexp
@@ -5671,7 +6136,9 @@ FRACTION is what fraction of the head-warning time has passed."
'help-echo
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
- (regexp org-scheduled-time-regexp)
+ (regexp (if with-hour
+ org-scheduled-time-hour-regexp
+ org-scheduled-time-regexp))
(todayp (org-agenda-todayp date)) ; DATE bound by calendar
(d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
mm
@@ -5680,9 +6147,10 @@ FRACTION is what fraction of the head-warning time has passed."
0 'org-hd-marker a))
(cons (marker-position mm) a)))
deadline-results))
- d2 diff pos pos1 category category-pos tags donep
+ d2 diff pos pos1 category category-pos level tags donep
ee txt head pastschedp todo-state face timestr s habitp show-all
- did-habit-check-p warntime)
+ did-habit-check-p warntime inherited-tags ts-date suppress-delay
+ ddays)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5695,18 +6163,50 @@ FRACTION is what fraction of the head-warning time has passed."
(member todo-state
org-agenda-repeating-timestamp-show-all))
d2 (org-time-string-to-absolute
- (match-string 1) d1 'past show-all
- (current-buffer) pos)
+ s d1 'past show-all (current-buffer) pos)
diff (- d2 d1)
- warntime (org-entry-get (point) "APPT_WARNTIME"))
+ warntime (get-text-property (point) 'org-appt-warntime))
(setq pastschedp (and todayp (< diff 0)))
(setq did-habit-check-p nil)
+ (setq suppress-delay
+ (let ((ds (and org-agenda-skip-scheduled-delay-if-deadline
+ (let ((item (buffer-substring (point-at-bol) (point-at-eol))))
+ (save-match-data
+ (and (string-match
+ org-deadline-time-regexp item)
+ (match-string 1 item)))))))
+ (cond
+ ((not ds) nil)
+ ;; The current item has a deadline date (in ds), so
+ ;; evaluate its delay time.
+ ((integerp org-agenda-skip-scheduled-delay-if-deadline)
+ ;; Use global delay time.
+ (- org-agenda-skip-scheduled-delay-if-deadline))
+ ((eq org-agenda-skip-scheduled-delay-if-deadline
+ 'post-deadline)
+ ;; Set delay to no later than deadline.
+ (min (- d2 (org-time-string-to-absolute
+ ds d1 'past show-all (current-buffer) pos))
+ org-scheduled-delay-days))
+ (t 0))))
+ (setq ddays (if suppress-delay
+ (let ((org-scheduled-delay-days suppress-delay))
+ (org-get-wdays s t t))
+ (org-get-wdays s t)))
+ ;; Use a delay of 0 when there is a repeater and the delay is
+ ;; of the form --3d
+ (when (and (save-match-data (string-match "--[0-9]+[hdwmy]" s))
+ (< (org-time-string-to-absolute s)
+ (org-time-string-to-absolute
+ s d2 'past nil (current-buffer) pos)))
+ (setq ddays 0))
;; When to show a scheduled item in the calendar:
;; If it is on or past the date.
- (when (or (and (< diff 0)
+ (when (or (and (> ddays 0) (= diff (- ddays)))
+ (and (zerop ddays) (= diff 0))
+ (and (< (+ diff ddays) 0)
(< (abs diff) org-scheduled-past-days)
(and todayp (not org-agenda-only-exact-dates)))
- (= diff 0)
;; org-is-habit-p uses org-entry-get, which is expansive
;; so we go extra mile to only call it once
(and todayp
@@ -5728,8 +6228,12 @@ FRACTION is what fraction of the head-warning time has passed."
(org-is-habit-p))))
(setq category (org-get-category)
category-pos (get-text-property (point) 'org-category-position))
+ (if (and (eq org-agenda-skip-scheduled-if-deadline-is-shown
+ 'repeated-after-deadline)
+ (<= 0 (- d2 (time-to-days (org-get-deadline-time (point))))))
+ (throw :skip nil))
(if (not (re-search-backward "^\\*+[ \t]+" nil t))
- (setq txt org-agenda-no-heading-message)
+ (throw :skip nil)
(goto-char (match-end 0))
(setq pos1 (match-beginning 0))
(if habitp
@@ -5740,12 +6244,21 @@ FRACTION is what fraction of the head-warning time has passed."
(throw :skip nil))
(if (and
(or (eq t org-agenda-skip-scheduled-if-deadline-is-shown)
- (and org-agenda-skip-scheduled-if-deadline-is-shown
+ (and (eq org-agenda-skip-scheduled-if-deadline-is-shown 'not-today)
pastschedp))
(setq mm (assoc pos1 deadline-position-alist)))
(throw :skip nil)))
- (setq tags (org-get-tags-at))
- (setq head (buffer-substring-no-properties
+ (setq inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'agenda org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'agenda org-agenda-use-tag-inheritance))))
+
+ tags (org-get-tags-at nil (not inherited-tags)))
+ (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
+ (setq head (buffer-substring
(point)
(progn (skip-chars-forward "^\r\n") (point))))
(if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
@@ -5757,7 +6270,7 @@ FRACTION is what fraction of the head-warning time has passed."
(car org-agenda-scheduled-leaders)
(format (nth 1 org-agenda-scheduled-leaders)
(- 1 diff)))
- head category tags
+ head level category tags
(if (not (= diff 0)) nil timestr)
nil habitp))))
(when txt
@@ -5775,7 +6288,9 @@ FRACTION is what fraction of the head-warning time has passed."
'org-hd-marker (org-agenda-new-marker pos1)
'type (if pastschedp "past-scheduled" "scheduled")
'date (if pastschedp d2 date)
+ 'ts-date d2
'warntime warntime
+ 'level level
'priority (if habitp
(org-habit-get-priority habitp)
(+ 94 (- 5 diff) (org-get-priority txt)))
@@ -5799,7 +6314,7 @@ FRACTION is what fraction of the head-warning time has passed."
(regexp org-tr-regexp)
(d0 (calendar-absolute-from-gregorian date))
marker hdmarker ee txt d1 d2 s1 s2 category category-pos
- todo-state tags pos head donep)
+ level todo-state tags pos head donep inherited-tags)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5823,10 +6338,19 @@ FRACTION is what fraction of the head-warning time has passed."
(setq category (org-get-category)
category-pos (get-text-property (point) 'org-category-position))
(if (not (re-search-backward org-outline-regexp-bol nil t))
- (setq txt org-agenda-no-heading-message)
+ (throw :skip nil)
(goto-char (match-beginning 0))
- (setq hdmarker (org-agenda-new-marker (point)))
- (setq tags (org-get-tags-at))
+ (setq hdmarker (org-agenda-new-marker (point))
+ inherited-tags
+ (or (eq org-agenda-show-inherited-tags 'always)
+ (and (listp org-agenda-show-inherited-tags)
+ (memq 'agenda org-agenda-show-inherited-tags))
+ (and (eq org-agenda-show-inherited-tags t)
+ (or (eq org-agenda-use-tag-inheritance t)
+ (memq 'agenda org-agenda-use-tag-inheritance))))
+
+ tags (org-get-tags-at nil (not inherited-tags)))
+ (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq head (match-string 1))
(let ((remove-re
@@ -5841,17 +6365,18 @@ FRACTION is what fraction of the head-warning time has passed."
(nth (if (= d1 d2) 0 1)
org-agenda-timerange-leaders)
(1+ (- d0 d1)) (1+ (- d2 d1)))
- head category tags
+ head level category tags
(cond ((and (= d1 d0) (= d2 d0))
(concat "<" start-time ">--<" end-time ">"))
((= d1 d0)
(concat "<" start-time ">"))
((= d2 d0)
(concat "<" end-time ">")))
- remove-re t))))
+ remove-re))))
(org-add-props txt props
'org-marker marker 'org-hd-marker hdmarker
'type "block" 'date date
+ 'level level
'todo-state todo-state
'priority (org-get-priority txt) 'org-category category
'org-category-position category-pos)
@@ -5871,6 +6396,9 @@ The flag is set if the currently compiled format contains a `%T'.")
(defvar org-prefix-has-effort nil
"A flag, set by `org-compile-prefix-format'.
The flag is set if the currently compiled format contains a `%e'.")
+(defvar org-prefix-has-breadcrumbs nil
+ "A flag, set by `org-compile-prefix-format'.
+The flag is set if the currently compiled format contains a `%b'.")
(defvar org-prefix-category-length nil
"Used by `org-compile-prefix-format' to remember the category field width.")
(defvar org-prefix-category-max-length nil
@@ -5884,20 +6412,23 @@ The flag is set if the currently compiled format contains a `%e'.")
(return (cadr entry))
(return (apply 'create-image (cdr entry)))))))
-(defun org-agenda-format-item (extra txt &optional category tags dotime
+(defun org-agenda-format-item (extra txt &optional level category tags dotime
remove-re habitp)
"Format TXT to be inserted into the agenda buffer.
-In particular, it adds the prefix and corresponding text properties. EXTRA
-must be a string and replaces the `%s' specifier in the prefix format.
-CATEGORY (string, symbol or nil) may be used to overrule the default
+In particular, add the prefix and corresponding text properties.
+
+EXTRA must be a string to replace the `%s' specifier in the prefix format.
+LEVEL may be a string to replace the `%l' specifier.
+CATEGORY (a string, a symbol or nil) may be used to overrule the default
category taken from local variable or file name. It will replace the `%c'
-specifier in the format. DOTIME, when non-nil, indicates that a
-time-of-day should be extracted from TXT for sorting of this entry, and for
-the `%t' specifier in the format. When DOTIME is a string, this string is
-searched for a time before TXT is. TAGS can be the tags of the headline.
+specifier in the format.
+DOTIME, when non-nil, indicates that a time-of-day should be extracted from
+TXT for sorting of this entry, and for the `%t' specifier in the format.
+When DOTIME is a string, this string is searched for a time before TXT is.
+TAGS can be the tags of the headline.
Any match of REMOVE-RE will be removed from TXT."
;; We keep the org-prefix-* variable values along with a compiled
- ;; formatter, so that multiple agendas existing at the same time, do
+ ;; formatter, so that multiple agendas existing at the same time do
;; not step on each other toes.
;;
;; It was inconvenient to make these variables buffer local in
@@ -5910,13 +6441,14 @@ Any match of REMOVE-RE will be removed from TXT."
do (set var value))
(save-match-data
;; Diary entries sometimes have extra whitespace at the beginning
- (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt)))
+ (setq txt (org-trim txt))
;; Fix the tags part in txt
(setq txt (org-agenda-fix-displayed-tags
txt tags
org-agenda-show-inherited-tags
org-agenda-hide-tags-regexp))
+
(let* ((category (or category
(if (stringp org-category)
org-category
@@ -5937,7 +6469,7 @@ Any match of REMOVE-RE will be removed from TXT."
(and org-agenda-search-headline-for-time txt))))
(time-of-day (and dotime (org-get-time-of-day ts)))
stamp plain s0 s1 s2 rtn srp l
- duration thecategory)
+ duration thecategory breadcrumbs)
(and (derived-mode-p 'org-mode) buffer-file-name
(add-to-list 'org-agenda-contributing-files buffer-file-name))
(when (and dotime time-of-day)
@@ -5965,10 +6497,12 @@ Any match of REMOVE-RE will be removed from TXT."
(if s2 (setq s2 (org-get-time-of-day s2 'string t)))
;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set
- (when (and s1 (not s2) org-agenda-default-appointment-duration)
- (setq s2
- (org-minutes-to-hh:mm-string
- (+ (org-hh:mm-string-to-minutes s1) org-agenda-default-appointment-duration))))
+ (let (org-time-clocksum-use-effort-durations)
+ (when (and s1 (not s2) org-agenda-default-appointment-duration)
+ (setq s2
+ (org-minutes-to-clocksum-string
+ (+ (org-hh:mm-string-to-minutes s1)
+ org-agenda-default-appointment-duration)))))
;; Compute the duration
(when s2
@@ -5987,17 +6521,15 @@ Any match of REMOVE-RE will be removed from TXT."
(match-string 2 txt))
t t txt))))
(when (derived-mode-p 'org-mode)
- (setq effort
- (condition-case nil
- (org-get-effort
- (or (get-text-property 0 'org-hd-marker txt)
- (get-text-property 0 'org-marker txt)))
- (error nil)))
- (when effort
+ (setq effort (ignore-errors (get-text-property 0 'org-effort txt))))
+
+ ;; org-agenda-add-time-grid-maybe calls us with *Agenda* as
+ ;; current buffer, so move this check outside of above
+ (if effort
(setq neffort (org-duration-string-to-minutes effort)
- effort (setq effort (concat "[" effort "]")))))
- ;; prevent erroring out with %e format when there is no effort
- (or effort (setq effort ""))
+ effort (setq effort (concat "[" effort "]")))
+ ;; prevent erroring out with %e format when there is no effort
+ (setq effort ""))
(when remove-re
(while (string-match remove-re txt)
@@ -6008,6 +6540,10 @@ Any match of REMOVE-RE will be removed from TXT."
(add-text-properties 0 (length txt) '(org-heading t) txt)
;; Prepare the variables needed in the eval of the compiled format
+ (if org-prefix-has-breadcrumbs
+ (setq breadcrumbs (org-with-point-at (org-get-at-bol 'org-marker)
+ (let ((s (org-display-outline-path nil nil "->" t)))
+ (if (eq "" s) "" (concat s "->"))))))
(setq time (cond (s2 (concat
(org-agenda-time-of-day-to-ampm-maybe s1)
"-" (org-agenda-time-of-day-to-ampm-maybe s2)
@@ -6020,7 +6556,8 @@ Any match of REMOVE-RE will be removed from TXT."
(t ""))
extra (or (and (not habitp) extra) "")
category (if (symbolp category) (symbol-name category) category)
- thecategory (copy-sequence category))
+ thecategory (copy-sequence category)
+ level (or level ""))
(if (string-match org-bracket-link-regexp category)
(progn
(setq l (if (match-end 3)
@@ -6048,7 +6585,9 @@ Any match of REMOVE-RE will be removed from TXT."
'duration duration
'effort effort
'effort-minutes neffort
+ 'breadcrumbs breadcrumbs
'txt txt
+ 'level level
'time time
'extra extra
'format org-prefix-format-compiled
@@ -6093,9 +6632,13 @@ The modified list may contain inherited tags, and tags matched by
s))
(defvar org-agenda-sorting-strategy) ;; because the def is in a let form
-(defvar org-agenda-sorting-strategy-selected nil)
(defun org-agenda-add-time-grid-maybe (list ndays todayp)
+ "Add a time-grid for agenda items which need it.
+
+LIST is the list of agenda items formatted by `org-agenda-list'.
+NDAYS is the span of the current agenda view.
+TODAYP is `t' when the current agenda view is on today."
(catch 'exit
(cond ((not org-agenda-use-time-grid) (throw 'exit list))
((and todayp (member 'today (car org-agenda-time-grid))))
@@ -6117,16 +6660,14 @@ The modified list may contain inherited tags, and tags matched by
(unless (and remove (member time have))
(setq time (replace-regexp-in-string " " "0" (format "%04s" time)))
(push (org-agenda-format-item
- nil string "" nil
+ nil string nil "" nil
(concat (substring time 0 -2) ":" (substring time -2)))
new)
(put-text-property
2 (length (car new)) 'face 'org-time-grid (car new))))
(when (and todayp org-agenda-show-current-time-in-grid)
(push (org-agenda-format-item
- nil
- org-agenda-current-time-string
- "" nil
+ nil org-agenda-current-time-string nil "" nil
(format-time-string "%H:%M "))
new)
(put-text-property
@@ -6140,9 +6681,11 @@ The modified list may contain inherited tags, and tags matched by
"Compile the prefix format into a Lisp form that can be evaluated.
The resulting form and associated variable bindings is returned
and stored in the variable `org-prefix-format-compiled'."
- (setq org-prefix-has-time nil org-prefix-has-tag nil
+ (setq org-prefix-has-time nil
+ org-prefix-has-tag nil
org-prefix-category-length nil
- org-prefix-has-effort nil)
+ org-prefix-has-effort nil
+ org-prefix-has-breadcrumbs nil)
(let ((s (cond
((stringp org-agenda-prefix-format)
org-agenda-prefix-format)
@@ -6151,11 +6694,11 @@ and stored in the variable `org-prefix-format-compiled'."
(t " %-12:c%?-12t% s")))
(start 0)
varform vars var e c f opt)
- (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\|(.+)\\)"
+ (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cltseib]\\|(.+)\\)"
s start)
(setq var (or (cdr (assoc (match-string 4 s)
- '(("c" . category) ("t" . time) ("s" . extra)
- ("i" . category-icon) ("T" . tag) ("e" . effort))))
+ '(("c" . category) ("t" . time) ("l" . level) ("s" . extra)
+ ("i" . category-icon) ("T" . tag) ("e" . effort) ("b" . breadcrumbs))))
'eval)
c (or (match-string 3 s) "")
opt (match-beginning 1)
@@ -6163,6 +6706,7 @@ and stored in the variable `org-prefix-format-compiled'."
(if (equal var 'time) (setq org-prefix-has-time t))
(if (equal var 'tag) (setq org-prefix-has-tag t))
(if (equal var 'effort) (setq org-prefix-has-effort t))
+ (if (equal var 'breadcrumbs) (setq org-prefix-has-breadcrumbs t))
(setq f (concat "%" (match-string 2 s) "s"))
(when (equal var 'category)
(setq org-prefix-category-length
@@ -6189,7 +6733,8 @@ and stored in the variable `org-prefix-format-compiled'."
`((org-prefix-has-time ,org-prefix-has-time)
(org-prefix-has-tag ,org-prefix-has-tag)
(org-prefix-category-length ,org-prefix-category-length)
- (org-prefix-has-effort ,org-prefix-has-effort))
+ (org-prefix-has-effort ,org-prefix-has-effort)
+ (org-prefix-has-breadcrumbs ,org-prefix-has-breadcrumbs))
`(format ,s ,@vars))))))
(defun org-set-sorting-strategy (key)
@@ -6249,14 +6794,69 @@ You can also use this function as a filter, by returning nil for lines
you don't want to have in the agenda at all. For this application, you
could bind the variable in the options section of a custom command.")
-(defun org-agenda-finalize-entries (list &optional nosort)
- "Sort and concatenate the agenda items."
- (setq list (mapcar 'org-agenda-highlight-todo list))
- (if nosort
- list
+(defun org-agenda-finalize-entries (list &optional type)
+ "Sort, limit and concatenate the LIST of agenda items.
+The optional argument TYPE tells the agenda type."
+ (let ((max-effort (cond ((listp org-agenda-max-effort)
+ (cdr (assoc type org-agenda-max-effort)))
+ (t org-agenda-max-effort)))
+ (max-todo (cond ((listp org-agenda-max-todos)
+ (cdr (assoc type org-agenda-max-todos)))
+ (t org-agenda-max-todos)))
+ (max-tags (cond ((listp org-agenda-max-tags)
+ (cdr (assoc type org-agenda-max-tags)))
+ (t org-agenda-max-tags)))
+ (max-entries (cond ((listp org-agenda-max-entries)
+ (cdr (assoc type org-agenda-max-entries)))
+ (t org-agenda-max-entries))) l)
(when org-agenda-before-sorting-filter-function
- (setq list (delq nil (mapcar org-agenda-before-sorting-filter-function list))))
- (mapconcat 'identity (sort list 'org-entries-lessp) "\n")))
+ (setq list
+ (delq nil
+ (mapcar
+ org-agenda-before-sorting-filter-function list))))
+ (setq list (mapcar 'org-agenda-highlight-todo list)
+ list (mapcar 'identity (sort list 'org-entries-lessp)))
+ (when max-effort
+ (setq list (org-agenda-limit-entries
+ list 'effort-minutes max-effort 'identity)))
+ (when max-todo
+ (setq list (org-agenda-limit-entries list 'todo-state max-todo)))
+ (when max-tags
+ (setq list (org-agenda-limit-entries list 'tags max-tags)))
+ (when max-entries
+ (setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
+ (mapconcat 'identity list "\n")))
+
+(defun org-agenda-limit-entries (list prop limit &optional fn)
+ "Limit the number of agenda entries."
+ (let ((include (and limit (< limit 0))))
+ (if limit
+ (let ((fun (or fn (lambda (p) (if p 1))))
+ (lim 0))
+ (delq nil
+ (mapcar
+ (lambda (e)
+ (let ((pval (funcall fun (get-text-property 1 prop e))))
+ (if pval (setq lim (+ lim pval)))
+ (cond ((and pval (<= lim (abs limit))) e)
+ ((and include (not pval)) e))))
+ list)))
+ list)))
+
+(defun org-agenda-limit-interactively ()
+ "In agenda, interactively limit entries to various maximums."
+ (interactive)
+ (let* ((max (read-char "Number of [e]ntries [t]odos [T]ags [E]ffort? "))
+ (num (string-to-number (read-from-minibuffer "How many? "))))
+ (cond ((equal max ?e)
+ (let ((org-agenda-max-entries num)) (org-agenda-redo)))
+ ((equal max ?t)
+ (let ((org-agenda-max-todos num)) (org-agenda-redo)))
+ ((equal max ?T)
+ (let ((org-agenda-max-tags num)) (org-agenda-redo)))
+ ((equal max ?E)
+ (let ((org-agenda-max-effort num)) (org-agenda-redo)))))
+ (org-agenda-fit-window-to-buffer))
(defun org-agenda-highlight-todo (x)
(let ((org-done-keywords org-done-keywords-for-agenda)
@@ -6383,6 +6983,20 @@ could bind the variable in the options section of a custom command.")
(cond ((< ta tb) -1)
((< tb ta) +1))))
+(defsubst org-cmp-ts (a b &optional type)
+ "Compare the timestamps values of entries A and B.
+When TYPE is \"scheduled\", \"deadline\", \"timestamp\" or
+\"timestamp_ia\", compare within each of these type. When TYPE
+is the empty string, compare all timestamps without respect of
+their type."
+ (let* ((def (if org-sort-agenda-notime-is-late 9901 -1))
+ (ta (or (and (string-match type (or (get-text-property 1 'type a) ""))
+ (get-text-property 1 'ts-date a)) def))
+ (tb (or (and (string-match type (or (get-text-property 1 'type b) ""))
+ (get-text-property 1 'ts-date b)) def)))
+ (cond ((< ta tb) -1)
+ ((< tb ta) +1))))
+
(defsubst org-cmp-habit-p (a b)
"Compare the todo states of strings A and B."
(let ((ha (get-text-property 1 'org-habit-p a))
@@ -6390,13 +7004,26 @@ could bind the variable in the options section of a custom command.")
(cond ((and ha (not hb)) -1)
((and (not ha) hb) +1))))
-(defsubst org-em (x y list) (or (memq x list) (memq y list)))
-
(defun org-entries-lessp (a b)
"Predicate for sorting agenda entries."
;; The following variables will be used when the form is evaluated.
;; So even though the compiler complains, keep them.
(let* ((ss org-agenda-sorting-strategy-selected)
+ (timestamp-up (and (org-em 'timestamp-up 'timestamp-down ss)
+ (org-cmp-ts a b "")))
+ (timestamp-down (if timestamp-up (- timestamp-up) nil))
+ (scheduled-up (and (org-em 'scheduled-up 'scheduled-down ss)
+ (org-cmp-ts a b "scheduled")))
+ (scheduled-down (if scheduled-up (- scheduled-up) nil))
+ (deadline-up (and (org-em 'deadline-up 'deadline-down ss)
+ (org-cmp-ts a b "deadline")))
+ (deadline-down (if deadline-up (- deadline-up) nil))
+ (tsia-up (and (org-em 'tsia-up 'tsia-down ss)
+ (org-cmp-ts a b "iatimestamp_ia")))
+ (tsia-down (if tsia-up (- tsia-up) nil))
+ (ts-up (and (org-em 'ts-up 'ts-down ss)
+ (org-cmp-ts a b "timestamp")))
+ (ts-down (if ts-up (- ts-up) nil))
(time-up (and (org-em 'time-up 'time-down ss)
(org-cmp-time a b)))
(time-down (if time-up (- time-up) nil))
@@ -6459,15 +7086,19 @@ in the file. Otherwise, restriction will be to the current subtree."
(t 'file)))
(if (eq type 'subtree)
(progn
- (setq org-agenda-restrict t)
+ (setq org-agenda-restrict (current-buffer))
(setq org-agenda-overriding-restriction 'subtree)
(put 'org-agenda-files 'org-restrict
(list (buffer-file-name (buffer-base-buffer))))
(org-back-to-heading t)
- (move-overlay org-agenda-restriction-lock-overlay (point) (point-at-eol))
+ (move-overlay org-agenda-restriction-lock-overlay
+ (point)
+ (if org-agenda-restriction-lock-highlight-subtree
+ (save-excursion (org-end-of-subtree t t) (point))
+ (point-at-eol)))
(move-marker org-agenda-restrict-begin (point))
(move-marker org-agenda-restrict-end
- (save-excursion (org-end-of-subtree t)))
+ (save-excursion (org-end-of-subtree t t)))
(message "Locking agenda restriction to subtree"))
(put 'org-agenda-files 'org-restrict
(list (buffer-file-name (buffer-base-buffer))))
@@ -6510,7 +7141,8 @@ in the file. Otherwise, restriction will be to the current subtree."
(defun org-agenda-check-type (error &rest types)
"Check if agenda buffer is of allowed type.
-If ERROR is non-nil, throw an error, otherwise just return nil."
+If ERROR is non-nil, throw an error, otherwise just return nil.
+Allowed types are 'agenda 'timeline 'todo 'tags 'search."
(if (not org-agenda-type)
(error "No Org agenda currently displayed")
(if (memq org-agenda-type types)
@@ -6519,8 +7151,9 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
(error "Not allowed in %s-type agenda buffers" org-agenda-type)
nil))))
-(defun org-agenda-Quit (&optional arg)
- "Exit agenda by removing the window or the buffer."
+(defun org-agenda-Quit ()
+ "Exit the agenda and kill buffers loaded by `org-agenda'.
+Also restore the window configuration."
(interactive)
(if org-agenda-columns-active
(org-columns-quit)
@@ -6539,6 +7172,7 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
(kill-buffer buf)
(org-columns-remove-overlays)
(setq org-agenda-archives-mode nil)))
+ (setq org-agenda-buffer nil)
;; Maybe restore the pre-agenda window configuration.
(and org-agenda-restore-windows-after-quit
(not (eq org-agenda-window-setup 'other-frame))
@@ -6547,12 +7181,15 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
(setq org-agenda-pre-window-conf nil))))
(defun org-agenda-quit ()
- "Exit agenda by killing agenda buffer or burying it when
-`org-agenda-sticky' is non-NIL"
+ "Exit the agenda and restore the window configuration.
+When `org-agenda-sticky' is non-nil, only bury the agenda."
(interactive)
(if (and (eq org-indirect-buffer-display 'other-window)
org-last-indirect-buffer)
- (delete-window (get-buffer-window org-last-indirect-buffer)))
+ (let ((org-last-indirect-window
+ (get-buffer-window org-last-indirect-buffer)))
+ (if org-last-indirect-window
+ (delete-window org-last-indirect-window))))
(if org-agenda-columns-active
(org-columns-quit)
(if org-agenda-sticky
@@ -6574,18 +7211,18 @@ If ERROR is non-nil, throw an error, otherwise just return nil."
(org-agenda-Quit))))
(defun org-agenda-exit ()
- "Exit agenda by removing the window or the buffer.
-Also kill all Org-mode buffers which have been loaded by `org-agenda'.
-Org-mode buffers visited directly by the user will not be touched."
+ "Exit the agenda and restore the window configuration.
+Also kill Org-mode buffers loaded by `org-agenda'. Org-mode
+buffers visited directly by the user will not be touched."
(interactive)
(org-release-buffers org-agenda-new-buffers)
(setq org-agenda-new-buffers nil)
(org-agenda-Quit))
(defun org-agenda-kill-all-agenda-buffers ()
- "Kill all buffers in `org-agena-mode'.
-This is used when toggling sticky agendas. You can also explicitly invoke it
-with `C-c a C-k'."
+ "Kill all buffers in `org-agenda-mode'.
+This is used when toggling sticky agendas.
+You can also explicitly invoke it with `C-c a C-k'."
(interactive)
(let (blist)
(dolist (buf (buffer-list))
@@ -6613,9 +7250,11 @@ in the agenda."
(org-agenda-keep-modes t)
(tag-filter org-agenda-tag-filter)
(tag-preset (get 'org-agenda-tag-filter :preset-filter))
- (top-cat-filter org-agenda-top-category-filter)
+ (top-hl-filter org-agenda-top-headline-filter)
(cat-filter org-agenda-category-filter)
(cat-preset (get 'org-agenda-category-filter :preset-filter))
+ (re-filter org-agenda-regexp-filter)
+ (re-preset (get 'org-agenda-regexp-filter :preset-filter))
(org-agenda-tag-filter-while-redo (or tag-filter tag-preset))
(cols org-agenda-columns-active)
(line (org-current-line))
@@ -6623,29 +7262,36 @@ in the agenda."
(lprops (get 'org-agenda-redo-command 'org-lprops))
(redo-cmd (get-text-property p 'org-redo-cmd))
(last-args (get-text-property p 'org-last-args))
- (org-agenda-overriding-cmd (get-text-property p 'org-serie-cmd))
+ (org-agenda-overriding-cmd (get-text-property p 'org-series-cmd))
(org-agenda-overriding-cmd-arguments
(unless (eq all t)
(cond ((listp last-args)
(cons (or cpa (car last-args)) (cdr last-args)))
((stringp last-args)
last-args))))
- (serie-redo-cmd (get-text-property p 'org-serie-redo-cmd)))
+ (series-redo-cmd (get-text-property p 'org-series-redo-cmd)))
(put 'org-agenda-tag-filter :preset-filter nil)
(put 'org-agenda-category-filter :preset-filter nil)
+ (put 'org-agenda-regexp-filter :preset-filter nil)
(and cols (org-columns-quit))
(message "Rebuilding agenda buffer...")
- (if serie-redo-cmd
- (eval serie-redo-cmd)
- (org-let lprops '(eval redo-cmd)))
+ (if series-redo-cmd
+ (eval series-redo-cmd)
+ (org-let lprops redo-cmd))
(setq org-agenda-undo-list nil
- org-agenda-pending-undo-list nil)
+ org-agenda-pending-undo-list nil
+ org-agenda-tag-filter tag-filter
+ org-agenda-category-filter cat-filter
+ org-agenda-regexp-filter re-filter
+ org-agenda-top-headline-filter top-hl-filter)
(message "Rebuilding agenda buffer...done")
(put 'org-agenda-tag-filter :preset-filter tag-preset)
(put 'org-agenda-category-filter :preset-filter cat-preset)
+ (put 'org-agenda-regexp-filter :preset-filter re-preset)
(and (or tag-filter tag-preset) (org-agenda-filter-apply tag-filter 'tag))
(and (or cat-filter cat-preset) (org-agenda-filter-apply cat-filter 'category))
- (and top-cat-filter (org-agenda-filter-top-category-apply top-cat-filter))
+ (and (or re-filter re-preset) (org-agenda-filter-apply re-filter 'regexp))
+ (and top-hl-filter (org-agenda-filter-top-headline-apply top-hl-filter))
(and cols (org-called-interactively-p 'any) (org-agenda-columns))
(org-goto-line line)
(recenter window-line)))
@@ -6662,11 +7308,18 @@ The category is that of the current line."
org-agenda-category-filter)
(org-agenda-filter-show-all-cat)
(let ((cat (org-no-properties (get-text-property (point) 'org-category))))
- (if cat (org-agenda-filter-apply
- (list (concat (if strip "-" "+") cat)) 'category)
- (error "No category at point")))))
-
-(defun org-find-top-category (&optional pos)
+ (cond
+ ((and cat strip)
+ (org-agenda-filter-apply
+ (push (concat "-" cat) org-agenda-category-filter) 'category))
+ ((and cat)
+ (org-agenda-filter-apply
+ (setq org-agenda-category-filter
+ (list (concat "+" cat))) 'category))
+ ((error "No category at point"))))))
+
+(defun org-find-top-headline (&optional pos)
+ "Find the topmost parent headline and return it."
(save-excursion
(with-current-buffer (if pos (marker-buffer pos) (current-buffer))
(if pos (goto-char pos))
@@ -6675,21 +7328,49 @@ The category is that of the current line."
(ignore-errors
(nth 4 (org-heading-components))))))
-(defvar org-agenda-filtered-by-top-category nil)
-
-(defun org-agenda-filter-by-top-category (strip)
- "Keep only those lines in the agenda buffer that have a specific category.
-The category is that of the current line."
+(defvar org-agenda-filtered-by-top-headline nil)
+(defun org-agenda-filter-by-top-headline (strip)
+ "Keep only those lines that are descendants from the same top headline.
+The top headline is that of the current line."
(interactive "P")
- (if org-agenda-filtered-by-top-category
+ (if org-agenda-filtered-by-top-headline
(progn
- (setq org-agenda-filtered-by-top-category nil
- org-agenda-top-category-filter nil)
+ (setq org-agenda-filtered-by-top-headline nil
+ org-agenda-top-headline-filter nil)
(org-agenda-filter-show-all-cat))
- (let ((cat (org-find-top-category (org-get-at-bol 'org-hd-marker))))
- (if cat (org-agenda-filter-top-category-apply cat strip)
+ (let ((cat (org-find-top-headline (org-get-at-bol 'org-hd-marker))))
+ (if cat (org-agenda-filter-top-headline-apply cat strip)
(error "No top-level category at point")))))
+(defvar org-agenda-regexp-filter nil)
+(defun org-agenda-filter-by-regexp (strip)
+ "Filter agenda entries by a regular expression.
+Regexp filters are cumulative.
+With no prefix argument, keep entries matching the regexp.
+With one prefix argument, filter out entries matching the regexp.
+With two prefix arguments, remove the regexp filters."
+ (interactive "P")
+ (if (not (equal strip '(16)))
+ (let ((flt (concat (if (equal strip '(4)) "-" "+")
+ (read-from-minibuffer
+ (if (equal strip '(4))
+ "Filter out entries matching regexp: "
+ "Narrow to entries matching regexp: ")))))
+ (push flt org-agenda-regexp-filter)
+ (org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
+ (org-agenda-filter-show-all-re)
+ (message "Regexp filter removed")))
+
+(defun org-agenda-filter-remove-all ()
+ "Remove all filters from the current agenda buffer."
+ (interactive)
+ (when org-agenda-tag-filter
+ (org-agenda-filter-show-all-tag))
+ (when org-agenda-category-filter
+ (org-agenda-filter-show-all-cat))
+ (when org-agenda-regexp-filter
+ (org-agenda-filter-show-all-re)))
+
(defun org-agenda-filter-by-tag (strip &optional char narrow)
"Keep only those lines in the agenda buffer that have a specific tag.
The tag is selected with its fast selection letter, as configured.
@@ -6754,7 +7435,7 @@ to switch to narrowing."
((equal char ?\r)
(org-agenda-filter-show-all-tag)
(when org-agenda-auto-exclude-function
- (setq org-agenda-tag-filter '())
+ (setq org-agenda-tag-filter nil)
(dolist (tag (org-agenda-get-represented-tags))
(let ((modifier (funcall org-agenda-auto-exclude-function tag)))
(if modifier
@@ -6811,29 +7492,59 @@ to switch to narrowing."
(interactive "P")
(org-agenda-filter-by-tag strip char 'refine))
-(defun org-agenda-filter-make-matcher ()
+(defun org-agenda-filter-make-matcher (filter type)
"Create the form that tests a line for agenda filter."
(let (f f1)
- ;; first compute the tag-filter matcher
- (dolist (x (delete-dups
- (append (get 'org-agenda-tag-filter
- :preset-filter) org-agenda-tag-filter)))
- (if (member x '("-" "+"))
- (setq f1 (if (equal x "-") 'tags '(not tags)))
- (if (string-match "[<=>?]" x)
- (setq f1 (org-agenda-filter-effort-form x))
- (setq f1 (list 'member (downcase (substring x 1)) 'tags)))
- (if (equal (string-to-char x) ?-)
- (setq f1 (list 'not f1))))
- (push f1 f))
- ;; then compute the category-filter matcher
- (dolist (x (delete-dups
- (append (get 'org-agenda-category-filter
- :preset-filter) org-agenda-category-filter)))
- (if (equal "-" (substring x 0 1))
- (setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
- (setq f1 (list 'equal (substring x 1) 'cat)))
- (push f1 f))
+ (cond
+ ;; Tag filter
+ ((eq type 'tag)
+ (setq filter
+ (delete-dups
+ (append (get 'org-agenda-tag-filter :preset-filter)
+ filter)))
+ (dolist (x filter)
+ (let ((nfilter (org-agenda-filter-expand-tags filter)) nf nf1
+ (ffunc
+ (lambda (nf0 nf01 fltr notgroup op)
+ (dolist (x fltr)
+ (if (member x '("-" "+"))
+ (setq nf01 (if (equal x "-") 'tags '(not tags)))
+ (if (string-match "[<=>?]" x)
+ (setq nf01 (org-agenda-filter-effort-form x))
+ (setq nf01 (list 'member (downcase (substring x 1))
+ 'tags)))
+ (when (equal (string-to-char x) ?-)
+ (setq nf01 (list 'not nf01))
+ (when (not notgroup) (setq op 'and))))
+ (push nf01 nf0))
+ (if notgroup
+ (push (cons 'and nf0) f)
+ (push (cons (or op 'or) nf0) f)))))
+ (if (equal nfilter filter)
+ (funcall ffunc f1 f filter t nil)
+ (funcall ffunc nf1 nf nfilter nil nil)))))
+ ;; Category filter
+ ((eq type 'category)
+ (setq filter
+ (delete-dups
+ (append (get 'org-agenda-category-filter :preset-filter)
+ filter)))
+ (dolist (x filter)
+ (if (equal "-" (substring x 0 1))
+ (setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
+ (setq f1 (list 'equal (substring x 1) 'cat)))
+ (push f1 f)))
+ ;; Regexp filter
+ ((eq type 'regexp)
+ (setq filter
+ (delete-dups
+ (append (get 'org-agenda-regexp-filter :preset-filter)
+ filter)))
+ (dolist (x filter)
+ (if (equal "-" (substring x 0 1))
+ (setq f1 (list 'not (list 'string-match (substring x 1) 'txt)))
+ (setq f1 (list 'string-match (substring x 1) 'txt)))
+ (push f1 f))))
(cons 'and (nreverse f))))
(defun org-agenda-filter-effort-form (e)
@@ -6858,13 +7569,31 @@ If the line does not have an effort defined, return nil."
(funcall op (or eff (if org-sort-agenda-noeffort-is-high 32767 0))
value))))
+(defun org-agenda-filter-expand-tags (filter &optional no-operator)
+ "Expand group tags in FILTER for the agenda.
+When NO-OPERATOR is non-nil, do not add the + operator to returned tags."
+ (if org-group-tags
+ (let ((case-fold-search t) rtn)
+ (mapc
+ (lambda (f)
+ (let (f0 dir)
+ (if (string-match "^\\([+-]\\)\\(.+\\)" f)
+ (setq dir (match-string 1 f) f0 (match-string 2 f))
+ (setq dir (if no-operator "" "+") f0 f))
+ (setq rtn (append (mapcar (lambda(f1) (concat dir f1))
+ (org-tags-expand f0 t t))
+ rtn))))
+ filter)
+ (reverse rtn))
+ filter))
+
(defun org-agenda-filter-apply (filter type)
"Set FILTER as the new agenda filter and apply it."
- (let (tags cat)
- (if (eq type 'tag)
- (setq org-agenda-tag-filter filter)
- (setq org-agenda-category-filter filter))
- (setq org-agenda-filter-form (org-agenda-filter-make-matcher))
+ ;; Deactivate `org-agenda-entry-text-mode' when filtering
+ (if org-agenda-entry-text-mode (org-agenda-entry-text-mode))
+ (let (tags cat txt)
+ (setq org-agenda-filter-form
+ (org-agenda-filter-make-matcher filter type))
(if (and (eq type 'category)
(not (equal (substring (car filter) 0 1) "-")))
;; Only set `org-agenda-filtered-by-category' to t
@@ -6876,8 +7605,13 @@ If the line does not have an effort defined, return nil."
(while (not (eobp))
(if (org-get-at-bol 'org-marker)
(progn
- (setq tags (org-get-at-bol 'tags) ; used in eval
- cat (get-text-property (point) 'org-category))
+ (setq tags ; used in eval
+ (apply 'append
+ (mapcar (lambda (f)
+ (org-agenda-filter-expand-tags (list f) t))
+ (org-get-at-bol 'tags)))
+ cat (get-text-property (point) 'org-category)
+ txt (get-text-property (point) 'txt))
(if (not (eval org-agenda-filter-form))
(org-agenda-filter-hide-line type))
(beginning-of-line 2))
@@ -6885,32 +7619,33 @@ If the line does not have an effort defined, return nil."
(if (get-char-property (point) 'invisible)
(ignore-errors (org-agenda-previous-line)))))
-(defun org-agenda-filter-top-category-apply (category &optional negative)
- "Set FILTER as the new agenda filter and apply it."
+(defun org-agenda-filter-top-headline-apply (hl &optional negative)
+ "Filter by top headline HL."
(org-agenda-set-mode-name)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(let* ((pos (org-get-at-bol 'org-hd-marker))
- (topcat (and pos (org-find-top-category pos))))
- (if (and topcat (funcall (if negative 'identity 'not)
- (string= category topcat)))
+ (tophl (and pos (org-find-top-headline pos))))
+ (if (and tophl (funcall (if negative 'identity 'not)
+ (string= hl tophl)))
(org-agenda-filter-hide-line 'category)))
(beginning-of-line 2)))
(if (get-char-property (point) 'invisible)
(org-agenda-previous-line))
- (setq org-agenda-top-category-filter category
- org-agenda-filtered-by-top-category t))
+ (setq org-agenda-top-headline-filter hl
+ org-agenda-filtered-by-top-headline t))
(defun org-agenda-filter-hide-line (type)
+ "Hide lines with TYPE in the agenda buffer."
(let (ov)
(setq ov (make-overlay (max (point-min) (1- (point-at-bol)))
(point-at-eol)))
(overlay-put ov 'invisible t)
(overlay-put ov 'type type)
- (if (eq type 'tag)
- (push ov org-agenda-tag-filter-overlays)
- (push ov org-agenda-cat-filter-overlays))))
+ (cond ((eq type 'tag) (push ov org-agenda-tag-filter-overlays))
+ ((eq type 'category) (push ov org-agenda-cat-filter-overlays))
+ ((eq type 'regexp) (push ov org-agenda-re-filter-overlays)))))
(defun org-agenda-fix-tags-filter-overlays-at (&optional pos)
(setq pos (or pos (point)))
@@ -6924,13 +7659,23 @@ If the line does not have an effort defined, return nil."
(overlay-end ov)))))))
(defun org-agenda-filter-show-all-tag nil
+ "Remove tag filter overlays from the agenda buffer."
(mapc 'delete-overlay org-agenda-tag-filter-overlays)
(setq org-agenda-tag-filter-overlays nil
org-agenda-tag-filter nil
org-agenda-filter-form nil)
(org-agenda-set-mode-name))
+(defun org-agenda-filter-show-all-re nil
+ "Remove regexp filter overlays from the agenda buffer."
+ (mapc 'delete-overlay org-agenda-re-filter-overlays)
+ (setq org-agenda-re-filter-overlays nil
+ org-agenda-regexp-filter nil
+ org-agenda-filter-form nil)
+ (org-agenda-set-mode-name))
+
(defun org-agenda-filter-show-all-cat nil
+ "Remove category filter overlays from the agenda buffer."
(mapc 'delete-overlay org-agenda-cat-filter-overlays)
(setq org-agenda-cat-filter-overlays nil
org-agenda-filtered-by-category nil
@@ -6994,23 +7739,31 @@ Negative selection means regexp must not match for selection of an entry."
(let* ((org-read-date-prefer-future
(eval org-agenda-jump-prefer-future))
(date (org-read-date))
+ (day (time-to-days (org-time-string-to-time date)))
(org-agenda-sticky-orig org-agenda-sticky)
(org-agenda-buffer-tmp-name (buffer-name))
(args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
(0-arg (or current-prefix-arg (car args)))
(2-arg (nth 2 args))
+ (with-hour-p (nth 4 org-agenda-redo-command))
(newcmd (list 'org-agenda-list 0-arg date
- (org-agenda-span-to-ndays 2-arg)))
+ (org-agenda-span-to-ndays
+ 2-arg (org-time-string-to-absolute date))
+ with-hour-p))
(newargs (cdr newcmd))
(inhibit-read-only t)
org-agenda-sticky)
(if (not (org-agenda-check-type t 'agenda))
- (error "Not available in non-agenda blocks")
+ (error "Not available in non-agenda views")
(add-text-properties (point-min) (point-max)
`(org-redo-cmd ,newcmd org-last-args ,newargs))
(org-agenda-redo)
- (setq org-agenda-sticky org-agenda-sticky-orig
- org-agenda-this-buffer-is-sticky org-agenda-sticky))))
+ (goto-char (point-min))
+ (while (not (or (= (or (get-text-property (point) 'day) 0) day)
+ (save-excursion (move-beginning-of-line 2) (eobp))))
+ (move-beginning-of-line 2))
+ (setq org-agenda-sticky org-agenda-sticky-orig
+ org-agenda-this-buffer-is-sticky org-agenda-sticky))))
(defun org-agenda-goto-today ()
"Go to today."
@@ -7035,7 +7788,7 @@ Negative selection means regexp must not match for selection of an entry."
(or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt))
(text-property-any (point-min) (point-max) 'org-today t)
(text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
- (and (get-text-property (min (1- (point-max)) (point)) 'org-serie)
+ (and (get-text-property (min (1- (point-max)) (point)) 'org-series)
(org-agenda-goto-block-beginning))
(point-min))))
@@ -7059,7 +7812,7 @@ Negative selection means regexp must not match for selection of an entry."
(move-beginning-of-line 1)))))
(defun org-agenda-later (arg)
- "Go forward in time by thee current span.
+ "Go forward in time by the current span.
With prefix ARG, go forward that many times the current span."
(interactive "p")
(org-agenda-check-type t 'agenda)
@@ -7071,7 +7824,7 @@ With prefix ARG, go forward that many times the current span."
greg2)
(cond
((numberp span)
- (setq sd (+ span sd)))
+ (setq sd (+ (* span arg) sd)))
((eq span 'day)
(setq sd (+ arg sd)))
((eq span 'week)
@@ -7090,7 +7843,7 @@ With prefix ARG, go forward that many times the current span."
;; `cmd' may have been set by `org-agenda-run-series' which
;; uses `org-agenda-overriding-cmd' to decide whether
;; overriding is allowed for `cmd'
- (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
+ (get-text-property (min (1- (point-max)) (point)) 'org-series-cmd))
(org-agenda-overriding-arguments
(list (car args) sd span)))
(org-agenda-redo)
@@ -7137,11 +7890,11 @@ With prefix ARG, go backward that many times the current span."
"Switch to default view for agenda."
(interactive)
(org-agenda-change-time-span (or org-agenda-ndays org-agenda-span)))
-(defun org-agenda-day-view (&optional day-of-year)
+(defun org-agenda-day-view (&optional day-of-month)
"Switch to daily view for agenda.
-With argument DAY-OF-YEAR, switch to that day of the year."
+With argument DAY-OF-MONTH, switch to that day of the month."
(interactive "P")
- (org-agenda-change-time-span 'day day-of-year))
+ (org-agenda-change-time-span 'day day-of-month))
(defun org-agenda-week-view (&optional iso-week)
"Switch to daily view for agenda.
With argument ISO-WEEK, switch to the corresponding ISO week.
@@ -7183,7 +7936,7 @@ SPAN may be `day', `week', `month', `year'."
org-starting-day))
(sd (org-agenda-compute-starting-span sd span n))
(org-agenda-overriding-cmd
- (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
+ (get-text-property (min (1- (point-max)) (point)) 'org-series-cmd))
(org-agenda-overriding-arguments
(list (car args) sd span)))
(org-agenda-redo)
@@ -7291,17 +8044,24 @@ so that the date SD will be in that range."
(defun org-agenda-entry-text-mode (&optional arg)
"Toggle entry text mode in an agenda buffer."
(interactive "P")
- (setq org-agenda-entry-text-mode (or (integerp arg)
- (not org-agenda-entry-text-mode)))
- (org-agenda-entry-text-hide)
- (and org-agenda-entry-text-mode
- (let ((org-agenda-entry-text-maxlines
- (if (integerp arg) arg org-agenda-entry-text-maxlines)))
- (org-agenda-entry-text-show)))
- (org-agenda-set-mode-name)
- (message "Entry text mode is %s. Maximum number of lines is %d"
- (if org-agenda-entry-text-mode "on" "off")
- (if (integerp arg) arg org-agenda-entry-text-maxlines)))
+ (if (or org-agenda-tag-filter
+ org-agenda-category-filter
+ org-agenda-regexp-filter
+ org-agenda-top-headline-filter)
+ (user-error "Can't show entry text in filtered views")
+ (setq org-agenda-entry-text-mode (or (integerp arg)
+ (not org-agenda-entry-text-mode)))
+ (org-agenda-entry-text-hide)
+ (and org-agenda-entry-text-mode
+ (let ((org-agenda-entry-text-maxlines
+ (if (integerp arg) arg org-agenda-entry-text-maxlines)))
+ (org-agenda-entry-text-show)))
+ (org-agenda-set-mode-name)
+ (message "Entry text mode is %s%s"
+ (if org-agenda-entry-text-mode "on" "off")
+ (if (not org-agenda-entry-text-mode) ""
+ (format " (maximum number of lines is %d)"
+ (if (integerp arg) arg org-agenda-entry-text-maxlines))))))
(defun org-agenda-clockreport-mode (&optional with-filter)
"Toggle clocktable mode in an agenda buffer.
@@ -7405,8 +8165,8 @@ When called with a prefix argument, include all archive files as well."
((eq org-agenda-show-log 'clockcheck) " ClkCk")
(org-agenda-show-log " Log")
(t ""))
- (if (or org-agenda-category-filter (get 'org-agenda-category-filter
- :preset-filter))
+ (if (or org-agenda-category-filter
+ (get 'org-agenda-category-filter :preset-filter))
'(:eval (org-propertize
(concat " <"
(mapconcat
@@ -7417,10 +8177,9 @@ When called with a prefix argument, include all archive files as well."
"")
">")
'face 'org-agenda-filter-category
- 'help-echo "Category used in filtering"))
- "")
- (if (or org-agenda-tag-filter (get 'org-agenda-tag-filter
- :preset-filter))
+ 'help-echo "Category used in filtering")) "")
+ (if (or org-agenda-tag-filter
+ (get 'org-agenda-tag-filter :preset-filter))
'(:eval (org-propertize
(concat " {"
(mapconcat
@@ -7431,8 +8190,20 @@ When called with a prefix argument, include all archive files as well."
"")
"}")
'face 'org-agenda-filter-tags
- 'help-echo "Tags used in filtering"))
- "")
+ 'help-echo "Tags used in filtering")) "")
+ (if (or org-agenda-regexp-filter
+ (get 'org-agenda-regexp-filter :preset-filter))
+ '(:eval (org-propertize
+ (concat " ["
+ (mapconcat
+ 'identity
+ (append
+ (get 'org-agenda-regexp-filter :preset-filter)
+ org-agenda-regexp-filter)
+ "")
+ "]")
+ 'face 'org-agenda-filter-regexp
+ 'help-echo "Regexp used in filtering")) "")
(if org-agenda-archives-mode
(if (eq org-agenda-archives-mode t)
" Archives"
@@ -7607,7 +8378,7 @@ Point is in the buffer where the item originated.")
(if (and confirm
(not (y-or-n-p "Archive this subtree or entry? ")))
(error "Abort")
- (save-excursion
+ (save-window-excursion
(goto-char pos)
(let ((org-agenda-buffer-name bufname-orig))
(org-remove-subtree-entries-from-agenda))
@@ -7641,10 +8412,19 @@ If this information is not given, the function uses the tree at point."
(beginning-of-line 0))))))
(defun org-agenda-refile (&optional goto rfloc no-update)
- "Refile the item at point."
+ "Refile the item at point.
+
+When GOTO is 0 or '(64), clear the refile cache.
+When GOTO is '(16), go to the location of the last refiled item.
+RFLOC can be a refile location obtained in a different way.
+When NO-UPDATE is non-nil, don't redo the agenda buffer."
(interactive "P")
- (if (equal goto '(16))
- (org-refile-goto-last-stored)
+ (cond
+ ((member goto '(0 (64)))
+ (org-refile-cache-clear))
+ ((equal goto '(16))
+ (org-refile-goto-last-stored))
+ (t
(let* ((buffer-orig (buffer-name))
(marker (or (org-get-at-bol 'org-hd-marker)
(org-agenda-error)))
@@ -7662,32 +8442,50 @@ If this information is not given, the function uses the tree at point."
(let ((org-agenda-buffer-name buffer-orig))
(org-remove-subtree-entries-from-agenda))
(org-refile goto buffer rfloc)))))
- (unless no-update (org-agenda-redo))))
+ (unless no-update (org-agenda-redo)))))
(defun org-agenda-open-link (&optional arg)
- "Follow the link in the current line, if any.
-This looks for a link in the displayed line in the agenda. It also looks
-at the text of the entry itself."
+ "Open the link(s) in the current entry, if any.
+This looks for a link in the displayed line in the agenda.
+It also looks at the text of the entry itself."
(interactive "P")
(let* ((marker (or (org-get-at-bol 'org-hd-marker)
(org-get-at-bol 'org-marker)))
(buffer (and marker (marker-buffer marker)))
- (prefix (buffer-substring
- (point-at-bol) (point-at-eol))))
+ (prefix (buffer-substring (point-at-bol) (point-at-eol)))
+ (lkall (org-offer-links-in-entry buffer marker arg prefix))
+ (lk0 (car lkall))
+ (lk (if (stringp lk0) (list lk0) lk0))
+ (lkend (cdr lkall))
+ trg)
(cond
- (buffer
- (with-current-buffer buffer
- (save-excursion
- (save-restriction
- (widen)
- (goto-char marker)
- (org-offer-links-in-entry arg prefix)))))
+ ((and buffer lk)
+ (mapcar (lambda(l)
+ (with-current-buffer buffer
+ (setq trg (and (string-match org-bracket-link-regexp l)
+ (match-string 1 l)))
+ (if (or (not trg) (string-match org-any-link-re trg))
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char marker)
+ (when (search-forward l nil lkend)
+ (goto-char (match-beginning 0))
+ (org-open-at-point))))
+ ;; This is an internal link, widen the buffer
+ (switch-to-buffer-other-window buffer)
+ (widen)
+ (goto-char marker)
+ (when (search-forward l nil lkend)
+ (goto-char (match-beginning 0))
+ (org-open-at-point)))))
+ lk))
((or (org-in-regexp (concat "\\(" org-bracket-link-regexp "\\)"))
(save-excursion
(beginning-of-line 1)
(looking-at (concat ".*?\\(" org-bracket-link-regexp "\\)"))))
(org-open-link-from-string (match-string 1)))
- (t (error "No link to open here")))))
+ (t (message "No link to open here")))))
(defun org-agenda-copy-local-variable (var)
"Get a variable from a referenced buffer and install it here."
@@ -8002,7 +8800,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
(save-excursion (save-restriction (widen)
(goto-char hdmarker)
(org-get-tags-at)))))
- props m pl undone-face done-face finish new dotime cat tags)
+ props m pl undone-face done-face finish new dotime level cat tags)
(save-excursion
(goto-char (point-max))
(beginning-of-line 1)
@@ -8014,6 +8812,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
(setq props (text-properties-at (point))
dotime (org-get-at-bol 'dotime)
cat (org-get-at-bol 'org-category)
+ level (org-get-at-bol 'level)
tags thetags
new
(let ((org-prefix-format-compiled
@@ -8024,7 +8823,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
(save-excursion
(save-restriction
(widen)
- (org-agenda-format-item extra newhead cat tags dotime)))))
+ (org-agenda-format-item extra newhead level cat tags dotime)))))
pl (text-property-any (point-at-bol) (point-at-eol) 'org-heading t)
undone-face (org-get-at-bol 'undone-face)
done-face (org-get-at-bol 'done-face))
@@ -8088,35 +8887,37 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
(interactive)
(org-agenda-priority 'down))
-(defun org-agenda-priority (&optional force-direction show)
+(defun org-agenda-priority (&optional force-direction)
"Set the priority of line at point, also in Org-mode file.
This changes the line at point, all other lines in the agenda referring to
-the same tree node, and the headline of the tree node in the Org-mode file."
+the same tree node, and the headline of the tree node in the Org-mode file.
+Called with a universal prefix arg, show the priority instead of setting it."
(interactive "P")
- (if (equal force-direction '(4)) (setq show t))
- (unless org-enable-priority-commands
- (error "Priority commands are disabled"))
- (org-agenda-check-no-diary)
- (let* ((marker (or (org-get-at-bol 'org-marker)
- (org-agenda-error)))
- (hdmarker (org-get-at-bol 'org-hd-marker))
- (buffer (marker-buffer hdmarker))
- (pos (marker-position hdmarker))
- (inhibit-read-only t)
- newhead)
- (org-with-remote-undo buffer
- (with-current-buffer buffer
- (widen)
- (goto-char pos)
- (org-show-context 'agenda)
- (save-excursion
- (and (outline-next-heading)
- (org-flag-heading nil))) ; show the next heading
- (funcall 'org-priority force-direction show)
- (end-of-line 1)
- (setq newhead (org-get-heading)))
- (org-agenda-change-all-lines newhead hdmarker)
- (beginning-of-line 1))))
+ (if (equal force-direction '(4))
+ (org-show-priority)
+ (unless org-enable-priority-commands
+ (error "Priority commands are disabled"))
+ (org-agenda-check-no-diary)
+ (let* ((marker (or (org-get-at-bol 'org-marker)
+ (org-agenda-error)))
+ (hdmarker (org-get-at-bol 'org-hd-marker))
+ (buffer (marker-buffer hdmarker))
+ (pos (marker-position hdmarker))
+ (inhibit-read-only t)
+ newhead)
+ (org-with-remote-undo buffer
+ (with-current-buffer buffer
+ (widen)
+ (goto-char pos)
+ (org-show-context 'agenda)
+ (save-excursion
+ (and (outline-next-heading)
+ (org-flag-heading nil))) ; show the next heading
+ (funcall 'org-priority force-direction)
+ (end-of-line 1)
+ (setq newhead (org-get-heading)))
+ (org-agenda-change-all-lines newhead hdmarker)
+ (beginning-of-line 1)))))
;; FIXME: should fix the tags property of the agenda line.
(defun org-agenda-set-tags (&optional tag onoff)
@@ -8319,9 +9120,8 @@ the same tree node, and the headline of the tree node in the Org-mode file."
(defun org-agenda-show-new-time (marker stamp &optional prefix)
"Show new date stamp via text properties."
;; We use text properties to make this undoable
- (let ((inhibit-read-only t)
- (buffer-invisibility-spec))
- (setq stamp (concat " " prefix " => " stamp))
+ (let ((inhibit-read-only t))
+ (setq stamp (concat prefix " => " stamp " "))
(save-excursion
(goto-char (point-max))
(while (not (bobp))
@@ -8383,8 +9183,8 @@ ARG is passed through to `org-schedule'."
(widen)
(goto-char pos)
(setq ts (org-schedule arg time)))
- (org-agenda-show-new-time marker ts "S"))
- (message "Item scheduled for %s" ts)))
+ (org-agenda-show-new-time marker ts " S"))
+ (message "%s" ts)))
(defun org-agenda-deadline (arg &optional time)
"Schedule the item at point.
@@ -8403,8 +9203,8 @@ ARG is passed through to `org-deadline'."
(widen)
(goto-char pos)
(setq ts (org-deadline arg time)))
- (org-agenda-show-new-time marker ts "D"))
- (message "Deadline for this item set to %s" ts)))
+ (org-agenda-show-new-time marker ts " D"))
+ (message "%s" ts)))
(defun org-agenda-clock-in (&optional arg)
"Start the clock on the currently selected item."
@@ -8414,9 +9214,9 @@ ARG is passed through to `org-deadline'."
(org-clock-in arg)
(let* ((marker (or (org-get-at-bol 'org-marker)
(org-agenda-error)))
- (hdmarker (or (org-get-at-bol 'org-hd-marker)
- marker))
+ (hdmarker (or (org-get-at-bol 'org-hd-marker) marker))
(pos (marker-position marker))
+ (col (current-column))
newhead)
(org-with-remote-undo (marker-buffer marker)
(with-current-buffer (marker-buffer marker)
@@ -8427,14 +9227,15 @@ ARG is passed through to `org-deadline'."
(org-cycle-hide-drawers 'children)
(org-clock-in arg)
(setq newhead (org-get-heading)))
- (org-agenda-change-all-lines newhead hdmarker)))))
+ (org-agenda-change-all-lines newhead hdmarker))
+ (org-move-to-column col))))
(defun org-agenda-clock-out ()
"Stop the currently running clock."
(interactive)
(unless (marker-buffer org-clock-marker)
(error "No running clock"))
- (let ((marker (make-marker)) newhead)
+ (let ((marker (make-marker)) (col (current-column)) newhead)
(org-with-remote-undo (marker-buffer org-clock-marker)
(with-current-buffer (marker-buffer org-clock-marker)
(save-excursion
@@ -8446,13 +9247,15 @@ ARG is passed through to `org-deadline'."
(org-clock-out)
(setq newhead (org-get-heading))))))
(org-agenda-change-all-lines newhead marker)
- (move-marker marker nil)))
+ (move-marker marker nil)
+ (org-move-to-column col)
+ (org-agenda-unmark-clocking-task)))
(defun org-agenda-clock-cancel (&optional arg)
"Cancel the currently running clock."
(interactive "P")
(unless (marker-buffer org-clock-marker)
- (error "No running clock"))
+ (user-error "No running clock"))
(org-with-remote-undo (marker-buffer org-clock-marker)
(org-clock-cancel)))
@@ -8480,7 +9283,7 @@ buffer, display it in another window."
(setq d1 (calendar-cursor-to-date t)
d2 (car calendar-mark-ring))
(setq dp1 (get-text-property (point-at-bol) 'day))
- (unless dp1 (error "No date defined in current line"))
+ (unless dp1 (user-error "No date defined in current line"))
(setq d1 (calendar-gregorian-from-absolute dp1)
d2 (and (ignore-errors (mark))
(save-excursion
@@ -8504,7 +9307,7 @@ buffer, display it in another window."
((equal char ?b)
(setq text (read-string "Block entry: "))
(unless (and d1 d2 (not (equal d1 d2)))
- (error "No block of days selected"))
+ (user-error "No block of days selected"))
(org-agenda-add-entry-to-org-agenda-diary-file 'block text d1 d2)
(and (equal (buffer-name) org-agenda-buffer-name) (org-agenda-redo)))
((equal char ?j)
@@ -8513,7 +9316,7 @@ buffer, display it in another window."
(require 'org-datetree)
(org-datetree-find-date-create d1)
(org-reveal t))
- (t (error "Invalid selection character `%c'" char)))))
+ (t (user-error "Invalid selection character `%c'" char)))))
(defcustom org-agenda-insert-diary-strategy 'date-tree
"Where in `org-agenda-diary-file' should new entries be added?
@@ -8571,7 +9374,7 @@ the resulting entry will not be shown. When TEXT is empty, switch to
;; Use org-agenda-format-item to parse text for a time-range and
;; remove it. FIXME: This is a hack, we should refactor
;; that function to make time extraction available separately
- (setq fmt (org-agenda-format-item nil text nil nil t)
+ (setq fmt (org-agenda-format-item nil text nil nil nil t)
time (get-text-property 0 'time fmt)
time2 (if (> (length time) 0)
;; split-string removes trailing ...... if
@@ -8654,7 +9457,6 @@ When `org-agenda-diary-file' points to a file,
`org-agenda-diary-entry-in-org-file' is called instead to create
entries in that Org-mode file."
(interactive)
- (org-agenda-check-type t 'agenda 'timeline)
(if (not (eq org-agenda-diary-file 'diary-file))
(org-agenda-diary-entry-in-org-file)
(require 'diary-lib)
@@ -8674,11 +9476,11 @@ entries in that Org-mode file."
(point (point))
(mark (or (mark t) (point))))
(unless cmd
- (error "No command associated with <%c>" char))
+ (user-error "No command associated with <%c>" char))
(unless (and (get-text-property point 'day)
(or (not (equal ?b char))
(get-text-property mark 'day)))
- (error "Don't know which date to use for diary entry"))
+ (user-error "Don't know which date to use for diary entry"))
;; We implement this by hacking the `calendar-cursor-to-date' function
;; and the `calendar-mark-ring' variable. Saves a lot of code.
(let ((calendar-mark-ring
@@ -8699,7 +9501,7 @@ entries in that Org-mode file."
(org-agenda-check-type t 'agenda 'timeline)
(require 'diary-lib)
(unless (get-text-property (min (1- (point-max)) (point)) 'day)
- (error "Don't know which date to use for the calendar command"))
+ (user-error "Don't know which date to use for the calendar command"))
(let* ((oldf (symbol-function 'calendar-cursor-to-date))
(point (point))
(date (calendar-gregorian-from-absolute
@@ -8748,7 +9550,7 @@ argument, latitude and longitude will be prompted for."
(interactive)
(org-agenda-check-type t 'agenda 'timeline)
(let* ((day (or (get-text-property (min (1- (point-max)) (point)) 'day)
- (error "Don't know which date to open in calendar")))
+ (user-error "Don't know which date to open in calendar")))
(date (calendar-gregorian-from-absolute day))
(calendar-move-hook nil)
(calendar-view-holidays-initially-flag nil)
@@ -8771,7 +9573,7 @@ This is a command that has to be installed in `calendar-mode-map'."
(let ((day (get-text-property (min (1- (point-max)) (point)) 'day))
date s)
(unless day
- (error "Don't know which date to convert"))
+ (user-error "Don't know which date to convert"))
(setq date (calendar-gregorian-from-absolute day))
(setq s (concat
"Gregorian: " (calendar-date-string date) "\n"
@@ -8807,14 +9609,17 @@ This is a command that has to be installed in `calendar-mode-map'."
(let* ((m (org-get-at-bol 'org-hd-marker))
ov)
(unless (org-agenda-bulk-marked-p)
- (unless m (error "Nothing to mark at point"))
+ (unless m (user-error "Nothing to mark at point"))
(push m org-agenda-bulk-marked-entries)
(setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol))))
(org-overlay-display ov (concat org-agenda-bulk-mark-char " ")
(org-get-todo-face "TODO")
'evaporate)
(overlay-put ov 'type 'org-marked-entry-overlay))
- (beginning-of-line 2)
+ (end-of-line 1)
+ (or (ignore-errors
+ (goto-char (next-single-property-change (point) 'txt)))
+ (beginning-of-line 2))
(while (and (get-char-property (point) 'invisible) (not (eobp)))
(beginning-of-line 2))
(message "%d entries marked for bulk action"
@@ -8828,12 +9633,13 @@ This is a command that has to be installed in `calendar-mode-map'."
(defun org-agenda-bulk-mark-regexp (regexp)
"Mark entries matching REGEXP for future agenda bulk action."
(interactive "sMark entries matching regexp: ")
- (let ((entries-marked 0))
+ (let ((entries-marked 0) txt-at-point)
(save-excursion
(goto-char (point-min))
(goto-char (next-single-property-change (point) 'txt))
- (while (re-search-forward regexp nil t)
- (when (string-match regexp (get-text-property (point) 'txt))
+ (while (and (re-search-forward regexp nil t)
+ (setq txt-at-point (get-text-property (point) 'txt)))
+ (when (string-match regexp txt-at-point)
(setq entries-marked (1+ entries-marked))
(call-interactively 'org-agenda-bulk-mark))))
(if (not entries-marked)
@@ -8850,15 +9656,27 @@ This is a command that has to be installed in `calendar-mode-map'."
(setq org-agenda-bulk-marked-entries
(delete (org-get-at-bol 'org-hd-marker)
org-agenda-bulk-marked-entries))
- (beginning-of-line 2)
+ (end-of-line 1)
+ (or (ignore-errors
+ (goto-char (next-single-property-change (point) 'txt)))
+ (beginning-of-line 2))
(while (and (get-char-property (point) 'invisible) (not (eobp)))
(beginning-of-line 2))
(message "%d entries left marked for bulk action"
(length org-agenda-bulk-marked-entries)))
(t (message "No entry to unmark here")))))
+(defun org-agenda-bulk-toggle-all ()
+ "Toggle all marks for bulk action."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (while (ignore-errors
+ (goto-char (next-single-property-change (point) 'txt)))
+ (org-agenda-bulk-toggle))))
+
(defun org-agenda-bulk-toggle ()
- "Toggle marking the entry at point for bulk action."
+ "Toggle the mark at point for bulk action."
(interactive)
(if (org-agenda-bulk-marked-p)
(org-agenda-bulk-unmark)
@@ -8899,14 +9717,14 @@ bulk action."
The prefix arg is passed through to the command if possible."
(interactive "P")
;; Make sure we have markers, and only valid ones
- (unless org-agenda-bulk-marked-entries (error "No entries are marked"))
+ (unless org-agenda-bulk-marked-entries (user-error "No entries are marked"))
(mapc
(lambda (m)
(unless (and (markerp m)
(marker-buffer m)
(buffer-live-p (marker-buffer m))
(marker-position m))
- (error "Marker %s for bulk command is invalid" m)))
+ (user-error "Marker %s for bulk command is invalid" m)))
org-agenda-bulk-marked-entries)
;; Prompt for the bulk command
@@ -8985,7 +9803,7 @@ The prefix arg is passed through to the command if possible."
((equal action ?S)
(if (not (org-agenda-check-type nil 'agenda 'timeline 'todo))
- (error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type)
+ (user-error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type)
(let ((days (read-number
(format "Scatter tasks across how many %sdays: "
(if arg "week" "")) 7)))
@@ -9023,7 +9841,7 @@ The prefix arg is passed through to the command if possible."
(org-icompleting-read "Function: "
obarray 'fboundp t nil nil)))))
- (t (error "Invalid bulk action")))
+ (t (user-error "Invalid bulk action")))
;; Sort the markers, to make sure that parents are handled before children
(setq entries (sort entries
@@ -9057,15 +9875,43 @@ The prefix arg is passed through to the command if possible."
(if (not org-agenda-persistent-marks)
"" " (kept marked)"))))))
-(defun org-agenda-capture ()
- "Call `org-capture' with the date at point."
- (interactive)
+(defun org-agenda-capture (&optional with-time)
+ "Call `org-capture' with the date at point.
+With a `C-1' prefix, use the HH:MM value at point (if any) or the
+current HH:MM time."
+ (interactive "P")
(if (not (eq major-mode 'org-agenda-mode))
- (error "You cannot do this outside of agenda buffers")
+ (user-error "You cannot do this outside of agenda buffers")
(let ((org-overriding-default-time
- (org-get-cursor-date)))
+ (org-get-cursor-date (equal with-time 1))))
(call-interactively 'org-capture))))
+;;; Dragging agenda lines forward/backward
+
+(defun org-agenda-drag-line-forward (arg)
+ "Drag an agenda line forward by ARG lines."
+ (interactive "p")
+ (let ((inhibit-read-only t) lst)
+ (if (save-excursion
+ (dotimes (n arg)
+ (beginning-of-line 2)
+ (push (not (get-text-property (point) 'txt)) lst))
+ (delq nil lst))
+ (message "Cannot move line forward")
+ (org-drag-line-forward arg))))
+
+(defun org-agenda-drag-line-backward (arg)
+ "Drag an agenda line backward by ARG lines."
+ (interactive "p")
+ (let ((inhibit-read-only t) lst)
+ (if (save-excursion
+ (dotimes (n arg)
+ (beginning-of-line 0)
+ (push (not (get-text-property (point) 'txt)) lst))
+ (delq nil lst))
+ (message "Cannot move line backward")
+ (org-drag-line-backward arg))))
+
;;; Flagging notes
(defun org-agenda-show-the-flagging-note ()
@@ -9077,7 +9923,7 @@ tag and (if present) the flagging note."
(win (selected-window))
note heading newhead)
(unless hdmarker
- (error "No linked entry at point"))
+ (user-error "No linked entry at point"))
(if (and (eq this-command last-command)
(y-or-n-p "Unflag and remove any flagging note? "))
(progn
@@ -9087,7 +9933,7 @@ tag and (if present) the flagging note."
(message "Entry unflagged"))
(setq note (org-entry-get hdmarker "THEFLAGGINGNOTE"))
(unless note
- (error "No flagging note"))
+ (user-error "No flagging note"))
(org-kill-new note)
(org-switch-to-buffer-other-window "*Flagging Note*")
(erase-buffer)
@@ -9143,18 +9989,19 @@ will only add headlines containing IMPORTANT or headlines
belonging to the \"Work\" category.
ARGS are symbols indicating what kind of entries to consider.
-By default `org-agenda-to-appt' will use :deadline, :scheduled
+By default `org-agenda-to-appt' will use :deadline*, :scheduled*
+\(i.e., deadlines and scheduled items with a hh:mm specification)
and :timestamp entries. See the docstring of `org-diary' for
details and examples.
-If an entry as a APPT_WARNTIME property, its value will be used
+If an entry has a APPT_WARNTIME property, its value will be used
to override `appt-message-warning-time'."
(interactive "P")
(if refresh (setq appt-time-msg-list nil))
(if (eq filter t)
(setq filter (read-from-minibuffer "Regexp filter: ")))
(let* ((cnt 0) ; count added events
- (scope (or args '(:deadline :scheduled :timestamp)))
+ (scope (or args '(:deadline* :scheduled* :timestamp)))
(org-agenda-new-buffers nil)
(org-deadline-warning-days 0)
;; Do not use `org-today' here because appt only takes
@@ -9176,7 +10023,10 @@ to override `appt-message-warning-time'."
;; Map thru entries and find if we should filter them out
(mapc
(lambda(x)
- (let* ((evt (org-trim (or (get-text-property 1 'txt x) "")))
+ (let* ((evt (org-trim
+ (replace-regexp-in-string
+ org-bracket-link-regexp "\\3"
+ (or (get-text-property 1 'txt x) ""))))
(cat (get-text-property 1 'org-category x))
(tod (get-text-property 1 'time-of-day x))
(ok (or (null filter)