Create note using Org capture
For integration with org-capture, the user must first add the relevant template. Such as:
(with-eval-after-load 'org-capture
(add-to-list 'org-capture-templates
'("n" "New note (with Denote)" plain
(file denote-last-path)
#'denote-org-capture
:no-save t
:immediate-finish nil
:kill-buffer t
:jump-to-captured t)))Once the template is added, it is accessed from the specified key. If, for instance, org-capture is bound to ‘C-c c’, then the note creation is initiated with ‘C-c c n’, per the above snippet. After that, the process is the same as with invoking denote directly, namely: a prompt for a title followed by a prompt for keywords, assuming the default settings (Standard note creation). Concretely, this method always respects the value of the user option denote-prompts (The denote-prompts option).
It is also possible to define templates that have specific prompts or certain values set, for which there is no prompt:
- Create note with specific values using Org capture
- Create note with specific prompts using Org capture
Users may prefer to leverage org-capture in order to extend file creation with the specifiers described in the org-capture-templates documentation (such as to capture the active region and/or create a hyperlink pointing to the given context).
IMPORTANT. Due to the particular file-naming scheme of Denote, which is derived dynamically, such specifiers or other arbitrary text cannot be written directly in the template. Instead, they have to be assigned to the user option denote-org-capture-specifiers, which is interpreted by the function denote-org-capture. Example with our default value:
(setq denote-org-capture-specifiers "%l\n%i\n%?")Note that denote-org-capture ignores the denote-file-type: it always sets the Org file extension for the created note to ensure that the capture process works as intended, especially for the desired output of the denote-org-capture-specifiers.
Developers or advanced users who let bind the denote-use-template must consider setting denote-org-capture-specifiers to nil or an appropriate string (Predefined note values for developers or advanced users). Otherwise the contents of the new note may contain duplicates.
[ You may not need org-capture to do what you want (Write your own convenience commands). ]