Emacs: new option for Denote letter casing
There are lots of quality-of-life improvements to
denote ahead of
2.1.0 (I might release it this month). Among them is a new
user option to control the letter casing of individual file name
Before I elaborate, a brief description of Denote is in order. At its core, Denote is a file-naming scheme implemented as an Emacs package that (i) creates new “note” files and links between them, and (ii) renames existing files. Denote works with any file type—it is NOT an Org extension. Use it to manage your knowledge base and long-term file storage. When Denote operates on file names, it enforces its file-naming scheme. The idea is to embed valuable (i.e. searchable) information in file names, including the time stamp, file title, keywords, and a catch-all string of characters (the “signature”). File names can then be searched easily using standard tools, even if Emacs is not available. The details of the file-naming scheme and everything else are documented at length in the manual.
Back to the new feature: the
option. The status quo ex ante was to downcase the entire file name,
whereas now we can have, say, keywords be recorded verbatim while the
rest are downcased. A potentially useful application of this is to
apply camelCase, CAPITALS, aLtCaPs (see my
altcaps package), etc.,
to keywords and/or the signature.
The effect of the new option
Using the default value of
denote-file-name-letter-casing, we get
the following file name for these inputs (e.g. by calling
M-x denote-signature, and the like). I am using an
all-inclusive case here, though note that all file name components
apart from timestamps are optional.
|File name component||User input|
|title||“How do you turn this on?”|
(setq denote-file-name-letter-casing ; the defaults '((title . downcase) (signature . downcase) (keywords . downcase) (t . downcase))) ;; => 20231011T150058==sig--how-do-you-turn-this-on__camelcase_gnuemacs.org
And then with this:
(setq denote-file-name-letter-casing '((title . downcase) (signature . verbatim) (keywords . verbatim) (t . downcase))) ;; => 20231011T150420==SIG--how-do-you-turn-this-on__camelCase_GNUEmacs.org
Specify the method Denote uses to affect the letter casing of file names.
The value is an alist where each element is a cons cell of the form (COMPONENT . METHOD).
The COMPONENT is an unquoted symbol among
keywords, which refer to the corresponding component of the file name. The special t COMPONENT is a fallback value in case the others are not specified.
The METHOD is the letter casing scheme, which is an unquoted symbol of either
verbatim. A nil value has the same meaning as
downcase. Other non-nil METHOD types are reserved for possible future use.
downcaseMETHOD converts user input for the given COMPONENT into lower case. The benefit of this approach (which is the default behaviour) is that file names remain consistent over the long-term. The user never needs to account for varying letter casing while working with them.
verbatimMETHOD means that Denote will not affect the letter casing of user input when generating the given file name COMPONENT. As such, conventions like CamelCase or camelCase are respected. The user thus assumes responsibility to keep file names in a good state over the long term.
Given the above, I think the
option may no longer be useful. If you cannot avoid multiple words,
it is better to use camel casing as this keeps hyphens limited to the
title component of the file name.
At any rate, this is part of the current development target. I may still make changes, subject to user feedback.
- Package name (GNU ELPA):
- Official manual: https://protesilaos.com/emacs/denote
- Change log: https://protesilaos.com/emacs/denote-changelog
- Git repo on SourceHut: https://git.sr.ht/~protesilaos/denote
- Mailing list: https://lists.sr.ht/~protesilaos/denote
- Video demo: https://protesilaos.com/codelog/2022-06-18-denote-demo/
- Backronyms: Denote Everything Neatly; Omit The Excesses. Don’t Ever Note Only The Epiphenomenal.