jrblevin / deft

Deft for Emacs

Home Page:http://jblevins.org/projects/deft/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default directory for new files

wd opened this issue · comments

The new file will put under deft-directory by default, is there any settings that can put the file to deft-directory/notes ? I want to use deft to search from all files in deft-directory, but want new file to put under deft-directory/notes.

There is no built-in support for this, but I wanted the same thing. I've got a workaround with advice that seems to work.

(defun my/use-deft-notes-dir (orig &rest args)
  (let ((deft-directory my/notes-dir))
    (apply orig args)))

(advice-add #'deft-absolute-filename :around #'my/use-deft-notes-dir)

This replaces the value for deft-directory in the function the builds the absolute path for a new file. You can set your own notes directory, e.g. (defvar my/notes-dir (expand-file-name "notes" deft-directory)).

So far it seems to work fine. Having deft provide a deft-new-file-directory would be great though.