Customizing deft-open-file-other-window
Thanks for the package! I am using it to implement a Zettelkasten.
Is there a way to customize deft-open-file-other-window or C-o? The current behavior splits the window vertically. If I were to make a request for additional features, it would be for (1) a function that opens the note file in an existing other or target window without altering the existing window layout; and (2) a function very similar to deft-open-file-other-window but which splits the window horizontally rather than vertically such that the note buffer appears below the Deft buffer.
Thanks again!
Currently, no, but I'd be happy to add such a feature. Please also see the discussion in #22.
I'm not an expert on window management, so I don't quite know what the right "Emacs way" to implement this is. For example, I wouldn't quite know how to implement (1) above. If you're able to submit a patch, I will certainly take a look.
Thanks for the quick response! I don't know any Elisp (or any other programming languages) sadly. I'll be sure to have a look at #22.
Emacs has a general mechanism for deciding how windows are split and/or reused. See How display-buffer works in the Emacs manual for more. You can tune this behavior by customizing display-buffer-alist -- see Choosing a Window for Display.
The display-buffer-alist lets you define rules for how to display buffers based on the buffer name. That may not help here because your deft buffers can have arbitrary names. However you can use this same mechanism to define your own variations of deft-open-file-other-window. For example, here's a command that will open the file in a window below the current window.
(defun my-deft-open-file-below ()
(interactive)
(let ((display-buffer-overriding-action
(cons
'(display-buffer-reuse-window
display-buffer-use-some-window
display-buffer-below-selected)
nil)))
(deft-open-file-other-window)))
This works by temporarily changing the default display action list before calling `deft-open-file-other-window. The specified action list is:
- If the buffer is already displayed somewhere, reuse that window.
- Otherwise use an existing window.
- Otherwise split to create a new window below the current one.