I'm trying to open Deft in the left sidebar using this code:

(setq display-buffer-alist
          (window-width . 0.25)
          (side . left)
          (slot . 0))))

This is not working and every time I call M-x deft, it shows in the main window.

What's wrong with my code? Has anyone had success in running Deft in the sidebar?

  • Your regexp doesn't match, try escaping the * it should be like this "\\*Deft\\*"
    – C11g
    May 30, 2021 at 10:03
  • I tried this before, doesn't change anything. Deft shows in the main window. May 30, 2021 at 10:37

1 Answer 1


Here's the definition of deft (version 20210101.1519 on MELPA)

(defun deft ()
  "Switch to *Deft* buffer and load files."
  (switch-to-buffer deft-buffer)
  (if (not (eq major-mode 'deft-mode))

So it uses your current window, then switch to a buffer with a name of the value of deft-buffer variable, "\*Deft\*" by default, then call deft-mode. This means that it doesn't create a new window, so setting display-buffer-alist does nothing. (Hope this is clear enough.)

You can probably write this in function advice, I prefer to not do this because of reasons. So here is a new function

(defun deft-side-window ()
  (let ((dummy-buf (generate-new-buffer deft-buffer)))
    (with-current-buffer dummy-buf
    (display-buffer dummy-buf)))

Firstly, it creates a new buffer named after the variable deft-buffer, call deft-mode then having Emacs try to display it, with this, it respects your display-buffer-alist.

Here's another version with your window rules if you want to do it manually.

(defun deft-side-window ()
  (let ((dummy-buf (generate-new-buffer deft-buffer)))
    (with-current-buffer dummy-buf
    (display-buffer-in-side-window dummy-buf
                   '((side . left)
                 (slot . 0)
                 (window-width . 0.25))))))

I messed up the formatting but it works! Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.