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.
This commit is contained in:
Nicolas Goaziou 2017-11-19 23:59:56 +01:00
parent 946f76d707
commit 82812ff086
3 changed files with 14 additions and 13 deletions

View File

@ -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

View File

@ -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))))

View File

@ -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."