浏览代码

Small refactoring

* lisp/org.el (org--property-global-value): New function.
(org-entry-get-with-inheritance): Use new function.
Nicolas Goaziou 8 年之前
父节点
当前提交
f2e861e0be
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      lisp/org.el

+ 12 - 4
lisp/org.el

@@ -16016,6 +16016,17 @@ unless LITERAL-NIL is non-nil."
 	;; Return final values.
 	;; Return final values.
 	(and (not (equal value '(nil))) (nreverse value))))))
 	(and (not (equal value '(nil))) (nreverse value))))))
 
 
+(defun org--property-global-value (property literal-nil)
+  "Return value for PROPERTY in current buffer.
+Return value is a string.  Return nil if property is not set
+globally.  Also return nil when PROPERTY is set to \"nil\",
+unless LITERAL-NIL is non-nil."
+  (let ((global
+	 (cdr (or (assoc-string property org-file-properties t)
+		  (assoc-string property org-global-properties t)
+		  (assoc-string property org-global-properties-fixed t)))))
+    (if literal-nil global (org-not-nil global))))
+
 (defun org-entry-get (pom property &optional inherit literal-nil)
 (defun org-entry-get (pom property &optional inherit literal-nil)
   "Get value of PROPERTY for entry or content at point-or-marker POM.
   "Get value of PROPERTY for entry or content at point-or-marker POM.
 
 
@@ -16168,10 +16179,7 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead."
 	     (throw 'exit nil))
 	     (throw 'exit nil))
 	    ((org-up-heading-safe))
 	    ((org-up-heading-safe))
 	    (t
 	    (t
-	     (let ((global
-		    (cdr (or (assoc-string property org-file-properties t)
-			     (assoc-string property org-global-properties t)
-			     (assoc-string property org-global-properties-fixed t)))))
+	     (let ((global (org--property-global-value property literal-nil)))
 	       (cond ((not global))
 	       (cond ((not global))
 		     (value (setq value (concat global " " value)))
 		     (value (setq value (concat global " " value)))
 		     (t (setq value global))))
 		     (t (setq value global))))