Skip to content

Open an existing note or create it if missing ​

Sometimes it is necessary to briefly interrupt the ongoing writing session to open an existing note or, if that is missing, to create it. This happens when a new tangential thought occurs and the user wants to confirm that an entry for it is in place. To this end, Denote provides the command denote-open-or-create as well as its more flexible counterpart denote-open-or-create-with-command.

The denote-open-or-create prompts to visit a file in the denote-directory. At this point, the user must type in search terms that match a file name. If the input does not return any matches and the user confirms their choice to proceed (usually by typing RET twice, depending on the minibuffer settings), denote-open-or-create will call the denote command interactively to create a new note. It will then use whatever prompts denote normally has, per the user option denote-prompts (Standard note creation). If the title prompt is involved (the default behaviour), the denote-open-or-create sets up this prompt to have the previous input as the default title of the note to-be-created. This means that the user can type RET at the empty prompt to re-use what they typed in previously. Commands to use previous inputs from the history are also available (‘M-p’ or ‘M-n’ in the minibuffer, which call previous-history-element and next-history-element by default). Accessing the history is helpful to, for example, make further edits to the available text.

The denote-open-or-create-with-command is like the above, except when it is about to create the new note it first prompts for the specific file-creating command to use (Choose which commands to prompt for). For example, the user may want to specify a signature for this new file, so they can select the denote-signature command.

Denote provides similar functionality for linking to an existing note or creating a new one (Link to a note or create it if missing).