>From e393fed9dbb132fdefff66d304f67f7def643140 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 10 Mar 2014 17:09:12 -0700 Subject: [PATCH] lisp/org-src.el: don't add indent for empty line when exiting a code edit Using C-c ' to edit code blocks adds an indent to all lines when exiting from the code edit. This leaves trailing whitespace in the buffer, which can be especially annoying when using show-trailing-whitespace. --- lisp/org-src.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index d1f6879..ef09bd6 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -737,8 +737,10 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (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))) + (while (re-search-forward "^" nil t) + (if (not (looking-at "$")) + (replace-match indent) + (forward-char 1)))) (if (org-bound-and-true-p org-edit-src-picture) (setq total-nindent (+ total-nindent 2))) (setq code (buffer-string)) -- 1.9.0