From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Shlyakhter Subject: [PATCH] Fixed bug in org-entry-get-with-inheritance Date: Fri, 07 Mar 2014 01:28:13 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020702070401010508080004" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLoGn-0003CZ-Po for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 01:28:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLoGg-0007dH-FD for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 01:28:33 -0500 Received: from plane.gmane.org ([80.91.229.3]:42802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLoGg-0007d9-5G for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 01:28:26 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WLoGe-00074C-VC for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 07:28:24 +0100 Received: from wrls-140-247-0-35.wrls.harvard.edu ([140.247.0.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Mar 2014 07:28:24 +0100 Received: from ilya_shl by wrls-140-247-0-35.wrls.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Mar 2014 07:28:24 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------020702070401010508080004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit --------------020702070401010508080004 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-Properties-Fix-property-getting-with-inheritance.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Properties-Fix-property-getting-with-inheritance.patch" >From bea0daf422e9ab8f27addb412aa03456c89d5844 Mon Sep 17 00:00:00 2001 From: Ilya Shlyakhter 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 --------------020702070401010508080004--