From c4d4bf3833ecdfffd603aa7555eca2cea45aff6e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:33:24 +0100 Subject: [PATCH 1/9] New defun `org-refresh-effort-properties' * org-agenda.el (org-agenda-format-item): Do not use org-get-effort to get the effort text property. (org-agenda-get-sexps): Use `org-back-to-heading' when setting the tags. * org-clock.el (org-clock-in): Refresh effort properties. * org.el (org-refresh-effort-properties): New defun. (org-get-effort): Delete. (org-set-effort): Set the 'org-effort text property. (org-property-next-allowed-value): Ditto. (org-agenda-prepare-buffers): Refresh effort properties. --- lisp/org-agenda.el | 10 ++-------- lisp/org-clock.el | 6 ++++-- lisp/org.el | 34 +++++++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b4c21fcb5..fe718d370 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5470,8 +5470,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? (setq marker (org-agenda-new-marker beg) 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)) + tags (save-excursion (org-back-to-heading t) (org-get-tags-at)) todo-state (org-get-todo-state) warntime (org-entry-get (point) "APPT_WARNTIME") extra nil) @@ -6224,12 +6223,7 @@ 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))) + (setq effort (ignore-errors (get-text-property 0 'org-effort txt))) (when effort (setq neffort (org-duration-string-to-minutes effort) effort (setq effort (concat "[" effort "]"))))) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index e3048e5a1..d30c3747f 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -35,6 +35,7 @@ (declare-function calendar-absolute-from-iso "cal-iso" (&optional date)) (declare-function notifications-notify "notifications" (&rest params)) (declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) +(declare-function org-refresh-effort-properties "org" ()) (defvar org-time-stamp-formats) (defvar org-ts-what) (defvar org-frame-title-format-backup frame-title-format) @@ -1081,6 +1082,7 @@ time as the start time \(see `org-clock-continuously' to make this the default behavior.)" (interactive "P") (setq org-clock-notification-was-shown nil) + (org-refresh-effort-properties) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) @@ -1202,7 +1204,7 @@ make this the default behavior.)" (setq org-clock-start-time (apply 'encode-time (org-parse-time-string (match-string 1)))) - (setq org-clock-effort (org-get-effort)) + (setq org-clock-effort (get-text-property (point) 'org-effort)) (setq org-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-start)))) ((eq org-clock-in-resume 'auto-restart) @@ -1222,7 +1224,7 @@ make this the default behavior.)" (beginning-of-line 1) (org-indent-line-to (- (org-get-indentation) 2))) (insert org-clock-string " ") - (setq org-clock-effort (org-get-effort)) + (setq org-clock-effort (get-text-property (point) 'org-effort)) (setq org-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-start))) (setq org-clock-start-time diff --git a/lisp/org.el b/lisp/org.el index ea19f97ff..8aa0548e4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8642,6 +8642,23 @@ call CMD." (put-text-property beg end 'org-category-position beg) (goto-char pos))))))) +(defun org-refresh-effort-properties () + "Refresh effort text properties in the buffer." + (let ((case-fold-search t) + (inhibit-read-only t) e) + (org-unmodified + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (put-text-property (point) (point-max) 'org-effort-timestamp (current-time)) + (while (re-search-forward (concat "^[ \t]*:" org-effort-property + ": +\\(.*\\)[ \t]*$") nil t) + (setq e (org-match-string-no-properties 1)) + (save-excursion + (org-back-to-heading t) + (put-text-property + (point-at-bol) (point-at-eol) 'org-effort e)))))))) ;;;; Link Stuff @@ -9949,12 +9966,6 @@ there is one, return it." '(add-hook 'org-export-preprocess-before-normalizing-links-hook 'org-remove-file-link-modifiers)) -;;;; Time estimates - -(defun org-get-effort (&optional pom) - "Get the effort estimate for the current entry." - (org-entry-get pom org-effort-property)) - ;;; File search (defvar org-create-file-search-functions nil @@ -14301,6 +14312,9 @@ When INCREMENT is non-nil, set the property to the next allowed value." existing nil nil "" nil cur)))))) (unless (equal (org-entry-get nil prop) val) (org-entry-put nil prop val)) + (save-excursion + (org-back-to-heading t) + (put-text-property (point-at-bol) (point-at-eol) 'org-effort val)) (message "%s is now %s" prop val))) (defun org-at-property-p () @@ -15021,7 +15035,8 @@ completion." (interactive) (unless (org-at-property-p) (error "Not at a property")) - (let* ((key (match-string 2)) + (let* ((prop (car (save-match-data (org-split-string (match-string 1) ":")))) + (key (match-string 2)) (value (match-string 3)) (allowed (or (org-property-get-allowed-values (point) key) (and (member value '("[ ]" "[-]" "[X]")) @@ -15040,6 +15055,10 @@ completion." (org-indent-line) (beginning-of-line 1) (skip-chars-forward " \t") + (when (equal prop org-effort-property) + (save-excursion + (org-back-to-heading t) + (put-text-property (point-at-bol) (point-at-eol) 'org-effort nval))) (run-hook-with-args 'org-property-changed-functions key nval))) (defun org-find-olp (path &optional this-buffer) @@ -16992,6 +17011,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (widen) (setq bmp (buffer-modified-p)) (org-refresh-category-properties) + (org-refresh-effort-properties) (setq org-todo-keywords-for-agenda (append org-todo-keywords-for-agenda org-todo-keywords-1)) (setq org-done-keywords-for-agenda From 8f749c983493a010c4ae0437975c8cb63017c3f4 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:33:57 +0100 Subject: [PATCH 2/9] org-depend.el (org-depend-trigger-todo): Refresh effort text properties * org-depend.el (org-depend-trigger-todo): Refresh effort text properties. Do not use `org-get-effort' for getting the effort property value. --- contrib/lisp/org-depend.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el index 0ca581952..81402b4d3 100644 --- a/contrib/lisp/org-depend.el +++ b/contrib/lisp/org-depend.el @@ -205,6 +205,8 @@ This does two different kinds of triggers: property is seen as an entry id. Org-mode finds the entry with the corresponding ID property and switches it to the state TODO as well." + ;; Refresh the effort text properties + (org-refresh-effort-properties) ;; Get information from the plist (let* ((type (plist-get change-plist :type)) (pos (plist-get change-plist :position)) @@ -268,7 +270,7 @@ This does two different kinds of triggers: (tags (match-string 5)) (priority (org-get-priority (or (match-string 3) ""))) (effort (when (or effort-up effort-down) - (let ((effort (org-get-effort))) + (let ((effort (get-text-property (point) 'org-effort))) (when effort (org-duration-string-to-minutes effort)))))) (push (list (point) todo-kwd priority tags effort) From 334596e3c7d4d793031cd8312f9b3ab18c0aa082 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:39:09 +0100 Subject: [PATCH 3/9] org.el (org-adaptive-fill-function): Fix checking of post-affiliated * org.el (org-adaptive-fill-function): Fix checking of post-affiliated. (org-id-link-to-org-use-id): Fix compiler warning. --- lisp/org.el | 62 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 8aa0548e4..6d2539eee 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8752,7 +8752,7 @@ type. For a simple example of an export function, see `org-bbdb.el'." (push (list type follow export) org-link-protocols))) (defvar org-agenda-buffer-name) ; Defined in org-agenda.el -(defvar org-link-to-org-use-id) ; Defined in org-id.el +(defvar org-id-link-to-org-use-id) ; Defined in org-id.el ;;;###autoload (defun org-store-link (arg) @@ -21002,36 +21002,36 @@ meant to be filled." (goto-char (org-element-property :begin element)) (while (looking-at org-element--affiliated-re) (forward-line)) (point)))) - (unless (< p post-affiliated)) - (case type - (comment (looking-at "[ \t]*# ?") (match-string 0)) - (footnote-definition "") - ((item plain-list) - (make-string (org-list-item-body-column post-affiliated) ? )) - (paragraph - ;; Fill prefix is usually the same as the current line, - ;; except if the paragraph is at the beginning of an item. - (let ((parent (org-element-property :parent element))) - (cond ((eq (org-element-type parent) 'item) - (make-string (org-list-item-body-column - (org-element-property :begin parent)) - ? )) - ((save-excursion (beginning-of-line) (looking-at "[ \t]+")) - (match-string 0)) - (t "")))) - (comment-block - ;; Only fill contents if P is within block boundaries. - (let* ((cbeg (save-excursion (goto-char post-affiliated) - (forward-line) - (point))) - (cend (save-excursion - (goto-char (org-element-property :end element)) - (skip-chars-backward " \r\t\n") - (line-beginning-position)))) - (when (and (>= p cbeg) (< p cend)) - (if (save-excursion (beginning-of-line) (looking-at "[ \t]+")) - (match-string 0) - "")))))))))) + (unless (< p post-affiliated) + (case type + (comment (looking-at "[ \t]*# ?") (match-string 0)) + (footnote-definition "") + ((item plain-list) + (make-string (org-list-item-body-column post-affiliated) ? )) + (paragraph + ;; Fill prefix is usually the same as the current line, + ;; except if the paragraph is at the beginning of an item. + (let ((parent (org-element-property :parent element))) + (cond ((eq (org-element-type parent) 'item) + (make-string (org-list-item-body-column + (org-element-property :begin parent)) + ? )) + ((save-excursion (beginning-of-line) (looking-at "[ \t]+")) + (match-string 0)) + (t "")))) + (comment-block + ;; Only fill contents if P is within block boundaries. + (let* ((cbeg (save-excursion (goto-char post-affiliated) + (forward-line) + (point))) + (cend (save-excursion + (goto-char (org-element-property :end element)) + (skip-chars-backward " \r\t\n") + (line-beginning-position)))) + (when (and (>= p cbeg) (< p cend)) + (if (save-excursion (beginning-of-line) (looking-at "[ \t]+")) + (match-string 0) + ""))))))))))) (declare-function message-goto-body "message" ()) (defvar message-cite-prefix-regexp) ; From message.el From 6cd243468bfa770490074ade3e963b676026a4a1 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:50:49 +0100 Subject: [PATCH 4/9] Speed up setting/getting the APPT_WARNTIME property. * org.el (org-refresh-properties): Rename from `org-refresh-effort-properties' and use two new parameters. (org-agenda-prepare-buffers): Use `org-refresh-properties'. Also refresh the 'org-appt-warntime text property. * org-clock.el (org-clock-in): Use the renamed defun. * org-icalendar.el (org-icalendar-print-entries): Refresh the 'org-appt-warntime property. (org-icalendar-print-entries): Do not use `org-entry-get' to get the "APPT_WARNTIME" property value. * org-agenda.el (org-agenda-get-timestamps) (org-agenda-get-sexps, org-agenda-get-deadlines) (org-agenda-get-scheduled): Ditto. --- lisp/org-agenda.el | 8 ++++---- lisp/org-clock.el | 4 ++-- lisp/org-icalendar.el | 3 ++- lisp/org.el | 20 +++++++++++--------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index fe718d370..d1010e5cb 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5401,7 +5401,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? 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)) @@ -5472,7 +5472,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? category-pos (get-text-property beg 'org-category-position) tags (save-excursion (org-back-to-heading t) (org-get-tags-at)) 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) @@ -5844,7 +5844,7 @@ 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) @@ -5934,7 +5934,7 @@ FRACTION is what fraction of the head-warning time has passed." (match-string 1) 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) ;; When to show a scheduled item in the calendar: diff --git a/lisp/org-clock.el b/lisp/org-clock.el index d30c3747f..364c7b6f2 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -35,7 +35,7 @@ (declare-function calendar-absolute-from-iso "cal-iso" (&optional date)) (declare-function notifications-notify "notifications" (&rest params)) (declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) -(declare-function org-refresh-effort-properties "org" ()) +(declare-function org-refresh-properties "org" (dprop tprop)) (defvar org-time-stamp-formats) (defvar org-ts-what) (defvar org-frame-title-format-backup frame-title-format) @@ -1082,7 +1082,7 @@ time as the start time \(see `org-clock-continuously' to make this the default behavior.)" (interactive "P") (setq org-clock-notification-was-shown nil) - (org-refresh-effort-properties) + (org-refresh-properties org-effort-property) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el index f13f46d68..389dc5df1 100644 --- a/lisp/org-icalendar.el +++ b/lisp/org-icalendar.el @@ -327,6 +327,7 @@ When COMBINE is non nil, add the category to each line." tmp pri categories location summary desc uid alarm alarm-time (sexp-buffer (get-buffer-create "*ical-tmp*"))) (org-refresh-category-properties) + (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime) (save-excursion (goto-char (point-min)) (while (re-search-forward re1 nil t) @@ -357,7 +358,7 @@ When COMBINE is non nil, add the category to each line." (org-id-get-create) (or (org-id-get) (org-id-new))) categories (org-export-get-categories) - alarm-time (org-entry-get nil "APPT_WARNTIME") + alarm-time (get-text-property (point) 'org-appt-warntime) alarm-time (if alarm-time (string-to-number alarm-time) 0) alarm "" deadlinep nil scheduledp nil) diff --git a/lisp/org.el b/lisp/org.el index 6d2539eee..69b9a7861 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8642,23 +8642,24 @@ call CMD." (put-text-property beg end 'org-category-position beg) (goto-char pos))))))) -(defun org-refresh-effort-properties () - "Refresh effort text properties in the buffer." +(defun org-refresh-properties (dprop tprop) + "Refresh buffer text properties. +DPROP is the drawer property and TPROP is the corresponding text +property to set." (let ((case-fold-search t) - (inhibit-read-only t) e) + (inhibit-read-only t) p) (org-unmodified (save-excursion (save-restriction (widen) (goto-char (point-min)) - (put-text-property (point) (point-max) 'org-effort-timestamp (current-time)) - (while (re-search-forward (concat "^[ \t]*:" org-effort-property - ": +\\(.*\\)[ \t]*$") nil t) - (setq e (org-match-string-no-properties 1)) + (while (re-search-forward (concat "^[ \t]*:" dprop ": +\\(.*\\)[ \t]*$") nil t) + (setq p (org-match-string-no-properties 1)) (save-excursion (org-back-to-heading t) (put-text-property - (point-at-bol) (point-at-eol) 'org-effort e)))))))) + (point-at-bol) (point-at-eol) tprop p)))))))) + ;;;; Link Stuff @@ -17011,7 +17012,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (widen) (setq bmp (buffer-modified-p)) (org-refresh-category-properties) - (org-refresh-effort-properties) + (org-refresh-properties org-effort-property 'org-effort) + (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime) (setq org-todo-keywords-for-agenda (append org-todo-keywords-for-agenda org-todo-keywords-1)) (setq org-done-keywords-for-agenda From e4df4e9ffdc5b88fd6a67e0fbd00eb364bdfa24c Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:52:34 +0100 Subject: [PATCH 5/9] org-clock.el: Fix last commit. --- lisp/org-clock.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 364c7b6f2..8c26d93ae 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1082,7 +1082,7 @@ time as the start time \(see `org-clock-continuously' to make this the default behavior.)" (interactive "P") (setq org-clock-notification-was-shown nil) - (org-refresh-properties org-effort-property) + (org-refresh-properties org-effort-property 'org-effort) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) From aaf14258eb3a2f55e34dba47c7b475bf51b7a6b6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:57:27 +0100 Subject: [PATCH 6/9] org.el (org-scan-tags): The skipper already checks for archived entries * org.el (org-scan-tags): The skipper already checks for archived entries. --- lisp/org.el | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 69b9a7861..90e6abf5c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13150,18 +13150,9 @@ headlines matching this string." (or (not todo-only) (and (member todo org-not-done-keywords) (or (not org-agenda-tags-todo-honor-ignore-options) - (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item))))) - - ;; Extra check for the archive tag - ;; FIXME: Does the skipper already do this???? - (or - (not (member org-archive-tag tags-list)) - ;; we have an archive tag, should we use this anyway? - (or (not org-agenda-skip-archived-trees) - (and (eq action 'agenda) org-agenda-archives-mode)))) + (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))))) ;; select this headline - (cond ((eq action 'sparse-tree) (and org-highlight-sparse-tree-matches From b27a020a835f67c1c61bd2bb1a03accc4ad4b453 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 13:01:36 +0100 Subject: [PATCH 7/9] `org-float' is now obsolete * org-agenda.el (org-float): Don't alias `org-float'. * org.texi (Timestamps, Deadlines and scheduling): Use `diary-float' instead of the now obsolete alias `org-float'. * test-org-element.el (test-org-element/timestamp-interpreter): Ditto. --- doc/org.texi | 4 ++-- lisp/org-agenda.el | 1 - testing/lisp/test-org-element.el | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3fcdb3196..3b03f1409 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -5520,7 +5520,7 @@ example with optional time @example * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month - <%%(org-float t 4 2)> + <%%(diary-float t 4 2)> @end example @item Time/Date range @@ -5858,7 +5858,7 @@ entries. Org mode will issue early and late warnings based on the assumption that the timestamp represents the @i{nearest instance} of the repeater. However, the use of diary sexp entries like @c -@code{<%%(org-float t 42)>} +@code{<%%(diary-float t 42)>} @c in scheduling and deadline timestamps is limited. Org mode does not know enough about the internals of each sexp function to issue early and diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d1010e5cb..7ca50a4cc 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5521,7 +5521,6 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? (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) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index c9ee14a3b..97d8533eb 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -2074,8 +2074,8 @@ CLOSED: [2012-01-01] DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01>\n")))) "[2012-03-29 16:40]--[2012-03-29 16:41]") "[2012-03-29 16:40]--[2012-03-29 16:41]\n")) ;; Diary. - (should (equal (org-test-parse-and-interpret "<%%org-float t 4 2>") - "<%%org-float t 4 2>\n")) + (should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>") + "<%%diary-float t 4 2>\n")) ;; Timestamp with repeater interval. (should (equal (org-test-parse-and-interpret "<2012-03-29 +1y>") "<2012-03-29 +1y>\n"))) From babba02750320db077d048adf63a591848d54ac6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 13:47:59 +0100 Subject: [PATCH 8/9] org.el (org-use-tag-inheritance): Fix typo in docstring * org.el (org-use-tag-inheritance): Fix typo in docstring. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 90e6abf5c..826e96fe4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2988,7 +2988,7 @@ When nil, only the tags directly given in a specific line apply there. This may also be a list of tags that should be inherited, or a regexp that matches tags that should be inherited. Additional control is possible with the variable `org-tags-exclude-from-inheritance' which gives an -explicit list of tags to be excluded from inheritance., even if the value of +explicit list of tags to be excluded from inheritance, even if the value of `org-use-tag-inheritance' would select it for inheritance. If this option is t, a match early-on in a tree can lead to a large From c8bfd50223d1a75d12d7f74571c24951592c56ec Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 16:12:52 +0100 Subject: [PATCH 9/9] org-agenda.el: New option `org-agenda-use-tag-inheritance' * org-agenda.el (org-search-view, org-agenda-get-todos) (org-agenda-get-timestamps, org-agenda-get-sexps) (org-agenda-get-progress, org-agenda-get-deadlines) (org-agenda-get-scheduled, org-agenda-get-blocks) (org-agenda-change-all-lines): Get local tags only. (org-agenda-use-tag-inheritance): New option. (org-agenda-finalize): When `org-agenda-use-tag-inheritance' is non-nil, possibly reset tags in the agenda buffer. (org-agenda-check-type): Enhance docstring. See the docstring of the new option for details. --- lisp/org-agenda.el | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 7ca50a4cc..64063e6c0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1652,6 +1652,18 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour." :group 'org-agenda-line-format :type 'boolean) +(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 when selecting the agenda +entries, but you may want the agenda to use the inherited tags +anyway, e.g. for later tag filtering. + +Setting this to nil will speed up non-tags agenda view a lot." + :version "24.3") + (defcustom org-agenda-hide-tags-regexp nil "Regular expression used to filter away specific tags in agenda views. This means that these tags will be present, but not be shown in the agenda @@ -3552,9 +3564,20 @@ generating a new one." (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)) + (when (delq nil (mapcar (lambda (tp) (org-agenda-check-type nil tp)) + 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 (org-get-tags-at))))))))) (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)) @@ -4417,7 +4440,7 @@ in `org-agenda-text-search-extra-files'." (setq marker (org-agenda-new-marker (point)) category (org-get-category) category-pos (get-text-property (point) 'org-category-position) - tags (org-get-tags-at (point)) + tags (org-get-tags-at nil t) txt (org-agenda-format-item "" (buffer-substring-no-properties @@ -5241,7 +5264,7 @@ the documentation of `org-diary'." 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)) + tags (org-get-tags-at nil t) txt (org-agenda-format-item "" txt category tags t) priority (1+ (org-get-priority txt)) todo-state (org-get-todo-state)) @@ -5420,7 +5443,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? (assoc (point) deadline-position-alist)) (throw :skip nil)) (setq hdmarker (org-agenda-new-marker) - tags (org-get-tags-at)) + tags (org-get-tags-at nil t)) (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") (setq head (or (match-string 1) "")) (setq txt (org-agenda-format-item @@ -5470,7 +5493,7 @@ Do we have a reason to ignore this TODO entry because it has a time stamp? (setq marker (org-agenda-new-marker beg) category (org-get-category beg) category-pos (get-text-property beg 'org-category-position) - tags (save-excursion (org-back-to-heading t) (org-get-tags-at)) + tags (save-excursion (org-back-to-heading t) (org-get-tags-at nil t)) todo-state (org-get-todo-state) warntime (get-text-property (point) 'org-appt-warntime) extra nil) @@ -5639,7 +5662,7 @@ please use `org-class' instead." (setq txt org-agenda-no-heading-message) (goto-char (match-beginning 0)) (setq hdmarker (org-agenda-new-marker) - tags (org-get-tags-at)) + tags (org-get-tags-at nil t)) (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") (setq txt (match-string 1)) (when extra @@ -5849,7 +5872,7 @@ See also the user option `org-agenda-clock-consistency-checks'." (setq txt org-agenda-no-heading-message) (goto-char (match-end 0)) (setq pos1 (match-beginning 0)) - (setq tags (org-get-tags-at pos1)) + (setq tags (org-get-tags-at pos1 t)) (setq head (buffer-substring-no-properties (point) (progn (skip-chars-forward "^\r\n") @@ -5979,7 +6002,7 @@ FRACTION is what fraction of the head-warning time has passed." pastschedp)) (setq mm (assoc pos1 deadline-position-alist))) (throw :skip nil))) - (setq tags (org-get-tags-at)) + (setq tags (org-get-tags-at nil t)) (setq head (buffer-substring-no-properties (point) (progn (skip-chars-forward "^\r\n") (point)))) @@ -6061,7 +6084,7 @@ FRACTION is what fraction of the head-warning time has passed." (setq txt org-agenda-no-heading-message) (goto-char (match-beginning 0)) (setq hdmarker (org-agenda-new-marker (point))) - (setq tags (org-get-tags-at)) + (setq tags (org-get-tags-at nil t)) (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") (setq head (match-string 1)) (let ((remove-re @@ -6740,7 +6763,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)