From 8320e4794efd0af7c86256865854f9f7232df60a Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 18 Oct 2023 11:37:13 +0300 Subject: [PATCH] org-entry-get-with-inheritance: Fix inherited explicit nil value * lisp/org.el (org-entry-get-with-inheritance): Do not ignore when property has explicit "nil" value. * testing/lisp/test-org.el (test-org/entry-get): Add test. --- lisp/org.el | 5 +++-- testing/lisp/test-org.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index c99887723..bda64bb6c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12958,7 +12958,8 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead." (org-element-at-point epom) (lambda (el) (pcase-let ((`(,val . ,val+) - (org--property-local-values property literal-nil el))) + ;; Force LITERAL-NIL t. + (org--property-local-values property t el))) (if (not val) ;; PROPERTY+ (prog1 nil ; keep looking for PROPERTY @@ -12976,7 +12977,7 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead." ;; only PROPERTY+). (unless found-inherited? (when-let ((global (org--property-global-or-keyword-value - property literal-nil))) + property t))) (setq values (cons global values)))) (when values (setq values (mapconcat diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 98d3e2782..21b850c03 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6863,6 +6863,34 @@ Paragraph" "#+PROPERTY: A 0\n* H\n:PROPERTIES:\n:A+: 1\n:END:" (org-mode-restart) (org-entry-get (point-max) "A" t)))) + ;; Explicit nil value takes precedence over parent non-nil properties. + (should-not + (org-test-with-temp-text + "* 1 +:PROPERTIES: +:PROP: value +:END: +** 2 +:PROPERTIES: +:PROP: nil +:END: +*** 3 +" + (org-entry-get (point-max) "PROP" t))) + (should + (equal "value" + (org-test-with-temp-text + "* 1 +:PROPERTIES: +:PROP: value +:END: +** 2 +:PROPERTIES: +:PROP: nil +:END: +*** 3 +" + (org-entry-get nil "PROP" t)))) ;; document level property-drawer has precedance over ;; global-property by PROPERTY-keyword. (should