From 6cd243468bfa770490074ade3e963b676026a4a1 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 7 Jan 2013 12:50:49 +0100 Subject: [PATCH] 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 -- 2.11.4.GIT