From d80b7726402a39b4c8a630a86614b0ba9d7eca6a Mon Sep 17 00:00:00 2001 From: Ken Williams Date: Thu, 16 Aug 2012 13:26:44 -0500 Subject: [PATCH] Change the edit-src-save code so that it either preserves original formatting, or imposes its new indentation, but not both. --- lisp/org-src.el | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index c110f32..61b800f 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -601,11 +601,9 @@ the language, a switch telling if the content should be in a single line." (buffer (current-buffer)) (single (org-bound-and-true-p org-edit-src-force-single-line)) (macro (eq single 'macro-definition)) - (total-nindent (+ (or org-edit-src-block-indentation 0) - org-edit-src-content-indentation)) (preserve-indentation org-src-preserve-indentation) (allow-write-back-p (org-bound-and-true-p org-edit-src-allow-write-back-p)) - (delta 0) code line col indent) + (delta 0) code line col indent total-nindent) (when allow-write-back-p (unless preserve-indentation (untabify (point-min) (point-max))) (if org-src-strip-leading-and-trailing-blank-lines @@ -640,14 +638,10 @@ the language, a switch telling if the content should be in a single line." (when (org-bound-and-true-p org-edit-src-picture) (setq preserve-indentation nil) (untabify (point-min) (point-max)) - (goto-char (point-min)) - (while (re-search-forward "^" nil t) - (replace-match ": "))) - (unless (or single preserve-indentation (= total-nindent 0)) - (setq indent (make-string total-nindent ?\ )) - (goto-char (point-min)) - (while (re-search-forward "^" nil t) - (replace-match indent))) + (org-prefixify ": ")) + (setq total-nindent (if preserve-indentation (or org-edit-src-block-indentation 0) + org-edit-src-content-indentation )) + (org-prefixify (make-string total-nindent ?\ )) (if (org-bound-and-true-p org-edit-src-picture) (setq total-nindent (+ total-nindent 2))) (setq code (buffer-string)) @@ -692,6 +686,12 @@ the language, a switch telling if the content should be in a single line." (message (or msg "")))) (def-edebug-spec org-src-in-org-buffer (body)) +(defun org-prefixify (s) + (unless (string= "" s) + (goto-char (point-min)) + (while (re-search-forward "^" nil t) + (replace-match s)))) + (defun org-edit-src-save () "Save parent buffer with current state source-code buffer." (interactive) -- 1.7.9