Fix "Before first headline" error in `org-refresh-property'

* lisp/org.el (org-refresh-property): Ignore function when before
first headline or inlinetask.  Small refactoring.

Reported-by: Nick Dokos <ndokos@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/96552>
This commit is contained in:
Nicolas Goaziou 2015-03-31 15:57:54 +02:00
parent 2081cd3f62
commit c1a744659d
1 changed files with 14 additions and 14 deletions

View File

@ -9523,20 +9523,20 @@ the value of the drawer property."
(defun org-refresh-property (tprop p) (defun org-refresh-property (tprop p)
"Refresh the buffer text property TPROP from the drawer property P. "Refresh the buffer text property TPROP from the drawer property P.
The refresh happens only for the current tree (not subtree)." The refresh happens only for the current tree (not subtree)."
(save-excursion (unless (org-before-first-heading-p)
(org-back-to-heading t) (save-excursion
;; tprop is a text property symbol (org-back-to-heading t)
(if (symbolp tprop) (if (symbolp tprop)
(put-text-property ;; TPROP is a text property symbol
(point) (or (outline-next-heading) (point-max)) tprop p) (put-text-property
;; tprop is an alist with (properties . function) elements (point) (or (outline-next-heading) (point-max)) tprop p)
(mapc (lambda(al) ;; TPROP is an alist with (properties . function) elements
(save-excursion (dolist (al tprop)
(put-text-property (save-excursion
(point-at-bol) (or (outline-next-heading) (point-max)) (put-text-property
(car al) (line-beginning-position) (or (outline-next-heading) (point-max))
(funcall (cdr al) p)))) (car al)
tprop)))) (funcall (cdr al) p))))))))
(defun org-refresh-category-properties () (defun org-refresh-category-properties ()
"Refresh category text properties in the buffer." "Refresh category text properties in the buffer."