summaryrefslogtreecommitdiff
path: root/lisp/org/org-exp-blocks.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org/org-exp-blocks.el')
-rw-r--r--lisp/org/org-exp-blocks.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/org/org-exp-blocks.el b/lisp/org/org-exp-blocks.el
index 7d466cec65d..fbac6592090 100644
--- a/lisp/org/org-exp-blocks.el
+++ b/lisp/org/org-exp-blocks.el
@@ -211,7 +211,13 @@ which defaults to the value of `org-export-blocks-witheld'."
(when replacement
(delete-region match-start match-end)
(goto-char match-start) (insert replacement)
- (unless preserve-indent
+ (if preserve-indent
+ ;; indent only the code block markers
+ (save-excursion
+ (indent-line-to indentation) ; indent end_block
+ (goto-char match-start)
+ (indent-line-to indentation)) ; indent begin_block
+ ;; indent everything
(indent-code-rigidly match-start (point) indentation)))))
;; cleanup markers
(set-marker match-start nil)