Ihor Radchenko <[email protected]> writes:
>> As others I am currently advising a lot of org display functions to make
>> them obey to my 'display-buffer-alist'. I hope for a better cooperation
>> from org to window.el.
>
> Can you elaborate? We are looking forward for ideas how to improve Org
> in this area. More concrete suggestions are welcome.
>
The last time I looked into org-todo I seen that somewhere a call to
split-window was make, so wathever I was trying to configure with
display-buffer-alist would not conclude.
Then I translated that from Doom's Emacs.
#+begin_src emacs-lisp
;; Ensure todo, agenda, and other minor popups are delegated to the popup
system.
;; needed for at least org-noter / org-insert-structure-template
(with-eval-after-load 'org
(advice-add #'org-switch-to-buffer-other-window :override
(defun +popup--org-pop-to-buffer-a (buf &optional norecord)
"Use `pop-to-buffer' instead of `switch-to-buffer' to open
buffer.'"
(pop-to-buffer buf nil norecord)))
(defun +popup--suppress-delete-other-windows-a (fn &rest args)
(cl-letf (((symbol-function #'delete-other-windows) #'ignore)
((symbol-function #'delete-window) #'ignore))
(apply fn args)))
(dolist (fn '(org-add-log-note
org-capture-place-template
org-export--dispatch-ui
org-agenda-get-restriction-and-command
org-goto-location
org-fast-tag-selection
org-fast-todo-selection))
(advice-add fn :around #'+popup--suppress-delete-other-windows-a))
(advice-add #'org-fit-window-to-buffer :override #'fit-window-to-buffer))
#+end_src
You can see that it is not only the org-no-popup macro that is in
question but more generally the liberal usage of _split/switch/delete
windows_.
So if we want to make org cooperate with window.el we must ban theses
functions and instead delegate the window management with calls to
proper display functions.
Concretly if you look at org-fast-todo-selection you can see :
(if expert
(set-buffer (get-buffer-create " *Org todo*"))
(delete-other-windows)
(set-window-buffer (split-window-vertically) (get-buffer-create "
*Org todo*"))
(org-switch-to-buffer-other-window " *Org todo*"))
Now consider in place :
(set-buffer (get-buffer-create " *Org todo*"))
(unless expert
(display-buffer " *Org todo*"
'((display-buffer-below-selected)
(window-height . fit-window-to-buffer))))
It will display this buffer below the currently selected window and fit
him.
Let's imagine the user wants in place to use :
(add-to-list 'display-buffer-alist
'(" *Org todo*"
(display-buffer-in-side-window)
(side . top)))
Now the buffer display in a side window at top.