In deft mode I can change the default text extension using

(setq deft-extension "txt")

Is there any way to support multiple file types? (e.g. I have a mix of .txt .md and .org files in my directory)

  • Could you link to deft-mode?
    – Malabarba
    Commented Nov 12, 2014 at 14:06
  • oh sorry: it's this one jblevins.org/projects/deft
    – ws6079
    Commented Nov 12, 2014 at 14:07
  • The short answer is no, deft only supports a single file extension at the moment. It would need to be updated. What about creating new notes, would you still want a single extension used as the default? One of the goals of deft is not to think about file names / extensions, I believe.
    – glucas
    Commented Nov 12, 2014 at 14:59
  • I see that it is more difficult than a simple regexp as I was hoping. I like the way nvALT handles file extensions: several are recognized, and one is specified as a default for new files.
    – ws6079
    Commented Nov 12, 2014 at 15:04

4 Answers 4


Building on the workaround in @ws6079's answer, you can use advice to specify a default extension for new files.

Here's an example that defaults to txt (using Emacs 24.4-style advice):

(setq deft-extension "")
(defvar deft-default-extension "txt")

(defun my/deft-default-extension (orig-func &rest args)
  (let ((deft-extension deft-default-extension))
    (apply orig-func args)))

(when (not (version< emacs-version "24.4"))         
  (advice-add 'deft-new-file :around #'my/deft-default-extension))

As pointed out by @glucas this does not seem to be possible right now. A somewhat acceptable workaround for multiple file types is (for me) to set

(setq deft-extension "")

which matches all files in the directory. Unfortunately new files then have an dot extension . e.g., todo_test..

  • To deal with the new file issue, maybe you could advise deft-new-file-named and use let to set the extension for the duration of that call?
    – glucas
    Commented Nov 13, 2014 at 15:48

Pretty big bump, but it really can be just a simple regexp as you (@ws6079) suggested in a comment. The following works for .org and .txt files:

(setq deft-extension "\\(\\.org\\'\\|\\.txt\\'\\)")

I don't know if support for this had been added since you first asked.

  • Thanks, unfortunately that still doesn't seem to work properly for my version. Specifically, the names of newly created file names are messed up.
    – ws6079
    Commented Feb 5, 2015 at 12:28

From the file deft.el, this works

(setq deft-extensions '("txt" "tex" "org")

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.