From 5e970e407a4d3c343141815f060560ad972d84c2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 15 Jan 2012 18:39:57 +0100 Subject: [PATCH] org-export: Add a new predicate to test if an headline is low level * contrib/lisp/org-export.el (org-export-low-level-p): New function. * EXPERIMENTAL/org-e-latex.el (org-e-latex-headline): Make use of new function. --- EXPERIMENTAL/org-e-latex.el | 4 +--- contrib/lisp/org-export.el | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/EXPERIMENTAL/org-e-latex.el b/EXPERIMENTAL/org-e-latex.el index 4ea2f2e69..a4a9ba51d 100644 --- a/EXPERIMENTAL/org-e-latex.el +++ b/EXPERIMENTAL/org-e-latex.el @@ -1040,9 +1040,7 @@ holding contextual information." ;; Case 2. This is a deep sub-tree: export it as a list item. ;; Also export as items headlines for which no section ;; format has been found. - ((or (not section-fmt) - (and (wholenump (plist-get info :headline-levels)) - (> level (plist-get info :headline-levels)))) + ((or (not section-fmt) (org-export-low-level-p headline info)) ;; Build the real contents of the sub-tree. (let ((low-level-body (concat diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 94bafa06b..e6c5f15d3 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2053,9 +2053,9 @@ INFO is the plist used as a communication channel." ;; headline, while `org-export-number-to-roman' allows to convert it ;; to roman numbers. -;; `org-export-first-sibling-p' and `org-export-last-sibling-p' are -;; two useful predicates when it comes to fulfill the -;; `:headline-levels' property. +;; `org-export-low-level-p', `org-export-first-sibling-p' and +;; `org-export-last-sibling-p' are three useful predicates when it +;; comes to fulfill the `:headline-levels' property. (defun org-export-get-relative-level (headline info) "Return HEADLINE relative level within current parsed tree. @@ -2063,6 +2063,19 @@ INFO is a plist holding contextual information." (+ (org-element-get-property :level headline) (or (plist-get info :headline-offset) 0))) +(defun org-export-low-level-p (headline info) + "Non-nil when HEADLINE is considered as low level. + +A low level headlines has a relative level greater than +`:headline-levels' property value. + +Return value is the difference between HEADLINE relative level +and the last level being considered as high enough, or nil." + (let ((limit (plist-get info :headline-levels))) + (when (wholenump limit) + (let ((level (org-export-get-relative-level headline info))) + (and (> level limit) (- level limit)))))) + (defun org-export-get-headline-number (headline info) "Return HEADLINE numbering as a list of numbers. INFO is a plist holding contextual information."