From 5406183319a9b26214c23b4869d9be218149aec1 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 17 Jun 2009 18:19:19 +0200 Subject: [PATCH] Blocks: Apply Erics patch for indented blocks in org-exp-blocks.el --- lisp/org-exp-blocks.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el index 848fc1399..56adb9f55 100644 --- a/lisp/org-exp-blocks.el +++ b/lisp/org-exp-blocks.el @@ -180,7 +180,7 @@ specified in BLOCKS which default to the value of (blocks org-export-blocks-witheld) (case-fold-search t) (types '()) - type func start end) + indentation type func start end) (flet ((interblock (start end type) (save-match-data (when (setf func (cadr (assoc type org-export-interblocks))) @@ -188,16 +188,22 @@ specified in BLOCKS which default to the value of (goto-char (point-min)) (setf start (point)) (while (re-search-forward - "^#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)#\\+end_\\S-+.*" nil t) - (save-match-data (setf type (intern (match-string 1)))) + "^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*" nil t) + (save-match-data (setq indentation (length (match-string 1)))) + (save-match-data (setf type (intern (match-string 2)))) (unless (memq type types) (setf types (cons type types))) (setf end (save-match-data (match-beginning 0))) (interblock start end type) (if (setf func (cadr (assoc type org-export-blocks))) - (replace-match (save-match-data - (if (memq type blocks) - "" - (apply func (match-string 3) (split-string (match-string 2) " ")))) t t)) + (progn + (replace-match (save-match-data + (if (memq type blocks) + "" + (apply func (save-match-data (org-remove-indentation (match-string 4))) + (split-string (match-string 3) " ")))) t t) + ;; indent the replaced match + (indent-region (match-beginning 0) (match-end 0) indentation) + )) (setf start (save-match-data (match-end 0)))) (mapcar (lambda (type) (interblock start (point-max) type)) -- 2.11.4.GIT