From d9447ad7b08332cac005bcb602ac1e55cf0588cf Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 31 Oct 2009 15:43:42 -0400 Subject: [PATCH 1/2] Allow code indentation to be preserved on export This is controlled on a per-block basis with a new src block flag -i. It can be controlled globally using the variable org-src-preserve-indentation. --- lisp/org-exp.el | 4 +++- lisp/org-src.el | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index f08ce41..c6ffe75 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2273,6 +2273,8 @@ INDENT was the original indentation of the block." rpllbl (string-match "-r\\>" opts) keepp (string-match "-k\\>" opts) textareap (string-match "-t\\>" opts) + preserve-indentp (or org-src-preserve-indentation + (string-match "-i\\>" opts)) cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts) (string-to-number (match-string 1 opts)) 80) @@ -2285,7 +2287,7 @@ INDENT was the original indentation of the block." ;; we cannot use numbering or highlighting. (setq num nil cont nil lang nil)) (if keepp (setq rpllbl 'keep)) - (setq rtn (org-remove-indentation code)) + (setq rtn (if preserve-indentp code (org-remove-indentation code))) (when (string-match "^," rtn) (setq rtn (with-temp-buffer (insert rtn) diff --git a/lisp/org-src.el b/lisp/org-src.el index 463bfa8..de8f8a2 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -87,11 +87,13 @@ These are the regions where each line starts with a colon." (defcustom org-src-preserve-indentation nil "If non-nil, leading whitespace characters in source code - blocks are preserved. Otherwise, after editing with - \\[org-edit-src-code], the minimum (across-lines) number of - leading whitespace characters are removed from all lines, and - the code block is then uniformly indented according to the - value of `org-edit-src-content-indentation'." + blocks are preserved on export, and when switching between the + org buffer and the language mode edit buffer. If this variable + is nil then, after editing with \\[org-edit-src-code], the + minimum (across-lines) number of leading whitespace characters + are removed from all lines, and the code block is uniformly + indented according to the value of + `org-edit-src-content-indentation'." :group 'org-edit-structure :type 'boolean) -- 1.6.3.3