fix(org): org-babel-do-in-edit-buffer deleting popups

Fix: #6061
This commit is contained in:
Henrik Lissner 2022-02-10 21:28:55 +01:00
parent 2df6a2e28a
commit 9217bb81f4
2 changed files with 18 additions and 4 deletions

View file

@ -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")

View file

@ -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."