summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2011-02-12 21:26:23 +0000
committerBastien Guerry <bzg@altern.org>2011-02-12 18:51:40 +0100
commit7dd425cc5d42fb297f547f713edfdc936f9271f0 (patch)
tree8b54318f72993a8598826b4edca4994072db390c
parent2df6f65e237920339c773ff2499cf060bc83fa32 (diff)
downloadorg-mode-7dd425cc5d42fb297f547f713edfdc936f9271f0.tar.gz
Allow properties to be retrieved before first heading in file.
* lisp/org.el (org-entry-get): Don't look for a property drawer if we are before the first heading in the file. (org-entry-get-with-inheritance): Don't attempt to move up the tree if we are before the first heading in the file. Also, enclose less of the function in the save-excursion.
-rw-r--r--lisp/org.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 7a55c3d..882cb7e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13568,7 +13568,8 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
;; We need a special property. Use `org-entry-properties' to
;; retrieve it, but specify the wanted property
(cdr (assoc property (org-entry-properties nil 'special property)))
- (let ((range (org-get-property-block)))
+ (let ((range (unless (org-before-first-heading-p)
+ (org-get-property-block))))
(if (and range
(goto-char (car range))
(re-search-forward
@@ -13681,6 +13682,7 @@ should be considered as undefined (this is the meaning of nil here).
However, if LITERAL-NIL is set, return the string value \"nil\" instead."
(move-marker org-entry-property-inherited-from nil)
(let (tmp)
+ (unless (org-before-first-heading-p)
(save-excursion
(save-restriction
(widen)
@@ -13691,11 +13693,12 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead."
(move-marker org-entry-property-inherited-from (point))
(throw 'ex tmp))
(or (org-up-heading-safe) (throw 'ex nil)))))
+ ))
(setq tmp (or tmp
(cdr (assoc property org-file-properties))
(cdr (assoc property org-global-properties))
(cdr (assoc property org-global-properties-fixed))))
- (if literal-nil tmp (org-not-nil tmp)))))
+ (if literal-nil tmp (org-not-nil tmp))))
(defvar org-property-changed-functions nil
"Hook called when the value of a property has changed.