# Org-capture: Capture template ‘d’: Cannot make side window the only window

**URL:** <https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986>\
**Category:** Troubleshooting\
**Created:** [February 21, 2023, 11:00am UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986 "2023-02-21T11:00:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea\_crotti](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/andrea_crotti/32/878_2.png) [@andrea\_crotti](https://org-roam.discourse.group/u/andrea_crotti)\
**Post date:** [February 21, 2023, 11:00am UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/1 "2023-02-21T11:00:27Z")

</div>

This is my Emacs configuration

> <https://github.com/AndreaCrotti/Emacs-configuration/blob/master/ca-init.el>

and I’m now getting this the error in subject when I try to create a new node.  
Weirdly after I removed my whole `.emacs.d` and recreated it it was fixed, but today it’s broken again without really having done any changes.  
Any idea what it could be?  
I suspect it’s maybe related to treemacs, but changing the config there didn’t help yet, so maybe it’s something else.

---

<div class="post-metadata">

**Author:** ![andrea\_crotti](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/andrea_crotti/32/878_2.png) [@andrea\_crotti](https://org-roam.discourse.group/u/andrea_crotti)\
**Post date:** [February 21, 2023, 11:12am UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/2 "2023-02-21T11:12:08Z")

</div>

Actually I could narrow it down, the problem is this function

```auto
(defun treemacs-enable-and-show ()
  (message "inside treemacs-enable-and-show")
  (when buffer-file-name
    (when (equal 'none (treemacs-current-visibility))
      (treemacs--init))

    (with-current-buffer (find-buffer-visiting buffer-file-name)
      (treemacs-display-current-project-exclusively))) )

```

Which is used a find-file-hook:  
`(add-hook 'find-file-hook 'treemacs-enable-and-show)`

Not sure how to fix it though, org-capture is doing something weird apparently there when creating the buffer?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [February 21, 2023, 11:59am UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/3 "2023-02-21T11:59:45Z")

</div>

> [@andrea\_crotti](#):
>
> (add-hook 'find-file-hook 'treemacs-enable-and-show)

I’d suggest:

(remove-hook 'find-file-hook 'treemacs-enable-and-show)

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [February 21, 2023, 12:04pm UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/4 "2023-02-21T12:04:54Z")

</div>

Also try toggle-debug-on-error and see the backtrace. it should show a call stack, which helps you determine offending function and context.

---

<div class="post-metadata">

**Author:** ![andrea\_crotti](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/andrea_crotti/32/878_2.png) [@andrea\_crotti](https://org-roam.discourse.group/u/andrea_crotti)\
**Post date:** [February 21, 2023, 9:11pm UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/5 "2023-02-21T21:11:21Z")

</div>

Yeah sure I removed the hook, but I would like to enable it again once I fix it, since it’s quite useful.  
Anyway this is the full error, and the file is actually created, and if I try to visit it a second time it works, I just can’t see see the right buffer when I do `C-c n f` for the first time.

```plaintext
  error("Capture template `%s': %s" "d" "Cannot make side window the only window")
  org-capture(nil "d")
  org-roam-capture-(:node #s(org-roam-node :file nil :file-title nil :file-hash nil :file-atime nil :file-mtime nil :id "2ed85b66-dc6f-4d5e-9f7a-4946f2dbe18f" :level nil :point nil :todo nil :priority nil :scheduled nil :deadline nil :title "check check again" :properties nil :olp nil :tags nil :aliases nil :refs nil) :templates nil :props (:finalize find-file :call-location #<marker at 1 in 20230221110739-check_somethinig.org>))
  org-roam-node-find()
  funcall-interactively(org-roam-node-find)
  #<subr command-execute>(org-roam-node-find nil nil nil)
  ad-Advice-command-execute(#<subr command-execute> org-roam-node-find)
  apply(ad-Advice-command-execute #<subr command-execute> org-roam-node-find)
  command-execute(org-roam-node-find)

```

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [February 22, 2023, 5:47pm UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/6 "2023-02-22T17:47:04Z")

</div>

What seems to be happening is as follows:

1. You star org-capture via org-roam-node-find
2. Emacs opens a capture buffer
3. At the same time, Emacs opens a treemacs buffer as a side-buffer via find-file-hook
4. You complete the capture peocess
5. Emacs tries to close the capture buffer
6. Emacs errors because side-buffer cannot be threonly buffer in a frame

If this is indeed what is happening then, you can just have a conditional in your the function set in find-file-hook to avoid opening treemacs for the capture buffer.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [February 22, 2023, 5:55pm UTC](https://org-roam.discourse.group/t/org-capture-capture-template-d-cannot-make-side-window-the-only-window/2986/7 "2023-02-22T17:55:16Z")

</div>

> [@andrea\_crotti](#):
>
> `treemacs-enable-and-show`

To test the idea, it should be trivial to modify the initial conditional in this function and check if the buffer-name contains “CAPTURE”.
