jrblevin / deft

Deft for Emacs
http://jblevins.org/projects/deft/
713 stars 87 forks source link

Default directory for new files #91

Open wd opened 3 years ago

wd commented 3 years ago

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.

glucas commented 2 months ago

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.