From 3fc6fed1b070db92986f909d5eec38bc90c8322d Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Sun, 29 Jan 2023 18:45:42 -0600 Subject: [PATCH] FUCK (org-mode's utter disregard for) SIDE WINDOWS --- .../my-org-capture-shouldnt-mess-windows.el | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lisp/org-config/my-org-capture-shouldnt-mess-windows.el b/lisp/org-config/my-org-capture-shouldnt-mess-windows.el index daf7227..8d9543c 100644 --- a/lisp/org-config/my-org-capture-shouldnt-mess-windows.el +++ b/lisp/org-config/my-org-capture-shouldnt-mess-windows.el @@ -24,9 +24,16 @@ ;;; Code: +(defun my/side-window-p (window) + (window-parameter window 'window-side)) + (defun my/org-capture-shouldnt-mess-windows (fun &rest args) (let ((buffer (save-window-excursion + (--> (window-list) + (remove-if #'my/side-window-p it) + (car it) + (select-window it)) (apply fun args) (current-buffer)))) (pop-to-buffer buffer))) @@ -43,5 +50,19 @@ :around #'my/org-capture-finalize-shouldnt-mess-windows) +(defun my/org-todo-side-window-hack (fun &rest args) + (save-window-excursion + (let ((b (current-buffer))) + (--> (window-list) + (remove-if #'my/side-window-p it) + (car it) + (select-window it)) + (switch-to-buffer b) + (apply fun args)))) + +(advice-add #'org-todo + :around + #'my/org-todo-side-window-hack) + (provide 'my-org-capture-shouldnt-mess-windows) ;;; my-org-capture-shouldnt-mess-windows.el ends here