emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fixed bug in org-entry-get-with-inheritance
Date: Fri, 07 Mar 2014 01:28:13 -0500	[thread overview]
Message-ID: <lfbote$vv9$1@ger.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0001-Properties-Fix-property-getting-with-inheritance.patch --]
[-- Type: text/plain, Size: 2755 bytes --]

From bea0daf422e9ab8f27addb412aa03456c89d5844 Mon Sep 17 00:00:00 2001
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
Date: Fri, 7 Mar 2014 01:09:13 -0500
Subject: [PATCH] Properties: Fix property-getting with inheritance

* lisp/org.el (org-entry-get-with-inheritance): Temporarily clear
org-file-properties, org-global-properties and org-global-properties-fixed
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.
---
 lisp/org.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 6f4b853..cd2a1c6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15548,14 +15548,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))
-- 
1.8.4


             reply	other threads:[~2014-03-07  6:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07  6:28 Ilya Shlyakhter [this message]
2014-03-14 11:16 ` [PATCH] Fixed bug in org-entry-get-with-inheritance Bastien
2014-03-17 18:25   ` Achim Gratz
2014-03-17 19:08     ` Bastien
2014-03-17 19:20       ` Achim Gratz
2014-03-17 19:33         ` Bastien
2014-03-17 19:49           ` Achim Gratz
2014-03-17 20:35             ` Bastien
2014-03-17 20:51               ` Achim Gratz
2014-03-17 20:56                 ` Bastien
2014-03-17 21:30               ` Ilya Shlyakhter
2014-03-17 21:43                 ` Achim Gratz
2014-03-17 22:06                   ` Ilya Shlyakhter
2014-03-17 22:13                     ` Bastien
2014-03-18 12:01                       ` Bastien
2014-03-18 15:14                       ` Bastien
2014-03-18 15:38                         ` Ilya Shlyakhter
2014-03-18 17:23                         ` Achim Gratz
2014-03-18 18:27                           ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='lfbote$vv9$1@ger.gmane.org' \
    --to=ilya_shl@alum.mit.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).