summaryrefslogtreecommitdiff
path: root/lisp/org-agenda.el
diff options
context:
space:
mode:
authorSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:35 +0200
committerSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:35 +0200
commit361fd4da7cfa870165cb1ec175cdbea55ca40e7e (patch)
treea36bfd91d9e14c354b6eaebb20f5d5d64ec438db /lisp/org-agenda.el
parent77ddd382df838e38504b822e729250b2a6dd9b63 (diff)
Imported Upstream version 8.2.7a
Diffstat (limited to 'lisp/org-agenda.el')
-rw-r--r--lisp/org-agenda.el391
1 files changed, 173 insertions, 218 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index e2a0629..42d62f3 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -390,32 +390,36 @@ the daily/weekly agenda, see `org-agenda-skip-function'.")
(repeat :inline t :tag "Conditions for skipping"
(choice
:tag "Condition type"
- (list :tag "Regexp matches" :inline t (const :format "" regexp) (regexp))
- (list :tag "Regexp does not match" :inline t (const :format "" notregexp) (regexp))
+ (list :tag "Regexp matches" :inline t
+ (const :format "" 'regexp)
+ (regexp))
+ (list :tag "Regexp does not match" :inline t
+ (const :format "" 'notregexp)
+ (regexp))
(list :tag "TODO state is" :inline t
- (const todo)
+ (const 'todo)
(choice
- (const :tag "any not-done state" todo)
- (const :tag "any done state" done)
- (const :tag "any state" any)
+ (const :tag "Any not-done state" 'todo)
+ (const :tag "Any done state" 'done)
+ (const :tag "Any state" 'any)
(list :tag "Keyword list"
(const :format "" quote)
(repeat (string :tag "Keyword")))))
(list :tag "TODO state is not" :inline t
- (const nottodo)
+ (const 'nottodo)
(choice
- (const :tag "any not-done state" todo)
- (const :tag "any done state" done)
- (const :tag "any state" any)
+ (const :tag "Any not-done state" 'todo)
+ (const :tag "Any done state" 'done)
+ (const :tag "Any state" 'any)
(list :tag "Keyword list"
(const :format "" quote)
(repeat (string :tag "Keyword")))))
- (const :tag "scheduled" scheduled)
- (const :tag "not scheduled" notscheduled)
- (const :tag "deadline" deadline)
- (const :tag "no deadline" notdeadline)
- (const :tag "timestamp" timestamp)
- (const :tag "no timestamp" nottimestamp))))))
+ (const :tag "scheduled" 'scheduled)
+ (const :tag "not scheduled" 'notscheduled)
+ (const :tag "deadline" 'deadline)
+ (const :tag "no deadline" 'notdeadline)
+ (const :tag "timestamp" 'timestamp)
+ (const :tag "no timestamp" 'nottimestamp))))))
(list :tag "Non-standard skipping condition"
:value (org-agenda-skip-function)
(const org-agenda-skip-function)
@@ -649,7 +653,7 @@ of custom agenda commands."
:tag "Org Agenda Match View"
:group 'org-agenda)
(defgroup org-agenda-search-view nil
- "Options concerning the general tags/property/todo match agenda view."
+ "Options concerning the search agenda view."
:tag "Org Agenda Search View"
:group 'org-agenda)
@@ -2092,11 +2096,9 @@ When nil, `q' will kill the single agenda buffer."
org-agenda-info
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-top-headline-filter
org-agenda-regexp-filter
org-agenda-markers
org-agenda-last-search-view-search-was-boolean
@@ -2158,10 +2160,11 @@ The following commands are available:
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
- org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
- org-agenda-show-log org-agenda-start-with-log-mode))
-
+ org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode))
+ (setq org-agenda-show-log org-agenda-start-with-log-mode)
+ (setq org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode)
+ (add-to-invisibility-spec '(org-filtered))
+ (add-to-invisibility-spec '(org-link))
(easy-menu-change
'("Agenda") "Agenda Files"
(append
@@ -2604,7 +2607,7 @@ type."
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
- (integer :tag "Max number of entries")
+ (integer :tag "Max number of TODOs")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
@@ -2612,7 +2615,7 @@ type."
(const tags)
(const search)
(const timeline))
- (integer :tag "Max number of entries")))))
+ (integer :tag "Max number of TODOs")))))
(defcustom org-agenda-max-tags nil
"Maximum number of tagged entries to display in an agenda.
@@ -2623,7 +2626,7 @@ type."
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
- (integer :tag "Max number of entries")
+ (integer :tag "Max number of tagged entries")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
@@ -2631,7 +2634,7 @@ type."
(const tags)
(const search)
(const timeline))
- (integer :tag "Max number of entries")))))
+ (integer :tag "Max number of tagged entries")))))
(defcustom org-agenda-max-effort nil
"Maximum cumulated effort duration for the agenda.
@@ -2642,7 +2645,7 @@ to limit entries to in this type."
:package-version '(Org . "8.0")
:group 'org-agenda-custom-commands
:type '(choice (symbol :tag "No limit" nil)
- (integer :tag "Max number of entries")
+ (integer :tag "Max number of minutes")
(repeat
(cons (choice :tag "Agenda type"
(const agenda)
@@ -2650,7 +2653,7 @@ to limit entries to in this type."
(const tags)
(const search)
(const timeline))
- (integer :tag "Max number of entries")))))
+ (integer :tag "Max number of minutes")))))
(defvar org-keys nil)
(defvar org-match nil)
@@ -3324,19 +3327,12 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
(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 content)
- (org-agenda-unmark-filtered-text)
(with-temp-buffer
(rename-buffer org-agenda-write-buffer-name t)
(set-buffer-modified-p nil)
(insert bs)
(org-agenda-remove-marked-text 'org-filtered)
- (while (setq beg (text-property-any (point-min) (point-max)
- 'org-filtered t))
- (delete-region
- beg (or (next-single-property-change beg 'org-filtered)
- (point-max))))
(run-hooks 'org-agenda-before-write-hook)
(cond
((org-bound-and-true-p org-mobile-creating-agendas)
@@ -3402,28 +3398,6 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
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."
- (let ((inhibit-read-only t))
- (mapc
- (lambda (o)
- (when (equal (overlay-buffer o) (current-buffer))
- (put-text-property
- (overlay-start o) (overlay-end o)
- 'org-filtered t)))
- (append org-agenda-tag-filter-overlays
- org-agenda-cat-filter-overlays
- org-agenda-re-filter-overlays))))
-
-(defun org-agenda-unmark-filtered-text ()
- "Remove the filtering text property."
- (let ((inhibit-read-only t))
- (remove-text-properties (point-min) (point-max) '(org-filtered t))))
-
(defun org-agenda-remove-marked-text (property &optional value)
"Delete all text marked with VALUE of PROPERTY.
VALUE defaults to t."
@@ -3432,7 +3406,7 @@ VALUE defaults to t."
(while (setq beg (text-property-any (point-min) (point-max)
property value))
(delete-region
- beg (or (next-single-property-change beg 'org-filtered)
+ beg (or (next-single-property-change beg property)
(point-max))))))
(defun org-agenda-add-entry-text ()
@@ -3557,7 +3531,6 @@ removed from the entry content. Currently only `planning' is allowed here."
(defvar org-agenda-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.
This must be a list of strings, each string must be a single tag preceded
@@ -3609,10 +3582,12 @@ generating a new one."
;; does not have org variables local
org-agenda-this-buffer-is-sticky))))
-(defun org-agenda-prepare-window (abuf)
- "Setup agenda buffer in the window."
- (let* ((awin (get-buffer-window abuf))
- wconf)
+(defun org-agenda-prepare-window (abuf filter-alist)
+ "Setup agenda buffer in the window.
+ABUF is the buffer for the agenda window.
+FILTER-ALIST is an alist of filters we need to apply when
+`org-agenda-persistent-filter' is non-nil."
+ (let* ((awin (get-buffer-window abuf)) wconf)
(cond
((equal (current-buffer) abuf) nil)
(awin (select-window awin))
@@ -3626,68 +3601,73 @@ generating a new one."
((equal org-agenda-window-setup 'reorganize-frame)
(delete-other-windows)
(org-switch-to-buffer-other-window abuf)))
- ;; additional test in case agenda is invoked from within agenda
- ;; buffer via elisp link
+ (setq org-agenda-tag-filter (cdr (assoc 'tag filter-alist)))
+ (setq org-agenda-category-filter (cdr (assoc 'cat filter-alist)))
+ (setq org-agenda-regexp-filter (cdr (assoc 're filter-alist)))
+ ;; Additional test in case agenda is invoked from within agenda
+ ;; buffer via elisp link.
(unless (equal (current-buffer) abuf)
(org-pop-to-buffer-same-window abuf))
(setq org-agenda-pre-window-conf
(or org-agenda-pre-window-conf wconf))))
(defun org-agenda-prepare (&optional name)
- (if (org-agenda-use-sticky-p)
- (progn
- ;; Popup existing buffer
- (org-agenda-prepare-window (get-buffer org-agenda-buffer-name))
- (message "Sticky Agenda buffer, use `r' to refresh")
- (or org-agenda-multi (org-agenda-fit-window-to-buffer))
- (throw 'exit "Sticky Agenda buffer, use `r' to refresh"))
- (setq org-todo-keywords-for-agenda nil)
- (setq org-drawers-for-agenda nil)
- (unless org-agenda-persistent-filter
- (setq org-agenda-tag-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
+ (let ((filter-alist (if org-agenda-persistent-filter
+ (list `(tag . ,org-agenda-tag-filter)
+ `(re . ,org-agenda-regexp-filter)
+ `(car . ,org-agenda-category-filter)))))
+ (if (org-agenda-use-sticky-p)
(progn
- (setq buffer-read-only nil)
- (goto-char (point-max))
- (unless (or (bobp) org-agenda-compact-blocks
- (not org-agenda-block-separator))
- (insert "\n"
- (if (stringp org-agenda-block-separator)
- org-agenda-block-separator
- (make-string (window-width) org-agenda-block-separator))
- "\n"))
- (narrow-to-region (point) (point-max)))
- (setq org-done-keywords-for-agenda nil)
-
- ;; Setting any org variables that are in org-agenda-local-vars
- ;; list need to be done after the prepare call
- (org-agenda-prepare-window (get-buffer-create org-agenda-buffer-name))
- (setq buffer-read-only nil)
- (org-agenda-reset-markers)
- (let ((inhibit-read-only t)) (erase-buffer))
- (org-agenda-mode)
- (setq org-agenda-buffer (current-buffer))
- (setq org-agenda-contributing-files nil)
- (setq org-agenda-columns-active nil)
- (org-agenda-prepare-buffers (org-agenda-files nil 'ifmode))
- (setq org-todo-keywords-for-agenda
- (org-uniquify org-todo-keywords-for-agenda))
- (setq org-done-keywords-for-agenda
- (org-uniquify org-done-keywords-for-agenda))
- (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
- (setq org-agenda-last-prefix-arg current-prefix-arg)
- (setq org-agenda-this-buffer-name org-agenda-buffer-name)
- (and name (not org-agenda-name)
- (org-set-local 'org-agenda-name name)))
- (setq buffer-read-only nil)))
+ ;; Popup existing buffer
+ (org-agenda-prepare-window (get-buffer org-agenda-buffer-name)
+ filter-alist)
+ (message "Sticky Agenda buffer, use `r' to refresh")
+ (or org-agenda-multi (org-agenda-fit-window-to-buffer))
+ (throw 'exit "Sticky Agenda buffer, use `r' to refresh"))
+ (setq org-todo-keywords-for-agenda nil)
+ (setq org-drawers-for-agenda nil)
+ (put 'org-agenda-tag-filter :preset-filter
+ org-agenda-tag-filter-preset)
+ (put 'org-agenda-category-filter :preset-filter
+ org-agenda-category-filter-preset)
+ (put 'org-agenda-regexp-filter :preset-filter
+ org-agenda-regexp-filter-preset)
+ (if org-agenda-multi
+ (progn
+ (setq buffer-read-only nil)
+ (goto-char (point-max))
+ (unless (or (bobp) org-agenda-compact-blocks
+ (not org-agenda-block-separator))
+ (insert "\n"
+ (if (stringp org-agenda-block-separator)
+ org-agenda-block-separator
+ (make-string (window-width) org-agenda-block-separator))
+ "\n"))
+ (narrow-to-region (point) (point-max)))
+ (setq org-done-keywords-for-agenda nil)
+
+ ;; Setting any org variables that are in org-agenda-local-vars
+ ;; list need to be done after the prepare call
+ (org-agenda-prepare-window
+ (get-buffer-create org-agenda-buffer-name) filter-alist)
+ (setq buffer-read-only nil)
+ (org-agenda-reset-markers)
+ (let ((inhibit-read-only t)) (erase-buffer))
+ (org-agenda-mode)
+ (setq org-agenda-buffer (current-buffer))
+ (setq org-agenda-contributing-files nil)
+ (setq org-agenda-columns-active nil)
+ (org-agenda-prepare-buffers (org-agenda-files nil 'ifmode))
+ (setq org-todo-keywords-for-agenda
+ (org-uniquify org-todo-keywords-for-agenda))
+ (setq org-done-keywords-for-agenda
+ (org-uniquify org-done-keywords-for-agenda))
+ (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
+ (setq org-agenda-last-prefix-arg current-prefix-arg)
+ (setq org-agenda-this-buffer-name org-agenda-buffer-name)
+ (and name (not org-agenda-name)
+ (org-set-local 'org-agenda-name name)))
+ (setq buffer-read-only nil))))
(defvar org-agenda-overriding-columns-format) ; From org-colview.el
(defun org-agenda-finalize ()
@@ -3739,13 +3719,15 @@ generating a new one."
(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)))
+ (when (setq mrk (get-text-property (point) 'org-hd-marker))
(put-text-property (point-at-bol) (point-at-eol)
'tags (org-with-point-at mrk
(delete-dups
(mapcar 'downcase (org-get-tags-at))))))))))
(run-hooks 'org-agenda-finalize-hook)
+ (when org-agenda-top-headline-filter
+ (org-agenda-filter-top-headline-apply
+ org-agenda-top-headline-filter))
(when org-agenda-tag-filter
(org-agenda-filter-apply org-agenda-tag-filter 'tag))
(when (get 'org-agenda-tag-filter :preset-filter)
@@ -4326,14 +4308,6 @@ items if they have an hour specification like [h]h:mm."
(setq p (plist-put p :tstart clocktable-start))
(setq p (plist-put p :tend clocktable-end))
(setq p (plist-put p :scope 'agenda))
- (when (and (eq org-agenda-clockreport-mode 'with-filter)
- (setq filter (or org-agenda-tag-filter-while-redo
- (get 'org-agenda-tag-filter :preset-filter))))
- (setq p (plist-put p :tags (mapconcat (lambda (x)
- (if (string-match "[<>=]" x)
- ""
- x))
- filter ""))))
(setq tbl (apply 'org-clock-get-clocktable p))
(insert tbl)))
(goto-char (point-min))
@@ -6781,8 +6755,10 @@ The optional STRING argument forces conversion into a 5 character wide string
HH:MM."
(save-match-data
(when
- (or (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s)
- (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\> *" s))
+ (and
+ (or (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s)
+ (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\> *" s))
+ (not (eq (get-text-property 1 'face s) 'org-link)))
(let* ((h (string-to-number (match-string 1 s)))
(m (if (match-end 3) (string-to-number (match-string 3 s)) 0))
(ampm (if (match-end 4) (downcase (match-string 4 s))))
@@ -7010,7 +6986,7 @@ The optional argument TYPE tells the agenda type."
(cond ((< ta tb) -1)
((< tb ta) +1))))
-(defsubst org-cmp-ts (a b &optional type)
+(defsubst org-cmp-ts (a b 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
@@ -7018,9 +6994,11 @@ is the empty string, compare all timestamps without respect of
their type."
(let* ((def (if org-sort-agenda-notime-is-late most-positive-fixnum -1))
(ta (or (and (string-match type (or (get-text-property 1 'type a) ""))
- (get-text-property 1 'ts-date a)) def))
+ (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)))
+ (get-text-property 1 'ts-date b))
+ def)))
(cond ((< ta tb) -1)
((< tb ta) +1))))
@@ -7046,7 +7024,7 @@ their type."
(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")))
+ (org-cmp-ts a b "timestamp_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")))
@@ -7283,7 +7261,6 @@ in the agenda."
(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))
(window-line (- line (org-current-line (window-start))))
@@ -7316,9 +7293,12 @@ in the agenda."
(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 (or re-filter re-preset) (org-agenda-filter-apply re-filter 'regexp))
+ (let ((tag (or tag-filter tag-preset))
+ (cat (or cat-filter cat-preset))
+ (re (or re-filter re-preset)))
+ (when tag (org-agenda-filter-apply tag 'tag))
+ (when cat (org-agenda-filter-apply cat 'category))
+ (when re (org-agenda-filter-apply re '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)
@@ -7344,7 +7324,7 @@ The category is that of the current line."
(org-agenda-filter-apply
(setq org-agenda-category-filter
(list (concat "+" cat))) 'category))
- ((error "No category at point"))))))
+ (t (error "No category at point"))))))
(defun org-find-top-headline (&optional pos)
"Find the topmost parent headline and return it."
@@ -7365,10 +7345,10 @@ The top headline is that of the current line."
(progn
(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-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")))))
+ (org-agenda-filter-show-all-top-filter))
+ (let ((toph (org-find-top-headline (org-get-at-bol 'org-hd-marker))))
+ (if toph (org-agenda-filter-top-headline-apply toph strip)
+ (error "No top-level headline at point")))))
(defvar org-agenda-regexp-filter nil)
(defun org-agenda-filter-by-regexp (strip)
@@ -7397,7 +7377,10 @@ With two prefix arguments, remove the regexp filters."
(when org-agenda-category-filter
(org-agenda-filter-show-all-cat))
(when org-agenda-regexp-filter
- (org-agenda-filter-show-all-re)))
+ (org-agenda-filter-show-all-re))
+ (when org-agenda-top-headline-filter
+ (org-agenda-filter-show-all-top-filter))
+ (org-agenda-finalize))
(defun org-agenda-filter-by-tag (strip &optional char narrow)
"Keep only those lines in the agenda buffer that have a specific tag.
@@ -7500,8 +7483,7 @@ to switch to narrowing."
(org-agenda-filter-apply org-agenda-tag-filter 'tag)
(setq maybe-refresh t))
(t (error "Invalid tag selection character %c" char)))
- (when (and maybe-refresh
- (eq org-agenda-clockreport-mode 'with-filter))
+ (when maybe-refresh
(org-agenda-redo))))
(defun org-agenda-get-represented-tags ()
@@ -7622,13 +7604,12 @@ When NO-OPERATOR is non-nil, do not add the + operator to returned tags."
;; 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
- ;; when a unique category is used as the filter
- (setq org-agenda-filtered-by-category t))
+ (setq org-agenda-filter-form (org-agenda-filter-make-matcher filter type))
+ ;; Only set `org-agenda-filtered-by-category' to t when a unique
+ ;; category is used as the filter:
+ (setq org-agenda-filtered-by-category
+ (and (eq type 'category)
+ (not (equal (substring (car filter) 0 1) "-"))))
(org-agenda-set-mode-name)
(save-excursion
(goto-char (point-min))
@@ -7659,7 +7640,7 @@ When NO-OPERATOR is non-nil, do not add the + operator to returned tags."
(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)))
+ (org-agenda-filter-hide-line 'top-headline)))
(beginning-of-line 2)))
(if (get-char-property (point) 'invisible)
(org-agenda-previous-line))
@@ -7669,50 +7650,35 @@ When NO-OPERATOR is non-nil, do not add the + operator to returned tags."
(defun org-agenda-filter-hide-line (type)
"Hide lines with TYPE in the agenda buffer."
(let* ((b (max (point-min) (1- (point-at-bol))))
- (e (point-at-eol))
- (ov (make-overlay b e)))
- (overlay-put ov 'invisible t)
- (overlay-put ov 'intangible t)
- (overlay-put ov 'type type)
- (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)))
+ (e (point-at-eol)))
+ (let ((inhibit-read-only t))
+ (add-text-properties
+ b e `(invisible org-filtered org-filter-type ,type)))))
+
+(defun org-agenda-remove-filter (type)
+ (interactive)
+ "Remove filter of type TYPE from the agenda buffer."
(save-excursion
- (dolist (ov (overlays-at pos))
- (when (and (overlay-get ov 'invisible)
- (eq (overlay-get ov 'type) 'tag))
+ (goto-char (point-min))
+ (let ((inhibit-read-only t) pos)
+ (while (setq pos (text-property-any (point) (point-max) 'org-filter-type type))
(goto-char pos)
- (if (< (overlay-start ov) (point-at-eol))
- (move-overlay ov (point-at-eol)
- (overlay-end ov)))))))
+ (remove-text-properties
+ (point) (next-single-property-change (point) 'org-filter-type)
+ `(invisible org-filtered org-filter-type ,type))))
+ (set (intern (format "org-agenda-%s-filter" (intern-soft type))) nil)
+ (setq org-agenda-filter-form nil)
+ (org-agenda-set-mode-name)
+ (org-agenda-finalize)))
(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))
-
+ (org-agenda-remove-filter 'tag))
(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))
-
+ (org-agenda-remove-filter 'regexp))
(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
- org-agenda-category-filter nil
- org-agenda-filter-form nil)
- (org-agenda-set-mode-name))
+ (org-agenda-remove-filter 'category))
+(defun org-agenda-filter-show-all-top-filter nil
+ (org-agenda-remove-filter 'top-headline))
(defun org-agenda-manipulate-query-add ()
"Manipulate the query by adding a search term with positive selection.
@@ -8106,15 +8072,12 @@ so that the date SD will be in that range."
(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.
-With prefix arg WITH-FILTER, make the clocktable respect the current
-agenda filter."
- (interactive "P")
+(defun org-agenda-clockreport-mode ()
+ "Toggle clocktable mode in an agenda buffer."
+ (interactive)
(org-agenda-check-type t 'agenda)
- (if with-filter
- (setq org-agenda-clockreport-mode 'with-filter)
- (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode)))
+ (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode))
+ (setq org-agenda-start-with-clockreport-mode org-agenda-clockreport-mode)
(org-agenda-set-mode-name)
(org-agenda-redo)
(message "Clocktable mode is %s"
@@ -8135,6 +8098,7 @@ With a double `C-u' prefix arg, show *only* log items, nothing else."
nil 'clockcheck))
(special '(closed clock state))
(t (not org-agenda-show-log))))
+ (setq org-agenda-start-with-log-mode org-agenda-show-log)
(org-agenda-set-mode-name)
(org-agenda-redo)
(message "Log mode is %s"
@@ -8252,10 +8216,7 @@ When called with a prefix argument, include all archive files as well."
" Archives"
(format " :%s:" org-archive-tag))
"")
- (if org-agenda-clockreport-mode
- (if (eq org-agenda-clockreport-mode 'with-filter)
- " Clock{}" " Clock")
- "")))
+ (if org-agenda-clockreport-mode " Clock" "")))
(force-mode-line-update))
(define-obsolete-function-alias
@@ -8623,7 +8584,8 @@ if it was hidden in the outline."
(interactive "p")
(let ((win (selected-window)))
(org-agenda-goto t)
- (org-recenter-heading 1)
+ (org-back-to-heading)
+ (set-window-start (selected-window) (point-at-bol))
(cond
((= more 0)
(hide-subtree)
@@ -8662,11 +8624,6 @@ if it was hidden in the outline."
(message "Remote: SUBTREE AND ALL DRAWERS")))
(select-window win)))
-(defun org-recenter-heading (n)
- (save-excursion
- (org-back-to-heading)
- (recenter n)))
-
(defvar org-agenda-cycle-counter nil)
(defun org-agenda-cycle-show (&optional n)
"Show the current entry in another window, with default settings.
@@ -9177,8 +9134,6 @@ Called with a universal prefix arg, show the priority instead of setting it."
(when (equal marker (org-get-at-bol 'org-marker))
(remove-text-properties (point-at-bol) (point-at-eol) '(display))
(org-move-to-column (- (window-width) (length stamp)) t)
-
- (org-agenda-fix-tags-filter-overlays-at (point))
(if (featurep 'xemacs)
;; Use `duplicable' property to trigger undo recording
(let ((ex (make-extent nil nil))
@@ -9190,7 +9145,7 @@ Called with a universal prefix arg, show the priority instead of setting it."
(add-text-properties
(1- (point)) (point-at-eol)
(list 'display (org-add-props stamp nil
- 'face 'secondary-selection))))
+ 'face '(secondary-selection default)))))
(beginning-of-line 1))
(beginning-of-line 0)))))
@@ -9478,9 +9433,9 @@ a timestamp can be added there."
(if org-adapt-indentation (org-indent-to-column 2)))
(defun org-agenda-insert-diary-make-new-entry (text)
- "Make new entry as last child of current entry.
-Add TEXT as headline, and position the cursor in the second line so that
-a timestamp can be added there."
+ "Make a new entry with TEXT as the first child of the current subtree.
+Position the point in the line right after the new heading so
+that a timestamp can be added there."
(let ((org-show-following-heading t)
(org-show-siblings t)
(org-show-hierarchy-above t)