0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-23 18:48:32 +00:00

Properties: Fix property-getting with inheritance

* lisp/org.el (org-entry-get-with-inheritance): Temporarily
let-bind `org-file-properties', `org-global-properties' and
`org-global-properties-fixed' to nil before calling `org-entry-get'
on entries up the hierarchy from the queried entry.

Problem was that when org-entry-get-with-inheritance went up the
hierarchy of entries from a given entry, checking whether the property
has been set in any of the entries, it was calling org-entry-get,
which always looks at file-scope and global-scope properties.  So if
our property was set file-wide or system-wide, and somewhere up the
hierarchy there was an entry which set some properties _other_ than
the one we're looking up but did not set ours, org-entry-get would
fill in the global property value and report that our property was in
fact set in that entry.  The search would stop, and if the property
was actually set further up the hierarchy (which should override
file-wide or system-wide settings), we would never get to that
up-the-hierarchy setting.

Illustration of fixed problem:

#+PROPERTY: myprop aaa
* headline A
	:PROPERTIES:
	:myprop: bbb
	:END:
*** headline B
		:PROPERTIES:
		:otherprop:       ccc
		:END:

    #+BEGIN_SRC emacs-lisp
    (message (org-entry-get-with-inheritance "myprop"))
    #+END_SRC

    #+RESULTS:
    : aaa

		Result should be bbb, which it is after the fix.
This commit is contained in:
Ilya Shlyakhter 2014-03-07 01:09:13 -05:00 committed by Bastien Guerry
parent 0997778dd1
commit 475f2f5388

View file

@ -15448,14 +15448,15 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead."
(save-restriction
(widen)
(catch 'ex
(while t
(when (setq tmp (org-entry-get nil property nil 'literal-nil))
(or (ignore-errors (org-back-to-heading t))
(goto-char (point-min)))
(move-marker org-entry-property-inherited-from (point))
(throw 'ex tmp))
(or (ignore-errors (org-up-heading-safe))
(throw 'ex nil))))))
(let (org-file-properties org-global-properties org-global-properties-fixed)
(while t
(when (setq tmp (org-entry-get nil property nil 'literal-nil))
(or (ignore-errors (org-back-to-heading t))
(goto-char (point-min)))
(move-marker org-entry-property-inherited-from (point))
(throw 'ex tmp))
(or (ignore-errors (org-up-heading-safe))
(throw 'ex nil)))))))
(setq tmp (or tmp
(cdr (assoc property org-file-properties))
(cdr (assoc property org-global-properties))