How to capture in the existing window?

Hi,

I would like to do capturing within the window I currently have active.
For example I often have a resource on one window and org-note on the other. Now when I do a new capture, org-roam-capture buffer will be opened on the window where the resource was. How I can change this behavior?

If you are not using Doom, try the code below. If you are using Doom, it uses its own (I think it’s a module called “popup” or something; I can’t remember).

For normal Emacs, with the change below, two things will happen:

  1. The selection screen of the template (if you have more than one) will open below the currently selected one
  2. The CAPTURE window will appear in the window you selected when you started the capture.

This way, I think your resource file won’t be covered over the CAPTURE window.

(setopt
 display-buffer-alist
 (cons '("\\*Org Select\\*" (display-buffer-below-selected))
       display-buffer-alist))

(setopt
 display-buffer-alist
 (cons '("CAPTURE*" (display-buffer-same-window))
       display-buffer-alist))

Window management in Emacs can be a rabbit hole. I suggest you first read the docstring of user option display-buffer-alist (the one you are adding custom values to in the code above).

There are many different functions you can use instead of display-buffer-below-selected and display-buffer-same-window. The image below is from customizing screen for display-buffer-alist. Note the drop-down menu I am showing where you see many functions to choose from.

In addition, I believe the following two resources are two of the best I have seen on this topic.

  1. The Emacs Window Management Almanac | Karthinks
  2. Emacs: control where buffers are displayed (the ‘display-buffer-alist’) | Protesilaos Stavrou