branch: externals/denote commit d4cbb974a51c1a64ddc3f350a0be819ab27fd099 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Rewrite node on multi file types (due to b42f68c) --- README.org | 63 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/README.org b/README.org index 206a5e4294..78097c9fdf 100644 --- a/README.org +++ b/README.org @@ -679,52 +679,56 @@ workflow the user wishes to follow nor does it expect a specific file type. It is entirely possible to store notes in a variety of formats across multiple directories and Denote will still be able to work with them, provided they follow the file-naming scheme and have an identifier -in their front matter (where relevant). Here we show how to create new -notes that deviate from the default value of ~denote-file-type~ and -specify their own ~denote-directory~. +in their front matter, where relevant. Here we show how to create new +notes that take the example of the ~denote-type~ command and take it one +step further. -Suppose you want to conform with the default of creating notes with the -=.org= extension but, for whatever reason, wish to have a way to quickly -produce a file with the =.md= extension and TOML-compliant front matter. +Suppose you want to use the ~denote~ command to store some notes in +Markdown, others in Org, and others still in plain text. Maybe you also +want to place each of those in its own directory. Using the +~denote-type~ command is not sufficient, as it only operates on the +value of the user option ~denote-directory~. You need some small +wrapper functions. -#+begin_src emacs-lisp -(setq denote-file-type nil) - -(defun my-denote-markdown-toml () - (interactive) - (let ((denote-file-type 'markdown-toml)) - (call-interactively #'denote))) -#+end_src +For example: -With the above, =M-x my-denote-markdown-toml= produces Markdown+TOML -notes while =M-x denote= uses Org. ++ =~/Documents/notes/= is your default and contains Org files. ++ =~/Documents/blog/= holds the files of your blog. ++ =~/Documents/random/= is where you scribble thoughts in plain text. -This principle can be taken a step further by ~let~ binding a second -directory for those alternative notes. Maybe your standard notes are -located in =~/Documents/notes/= but you plan to store the other ones in -=~/blog/= ([[#h:337f9cf0-9f66-45af-b73f-f6370472fb51][Fontification in Dired]]). +Why would you do that? It does not matter. This is for didactic +purposes. All you need to do is write functions that ~let~ bind the +~denote-directory~ and to the desired value. #+begin_src emacs-lisp -(setq denote-file-type nil) -(setq denote-directory (expand-file-name "~/Documents/notes/")) - (defun my-denote-markdown-toml () + "Create Markdown+TOML note in ~/Documents/blog/." (interactive) (let ((denote-file-type 'markdown-toml) - (denote-directory "~/blog/")) + (denote-directory "~/Documents/blog/")) + (call-interactively #'denote))) + +(defun my-denote-plain-text () + "Create plain text note in ~/Documents/random/." + (interactive) + (let ((denote-file-type 'text) + (denote-directory "~/Documents/random/")) (call-interactively #'denote))) #+end_src +You do not need a third command for the Org files, as those would be the +default used by regular ~denote~. + Given Denote's composable code, you can tweak the output however you like, including the contents of the file ([[#h:f69371d5-1843-493d-9ff5-c1ab3b43024e][Tweaking the front matter]]). If you do place different types of notes in their own directories, consider introducing directory-local variables to keep things working seamlessly. An obvious candidate for such a local variable is the -~denote-directory~: you want notes in =~/blog/= to treat their directory -as the canonical one; while those in =~/Documents/notes/= to do the same -for that path. Write a =.dir-locals.el= file with the following -contents and place it in each of those directories: +~denote-directory~: you want notes in =~/Documents/blog/= to treat their +directory as the canonical one; while those in =~/Documents/random/= to +do the same for that path. Write a =.dir-locals.el= file with the +following contents and place it in each of those directories: #+begin_src emacs-lisp ;;; Directory Local Variables @@ -735,6 +739,9 @@ contents and place it in each of those directories: This will allow things to work smoothly (e.g. ~denote-infer-keywords~). +Your default ~denote-directory~ does not need this, as it already is the +normal target that Denote uses. + Have more ideas? Something does not work quite right? Areas you wish were more abstract in the code? Please participate in the development process.