dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

README-elpa (159111B)


      1 	   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      2 		 DENOTE: SIMPLE NOTES WITH AN EFFICIENT
      3 			   FILE-NAMING SCHEME
      4 
      5 			  Protesilaos Stavrou
      6 			  info@protesilaos.com
      7 	   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      8 
      9 
     10 This manual, written by Protesilaos Stavrou, describes the customization
     11 options for the Emacs package called `denote' (or `denote.el'), and
     12 provides every other piece of information pertinent to it.
     13 
     14 The documentation furnished herein corresponds to stable version 1.2.0,
     15 released on 2022-12-16.  Any reference to a newer feature which does not
     16 yet form part of the latest tagged commit, is explicitly marked as such.
     17 
     18 Current development target is 1.3.0-dev.
     19 
     20 ⁃ Package name (GNU ELPA): `denote'
     21 ⁃ Official manual: <https://protesilaos.com/emacs/denote>
     22 ⁃ Change log: <https://protesilaos.com/emacs/denote-changelog>
     23 ⁃ Git repo on SourceHut: <https://git.sr.ht/~protesilaos/denote>
     24   • Mirrors:
     25     ⁃ GitHub: <https://github.com/protesilaos/denote>
     26     ⁃ GitLab: <https://gitlab.com/protesilaos/denote>
     27 ⁃ Mailing list: <https://lists.sr.ht/~protesilaos/denote>
     28 ⁃ Backronyms: Denote Everything Neatly; Omit The Excesses.  Don’t Ever
     29   Note Only The Epiphenomenal.
     30 
     31 If you are viewing the README.org version of this file, please note that
     32 the GNU ELPA machinery automatically generates an Info manual out of it.
     33 
     34 Table of Contents
     35 ─────────────────
     36 
     37 1. COPYING
     38 2. Overview
     39 3. Points of entry
     40 .. 1. Standard note creation
     41 ..... 1. The `denote-prompts' option
     42 ..... 2. The `denote-templates' option
     43 ..... 3. Convenience commands for note creation
     44 ..... 4. The `denote-date-prompt-use-org-read-date' option
     45 ..... 5. Add or remove keywords interactively
     46 .. 2. Create note using Org capture
     47 .. 3. Maintain separate directory silos for notes
     48 .. 4. Exclude certain directories from all operations
     49 .. 5. Exclude certain keywords from being inferred
     50 4. Renaming files
     51 .. 1. Rename a single file
     52 .. 2. Rename multiple files at once
     53 .. 3. Rename a single file based on its front matter
     54 .. 4. Rename multiple files based on their front matter
     55 5. The file-naming scheme
     56 .. 1. Sluggified title and keywords
     57 .. 2. Features of the file-naming scheme for searching or filtering
     58 6. Front matter
     59 .. 1. Change the front matter format
     60 .. 2. Regenerate front matter
     61 7. Linking notes
     62 .. 1. Adding a single link
     63 .. 2. Insert links matching a regexp
     64 .. 3. Insert links, but only those missing from current buffer
     65 .. 4. Insert links from marked files in Dired
     66 .. 5. Link to an existing note or create a new one
     67 .. 6. The backlinks’ buffer
     68 .. 7. Writing metanotes
     69 .. 8. Visiting linked files via the minibuffer
     70 .. 9. Miscellaneous information about links
     71 8. Fontification in Dired
     72 9. Use Org dynamic blocks
     73 10. Minibuffer histories
     74 11. Extending Denote
     75 .. 1. Keep a journal or diary
     76 .. 2. Create a note with the region’s contents
     77 .. 3. Split an Org subtree into its own note
     78 .. 4. Narrow the list of files in Dired
     79 .. 5. Use `dired-virtual-mode' for arbitrary file listings
     80 .. 6. Use Embark to collect minibuffer candidates
     81 .. 7. Search file contents
     82 .. 8. Bookmark the directory with the notes
     83 .. 9. Use the `citar-denote' package for bibliography notes
     84 .. 10. Use the `consult-notes' package
     85 .. 11. Treat your notes as a project
     86 .. 12. Variants of `denote-open-or-create'
     87 .. 13. Variants of `denote-link-or-create'
     88 12. Installation
     89 .. 1. GNU ELPA package
     90 .. 2. Manual installation
     91 13. Sample configuration
     92 14. For developers or advanced users
     93 15. Contributing
     94 16. Things to do
     95 17. Publications about Denote
     96 18. Alternatives to Denote
     97 .. 1. Alternative ideas with Emacs and further reading
     98 19. Frequently Asked Questions
     99 .. 1. Why develop Denote when PACKAGE already exists?
    100 .. 2. Why not rely exclusively on Org?
    101 .. 3. Why care about Unix tools when you use Emacs?
    102 .. 4. Why many small files instead of few large ones?
    103 .. 5. Does Denote perform well at scale?
    104 .. 6. I add TODOs to my notes; will many files slow down the Org agenda?
    105 .. 7. I want to sort by last modified, why won’t Denote let me?
    106 .. 8. How do you handle the last modified case?
    107 .. 9. Speed up backlinks’ buffer creation?
    108 .. 10. Why do I get “Search failed with status 1” when I search for backlinks?
    109 20. Acknowledgements
    110 21. GNU Free Documentation License
    111 22. Indices
    112 .. 1. Function index
    113 .. 2. Variable index
    114 .. 3. Concept index
    115 
    116 
    117 1 COPYING
    118 ═════════
    119 
    120   Copyright (C) 2022 Free Software Foundation, Inc.
    121 
    122         Permission is granted to copy, distribute and/or modify
    123         this document under the terms of the GNU Free
    124         Documentation License, Version 1.3 or any later version
    125         published by the Free Software Foundation; with no
    126         Invariant Sections, with the Front-Cover Texts being “A
    127         GNU Manual,” and with the Back-Cover Texts as in (a)
    128         below.  A copy of the license is included in the section
    129         entitled “GNU Free Documentation License.”
    130 
    131         (a) The FSF’s Back-Cover Text is: “You have the freedom to
    132         copy and modify this GNU manual.”
    133 
    134 
    135 2 Overview
    136 ══════════
    137 
    138   Denote aims to be a simple-to-use, focused-in-scope, and effective
    139   note-taking tool for Emacs.  It is based on the following core design
    140   principles:
    141 
    142   Predictability
    143         File names must follow a consistent and descriptive naming
    144         convention ([The file-naming scheme]).  The file name alone
    145         should offer a clear indication of what the contents are,
    146         without reference to any other metadatum.  This convention is
    147         not specific to note-taking, as it is pertinent to any form of
    148         file that is part of the user’s long-term storage ([Renaming
    149         files]).
    150 
    151   Composability
    152         Be a good Emacs citizen, by integrating with other packages or
    153         built-in functionality instead of re-inventing functions such as
    154         for filtering or greping.  The author of Denote (Protesilaos,
    155         aka “Prot”) writes ordinary notes in plain text (`.txt'),
    156         switching on demand to an Org file only when its expanded set of
    157         functionality is required for the task at hand ([Points of
    158         entry]).
    159 
    160   Portability
    161         Notes are plain text and should remain portable.  The way Denote
    162         writes file names, the front matter it includes in the note’s
    163         header, and the links it establishes must all be adequately
    164         usable with standard Unix tools.  No need for a database or some
    165         specialised software.  As Denote develops and this manual is
    166         fully fleshed out, there will be concrete examples on how to do
    167         the Denote-equivalent on the command-line.
    168 
    169   Flexibility
    170         Do not assume the user’s preference for a note-taking
    171         methodology.  Denote is conceptually similar to the Zettelkasten
    172         Method, which you can learn more about in this detailed
    173         introduction: <https://zettelkasten.de/introduction/>.  Notes
    174         are atomic (one file per note) and have a unique identifier.
    175         However, Denote does not enforce a particular methodology for
    176         knowledge management, such as a restricted vocabulary or
    177         mutually exclusive sets of keywords.  Denote also does not check
    178         if the user writes thematically atomic notes.  It is up to the
    179         user to apply the requisite rigor and/or creativity in pursuit
    180         of their preferred workflow ([Writing metanotes]).
    181 
    182   Hackability
    183         Denote’s code base consists of small and reusable functions.
    184         They all have documentation strings.  The idea is to make it
    185         easier for users of varying levels of expertise to understand
    186         what is going on and make surgical interventions where necessary
    187         (e.g. to tweak some formatting).  In this manual, we provide
    188         concrete examples on such user-level configurations ([Keep a
    189         journal or diary]).
    190 
    191   Now the important part…  “Denote” is the familiar word, though it also
    192   is a play on the “note” concept.  Plus, we can come up with acronyms,
    193   recursive or otherwise, of increasingly dubious utility like:
    194 
    195   ⁃ Don’t Ever Note Only The Epiphenomenal
    196   ⁃ Denote Everything Neatly; Omit The Excesses
    197 
    198   But we’ll let you get back to work.  Don’t Eschew or Neglect your
    199   Obligations, Tasks, and Engagements.
    200 
    201 
    202 [The file-naming scheme] See section 5
    203 
    204 [Renaming files] See section 4
    205 
    206 [Points of entry] See section 3
    207 
    208 [Writing metanotes] See section 7.7
    209 
    210 [Keep a journal or diary] See section 11.1
    211 
    212 
    213 3 Points of entry
    214 ═════════════════
    215 
    216   There are five ways to write a note with Denote: invoke the `denote',
    217   `denote-type', `denote-date', `denote-subdirectory', `denote-template'
    218   commands, or leverage the `org-capture-templates' by setting up a
    219   template which calls the function `denote-org-capture'.  We explain
    220   all of those in the subsequent sections.
    221 
    222 
    223 3.1 Standard note creation
    224 ──────────────────────────
    225 
    226   The `denote' command will prompt for a title.  If a region is active,
    227   the text of the region becomes the default at the minibuffer prompt
    228   (meaning that typing `RET' without any input will use the default
    229   value).  Once the title is supplied, the `denote' command will then
    230   ask for keywords.  The resulting note will have a file name as already
    231   explained: [The file naming scheme]
    232 
    233   The file type of the new note is determined by the user option
    234   `denote-file-type' ([Front matter]).
    235 
    236   The keywords’ prompt supports minibuffer completion.  Available
    237   candidates are those defined in the user option
    238   `denote-known-keywords'.  More candidates can be inferred from the
    239   names of existing notes, by setting `denote-infer-keywords' to non-nil
    240   (which is the case by default).
    241 
    242   Multiple keywords can be inserted by separating them with a comma (or
    243   whatever the value of the `crm-separator' is—which should be a comma).
    244   When the user option `denote-sort-keywords' is non-nil (the default),
    245   keywords are sorted alphabetically (technically, the sorting is done
    246   with `string-lessp').
    247 
    248   The interactive behaviour of the `denote' command is influenced by the
    249   user option `denote-prompts' ([The denote-prompts option]).
    250 
    251   The `denote' command can also be called from Lisp.  Read its doc
    252   string for the technicalities.
    253 
    254   In the interest of discoverability, `denote' is also available under
    255   the alias `denote-create-note'.
    256 
    257 
    258 [The file naming scheme] See section 5
    259 
    260 [Front matter] See section 6
    261 
    262 [The denote-prompts option] See section 3.1.1
    263 
    264 3.1.1 The `denote-prompts' option
    265 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    266 
    267   The user option `denote-prompts' determines how the `denote' command
    268   will behave interactively ([Standard note creation]).
    269 
    270   The value is a list of symbols, which includes any of the following:
    271 
    272   • `title': Prompt for the title of the new note.
    273 
    274   • `keywords': Prompts with completion for the keywords of the new
    275     note.  Available candidates are those specified in the user option
    276     `denote-known-keywords'.  If the user option `denote-infer-keywords'
    277     is non-nil, keywords in existing note file names are included in the
    278     list of candidates.  The `keywords' prompt uses
    279     `completing-read-multiple', meaning that it can accept multiple
    280     keywords separated by a comma (or whatever the value of
    281     `crm-sepator' is).
    282 
    283   • `file-type': Prompts with completion for the file type of the new
    284     note.  Available candidates are those specified in the user option
    285     `denote-file-type'.  Without this prompt, `denote' uses the value of
    286     `denote-file-type'.
    287 
    288   • `subdirectory': Prompts with completion for a subdirectory in which
    289     to create the note.  Available candidates are the value of the user
    290     option `denote-directory' and all of its subdirectories.  Any
    291     subdirectory must already exist: Denote will not create it.
    292 
    293   • `date': Prompts for the date of the new note.  It will expect an
    294     input like 2022-06-16 or a date plus time: 2022-06-16 14:30.
    295     Without the `date' prompt, the `denote' command uses the
    296     `current-time'.
    297 
    298     [The denote-date-prompt-use-org-read-date option].
    299 
    300   • `template': Prompts for a KEY among the `denote-templates'.  The
    301     value of that KEY is used to populate the new note with content,
    302     which is added after the front matter ([The denote-templates
    303     option]).
    304 
    305   The prompts occur in the given order.
    306 
    307   If the value of this user option is nil, no prompts are used.  The
    308   resulting file name will consist of an identifier (i.e. the date and
    309   time) and a supported file type extension (per `denote-file-type').
    310 
    311   Recall that Denote’s standard file-naming scheme is defined as follows
    312   ([The file-naming scheme]):
    313 
    314   ┌────
    315   │ DATE--TITLE__KEYWORDS.EXT
    316   └────
    317 
    318 
    319   If either or both of the `title' and `keywords' prompts are not
    320   included in the value of this variable, file names will be any of
    321   those permutations:
    322 
    323   ┌────
    324   │ DATE.EXT
    325   │ DATE--TITLE.EXT
    326   │ DATE__KEYWORDS.EXT
    327   └────
    328 
    329 
    330   When in doubt, always include the `title' and `keywords' prompts.
    331 
    332   Finally, this user option only affects the interactive use of the
    333   `denote' command (advanced users can call it from Lisp).  For ad-hoc
    334   interactive actions that do not change the default behaviour of the
    335   `denote' command, users can invoke these convenience commands:
    336   `denote-type', `denote-subdirectory', `denote-date'.  They are
    337   described in the subsequent section ([Convenience commands for note
    338   creation]).
    339 
    340 
    341 [Standard note creation] See section 3.1
    342 
    343 [The denote-date-prompt-use-org-read-date option] See section 3.1.4
    344 
    345 [The denote-templates option] See section 3.1.2
    346 
    347 [The file-naming scheme] See section 5
    348 
    349 [Convenience commands for note creation] See section 3.1.3
    350 
    351 
    352 3.1.2 The `denote-templates' option
    353 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    354 
    355   The user option `denote-templates' is an alist of content templates
    356   for new notes.  A template is arbitrary text that Denote will add to a
    357   newly created note right below the front matter.
    358 
    359   Templates are expressed as a `(KEY . STRING)' association.
    360 
    361   • The `KEY' is the name which identifies the template.  It is an
    362     arbitrary symbol, such as `report', `memo', `statement'.
    363 
    364   • The `STRING' is ordinary text that Denote will insert as-is.  It can
    365     contain newline characters to add spacing.  Below we show some
    366     concrete examples.
    367 
    368   The user can choose a template either by invoking the command
    369   `denote-template' or by changing the user option `denote-prompts' to
    370   always prompt for a template when calling the `denote' command.
    371 
    372   [The denote-prompts option].
    373 
    374   [Convenience commands for note creation].
    375 
    376   Templates can be written directly as one large string.  For example
    377   (the `\n' character is read as a newline):
    378 
    379   ┌────
    380   │ (setq denote-templates
    381   │       '((report . "* Some heading\n\n* Another heading")
    382   │ 	(memo . "* Some heading
    383    384   │ * Another heading
    385    386   │ ")))
    387   └────
    388 
    389   Long strings may be easier to type but interpret indentation
    390   literally.  Also, they do not scale well.  A better way is to use some
    391   Elisp code to construct the string.  This would typically be the
    392   `concat' function, which joins multiple strings into one.  The
    393   following is the same as the previous example:
    394 
    395   ┌────
    396   │ (setq denote-templates
    397   │       `((report . "* Some heading\n\n* Another heading")
    398   │ 	(memo . ,(concat "* Some heading"
    399   │ 			 "\n\n"
    400   │ 			 "* Another heading"
    401   │ 			 "\n\n"))))
    402   └────
    403 
    404   Notice that to evaluate a function inside of an alist we use the
    405   backtick to quote the alist (NOT the straight quote) and then prepend
    406   a comma to the expression that should be evaluated.  The `concat' form
    407   here is not sensitive to indentation, so it is easier to adjust for
    408   legibility.
    409 
    410   DEV NOTE: We do not provide more examples at this point, though feel
    411   welcome to ask for help if the information provided herein is not
    412   sufficient.  We shall expand the manual accordingly.
    413 
    414 
    415 [The denote-prompts option] See section 3.1.1
    416 
    417 [Convenience commands for note creation] See section 3.1.3
    418 
    419 
    420 3.1.3 Convenience commands for note creation
    421 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    422 
    423   Sometimes the user needs to create a note that has different
    424   requirements from those of `denote' ([Standard note creation]).  While
    425   this can be achieved globally by changing the `denote-prompts' user
    426   option, there are cases where an ad-hoc method is the appropriate one
    427   ([The denote-prompts option]).
    428 
    429   To this end, Denote provides the following convenience interactive
    430   commands for note creation:
    431 
    432   Create note by specifying file type
    433         The `denote-type' command creates a note while prompting for a
    434         file type.
    435 
    436         This is the equivalent to calling `denote' when `denote-prompts'
    437         is set to `'(file-type title keywords)'.  In practical terms,
    438         this lets you produce, say, a note in Markdown even though you
    439         normally write in Org ([Standard note creation]).
    440 
    441         The `denote-create-note-using-type' is an alias of
    442         `denote-type'.
    443 
    444   Create note using a date
    445         Normally, Denote reads the current date and time to construct
    446         the unique identifier of a newly created note ([Standard note
    447         creation]).  Sometimes, however, the user needs to set an
    448         explicit date+time value.
    449 
    450         This is where the `denote-date' command comes in.  It creates a
    451         note while prompting for a date.  The date can be in
    452         YEAR-MONTH-DAY notation like `2022-06-30' or that plus the time:
    453         `2022-06-16 14:30'.
    454 
    455         [The denote-date-prompt-use-org-read-date option].
    456 
    457         This is the equivalent to calling `denote' when `denote-prompts'
    458         is set to `'(date title keywords)'.
    459 
    460         The `denote-create-note-using-date' is an alias of
    461         `denote-date'.
    462 
    463   Create note in a specific directory
    464         The `denote-subdirectory' command creates a note while prompting
    465         for a subdirectory.  Available candidates include the value of
    466         the variable `denote-directory' and any subdirectory thereof
    467         (Denote does not create subdirectories).
    468 
    469         This is equivalent to calling `denote' when `denote-prompts' is
    470         set to `'(subdirectory title keywords)'.
    471 
    472         The `denote-create-note-in-subdirectory' is a more descriptive
    473         alias of `denote-subdirectory'.
    474 
    475   Create note and add a template
    476         The `denote-template' command creates a new note and inserts the
    477         specified template below the front matter ([The denote-templates
    478         option]).  Available candidates for templates are specified in
    479         the user option `denote-templates'.
    480 
    481         This is equivalent to calling `denote' when `denote-prompts' is
    482         set to `'(template title keywords)'.
    483 
    484         The `denote-create-note-with-template' is an alias of the
    485         command `denote-template', meant to help with discoverability.
    486 
    487 
    488 [Standard note creation] See section 3.1
    489 
    490 [The denote-prompts option] See section 3.1.1
    491 
    492 [The denote-date-prompt-use-org-read-date option] See section 3.1.4
    493 
    494 [The denote-templates option] See section 3.1.2
    495 
    496 ◊ 3.1.3.1 Write your own convenience commands
    497 
    498   The convenience commands we provide only cover some basic use-cases
    499   ([Convenience commands for note creation]).  The user may require
    500   combinations that are not covered, such as to prompt for a template
    501   and for a subdirectory, instead of only one of the two.  To this end,
    502   we show how to follow the code we use in Denote to write your own
    503   variants of those commands.
    504 
    505   First let’s take a look at the definition of one of those commands.
    506   They all look the same, but we use `denote-subdirectory' for this
    507   example:
    508 
    509   ┌────
    510   │ (defun denote-subdirectory ()
    511   │   "Create note while prompting for a subdirectory.
    512    513   │ Available candidates include the value of the variable
    514   │ `denote-directory' and any subdirectory thereof.
    515    516   │ This is equivalent to calling `denote' when `denote-prompts' is
    517   │ set to '(subdirectory title keywords)."
    518   │   (declare (interactive-only t))
    519   │   (interactive)
    520   │   (let ((denote-prompts '(subdirectory title keywords)))
    521   │     (call-interactively #'denote)))
    522   └────
    523 
    524   The hyphenated word after `defun' is the name of the function.  It has
    525   to be unique.  Then we have the documentation string (or “doc string”)
    526   which is for the user’s convenience.
    527 
    528   This function is `interactive', meaning that it can be called via
    529   `M-x' or be assigned to a key binding.  Then we have the local binding
    530   of the `denote-prompts' to the desired combination (“local” means
    531   specific to this function without affecting other contexts).  Lastly,
    532   it calls the standard `denote' command interactively, so it uses all
    533   the prompts in their specified order.
    534 
    535   Now let’s say we want to have a command that (i) asks for a template
    536   and (ii) for a subdirectory ([The denote-templates option]).  All we
    537   need to do is tweak the `let' bound value of `denote-prompts' and give
    538   our command a unique name:
    539 
    540   ┌────
    541   │ ;; Like `denote-subdirectory' but also ask for a template
    542   │ (defun denote-subdirectory-with-template ()
    543   │   "Create note while also prompting for a template and subdirectory.
    544    545   │ This is equivalent to calling `denote' when `denote-prompts' is
    546   │ set to '(template subdirectory title keywords)."
    547   │   (declare (interactive-only t))
    548   │   (interactive)
    549   │   (let ((denote-prompts '(template subdirectory title keywords)))
    550   │     (call-interactively #'denote)))
    551   └────
    552 
    553   The tweaks to `denote-prompts' determine how the command will behave
    554   ([The denote-prompts option]).  Use this paradigm to write your own
    555   variants which you can then assign to keys or invoke with `M-x'.
    556 
    557 
    558   [Convenience commands for note creation] See section 3.1.3
    559 
    560   [The denote-templates option] See section 3.1.2
    561 
    562   [The denote-prompts option] See section 3.1.1
    563 
    564 
    565 3.1.4 The `denote-date-prompt-use-org-read-date' option
    566 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    567 
    568   By default, Denote uses its own simple prompt for date or date+time
    569   input ([The denote-prompts option]).  This is done when the
    570   `denote-prompts' option includes a `date' symbol and/or when the user
    571   invokes the `denote-date' command.
    572 
    573   Users who want to benefit from the more advanced date selection method
    574   that is common in interactions with Org mode, can set the user option
    575   `denote-date-prompt-use-org-read-date' to a non-nil value.
    576 
    577 
    578 [The denote-prompts option] See section 3.1.1
    579 
    580 
    581 3.1.5 Add or remove keywords interactively
    582 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    583 
    584   The commands `denote-keywords-add' and `denote-keywords-remove'
    585   streamline the process of interactively updating a file’s keywords in
    586   the front matter and renaming it accordingly.
    587 
    588   The `denote-keywords-add' asks for keywords using the familiar
    589   minibuffer prompt ([Standard note creation]).  It then renames the
    590   file ([Rename a single file based on its front matter]).
    591 
    592   Similarly, the `denote-keywords-remove' removes one or more keywords
    593   from the list of existing keywords and then renames the file
    594   accordingly.
    595 
    596 
    597 [Standard note creation] See section 3.1
    598 
    599 [Rename a single file based on its front matter] See section 4.3
    600 
    601 
    602 3.2 Create note using Org capture
    603 ─────────────────────────────────
    604 
    605   For integration with `org-capture', the user must first add the
    606   relevant template.  Such as:
    607 
    608   ┌────
    609   │ (with-eval-after-load 'org-capture
    610   │   (add-to-list 'org-capture-templates
    611   │ 	       '("n" "New note (with Denote)" plain
    612   │ 		 (file denote-last-path)
    613   │ 		 #'denote-org-capture
    614   │ 		 :no-save t
    615   │ 		 :immediate-finish nil
    616   │ 		 :kill-buffer t
    617   │ 		 :jump-to-captured t)))
    618   └────
    619 
    620   [ In the future, we might develop Denote in ways which do not require
    621     such manual intervention.  More user feedback is required to
    622     identify the relevant workflows. ]
    623 
    624   Once the template is added, it is accessed from the specified key.
    625   If, for instance, `org-capture' is bound to `C-c c', then the note
    626   creation is initiated with `C-c c n', per the above snippet.  After
    627   that, the process is the same as with invoking `denote' directly,
    628   namely: a prompt for a title followed by a prompt for keywords
    629   ([Standard note creation]).
    630 
    631   Users may prefer to leverage `org-capture' in order to extend file
    632   creation with the specifiers described in the `org-capture-templates'
    633   documentation (such as to capture the active region and/or create a
    634   hyperlink pointing to the given context).
    635 
    636   IMPORTANT.  Due to the particular file-naming scheme of Denote, which
    637   is derived dynamically, such specifiers or other arbitrary text cannot
    638   be written directly in the template.  Instead, they have to be
    639   assigned to the user option `denote-org-capture-specifiers', which is
    640   interpreted by the function `denote-org-capture'.  Example with our
    641   default value:
    642 
    643   ┌────
    644   │ (setq denote-org-capture-specifiers "%l\n%i\n%?")
    645   └────
    646 
    647   Note that `denote-org-capture' ignores the `denote-file-type': it
    648   always sets the Org file extension for the created note to ensure that
    649   the capture process works as intended, especially for the desired
    650   output of the `denote-org-capture-specifiers'.
    651 
    652 
    653 [Standard note creation] See section 3.1
    654 
    655 
    656 3.3 Maintain separate directory silos for notes
    657 ───────────────────────────────────────────────
    658 
    659   The user option `denote-directory' accepts a value that represents the
    660   path to a directory, such as `~/Documents/notes'.  Normally, the user
    661   will have one place where they store all their notes, in which case
    662   this arrangement shall suffice.
    663 
    664   There is, however, the possibility to maintain separate directories of
    665   notes.  By “separate”, we mean that they do not communicate with each
    666   other: no linking between them, no common keywords, nothing.  Think of
    667   the scenario where one set of notes is for private use and another is
    668   for an employer.  We call these separate directories “silos”.
    669 
    670   To create silos, the user must specify a local variable at the root of
    671   the desired directory.  This is done by creating a `.dir-locals.el'
    672   file, with the following contents:
    673 
    674   ┌────
    675   │ ;;; Directory Local Variables.  For more information evaluate:
    676   │ ;;;
    677   │ ;;;     (info "(emacs) Directory Variables")
    678    679   │ ((nil . ((denote-directory . default-directory))))
    680   └────
    681 
    682   When inside the directory that contains this `.dir-locals.el' file,
    683   all Denote commands/functions for note creation, linking, the
    684   inference of available keywords, et cetera will use the silo as their
    685   point of reference.  They will not read the global value of
    686   `denote-directory'.  The global value of `denote-directory' is read
    687   everywhere else except the silos.
    688 
    689   In concrete terms, this is a representation of the directory
    690   structures (notice the `.dir-locals.el' file is needed only for the
    691   silos):
    692 
    693   ┌────
    694   │ ;; This is the global value of 'denote-directory' (no need for a .dir-locals.el)
    695   │ ~/Documents/notes
    696   │ |-- 20210303T120534--this-is-a-test__journal_philosophy.txt
    697   │ |-- 20220303T120534--another-sample__journal_testing.md
    698   │ `-- 20220620T181255--the-third-test__keyword.org
    699    700   │ ;; A silo with notes for the employer
    701   │ ~/different/path/to/notes-for-employer
    702   │ |-- .dir-locals.el
    703   │ |-- 20210303T120534--this-is-a-test__conference.txt
    704   │ |-- 20220303T120534--another-sample__meeting.md
    705   │ `-- 20220620T181255--the-third-test__keyword.org
    706    707   │ ;; Another silo with notes for my volunteering
    708   │ ~/different/path/to/notes-for-volunteering
    709   │ |-- .dir-locals.el
    710   │ |-- 20210303T120534--this-is-a-test__activism.txt
    711   │ |-- 20220303T120534--another-sample__teambuilding.md
    712   │ `-- 20220620T181255--the-third-test__keyword.org
    713   └────
    714 
    715   It is possible to configure other user options of Denote to have a
    716   silo-specific value.  For example, this one changes the
    717   `denote-known-keywords' only for this particular silo:
    718 
    719   ┌────
    720   │ ;;; Directory Local Variables.  For more information evaluate:
    721   │ ;;;
    722   │ ;;;     (info "(emacs) Directory Variables")
    723    724   │ ((nil . ((denote-directory . default-directory)
    725   │ 	 (denote-known-keywords . ("food" "drink")))))
    726   └────
    727 
    728   This one is like the above, but also disables `denote-infer-keywords':
    729 
    730   ┌────
    731   │ ;;; Directory Local Variables.  For more information evaluate:
    732   │ ;;;
    733   │ ;;;     (info "(emacs) Directory Variables")
    734    735   │ ((nil . ((denote-directory . default-directory)
    736   │ 	 (denote-known-keywords . ("food" "drink"))
    737   │ 	 (denote-infer-keywords . nil))))
    738   └────
    739 
    740   To expand the list of local variables to, say, cover specific major
    741   modes, we can do something like this:
    742 
    743   ┌────
    744   │ ;;; Directory Local Variables.  For more information evaluate:
    745   │ ;;;
    746   │ ;;;     (info "(emacs) Directory Variables")
    747    748   │ ((nil . ((denote-directory . default-directory)
    749   │ 	 (denote-known-keywords . ("food" "drink"))
    750   │ 	 (denote-infer-keywords . nil)))
    751   │  (org-mode . ((org-hide-emphasis-markers . t)
    752   │ 	      (org-hide-macro-markers . t)
    753   │ 	      (org-hide-leading-stars . t))))
    754   └────
    755 
    756   As not all user options have a “safe” local value, Emacs will ask the
    757   user to confirm their choice and to store it in the Custom code
    758   snippet that is normally appended to init file (or added to the file
    759   specified by the user option `custom-file').
    760 
    761   Finally, it is possible to have a `.dir-locals.el' for subdirectories
    762   of any `denote-directory'.  Perhaps to specify a different set of
    763   known keywords, while not making the subdirectory a silo in its own
    764   right.  We shall not expand on such an example, as we trust the user
    765   to experiment with the best setup for their workflow.
    766 
    767   Feel welcome to ask for help if the information provided herein is not
    768   sufficient.  The manual shall be expanded accordingly.
    769 
    770 
    771 3.4 Exclude certain directories from all operations
    772 ───────────────────────────────────────────────────
    773 
    774   The user option `denote-excluded-directories-regexp' instructs all
    775   Denote functions that read or check file/directory names to omit
    776   directories that match the given regular expression.  The regexp needs
    777   to match only the name of the directory, not its full path.
    778 
    779   Affected operations include file prompts and functions that return the
    780   available files in the value of the user option `denote-directory'
    781   ([Maintain separate directory silos for notes]).
    782 
    783   File prompts are used by several commands, such as `denote-link' and
    784   `denote-subdirectory'.
    785 
    786   Functions that check for files include `denote-directory-files' and
    787   `denote-directory-subdirectories'.
    788 
    789   The match is performed with `string-match-p'.
    790 
    791   [For developers or advanced users].
    792 
    793 
    794 [Maintain separate directory silos for notes] See section 3.3
    795 
    796 [For developers or advanced users] See section 14
    797 
    798 
    799 3.5 Exclude certain keywords from being inferred
    800 ────────────────────────────────────────────────
    801 
    802   The user option `denote-excluded-keywords-regexp' omits keywords that
    803   match a regular expression from the list of inferred keywords.
    804 
    805   Keywords are inferred from file names and provided at relevant prompts
    806   as completion candidates when the user option `denote-infer-keywords'
    807   is non-nil.
    808 
    809   The match is performed with `string-match-p'.
    810 
    811 
    812 4 Renaming files
    813 ════════════════
    814 
    815   Denote provides commands to rename files and update their front matter
    816   where relevant.  For Denote to work, only the file name needs to be in
    817   order, by following our naming conventions ([The file-naming scheme]).
    818   The linking mechanism, in particular, needs just the identifier in the
    819   file name ([Linking notes]).
    820 
    821   We write front matter in notes for the user’s convenience and for
    822   other tools to make use of that information (e.g. Org’s export
    823   mechanism).  The renaming mechanism takes care to keep this data in
    824   sync with the file name, when the user performs a change.
    825 
    826   Renaming is useful for managing existing files created with Denote,
    827   but also for converting older text files to Denote notes.
    828 
    829   Lastly, Denote’s file-naming scheme is not specific to notes or text
    830   files: it is useful for all sorts of items, such as multimedia and
    831   PDFs that form part of the user’s longer-term storage.  While Denote
    832   does not manage such files (e.g. doesn’t create links to them), it
    833   already has all the mechanisms to facilitate the task of renaming
    834   them.
    835 
    836 
    837 [The file-naming scheme] See section 5
    838 
    839 [Linking notes] See section 7
    840 
    841 4.1 Rename a single file
    842 ────────────────────────
    843 
    844   The `denote-rename-file' command renames a file and updates existing
    845   front matter if appropriate.
    846 
    847   If in Dired, the `FILE' to be renamed is the one at point, else the
    848   command prompts with minibuffer completion for a target file.
    849 
    850   If `FILE' has a Denote-compliant identifier, retain it while updating
    851   the `TITLE' and `KEYWORDS' fields of the file name.  Else create an
    852   identifier based on the following conditions:
    853 
    854   • If `FILE' does not have an identifier and optional `DATE' is non-nil
    855     (such as with a prefix argument), invoke the function
    856     `denote-prompt-for-date-return-id'.  It prompts for a date and uses
    857     it to derive the identifier.
    858 
    859   • If `FILE' does not have an identifier and optional `DATE' is nil
    860     (this is the case without a prefix argument), use the file
    861     attributes to determine the last modified date and format it as an
    862     identifier.
    863 
    864   • As a fallback, derive an identifier from the current time.
    865 
    866   The default `TITLE' is retrieved from a line starting with a title
    867   field in the file’s contents, depending on the given file type ([Front
    868   matter]).  Else, the file name is used as a default value at the
    869   minibuffer prompt.
    870 
    871   As a final step after the `FILE', `TITLE', and `KEYWORDS' prompts, ask
    872   for confirmation, showing the difference between old and new file
    873   names.  For example:
    874 
    875   ┌────
    876   │ Rename sample.txt to 20220612T052900--my-sample-title__testing.txt? (y or n)
    877   └────
    878 
    879   The file type extension (e.g. `.txt') is read from the underlying file
    880   and is preserved through the renaming process.  Files that have no
    881   extension are simply left without one.
    882 
    883   Renaming only occurs relative to the current directory.  Files are not
    884   moved between directories.
    885 
    886   If the `FILE' has Denote-style front matter for the `TITLE' and
    887   `KEYWORDS', this command asks to rewrite their values in order to
    888   reflect the new input (this step always requires confirmation and the
    889   underlying buffer is not saved, so consider invoking
    890   `diff-buffer-with-file' to double-check the effect).  The rewrite of
    891   the `FILE' and `KEYWORDS' in the front matter should not affect the
    892   rest of the block.
    893 
    894   If the file doesn’t have front matter but is among the supported file
    895   types (per `denote-file-type'), the `denote-rename-file' command adds
    896   front matter at the top of it and leaves the buffer unsaved for
    897   further inspection.
    898 
    899   This command is intended to (i) rename existing Denote notes while
    900   updating their title and keywords in the front matter, (ii) convert
    901   existing supported file types to Denote notes, and (ii) rename
    902   non-note files (e.g. PDF) that can benefit from Denote’s file-naming
    903   scheme.  The latter is a convenience we provide, since we already have
    904   all the requisite mechanisms in place (though Denote does not—and will
    905   not—manage such files).
    906 
    907 
    908 [Front matter] See section 6
    909 
    910 
    911 4.2 Rename multiple files at once
    912 ─────────────────────────────────
    913 
    914   The `denote-dired-rename-marked-files' command renames marked files in
    915   Dired to conform with our file-naming scheme.  The operation does the
    916   following:
    917 
    918   • the file’s existing file name is retained and becomes the `TITLE'
    919     field, per Denote’s file-naming scheme;
    920 
    921   • the `TITLE' is sluggified and downcased, per our conventions;
    922 
    923   • an identifier is prepended to the `TITLE';
    924 
    925   • the file’s extension is retained;
    926 
    927   • a prompt is asked once for the `KEYWORDS' field and the input is
    928     applied to all file names;
    929 
    930   • if the file is recognized as a Denote note, this command adds or
    931     rewrites front matter to include the new keywords.  A confirmation
    932     to carry out this step is performed once at the outset.  Note that
    933     the affected buffers are not saved.  The user can thus check them to
    934     confirm that the new front matter does not cause any problems
    935     (e.g. with the command `diff-buffer-with-file').  Multiple buffers
    936     can be saved with `save-some-buffers' (read its doc string).  The
    937     addition of front matter takes place only if the given file has the
    938     appropriate file type extension (per the user option
    939     `denote-file-type').
    940 
    941 
    942 4.3 Rename a single file based on its front matter
    943 ──────────────────────────────────────────────────
    944 
    945   In the previous section, we covered the more general mechanism of the
    946   command `denote-rename-file' ([Rename a single file]).  There is also
    947   a way to have the same outcome by making Denote read the data in the
    948   current file’s front matter and use it to construct/update the file
    949   name.  The command for this is
    950   `denote-rename-file-using-front-matter'.  It is only relevant for
    951   files that (i) are among the supported file types, per
    952   `denote-file-type', and (ii) have the requisite front matter in place.
    953 
    954   Suppose you have an `.org' file with this front matter ([Front
    955   matter]):
    956 
    957   ┌────
    958   │ #+title:      My sample note file
    959   │ #+date:       [2022-08-05 Fri 13:10]
    960   │ #+filetags:   :testing:
    961   │ #+identifier: 20220805T131044
    962   └────
    963 
    964   Its file name reflects this information:
    965 
    966   ┌────
    967   │ 20220805T131044--my-sample-note-file__testing.org
    968   └────
    969 
    970 
    971   You want to change its title and keywords manually, so you modify it
    972   thus:
    973 
    974   ┌────
    975   │ #+title:      My modified sample note file
    976   │ #+date:       [2022-08-05 Fri 13:10]
    977   │ #+filetags:   :testing:denote:emacs:
    978   │ #+identifier: 20220805T131044
    979   └────
    980 
    981   The file name still shows the old title and keywords.  So after saving
    982   the buffer, you invoke `denote-rename-file-using-front-matter' and it
    983   updates the file name to:
    984 
    985   ┌────
    986   │ 20220805T131044--my-modified-sample-note-file__testing_denote_emacs.org
    987   └────
    988 
    989 
    990   The renaming is subject to a “yes or no” prompt that shows the old and
    991   new names, just so the user is certain about the change.
    992 
    993   If called interactively with a prefix argument `C-u' or from Lisp with
    994   a non-nil `AUTO-CONFIRM' argument, this “yes or no” prompt is skipped.
    995 
    996   The identifier of the file, if any, is never modified even if it is
    997   edited in the front matter: Denote considers the file name to be the
    998   source of truth in this case, to avoid potential breakage with typos
    999   and the like.
   1000 
   1001 
   1002 [Rename a single file] See section 4.1
   1003 
   1004 [Front matter] See section 6
   1005 
   1006 
   1007 4.4 Rename multiple files based on their front matter
   1008 ─────────────────────────────────────────────────────
   1009 
   1010   As already noted, Denote can rename a file based on the data in its
   1011   front matter ([Rename a single file based on its front matter]).  The
   1012   command `denote-dired-rename-marked-files-using-front-matter' extends
   1013   this principle to a batch operation which applies to all marked files
   1014   in Dired.
   1015 
   1016   Marked files must count as notes for the purposes of Denote, which
   1017   means that they at least have an identifier in their file name and use
   1018   a supported file type, per `denote-file-type'.  Files that do not meet
   1019   this criterion are ignored.
   1020 
   1021   The operation does the following:
   1022 
   1023   • the title in the front matter becomes the `TITLE' component of the
   1024     file name ([The file-naming scheme]);
   1025 
   1026   • the keywords in the front matter are used for the `KEYWORDS'
   1027     component of the file name and are processed accordingly, if needed;
   1028 
   1029   • the identifier remains unchanged in the file name even if it is
   1030     modified in the front matter (this is done to avoid breakage caused
   1031     by typos and the like).
   1032 
   1033   NOTE that files must be saved, because Denote reads from the
   1034   underlying file, not a modified buffer (this is done to avoid
   1035   potential mistakes).  The return value of a modified buffer is the one
   1036   prior to the modification, i.e. the one already written on disk.
   1037 
   1038   This command is useful for synchronizing multiple file names with
   1039   their respective front matter.
   1040 
   1041 
   1042 [Rename a single file based on its front matter] See section 4.3
   1043 
   1044 [The file-naming scheme] See section 5
   1045 
   1046 
   1047 5 The file-naming scheme
   1048 ════════════════════════
   1049 
   1050   Notes are stored the `denote-directory'.  The default path is
   1051   `~/Documents/notes'.  The `denote-directory' can be a flat listing,
   1052   meaning that it has no subdirectories, or it can be a directory tree.
   1053   Either way, Denote takes care to only consider “notes” as valid
   1054   candidates in the relevant operations and will omit other files or
   1055   directories.
   1056 
   1057   Every note produced by Denote follows this pattern ([Points of
   1058   entry]):
   1059 
   1060   ┌────
   1061   │ DATE--TITLE__KEYWORDS.EXTENSION
   1062   └────
   1063 
   1064 
   1065   The `DATE' field represents the date in year-month-day format followed
   1066   by the capital letter `T' (for “time”) and the current time in
   1067   hour-minute-second notation.  The presentation is compact:
   1068   `20220531T091625'.  The `DATE' serves as the unique identifier of each
   1069   note.
   1070 
   1071   The `TITLE' field is the title of the note, as provided by the user.
   1072   It automatically gets downcased and hyphenated.  An entry about
   1073   “Economics in the Euro Area” produces an `economics-in-the-euro-area'
   1074   string for the `TITLE' of the file name.
   1075 
   1076   The `KEYWORDS' field consists of one or more entries demarcated by an
   1077   underscore (the separator is inserted automatically).  Each keyword is
   1078   a string provided by the user at the relevant prompt which broadly
   1079   describes the contents of the entry.  Keywords that need to be more
   1080   than one-word-long must be written with hyphens: any other character,
   1081   such as spaces or the plus sign is automatically converted into a
   1082   hyphen.  So when `emacs_library' appears in a file name, it is
   1083   interpreted as two distinct keywords, whereas `emacs-library' is one
   1084   keyword.  This is reflected in how the keywords are recorded in the
   1085   note ([Front matter]).  While Denote supports multi-word keywords by
   1086   default, the user option `denote-allow-multi-word-keywords' can be set
   1087   to nil to forcibly join all words into one, meaning that an input of
   1088   `word1 word2' will be written as `word1word2'.
   1089 
   1090   The `EXTENSION' is the file type.  By default, it is `.org'
   1091   (`org-mode') though the user option `denote-file-type' provides
   1092   support for Markdown with YAML or TOML variants (`.md' which runs
   1093   `markdown-mode') and plain text (`.txt' via `text-mode').  Consult its
   1094   doc string for the minutiae.  While files end in the `.org' extension
   1095   by default, the Denote code base does not actually depend on org.el
   1096   and/or its accoutrements.
   1097 
   1098   Examples:
   1099 
   1100   ┌────
   1101   │ 20220610T043241--initial-thoughts-on-the-zettelkasten-method__notetaking.org
   1102   │ 20220610T062201--define-custom-org-hyperlink-type__denote_emacs_package.md
   1103   │ 20220610T162327--on-hierarchy-and-taxis__notetaking_philosophy.txt
   1104   └────
   1105 
   1106 
   1107   The different field separators, namely `--' and `__' introduce an
   1108   efficient way to anchor searches (such as with Emacs commands like
   1109   `isearch' or from the command-line with `find' and related).  A query
   1110   for `_word' always matches a keyword, while a regexp in the form of,
   1111   say, `"\\([0-9T]+?\\)--\\(.*?\\)_"' captures the date in group `\1'
   1112   and the title in `\2' (test any regular expression in the current
   1113   buffer by invoking `M-x re-builder').
   1114 
   1115   [Features of the file-naming scheme for searching or filtering].
   1116 
   1117   While Denote is an Emacs package, notes should work long-term and not
   1118   depend on the functionality of a specific program.  The file-naming
   1119   scheme we apply guarantees that a listing is readable in a variety of
   1120   contexts.
   1121 
   1122 
   1123 [Points of entry] See section 3
   1124 
   1125 [Front matter] See section 6
   1126 
   1127 [Features of the file-naming scheme for searching or filtering] See
   1128 section 5.2
   1129 
   1130 5.1 Sluggified title and keywords
   1131 ─────────────────────────────────
   1132 
   1133   Denote has to be highly opinionated about which characters can be used
   1134   in file names and the file’s front matter in order to enforce its
   1135   file-naming scheme.  The private variable `denote--punctuation-regexp'
   1136   holds the relevant value.  In simple terms:
   1137 
   1138   ⁃ What we count as “illegal characters” are converted into hyphens.
   1139 
   1140   ⁃ Input for a file title is hyphenated and downcased.  The original
   1141     value is preserved in the note’s contents ([Front matter]).
   1142 
   1143   ⁃ Keywords should not have spaces or other delimiters.  If they do,
   1144     they are converted into hyphens.  Keywords are always downcased.
   1145 
   1146 
   1147 [Front matter] See section 6
   1148 
   1149 
   1150 5.2 Features of the file-naming scheme for searching or filtering
   1151 ─────────────────────────────────────────────────────────────────
   1152 
   1153   File names have three fields and two sets of field delimiters between
   1154   them:
   1155 
   1156   ┌────
   1157   │ DATE--TITLE__KEYWORDS.EXTENSION
   1158   └────
   1159 
   1160 
   1161   The first field delimiter is the double hyphen, while the second is
   1162   the double underscore.  These practically serve as anchors for easier
   1163   searching.  Consider this example:
   1164 
   1165   ┌────
   1166   │ 20220621T062327--introduction-to-denote__denote_emacs.txt
   1167   └────
   1168 
   1169 
   1170   You will notice that there are two matches for the word `denote': one
   1171   in the title field and another in the keywords’ field.  Because of the
   1172   distinct field delimiters, if we search for `-denote' we only match
   1173   the first instance while `_denote' targets the second one.  When
   1174   sorting through your notes, this kind of specificity is invaluable—and
   1175   you get it for free from the file names alone!
   1176 
   1177   Users can get a lot of value out of this simple arrangement, even if
   1178   they have no knowledge of regular expressions.  One thing to consider,
   1179   for maximum effect, is to avoid using multi-word keywords as those get
   1180   hyphenated like the title and will thus interfere with the above:
   1181   either set the user option `denote-allow-multi-word-keywords' to nil
   1182   or simply insert single words at the relevant prompts.
   1183 
   1184 
   1185 6 Front matter
   1186 ══════════════
   1187 
   1188   Notes have their own “front matter”.  This is a block of data at the
   1189   top of the file, with no empty lines between the entries, which is
   1190   automatically generated at the creation of a new note.  The front
   1191   matter includes the title and keywords (aka “tags” or “filetags”,
   1192   depending on the file type) which the user specified at the relevant
   1193   prompt, as well as the date and unique identifier, which are derived
   1194   automatically.
   1195 
   1196   This is how it looks for Org mode (when `denote-file-type' is nil or
   1197   the `org' symbol):
   1198 
   1199   ┌────
   1200   │ #+title:      This is a sample note
   1201   │ #+date:       [2022-06-30 Thu 16:09]
   1202   │ #+filetags:   :denote:testing:
   1203   │ #+identifier: 20220630T160934
   1204   └────
   1205 
   1206   For Markdown with YAML (`denote-file-type' has the `markdown-yaml'
   1207   value), the front matter looks like this:
   1208 
   1209   ┌────
   1210   │ ---
   1211   │ title:      "This is a sample note"
   1212   │ date:       2022-06-30T16:09:58+03:00
   1213   │ tags:       ["denote", "testing"]
   1214   │ identifier: "20220630T160958"
   1215   │ ---
   1216   └────
   1217 
   1218   For Markdown with TOML (`denote-file-type' has the `markdown-toml'
   1219   value), it is:
   1220 
   1221   ┌────
   1222   │ +++
   1223   │ title      = "This is a sample note"
   1224   │ date       = 2022-06-30T16:10:13+03:00
   1225   │ tags       = ["denote", "testing"]
   1226   │ identifier = "20220630T161013"
   1227   │ +++
   1228   └────
   1229 
   1230   And for plain text (`denote-file-type' has the `text' value), we have
   1231   the following:
   1232 
   1233   ┌────
   1234   │ title:      This is a sample note
   1235   │ date:       2022-06-30
   1236   │ tags:       denote  testing
   1237   │ identifier: 20220630T161028
   1238   │ ---------------------------
   1239   └────
   1240 
   1241   The format of the date in the front matter is controlled by the user
   1242   option `denote-date-format'.  When nil, Denote uses a
   1243   file-type-specific format:
   1244 
   1245   • For Org, an inactive timestamp is used, such as `[2022-06-30 Wed
   1246     15:31]'.
   1247 
   1248   • For Markdown, the RFC3339 standard is applied:
   1249     `2022-06-30T15:48:00+03:00'.
   1250 
   1251   • For plain text, the format is that of ISO 8601: `2022-06-30'.
   1252 
   1253   If the value is a string, ignore the above and use it instead.  The
   1254   string must include format specifiers for the date.  These are
   1255   described in the doc string of `format-time-string'..
   1256 
   1257 
   1258 6.1 Change the front matter format
   1259 ──────────────────────────────────
   1260 
   1261   Per Denote’s design principles, the code is hackable.  All front
   1262   matter is stored in variables that are intended for public use.  We do
   1263   not declare those as “user options” because (i) they expect the user
   1264   to have some degree of knowledge in Emacs Lisp and (ii) implement
   1265   custom code.
   1266 
   1267   [ NOTE for tinkerers: code intended for internal use includes double
   1268     hyphens in its symbol.  “Internal use” means that it can be changed
   1269     without warning and with no further reference in the change log.  Do
   1270     not use any of it without understanding the consequences. ]
   1271 
   1272   The variables which hold the front matter format are:
   1273 
   1274   • `denote-org-front-matter'
   1275 
   1276   • `denote-text-front-matter'
   1277 
   1278   • `denote-toml-front-matter'
   1279 
   1280   • `denote-yaml-front-matter'
   1281 
   1282   These variables have a string value with specifiers that are used by
   1283   the `format' function.  The formatting operation passes four arguments
   1284   which include the values of the given entries.  If you are an advanced
   1285   user who wants to edit this variable to affect how front matter is
   1286   produced, consider using something like `%2$s' to control where the
   1287   Nth argument is placed.
   1288 
   1289   When editing the value, make sure to:
   1290 
   1291   1. Not use empty lines inside the front matter block.
   1292 
   1293   2. Insert at least one empty line after the front matter block and do
   1294      not use any empty line before it.
   1295 
   1296   These help with consistency and might prove useful if we ever need to
   1297   operate on the front matter as a whole.
   1298 
   1299   With those granted, below are some examples.  The approach is the same
   1300   for all variables.
   1301 
   1302   ┌────
   1303   │ ;; Like the default, but upcase the entries
   1304   │ (setq denote-org-front-matter
   1305   │   "#+TITLE:      %s
   1306   │ #+DATE:       %s
   1307   │ #+FILETAGS:   %s
   1308   │ #+IDENTIFIER: %s
   1309   │ \n")
   1310   1311   │ ;; Change the order (notice the %N$s notation)
   1312   │ (setq denote-org-front-matter
   1313   │   "#+title:      %1$s
   1314   │ #+filetags:   %3$s
   1315   │ #+date:       %2$s
   1316   │ #+identifier: %4$s
   1317   │ \n")
   1318   1319   │ ;; Remove the date
   1320   │ (setq denote-org-front-matter
   1321   │   "#+title:      %1$s
   1322   │ #+filetags:   %3$s
   1323   │ #+identifier: %4$s
   1324   │ \n")
   1325   1326   │ ;; Remove the date and the identifier
   1327   │ (setq denote-org-front-matter
   1328   │   "#+title:      %1$s
   1329   │ #+filetags:   %3$s
   1330   │ \n")
   1331   └────
   1332 
   1333   Note that `setq' has a global effect: it affects the creation of all
   1334   new notes.  Depending on the workflow, it may be preferrable to have a
   1335   custom command which `let' binds the different format.  We shall not
   1336   provide examples at this point as this is a more advanced feature and
   1337   we are not yet sure what the user’s needs are.  Please provide
   1338   feedback and we shall act accordingly.
   1339 
   1340 
   1341 6.2 Regenerate front matter
   1342 ───────────────────────────
   1343 
   1344   Sometimes the user needs to produce new front matter for an existing
   1345   note.  Perhaps because they accidentally deleted a line and could not
   1346   undo the operation.  The command `denote-add-front-matter' can be used
   1347   for this very purpose.
   1348 
   1349   In interactive use, `denote-add-front-matter' must be invoked from a
   1350   buffer that visits a Denote note.  It prompts for a title and then for
   1351   keywords.  These are the standard prompts we already use for note
   1352   creation, so the keywords’ prompt allows minibuffer completion and the
   1353   input of multiple entries, each separated by a comma ([Points of
   1354   entry]).
   1355 
   1356   The newly created front matter is added to the top of the file.
   1357 
   1358   This command does not rename the file (e.g. to update the keywords).
   1359   To rename a file by reading its front matter as input, the user can
   1360   rely on `denote-rename-file-using-front-matter' ([Renaming files]).
   1361 
   1362   Note that `denote-add-front-matter' is useful only for existing Denote
   1363   notes.  If the user needs to convert a generic text file to a Denote
   1364   note, they can use one of the command which first rename the file to
   1365   make it comply with our file-naming scheme and then add the relevant
   1366   front matter.
   1367 
   1368 
   1369 [Points of entry] See section 3
   1370 
   1371 [Renaming files] See section 4
   1372 
   1373 
   1374 7 Linking notes
   1375 ═══════════════
   1376 
   1377   Denote offers several commands for linking between notes.
   1378 
   1379   All links target files which are Denote notes.  This means that they
   1380   have our file-naming scheme, are writable/regular (not directory,
   1381   named pipe, etc.), and use the appropriate file type extension (per
   1382   `denote-file-type').  Furthermore, the files need to be inside the
   1383   `denote-directory' or one of its subdirectories.  No other file is
   1384   recognised.
   1385 
   1386   The following sections delve into the details.
   1387 
   1388 
   1389 7.1 Adding a single link
   1390 ────────────────────────
   1391 
   1392   The `denote-link' command inserts a link at point to an entry
   1393   specified at the minibuffer prompt.  Links are formatted depending on
   1394   the file type of current note.  In Org and plain text buffers, links
   1395   are formatted thus: `[[denote:IDENTIFIER][TITLE]]'.  While in Markdown
   1396   they are expressed as `[TITLE](denote:IDENTIFIER)'.
   1397 
   1398   When `denote-link' is called with a prefix argument (`C-u' by
   1399   default), it formats links like `[[denote:IDENTIFIER]]'.  The user
   1400   might prefer its simplicity.
   1401 
   1402   The description of the link is taken from the target file’s front
   1403   matter or, if that is not available, from the file name.  If the
   1404   region is active, its text is used as the link’s description instead.
   1405   If the active region has no text, the inserted link used just the
   1406   identifier, as with the `C-u' prefix mentioned above.
   1407 
   1408   Inserted links are automatically buttonized and remain active for as
   1409   long as the buffer is available.  In Org this is handled by the major
   1410   mode: the `denote:' hyperlink type works exactly like the standard
   1411   `file:'.  In Markdown and plain text, Denote performs the
   1412   buttonization of those links.  To buttonize links in existing files
   1413   while visiting them, the user must add this snippet to their setup (it
   1414   already excludes Org):
   1415 
   1416   ┌────
   1417   │ (add-hook 'find-file-hook #'denote-link-buttonize-buffer)
   1418   └────
   1419 
   1420   The `denote-link-buttonize-buffer' is also an interactive function in
   1421   case the user needs it.
   1422 
   1423   Links are created only for files which qualify as a “note” for our
   1424   purposes ([Linking notes]).
   1425 
   1426   Links are styled with the `denote-faces-link' face, which looks
   1427   exactly like an ordinary link by default.  This is just a convenience
   1428   for the user/theme in case they want `denote:' links to remain
   1429   distinct from other links.
   1430 
   1431 
   1432 [Linking notes] See section 7
   1433 
   1434 
   1435 7.2 Insert links matching a regexp
   1436 ──────────────────────────────────
   1437 
   1438   The command `denote-link-add-links' adds links at point matching a
   1439   regular expression or plain string.  The links are inserted as a
   1440   typographic list, such as:
   1441 
   1442   ┌────
   1443   │ - link1
   1444   │ - link2
   1445   │ - link3
   1446   └────
   1447 
   1448   Each link is formatted according to the file type of the current note,
   1449   as explained further above about the `denote-link' command.  The
   1450   current note is excluded from the matching entries (adding a link to
   1451   itself is pointless).
   1452 
   1453   When called with a prefix argument (`C-u') `denote-link-add-links'
   1454   will format all links as `[[denote:IDENTIFIER]]', hence a typographic
   1455   list:
   1456 
   1457   ┌────
   1458   │ - [[denote:IDENTIFIER-1]]
   1459   │ - [[denote:IDENTIFIER-2]]
   1460   │ - [[denote:IDENTIFIER-3]]
   1461   └────
   1462 
   1463   Same examples of a regular expression that can be used with this
   1464   command:
   1465 
   1466   • `journal' match all files which include `journal' anywhere in their
   1467     name.
   1468 
   1469   • `_journal' match all files which include `journal' as a keyword.
   1470 
   1471   • `^2022.*_journal' match all file names starting with `2022' and
   1472     including the keyword `journal'.
   1473 
   1474   • `\.txt' match all files including `.txt'.  In practical terms, this
   1475     only applies to the file extension, as Denote automatically removes
   1476     dots (and other characters) from the base file name.
   1477 
   1478   If files are created with `denote-sort-keywords' as non-nil (the
   1479   default), then it is easy to write a regexp that includes multiple
   1480   keywords in alphabetic order:
   1481 
   1482   • `_denote.*_package' match all files that include both the `denote'
   1483     and `package' keywords, in this order.
   1484 
   1485   • `\(.*denote.*package.*\)\|\(.*package.*denote.*\)' is the same as
   1486     above, but out-of-order.
   1487 
   1488   Remember that regexp constructs only need to be escaped once (like
   1489   `\|') when done interactively but twice when called from Lisp.  What
   1490   we show above is for interactive usage.
   1491 
   1492   Links are created only for files which qualify as a “note” for our
   1493   purposes ([Linking notes]).
   1494 
   1495 
   1496 [Linking notes] See section 7
   1497 
   1498 
   1499 7.3 Insert links, but only those missing from current buffer
   1500 ────────────────────────────────────────────────────────────
   1501 
   1502   As a variation on the `denote-link-add-links' command, one may wish to
   1503   only include ’missing links’, i.e. links that are not yet present in
   1504   the current file.
   1505 
   1506   This can be achieved with `denote-link-add-missing-links'. The command
   1507   is similar to `denote-link-add-links', but will only include links to
   1508   notes that are not yet linked to ([Insert links matching a regexp]).
   1509 
   1510 
   1511 [Insert links matching a regexp] See section 7.2
   1512 
   1513 
   1514 7.4 Insert links from marked files in Dired
   1515 ───────────────────────────────────────────
   1516 
   1517   The command `denote-link-dired-marked-notes' is similar to
   1518   `denote-link-add-links' in that it inserts in the buffer a typographic
   1519   list of links to Denote notes ([Insert links matching a regexp]).
   1520   Though instead of reading a regular expression, it lets the user mark
   1521   files in Dired and link to them.  This should be easier for users of
   1522   all skill levels, instead of having to write a potentially complex
   1523   regular expression.
   1524 
   1525   If there are multiple buffers that visit a Denote note, this command
   1526   will ask to select one among them, using minibuffer completion.  If
   1527   there is only one buffer, it will operate in it outright.  If there
   1528   are no buffers, it will produce an error.
   1529 
   1530   With optional `ID-ONLY' as a prefix argument (`C-u' by default), the
   1531   command inserts links with just the identifier, which is the same
   1532   principle as with `denote-link' and others ([Adding a single link]).
   1533 
   1534   The command `denote-link-dired-marked-notes' is meant to be used from
   1535   a Dired buffer.
   1536 
   1537   As always, links are created only for files which qualify as a “note”
   1538   for our purposes ([Linking notes]).
   1539 
   1540 
   1541 [Insert links matching a regexp] See section 7.2
   1542 
   1543 [Adding a single link] See section 7.1
   1544 
   1545 [Linking notes] See section 7
   1546 
   1547 
   1548 7.5 Link to an existing note or create a new one
   1549 ────────────────────────────────────────────────
   1550 
   1551   In one’s note-taking workflow, there may come a point where they are
   1552   expounding on a certain topic but have an idea about another subject
   1553   they would like to link to ([Linking notes]).  The user can always
   1554   rely on the other linking facilities we have covered herein to target
   1555   files that already exist.  Though they may not know whether they
   1556   already have notes covering the subject or whether they would need to
   1557   write new ones.  To this end, Denote provides two convenience
   1558   commands:
   1559 
   1560   `denote-link-after-creating'
   1561         Create new note in the background and link to it directly.
   1562 
   1563         Use `denote' interactively to produce the new note.  Its doc
   1564         string or this manual explains which prompts will be used and
   1565         under what conditions ([Standard note creation]).
   1566 
   1567         With optional `ID-ONLY' as a prefix argument (this is the `C-u'
   1568         key, by default) create a link that consists of just the
   1569         identifier.  Else try to also include the file’s title.  This
   1570         has the same meaning as in `denote-link' ([Adding a single
   1571         link]).
   1572 
   1573         IMPORTANT NOTE: Normally, `denote' does not save the buffer it
   1574         produces for the new note.  This is a safety precaution to not
   1575         write to disk unless the user wants it (e.g. the user may choose
   1576         to kill the buffer, thus cancelling the creation of the note).
   1577         However, for this command the creation of the note happens in
   1578         the background and the user may miss the step of saving their
   1579         buffer.  We thus have to save the buffer in order to (i)
   1580         establish valid links, and (ii) retrieve whatever front matter
   1581         from the target file.
   1582 
   1583   `denote-link-or-create'
   1584         Use `denote-link' on `TARGET' file, creating it if necessary.
   1585 
   1586         If `TARGET' file does not exist, call
   1587         `denote-link-after-creating' which runs the `denote' command
   1588         interactively to create the file.  The established link will
   1589         then be targeting that new file.
   1590 
   1591         If `TARGET' file does not exist, add the user input that was
   1592         used to search for it to the history of the
   1593         `denote-title-prompt'.  The user can then retrieve and possibly
   1594         further edit their last input, using it as the newly created
   1595         note’s actual title.  At the `denote-title-prompt' type `M-p'
   1596         with the default key bindings, which calls
   1597         `previous-history-element'.
   1598 
   1599         With optional `ID-ONLY' as a prefix argument create a link with
   1600         just the file’s identifier.  This has the same meaning as in
   1601         `denote-link'.
   1602 
   1603         This command has the alias
   1604         `denote-link-to-existing-or-new-note', which helps with
   1605         discoverability.
   1606 
   1607 
   1608 [Linking notes] See section 7
   1609 
   1610 [Standard note creation] See section 3.1
   1611 
   1612 [Adding a single link] See section 7.1
   1613 
   1614 
   1615 7.6 The backlinks’ buffer
   1616 ─────────────────────────
   1617 
   1618   The command `denote-link-backlinks' produces a bespoke buffer which
   1619   displays backlinks to the current note.  A “backlink” is a link back
   1620   to the present entry.
   1621 
   1622   By default, the backlinks’ buffer is desinged to display the file name
   1623   of the note linking to the current entry.  Each file name is presented
   1624   on its own line, like this:
   1625 
   1626   ┌────
   1627   │ Backlinks to "On being honest" (20220614T130812)
   1628   │ ------------------------------------------------
   1629   1630   │ 20220614T145606--let-this-glance-become-a-stare__journal.txt
   1631   │ 20220616T182958--feeling-butterflies-in-your-stomach__journal.txt
   1632   └────
   1633 
   1634   When the user option `denote-backlinks-show-context' is non-nil, the
   1635   backlinks’ buffer displays the line on which a link to the current
   1636   note occurs.  It also shows multiple occurances, if present.  It looks
   1637   like this (and has the appropriate fontification):
   1638 
   1639   ┌────
   1640   │ Backlinks to "On being honest" (20220614T130812)
   1641   │ ------------------------------------------------
   1642   1643   │ 20220614T145606--let-this-glance-become-a-stare__journal.txt
   1644   │ 37: growing into it: [[denote:20220614T130812][On being honest]].
   1645   │ 64: As I said in [[denote:20220614T130812][On being honest]] I have never
   1646   │ 20220616T182958--feeling-butterflies-in-your-stomach__journal.txt
   1647   │ 62: indifference.  In [[denote:20220614T130812][On being honest]] I alluded
   1648   └────
   1649 
   1650   Note that the width of the lines in the context depends on the
   1651   underlying file.  In the above example, the lines are split at the
   1652   `fill-column'.  Long lines will show up just fine.  Also note that the
   1653   built-in user option `xref-truncation-width' can truncate long lines
   1654   to a given maximum number of characters.
   1655 
   1656   [Speed up backlinks’ buffer creation?]
   1657 
   1658   The backlinks’ buffer runs the major-mode `denote-backlinks-mode'.  It
   1659   binds keys to move between links with `n' (next) and `p' (previous).
   1660   These are stored in the `denote-backlinks-mode-map' (use `M-x
   1661   describe-mode' (`C-h m') in an unfamiliar buffer to learn more about
   1662   it).  When the user option `denote-backlinks-show-context' is non-nil,
   1663   all relevant Xref key bindings are fully functional: again, check
   1664   `describe-mode'.
   1665 
   1666   The backlinking facility uses Emacs’ built-in Xref infrastructure.  On
   1667   some operating systems, the user may need to add certain executables
   1668   to the relevant environment variable.
   1669 
   1670   [Why do I get “Search failed with status 1” when I search for
   1671   backlinks?]
   1672 
   1673   Backlinks to the current file can also be visited by using the
   1674   minibuffer completion interface with the `denote-link-find-backlink'
   1675   command ([Visiting linked files via the minibuffer]).
   1676 
   1677   The placement of the backlinks’ buffer is subject to the user option
   1678   `denote-link-backlinks-display-buffer-action'.  Due to the nature of
   1679   the underlying `display-buffer' mechanism, this inevitably is a
   1680   relatively advanced feature.  By default, the backlinks’ buffer is
   1681   displayed below the current window.  The doc string of our user option
   1682   includes a sample configuration that places the buffer in a left side
   1683   window instead.  Reproducing it here for the sake of convenience:
   1684 
   1685   ┌────
   1686   │ (setq denote-link-backlinks-display-buffer-action
   1687   │       '((display-buffer-reuse-window
   1688   │ 	 display-buffer-in-side-window)
   1689   │ 	(side . left)
   1690   │ 	(slot . 99)
   1691   │ 	(window-width . 0.3)))
   1692   └────
   1693 
   1694 
   1695 [Speed up backlinks’ buffer creation?] See section 19.9
   1696 
   1697 [Why do I get “Search failed with status 1” when I search for
   1698 backlinks?] See section 19.10
   1699 
   1700 [Visiting linked files via the minibuffer] See section 7.8
   1701 
   1702 
   1703 7.7 Writing metanotes
   1704 ─────────────────────
   1705 
   1706   A “metanote” is an entry that describes other entries who have
   1707   something in common.  Writing metanotes can be part of a workflow
   1708   where the user periodically reviews their work in search of patterns
   1709   and deeper insights.  For example, you might want to read your journal
   1710   entries from the past year to reflect on your experiences, evolution
   1711   as a person, and the like.
   1712 
   1713   The commands `denote-link-add-links', `denote-link-dired-marked-notes'
   1714   are suited for this task.
   1715 
   1716   [Insert links matching a regexp].
   1717 
   1718   [Insert links from marked files in Dired].
   1719 
   1720   You will create your metanote the way you use Denote ordinarily
   1721   (metanotes may have the `metanote' keyword, among others), write an
   1722   introduction or however you want to go about it, invoke the command
   1723   which inserts multiple links at once (see the above-cited nodes), and
   1724   continue writing.
   1725 
   1726   Metanotes can serve as entry points to groupings of individual notes.
   1727   They are not the same as a filtered list of files, i.e. what you would
   1728   do in Dired or the minibuffer where you narrow the list of notes to a
   1729   given query.  Metanotes contain the filtered list plus your thoughts
   1730   about it.  The act of purposefully grouping notes together and
   1731   contemplating on their shared patterns is what adds value.
   1732 
   1733   Your future self will appreciate metanotes for the function they serve
   1734   in encapsulating knowledge, while current you will be equipped with
   1735   the knowledge derived from the deliberate self-reflection.
   1736 
   1737 
   1738 [Insert links matching a regexp] See section 7.2
   1739 
   1740 [Insert links from marked files in Dired] See section 7.4
   1741 
   1742 
   1743 7.8 Visiting linked files via the minibuffer
   1744 ────────────────────────────────────────────
   1745 
   1746   Denote has a major-mode-agnostic mechanism to collect all linked file
   1747   references in the current buffer and return them as an appropriately
   1748   formatted list.  This list can then be used in interactive commands.
   1749   The `denote-link-find-file' is such a command.  It uses minibuffer
   1750   completion to visit a file that is linked to from the current note.
   1751   The candidates have the correct metadata, which is ideal for
   1752   integration with other standards-compliant tools ([Extending Denote]).
   1753   For instance, a package such as `marginalia' will display accurate
   1754   annotations, while the `embark' package will be able to work its magic
   1755   such as in exporting the list into a filtered Dired buffer (i.e. a
   1756   familiar Dired listing with only the files of the current minibuffer
   1757   session).
   1758 
   1759   To visit backlinks to the current note via the minibuffer, use
   1760   `denote-link-find-backlink'.  This is an alternative to placing
   1761   backlinks in a dedicated buffer ([The backlinks’ buffer]).
   1762 
   1763 
   1764 [Extending Denote] See section 11
   1765 
   1766 [The backlinks’ buffer] See section 7.6
   1767 
   1768 
   1769 7.9 Miscellaneous information about links
   1770 ─────────────────────────────────────────
   1771 
   1772   For convenience, the `denote-link' command has an alias called
   1773   `denote-link-insert-link'.  The `denote-link-backlinks' can also be
   1774   used as `denote-link-show-backlinks-buffer'.  While
   1775   `denote-link-add-links' is aliased
   1776   `denote-link-insert-links-matching-regexp'.  The purpose of these
   1777   aliases is to offer alternative, more descriptive names of select
   1778   commands.
   1779 
   1780 
   1781 8 Fontification in Dired
   1782 ════════════════════════
   1783 
   1784   One of the upsides of Denote’s file-naming scheme is the predictable
   1785   pattern it establishes, which appears as a near-tabular presentation
   1786   in a listing of notes (i.e. in Dired).  The `denote-dired-mode' can
   1787   help enhance this impression, by fontifying the components of the file
   1788   name to make the date (identifier) and keywords stand out.
   1789 
   1790   There are two ways to set the mode.  Either use it for all
   1791   directories, which probably is not needed:
   1792 
   1793   ┌────
   1794   │ (add-hook 'dired-mode-hook #'denote-dired-mode)
   1795   └────
   1796 
   1797   Or configure the user option `denote-dired-directories' and then set
   1798   up the function `denote-dired-mode-in-directories':
   1799 
   1800   ┌────
   1801   │ ;; We use different ways to specify a path for demo purposes.
   1802   │ (setq denote-dired-directories
   1803   │       (list denote-directory
   1804   │ 	    (thread-last denote-directory (expand-file-name "attachments"))
   1805   │ 	    (expand-file-name "~/Documents/vlog")))
   1806   1807   │ (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
   1808   └────
   1809 
   1810   The faces we define for this purpose are:
   1811 
   1812   ⁃ `denote-faces-date'
   1813   ⁃ `denote-faces-delimiter'
   1814   ⁃ `denote-faces-extension'
   1815   ⁃ `denote-faces-keywords'
   1816   ⁃ `denote-faces-subdirectory'
   1817   ⁃ `denote-faces-time'
   1818   ⁃ `denote-faces-title'
   1819 
   1820   For the time being, the `diredfl' package is not compatible with this
   1821   facility.
   1822 
   1823   The `denote-dired-mode' does not only fontify note files that were
   1824   created by Denote: it covers every file name that follows our naming
   1825   conventions ([The file-naming scheme]).  This is particularly useful
   1826   for scenaria where, say, one wants to organise their collection of
   1827   PDFs and multimedia in a systematic way (and, perhaps, use them as
   1828   attachments for the notes Denote produces if you are writing Org notes
   1829   and are using its standand attachments’ facility).
   1830 
   1831 
   1832 [The file-naming scheme] See section 5
   1833 
   1834 
   1835 9 Use Org dynamic blocks
   1836 ════════════════════════
   1837 
   1838   Denote can optionally integrate with Org mode’s “dynamic blocks”
   1839   facility.  Start by loading the relevant library:
   1840 
   1841   ┌────
   1842   │ ;; Register Denote's Org dynamic blocks
   1843   │ (require 'denote-org-dblock)
   1844   └────
   1845 
   1846   A dynamic block gets its contents by evaluating a given function,
   1847   depending on the type of block.  The type of block and its parameters
   1848   are stated in the opening `#+BEGIN' line of the block.  Typing `C-c
   1849   C-c' with point on that line runs the function, with the given
   1850   arguments, and populates the block’s contents accordingly.
   1851 
   1852   Denote leverages Org dynamic blocks to streamline the inclusion of (i)
   1853   links to notes whose name matches a given search query (like
   1854   `denote-link-add-links') and (ii) backlinks to the current note
   1855   (similar to `denote-link-find-backlink').
   1856 
   1857   These two types of blocks are named `denote-links' and
   1858   `denote-backlinks' respectively.  The latter does not accept any
   1859   parameters, while the former does, which we explain below by also
   1860   demonstrating how dynamic blocks are written.
   1861 
   1862   A dynamic block looks like this:
   1863 
   1864   ┌────
   1865   │ #+BEGIN: denote-links :regexp "_journal"
   1866   1867   │ #+END:
   1868   └────
   1869 
   1870 
   1871   Here we have the `denote-links' type, with the `:regexp' parameter.
   1872   The value of the `:regexp' parameter is the same as that of the
   1873   command `denote-link-add-links' ([Insert links matching a regexp]).
   1874   The linked entry provides practical examples of patterns that make
   1875   good use of Denote’s file-naming scheme ([The file-naming scheme]).
   1876 
   1877   In this example, we instruct Org to produce a list of all notes that
   1878   include the `journal' keyword in their file name (keywords in file
   1879   names are prefixed with the underscore).  So the following:
   1880 
   1881   ┌────
   1882   │ #+BEGIN: denote-links :regexp "_journal"
   1883   1884   │ #+END:
   1885   └────
   1886 
   1887 
   1888   Becomes something like this once we type `C-c C-c' with point on the
   1889   `#+BEGIN' line (Org makes the links look prettier by default):
   1890 
   1891   ┌────
   1892   │ #+BEGIN: denote-links :regexp "_journal"
   1893   │ - [[denote:20220616T182958][Feeling butterflies in your stomach]]
   1894   │ - [[denote:20220818T221036][Between friend and stranger]]
   1895   │ #+END:
   1896   └────
   1897 
   1898 
   1899   The dynamic block takes care to keep the list in order and to add any
   1900   missing links when the block is evaluated anew.
   1901 
   1902   Depending on one’s workflow, the dynamic block can be instructed to
   1903   list only those links which are missing from the current buffer
   1904   (similar to `denote-link-add-missing-links').  Adding the
   1905   `:missing-only' parameter with a non-`nil' value achieves this
   1906   effect. The `#+BEGIN' line looks like this:
   1907 
   1908   ┌────
   1909   │ #+BEGIN: denote-links :regexp "_journal" :missing-only t
   1910   └────
   1911 
   1912 
   1913   To reverse the order links appear in, add `:reverse t' to the
   1914   `#+BEGIN' line.
   1915 
   1916   The `denote-links' block can also accept a `:block-name' parameter
   1917   with a string value that names the block.  Once the dynamic block is
   1918   evaluated, a `#+NAME' is prepended to the block’s contents.  This can
   1919   be referenced in other source blocks to parse the named block’s
   1920   contents as input of another process.  The details are beyond the
   1921   scope of Denote.
   1922 
   1923   As for the `denote-backlinks' dynamic block type, it simply produces a
   1924   list of notes that link to the current file.  It accepts no parameters
   1925   and looks like this:
   1926 
   1927   ┌────
   1928   │ #+BEGIN: denote-backlinks
   1929   1930   │ #+END:
   1931   └────
   1932 
   1933 
   1934   The Org manual describes the technicalities of Dynamic Blocks.
   1935   Evaluate:
   1936 
   1937   ┌────
   1938   │ (info "(org) Dynamic Blocks")
   1939   └────
   1940 
   1941   Dynamic blocks are particularly useful for metanote entries that
   1942   reflect on the status of earlier notes ([Writing metanotes]).
   1943 
   1944 
   1945 [Insert links matching a regexp] See section 7.2
   1946 
   1947 [The file-naming scheme] See section 5
   1948 
   1949 [Writing metanotes] See section 7.7
   1950 
   1951 
   1952 10 Minibuffer histories
   1953 ═══════════════════════
   1954 
   1955   Denote has a dedicated minibuffer history for each one of its prompts.
   1956   This practically means that using `M-p' (`previous-history-element')
   1957   and `M-n' (`next-history-element') will only cycle through the
   1958   relevant record of inputs, such as your latest titles in the `TITLE'
   1959   prompt, and keywords in the `KEYWORDS' prompt.
   1960 
   1961   The built-in `savehist' library saves minibuffer histories.  Sample
   1962   configuration:
   1963 
   1964   ┌────
   1965   │ (require 'savehist)
   1966   │ (setq savehist-file (locate-user-emacs-file "savehist"))
   1967   │ (setq history-length 500)
   1968   │ (setq history-delete-duplicates t)
   1969   │ (setq savehist-save-minibuffer-history t)
   1970   │ (add-hook 'after-init-hook #'savehist-mode)
   1971   └────
   1972 
   1973 
   1974 11 Extending Denote
   1975 ═══════════════════
   1976 
   1977   Denote is a tool with a narrow scope: create notes and link between
   1978   them, based on the aforementioned file-naming scheme.  For other
   1979   common operations the user is advised to rely on standard Emacs
   1980   facilities or specialised third-party packages.  This section covers
   1981   the details.
   1982 
   1983 
   1984 11.1 Keep a journal or diary
   1985 ────────────────────────────
   1986 
   1987   While there are subtle technical differences between a journal and a
   1988   diary, we will consider those equivalent in the interest of brevity:
   1989   they both describe a personal space that holds a record of your
   1990   thoughts about your experiences and/or view of events in the world.
   1991 
   1992   Suppose you are committed to writing an entry every day.  Unlike what
   1993   we demonstrated before, your writing will follow a regular naming
   1994   pattern.  You know that the title of the new note must always look
   1995   like `Tuesday 14 June 2022' and the keyword has to be `journal' or
   1996   `diary'.  As such, you want to automate the task instead of being
   1997   prompted each time, as is the norm with `denote' and the relevant
   1998   commands ([Points of entry]).  This is easy to accomplish because
   1999   `denote' can be called from Lisp and given the required arguments of
   2000   `TITLE' and `KEYWORDS' directly.  All you need is a simple wrapper
   2001   function:
   2002 
   2003   ┌────
   2004   │ (defun my-denote-journal ()
   2005   │   "Create an entry tagged 'journal' with the date as its title."
   2006   │   (interactive)
   2007   │   (denote
   2008   │    (format-time-string "%A %e %B %Y") ; format like Tuesday 14 June 2022
   2009   │    '("journal"))) ; multiple keywords are a list of strings: '("one" "two")
   2010   └────
   2011 
   2012   By invoking `my-denote-journal' you will go straight into the newly
   2013   created note and commit to your writing outright.
   2014 
   2015   Of course, you can always set up the function so that it asks for a
   2016   `TITLE' but still automatically applies the `journal' tag:
   2017 
   2018   ┌────
   2019   │ (defun denote-journal-with-title ()
   2020   │   "Create an entry tagged 'journal', while prompting for a title."
   2021   │   (interactive)
   2022   │   (denote
   2023   │    (denote--title-prompt) ; ask for title, instead of using human-readable date
   2024   │    '("journal")))
   2025   └────
   2026 
   2027   Sometimes journaling is done with the intent to hone one’s writing
   2028   skills.  Perhaps you are learning a new language or wish to
   2029   communicate your ideas with greater clarity and precision.  As with
   2030   everything that requires a degree of sophistication, you have to work
   2031   for it—write, write, write!
   2032 
   2033   One way to test your progress is to set a timer.  It helps you gauge
   2034   your output and its quality.  To use a timer with Emacs, consider the
   2035   `tmr' package:
   2036 
   2037   ┌────
   2038   │ (defun my-denote-journal-with-tmr ()
   2039   │   "Like `my-denote-journal', but also set a 10-minute timer.
   2040   │ The `tmr' command is part of the `tmr' package."
   2041   │   (interactive)
   2042   │   (denote
   2043   │    (format-time-string "%A %e %B %Y")
   2044   │    '("journal"))
   2045   │   (tmr "10" "Practice writing in my journal")) ; set 10 minute timer with a description
   2046   └────
   2047 
   2048   Once the timer elapses, stop writing and review your performance.
   2049   Practice makes perfect!
   2050 
   2051   [ As Denote matures, we may add hooks to control what happens before
   2052     or after the creation of a new note.  We shall also document more
   2053     examples of tasks that can be accomplished with this package. ]
   2054 
   2055   Sources for `tmr':
   2056 
   2057   ⁃ Package name (GNU ELPA): `tmr'
   2058   ⁃ Official manual: <https://protesilaos.com/emacs/tmr>
   2059   ⁃ Change log: <https://protesilaos.com/emacs/denote-changelog>
   2060   ⁃ Git repo on SourceHut: <https://git.sr.ht/~protesilaos/tmr>
   2061     • Mirrors:
   2062       ⁃ GitHub: <https://github.com/protesilaos/tmr>
   2063       ⁃ GitLab: <https://gitlab.com/protesilaos/tmr>
   2064   ⁃ Mailing list: <https://lists.sr.ht/~protesilaos/tmr>
   2065 
   2066 
   2067 [Points of entry] See section 3
   2068 
   2069 
   2070 11.2 Create a note with the region’s contents
   2071 ─────────────────────────────────────────────
   2072 
   2073   Sometimes it makes sense to gather notes in a single file and later
   2074   review it to make multiple notes out of it.  With the following code,
   2075   the user marks a region and then invokes the command
   2076   `my-denote-create-new-note-from-region': it prompts for a title and
   2077   keywords and then uses the region’s contents to fill in the newly
   2078   created note.
   2079 
   2080   ┌────
   2081   │ (defun my-denote-create-new-note-from-region (beg end)
   2082   │   "Create note whose contents include the text between BEG and END.
   2083   │ Prompt for title and keywords of the new note."
   2084   │   (interactive "r")
   2085   │   (if-let (((region-active-p))
   2086   │ 	   (text (buffer-substring-no-properties beg end)))
   2087   │       (progn
   2088   │ 	(denote (denote--title-prompt) (denote--keywords-prompt))
   2089   │ 	(insert text))
   2090   │     (user-error "No region is available")))
   2091   └────
   2092 
   2093   Have a different workflow?  Feel welcome to discuss it in any of our
   2094   official channels ([Contributing]).
   2095 
   2096 
   2097 [Contributing] See section 15
   2098 
   2099 
   2100 11.3 Split an Org subtree into its own note
   2101 ───────────────────────────────────────────
   2102 
   2103   With Org files in particular, it is common to have nested headings
   2104   which could be split off into their own standalone notes.  In Org
   2105   parlance, an entry with all its subheadings is a “subtree”.  With the
   2106   following code, the user places the point inside the heading they want
   2107   to split off and invokes the command `my-denote-org-extract-subtree'.
   2108   It will create a note using the heading’s text and tags for the new
   2109   file.  The contents of the subtree become the contents of the new note
   2110   and are removed from the old one.
   2111 
   2112   ┌────
   2113   │ (defun my-denote-org-extract-subtree ()
   2114   │   "Create new Denote note using current Org subtree.
   2115   │ Make the new note use the Org file type, regardless of the value
   2116   │ of `denote-file-type'.
   2117   2118   │ Use the subtree title as the note's title.  If available, use the
   2119   │ tags of the heading are used as note keywords.
   2120   2121   │ Delete the original subtree."
   2122   │   (interactive)
   2123   │   (if-let ((text (org-get-entry))
   2124   │ 	   (heading (org-get-heading :no-tags :no-todo :no-priority :no-comment)))
   2125   │       (progn
   2126   │ 	(delete-region (org-entry-beginning-position) (org-entry-end-position))
   2127   │ 	(denote heading (org-get-tags) 'org)
   2128   │ 	(insert text))
   2129   │     (user-error "No subtree to extract; aborting")))
   2130   └────
   2131 
   2132   Have a different workflow?  Feel welcome to discuss it in any of our
   2133   official channels ([Contributing]).
   2134 
   2135 
   2136 [Contributing] See section 15
   2137 
   2138 
   2139 11.4 Narrow the list of files in Dired
   2140 ──────────────────────────────────────
   2141 
   2142   Emacs’ standard file manager (or directory editor) can read a regular
   2143   expression to mark the matching files.  This is the command
   2144   `dired-mark-files-regexp', which is bound to `% m' by default.  For
   2145   example, `% m _denote' will match all files that have the `denote'
   2146   keyword ([Features of the file-naming scheme for searching or
   2147   filtering]).
   2148 
   2149   Once the files are matched, the user has to options: (i) narrow the
   2150   list to the matching items or (ii) exclude the matching items from the
   2151   list.
   2152 
   2153   For the former, we want to toggle the marks by typing `t' (calls the
   2154   command `dired-toggle-marks' by default) and then hit the letter `k'
   2155   (for `dired-do-kill-lines').  The remaining files are those that match
   2156   the regexp that was provided earlier.
   2157 
   2158   For the latter approach of filtering out the matching items, simply
   2159   involves the use of the `k' command (`dired-do-kill-lines') to omit
   2160   the marked files from the list.
   2161 
   2162   These sequences can be combined to incrementally narrow the list.
   2163   Note that `dired-do-kill-lines' does not delete files: it simply hides
   2164   them from the current view.
   2165 
   2166   Revert to the original listing with `g' (`revert-buffer').
   2167 
   2168   For a convenient wrapper, consider this example:
   2169 
   2170   ┌────
   2171   │ (defvar prot-dired--limit-hist '()
   2172   │   "Minibuffer history for `prot-dired-limit-regexp'.")
   2173   2174   │ ;;;###autoload
   2175   │ (defun prot-dired-limit-regexp (regexp omit)
   2176   │   "Limit Dired to keep files matching REGEXP.
   2177   2178   │ With optional OMIT argument as a prefix (\\[universal-argument]),
   2179   │ exclude files matching REGEXP.
   2180   2181   │ Restore the buffer with \\<dired-mode-map>`\\[revert-buffer]'."
   2182   │   (interactive
   2183   │    (list
   2184   │     (read-regexp
   2185   │      (concat "Files "
   2186   │ 	     (when current-prefix-arg
   2187   │ 	       (propertize "NOT " 'face 'warning))
   2188   │ 	     "matching PATTERN: ")
   2189   │      nil 'prot-dired--limit-hist)
   2190   │     current-prefix-arg))
   2191   │   (dired-mark-files-regexp regexp)
   2192   │   (unless omit (dired-toggle-marks))
   2193   │   (dired-do-kill-lines))
   2194   └────
   2195 
   2196 
   2197 [Features of the file-naming scheme for searching or filtering] See
   2198 section 5.2
   2199 
   2200 
   2201 11.5 Use `dired-virtual-mode' for arbitrary file listings
   2202 ─────────────────────────────────────────────────────────
   2203 
   2204   Emacs’ Dired is a powerful file manager that builds its functionality
   2205   on top of the Unix `ls' command.  As noted elsewhere in this manual,
   2206   the user can update the `ls' flags that Dired uses to display its
   2207   contents ([I want to sort by last modified, why won’t Denote let
   2208   me?]).
   2209 
   2210   What Dired cannot do is parse the output of a result that is produced
   2211   by piped commands, such as `ls -l | sort -t _ -k2'.  This specific
   2212   example targets the second underscore-separated field of the file
   2213   name, per our conventions ([The file-naming scheme]).  Conceretely, it
   2214   matches the “alpha” as the sorting key in something like this:
   2215 
   2216   ┌────
   2217   │ 20220929T200432--testing-file-one__alpha.txt
   2218   └────
   2219 
   2220   Consider then, how Dired will sort those files by their identifier:
   2221 
   2222   ┌────
   2223   │ 20220929T200432--testing-file-one__alpha.txt
   2224   │ 20220929T200532--testing-file-two__beta.txt
   2225   │ 20220929T200632--testing-file-three__alpha.txt
   2226   │ 20220929T200732--testing-file-four__beta.txt
   2227   └────
   2228 
   2229   Whereas on the command line, we can get the following:
   2230 
   2231   ┌────
   2232   │ $ ls | sort -t _ -k 2
   2233   │ 20220929T200432--testing-file-one__alpha.txt
   2234   │ 20220929T200632--testing-file-three__alpha.txt
   2235   │ 20220929T200532--testing-file-two__beta.txt
   2236   │ 20220929T200732--testing-file-four__beta.txt
   2237   └────
   2238 
   2239   This is where `dired-virtual-mode' shows its utility.  If we tweak our
   2240   command-line invocation to include `ls -l', this mode can behave like
   2241   Dired on the listed files.  (We omit the output of the `-l' flag from
   2242   this tutorial, as it is too verbose.)
   2243 
   2244   What we now need is to capture the output of `ls -l | sort -t _ -k 2'
   2245   in an Emacs buffer and then enable `dired-virtual-mode'.  To do that,
   2246   we can rely on either `M-x shell' or `M-x eshell' and then manually
   2247   copy the relevant contents.
   2248 
   2249   For the user’s convenience, I share what I have for Eshell to quickly
   2250   capture the last command’s output in a dedicated buffer:
   2251 
   2252   ┌────
   2253   │ (defcustom prot-eshell-output-buffer "*Exported Eshell output*"
   2254   │   "Name of buffer with the last output of Eshell command.
   2255   │ Used by `prot-eshell-export'."
   2256   │   :type 'string
   2257   │   :group 'prot-eshell)
   2258   2259   │ (defcustom prot-eshell-output-delimiter "* * *"
   2260   │   "Delimiter for successive `prot-eshell-export' outputs.
   2261   │ This is formatted internally to have newline characters before
   2262   │ and after it."
   2263   │   :type 'string
   2264   │   :group 'prot-eshell)
   2265   2266   │ (defun prot-eshell--command-prompt-output ()
   2267   │   "Capture last command prompt and its output."
   2268   │   (let ((beg (save-excursion
   2269   │ 	       (goto-char (eshell-beginning-of-input))
   2270   │ 	       (goto-char (point-at-bol)))))
   2271   │     (when (derived-mode-p 'eshell-mode)
   2272   │       (buffer-substring-no-properties beg (eshell-end-of-output)))))
   2273   2274   │ ;;;###autoload
   2275   │ (defun prot-eshell-export ()
   2276   │   "Produce a buffer with output of the last Eshell command.
   2277   │ If `prot-eshell-output-buffer' does not exist, create it.  Else
   2278   │ append to it, while separating multiple outputs with
   2279   │ `prot-eshell-output-delimiter'."
   2280   │   (interactive)
   2281   │   (let ((eshell-output (prot-eshell--command-prompt-output)))
   2282   │     (with-current-buffer (get-buffer-create prot-eshell-output-buffer)
   2283   │       (let ((inhibit-read-only t))
   2284   │ 	(goto-char (point-max))
   2285   │ 	(unless (eq (point-min) (point-max))
   2286   │ 	  (insert (format "\n%s\n\n" prot-eshell-output-delimiter)))
   2287   │ 	(goto-char (point-at-bol))
   2288   │ 	(insert eshell-output)
   2289   │ 	(switch-to-buffer-other-window (current-buffer))))))
   2290   └────
   2291 
   2292   Bind `prot-eshell-export' to a key in the `eshell-mode-map' and give
   2293   it a try (I use `C-c C-e').  In the produced buffer, activate the
   2294   `dired-virtual-mode'.
   2295 
   2296 
   2297 [I want to sort by last modified, why won’t Denote let me?] See section
   2298 19.7
   2299 
   2300 [The file-naming scheme] See section 5
   2301 
   2302 
   2303 11.6 Use Embark to collect minibuffer candidates
   2304 ────────────────────────────────────────────────
   2305 
   2306   `embark' is a remarkable package that lets you perform relevant,
   2307   context-dependent actions using a prefix key (simplifying in the
   2308   interest of brevity).
   2309 
   2310   For our purposes, Embark can be used to produce a Dired listing
   2311   directly from the minibuffer.  Suppose the current note has links to
   2312   three other notes.  You might use the `denote-link-find-file' command
   2313   to pick one via the minibuffer.  But why not turn those three links
   2314   into their own Dired listing?  While in the minibuffer, invoke
   2315   `embark-act' which you may have already bound to `C-.' and then follow
   2316   it up with `E' (for the `embark-export' command).
   2317 
   2318   This pattern can be repeated with any list of candidates, meaning that
   2319   you can narrow the list by providing some input before eventually
   2320   exporting the results with Embark.
   2321 
   2322   Overall, this is very powerful and you might prefer it over doing the
   2323   same thing directly in Dired, since you also benefit from all the
   2324   power of the minibuffer ([Narrow the list of files in Dired]).
   2325 
   2326 
   2327 [Narrow the list of files in Dired] See section 11.4
   2328 
   2329 
   2330 11.7 Search file contents
   2331 ─────────────────────────
   2332 
   2333   Emacs provides built-in commands which are wrappers of standard Unix
   2334   tools: `M-x grep' lets the user input the flags of a `grep' call and
   2335   pass a regular expression to the `-e' flag.
   2336 
   2337   The author of Denote uses this thin wrapper instead:
   2338 
   2339   ┌────
   2340   │ (defvar prot-search--grep-hist '()
   2341   │   "Input history of grep searches.")
   2342   2343   │ ;;;###autoload
   2344   │ (defun prot-search-grep (regexp &optional recursive)
   2345   │   "Run grep for REGEXP.
   2346   2347   │ Search in the current directory using `lgrep'.  With optional
   2348   │ prefix argument (\\[universal-argument]) for RECURSIVE, run a
   2349   │ search starting from the current directory with `rgrep'."
   2350   │   (interactive
   2351   │    (list
   2352   │     (read-from-minibuffer (concat (if current-prefix-arg
   2353   │ 				      (propertize "Recursive" 'face 'warning)
   2354   │ 				    "Local")
   2355   │ 				  " grep for PATTERN: ")
   2356   │ 			  nil nil nil 'prot-search--grep-hist)
   2357   │     current-prefix-arg))
   2358   │   (unless grep-command
   2359   │     (grep-compute-defaults))
   2360   │   (if recursive
   2361   │       (rgrep regexp "*" default-directory)
   2362   │     (lgrep regexp "*" default-directory)))
   2363   └────
   2364 
   2365   Rather than maintain custom code, consider using the excellent
   2366   `consult' package: it provides commands such as `consult-grep' and
   2367   `consult-find' which provide live results and are generally easier to
   2368   use than the built-in commands.
   2369 
   2370 
   2371 11.8 Bookmark the directory with the notes
   2372 ──────────────────────────────────────────
   2373 
   2374   Part of the reason Denote does not reinvent existing functionality is
   2375   to encourage you to learn more about Emacs.  You do not need a bespoke
   2376   “jump to my notes” directory because such commands do not scale well.
   2377   Will you have a “jump to my downloads” then another for multimedia and
   2378   so on?  No.
   2379 
   2380   Emacs has a built-in framework for recording persistent markers to
   2381   locations.  Visit the `denote-directory' (or any dir/file for that
   2382   matter) and invoke the `bookmark-set' command (bound to `C-x r m' by
   2383   default).  It lets you create a bookmark.
   2384 
   2385   The list of bookmarks can be reviewed with the `bookmark-bmenu-list'
   2386   command (bound to `C-x r l' by default).  A minibuffer interface is
   2387   available with `bookmark-jump' (`C-x r b').
   2388 
   2389   If you use the `consult' package, its default `consult-buffer' command
   2390   has the means to group together buffers, recent files, and bookmarks.
   2391   Each of those types can be narrowed to with a prefix key.  The package
   2392   `consult-dir' is an extension to `consult' which provides useful
   2393   extras for working with directories, including bookmarks.
   2394 
   2395 
   2396 11.9 Use the `citar-denote' package for bibliography notes
   2397 ──────────────────────────────────────────────────────────
   2398 
   2399   Peter Prevos has produced the `citar-denote' package which makes it
   2400   possible to write notes on BibTeX entries with the help of the `citar'
   2401   package.  These notes have the citation’s unique key associated with
   2402   them in the file’s front matter.  They also get a configurable keyword
   2403   in their file name, making it easy to find them in Dired and/or
   2404   retrieve them with the various Denote methods.
   2405 
   2406   With `citar-denote', the user leverages standard minibuffer completion
   2407   mechanisms (e.g. with the help of the `vertico' and `embark' packages)
   2408   to manage bibliographic notes and access those notes with ease.  The
   2409   package’s documentation covers the details:
   2410   <https://github.com/pprevos/citar-denote/>.
   2411 
   2412 
   2413 11.10 Use the `consult-notes' package
   2414 ─────────────────────────────────────
   2415 
   2416   If you are already using `consult' (which is a brilliant package), you
   2417   will probably like its `consult-notes' extension.  It uses the
   2418   familiar mechanisms of Consult to filter searches via a prefix key.
   2419   For example:
   2420 
   2421   ┌────
   2422   │ (setq consult-notes-sources
   2423   │       `(("Notes"  ?n ,denote-directory)
   2424   │ 	("Books"  ?b "~/Documents/books")))
   2425   └────
   2426 
   2427   With the above, `M-x consult-notes' will list the files in those two
   2428   directories.  If you type `n' and space, it narrows the list to just
   2429   the notes, while `b' does the same for books.
   2430 
   2431   To search all your notes with grep (or ripgrep if installed – see
   2432   `consult-notes-use-rg' variable) use the command
   2433   `consult-notes-search-in-all-notes'. This will employ grep/ripgrep for
   2434   searching terms in all the directories set in `consult-notes-sources'.
   2435 
   2436   Note that `consult-notes' is in its early stages of development.
   2437   Expect improvements in the near future (written on 2022-06-22 16:48
   2438   +0300).
   2439 
   2440 
   2441 11.11 Treat your notes as a project
   2442 ───────────────────────────────────
   2443 
   2444   Emacs has a built-in library for treating a directory tree as a
   2445   “project”.  This means that the contents of this tree are seen as part
   2446   of the same set, so commands like `project-switch-to-buffer' (`C-x p
   2447   b' by default) will only consider buffers in the current project
   2448   (e.g. three notes that are currently being visited).
   2449 
   2450   Normally, a “project” is a directory tree whose root is under version
   2451   control.  For our purposes, all you need is to navigate to the
   2452   `denote-directory' (for the shell or via Dired) and use the
   2453   command-line to run this (requires the `git' executable):
   2454 
   2455   ┌────
   2456   │ git init
   2457   └────
   2458 
   2459 
   2460   From Dired, you can type `M-!' which invokes
   2461   `dired-smart-shell-command' and then run the git call there.
   2462 
   2463   The project can then be registered by invoking any project-related
   2464   command inside of it, such as `project-find-file' (`C-x p f').
   2465 
   2466   It is a good idea to keep your notes under version control, as that
   2467   gives you a history of changes for each file.  We shall not delve into
   2468   the technicalities here, though suffice to note that Emacs’ built-in
   2469   version control framework or the exceptionally well-crafted `magit'
   2470   package will get the job done (VC can work with other backends besides
   2471   Git).
   2472 
   2473 
   2474 11.12 Variants of `denote-open-or-create'
   2475 ─────────────────────────────────────────
   2476 
   2477   The command `denote-open-or-create' prompts to visit a file in the
   2478   `denote-directory'.  If the user input does not have any matches,
   2479   `denote-open-or-create' will call the `denote' command interactively.
   2480   It will then use whatever prompts `denote' normally has, per the user
   2481   option `denote-prompts' ([Standard note creation]).
   2482 
   2483   To speed up the process or to maintain variants that suit one’s
   2484   workflow, we provide these ready-to-use commands that one can add to
   2485   their Emacs init file.  They can be assigned to key bindings or be
   2486   used via `M-x' after they have been evaluated.
   2487 
   2488   ┌────
   2489   │ ;;;###autoload
   2490   │ (defun denote-open-or-create-with-date ()
   2491   │   "Invoke `denote-open-or-create' but also prompt for date.
   2492   2493   │ The date can be in YEAR-MONTH-DAY notation like 2022-06-30 or
   2494   │ that plus the time: 2022-06-16 14:30.  When the user option
   2495   │ `denote-date-prompt-use-org-read-date' is non-nil, the date
   2496   │ prompt uses the more powerful Org+calendar system.
   2497   2498   │ This is the equivalent to calling `denote-open-or-create' when
   2499   │ `denote-prompts' is set to \\='(date title keywords)."
   2500   │   (declare (interactive-only t))
   2501   │   (interactive)
   2502   │   (let ((denote-prompts '(date title keywords)))
   2503   │     (call-interactively #'denote-open-or-create)))
   2504   2505   │ ;;;###autoload
   2506   │ (defun denote-open-or-create-with-type ()
   2507   │   "Invoke `denote-open-or-create' but also prompt for file type.
   2508   │ This is the equivalent to calling `denote-open-or-create' when
   2509   │ `denote-prompts' is set to \\='(type title keywords)."
   2510   │   (declare (interactive-only t))
   2511   │   (interactive)
   2512   │   (let ((denote-prompts '(type title keywords)))
   2513   │     (call-interactively #'denote-open-or-create)))
   2514   2515   │ ;;;###autoload
   2516   │ (defun denote-open-or-create-with-subdirectory ()
   2517   │   "Invoke `denote-open-or-create' but also prompt for subdirectory.
   2518   │ This is the equivalent to calling `denote-open-or-create' when
   2519   │ `denote-prompts' is set to \\='(subdirectory title keywords)."
   2520   │   (declare (interactive-only t))
   2521   │   (interactive)
   2522   │   (let ((denote-prompts '(subdirectory title keywords)))
   2523   │     (call-interactively #'denote-open-or-create)))
   2524   2525   │ ;;;###autoload
   2526   │ (defun denote-open-or-create-with-template ()
   2527   │   "Invoke `denote-open-or-create' but also prompt for template.
   2528   │ This is the equivalent to calling `denote-open-or-create' when
   2529   │ `denote-prompts' is set to \\='(template title keywords).
   2530   2531   │ For templates, refer to `denote-templates'."
   2532   │   (declare (interactive-only t))
   2533   │   (interactive)
   2534   │   (let ((denote-prompts '(template title keywords)))
   2535   │     (call-interactively #'denote-open-or-create)))
   2536   └────
   2537 
   2538 
   2539 [Standard note creation] See section 3.1
   2540 
   2541 
   2542 11.13 Variants of `denote-link-or-create'
   2543 ─────────────────────────────────────────
   2544 
   2545   The command `denote-link-or-create' uses `denote-link' on a `TARGET'
   2546   file, creating it if necessary.  The `TARGET' matches the user input
   2547   at a minibuffer prompt: it is a file in the `denote-directory'.
   2548 
   2549   If `TARGET' file does not exist, The `denote-link-or-create' calls
   2550   `denote-link-after-creating' which runs the standard `denote' command
   2551   interactively to create the file ([Standard note creation]).  The
   2552   established link will then be targeting that new file.
   2553 
   2554   When called with an optional prefix argument (`C-u' by default)
   2555   `denote-link-or-create' creates a link that consists of just the
   2556   identifier.  Else it tries to also include the file’s title.  This has
   2557   the same meaning as in `denote-link' ([Linking notes]).
   2558 
   2559   To speed up the process or to maintain variants that suit one’s
   2560   workflow, we provide these ready-to-use commands that one can add to
   2561   their Emacs init file.  They can be assigned to key bindings or be
   2562   used via `M-x' after they have been evaluated.
   2563 
   2564   ┌────
   2565   │ ;;;###autoload
   2566   │ (defun denote-link-or-create-with-date ()
   2567   │   "Invoke `denote-link-or-create' but also prompt for date.
   2568   2569   │ The date can be in YEAR-MONTH-DAY notation like 2022-06-30 or
   2570   │ that plus the time: 2022-06-16 14:30.  When the user option
   2571   │ `denote-date-prompt-use-org-read-date' is non-nil, the date
   2572   │ prompt uses the more powerful Org+calendar system.
   2573   2574   │ This is the equivalent to calling `denote-link-or-create' when
   2575   │ `denote-prompts' is set to \\='(date title keywords)."
   2576   │   (declare (interactive-only t))
   2577   │   (interactive)
   2578   │   (let ((denote-prompts '(date title keywords)))
   2579   │     (call-interactively #'denote-link-or-create)))
   2580   2581   │ ;;;###autoload
   2582   │ (defun denote-link-or-create-with-type ()
   2583   │   "Invoke `denote-link-or-create' but also prompt for file type.
   2584   │ This is the equivalent to calling `denote-link-or-create' when
   2585   │ `denote-prompts' is set to \\='(type title keywords)."
   2586   │   (declare (interactive-only t))
   2587   │   (interactive)
   2588   │   (let ((denote-prompts '(type title keywords)))
   2589   │     (call-interactively #'denote-link-or-create)))
   2590   2591   │ ;;;###autoload
   2592   │ (defun denote-link-or-create-with-subdirectory ()
   2593   │   "Invoke `denote-link-or-create' but also prompt for subdirectory.
   2594   │ This is the equivalent to calling `denote-link-or-create' when
   2595   │ `denote-prompts' is set to \\='(subdirectory title keywords)."
   2596   │   (declare (interactive-only t))
   2597   │   (interactive)
   2598   │   (let ((denote-prompts '(subdirectory title keywords)))
   2599   │     (call-interactively #'denote-link-or-create)))
   2600   2601   │ ;;;###autoload
   2602   │ (defun denote-link-or-create-with-template ()
   2603   │   "Invoke `denote-link-or-create' but also prompt for template.
   2604   │ This is the equivalent to calling `denote-link-or-create' when
   2605   │ `denote-prompts' is set to \\='(template title keywords).
   2606   2607   │ For templates, refer to `denote-templates'."
   2608   │   (declare (interactive-only t))
   2609   │   (interactive)
   2610   │   (let ((denote-prompts '(template title keywords)))
   2611   │     (call-interactively #'denote-link-or-create)))
   2612   └────
   2613 
   2614 
   2615 [Standard note creation] See section 3.1
   2616 
   2617 [Linking notes] See section 7
   2618 
   2619 
   2620 12 Installation
   2621 ═══════════════
   2622 
   2623 
   2624 
   2625 
   2626 12.1 GNU ELPA package
   2627 ─────────────────────
   2628 
   2629   The package is available as `denote'.  Simply do:
   2630 
   2631   ┌────
   2632   │ M-x package-refresh-contents
   2633   │ M-x package-install
   2634   └────
   2635 
   2636 
   2637   And search for it.
   2638 
   2639   GNU ELPA provides the latest stable release.  Those who prefer to
   2640   follow the development process in order to report bugs or suggest
   2641   changes, can use the version of the package from the GNU-devel ELPA
   2642   archive.  Read:
   2643   <https://protesilaos.com/codelog/2022-05-13-emacs-elpa-devel/>.
   2644 
   2645 
   2646 12.2 Manual installation
   2647 ────────────────────────
   2648 
   2649   Assuming your Emacs files are found in `~/.emacs.d/', execute the
   2650   following commands in a shell prompt:
   2651 
   2652   ┌────
   2653   │ cd ~/.emacs.d
   2654   2655   │ # Create a directory for manually-installed packages
   2656   │ mkdir manual-packages
   2657   2658   │ # Go to the new directory
   2659   │ cd manual-packages
   2660   2661   │ # Clone this repo, naming it "denote"
   2662   │ git clone https://git.sr.ht/~protesilaos/denote denote
   2663   └────
   2664 
   2665   Finally, in your `init.el' (or equivalent) evaluate this:
   2666 
   2667   ┌────
   2668   │ ;; Make Elisp files in that directory available to the user.
   2669   │ (add-to-list 'load-path "~/.emacs.d/manual-packages/denote")
   2670   └────
   2671 
   2672   Everything is in place to set up the package.
   2673 
   2674 
   2675 13 Sample configuration
   2676 ═══════════════════════
   2677 
   2678   ┌────
   2679   │ (require 'denote)
   2680   2681   │ ;; Remember to check the doc strings of those variables.
   2682   │ (setq denote-directory (expand-file-name "~/Documents/notes/"))
   2683   │ (setq denote-known-keywords '("emacs" "philosophy" "politics" "economics"))
   2684   │ (setq denote-infer-keywords t)
   2685   │ (setq denote-sort-keywords t)
   2686   │ (setq denote-file-type nil) ; Org is the default, set others here
   2687   │ (setq denote-prompts '(title keywords))
   2688   │ (setq denote-excluded-directories-regexp nil)
   2689   │ (setq denote-excluded-keywords-regexp nil)
   2690   2691   │ ;; Pick dates, where relevant, with Org's advanced interface:
   2692   │ (setq denote-date-prompt-use-org-read-date t)
   2693   2694   2695   │ ;; Read this manual for how to specify `denote-templates'.  We do not
   2696   │ ;; include an example here to avoid potential confusion.
   2697   2698   2699   │ ;; We allow multi-word keywords by default.  The author's personal
   2700   │ ;; preference is for single-word keywords for a more rigid workflow.
   2701   │ (setq denote-allow-multi-word-keywords t)
   2702   2703   │ (setq denote-date-format nil) ; read doc string
   2704   2705   │ ;; By default, we do not show the context of links.  We just display
   2706   │ ;; file names.  This provides a more informative view.
   2707   │ (setq denote-backlinks-show-context t)
   2708   2709   │ ;; Also see `denote-link-backlinks-display-buffer-action' which is a bit
   2710   │ ;; advanced.
   2711   2712   │ ;; If you use Markdown or plain text files (Org renders links as buttons
   2713   │ ;; right away)
   2714   │ (add-hook 'find-file-hook #'denote-link-buttonize-buffer)
   2715   2716   │ ;; We use different ways to specify a path for demo purposes.
   2717   │ (setq denote-dired-directories
   2718   │       (list denote-directory
   2719   │ 	    (thread-last denote-directory (expand-file-name "attachments"))
   2720   │ 	    (expand-file-name "~/Documents/books")))
   2721   2722   │ ;; Generic (great if you rename files Denote-style in lots of places):
   2723   │ ;; (add-hook 'dired-mode-hook #'denote-dired-mode)
   2724   │ ;;
   2725   │ ;; OR if only want it in `denote-dired-directories':
   2726   │ (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
   2727   2728   │ ;; Here is a custom, user-level command from one of the examples we
   2729   │ ;; showed in this manual.  We define it here and add it to a key binding
   2730   │ ;; below.
   2731   │ (defun my-denote-journal ()
   2732   │   "Create an entry tagged 'journal', while prompting for a title."
   2733   │   (interactive)
   2734   │   (denote
   2735   │    (denote--title-prompt)
   2736   │    '("journal")))
   2737   2738   │ ;; Denote DOES NOT define any key bindings.  This is for the user to
   2739   │ ;; decide.  For example:
   2740   │ (let ((map global-map))
   2741   │   (define-key map (kbd "C-c n j") #'my-denote-journal) ; our custom command
   2742   │   (define-key map (kbd "C-c n n") #'denote)
   2743   │   (define-key map (kbd "C-c n N") #'denote-type)
   2744   │   (define-key map (kbd "C-c n d") #'denote-date)
   2745   │   (define-key map (kbd "C-c n s") #'denote-subdirectory)
   2746   │   (define-key map (kbd "C-c n t") #'denote-template)
   2747   │   ;; If you intend to use Denote with a variety of file types, it is
   2748   │   ;; easier to bind the link-related commands to the `global-map', as
   2749   │   ;; shown here.  Otherwise follow the same pattern for `org-mode-map',
   2750   │   ;; `markdown-mode-map', and/or `text-mode-map'.
   2751   │   (define-key map (kbd "C-c n i") #'denote-link) ; "insert" mnemonic
   2752   │   (define-key map (kbd "C-c n I") #'denote-link-add-links)
   2753   │   (define-key map (kbd "C-c n b") #'denote-link-backlinks)
   2754   │   (define-key map (kbd "C-c n f f") #'denote-link-find-file)
   2755   │   (define-key map (kbd "C-c n f b") #'denote-link-find-backlink)
   2756   │   ;; Note that `denote-rename-file' can work from any context, not just
   2757   │   ;; Dired bufffers.  That is why we bind it here to the `global-map'.
   2758   │   (define-key map (kbd "C-c n r") #'denote-rename-file)
   2759   │   (define-key map (kbd "C-c n R") #'denote-rename-file-using-front-matter))
   2760   2761   │ ;; Key bindings specifically for Dired.
   2762   │ (let ((map dired-mode-map))
   2763   │   (define-key map (kbd "C-c C-d C-i") #'denote-link-dired-marked-notes)
   2764   │   (define-key map (kbd "C-c C-d C-r") #'denote-dired-rename-marked-files)
   2765   │   (define-key map (kbd "C-c C-d C-R") #'denote-dired-rename-marked-files-using-front-matter))
   2766   2767   │ (with-eval-after-load 'org-capture
   2768   │   (setq denote-org-capture-specifiers "%l\n%i\n%?")
   2769   │   (add-to-list 'org-capture-templates
   2770   │ 	       '("n" "New note (with denote.el)" plain
   2771   │ 		 (file denote-last-path)
   2772   │ 		 #'denote-org-capture
   2773   │ 		 :no-save t
   2774   │ 		 :immediate-finish nil
   2775   │ 		 :kill-buffer t
   2776   │ 		 :jump-to-captured t)))
   2777   2778   │ ;; Also check the commands `denote-link-after-creating',
   2779   │ ;; `denote-link-or-create'.  You may want to bind them to keys as well.
   2780   └────
   2781 
   2782 
   2783 14 For developers or advanced users
   2784 ═══════════════════════════════════
   2785 
   2786   Denote is in a stable state and can be relied upon as the basis for
   2787   custom extensions.  Further below is a list with the functions or
   2788   variables we provide for public usage.  Those are in addition to all
   2789   user options and commands that are already documented in the various
   2790   sections of this manual.
   2791 
   2792   In this context “public” is any form with single hyphens in its
   2793   symbol, such as `denote-directory-files'.  We expressly support those,
   2794   meaning that we consider them reliable and commit to documenting any
   2795   changes in their particularities (such as through `make-obsolete', a
   2796   record in the change log, a blog post on the maintainer’s website, and
   2797   the like).
   2798 
   2799   By contradistinction, a “private” form is declared with two hyphens in
   2800   its symbol such as `denote--file-extension'.  Do not use those as we
   2801   might change them without further notice.
   2802 
   2803   Variable `denote-id-format'
   2804         Format of ID prefix of a note’s filename.  The note’s ID is
   2805         derived from the date and time of its creation ([The file-naming
   2806         scheme]).
   2807 
   2808   Variable `denote-id-regexp'
   2809         Regular expression to match `denote-id-format'.
   2810 
   2811   Variable `denote-title-regexp'
   2812         Regular expression to match the TITLE field in a file name ([The
   2813         file-naming scheme]).
   2814 
   2815   Variable `denote-keywords-regexp'
   2816         Regular expression to match the KEYWORDS field in a file name
   2817         ([The file-naming scheme]).
   2818 
   2819   Variable `denote-excluded-punctuation-regexp'
   2820         Punctionation that is removed from file names.  We consider
   2821         those characters illegal for our purposes.
   2822 
   2823   Variable `denote-excluded-punctuation-extra-regexp'
   2824         Additional punctuation that is removed from file names.  This
   2825         variable is for advanced users who need to extend the
   2826         `denote-excluded-punctuation-regexp'.  Once we have a better
   2827         understanding of what we should be omitting, we will update
   2828         things accordingly.
   2829 
   2830   Function `denote-file-is-note-p'
   2831         Return non-nil if `FILE' is an actual Denote note.  For our
   2832         purposes, a note must not be a directory, must satisfy
   2833         `file-regular-p', its path must be part of the variable
   2834         `denote-directory', it must have a Denote identifier in its
   2835         name, and use one of the extensions implied by
   2836         `denote-file-type'.
   2837 
   2838   Function `denote-file-has-identifier-p'
   2839         Return non-nil if `FILE' has a Denote identifier.
   2840 
   2841   Function `denote-file-has-supported-extension-p'
   2842         Return non-nil if `FILE' has supported extension.  Also account
   2843         for the possibility of an added `.gpg' suffix. Supported
   2844         extensions are those implied by `denote-file-type'.
   2845 
   2846   Function `denote-file-is-writable-and-supported-p'
   2847         Return non-nil if `FILE' is writable and has supported
   2848         extension.
   2849 
   2850   Function `denote-keywords'
   2851         Return appropriate list of keyword candidates.  If
   2852         `denote-infer-keywords' is non-nil, infer keywords from existing
   2853         notes and combine them into a list with `denote-known-keywords'.
   2854         Else use only the latter set of keywords ([Standard note
   2855         creation]).
   2856 
   2857   Function `denote-keywords-sort'
   2858         Sort `KEYWORDS' if `denote-sort-keywords' is non-nil.
   2859         `KEYWORDS' is a list of strings, per `denote-keywords-prompt'.
   2860 
   2861   Function `denote-directory'
   2862         Return path of the variable `denote-directory' as a proper
   2863         directory, also because it accepts a directory-local value for
   2864         what we internally refer to as “silos” ([Maintain separate
   2865         directories for notes]).
   2866 
   2867   Function `denote-directory-files'
   2868         Return list of absolute file paths in variable
   2869         `denote-directory'.  Files only need to have an identifier.  The
   2870         return value may thus include file types that are not implied by
   2871         `denote-file-type'. To limit the return value to text files, use
   2872         the function `denote-directory-text-only-files'.  Remember that
   2873         the `denote-directory' accepts a directory-local value
   2874         ([Maintain separate directories for notes]).
   2875 
   2876   Function `denote-directory-text-only-files'
   2877         Return list of text files in variable `denote-directory'.
   2878         Filter `denote-directory-files' using `denote-file-is-note-p'.
   2879 
   2880   Function `denote-directory-subdirectories'
   2881         Return list of subdirectories in variable
   2882         `denote-directory'. Omit dotfiles (such as .git)
   2883         unconditionally.  Also exclude whatever matches
   2884         `denote-excluded-directories-regexp'.  Note that the
   2885         `denote-directory' accepts a directory-local value for what we
   2886         call “silos” ([Maintain separate directories for notes]).
   2887 
   2888   Function `denote-directory-files-matching-regexp'
   2889         Return list of files matching `REGEXP' in
   2890         `denote-directory-files'.
   2891 
   2892   Function `denote-file-name-relative-to-denote-directory'
   2893         Return name of `FILE' relative to the variable
   2894         `denote-directory'.  `FILE' must be an absolute path.
   2895 
   2896   Function `denote-get-path-by-id'
   2897         Return absolute path of `ID' string in `denote-directory-files'.
   2898 
   2899   Function `denote-barf-duplicate-id'
   2900         Throw a `user-error' if `IDENTIFIER' already exists.
   2901 
   2902   Function `denote-sluggify'
   2903         Make `STR' an appropriate slug for file names and related
   2904         ([Sluggified title and keywords]).
   2905 
   2906   Function `denote-sluggify-and-join'
   2907         Sluggify `STR' while joining separate words.
   2908 
   2909   Function `denote-desluggify'
   2910         Upcase first char in `STR' and dehyphenate `STR', inverting
   2911         `denote-sluggify'.  Basically, convert `this-is-a-test' to `This
   2912         is a test'.
   2913 
   2914   Function `denote-sluggify-keywords'
   2915         Sluggify `KEYWORDS', which is a list of strings ([Sluggified
   2916         title and keywords]).
   2917 
   2918   Function `denote-filetype-heuristics'
   2919         Return likely file type of `FILE'.  Use the file extension to
   2920         detect the file type of the file.
   2921 
   2922         If more than one file type correspond to this file extension,
   2923         use the first file type for which the key-title-kegexp matches
   2924         in the file or, if none matches, use the first type with this
   2925         file extension in `denote-file-type'.
   2926 
   2927         If no file types in `denote-file-types' has the file extension,
   2928         the file type is assumed to be the first of `denote-file-types'.
   2929 
   2930   Function `denote-format-file-name'
   2931         Format file name.  `PATH', `ID', `KEYWORDS', `TITLE-SLUG' are
   2932         expected to be supplied by `denote' or equivalent: they will all
   2933         be converted into a single string.  `EXTENSION' is the file type
   2934         extension, as a string.
   2935 
   2936   Function `denote-extract-keywords-from-path'
   2937         Extract keywords from `PATH' and return them as a list of
   2938         strings.  `PATH' must be a Denote-style file name where keywords
   2939         are prefixed with an underscore.  If `PATH' has no such
   2940         keywords, which is possible, return nil ([The file-naming
   2941         scheme]).
   2942 
   2943   Function `denote-extract-id-from-string'
   2944         Return existing Denote identifier in `STRING', else nil.
   2945 
   2946   Function `denote-retrieve-filename-identifier'
   2947         Extract identifier from `FILE' name.  To return an existing
   2948         identifier or create a new one, refer to the
   2949         `denote-retrieve-or-create-file-identifier' function.
   2950 
   2951   Function `denote-retrieve-or-create-file-identifier'
   2952         Return `FILE' identifier, generating one if appropriate.  The
   2953         conditions are as follows:
   2954 
   2955         • If `FILE' has an identifier, return it.
   2956 
   2957         • If `FILE' does not have an identifier and optional `DATE' is
   2958           non-nil, invoke `denote-prompt-for-date-return-id'.
   2959 
   2960         • If `FILE' does not have an identifier and DATE is nil, use the
   2961           file attributes to determine the last modified date and format
   2962           it as an identifier.
   2963 
   2964         • As a fallback, derive an identifier from the current time.
   2965 
   2966         To only return an existing identifier, refer to the function
   2967         `denote-retrieve-filename-identifier'.
   2968 
   2969   Function `denote-retrieve-filename-title'
   2970         Extract title from `FILE' name, else return `file-name-base'.
   2971         Run `denote-desluggify' on the title if the extraction is
   2972         successful.
   2973 
   2974   Function `denote-retrieve-title-value'
   2975         Return title value from `FILE' front matter per `FILE-TYPE'.
   2976 
   2977   Function `denote-retrieve-title-line'
   2978         Return title line from `FILE' front matter per `FILE-TYPE'.
   2979 
   2980   Function `denote-retrieve-keywords-value'
   2981         Return keywords value from `FILE' front matter per `FILE-TYPE'.
   2982 
   2983   Function `denote-retrieve-keywords-line'
   2984         Return keywords line from `FILE' front matter per `FILE-TYPE'.
   2985 
   2986   Function `denote-file-prompt'
   2987         Prompt for file with identifier in variable `denote-directory'.
   2988         With optional `INITIAL-TEXT', use it to prepopulate the
   2989         minibuffer.
   2990 
   2991   Function `denote-keywords-prompt'
   2992         Prompt for one or more keywords.  In the case of multiple
   2993         entries, those are separated by the `crm-sepator', which
   2994         typically is a comma.  In such a scenario, the output is sorted
   2995         with `string-lessp'.  To sort the return value, use
   2996         `denote-keywords-sort'.
   2997 
   2998   Function `denote-title-prompt'
   2999         Read file title for `denote'.  With optional `DEFAULT-TITLE' use
   3000         it as the default value.
   3001 
   3002   Function `denote-file-type-prompt'
   3003         Prompt for `denote-file-type'.  Note that a non-nil value other
   3004         than `text', `markdown-yaml', and `markdown-toml' falls back to
   3005         an Org file type.  We use `org' here for clarity.
   3006 
   3007   Function `denote-date-prompt'
   3008         Prompt for date, expecting `YYYY-MM-DD' or that plus `HH:MM' (or
   3009         even `HH:MM:SS').  Use Org’s more advanced date selection
   3010         utility if the user option
   3011         `denote-date-prompt-use-org-read-date' is non-nil.  It requires
   3012         Org ([The denote-date-prompt-use-org-read-date option]).
   3013 
   3014   Function `denote-prompt-for-date-return-id'
   3015         Use `denote-date-prompt' and return it as `denote-id-format'.
   3016 
   3017   Function `denote-template-prompt'
   3018         Prompt for template key in `denote-templates' and return its
   3019         value.
   3020 
   3021   Function `denote-subdirectory-prompt'
   3022         Prompt for subdirectory of the variable `denote-directory'.  The
   3023         table uses the `file' completion category (so it works with
   3024         packages such as `marginalia' and `embark').
   3025 
   3026   Function `denote-rename-file-prompt'
   3027         Prompt to rename file named `OLD-NAME' to `NEW-NAME'.
   3028 
   3029   Function `denote-rename-file-and-buffer'
   3030         Rename file named `OLD-NAME' to `NEW-NAME', updating buffer
   3031         name.
   3032 
   3033   Function `denote-update-dired-buffers'
   3034         Update Dired buffers of variable `denote-directory'.  Note that
   3035         the `denote-directory' accepts a directory-local value for what
   3036         we internally refer to as “silos” ([Maintain separate
   3037         directories for notes]).
   3038 
   3039   Variable `denote-file-types'
   3040         Alist of `denote-file-type' and their format properties.
   3041 
   3042         Each element is of the form `(SYMBOL PROPERTY-LIST)'.  `SYMBOL'
   3043         is one of those specified in `denote-file-type' or an arbitrary
   3044         symbol that defines a new file type.
   3045 
   3046         `PROPERTY-LIST' is a plist that consists of eight elements:
   3047 
   3048         1. `:extension' is a string with the file extension including
   3049            the period.
   3050 
   3051         2. `:date-function' is a function that can format a date.  See
   3052            the functions `denote--date-iso-8601',
   3053            `denote--date-rfc3339', and `denote--date-org-timestamp'.
   3054 
   3055         3. `:front-matter' is either a string passed to `format' or a
   3056            variable holding such a string.  The `format' function
   3057            accepts four arguments, which come from `denote' in this
   3058            order: `TITLE', `DATE', `KEYWORDS', `IDENTIFIER'.  Read the
   3059            doc string of `format' on how to reorder arguments.
   3060 
   3061         4. `:title-key-regexp' is a regular expression that is used to
   3062            retrieve the title line in a file.  The first line matching
   3063            this regexp is considered the title line.
   3064 
   3065         5. `:title-value-function' is the function used to format the
   3066            raw title string for inclusion in the front matter (e.g. to
   3067            surround it with quotes).  Use the `identity' function if no
   3068            further processing is required.
   3069 
   3070         6. `:title-value-reverse-function' is the function used to
   3071            retrieve the raw title string from the front matter.  It
   3072            performs the reverse of `:title-value-function'.
   3073 
   3074         7. `:keywords-key-regexp' is a regular expression used to
   3075            retrieve the keywords’ line in the file.  The first line
   3076            matching this regexp is considered the keywords’ line.
   3077 
   3078         8. `:keywords-value-function' is the function used to format the
   3079            keywords’ list of strings as a single string, with
   3080            appropriate delimiters, for inclusion in the front matter.
   3081 
   3082         9. `:keywords-value-reverse-function' is the function used to
   3083            retrieve the keywords’ value from the front matter.  It
   3084            performs the reverse of the `:keywords-value-function'.
   3085 
   3086         10. `:link' is a string, or variable holding a string, that
   3087             specifies the format of a link.  See the variables
   3088             `denote-org-link-format', `denote-md-link-format'.
   3089 
   3090         11. `:link-in-context-regexp' is a regular expression that is
   3091             used to match the aforementioned link format.  See the
   3092             variables `denote-org-link-in-context-regexp',
   3093             `denote-md-link-in-context-regexp'.
   3094 
   3095         If `denote-file-type' is nil, use the first element of this list
   3096         for new note creation.  The default is `org'.
   3097 
   3098   Variable `denote-org-front-matter'
   3099         Specifies the Org front matter.  It is passed to `format' with
   3100         arguments `TITLE', `DATE', `KEYWORDS', `ID' ([Change the front
   3101         matter format])
   3102 
   3103   Variable `denote-yaml-front-matter'
   3104         Specifies the YAML (Markdown) front matter.  It is passed to
   3105         `format' with arguments `TITLE', `DATE', `KEYWORDS', `ID'
   3106         ([Change the front matter format])
   3107 
   3108   Variable `denote-toml-front-matter'
   3109         Specifies the TOML (Markdown) front matter.  It is passed to
   3110         `format' with arguments `TITLE', `DATE', `KEYWORDS', `ID'
   3111         ([Change the front matter format])
   3112 
   3113   Variable `denote-text-front-matter'
   3114         Specifies the plain text front matter.  It is passed to `format'
   3115         with arguments `TITLE', `DATE', `KEYWORDS', `ID' ([Change the
   3116         front matter format])
   3117 
   3118   Variable `denote-org-link-format'
   3119         Format of Org link to note.  The value is passed to `format'
   3120         with `IDENTIFIER' and `TITLE' arguments, in this order.  Also
   3121         see `denote-org-link-in-context-regexp'.
   3122 
   3123   Variable `denote-md-link-format'
   3124         Format of Markdown link to note.  The `%N$s' notation used in
   3125         the default value is for `format' as the supplied arguments are
   3126         `IDENTIFIER' and `TITLE', in this order.  Also see
   3127         `denote-md-link-in-context-regexp'.
   3128 
   3129   Variable `denote-id-only-link-format'
   3130         Format of identifier-only link to note.  The value is passed to
   3131         `format' with `IDENTIFIER' as its sole argument.  Also see
   3132         `denote-id-only-link-in-context-regexp'.
   3133 
   3134   Variable `denote-org-link-in-context-regexp'
   3135         Regexp to match an Org link in its context.  The format of such
   3136         links is `denote-org-link-format'.
   3137 
   3138   Variable `denote-md-link-in-context-regexp'
   3139         Regexp to match an Markdown link in its context.  The format of
   3140         such links is `denote-md-link-format'.
   3141 
   3142   Variable `denote-id-only-link-in-context-regexp'
   3143         Regexp to match an identifier-only link in its context.  The
   3144         format of such links is `denote-id-only-link-format'.
   3145 
   3146   Function `denote-surround-with-quotes'
   3147         Surround string `S' with quotes.  This can be used in
   3148         `denote-file-types' to format front mattter.
   3149 
   3150   Function `denote-date-org-timestamp'
   3151         Format `DATE' using the Org inactive timestamp notation.
   3152 
   3153   Function `denote-date-rfc3339'
   3154         Format `DATE' using the RFC3339 specification.
   3155 
   3156   Function `denote-date-iso-8601'
   3157         Format `DATE' according to ISO 8601 standard.
   3158 
   3159   Function `denote-trim-whitespace'
   3160         Trim whitespace around string `S'.  This can be used in
   3161         `denote-file-types' to format front mattter.
   3162 
   3163   Function `denote-trim-whitespace-then-quotes'
   3164         Trim whitespace then quotes around string `S'.  This can be used
   3165         in `denote-file-types' to format front mattter.
   3166 
   3167   Function `denote-format-keywords-for-md-front-matter'
   3168         Format front matter `KEYWORDS' for markdown file type.
   3169         `KEYWORDS' is a list of strings.  Consult the
   3170         `denote-file-types' for how this is used.
   3171 
   3172   Function `denote-format-keywords-for-text-front-matter'
   3173         Format front matter `KEYWORDS' for text file type.  `KEYWORDS'
   3174         is a list of strings.  Consult the `denote-file-types' for how
   3175         this is used.
   3176 
   3177   Function `denote-format-keywords-for-org-front-matter'
   3178         Format front matter `KEYWORDS' for org file type.  `KEYWORDS' is
   3179         a list of strings.  Consult the `denote-file-types' for how this
   3180         is used.
   3181 
   3182   Function `denote-extract-keywords-from-front-matter'
   3183         Format front matter `KEYWORDS' for org file type.  `KEYWORDS' is
   3184         a list of strings.  Consult the `denote-file-types' for how this
   3185         is used.
   3186 
   3187 
   3188 [The file-naming scheme] See section 5
   3189 
   3190 [Standard note creation] See section 3.1
   3191 
   3192 [Maintain separate directories for notes] See section 3.3
   3193 
   3194 [Sluggified title and keywords] See section 5.1
   3195 
   3196 [The denote-date-prompt-use-org-read-date option] See section 3.1.4
   3197 
   3198 [Change the front matter format] See section 6.1
   3199 
   3200 
   3201 15 Contributing
   3202 ═══════════════
   3203 
   3204   Denote is a GNU ELPA package.  As such, any significant change to the
   3205   code requires copyright assignment to the Free Software Foundation
   3206   (more below).
   3207 
   3208   You do not need to be a programmer to contribute to this package.
   3209   Sharing an idea or describing a workflow is equally helpful, as it
   3210   teaches us something we may not know and might be able to cover either
   3211   by extending Denote or expanding this manual ([Things to do]).  If you
   3212   prefer to write a blog post, make sure you share it with us: we can
   3213   add a section herein referencing all such articles.  Everyone gets
   3214   acknowledged ([Acknowledgements]).  There is no such thing as an
   3215   “insignificant contribution”—they all matter.
   3216 
   3217   ⁃ Package name (GNU ELPA): `denote'
   3218   ⁃ Official manual: <https://protesilaos.com/emacs/denote>
   3219   ⁃ Change log: <https://protesilaos.com/emacs/denote-changelog>
   3220   ⁃ Git repo on SourceHut: <https://git.sr.ht/~protesilaos/denote>
   3221     • Mirrors:
   3222       ⁃ GitHub: <https://github.com/protesilaos/denote>
   3223       ⁃ GitLab: <https://gitlab.com/protesilaos/denote>
   3224   ⁃ Mailing list: <https://lists.sr.ht/~protesilaos/denote>
   3225 
   3226   If our public media are not suitable, you are welcome to contact me
   3227   (Protesilaos) in private: <https://protesilaos.com/contact>.
   3228 
   3229   Copyright assignment is a prerequisite to sharing code.  It is a
   3230   simple process.  Check the request form below (please adapt it
   3231   accordingly).  You must write an email to the address mentioned in the
   3232   form and then wait for the FSF to send you a legal agreement.  Sign
   3233   the document and file it back to them.  This could all happen via
   3234   email and take about a week.  You are encouraged to go through this
   3235   process.  You only need to do it once.  It will allow you to make
   3236   contributions to Emacs in general.
   3237 
   3238   ┌────
   3239   │ Please email the following information to assign@gnu.org, and we
   3240   │ will send you the assignment form for your past and future changes.
   3241   3242   │ Please use your full legal name (in ASCII characters) as the subject
   3243   │ line of the message.
   3244   3245   │ REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
   3246   3247   │ [What is the name of the program or package you're contributing to?]
   3248   3249   │ GNU Emacs
   3250   3251   │ [Did you copy any files or text written by someone else in these changes?
   3252   │ Even if that material is free software, we need to know about it.]
   3253   3254   │ Copied a few snippets from the same files I edited.  Their author,
   3255   │ Protesilaos Stavrou, has already assigned copyright to the Free Software
   3256   │ Foundation.
   3257   3258   │ [Do you have an employer who might have a basis to claim to own
   3259   │ your changes?  Do you attend a school which might make such a claim?]
   3260   3261   3262   │ [For the copyright registration, what country are you a citizen of?]
   3263   3264   3265   │ [What year were you born?]
   3266   3267   3268   │ [Please write your email address here.]
   3269   3270   3271   │ [Please write your postal address here.]
   3272   3273   3274   3275   3276   3277   │ [Which files have you changed so far, and which new files have you written
   3278   │ so far?]
   3279   3280   └────
   3281 
   3282 
   3283 [Things to do] See section 16
   3284 
   3285 [Acknowledgements] See section 20
   3286 
   3287 
   3288 16 Things to do
   3289 ═══════════════
   3290 
   3291   Denote should work well for what is described in this manual.  Though
   3292   we can always do better.  This is a non-exhaustive list with some
   3293   low-priority ideas you may want to help with ([Contributing]).
   3294 
   3295   • Support mutually-exclusive sets of tags.  For example, a `home'
   3296     keyword would preclude `work'.  Personally, I am not a fan of such
   3297     arrangements as there may be a case where something applies to both
   3298     ends of this prefigured binary.  Though we can think about it.
   3299 
   3300   • Add command that expands the identifier in links to a full file
   3301     name.  This would be useful for some sort of “export” operation
   3302     where the absolute file path is necessary and where the Denote
   3303     linking mechanism is not available.  Though this could be handled by
   3304     the exporter, by doing something like what `denote-link-find-file'
   3305     does.
   3306 
   3307   • Add command that rewrites full names in links, if they are invalid.
   3308     This would complement the renaming mechanism.  Personally, I think
   3309     old titles in links are not a problem, because they show you what
   3310     was true at the time and are usually relevant to their context.
   3311     Again though, it is an option worth exploring.
   3312 
   3313   • Ensure integration between `denote:' links and the `embark' package.
   3314     The idea is to allow Embark to understand the Denote buttons are
   3315     links to files and correctly infer the absolute path.  I am not sure
   3316     what a user would want to do with this, but maybe there are some
   3317     interesting possibilities.
   3318 
   3319   You are welcome to suggest more ideas.  If they do not broaden the
   3320   scope of Denote, they can be added to denote.el.  Otherwise we might
   3321   think of extensions to the core package.
   3322 
   3323 
   3324 [Contributing] See section 15
   3325 
   3326 
   3327 17 Publications about Denote
   3328 ════════════════════════════
   3329 
   3330   The Emacs community is putting Denote to great use.  This section
   3331   includes publications that show how people configure their note-taking
   3332   setup.  If you have a blog post, video, or configuration file about
   3333   Denote, feel welcome to tell us about it ([Contributing]).
   3334 
   3335   ⁃ David Wilson (SystemCrafters): /Generating a Blog Site from Denote
   3336     Entries/, 2022-09-09, <https://www.youtube.com/watch?v=5R7ad5xz5wo>.
   3337 
   3338   ⁃ David Wilson (SystemCrafters): /Trying Out Prot’s Denote, an Org
   3339     Roam Alternative?/, 2022-07-15,
   3340     <https://www.youtube.com/watch?v=QcRY_rsX0yY>.
   3341 
   3342   ⁃ Jack Baty: /Keeping my Org Agenda updated based on Denote keywords/,
   3343     2022-11-30, <https://baty.net/2022/keeping-my-org-agenda-updated>.
   3344 
   3345   ⁃ Jeremy Friesen: /Denote Emacs Configuration/, 2022-10-02,
   3346     <https://takeonrules.com/2022/10/09/denote-emacs-configuration/>
   3347 
   3348   ⁃ Jeremy Friesen: /Exploring the Denote Emacs Package/, 2022-10-01,
   3349     <https://takeonrules.com/2022/10/01/exploring-the-denote-emacs-package/>
   3350 
   3351   ⁃ Jeremy Friesen: /Migration Plan for Org-Roam Notes to Denote/,
   3352     2022-10-02,
   3353     <https://takeonrules.com/2022/10/02/migration-plan-for-org-roam-notes-to-denote/>
   3354 
   3355   ⁃ Jeremy Friesen: /Project Dispatch Menu with Org Mode Metadata,
   3356     Denote, and Transient/, 2022-11-19,
   3357     <https://takeonrules.com/2022/11/19/project-dispatch-menu-with-org-mode-metadata-denote-and-transient/>
   3358 
   3359   ⁃ Peter Prevos: /Simulating Text Files with R to Test the Emacs Denote
   3360     Package/, 2022-07-28,
   3361     <https://lucidmanager.org/productivity/testing-denote-package/>.
   3362 
   3363 
   3364 [Contributing] See section 15
   3365 
   3366 
   3367 18 Alternatives to Denote
   3368 ═════════════════════════
   3369 
   3370   What follows is a list of Emacs packages for note-taking.  I
   3371   (Protesilaos) have not used any of them, as I was manually applying my
   3372   file-naming scheme beforehand and by the time those packages were
   3373   available I was already hacking on the predecessor of Denote as a
   3374   means of learning Emacs Lisp (a package which I called “Unassuming
   3375   Sidenotes of Little Significance”, aka “USLS” which is pronounced as
   3376   “U-S-L-S” or “useless”).  As such, I cannot comment at length on the
   3377   differences between Denote and each of those packages, beside what I
   3378   gather from their documentation.
   3379 
   3380   [org-roam]
   3381         The de facto standard in the Emacs milieu—and rightly so!  It
   3382         has a massive community, is featureful, and should be an
   3383         excellent companion to anyone who is invested in the Org
   3384         ecosystem and/or knows what “Roam” is (I don’t).  It has been
   3385         explained to me that Org Roam uses a database to store a cache
   3386         about your notes.  It otherwise uses standard Org files.  The
   3387         cache helps refer to the same node through aliases which can
   3388         provide lots of options.  Personally, I follow a
   3389         single-topic-per-note approach, so anything beyond that is
   3390         overkill.  If the database is only for a cache, then maybe that
   3391         has no downside, though I am careful with any kind of
   3392         specialised program as it creates a dependency.  If you ask me
   3393         about database software in particular, I have no idea how to use
   3394         one, let alone debug it or retrieve data from it if something
   3395         goes awry (I could learn, but that is beside the point).
   3396 
   3397   [zk (or zk.el)]
   3398         Reading its documentation makes me think that this is Denote’s
   3399         sibling—the two projects have a lot of things in common,
   3400         including the preference to rely on plain files and standard
   3401         tools.  The core difference is that Denote has a strict
   3402         file-naming scheme.  Other differences in available features
   3403         are, in principle, matters of style or circumstance: both
   3404         packages can have them.  As its initials imply, ZK enables a
   3405         zettelkasten-like workflow.  It does not enforce it though,
   3406         letting the user adapt the method to their needs and
   3407         requirements.
   3408 
   3409   [zettelkasten]
   3410         This is another one of Denote’s relatives, at least insofar as
   3411         the goal of simplicity is concerned.  The major difference is
   3412         that according to its documentation “the name of the file that
   3413         is created is just a unique ID”.  This is not consistent with
   3414         our file-naming scheme which is all about making sense of your
   3415         files by their name alone and being able to visually parse a
   3416         listing of them without any kind of specialised tool (e.g. `ls
   3417         -l' or `ls -C' on the command-line from inside the
   3418         `denote-directory' give you a human-readable set of files names,
   3419         while `find * -maxdepth 0 -type f' is another approach).
   3420 
   3421   [zetteldeft]
   3422         This is a zettelkasten note-taking system built on top of the
   3423         `deft' package.  Deft provides a search interface to a
   3424         directory, in this case the one holding the user’s `zetteldeft'
   3425         notes.  Denote has no such dependency and is not opinionated
   3426         about how the user prefers to search/access their notes: use
   3427         Dired, Grep, the `consult' package, or whatever else you already
   3428         have set up for all things Emacs, not just your notes.
   3429 
   3430   Searching through `M-x list-packages' for “zettel” brings up more
   3431   matches.  `zetteldesk' is an extension to Org Roam and, as such, I
   3432   cannot possibly know what Org Roam truly misses and what the
   3433   added-value of this package is.  `neuron-mode' builds on top of an
   3434   external program called `neuron', which I have never used.
   3435 
   3436   Searching for “note” gives us a few more results.  `notes-mode' has
   3437   precious little documentation and I cannot tell what it actually does
   3438   (as I said in my presentation for LibrePlanet 2022, inadequate docs
   3439   are a bug).  `side-notes' differs from what we try to do with Denote,
   3440   as it basically gives you the means to record your thoughts about some
   3441   other project you are working on and keep them on the side: so it and
   3442   Denote should not be mutually exclusive.
   3443 
   3444   If I missed something, please let me know.
   3445 
   3446 
   3447 [org-roam] <https://github.com/org-roam/org-roam>
   3448 
   3449 [zk (or zk.el)] <https://github.com/localauthor/zk>
   3450 
   3451 [zettelkasten] <https://github.com/ymherklotz/emacs-zettelkasten>
   3452 
   3453 [zetteldeft] <https://github.com/EFLS/zetteldeft>
   3454 
   3455 18.1 Alternative ideas with Emacs and further reading
   3456 ─────────────────────────────────────────────────────
   3457 
   3458   This section covers blog posts from the Emacs community on the matter
   3459   of note-taking.  They may reference some of the packages covered in
   3460   the previous section or provide their custom code ([Alternatives to
   3461   Denote]).  The list is unsorted.
   3462 
   3463   ⁃ José Antonio Ortega Ruiz (aka “jao”) explains a note-taking method
   3464     that is simple like Denote but differs in other ways.  An
   3465     interesting approach overall:
   3466     <https://jao.io/blog/2022-06-19-simple-note-taking.html>.
   3467 
   3468   ⁃ Jethro Kuan (the main `org-roam' developer) explains their
   3469     note-taking techniques:
   3470     <https://jethrokuan.github.io/org-roam-guide/>.  Good ideas all
   3471     round, regardless of the package/code you choose to use.
   3472 
   3473   [ Development note: help expand this list. ]
   3474 
   3475 
   3476 [Alternatives to Denote] See section 18
   3477 
   3478 
   3479 19 Frequently Asked Questions
   3480 ═════════════════════════════
   3481 
   3482   I (Protesilaos) answer some questions I have received or might get.
   3483   It is assumed that you have read the rest of this manual: I will not
   3484   go into the specifics of how Denote works.
   3485 
   3486 
   3487 19.1 Why develop Denote when PACKAGE already exists?
   3488 ────────────────────────────────────────────────────
   3489 
   3490   I wrote Denote because I was using a variant of Denote’s file-naming
   3491   scheme before I was even an Emacs user (I switched to Emacs from
   3492   Tmux+Vim+CLI in the summer of 2019).  I was originally inspired by
   3493   Jekyll, the static site generator, which I started using for my
   3494   website in 2016 (was on WordPress before).  Jekyll’s files follow the
   3495   `YYYY-MM-DD-TITLE.md' pattern.  I liked its efficiency relative to the
   3496   unstructured mess I had before.  Eventually, I started using that
   3497   scheme outside the confines of my website’s source code.  Over time I
   3498   refined it and here we are.
   3499 
   3500   Note-taking is something I take very seriously, as I am a prolific
   3501   writer (just check my website, which only reveals the tip of the
   3502   iceberg).  As such, I need a program that does exactly what I want and
   3503   which I know how to extend.  I originally tried to use Org capture
   3504   templates to create new files with a Denote-style file-naming scheme
   3505   but never managed to achieve it.  Maybe because `org-capture' has some
   3506   hard-coded assumptions or I simply am not competent enough to hack on
   3507   core Org facilities.  Whatever the case, an alternative was in order.
   3508 
   3509   The existence of PACKAGE is never a good reason for me not to conduct
   3510   my own experiments for recreational, educational, or practical
   3511   purposes.  When the question arises of “why not contribute to PACKAGE
   3512   instead?” the answer is that without me experimenting in the first
   3513   place, I would lack the skills for such a task.  Furthermore,
   3514   contributing to another package does not guarantee I get what I want
   3515   in terms of workflow.
   3516 
   3517   Whether you should use Denote or not is another matter altogether:
   3518   choose whatever you want.
   3519 
   3520 
   3521 19.2 Why not rely exclusively on Org?
   3522 ─────────────────────────────────────
   3523 
   3524   I think Org is one of Emacs’ killer apps.  I also believe it is not
   3525   the right tool for every job.  When I write notes, I want to focus on
   3526   writing.  Nothing more.  I thus have no need for stuff like org-babel,
   3527   scheduling to-do items, clocking time, and so on.  The more “mental
   3528   dependencies” you add to your workflow, the heavier the burden you
   3529   carry and the less focused you are on the task at hand: there is
   3530   always that temptation to tweak the markup, tinker with some syntactic
   3531   construct, obsess about what ought to be irrelevant to writing as
   3532   such.
   3533 
   3534   In technical terms, I also am not fond of Org’s code base (I
   3535   understand why it is the way it is—just commenting on the fact).  Ever
   3536   tried to read it?  You will routinely find functions that are
   3537   tens-to-hundreds of lines long and have all sorts of special casing.
   3538   As I am not a programmer and only learnt to write Elisp through trial
   3539   and error, I have no confidence in my ability to make Org do what I
   3540   want at that level, hence `denote' instead of `org-denote' or
   3541   something.
   3542 
   3543   Perhaps the master programmer is one who can deal with complexity and
   3544   keep adding to it.  I am of the opposite view, as language—code
   3545   included—is at its communicative best when it is clear and accessible.
   3546 
   3547   Make no mistake: I use Org for the agenda and also to write technical
   3548   documentation that needs to be exported to various formats, including
   3549   this very manual.
   3550 
   3551 
   3552 19.3 Why care about Unix tools when you use Emacs?
   3553 ──────────────────────────────────────────────────
   3554 
   3555   My notes form part of my longer-term storage.  I do not want to have
   3556   to rely on a special program to be able to read them or filter them.
   3557   Unix is universal, at least as far as I am concerned.
   3558 
   3559   Denote streamlines some tasks and makes things easier in general,
   3560   which is consistent with how Emacs provides a layer of interactivity
   3561   on top of Unix.  Still, Denote’s utilities can, in principle, be
   3562   implemented as POSIX shell scripts (minus the Emacs-specific parts
   3563   like fontification in Dired or the buttonization of links).
   3564 
   3565   Portability matters.  For example, in the future I might own a
   3566   smartphone, so I prefer not to require Emacs, Org, or some other
   3567   executable to access my files on the go.
   3568 
   3569   Furthermore, I might want to share those files with someone.  If I
   3570   make Emacs a requirement, I am limiting my circle to a handful of
   3571   relatively advanced users.
   3572 
   3573   Please don’t misinterpret this: I am using Emacs full-time for my
   3574   computing and maintain a growing list of packages for it.  This is
   3575   just me thinking long-term.
   3576 
   3577 
   3578 19.4 Why many small files instead of few large ones?
   3579 ────────────────────────────────────────────────────
   3580 
   3581   I have read that Org favours the latter method.  If true, I strongly
   3582   disagree with it because of the implicit dependency it introduces and
   3583   the way it favours machine-friendliness over human-readability in
   3584   terms of accessing information.  Notes are long-term storage.  I might
   3585   want to access them on (i) some device with limited features, (ii)
   3586   print on paper, (iii) share with another person who is not a tech
   3587   wizard.
   3588 
   3589   There are good arguments for few large files, but all either
   3590   prioritize machine-friendliness or presuppose the use of sophisticated
   3591   tools like Emacs+Org.
   3592 
   3593   Good luck using `less' on a generic TTY to read a file with a zillion
   3594   words, headings, sub-headings, sub-sub-headings, property drawers, and
   3595   other constructs!  You will not get the otherwise wonderful folding of
   3596   headings the way you do in Emacs—do not take such features for
   3597   granted.
   3598 
   3599   My point is that notes should be atomic to help the user—and
   3600   potentially the user’s family, friends, acquaintances—make sense of
   3601   them in a wide range of scenaria.  The more program-agnostic your file
   3602   is, the better for you and/or everyone else you might share your
   3603   writings with.
   3604 
   3605   Human-readability means that we optimize for what matters to us.  If
   3606   (a) you are the only one who will ever read your notes, (b) always
   3607   have access to good software like Emacs+Org, (c) do not care about
   3608   printing on paper, then Denote’s model is not for you.  Maybe you need
   3609   to tweak some `org-capture' template to append a new entry to one mega
   3610   file (I do that for my Org agenda, by the way, as I explained before
   3611   about using the right tool for the job).
   3612 
   3613 
   3614 19.5 Does Denote perform well at scale?
   3615 ───────────────────────────────────────
   3616 
   3617   Denote does not do anything fancy and has no special requirements: it
   3618   uses standard tools to accomplish ordinary tasks.  If Emacs can cope
   3619   with lots of files, then that is all you need to know: Denote will
   3620   work.
   3621 
   3622   To put this to the test, Peter Prevos is running simulations with R
   3623   that generate large volumes of notes.  You can read the technicalities
   3624   here: <https://lucidmanager.org/productivity/testing-denote-package/>.
   3625   Excerpt:
   3626 
   3627         Using this code I generated ten thousands notes and used
   3628         this to test the Denote package to see it if works at a
   3629         large scale. This tests shows that Prot’s approach is
   3630         perfectly capable of working with thousands of notes.
   3631 
   3632   Of course, we are always prepared to make refinements to the code,
   3633   where necessary, without compromising on the project’s principles.
   3634 
   3635 
   3636 19.6 I add TODOs to my notes; will many files slow down the Org agenda?
   3637 ───────────────────────────────────────────────────────────────────────
   3638 
   3639   Yes, many files will slow down the agenda due to how that works.  Org
   3640   collects all files specified in the `org-agenda-files', searches
   3641   through their contents for timestamped entries, and then loops through
   3642   all days to determine where each entry belongs.  The more days and
   3643   more files, the longer it takes to build the agenda.  Doing this with
   3644   potentially hundreds of files will have a noticeable impact on
   3645   performance.
   3646 
   3647   This is not a deficiency of Denote.  It happens with generic Org
   3648   files.  The way the agenda is built is heavily favoring the use of a
   3649   single file that holds all your timestamped entries (or at least a few
   3650   such files).  Tens or hundreds of files are inefficient for this job.
   3651   Plus doing so has the side-effect of making Emacs open all those
   3652   files, which you probably do not need.
   3653 
   3654   If you want my opinion though, be more forceful with the separation of
   3655   concerns.  Decouple your knowledge base from your ephemeral to-do
   3656   list: Denote (and others) can be used for the former, while you let
   3657   standard Org work splendidly for the latter—that is what I do, anyway.
   3658 
   3659   Org has a powerful linking facility, whether you use `org-store-link'
   3660   or do it via an `org-capture' template.  If you want a certain note to
   3661   be associated with a task, just store the task in a single `tasks.org'
   3662   (or however you name it) and link to the relevant context.
   3663 
   3664   Do not mix your knowledge base with your to-do items.  If you need
   3665   help figuring out the specifics of this workflow, you are welcome to
   3666   ask for help in our relevant channels ([Contributing]).
   3667 
   3668 
   3669 [Contributing] See section 15
   3670 
   3671 
   3672 19.7 I want to sort by last modified, why won’t Denote let me?
   3673 ──────────────────────────────────────────────────────────────
   3674 
   3675   Denote does not sort files and will not reinvent tools that handle
   3676   such functionality.  This is the job of the file manager or
   3677   command-line executable that lists files.
   3678 
   3679   I encourage you to read the manpage of the `ls' executable.  It will
   3680   help you in general, while it applies to Emacs as well via Dired.  The
   3681   gist is that you can update the `ls' flags that Dired uses on-the-fly:
   3682   type `C-u M-x dired-sort-toggle-or-edit' (`C-u s' by default) and
   3683   append `--sort=time' at the prompt.  To reverse the order, add the
   3684   `-r' flag.  The user option `dired-listing-switches' sets your default
   3685   preference.
   3686 
   3687   There is also “virtual Dired” if you need something that cannot be
   3688   done with Dired ([Use dired-virtual-mode for arbitrary file
   3689   listings]).
   3690 
   3691 
   3692 [Use dired-virtual-mode for arbitrary file listings] See section 11.5
   3693 
   3694 
   3695 19.8 How do you handle the last modified case?
   3696 ──────────────────────────────────────────────
   3697 
   3698   Denote does not insert any meta data or heading pertaining to edits in
   3699   the file.  I am of the view that these either do not scale well or are
   3700   not descriptive enough.  Suppose you use a “lastmod” heading with a
   3701   timestamp: which lines where edited and what did the change amount to?
   3702 
   3703   This is where an external program can be helpful.  Use a Version
   3704   Control System, such as Git, to keep track of all your notes.  Every
   3705   time you add a new file, record the addition.  Same for post-creation
   3706   edits.  Your VCS will let you review the history of those changes.
   3707   For instance, Emacs’ built-in version control framework has a command
   3708   that produces a log of changes for the current file: `M-x
   3709   vc-print-log', bound to `C-x v l' by default.  From there one can
   3710   access the corresponding diff output (use `M-x describe-mode' (`C-h
   3711   m') in an unfamiliar buffer to learn more about it).  With Git in
   3712   particular, Emacs users have the option of the all-round excellent
   3713   `magit' package.
   3714 
   3715   In short: let Denote (or equivalent) create notes and link between
   3716   them, the file manager organise and provide access to files, search
   3717   programs deal with searching and narrowing, and version control
   3718   software handle the tracking of changes.
   3719 
   3720 
   3721 19.9 Speed up backlinks’ buffer creation?
   3722 ─────────────────────────────────────────
   3723 
   3724   Denotes leverages the built-in `xref' library to search for the
   3725   identifier of the current file and return any links to it.  For users
   3726   of Emacs version 28 or higher, there exists a user option to specify
   3727   the program that performs this search: `xref-search-program'.  The
   3728   default is `grep', which can be slow, though one may opt for `ugrep',
   3729   `ripgrep', or even specify something else (read the doc string of that
   3730   user option for the details).
   3731 
   3732   Try either for these for better results:
   3733 
   3734   ┌────
   3735   │ (setq xref-search-program 'ripgrep)
   3736   3737   │ ;; OR
   3738   3739   │ (setq xref-search-program 'ugrep)
   3740   └────
   3741 
   3742   To use whatever executable is available on your system, use something
   3743   like this:
   3744 
   3745   ┌────
   3746   │ ;; Prefer ripgrep, then ugrep, and fall back to regular grep.
   3747   │ (setq xref-search-program
   3748   │       (cond
   3749   │        ((or (executable-find "ripgrep")
   3750   │ 	    (executable-find "rg"))
   3751   │ 	'ripgrep)
   3752   │        ((executable-find "ugrep")
   3753   │ 	'ugrep)
   3754   │        (t
   3755   │ 	'grep)))
   3756   └────
   3757 
   3758 
   3759 19.10 Why do I get “Search failed with status 1” when I search for backlinks?
   3760 ─────────────────────────────────────────────────────────────────────────────
   3761 
   3762   Denote uses [Emacs’ Xref] to find backlinks.  Xref requires `xargs'
   3763   and one of `grep' or `ripgrep', depending on your configuration.
   3764 
   3765   This is usually not an issue on *nix systems, but the necessary
   3766   executables are not available on Windows Emacs distributions.  Please
   3767   ensure that you have both `xargs' and either `grep' or `ripgrep'
   3768   available within your `PATH' environment variable.
   3769 
   3770   If you have `git' on Windows installed, then you may use the following
   3771   code (adjust the git’s installation path if necessary):
   3772   ┌────
   3773   │ (setenv "PATH" (concat (getenv "PATH") ";" "C:\\Program Files\\Git\\usr\\bin"))
   3774   └────
   3775 
   3776 
   3777 [Emacs’ Xref] <info:emacs#Xref>
   3778 
   3779 
   3780 20 Acknowledgements
   3781 ═══════════════════
   3782 
   3783   Denote is meant to be a collective effort.  Every bit of help matters.
   3784 
   3785   Author/maintainer
   3786         Protesilaos Stavrou.
   3787 
   3788   Contributions to code or the manual
   3789         Abin Simon, Alan Schmitt, Benjamin Kästner, Charanjit Singh,
   3790         Clemens Radermacher, Colin McLear, Damien Cassou, Elias Storms,
   3791         Eshel Yaron, Florian, Graham Marlow, Hilde Rhyne, Jack Baty,
   3792         Jean-Philippe Gagné Guay, Jürgen Hötzel, Kaushal Modi, Kyle
   3793         Meyer, Marc Fargas, Noboru Ota (nobiot), Peter Prevos, Philip
   3794         Kaludercic, Quiliro Ordóñez, Stefan Monnier, Thibaut Benjamin.
   3795 
   3796   Ideas and/or user feedback
   3797         Abin Simon, Alan Schmitt, Alfredo Borrás, Benjamin Kästner,
   3798         Colin McLear, Damien Cassou, Elias Storms, Federico Stilman,
   3799         Florian, Frank Ehmsen, Guo Yong, Hanspeter Gisler, Jack Baty,
   3800         Jeremy Friesen, Juanjo Presa, Johan Bolmsjö, Kaushal Modi,
   3801         M. Hadi Timachi, Paul van Gelder, Peter Prevos, Shreyas Ragavan,
   3802         Stefan Thesing, Summer Emacs, Sven Seebeck, Taoufik, Viktor
   3803         Haag, Yi Liu, Ypot, atanasj, hpgisler, pRot0ta1p, sienic, sundar
   3804         bp.
   3805 
   3806   Special thanks to Peter Povinec who helped refine the file-naming
   3807   scheme, which is the cornerstone of this project.
   3808 
   3809   Special thanks to Jean-Philippe Gagné Guay for the numerous
   3810   contributions to the code base.
   3811 
   3812 
   3813 21 GNU Free Documentation License
   3814 ═════════════════════════════════
   3815 
   3816 
   3817 22 Indices
   3818 ══════════
   3819 
   3820 22.1 Function index
   3821 ───────────────────
   3822 
   3823 
   3824 22.2 Variable index
   3825 ───────────────────
   3826 
   3827 
   3828 22.3 Concept index
   3829 ──────────────────