summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <davison@stats.ox.ac.uk>2009-10-31 15:45:52 -0400
committerDan Davison <davison@stats.ox.ac.uk>2009-10-31 15:45:52 -0400
commit957b4088483d910a496a0bcd13b10621bc7504bd (patch)
tree73151e3ef1900f5da3fc6e18c440dbefdb8839ee
parentd9447ad7b08332cac005bcb602ac1e55cf0588cf (diff)
downloadorg-mode-957b4088483d910a496a0bcd13b10621bc7504bd.tar.gz
Allow org-exp-blocks plugins to return block with indentation unaltered.
With these changes, if org-src-preserve-indentation is non-nil, or if the block has a -i switch, then the behaviour of org-exp-blocks is altered as follows: 1. Indentation is not removed before passing the block contents to the block-transforming plugin. 2. The result returned by the plugin is not re-indented.
-rw-r--r--lisp/org-exp-blocks.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el
index 646688d..a78da00 100644
--- a/lisp/org-exp-blocks.el
+++ b/lisp/org-exp-blocks.el
@@ -166,7 +166,7 @@ specified in BLOCKS which default to the value of
(save-window-excursion
(let ((case-fold-search t)
(types '())
- indentation type func start)
+ indentation type func start body headers preserve-indent)
(flet ((interblock (start end)
(mapcar (lambda (pair) (funcall (second pair) start end))
org-export-interblocks)))
@@ -176,17 +176,20 @@ specified in BLOCKS which default to the value of
"^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*" nil t)
(setq indentation (length (match-string 1)))
(setq type (intern (match-string 2)))
+ (setq headers (save-match-data (split-string (match-string 3) "[ \t]")))
+ (setq body (match-string 4))
+ (setq preserve-indent (or org-src-preserve-indentation (member "-i" headers)))
+ (unless preserve-indent
+ (setq body (save-match-data (org-remove-indentation body))))
(unless (memq type types) (setq types (cons type types)))
(save-match-data (interblock start (match-beginning 0)))
(if (setq func (cadr (assoc type org-export-blocks)))
(progn
(replace-match (save-match-data
- (if (memq type org-export-blocks-witheld)
- ""
- (apply func (save-match-data (org-remove-indentation (match-string 4)))
- (split-string (match-string 3) " ")))) t t)
- ;; indent block
- (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
+ (if (memq type org-export-blocks-witheld) ""
+ (apply func body headers))) t t)
+ (unless preserve-indent
+ (indent-code-rigidly (match-beginning 0) (match-end 0) indentation))))
(setq start (match-end 0)))
(interblock start (point-max))))))