Create note with specific values using Org capture
The ordinary procedure to create a note with org-capture respects the value of the user option denote-prompts (Create note using Org capture): the user is prompted for all the values they have configured (title and keywords, by default). Sometimes, there is no need to have a certain prompt because the value of it will be constant. For example, the user wants to have a template that (i) respects the denote-prompts but (ii) puts the new note in an existing subdirectory of the denote-directory. The following code block does exactly that.
[ It also is possible to have a template that deviates from denote-prompts and prompts for specific values (Create note with specific prompts using Org capture). ]
(with-eval-after-load 'org-capture
(add-to-list 'org-capture-templates
'("r" "New reference (with Denote)" plain
(file denote-last-path)
(function
(lambda ()
(let ((denote-use-directory (expand-file-name "reference" (denote-directory))))
(denote-org-capture))))
:no-save t
:immediate-finish nil
:kill-buffer t
:jump-to-captured t)))The values one may predefine in this way are described elsewhere in this manual (Predefined note values for developers or advanced users). When there exists a binding for those variables, the corresponding prompt is always skipped. It is thus paramount to never set those variables outside the scope of a let (or equivalent).
With those granted, here is another example scenario where the user wants to have a constant value for the subdirectory but also be prompted for a date.
(with-eval-after-load 'org-capture
(add-to-list 'org-capture-templates
'("j" "New journal (with Denote)" plain
(file denote-last-path)
(function
(lambda ()
;; The "journal" subdirectory of the `denote-directory'---this must exist!
(let* ((denote-use-directory (expand-file-name "journal" (denote-directory)))
;; Use the existing `denote-prompts' as well as the one for a date.
(denote-prompts (denote-add-prompts '(date))))
(denote-org-capture))))
:no-save t
:immediate-finish nil
:kill-buffer t
:jump-to-captured t)))The above highlights the hackability of the Denote code base, namely, how we can affect the behaviour of the underlying denote command by let binding variables that affect every aspect of its behaviour (Write your own convenience commands).