From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Persaud Subject: [Patch] don't add indent for empty line when exiting, a code edit Date: Mon, 10 Mar 2014 17:22:16 -0700 Message-ID: <531E5738.7040003@lbl.gov> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070704070606040508090804" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNATA-0006sh-Ec for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 20:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNAT3-0001JF-Lj for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 20:22:56 -0400 Received: from fe2.lbl.gov ([128.3.41.134]:6549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNAT3-0001J5-Fe for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 20:22:49 -0400 Received: by mail-pd0-f177.google.com with SMTP id g10so7664213pdj.8 for ; Mon, 10 Mar 2014 17:22:19 -0700 (PDT) Received: from [128.3.5.223] (apersaud.dhcp.lbl.gov. [128.3.5.223]) by mx.google.com with ESMTPSA id ei4sm69544438pbb.42.2014.03.10.17.22.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Mar 2014 17:22:18 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------070704070606040508090804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi I started using org babel for python, but when using C-c ' I always ended up with white space added to the empty lines in the source code when returning into the org buffer. This especially shows up (setq-default show-trailing-whitespace t). I tried to fix this in org. It seems to work over here, but my elisp as well as my understanding of org-mode is not perfect ;) Let me know if it needs more work. Arun --------------070704070606040508090804 Content-Type: text/x-patch; name="0001-lisp-org-src.el-don-t-add-indent-for-empty-line-when.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-lisp-org-src.el-don-t-add-indent-for-empty-line-when.pa"; filename*1="tch" >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 --------------070704070606040508090804--