This article describes how to take notes with the Emacs Denote package as part of the Emacs Writing Studio configuration for authors.

Taking Notes With the Emacs Denote Package

Peter Prevos

Peter Prevos |

4065 words | 20 minutes

Share this content

Over the years I have tried a cornucopia of digital applications to take notes. Emacs has several note-taking packages that extend basic functionality to help you manage your solidified thoughts. This article explains how to use Org mode and the Denote package by Protesilaos Stavrou.

Denote excels in its simplicity and the ease by which it can be extended. The most exciting aspect of Denote is that it can help you manage any file type, not only notes in Org mode. I use Denote extensively to manage my Org mode and other types of notes, PDF documents, photographs and videos and anything else. Another advantage is that Denote does not necessarily rely on Emacs, you can search and view your notes with any software that can process plain text files.

Emacs Writing Studio

Emacs Writing Studio

A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.

The source files of the book and EWS configuration are also freely available on GitHub.

Emacs Writing Studio: Ideation (Taking fleeting and permanent notes).

Creating Notes

Note-taking seems to have gained popularity in recent years judging by the flood of blog pages and videos that tell you how to best take notes. Whether Luhmann's Zettelkasten or Carroll's Bullet Journal, they all profess to solve all your personal knowledge management challenges. In my personal experience with paper and digital journals for over thirty years, the structure of your notes is not that important. The sincerity and originality of the thoughts contained within your notes has primacy over following some rigid system. My methodology is a primordial soup of thoughts from which my writings emerge. Even Luhmann himself saw his Zettelkasten as a septic tank for ideas. However, we can apply some logic to our workflow.

Not all notes are created equal and the relevant workflow depends on their purpose. Broadly speaking, we can distinguish between six types of notes:

  1. Fleeting notes
  2. Permanent notes
  3. Bibliographic notes
  4. Journal entries
  5. Meta notes
  6. Attachments

Fleeting notes

Fleeting notes are transient thoughts you store for a future review. You might have a sudden insight or remember a task you need to do. You quickly jot it down in your notebook and move on with whatever you were doing.

Physical notebooks or mobile phone applications are good methods to capture fleeting notes. Imagine you are in the middle of writing an article and suddenly you remind myself to put the rubbish bins out. In Org mode you don't open a special note-taking application and break your focus with a complex workflow. Adding a fleeting note is only a few keystrokes away.

When you feel the urge to write a note that is unrelated to the buffer you are currently working in, simply press C-c c and a the Org mode capture screen pops up. You select the relevant template and write your thoughts into the popup buffer and press C-c C-c to save it. If you decide it was not worth storing after all, press C-c C-k to cancel the input. Org mode then returns to where you left off and you happily continue with your task with minimal disturbance.

The Emacs Writing Studio configuration defines two types of fleeting notes:

  1. Textual notes
  2. New tasks

When you create a new fleeting note, Org mode asks you wether you need a new fleeting note or a task. Any entries are stored under the relevant heading and new notes are placed directly under previous entries.

The basic structure of your inbox looks like this:

  #+title: Inbox

  * Notes

  * Tasks

The configuration below binds the keyboard shortcuts for capturing fleeting notes and links (see below on how to use links). The configuration also uses the ews-inbox-file variable to store the filename of you fleeting note location, which is ~/Documents/inbox.org by default. You can of course customise this location to any filename of your choosing (see configure Emacs for details).

  ;; Fleeting notes
  (use-package org
    :after
    denote
    :bind
    (("C-c c" . org-capture)
     ("C-c l" . org-store-link))
    :custom
    (org-default-notes-file ews-inbox-file)
    (org-capture-bookmark nil)
    ;; Capture templates
    (org-capture-templates
     '(("f" "Fleeting note" item
        (file+headline org-default-notes-file "Notes")
        "- %?")
       ("p" "Permanent note" plain
        (file denote-last-path)
        #'denote-org-capture
        :no-save t
        :immediate-finish nil
        :kill-buffer t
        :jump-to-captured t)
       ("t" "New task" entry
        (file+headline org-default-notes-file "Tasks")
        "* TODO %i%?"))))

As you create more and more fleeting notes your inbox steadily fills with random musings and actions. In my personal Getting Things Done setup I promise myself to review these notes once per week and process them. You can use the C-u C-c c shortcut to jump to the inbox for your chosen template.

The weekly process involves reviewing these entries and either:

  • Undertaking the actions
  • Move the actions to your calendar
  • Convert the fleeting note to a permananet note.
  • Trashing the fleeting note.

Ideally, your Inbox should trend towards zero content.

The Org mode capture templates are a versatile system that allows you to craft templates for different types of notes. You could, for example, create a separate entry for a shopping list that you synchronise with your mobile phone.

You can access the configuration in the capture menu with the C button, which pops up the customisation screen for the org-capture-templates variable. Next click the INS button to add another entry and complete the relevant fields as below and save the new variable. The example below create a shopping list stored in a file in your Dropbox folder. Several mobile apps exist that can read Org mode files, so you can take your list to the shops if you have a means to synchronise the relevant files.

Org capture customisation
Org capture customisation.

The possibilities for capture templates are extensive and depend on your individual use cases. Explaining the configuration of the Org capture options in detail is outside the scope of this website. Section 10.1 of the Org manual discusses developing capture templates in detail.

 

Creating notes with Denote

The Denote package is amazingly flexible and can implement whatever note-taking approach you like to use, including a fully-fledged Zettelkasten approach or just a freeform stream of consciousness.

The driving force of the Denote package is its file-naming convention. This approach embeds any metadata in the filename so there is no need for complex nested folder structures to find your way through your jungle of notes.

The Denote file naming convention has five parts (all in lowercase by default), of which only the first part and file extensions are required:

  1. Timestamp in ISO 8601 format with a T separating date and time, e.g. 20230930T160112.
  2. The signature of the note (freeform letters and numbers), staring with a double equals sign, e.g. ==9a12.
  3. Note title separated by dashes (kebab-case), staring with a double dash, e.g. --taking-notes-with-denote.
  4. Keywords separated by an underscore (snake_case), starting with a double underscore, e.g. __emacs_productivity
  5. Filename extension so Emacs recognises your file type.

The default setting is that filenames are in all lowercase. So a full Denote file name for this example looks like this:

20230930T160112==9a12--taking-notes-with-denote__emacs_productivity.org

By default, Denote enforces lowercase characters in its filenames, but you can change his behaviour and control the letter casing of file names.

The timestamp is a unique and immutable identifier that Denote uses for linking notes. The signature indicates a semantic order for notes, such as used in the . Semantic note-taking systems such Zettelkasten method. The keywords define categories the note belongs to. The signature, title and tags are flexible and can change over time without damaging the integrity of the system.

If you like to include signatures for your notes, then you need to use the denote-signature function.

All new notes are stored in the same folder, signified by the denote-directory variable, which in EWS is mapped to ews-notes-directory. There is technically no need to store notes in subdirectories, but you can do so with the denote-subdirectory function.

Using tags is a more versatile method to organise your information than subdirectories. If you use a subdirectory to order files, then part of the meta data for that file disappears as soon as you move or copy the file to another location. Also, a file can only live in one directory, but it can have multiple tags. Modern operating systems can easily manage tens of thousands of files in one directory, so use tags to categorise your information.

Configure the denote-prompts variable to define the default way Denote generates and renames files.

Denote has a minor mode that formats compliant filenames in the directory editor so it is easy to recognise the individual items of the note's metadata. The filenames not only provide metadata for the note itself, they are also a heuristic to make it easy to find notes based on date, signatures, title or keyword.

Extract of Denote files in Dired
Extract of Denote files in Dired.

Denote can generate notes in plain text, Markdown or Org mode. Emacs Writing Studio uses the Org mode format because it is most suitable for writing bibliographic notes and managing citations. You can also use the Denote file naming convention for any other file types, for example to organise your photographs or PDF documents. So in Denote we can have notes (txt, md or org) and any other file is an attachment.

Permanent notes

A permanent note is a piece of information you like to retain long term. In my personal workflow, I regularly convert fleeting notes and writings in my paper notebook to permanent notes.

The denote-create-note function, which you activate with C-c w d n creates new notes. It first asks for a title and then for the relevant keywords. You either select a keyword from the completion list in the minibuffer with the TAB key or you enter new ones, separated by a comma.

You can also create a permanent note through the Org capture mechanism with the p option in the capture menu (C-c c).

The title of the note becomes part of the filename. In Org mode, you can also add a subtitle to the note by adding #+subtitle: to the front matter of your note.

 

Bibliographic notes

A bibliographic note is a special category of permanent notes that link to one or more publications in your bibliography. The citar-denote package provides extended functionality to create and manage bibliographic notes, described in detail in another article.

 

Journal notes

You can also use Denote for personal reflection and create a journal. Writing a journal with Denote is easy because the identifier for each note indicates the date and time you created each note. Adding a standard tag, such as _journal makes your journal entries easy to distinguish from other notes.

If you like to create a note for an entry in the past, then use the denote-date function (C-c w d d). You enter the date in Year-Month-Day (ISO 8601) notation like 2023-09-06. Optionally you can add a specific time, e.g: 2023-09-6 20:30. If no date and/or time is provided, Denote uses the present date and time. It makes sense to tag each journal entry with a standard keyword, e.g. _journal, or whatever makes sense in your native language.

The Denote manual provides some extra functionality on keeping a journal or diary.

 

Meta notes

A metanote provides an entry point to other notes about a similar topic. Lets say that you are working on a project to write a paper about the daimonion (prophetic monitor) that spoke to ancient Greek philosopher Socrates. You read the literature and create a bunch of permanent and bibliographic notes that use the _daimonion keyword. When it is time to gather your thoughts into an integrated view, you can create a new note that links to all your relevant notes.

Org mode uses dynamic blocks to achieve this. The denote-org-dblock-insert-links function (C-c w d D) will ask you for a regular expression that matches the notes you like to list. The great thing about dynamic blocks is that you can update them in case new notes are added by hitting C-c C-c twice when the cursor is on the BEGIN or END line.

#+BEGIN: denote-links :regexp "_daimonion"
- Plato: Apology
- Socrates and Plato
- Plato: Crito
#+END:

To change the search criteria you change the text between quotation marks after the :regexp part of the first line.

You could, for example, use this approach to collate your journal notes for a certain month. Using the regular expression ^202309.*_journal will list all your journal entries for September 2023. The regular expression lists filenames that starts with 202309 and include the _journal keyword. The tilde (^) denotes that you are searching at the start of the filename. The .* in the middle of the regular expression indicates that any character (.) can appear multiple times (*). In other words, this regular expression searches for all notes that start with 202309, then some random characters, followed by _journal. The .* expression effectively acts as an AND statement, so we look for a note that starts with 202309 and contains journal. The only restriction is that the two elements have to appear in this order. Using ^202308\|_journal searches for notes that start with 202308 or contain _journal. Regular expressions are a powerful tool for searching but detailed discussion is outside the scope of the Emacs Writing Studio.

The latest version of Denote also lets you transclude the text of other notes inside a note. The denote-org-dblock-insert-text function works much in the same way as the links version, but includes the text of the referenced notes inside the meta note.

The dynamic block option provides a versatile tool to aggregate your thoughts about a topic and link to relevant notes. They provide an easy entry point into your collection of notes and are a great starting point for your writing projects.

 

Attachments

Denote's reliance on a filename to store metadata allows you to manage files other than the three types specified by Denote, which we can call attachments. An attachment in Denote is any file that is not recognised by Denote as a note, but with a compatible filename. Any file stored in the Denote directory that follows the Denote file naming convention will be recognised as an attachment and can be linked from inside a Denote file.

The denote-file-types variable defines the file types that are considered notes (by default Org mode, Markdown and plain text). You only need to adust this variable if you like to use Denote to create new notes in a non-standard format. No configuration is required to visit and link to attachments.

This means that your digital notes garden can be much more than just text, Markdown or Org files. You can manage your photographs with Denote, store an archive of PDF files, such as bank statements, course certificates, or scans of your paper archive. Extending the Denote in this way converts your list of notes to a complete information management system with easy heuristics to find your documents and linking your them to notes. Extending the Denote in this way converts your list of notes to a complete information management system with great heuristics to enable finding attachments and linking your them to notes.

The use-cases for extending Denote to binary files are numerous. I personally save my photographs and videos in the Denote file format. I also store numerous PDF files, such as documents I scan or receive in this format. You could store literature as attachments instead of in your bibliography, but then you lose the ability to cite them in your writing.

If you like to separate collections of files then you can use silos within Denote. A silos is a group of Denote files that do link to each other. The denote-directory defines the default silo. If you want to link Denote files to each other, then they need to live within the same silo. Alternatively, you can create a symbolic link inside the Denote directory.

One use case would be to store all your tax receipts as PDF files. Getting ready for your tax return is than as easy as using a regular expression filter in Dired to mark all the files you need. Alternatively, you can link them all in an Org mode Denote file with a dynamic block using denote-org-dblock-insert-links.

For example, you tag all your tax records with the _tax keyword and you can then find your 2023 tax files with the ^2023.*_tax regular expression, which creates a list of links.

You can also link to individual attachments inside a Denote file in the same way as you link your notes. It is obviously not possible to link back from an attachment to a note using Denote.

Denote recognises any file in the Denote directory that follows the correct naming convention. So the first step to register your attachment in Denote is giving it a compliant correct name.

The denote-rename-file function (C-c w d r) lets you construct a Denote-compliant file name for attachments from within the dired file manager. This function uses the filename as a default title, which you can of course modify. The user adds relevant keywords and the last modified timestamp for the file becomes the identifier.

However, the creation date on the file system is not always the actual creation date. When working with attachments there are three options for a valid timestamp:

  • When the digitised document was created
  • When the electronic file was born
  • When the electronic file was created on the file system

Using the universal argument C-u instructs denote-rename-file to ask the user to enter a date and/or time for the attachment.

So in Emacs Writing Studio, use C-u C-c d r to rename a file and manually provide a timestamp. You need to enter the timestamp is ISO 8601 format, for example: 2023-11-04 12:32:45. Alternatively, when you use Org mode, you can customise the denote-date-prompt-use-org-read-date variable.

Over the years I have gradually digitised my paper archives. The oldest timestamp in my Denote library is 13700623T120000, which is a scan of a historic document that holds the mortgage of the house in which I was born. The creation date of the document is 20 September 2021. The Denote renaming function uses the file system date, but in this case I need to manually create a timestamp that places the document in the distant past.

The second scenario mostly occurs with photographs. The timestamp on the file system might not be the same as the moment the photograph was taken. So in this situation we need to extract the creation date from the file. Several tools, such as exiftool are available to extract metadata from photographs and PDF files.

Finding Notes and Attachments

When collecting thousands of notes and attachments it is important that you have a way into the system to find the information you need or to make new connections between ideas.

The most straightforward method to find files is by opening a file in your Denote directory. The minibuffer completion system helps you to find what you need.

If, for example, you like to filter to all notes tagged as Emacs, type C-c C-f and move to your notes folder and type _emacs and minibuffer completion narrows the options. If you need a note with Emacs in the title, but not as a tag, then use -emacs. If you type emacs without a prefix then you see all posts with Emacs in the signature, title or as a tag.

When you use the minibuffer completion configuration for the Emacs Writing Studio, you can separate keywords with spaces in any order. You can apply the same approach to title words and signatures. For example, using the search string --denote _ews ==9a shows all notes with a title that starts with Denote (using the double hyphen), include the "ews" keyword and have a signature that starts with "9a".

The consult-notes package by Colin McLear merges the capabilities of Denote and the Daniel Mendler's Consult package to help you find notes without having to remember which directory they live in. This package also provides facilities to search through the content of your notes collection.

To find a note by any part of its filename, use the consult-notes function bound to C-c w f. You can use all methods described in the section on finding notes to narrow your quest for the perfect note. The configuration for Consult-Notes can include your main Denote files and one or more silos, giving you full access to all your files in a convenient interface.

Search for titles, tags and other meta data is great, but sometimes you will want to search through the content of your notes. The consult-notes-search-in-all-notes function (C-c w s) activates the search facilities. For this purpose, the package uses the grep software, which needs to be available on your system. Emacs Writing Studio checks for the presence of external software at startup and leaves a warning in the messages buffer.

Linking Notes

You can link notes and attachments with the denote-link-or-create function (C-c w d i). This function provides a list of all available notes. Using the minibuffer completion system and the heuristics described in the previous section you can find the note you like to link to and hit ENTER.

The link only stores the identifier, e.g. denote:20210208T150244. This means that you are free to change the signature, title or keywords of notes without having to worry about broken links. If you change the identifier timestamp in the filename, then Denote will be unable to find the linked document.

You follow a link in Org mode with the org-open-at-point command, bound to C-c C-o.

You can jump to any linked note with denote-link-find-file (C-c w d l). This function shows all notes linked in this file in the minibuffer so you can select the one you like to jump to. This saves you having to find the location of the link and click on it. To find out which notes link to the one that you are currently reading, use the denote-find-backlink function (C-c w d b). This will, just like the previous function, show a list of all notes that are linked to the current one.

Managing Meta Data

If you need to change the title or signature of a note, you can do so in the front matter inside the file. The denote-rename-file-using-front-matter function (C-c w d R) renames the file based on the information in the file.

To conveniently change keywords with minibuffer completion, use the denote-keyword-add (C-c w d k) and denote-keyword-remove (C-c w d K) functions.

The Denote-Explore package provides some additional functionality to manage Denote files.

Configuring Denote

The following lines of Elisp code configure Denote. This configuration sets the ews-notes-directory variable as the repository for your Denote notes. You can change this location to any one you choose using the customisation menu, or replace this variable with a string.

  ;; Denote
  (use-package denote
    :init
    (require 'denote-org-dblock)
    (denote-rename-buffer-mode 1)
    :custom
    (denote-directory ews-notes-directory)
    :hook
    (dired-mode . denote-dired-mode)
    :custom-face
    (denote-faces-link ((t (:slant italic)))))

  ;; Denote extensions
  (use-package consult-notes
    :commands (consult-notes
               consult-notes-search-in-all-notes)
    :custom
    (consult-notes-file-dir-sources
     `(("Denote" ?d ,ews-notes-directory))))

Learn more about Denote

This article only provides a brief introduction to the Denote package. The extensive manual describes its full functionality in great detail. You can read the manual online, or read it inside Emacs with the info function (C-h R denote).

Emacs Writing Studio

If you like to support my work, then please purchase the Emacs Writing Studio book.

Emacs Writing Studio

Emacs Writing Studio

A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.

You can find the source files for the book and the latest configuration files on GitHub:

Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the contact form to send me an email or contact me on social media.

The next articles in this series discusses how to explore your Denote collection with some enhanced functionality.

Share this content

You might also enjoy reading these articles

Writing Prose with Emacs

Exploring Your Ideas With the Denote-Explore Package

Reading eBooks with Emacs