I am trying to edit a document using org mode. The document represents a blog post. I need the body of the post to be in markdown so I am using a src block.
The problem is that when I alter or save the text in the src block after opening it in another buffer using C-c '
, there is some type of automatic indention that is applied that messes up my formatting.
Here are the details.
Beginning with with a buffer that looks like this:
* title...
* body
#+begin_src markdown
Some text.
#+end_src
I press C-c '
and get a new buffer where I edit the markdown text to look like this in markdown mode:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
viverra nec consectetur ante hendrerit. Donec et mollis
dolor. Praesent et diam eget libero egestas mattis sit amet vitae
I used M-q
to format the text lines so there are newlines at the end of each line above. There are also no initial spaces.
Now if I either press C-x C-s
to save or C-c '
the formatting above is changed to look like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
viverra nec consectetur ante hendrerit. Donec et mollis
dolor. Praesent et diam eget libero egestas mattis sit amet vitae
Every other line is indented two spaces.
I have tried this with other src types, such as using:
#+begin_src javascript
I get similar indentation, though it doesn't alternate. Two spaces are added to every line, instead.
I am assuming that this isn't a bug but my Internet searches and looks through the documentation haven't turned up the answer.
I'm using GNU Emacs 23.4.1 on Arch Linux with Org-mode 6.33x.
I also tried using the latest version of org-mode from git 7.8.05.
The variable you're looking to customize is org-edit-src-content-indentation
org-edit-src-content-indentation is a variable defined in `org-src.el'.
Its value is 2
Documentation: Indentation for the content of a source code block. This should be the number of spaces added to the indentation of the #+begin line in order to compute the indentation of the block content after editing it with M-x org-edit-src-code. Has no effect if `org-src-preserve-indentation' is non-nil.
You can discover this for yourself by:
C-h k C-c ' → org-edit-special
M-x apropos-variable
org-edit
On first glance this looks like the auto-indentation of blocks in Org. I do know that by default it tries to indent the body of the block to be two spaces in from the #+begin
and #+end
lines.
However, I would recommend updating to a newer version of Org. 6.33x is very old and there have been changes to code blocks in the meantime. It is available in the AUR (Here). However I would recommend using git to pull version 7.8.03 at the moment, there was a mistake made while releasing 7.8.04 and then 7.8.05 and they are in the midst of fixing it. Alternately, the version bundled with Emacs24 is stable and much more up to date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With