Skip to content

Define a custom file type to automatically encrypt new notes

Denote can work with any file type. By default, it works with those defined in the variable denote-file-types. The documentation string of that variable explains the technicalities.

Users who simply want to write files with something like a ‘.org.gpg’ extension can add the following to their configuration:

emacs-lisp
;; This is the same as the default `denote-file-types' entry for
;; `org', except for the :extension.  I gave it a different name (the
;; `org-gpg'), to distinguish it from the default.
(add-to-list 'denote-file-types
             '(org-gpg
               :extension ".org.gpg"
               :front-matter denote-org-front-matter
               :title-key-regexp "^#\\+title\\s-*:"
               :title-value-function denote-format-string-for-org-front-matter
               :title-value-reverse-function denote-trim-whitespace
               :keywords-key-regexp "^#\\+filetags\\s-*:"
               :keywords-value-function denote-format-keywords-for-org-front-matter
               :keywords-value-reverse-function denote-extract-keywords-from-front-matter
               :signature-key-regexp "^#\\+signature\\s-*:"
               :signature-value-function denote-format-string-for-org-front-matter
               :signature-value-reverse-function denote-trim-whitespace
               :identifier-key-regexp "^#\\+identifier\\s-*:"
               :identifier-value-function denote-format-string-for-org-front-matter
               :identifier-value-reverse-function denote-trim-whitespace
               :date-key-regexp "^#\\+date\\s-*:"
               :date-value-function denote-date-org-timestamp
               :date-value-reverse-function denote-extract-date-from-front-matter
               :link-retrieval-format "[denote:%VALUE%]"
               :link denote-org-link-format
               :link-in-context-regexp denote-org-link-in-context-regexp))

With this in place, the command denote-type will include the ‘org-gpg’ file type in its minibuffer prompt for a file type (Convenience commands for note creation). Same principle if the user option denote-prompts is configured to include the ‘file-type’ prompt (The denote-prompts option).