From f6426704852aa84f7b8fa4efda8560eb66a73a9a Mon Sep 17 00:00:00 2001 From: Rasmus Date: Thu, 18 Dec 2014 16:48:49 +0100 Subject: [PATCH 2/2] ox.el: Guess the :minlevel for INCLUDE-keywords * ox.el (org-export-expand-include-keyword): Guess :minlevel if missing. --- lisp/ox.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/ox.el b/lisp/ox.el index 99c4e9b..cba624c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3066,6 +3066,18 @@ storing and resolving footnotes. It is created automatically." (footnotes (or footnotes (make-hash-table :test #'equal))) (include-re "^[ \t]*#\\+INCLUDE:")) (goto-char (point-min)) + ;; Add :minlevel to all include words that no explicitly have one. + (save-excursion + (while (re-search-forward "^[ \t]*#\\+INCLUDE: \\(.*\\)$" nil t) + (let ((matched (match-string 1))) + (unless (or (string-match-p ":minlevel" matched) + (string-match-p "\\(\\\\)" matched)) + (goto-char (line-end-position)) + (insert (format " :minlevel %d" + (1+ (save-excursion + (if (search-backward-regexp org-heading-regexp nil t) + (length (match-string 1)) + 0))))))))) ;; Expand INCLUDE keywords. (while (re-search-forward include-re nil t) (let ((element (save-match-data (org-element-at-point)))) -- 2.2.0