2

When editing org-src blocks, I sometimes go to other buffers while editing but whenever I close; it restores the window configuration before editing the block which is a minor annoyance when you need to find an existing buffer.

I checked out org-src.el and this is my hack.

        (defun fn/org-src-inhibit-save-window-configuration ()
                 "Disable org-src from saving the window configuration"
                 ;; HACK: This uses an internal variable, might be unstable
                 (setq org-src--saved-temp-window-config nil))

               (add-hook 'org-src-mode-hook #'fn/org-src-inhibit-save-window-configuration)

Sadly, this is touches on a private variable so my question is there a correct way of doing this?

  • I found I had to slightly modify your function to make it work for me, by wrapping the function body in (with-current-buffer (marker-buffer org-src--beg-marker) ...). I agree there should be a built-in option for this. – jackkamm Apr 6 at 22:00
2

If the first argument (labeled CONTEXT) to org-edit-src-code is 'save, then the window configuration is not saved. Try evaluating (org-edit-src-code 'save). Also, take a look at that function with M-x find-function RET org-edit-src-code RET. See where the first couple of lines of code say (unless (eq context 'save) (setq org-edit-src-saved-temp-window-config (current-window-configuration))).

See also the optional argument to org-edit-src-exit -- i.e., similar as above -- if it is 'save, then no restoration of window configuration occurs even though the variable org-src--saved-temp-window-config may contain a saved window configuration. To see the function, type M-x find-function RET org-edit-src-exit RET -- the relevant portion is at the tail end of said function.

  • My org-edit-src-code does not have a context arguments? Is it org-src-switch-to-buffer? My current org-version is 8.3.5. What I did find was only two points where org-src--saved-temp-window-config was being modified and those belong to org-edit-src-exit and org-edit-src-code. – fm2090 Aug 17 '16 at 11:28
  • Unfortunately, your version (which admittedly is the latest stable release) does not have a way for a user to turn off the feature. You would need to comment out line 396 of org-src.el and then M-x byte-compile-file. Essentially, you are commenting out: (setq org-src--saved-temp-window-config (current-window-configuration)). The version that I tested was the one that comes with the latest stable public release of Emacs 24.5.1, and org-mode version 8.2.10 is bundled with it. You could also add features to make it optional (like previous versions), instead of commenting it out. – lawlist Aug 17 '16 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.