Move the category property refresh to org-get-category where possible

* lisp/org.el (org-get-category): New optional argument FORCE-REFRESH.
Automatically refresh if the property is not there.
(org-entry-properties): Remove refresh - this is now done in
org-get-category.
* lisp/org-clock.el (org-clock-insert-selection-line): Let `org-get-category'
do the property refresh.
* lisp/org-archive.el (org-archive-subtree): Force a refresh of
category properties.

Based on a patch by Julien Danjou.
This commit is contained in:
Carsten Dominik 2011-01-03 13:12:42 +01:00
parent 088a9ae0ca
commit ca733df0d4
3 changed files with 9 additions and 11 deletions

View File

@ -226,8 +226,7 @@ this heading."
(save-excursion
(org-back-to-heading t)
;; Get context information that will be lost by moving the tree
(org-refresh-category-properties)
(setq category (org-get-category)
(setq category (org-get-category nil 'force-refresh)
todo (and (looking-at org-todo-line-regexp)
(match-string 2))
priority (org-get-priority

View File

@ -442,9 +442,7 @@ pointing to it."
(ignore-errors
(goto-char marker)
(setq file (buffer-file-name (marker-buffer marker))
cat (or (org-get-category)
(progn (org-refresh-category-properties)
(org-get-category)))
cat (org-get-category)
heading (org-get-heading 'notags)
prefix (save-excursion
(org-back-to-heading t)

View File

@ -8140,9 +8140,13 @@ call CMD."
;;;; Archiving
(defun org-get-category (&optional pos)
(defun org-get-category (&optional pos force-refresh)
"Get the category applying to position POS."
(get-text-property (or pos (point)) 'org-category))
(if force-refresh (org-refresh-category-properties))
(let ((pos (or pos (point))))
(or (get-text-property pos 'org-category)
(progn (org-refresh-category-properties)
(get-text-property pos 'org-category)))))
(defun org-refresh-category-properties ()
"Refresh category text properties in the buffer."
@ -13482,10 +13486,7 @@ things up because then unnecessary parsing is avoided."
'add_times))
props))
(unless (assoc "CATEGORY" props)
(setq value (or (org-get-category)
(progn (org-refresh-category-properties)
(org-get-category))))
(push (cons "CATEGORY" value) props))
(push (cons "CATEGORY" (org-get-category)) props))
(append sum-props (nreverse props)))))))
(defun org-entry-get (pom property &optional inherit literal-nil)