Deft as a file search tool

We’ve looked at using deft to make quick notes, with a couple of tweaks. I found I really like the deft interface for finding files. In particular, in the directory where I keep my blog posts, I have a large number of org files, and the deft interface is a very convenient way to search them to see in which posts I have mentioned particular things. I like the overview that deft gives you, and the incremental search as you type.

However, by default deft launches in my deft notes directory. To get around this I created a simple function to wrap around deft:

;;function to run deft in specified directory
(defun bjm-deft (dir)
  "Run deft in directory DIR"
  (setq deft-directory dir)
  (switch-to-buffer "*Deft*")

This sets the desired directory to run deft, kills any current deft buffer (which may be in the wrong directory) and then starts deft.

I then bound this to convenient keys:

(global-set-key (kbd "C-c d")
                (lambda () (interactive) (bjm-deft "~/docs/deft")))
(global-set-key (kbd "C-c D")
                (lambda () (interactive) (bjm-deft "~/docs/emacs/blog")))

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s