[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 0e731a4e71 2/2: org-export-expand-include-keyword:
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 0e731a4e71 2/2: org-export-expand-include-keyword: Preserve indentation |
Date: |
Sat, 29 Mar 2025 12:59:21 -0400 (EDT) |
branch: externals/org
commit 0e731a4e71d46218f973ca05dab9360b2e8384ff
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-export-expand-include-keyword: Preserve indentation
* lisp/ox.el (org-export--blindly-expand-include): Accept INDENTATION
as keyword argument rather than using `current-text-indentation'.
(org-export-expand-include-keyword): Pass indentation of the #+include
keyword to `org-export--blindly-expand-include'. Compute it before we
delete the keyword.
* testing/lisp/test-ox.el (test-org-export/expand-include): Add test.
Reported-by: Jens Lechtenboerger <lechten@wi.uni-muenster.de>
Link: https://orgmode.org/list/87o6xusl38.fsf@wi.uni-muenster.de
---
lisp/ox.el | 13 ++++++++-----
testing/lisp/test-ox.el | 10 ++++++++++
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 7e8ffc715d..274ca21c36 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3315,7 +3315,8 @@ variables in include file names."
(when (org-element-type-p element 'keyword)
(forward-line 0)
;; Extract arguments from keyword's value.
- (let* ((value (org-element-property :value element))
+ (let* ((indentation (org-current-text-indentation))
+ (value (org-element-property :value element))
(parameters (org-export-parse-include-value value dir))
(file (if expand-env
(substitute-env-in-file-name
@@ -3340,7 +3341,8 @@ variables in include file names."
:file-prefix file-prefix
:footnotes footnotes
:already-included included
- :expand-env expand-env)
+ :expand-env expand-env
+ :indentation indentation)
;; Expand footnotes after all files have been
;; included. Footnotes are stored at end of buffer.
(unless included
@@ -3435,7 +3437,8 @@ provided as the :unmatched parameter."
(cl-defun org-export--blindly-expand-include
(parameters
- &key includer-file file-prefix footnotes already-included expand-env)
+ &key includer-file file-prefix footnotes
+ already-included expand-env indentation)
"Unconditionally include reference defined by PARAMETERS in the buffer.
PARAMETERS is a plist of the form returned by `org-export-parse-include-value'.
@@ -3447,7 +3450,7 @@ which when provided allows footnotes to be handled
appropriately.
ALREADY-INCLUDED is a list of included names along with their
line restriction which prevents recursion. EXPAND-ENV is a flag to
expand environment variables for #+INCLUDE keywords in the included
-file."
+file. INDENTATION is the common indentation to be added."
(let* ((coding-system-for-read
(or (plist-get parameters :coding-system)
coding-system-for-read))
@@ -3455,7 +3458,7 @@ file."
(lines (plist-get parameters :lines))
(args (plist-get parameters :args))
(block (plist-get parameters :block))
- (ind (org-current-text-indentation)))
+ (ind indentation))
(cond
((eq (plist-get parameters :env) 'literal)
(insert
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 0a39ddf2db..ec16a75fc3 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -1302,6 +1302,16 @@ Text"
org-test-dir)
(org-export-expand-include-keyword)
(buffer-string))))
+ ;; Keep indentation
+ (should
+ (equal
+ " #+BEGIN_SRC emacs-lisp\n(+ 2 1)\n #+END_SRC\n"
+ (org-test-with-temp-text
+ (format
+ " #+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" SRC
emacs-lisp"
+ org-test-dir)
+ (org-export-expand-include-keyword)
+ (buffer-string))))
;; Inclusion within an html export-block.
(should
(equal