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