From 554c9e3228b54044a0fbe1caa4008a4cefdd87b6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 29 May 2014 23:46:11 +0200 Subject: [PATCH] org.el (org-refresh-effort-properties): New function * org.el (org-refresh-effort-properties): New function. (org-agenda-prepare-buffers, org-mode): Use it. --- lisp/org.el | 81 ++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 6d82aeeed..b10e82666 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5550,7 +5550,8 @@ The following commands are available: (when org-startup-with-latex-preview (org-preview-latex-fragment)) (unless org-inhibit-startup-visibility-stuff - (org-set-startup-visibility)))) + (org-set-startup-visibility)) + (org-refresh-effort-properties))) ;; Try to set org-hide correctly (let ((foreground (org-find-invisible-foreground))) (if foreground @@ -9414,6 +9415,40 @@ call CMD." ;;; Refresh properties +(defun org-refresh-properties (dprop tprop) + "Refresh buffer text properties. +DPROP is the drawer property and TPROP is either the +corresponding text property to set, or an alist with each element +being a text property (as a symbol) and a function to apply to +the value of the drawer property." + (let ((case-fold-search t) + (inhibit-read-only t)) + (org-with-silent-modifications + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (while (re-search-forward (concat "^[ \t]*:" dprop ": +\\(.*\\)[ \t]*$") nil t) + (org-refresh-property tprop (org-match-string-no-properties 1)))))))) + +(defun org-refresh-property (tprop p) + "Refresh the buffer text property TPROP from the drawer property P. +The refresh happens only for the current tree (not subtree)." + (save-excursion + (org-back-to-heading t) + ;; tprop is a text property symbol + (if (symbolp tprop) + (put-text-property + (point) (or (outline-next-heading) (point-max)) tprop p) + ;; tprop is an alist with (properties . function) elements + (mapc (lambda(al) + (save-excursion + (put-text-property + (point-at-bol) (or (outline-next-heading) (point-max)) + (car al) + (funcall (cdr al) p)))) + tprop)))) + (defun org-refresh-category-properties () "Refresh category text properties in the buffer." (let ((case-fold-search t) @@ -9466,39 +9501,12 @@ call CMD." (put-text-property (point) (progn (org-end-of-subtree t t) (point)) 'org-stats stats))))))) -(defun org-refresh-properties (dprop tprop) - "Refresh buffer text properties. -DPROP is the drawer property and TPROP is either the -corresponding text property to set, or an alist with each element -being a text property (as a symbol) and a function to apply to -the value of the drawer property." - (let ((case-fold-search t) - (inhibit-read-only t)) - (org-with-silent-modifications - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward (concat "^[ \t]*:" dprop ": +\\(.*\\)[ \t]*$") nil t) - (org-refresh-property tprop (org-match-string-no-properties 1)))))))) - -(defun org-refresh-property (tprop p) - "Refresh the buffer text property TPROP from the drawer property P. -The refresh happens only for the current tree (not subtree)." - (save-excursion - (org-back-to-heading t) - ;; tprop is a text property symbol - (if (symbolp tprop) - (put-text-property - (point) (or (outline-next-heading) (point-max)) tprop p) - ;; tprop is an alist with (properties . function) elements - (mapc (lambda(al) - (save-excursion - (put-text-property - (point-at-bol) (or (outline-next-heading) (point-max)) - (car al) - (funcall (cdr al) p)))) - tprop)))) +(defun org-refresh-effort-properties () + "Refresh effort properties" + (org-refresh-properties + org-effort-property + '((effort . identity) + (effort-minutes . org-duration-string-to-minutes)))) ;;;; Link Stuff @@ -18344,10 +18352,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (or (memq 'stats org-agenda-ignore-properties) (org-refresh-stats-properties)) (or (memq 'effort org-agenda-ignore-properties) - (org-refresh-properties - org-effort-property - '((effort . identity) - (effort-minutes . org-duration-string-to-minutes)))) + (org-refresh-effort-properties)) (or (memq 'appt org-agenda-ignore-properties) (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)) (setq org-todo-keywords-for-agenda