Browse Source

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.
Carsten Dominik 14 năm trước cách đây
mục cha
commit
ca733df0d4
3 tập tin đã thay đổi với 9 bổ sung11 xóa
  1. 1 2
      lisp/org-archive.el
  2. 1 3
      lisp/org-clock.el
  3. 7 6
      lisp/org.el

+ 1 - 2
lisp/org-archive.el

@@ -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

+ 1 - 3
lisp/org-clock.el

@@ -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)

+ 7 - 6
lisp/org.el

@@ -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)