Transient Directories in NotDeft

My NotDeft note manager has an optional notdeft-path feature to better support transient directories of notes. Also in the standard configuration, the notdeft-directories list may contain directories that do not have to always exist, as any non-existing directories are simply ignored; if and when they appear, they can be included in subsequent searches.

Note, however, that the notdeft-directories variable is normally set only once, and if the initializer expression includes wildcards, the variable value may not contain directories that get mounted or copied over later. Thus, if your Emacs startup file says

(setq notdeft-directories `("~/notes" ,@(file-expand-wildcards "~/*/notes")))

and the directory


becomes available after Emacs has already started, your notdeft-directories may not include that directory.

NotDeft includes a notdeft-refresh command (bound to C-c C-g) for notifying NotDeft of filesystem changes that have occurred outside NotDeft control, and it would be consistent with that semantics for the command to also detect any new NotDeft directories that may also have appeared.

That additional functionality can be achieved by also updating the notdeft-directories value for each notdeft-refresh, prior to scanning the contents of those directories. The notdeft-path feature arranges for that to happen, if it is set up as follows:

(require 'notdeft-path)
(setq notdeft-path
      (lambda ()
        `("~/notes" ,@(file-expand-wildcards "~/*/notes"))))
(add-hook 'notdeft-pre-refresh-hook 'notdeft-refresh-directories)

where the notdeft-refresh-directories function computes and assigns a value for notdeft-directories. By installing that function into the notdeft-pre-refresh-hook we also arrange for notdeft-directories updates later, once NotDeft is already running.

The notdeft-refresh-directories function also runs the notdeft-directories-changed-hook after a new set of directories has been computed, in case other settings need updating to reflect the change in directories. For example, suppose we are using org-agenda for calendaring, and we wish to also recompute our list of org-agenda-files:

(defun my-refresh-org-agenda-files ()
  (apply 'append (mapcar (lambda (dir)
                            (concat (file-name-as-directory dir)
(add-hook 'notdeft-directories-changed-hook 'my-refresh-org-agenda-files)

This information is current as of NotDeft revision 5c75549.