From 82812ff086ccb54eb41cd2f1df3fedea3a709ab8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 19 Nov 2017 23:59:56 +0100 Subject: [PATCH] ox: Fix UNNUMBERED strict inheritance * lisp/ox.el (org-export-numbered-headline-p): Use a less opinionated definition of inheritance. * testing/lisp/test-ox.el (test-org-export/numbered-headline-p): Update test. * doc/org.texi (Export settings): Insist on UNNUMBERED inheritance. It is now possible to number a headline within an unnumbered tree. --- doc/org.texi | 5 +++-- lisp/ox.el | 4 +--- testing/lisp/test-ox.el | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index fa42d2f49..21ec0e0cc 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10790,8 +10790,9 @@ Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}). @cindex property, UNNUMBERED Toggle section-numbers (@code{org-export-with-section-numbers}). When set to number @samp{n}, Org numbers only those headlines at level @samp{n} or above. -Set @code{UNNUMBERED} property to non-@code{nil} to disable numbering of -heading and subheadings entirely. +Setting @code{UNNUMBERED} property to non-@code{nil} disables numbering of +a heading. Since subheadings inherit from this property, it affect their +numbering, too. @item p: @vindex org-export-with-planning diff --git a/lisp/ox.el b/lisp/ox.el index af1686870..3c052a29f 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3954,9 +3954,7 @@ INFO is a plist holding contextual information." (defun org-export-numbered-headline-p (headline info) "Return a non-nil value if HEADLINE element should be numbered. INFO is a plist used as a communication channel." - (unless (cl-some - (lambda (head) (org-not-nil (org-element-property :UNNUMBERED head))) - (org-element-lineage headline nil t)) + (unless (org-not-nil (org-export-get-node-property :UNNUMBERED headline t)) (let ((sec-num (plist-get info :section-numbers)) (level (org-export-get-relative-level headline info))) (if (wholenump sec-num) (<= level sec-num) sec-num)))) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 6b5e3a30f..79429371f 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -2474,11 +2474,11 @@ Para2" (org-export-numbered-headline-p (org-element-map tree 'headline #'identity info t) info))) - ;; UNNUMBERED ignores inheritance. Any non-nil value among - ;; ancestors disables numbering. + ;; UNNUMBERED is inherited. (should - (org-test-with-parsed-data - "* H + (equal '(unnumbered numbered unnumbered) + (org-test-with-parsed-data + "* H :PROPERTIES: :UNNUMBERED: t :END: @@ -2486,10 +2486,12 @@ Para2" :PROPERTIES: :UNNUMBERED: nil :END: -*** H3" - (cl-every - (lambda (h) (not (org-export-numbered-headline-p h info))) - (org-element-map tree 'headline #'identity info))))) +** H3" + (org-element-map tree 'headline + (lambda (h) + (if (org-export-numbered-headline-p h info) 'numbered + 'unnumbered)) + info))))) (ert-deftest test-org-export/number-to-roman () "Test `org-export-number-to-roman' specifications."