From: Arun Persaud <apersaud@lbl.gov>
To: emacs-orgmode@gnu.org
Subject: [Patch] don't add indent for empty line when exiting, a code edit
Date: Mon, 10 Mar 2014 17:22:16 -0700 [thread overview]
Message-ID: <531E5738.7040003@lbl.gov> (raw)
[-- Attachment #1: Type: text/plain, Size: 415 bytes --]
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
[-- Attachment #2: 0001-lisp-org-src.el-don-t-add-indent-for-empty-line-when.patch --]
[-- Type: text/x-patch, Size: 1223 bytes --]
From e393fed9dbb132fdefff66d304f67f7def643140 Mon Sep 17 00:00:00 2001
From: Arun Persaud <arun@nubati.net>
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
next reply other threads:[~2014-03-11 0:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-11 0:22 Arun Persaud [this message]
2014-03-12 18:08 ` [Patch] don't add indent for empty line when exiting, a code edit Bastien
2014-03-12 23:06 ` Charles Berry
2014-03-13 8:47 ` Bastien
2014-03-13 18:03 ` Charles Berry
2014-03-13 18:08 ` Bastien
2014-03-13 19:07 ` Charles Berry
2014-03-13 19:46 ` Bastien
2014-03-13 22:08 ` Charles C. Berry
2014-03-13 22:27 ` Florian Beck
2014-03-14 9:00 ` Bastien
2014-03-14 18:46 ` Arun Persaud
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=531E5738.7040003@lbl.gov \
--to=apersaud@lbl.gov \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).