I am having a strange problem with R Source Blocks. Let me explain (I hope the 
explanation below makes sense).

When I am creating a source block, I typically create the #+BEGIN_SRC and 
#+END_SRC lines, and then use C-c ' to enter ESS mode, fill the block there, 
and return to my org buffer using C-c ' again. 

While I am filling in my source block, I sometimes need to refer to my full org 
file and some other source blocks in there. So my cursor in the Org file moves. 
Then, if my code block is a little complex, I like to save it while I am 
editing (C-x C-s). This is where the mess is created. Instead of saving the 
code in the source block from where ESS was called, the code is saved at the 
point where my cursor in the org file at the moment is. As a result, I get a 
copy of the source code text (without the BEGIN_SRC and END_SRC lines) at the 
place where my cursor is. This obviously creates a total mess and I have to 
clean it up.

Is this the intended behaviour? I have used source code blocks for years and 
have not had this problem before. But I cannot say whether this is a new 
behaviour in org or something in my behaviour has changed. In the past, I 
perhaps never moved the cursor in my org buffer while editing a source code 
block. 

Of course, one advice could be not to switch back from the ESS buffer without 
closing it. But a better thing would be if saving in the ESS buffer saved the 
source code block in the right place. But I don’t know if that is too much to 
ask.

Vikas


Reply via email to