Skip to content

A custom identifier that is a simple string given at the prompt each time

This is a sample implementation of custom Denote identifiers (Define a completely custom identifier scheme).

While it is possible to implement a certain automatic scheme for the Denote identifier, users may prefer to have a prompt each time that asks them for a simple string which is then used as-is. This can be done by modifying the user option denote-prompts to include the ‘identifier’ in the list of file name components to prompt for (The denote-prompts option).

For example:

emacs-lisp
;; The default is '(title keywords)
(setq denote-prompts '(identifier title keywords))

With the above, each time Denote needs to produce a new file name it will prompt for the identifier. Note that it is then up to the user to guarantee the uniqueness of the resulting identifiers. With this code, Denote will fall back to using the current date as the identifier if the provided string is not yielding a unique match.

In practice, the identifier prompt is a useful tool for wrapper functions that need to do something special in a given context. For example, in a folder with some ancient photos the user wants to have an identifier scheme that is ‘PLACE+PEOPLE+N’ where it is easier to prompt for that value each time than write some extra code to do the work. To this end, here is a sample wrapper function of denote-rename-file:

emacs-lisp
(defun my-denote-rename-file-with-identifier-prompt ()
  (interactive)
  (let ((denote-prompts '(identifier title keywords)))
    (call-interactively 'denote-rename-file)))