The Org Code Edit Buffer

I use the Org-mode code editing buffer all the time either for adding some code to a post or for embedding a tweet or video. When I’m writing a blog post, I always have two windows displayed. On the left is my blog queue file with past/current/future blog post ideas and notes. On the right is the actual post I’m writing.

It used to be that when I toggled into the code editing buffer, the right buffer would replace the left and the code editing buffer would be on the right. When I toggled out of the code editing buffer, things would be restored. That always worked perfectly for me but apparently caused problems with other window configurations so recently Org was changed so that after exiting the code editing buffer, the post (right) buffer would be the only one displayed. I could sort of fix this with winner-mode but it left the point on the blog queue (left) window in the wrong place. I grumbled a bit but made do.

Then I saw this tweet:

I had no idea what org-src-window-setup was for so just out of curiosity I queried Emacs about its function. It turns out it controls what happens to the currently displayed windows when you invoke the Org code editing buffer. There are a several possible options for the variable but I tried current-window as suggested by KDr2 and suddenly my problem with the using the code edit buffer was resolved. What happens is that the editing buffer window replaces the Org buffer window I was working in and then restores it when I exit the editing buffer.

I do lose the ability to look at the Org buffer I was working on but, at least for me, that isn’t a problem and even if it was I could simply toggle out of the editing buffer to check what I needed to and then toggle back in.

This is a really great solution to the problem I was having with using the code editing buffer and I wish I’d learned about it sooner. Thanks to KDr2 for enlightening me.

This entry was posted in General and tagged , . Bookmark the permalink.