On 2015-05-28 Thu 11:15, Thomas S. Dye wrote: > Titus von der Malsburg writes: > >> I can’t reproduce the second indent but I think it’s a bug that there is >> any indentation at all. >> >> The documentation of `org-edit-special' (C-x ') says: >> >> Call a special editor for the element at point. … >> >> No mention of indentation or other reformatting of my code. >> >> The same goes for `org-edit-src-exit' (C-c C-c) which says: >> >> Kill current sub-editing buffer and return to source buffer. >> >> The edit-in-buffer feature should not touch the indentation. If the >> syntax of the language is sensitive to indentation (e.g. Python) this >> can break the code. Example: >> >> #+BEGIN_SRC python :results output >> print "test" >> #+END_SRC >> >> is invalid Python syntax. >> >> Also having one function perform two very different actions (edit code >> in separate buffer *and* reformat the code) is poor design. At least in >> this special case. When I open the code in a separate buffer but then >> decide not to change it (C-c C-c), I'll end up with extra indentation >> and this will create unnecessary changes when I commit the file in git. > > Does the variable org-src-preserve-indentation get the behavior you're > after? It does. I propose two changes: 1.) The default value `org-src-preserve-indentation' should be t because that is safer (see Python example) and more conservative. (Don’t mess with my code!) 2.) The documentation of `org-edit-special' and `org-edit-src-exit' should point out that depending on `org-src-preserve-indentation' the code may be re-indented. Even better would be to remove `org-src-preserve-indentation' and to do the right thing, which is to leave the code untouched. Emacs already has facilities for indenting code. No need to reinvent the wheel. Titus