Skip to content

Change the front matter format

Per Denote’s design principles, the code is hackable. All front matter is stored in variables that are intended for public use. We do not declare those as “user options” because (i) they expect the user to have some degree of knowledge in Emacs Lisp and (ii) implement custom code.

[ NOTE for tinkerers: code intended for internal use includes double hyphens in its symbol. “Internal use” means that it can be changed without warning and with no further reference in the change log. Do not use any of it without understanding the consequences. ]

The variables which hold the front matter format are:

These variables have a string value with specifiers that are used by the format function. The formatting operation passes five arguments which include the values of the given entries: ‘TITLE’, ‘DATE’, ‘KEYWORDS’, ‘IDENTIFIER’, and ‘SIGNATURE’. If you are an advanced user who wants to edit this variable to affect how front matter is produced, consider using something like ‘%2$s’ to control where the Nth argument is placed.

When editing the value, make sure to:

  1. Not use empty lines inside the front matter block.
  2. Insert at least one empty line after the front matter block and do not use any empty line before it.

These help with consistency and might prove useful if we ever need to operate on the front matter as a whole.

With those granted, below are some examples. The approach is the same for all variables.

emacs-lisp
;; Like the default, but upcase the entries
(setq denote-org-front-matter
  "#+TITLE:      %s
#+DATE:       %s
#+FILETAGS:   %s
#+IDENTIFIER: %s
#+SIGNATURE:  %s
\n")

;; Change the order (notice the %N$s notation)
(setq denote-org-front-matter
  "#+title:      %1$s
#+filetags:   %3$s
#+date:       %2$s
#+identifier: %4$s
#+signature:  %5$s
\n")

;; Remove the date
(setq denote-org-front-matter
  "#+title:      %1$s
#+filetags:   %3$s
#+identifier: %4$s
#+signature:  %5$s
\n")

;; Remove the date and the identifier
(setq denote-org-front-matter
  "#+title:      %1$s
#+filetags:   %3$s
#+signature:  %5$s
\n")

Note that setq has a global effect: it affects the creation of all new notes. Depending on the workflow, it may be preferrable to have a custom command which let binds the different format. We shall not provide examples at this point as this is a more advanced feature and we are not yet sure what the user’s needs are. Please provide feedback and we shall act accordingly.