diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 2b5ec31b7..1e89ffc05 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -414,8 +414,9 @@ Made for `org-tab-first-hook' in evil-mode." (org-demote))) t) ((org-in-src-block-p t) - (org-babel-do-in-edit-buffer - (call-interactively #'indent-for-tab-command)) + (save-window-excursion + (org-babel-do-in-edit-buffer + (call-interactively #'indent-for-tab-command))) t) ((and (save-excursion (skip-chars-backward " \t") diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index e27ec73be..5779c9ca2 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -277,14 +277,27 @@ Also adds support for a `:sync' parameter to override `:async'." (funcall orig-fn arg info params) (funcall fn orig-fn arg info params))))) + ;; HACK Fix #6061. Seems `org-babel-do-in-edit-buffer' has the side effect of + ;; deleting side windows. Should be reported upstream! This advice + ;; suppresses this behavior wherever it is known to be used. + (defadvice! +org-fix-window-excursions-a (fn &rest args) + "Suppress changes to the window config anywhere +`org-babel-do-in-edit-buffer' is used." + :around #'evil-org-open-below + :around #'evil-org-open-above + :around #'org-indent-region + :around #'org-indent-line + (save-window-excursion (apply fn args))) + (defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive) "Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation." :after #'org-return (when (and indent org-src-tab-acts-natively (org-in-src-block-p t)) - (org-babel-do-in-edit-buffer - (call-interactively #'indent-for-tab-command)))) + (save-window-excursion + (org-babel-do-in-edit-buffer + (call-interactively #'indent-for-tab-command))))) (defadvice! +org-inhibit-mode-hooks-a (fn datum name &optional initialize &rest args) "Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops."