README.org (258584B)
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 2.3.0 8 #+macro: release-date 2024-03-24 9 #+macro: development-version 3.0.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 repositories: 37 + GitHub: <https://github.com/protesilaos/denote> 38 + GitLab: <https://gitlab.com/protesilaos/denote> 39 + Video demo: <https://protesilaos.com/codelog/2022-06-18-denote-demo/> 40 + Backronyms: Denote Everything Neatly; Omit The Excesses. Don't Ever 41 Note Only The Epiphenomenal. 42 43 If you are viewing the README.org version of this file, please note that 44 the GNU ELPA machinery automatically generates an Info manual out of it. 45 46 #+toc: headlines 8 insert TOC here, with eight headline levels 47 48 * COPYING 49 :PROPERTIES: 50 :COPYING: t 51 :CUSTOM_ID: h:40b18bb2-4dc1-4202-bd0b-6fab535b2a0f 52 :END: 53 54 Copyright (C) 2022-2024 Free Software Foundation, Inc. 55 56 #+begin_quote 57 Permission is granted to copy, distribute and/or modify this document 58 under the terms of the GNU Free Documentation License, Version 1.3 or 59 any later version published by the Free Software Foundation; with no 60 Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and 61 with the Back-Cover Texts as in (a) below. A copy of the license is 62 included in the section entitled “GNU Free Documentation License.” 63 64 (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and 65 modify this GNU manual.” 66 #+end_quote 67 68 * Overview 69 :PROPERTIES: 70 :CUSTOM_ID: h:a09b70a2-ae0b-4855-ac14-1dddfc8e3241 71 :END: 72 73 Denote aims to be a simple-to-use, focused-in-scope, and effective 74 note-taking and file-naming tool for Emacs. 75 76 Denote is based on the idea that files should follow a predictable and 77 descriptive file-naming scheme. The file name must offer a clear 78 indication of what the contents are about, without reference to any 79 other metadata. Denote basically streamlines the creation of such 80 files or file names while providing facilities to link between them 81 (where those files are editable). 82 83 Denote's file-naming scheme is not limited to "notes". It can be used 84 for all types of file, including those that are not editable in Emacs, 85 such as videos. Naming files in a consistent way makes their 86 filtering and retrieval considerably easier. Denote provides relevant 87 facilities to rename files, regardless of file type. 88 89 Denote is based on the following core design principles: 90 91 + Predictability :: File names must follow a consistent and descriptive 92 naming convention ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). The file name alone 93 should offer a clear indication of what the contents are, without 94 reference to any other metadatum. This convention is not specific to 95 note-taking, as it is pertinent to any form of file that is part of 96 the user's long-term storage ([[#h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca][Renaming files]]). 97 98 + Composability :: Be a good Emacs citizen, by integrating with other 99 packages or built-in functionality instead of re-inventing functions 100 such as for filtering or greping. The author of Denote (Protesilaos, 101 aka "Prot") writes ordinary notes in plain text (=.txt=), switching on 102 demand to an Org file only when its expanded set of functionality is 103 required for the task at hand ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). 104 105 + Portability :: Notes are plain text and should remain portable. The 106 way Denote writes file names, the front matter it includes in the 107 note's header, and the links it establishes must all be adequately 108 usable with standard Unix tools. No need for a database or some 109 specialised software. As Denote develops and this manual is fully 110 fleshed out, there will be concrete examples on how to do the 111 Denote-equivalent on the command-line. 112 113 + Flexibility :: Do not assume the user's preference for a note-taking 114 methodology. Denote is conceptually similar to the Zettelkasten 115 Method, which you can learn more about in this detailed introduction: 116 <https://zettelkasten.de/introduction/>. Notes are atomic (one file 117 per note) and have a unique identifier. However, Denote does not 118 enforce a particular methodology for knowledge management, such as a 119 restricted vocabulary or mutually exclusive sets of keywords. Denote 120 also does not check if the user writes thematically atomic notes. It 121 is up to the user to apply the requisite rigor and/or creativity in 122 pursuit of their preferred workflow ([[#h:6060a7e6-f179-4d42-a9de-a9968aaebecc][Writing metanotes]]). 123 124 + Hackability :: Denote's code base consists of small and reusable 125 functions. They all have documentation strings. The idea is to make 126 it easier for users of varying levels of expertise to understand what 127 is going on and make surgical interventions where necessary (e.g. to 128 tweak some formatting). In this manual, we provide concrete examples 129 on such user-level configurations ([[#h:4a6d92dd-19eb-4fcc-a7b5-05ce04da3a92][Keep a journal or diary]]). 130 131 Now the important part... "Denote" is the familiar word, though it also 132 is a play on the "note" concept. Plus, we can come up with acronyms, 133 recursive or otherwise, of increasingly dubious utility like: 134 135 + Don't Ever Note Only The Epiphenomenal 136 + Denote Everything Neatly; Omit The Excesses 137 138 But we'll let you get back to work. Don't Eschew or Neglect your 139 Obligations, Tasks, and Engagements. 140 141 * Points of entry 142 :PROPERTIES: 143 :CUSTOM_ID: h:17896c8c-d97a-4faa-abf6-31df99746ca6 144 :END: 145 146 #+findex: denote 147 #+findex: denote-type 148 #+findex: denote-org-capture 149 #+findex: denote-date 150 #+findex: denote-subdirectory 151 #+findex: denote-template 152 #+findex: denote-signature 153 There are five main ways to write a note with Denote: invoke the 154 ~denote~, ~denote-type~, ~denote-date~, ~denote-subdirectory~, 155 ~denote-template~, ~denote-signature~ commands, or leverage the 156 ~org-capture-templates~ by setting up a template which calls the 157 function ~denote-org-capture~. We explain all of those in the 158 subsequent sections. Other more specialised commands exist as well, 159 which one shall learn about as they read through this manual. We do 160 not want to overwhelm the user with options at this stage. 161 162 ** Standard note creation 163 :PROPERTIES: 164 :CUSTOM_ID: h:6a92a8b5-d766-42cc-8e5b-8dc255466a23 165 :END: 166 167 The ~denote~ command will prompt for a title. If a region is active, 168 the text of the region becomes the default at the minibuffer prompt 169 (meaning that typing =RET= without any input will use the default 170 value). Once the title is supplied, the ~denote~ command will then ask 171 for keywords. The resulting note will have a file name as already 172 explained: [[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file naming scheme]] 173 174 #+vindex: denote-after-new-note-hook 175 The ~denote~ command runs the hook ~denote-after-new-note-hook~ after 176 creating the new note. 177 178 The file type of the new note is determined by the user option 179 ~denote-file-type~ ([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]). 180 181 #+vindex: denote-known-keywords 182 #+vindex: denote-infer-keywords 183 The keywords' prompt supports minibuffer completion. Available 184 candidates are those defined in the user option ~denote-known-keywords~. 185 More candidates can be inferred from the names of existing notes, by 186 setting ~denote-infer-keywords~ to non-nil (which is the case by 187 default). 188 189 #+vindex: denote-sort-keywords 190 Multiple keywords can be inserted by separating them with a comma (or 191 whatever the value of the ~crm-separator~ is---which should be a comma). 192 When the user option ~denote-sort-keywords~ is non-nil (the default), 193 keywords are sorted alphabetically (technically, the sorting is done 194 with ~string-lessp~). 195 196 The interactive behaviour of the ~denote~ command is influenced by the 197 user option ~denote-prompts~ ([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The denote-prompts option]]). 198 199 The ~denote~ command can also be called from Lisp. Read its doc string 200 for the technicalities. 201 202 #+findex: denote-create-note 203 In the interest of discoverability, ~denote~ is also available under the 204 alias ~denote-create-note~. 205 206 *** The ~denote-prompts~ option 207 :PROPERTIES: 208 :CUSTOM_ID: h:f9204f1f-fcee-49b1-8081-16a08a338099 209 :END: 210 211 #+vindex: denote-prompts 212 The user option ~denote-prompts~ determines how the ~denote~ command 213 will behave interactively ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). 214 215 Commands that prompt for user input to construct a Denote file name 216 include, but are not limited to: ~denote~, ~denote-signature~, 217 ~denote-type~, ~denote-date~, ~denote-subdirectory~, 218 ~denote-rename-file~, ~denote-dired-rename-files~. 219 220 - [[#h:887bdced-9686-4e80-906f-789e407f2e8f][Convenience commands for note creation]]. 221 - [[#h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca][Renaming files]]. 222 223 The value of this user option is a list of symbols, which includes any 224 of the following: 225 226 - =title=: Prompt for the title of the new note ([[#h:403422a7-7578-494b-8f33-813874c12da3][The ~denote-history-completion-in-prompts~ option]]). 227 228 - =keywords=: Prompts with completion for the keywords of the new note. 229 Available candidates are those specified in the user option 230 ~denote-known-keywords~. If the user option ~denote-infer-keywords~ 231 is non-nil, keywords in existing note file names are included in the 232 list of candidates. The =keywords= prompt uses 233 ~completing-read-multiple~, meaning that it can accept multiple 234 keywords separated by a comma (or whatever the value of ~crm-separator~ 235 is). 236 237 - =file-type=: Prompts with completion for the file type of the new 238 note. Available candidates are those specified in the user option 239 ~denote-file-type~. Without this prompt, ~denote~ uses the value of 240 ~denote-file-type~. 241 242 - =subdirectory=: Prompts with completion for a subdirectory in which to 243 create the note. Available candidates are the value of the user 244 option ~denote-directory~ and all of its subdirectories. Any 245 subdirectory must already exist: Denote will not create it. 246 247 - =date=: Prompts for the date of the new note. It will expect an input 248 like 2022-06-16 or a date plus time: 2022-06-16 14:30. Without the 249 =date= prompt, the ~denote~ command uses the ~current-time~. 250 251 [[#h:e7ef08d6-af1b-4ab3-bb00-494a653e6d63][The denote-date-prompt-use-org-read-date option]]. 252 253 - =template=: Prompts for a KEY among the ~denote-templates~. The value 254 of that KEY is used to populate the new note with content, which is 255 added after the front matter ([[#h:f635a490-d29e-4608-9372-7bd13b34d56c][The denote-templates option]]). 256 257 - =signature=: - Prompts for an arbitrary string that can be used to 258 establish a sequential relationship between files (e.g. 1, 1a, 1b, 259 1b1, 1b2, ...). Signatures have no strictly defined function and 260 are up to the user to apply as they see fit. One use-case is to 261 implement Niklas Luhmann's Zettelkasten system for a sequence of 262 notes (Folgezettel). Signatures are not included in a file's front 263 matter. They are reserved solely for creating a sequence in a file 264 listing, at least for the time being. To insert a link that 265 includes the signature, use the command ~denote-link-with-signature~ 266 ([[#h:066e5221-9844-474b-8858-398398646f86][Insert link to file with signature]]). 267 268 The prompts occur in the given order. 269 270 If the value of this user option is nil, no prompts are used. The 271 resulting file name will consist of an identifier (i.e. the date and 272 time) and a supported file type extension (per ~denote-file-type~). 273 274 Recall that Denote's standard file-naming scheme is defined as follows 275 ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]): 276 277 : DATE--TITLE__KEYWORDS.EXT 278 279 If either or both of the =title= and =keywords= prompts are not 280 included in the value of this variable, file names will be any of 281 those permutations: 282 283 : DATE.EXT 284 : DATE--TITLE.EXT 285 : DATE__KEYWORDS.EXT 286 287 When in doubt, always include the =title= and =keywords= prompts. 288 289 Finally, this user option only affects the interactive use of the 290 ~denote~ or other relevant commands (advanced users can call it from 291 Lisp). In Lisp usage, the behaviour is always what the caller 292 specifies, based on the supplied arguments. 293 294 *** The ~denote-history-completion-in-prompts~ option 295 :PROPERTIES: 296 :CUSTOM_ID: h:403422a7-7578-494b-8f33-813874c12da3 297 :END: 298 299 #+vindex: denote-history-completion-in-prompts 300 The user option ~denote-history-completion-in-prompts~ toggles history 301 completion in all ~denote-prompts-with-history-as-completion~. 302 303 When this user option is set to a non-nil value, Denote will use 304 minibuffer history entries as completion candidates in all of the 305 ~denote-prompts-with-history-as-completion~. Those will show previous 306 inputs from their respective history as possible values to select, 307 either to (i) re-insert them verbatim or (ii) with the intent to edit 308 them further (depending on the minibuffer user interface, one can 309 select a candidate with =TAB= without exiting the minibuffer, as 310 opposed to what =RET= normally does by selecting and exiting). 311 312 When this user option is set to a nil value, all of the 313 ~denote-prompts-with-history-as-completion~ will not use minibuffer 314 completion: they will just prompt for a string of characters. Their 315 history is still available through all the standard ways of retrieving 316 minibuffer history, such as with the command ~previous-history-element~. 317 318 History completion still allows arbitrary values to be provided as 319 input: they do not have to match the available minibuffer completion 320 candidates. 321 322 Note that some prompts, like ~denote-keywords-prompt~, always use 323 minibuffer completion, due to the specifics of their data. 324 325 [ Consider enabling the built-in ~savehist-mode~ to persist minibuffer 326 histories between sessions.] 327 328 *** The ~denote-templates~ option 329 :PROPERTIES: 330 :CUSTOM_ID: h:f635a490-d29e-4608-9372-7bd13b34d56c 331 :END: 332 333 #+vindex: denote-templates 334 The user option ~denote-templates~ is an alist of content templates for 335 new notes. A template is arbitrary text that Denote will add to a newly 336 created note right below the front matter. 337 338 Templates are expressed as a =(KEY . STRING)= association. 339 340 - The =KEY= is the name which identifies the template. It is an 341 arbitrary symbol, such as =report=, =memo=, =statement=. 342 343 - The =STRING= is ordinary text that Denote will insert as-is. It can 344 contain newline characters to add spacing. Below we show some 345 concrete examples. 346 347 The user can choose a template either by invoking the command 348 ~denote-template~ or by changing the user option ~denote-prompts~ to 349 always prompt for a template when calling the ~denote~ command. 350 351 [[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The denote-prompts option]]. 352 353 [[#h:887bdced-9686-4e80-906f-789e407f2e8f][Convenience commands for note creation]]. 354 355 Templates can be written directly as one large string. For example (the 356 =\n= character is read as a newline): 357 358 #+begin_src emacs-lisp 359 (setq denote-templates 360 '((report . "* Some heading\n\n* Another heading") 361 (memo . "* Some heading 362 363 ,* Another heading 364 365 "))) 366 #+end_src 367 368 Long strings may be easier to type but interpret indentation literally. 369 Also, they do not scale well. A better way is to use some Elisp code to 370 construct the string. This would typically be the ~concat~ function, 371 which joins multiple strings into one. The following is the same as the 372 previous example: 373 374 #+begin_src emacs-lisp 375 (setq denote-templates 376 `((report . "* Some heading\n\n* Another heading") 377 (memo . ,(concat "* Some heading" 378 "\n\n" 379 "* Another heading" 380 "\n\n")))) 381 #+end_src 382 383 Notice that to evaluate a function inside of an alist we use the 384 backtick to quote the alist (NOT the straight quote) and then prepend a 385 comma to the expression that should be evaluated. The ~concat~ form 386 here is not sensitive to indentation, so it is easier to adjust for 387 legibility. 388 389 DEV NOTE: We do not provide more examples at this point, though feel 390 welcome to ask for help if the information provided herein is not 391 sufficient. We shall expand the manual accordingly. 392 393 *** Convenience commands for note creation 394 :PROPERTIES: 395 :CUSTOM_ID: h:887bdced-9686-4e80-906f-789e407f2e8f 396 :END: 397 398 Sometimes the user needs to create a note that has different 399 requirements from those of ~denote~ ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). While 400 this can be achieved globally by changing the ~denote-prompts~ user 401 option, there are cases where an ad-hoc method is the appropriate one 402 ([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The denote-prompts option]]). 403 404 To this end, Denote provides the following interactive convenience 405 commands for note creation. They all work by appending a new prompt to 406 the existing ~denote-prompts~. 407 408 + Create note by specifying file type :: The ~denote-type~ command 409 creates a note while prompting for a file type. 410 411 This is the equivalent of calling ~denote~ when ~denote-prompts~ has 412 the =file-type= prompt appended to its existing prompts. In practical 413 terms, this lets you produce, say, a note in Markdown even though 414 you normally write in Org ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). 415 416 #+findex: denote-create-note-using-type 417 The ~denote-create-note-using-type~ is an alias of ~denote-type~. 418 419 + Create note using a date :: Normally, Denote reads the current date 420 and time to construct the unique identifier of a newly created note 421 ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). Sometimes, however, the user needs to set 422 an explicit date+time value. 423 424 This is where the ~denote-date~ command comes in. It creates a note 425 while prompting for a date. The date can be in YEAR-MONTH-DAY 426 notation like =2022-06-30= or that plus the time: =2022-06-16 14:30=. 427 428 [[#h:e7ef08d6-af1b-4ab3-bb00-494a653e6d63][The denote-date-prompt-use-org-read-date option]]. 429 430 This is the equivalent of calling ~denote~ when ~denote-prompts~ has 431 the =date= prompt appended to its existing prompts. 432 433 #+findex: denote-create-note-using-date 434 The ~denote-create-note-using-date~ is an alias of ~denote-date~. 435 436 + Create note in a specific directory :: The ~denote-subdirectory~ 437 command creates a note while prompting for a subdirectory. Available 438 candidates include the value of the variable ~denote-directory~ and 439 any subdirectory thereof (Denote does not create subdirectories). 440 441 This is the equivalent of calling ~denote~ when ~denote-prompts~ has 442 the =subdirectory= prompt appended to its existing prompts. 443 444 #+findex: denote-create-note-in-subdirectory 445 The ~denote-create-note-in-subdirectory~ is a more descriptive alias 446 of ~denote-subdirectory~. 447 448 + Create note and add a template :: The ~denote-template~ command 449 creates a new note and inserts the specified template below the front 450 matter ([[#h:f635a490-d29e-4608-9372-7bd13b34d56c][The denote-templates option]]). Available candidates for 451 templates are specified in the user option ~denote-templates~. 452 453 This is the equivalent of calling ~denote~ when ~denote-prompts~ has 454 the =template= prompt appended to its existing prompts. 455 456 #+findex: denote-create-note-with-template 457 The ~denote-create-note-with-template~ is an alias of the command 458 ~denote-template~, meant to help with discoverability. 459 460 + Create note with a signature :: The ~denote-signature~ command first 461 prompts for an arbitrary string to use in the optional =SIGNATURE= 462 field of the file name and then asks for a title and keywords. 463 Signatures are arbitrary strings of alphanumeric characters which 464 can be used to establish sequential relations between file at the 465 level of their file name (e.g. 1, 1a, 1b, 1b1, 1b2, ...). 466 467 This is the equivalent of calling ~denote~ when ~denote-prompts~ has 468 the =signature= prompt appended to its existing prompts. 469 470 The ~denote-create-note-using-signature~ is an alias of the command 471 ~denote-signature~ intended to make the functionality more 472 discoverable. 473 474 **** Write your own convenience commands 475 :PROPERTIES: 476 :CUSTOM_ID: h:11946562-7eb0-4925-a3b5-92d75f1f5895 477 :END: 478 479 The convenience commands we provide only cover some basic use-cases 480 ([[#h:887bdced-9686-4e80-906f-789e407f2e8f][Convenience commands for note creation]]). The user may require 481 combinations that are not covered, such as to prompt for a template and 482 for a subdirectory, instead of only one of the two. To this end, we 483 show how to follow the code we use in Denote to write your own variants 484 of those commands. 485 486 First let's take a look at the definition of one of those commands. 487 They all look the same, but we use ~denote-subdirectory~ for this 488 example: 489 490 #+begin_src emacs-lisp 491 (defun denote-subdirectory () 492 "Create note while prompting for a subdirectory. 493 494 Available candidates include the value of the variable 495 `denote-directory' and any subdirectory thereof. 496 497 This is equivalent to calling `denote' when `denote-prompts' is 498 set to '(subdirectory title keywords)." 499 (declare (interactive-only t)) 500 (interactive) 501 (let ((denote-prompts '(subdirectory title keywords))) 502 (call-interactively #'denote))) 503 #+end_src 504 505 The hyphenated word after ~defun~ is the name of the function. It has 506 to be unique. Then we have the documentation string (or "doc string") 507 which is for the user's convenience. 508 509 This function is ~interactive~, meaning that it can be called via =M-x= 510 or be assigned to a key binding. Then we have the local binding of the 511 ~denote-prompts~ to the desired combination ("local" means specific to 512 this function without affecting other contexts). Lastly, it calls the 513 standard ~denote~ command interactively, so it uses all the prompts in 514 their specified order. 515 516 Now let's say we want to have a command that (i) asks for a template and 517 (ii) for a subdirectory ([[#h:f635a490-d29e-4608-9372-7bd13b34d56c][The denote-templates option]]). All we need to 518 do is tweak the ~let~ bound value of ~denote-prompts~ and give our 519 command a unique name: 520 521 #+begin_src emacs-lisp 522 ;; Like `denote-subdirectory' but also ask for a template 523 (defun denote-subdirectory-with-template () 524 "Create note while also prompting for a template and subdirectory. 525 526 This is equivalent to calling `denote' when `denote-prompts' is 527 set to '(template subdirectory title keywords)." 528 (declare (interactive-only t)) 529 (interactive) 530 (let ((denote-prompts '(template subdirectory title keywords))) 531 (call-interactively #'denote))) 532 #+end_src 533 534 The tweaks to ~denote-prompts~ determine how the command will behave 535 ([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The denote-prompts option]]). Use this paradigm to write your own 536 variants which you can then assign to keys, invoke with =M-x=, or add 537 to the list of commands available at the ~denote-command-prompt~ 538 ([[#h:98c732ac-da0e-4ebd-a0e3-5c47f9075e51][Choose which commands to prompt for]]). 539 540 *** The ~denote-save-buffer-after-creation~ option 541 :PROPERTIES: 542 :CUSTOM_ID: h:bf80f4cd-6f56-4f7c-a991-8573161e4511 543 :END: 544 545 #+vindex: denote-save-buffer-after-creation 546 The user option ~denote-save-buffer-after-creation~ controls whether 547 commands that creeate new notes save their buffer outright. 548 549 The default behaviour of commands such as ~denote~ (or related) is to 550 not save the buffer they create ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). This gives the user 551 the chance to review the text before writing it to a file. The user 552 may choose to delete the unsaved buffer, thus not creating a new note 553 ([[#h:bf80f4cd-6f56-4f7c-a991-8573161e4511][The ~denote-save-buffer-after-creation~ option]]). 554 555 If ~denote-save-buffer-after-creation~ is set to a non-nil value, such 556 buffers are saved automatically. 557 558 *** The ~denote-date-prompt-use-org-read-date~ option 559 :PROPERTIES: 560 :CUSTOM_ID: h:e7ef08d6-af1b-4ab3-bb00-494a653e6d63 561 :END: 562 563 By default, Denote uses its own simple prompt for date or date+time 564 input ([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The denote-prompts option]]). This is done when the 565 ~denote-prompts~ option includes a =date= symbol and/or when the user 566 invokes the ~denote-date~ command. 567 568 #+vindex: denote-date-prompt-use-org-read-date 569 Users who want to benefit from the more advanced date selection method 570 that is common in interactions with Org mode, can set the user option 571 ~denote-date-prompt-use-org-read-date~ to a non-nil value. 572 573 ** Create a note from the current Org subtree 574 :PROPERTIES: 575 :CUSTOM_ID: h:d0c7cb79-21e5-4176-a6af-f4f68578c8dd 576 :END: 577 578 In Org parlance, an entry with all its subheadings and other contents 579 is a "subtree". Denote can operate on the subtree to extract it from 580 the current file and create a new file out of it. One such workflow is 581 to collect thoughts in a single document and produce longer standalone 582 notes out of them upon review. 583 584 #+findex: denote-org-extras-extract-org-subtree 585 The command ~denote-org-extras-extract-org-subtree~ (part of the 586 optional =denote-org-extras.el= extension) is used for this purpose. 587 It creates a new Denote note using the current Org subtree. In doing 588 so, it removes the subtree from its current file and moves its 589 contents into a new file. 590 591 The text of the subtree's heading becomes the =#+title= of the new 592 note. Everything else is inserted as-is. 593 594 If the heading has any tags, they are used as the keywords of the new 595 note. If the Org file has any =#+filetags= they are taken as well 596 (Org's =#+filetags= are inherited by the headings). If none of these 597 are true and the user option ~denote-prompts~ includes an entry for 598 keywords, then ~denote-org-extras-extract-org-subtree~ prompts for 599 keywords. Else the new note has no keywords ([[#h:ad4dde4a-8e88-470a-97ae-e7b9d4b41fb4][Add or remove keywords interactively]]). 600 601 If the heading has a =PROPERTIES= drawer, it is retained for further 602 review. 603 604 If the heading's =PROPERTIES= drawer includes a =DATE= or =CREATED= 605 property, or there exists a =CLOSED= statement with a timestamp value, 606 use that to derive the date (or date and time) of the new note (if 607 there is only a date, the time is taken as 00:00). If more than one of 608 these is present, the order of preference is =DATE=, then =CREATED=, 609 then =CLOSED=. If none of these is present, the current time is used. 610 If the ~denote-prompts~ includes an entry for a date, then the command 611 prompts for a date at this stage (also see ~denote-date-prompt-use-org-read-date~). 612 613 For the rest, it consults the value of the user option 614 ~denote-prompts~ in the following scenaria: 615 616 - To optionally prompt for a subdirectory, otherwise it produces the 617 new note in the ~denote-directory~. 618 - To optionally prompt for a file signature, otherwise to not use any. 619 620 The new note is an Org file regardless of the user option 621 ~denote-file-type~. 622 623 ** Create note using Org capture 624 :PROPERTIES: 625 :CUSTOM_ID: h:656c70cd-cf9a-4471-a0b5-4f0aaf60f881 626 :END: 627 628 For integration with ~org-capture~, the user must first add the relevant 629 template. Such as: 630 631 #+begin_src emacs-lisp 632 (with-eval-after-load 'org-capture 633 (add-to-list 'org-capture-templates 634 '("n" "New note (with Denote)" plain 635 (file denote-last-path) 636 #'denote-org-capture 637 :no-save t 638 :immediate-finish nil 639 :kill-buffer t 640 :jump-to-captured t))) 641 #+end_src 642 643 [ In the future, we might develop Denote in ways which do not require such 644 manual intervention. More user feedback is required to identify the 645 relevant workflows. ] 646 647 Once the template is added, it is accessed from the specified key. If, 648 for instance, ~org-capture~ is bound to =C-c c=, then the note creation 649 is initiated with =C-c c n=, per the above snippet. After that, the 650 process is the same as with invoking ~denote~ directly, namely: a prompt 651 for a title followed by a prompt for keywords ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). 652 653 #+vindex: denote-org-capture-specifiers 654 Users may prefer to leverage ~org-capture~ in order to extend file 655 creation with the specifiers described in the ~org-capture-templates~ 656 documentation (such as to capture the active region and/or create a 657 hyperlink pointing to the given context). 658 659 IMPORTANT. Due to the particular file-naming scheme of Denote, which is 660 derived dynamically, such specifiers or other arbitrary text cannot be 661 written directly in the template. Instead, they have to be assigned to 662 the user option ~denote-org-capture-specifiers~, which is interpreted by 663 the function ~denote-org-capture~. Example with our default value: 664 665 #+begin_src emacs-lisp 666 (setq denote-org-capture-specifiers "%l\n%i\n%?") 667 #+end_src 668 669 Note that ~denote-org-capture~ ignores the ~denote-file-type~: it always 670 sets the Org file extension for the created note to ensure that the 671 capture process works as intended, especially for the desired output of 672 the ~denote-org-capture-specifiers~. 673 674 ** Create note with specific prompts using Org capture 675 :PROPERTIES: 676 :CUSTOM_ID: h:95b78582-9086-47e8-967f-62373e2369a0 677 :END: 678 679 This section assumes knowledge of how Denote+org-capture work, as 680 explained in the previous section ([[#h:656c70cd-cf9a-4471-a0b5-4f0aaf60f881][Create note using Org capture]]). 681 682 #+findex: denote-org-capture-with-prompts 683 The previous section shows how to define an Org capture template that 684 always prompts for a title and keywords. There are, however, cases 685 where the user wants more control over what kind of input Denote will 686 prompt for. To this end, we provide the function 687 ~denote-org-capture-with-prompts~. Below we explain it and then show 688 some examples of how to use it. 689 690 The ~denote-org-capture-with-prompts~ is like ~denote-org-capture~ but 691 with optional prompt parameters. 692 693 When called without arguments, it does not prompt for anything. It 694 just returns the front matter with title and keyword fields empty and 695 the date and identifier fields specified. It also makes the file name 696 consist of only the identifier plus the Org file name extension. 697 698 [[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]. 699 700 Otherwise, it produces a minibuffer prompt for every non-nil value 701 that corresponds to the =TITLE=, =KEYWORDS=, =SUBDIRECTORY=, =DATE=, 702 and =TEMPLATE= arguments. The prompts are those used by the standard 703 ~denote~ command and all of its utility commands. 704 705 [[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]. 706 707 When returning the contents that fill in the Org capture template, the 708 sequence is as follows: front matter, =TEMPLATE=, and then the value 709 of the user option ~denote-org-capture-specifiers~. 710 711 Important note: in the case of =SUBDIRECTORY= actual subdirectories 712 must exist---Denote does not create them. Same principle for 713 =TEMPLATE= as templates must exist and are specified in the user 714 option ~denote-templates~. 715 716 This is how one can incorporate ~denote-org-capture-with-prompts~ in 717 their Org capture templates. Instead of passing a generic ~t~ which 718 makes it hard to remember what the argument means, we use semantic 719 keywords like =:title= for our convenience (internally this does not 720 matter as the value still counts as non-nil, so =:foo= for =TITLE= is 721 treated the same as =:title= or ~t~). 722 723 #+begin_src emacs-lisp 724 ;; This prompts for TITLE, KEYWORDS, and SUBDIRECTORY 725 (add-to-list 'org-capture-templates 726 '("N" "New note with prompts (with denote.el)" plain 727 (file denote-last-path) 728 (function 729 (lambda () 730 (denote-org-capture-with-prompts :title :keywords :subdirectory))) 731 :no-save t 732 :immediate-finish nil 733 :kill-buffer t 734 :jump-to-captured t)) 735 736 ;; This prompts only for SUBDIRECTORY 737 (add-to-list 'org-capture-templates 738 '("N" "New note with prompts (with denote.el)" plain 739 (file denote-last-path) 740 (function 741 (lambda () 742 (denote-org-capture-with-prompts nil nil :subdirectory))) 743 :no-save t 744 :immediate-finish nil 745 :kill-buffer t 746 :jump-to-captured t)) 747 748 ;; This prompts for TITLE and SUBDIRECTORY 749 (add-to-list 'org-capture-templates 750 '("N" "New note with prompts (with denote.el)" plain 751 (file denote-last-path) 752 (function 753 (lambda () 754 (denote-org-capture-with-prompts :title nil :subdirectory))) 755 :no-save t 756 :immediate-finish nil 757 :kill-buffer t 758 :jump-to-captured t)) 759 #+end_src 760 761 ** Create a note with the region's contents 762 :PROPERTIES: 763 :CUSTOM_ID: h:2f8090f1-50af-4965-9771-d5a91a0a87bd 764 :END: 765 766 #+findex: denote-region 767 The command ~denote-region~ takes the contents of the active region 768 and then calls the ~denote~ command. Once a new note is created, it 769 inserts the contents of the region therein. This is useful to 770 quickly elaborate on some snippet of text or capture it for future 771 reference. 772 773 #+vindex: denote-region-after-new-note-functions 774 When the ~denote-region~ command is called with an active region, it 775 finalises its work by calling ~denote-region-after-new-note-functions~. 776 This is an abnormal hook, meaning that the functions added to it are 777 called with arguments. The arguments are two, representing the 778 beginning and end positions of the newly inserted text. 779 780 A common use-case for Org mode users is to call the command 781 ~org-insert-structure-template~ after a region is inserted. Emacs 782 will thus prompt for a structure template, such as the one 783 corresponding to a source block. In this case the function added to 784 ~denote-region-after-new-note-functions~ does not actually need 785 aforementioned arguments: it can simply declare those as ignored by 786 prefixing the argument names with an underscore (an underscore is 787 enough, but it is better to include a name for clarity). For example, 788 the following will prompt for a structure template as soon as 789 ~denote-region~ is done: 790 791 #+begin_src emacs-lisp 792 (defun my-denote-region-org-structure-template (_beg _end) 793 (when (derived-mode-p 'org-mode) 794 (activate-mark) 795 (call-interactively 'org-insert-structure-template))) 796 797 (add-hook 'denote-region-after-new-note-functions #'my-denote-region-org-structure-template) 798 #+end_src 799 800 Remember that ~denote-region-after-new-note-functions~ are not called 801 if ~denote-region~ is used without an active region. 802 803 ** Open an existing note or create it if missing 804 :PROPERTIES: 805 :CUSTOM_ID: h:ad91ca39-cf10-4e16-b224-fdf78f093883 806 :END: 807 808 #+findex: denote-open-or-create 809 #+findex: denote-open-or-create-with-command 810 Sometimes it is necessary to briefly interrupt the ongoing writing 811 session to open an existing note or, if that is missing, to create it. 812 This happens when a new tangential thought occurs and the user wants 813 to confirm that an entry for it is in place. To this end, Denote 814 provides the command ~denote-open-or-create~ as well as its more 815 flexible counterpart ~denote-open-or-create-with-command~. 816 817 The ~denote-open-or-create~ prompts to visit a file in the 818 ~denote-directory~. At this point, the user must type in search terms 819 that match a file name. If the input does not return any matches and 820 the user confirms their choice to proceed (usually by typing RET 821 twice, depending on the minibuffer settings), ~denote-open-or-create~ 822 will call the ~denote~ command interactively to create a new note. It 823 will then use whatever prompts ~denote~ normally has, per the user 824 option ~denote-prompts~ ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). If the title prompt 825 is involved (the default behaviour), the ~denote-open-or-create~ sets 826 up this prompt to have the previous input as the default title of the 827 note to-be-created. This means that the user can type RET at the 828 empty prompt to re-use what they typed in previously. Commands to use 829 previous inputs from the history are also available (=M-p= or =M-n= in 830 the minibuffer, which call ~previous-history-element~ and 831 ~next-history-element~ by default). Accessing the history is helpful 832 to, for example, make further edits to the available text. 833 834 The ~denote-open-or-create-with-command~ is like the above, except 835 when it is about to create the new note it first prompts for the 836 specific file-creating command to use ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). For example, 837 the user may want to specify a signature for this new file, so they 838 can select the ~denote-signature~ command. 839 840 Denote provides similar functionality for linking to an existing note 841 or creating a new one ([[#h:b6056e6b-93df-4e6b-a778-eebd105bac46][Link to a note or create it if missing]]). 842 843 ** Maintain separate directory silos for notes 844 :PROPERTIES: 845 :CUSTOM_ID: h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5 846 :END: 847 #+cindex: Note silos 848 849 The user option ~denote-directory~ accepts a value that represents the 850 path to a directory, such as =~/Documents/notes=. Normally, the user 851 will have one place where they store all their notes, in which case this 852 arrangement shall suffice. 853 854 There is, however, the possibility to maintain separate directories of 855 notes. By "separate", we mean that they do not communicate with each 856 other: no linking between them, no common keywords, nothing. Think of 857 the scenario where one set of notes is for private use and another is 858 for an employer. We call these separate directories "silos". 859 860 To create silos, the user must specify a local variable at the root of 861 the desired directory. This is done by creating a =.dir-locals.el= 862 file, with the following contents: 863 864 #+begin_src emacs-lisp 865 ;;; Directory Local Variables. For more information evaluate: 866 ;;; 867 ;;; (info "(emacs) Directory Variables") 868 869 ((nil . ((denote-directory . "/path/to/silo/")))) 870 #+end_src 871 872 When inside the directory that contains this =.dir-locals.el= file, all 873 Denote commands/functions for note creation, linking, the inference of 874 available keywords, et cetera will use the silo as their point of 875 reference. They will not read the global value of ~denote-directory~. 876 The global value of ~denote-directory~ is read everywhere else except 877 the silos. 878 879 [[#h:0f72e6ea-97f0-42e1-8fd4-0684af0422e0][Use custom commands to select a silo]]. 880 881 In concrete terms, this is a representation of the directory structures 882 (notice the =.dir-locals.el= file is needed only for the silos): 883 884 #+begin_example 885 ;; This is the global value of 'denote-directory' (no need for a .dir-locals.el) 886 ~/Documents/notes 887 |-- 20210303T120534--this-is-a-test__journal_philosophy.txt 888 |-- 20220303T120534--another-sample__journal_testing.md 889 `-- 20220620T181255--the-third-test__keyword.org 890 891 ;; A silo with notes for the employer 892 ~/different/path/to/notes-for-employer 893 |-- .dir-locals.el 894 |-- 20210303T120534--this-is-a-test__conference.txt 895 |-- 20220303T120534--another-sample__meeting.md 896 `-- 20220620T181255--the-third-test__keyword.org 897 898 ;; Another silo with notes for my volunteering 899 ~/different/path/to/notes-for-volunteering 900 |-- .dir-locals.el 901 |-- 20210303T120534--this-is-a-test__activism.txt 902 |-- 20220303T120534--another-sample__teambuilding.md 903 `-- 20220620T181255--the-third-test__keyword.org 904 #+end_example 905 906 It is possible to configure other user options of Denote to have a 907 silo-specific value. For example, this one changes the 908 ~denote-known-keywords~ only for this particular silo: 909 910 #+begin_src emacs-lisp 911 ;;; Directory Local Variables. For more information evaluate: 912 ;;; 913 ;;; (info "(emacs) Directory Variables") 914 915 ((nil . ((denote-directory . "/path/to/silo/") 916 (denote-known-keywords . ("food" "drink"))))) 917 #+end_src 918 919 This one is like the above, but also disables ~denote-infer-keywords~: 920 921 #+begin_src emacs-lisp 922 ;;; Directory Local Variables. For more information evaluate: 923 ;;; 924 ;;; (info "(emacs) Directory Variables") 925 926 ((nil . ((denote-directory . "/path/to/silo/") 927 (denote-known-keywords . ("food" "drink")) 928 (denote-infer-keywords . nil)))) 929 #+end_src 930 931 To expand the list of local variables to, say, cover specific major 932 modes, we can do something like this: 933 934 #+begin_src emacs-lisp 935 ;;; Directory Local Variables. For more information evaluate: 936 ;;; 937 ;;; (info "(emacs) Directory Variables") 938 939 ((nil . ((denote-directory . "/path/to/silo/") 940 (denote-known-keywords . ("food" "drink")) 941 (denote-infer-keywords . nil))) 942 (org-mode . ((org-hide-emphasis-markers . t) 943 (org-hide-macro-markers . t) 944 (org-hide-leading-stars . t)))) 945 #+end_src 946 947 As not all user options have a "safe" local value, Emacs will ask the 948 user to confirm their choice and to store it in the Custom code 949 snippet that is normally appended to init file (or added to the file 950 specified by the user option ~custom-file~). 951 952 Finally, it is possible to have a =.dir-locals.el= for subdirectories 953 of any ~denote-directory~. Perhaps to specify a different set of 954 known keywords, while not making the subdirectory a silo in its own 955 right. We shall not expand on such an example, as we trust the user 956 to experiment with the best setup for their workflow. 957 958 Feel welcome to ask for help if the information provided herein is not 959 sufficient. The manual shall be expanded accordingly. 960 961 *** Use custom commands to select a silo 962 :PROPERTIES: 963 :CUSTOM_ID: h:0f72e6ea-97f0-42e1-8fd4-0684af0422e0 964 :END: 965 966 [ As part of version 2.1.0, the contents of this section 967 are formally provided in the file =denote-silo-extras.el=. We keep 968 this here for existing users. Otherwise consult the new entry in 969 the manual ([[#h:e43baf95-f201-4fec-8620-c0eb5eaa1c85][The =denote-silo-extras.el=]]). ] 970 971 We implement silos as directory-local values of the user option 972 ~denote-directory~. This means that all Denote commands read from the 973 local value if they are invoked from that context. For example, if 974 =~/Videos/recordings= is a silo and =~/Documents/notes= is the 975 default/global value of ~denote-directory~ all Denote commands will 976 read the video's path when called from there (e.g. by using Emacs' 977 ~dired~); any other context reads the global value. 978 979 [[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos for notes]]. 980 981 There are cases where the user (i) wants to maintain multiple silos 982 and (ii) prefers an interactive way to switch between them without 983 going through Dired. Since this is specific to the user's workflow, 984 it is easier to have some custom code for it. The following should be 985 added to the user's Denote configuration: 986 987 #+begin_src emacs-lisp 988 (defvar my-denote-silo-directories 989 `("/home/prot/Videos/recordings" 990 "/home/prot/Documents/books" 991 ;; You don't actually need to include the `denote-directory' here 992 ;; if you use the regular commands in their global context. I am 993 ;; including it for completeness. 994 ,denote-directory) 995 "List of file paths pointing to my Denote silos. 996 This is a list of strings.") 997 998 (defvar my-denote-commands-for-silos 999 '(denote 1000 denote-date 1001 denote-subdirectory 1002 denote-template 1003 denote-type) 1004 "List of Denote commands to call after selecting a silo. 1005 This is a list of symbols that specify the note-creating 1006 interactive functions that Denote provides.") 1007 1008 (defun my-denote-pick-silo-then-command (silo command) 1009 "Select SILO and run Denote COMMAND in it. 1010 SILO is a file path from `my-denote-silo-directories', while 1011 COMMAND is one among `my-denote-commands-for-silos'." 1012 (interactive 1013 (list (completing-read "Select a silo: " my-denote-silo-directories nil t) 1014 (intern (completing-read 1015 "Run command in silo: " 1016 my-denote-commands-for-silos nil t)))) 1017 (let ((denote-directory silo)) 1018 (call-interactively command))) 1019 #+end_src 1020 1021 With this in place, =M-x my-denote-pick-silo-then-command= will use 1022 minibuffer completion to select a silo among the predefined options 1023 and then ask for the command to run in that context. 1024 1025 Note that =let= binding ~denote-directory~ can be used in custom 1026 commands and other wrapper functions to override the global default 1027 value of ~denote-directory~ to select silos. 1028 1029 To see another example of a wrapper function that =let= binds 1030 ~denote-directory~, see: 1031 1032 [[#h:d0c7cb79-21e5-4176-a6af-f4f68578c8dd][Extending Denote: Split an Org subtree into its own note]]. 1033 1034 *** The =denote-silo-extras.el= 1035 :PROPERTIES: 1036 :CUSTOM_ID: h:e43baf95-f201-4fec-8620-c0eb5eaa1c85 1037 :END: 1038 1039 The =denote-silo-extras.el= provides optional convenience functions for 1040 working with silos ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos for notes]]). 1041 Start by loading the relevant library: 1042 1043 #+begin_src emacs-lisp 1044 (require 'denote-silo-extras) 1045 #+end_src 1046 1047 #+vindex: denote-silo-extras-directories 1048 The user option ~denote-silo-extras-directories~ specifies a list of 1049 directories that the user has set up as ~denote-directory~ silos. 1050 1051 #+findex: denote-silo-extras-create-note 1052 The command ~denote-silo-extras-create-note~ prompts for a directory 1053 among ~denote-silo-extras-directories~ and runs the ~denote~ command 1054 from there. 1055 1056 #+findex: denote-silo-extras-open-or-create 1057 Similar to the above, the command ~denote-silo-extras-open-or-create~ 1058 prompts for a directory among ~denote-silo-extras-directories~ and runs 1059 the ~denote-open-or-create~ command from there. 1060 1061 #+findex: denote-silo-extras-select-silo-then-command 1062 The command ~denote-silo-extras-select-silo-then-command~ prompts with 1063 minibuffer completion for a directory among ~denote-silo-extras-directories~. 1064 Once the user selects a silo, a second prompt asks for a Denote 1065 note-creation command to call from inside that silo ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). 1066 1067 ** Exclude certain directories from all operations 1068 :PROPERTIES: 1069 :CUSTOM_ID: h:8458f716-f9c2-4888-824b-2bf01cc5850a 1070 :END: 1071 1072 #+vindex: denote-excluded-directories-regexp 1073 The user option ~denote-excluded-directories-regexp~ instructs all 1074 Denote functions that read or check file/directory names to omit 1075 directories that match the given regular expression. The regexp needs 1076 to match only the name of the directory, not its full path. 1077 1078 Affected operations include file prompts and functions that return the 1079 available files in the value of the user option ~denote-directory~ 1080 ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos for notes]]). 1081 1082 File prompts are used by several commands, such as ~denote-link~ and 1083 ~denote-subdirectory~. 1084 1085 Functions that check for files include ~denote-directory-files~ and 1086 ~denote-directory-subdirectories~. 1087 1088 The match is performed with ~string-match-p~. 1089 1090 [[#h:c916d8c5-540a-409f-b780-6ccbd90e088e][For developers or advanced users]]. 1091 1092 ** Exclude certain keywords from being inferred 1093 :PROPERTIES: 1094 :CUSTOM_ID: h:69e518ee-ed43-40ab-a5f4-c780a23e5358 1095 :END: 1096 1097 #+vindex: denote-excluded-keywords-regexp 1098 The user option ~denote-excluded-keywords-regexp~ omits keywords that 1099 match a regular expression from the list of inferred keywords. 1100 1101 Keywords are inferred from file names and provided at relevant prompts 1102 as completion candidates when the user option ~denote-infer-keywords~ 1103 is non-nil. 1104 1105 The match is performed with ~string-match-p~. 1106 1107 ** Use Denote commands from the menu bar or context menu 1108 :PROPERTIES: 1109 :CUSTOM_ID: h:c4290e15-e97e-4a9b-b8db-6b9738e37e78 1110 :END: 1111 1112 Denote registers a submenu for the ~menu-bar-mode~. Users will find 1113 the entry called "Denote". From there they can use their pointer to 1114 select a command. For a sample of how this looks, read the 1115 development log: <https://protesilaos.com/codelog/2023-03-31-emacs-denote-menu/>. 1116 1117 #+findex: denote-menu-bar-mode 1118 The command ~denote-menu-bar-mode~ toggles the presentation of the 1119 menu. It is enabled by default. 1120 1121 Emacs also provides support for operations through a context menu. 1122 This is typically the set of actions that are made available via a 1123 right mouse click. Users who enable ~context-menu-mode~ can register 1124 the Denote entry for it by adding the following to their configuration 1125 file: 1126 1127 #+begin_src emacs-lisp 1128 (add-hook 'context-menu-functions #'denote-context-menu) 1129 #+end_src 1130 1131 * Renaming files 1132 :PROPERTIES: 1133 :CUSTOM_ID: h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca 1134 :END: 1135 1136 Denote provides commands to rename files and update their front matter 1137 where relevant. For Denote to work, only the file name needs to be in 1138 order, by following our naming conventions ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 1139 The linking mechanism, in particular, needs just the identifier in the 1140 file name ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). 1141 1142 We write front matter in notes for the user's convenience and for other 1143 tools to make use of that information (e.g. Org's export mechanism). 1144 The renaming mechanism takes care to keep this data in sync with the 1145 file name, when the user performs a change. 1146 1147 Renaming is useful for managing existing files created with Denote, 1148 but also for converting older text files to Denote notes. Denote's 1149 file-naming scheme is not specific to notes or text files: it is 1150 relevant for all sorts of items, such as multimedia and PDFs that form 1151 part of the user's longer-term storage. While Denote does not manage 1152 such files (e.g. doesn't create links to them), it already has all the 1153 mechanisms to facilitate the task of renaming them. 1154 1155 #+vindex: denote-after-rename-file-hook 1156 All renaming commands run the ~denote-after-rename-file-hook~ after a 1157 succesful operation. 1158 1159 Apart from renaming files, Denote can also rename only the buffer. 1160 The idea is that the underlying file name is correct but it can be 1161 easier to use shorter buffer names when displaying them on the mode 1162 line or switching between then with commands like ~switch-to-buffer~. 1163 1164 [[#h:3ca4db16-8f26-4d7d-b748-bac48ae32d69][Automatically rename Denote buffers]]. 1165 1166 ** Rename a single file 1167 :PROPERTIES: 1168 :CUSTOM_ID: h:7cc9e000-806a-48da-945c-711bbc7426b0 1169 :END: 1170 1171 #+findex: denote-rename-file 1172 The ~denote-rename-file~ command renames a file and updates existing 1173 front matter if appropriate. It is possible to do the same with 1174 multiple files ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files interactively]]). 1175 1176 It always renames the file where it is located in the file system: 1177 it never moves it to another directory. 1178 1179 If in Dired, it considers =FILE= to be the one at point, else it 1180 prompts with minibuffer completion for one. When called from Lisp, 1181 =FILE= is a file system path represented as a string. 1182 1183 If =FILE= has a Denote-compliant identifier, it retains it while 1184 updating components of the file name referenced by the user option 1185 ~denote-prompts~ ([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The ~denote-prompts~ option]]). By default, these are 1186 the =TITLE= and =KEYWORDS=. The =SIGNATURE= is another one. When 1187 called from Lisp, =TITLE= and =SIGNATURE= are strings, while 1188 =KEYWORDS= is a list of strings. 1189 1190 If there is no identifier, ~denote-rename-file~ creates an identifier 1191 based on the following conditions: 1192 1193 1. If the ~denote-prompts~ includes an entry for date prompts, then it 1194 prompts for =DATE= and takes its input to produce a new identifier. For 1195 use in Lisp, =DATE= must conform with ~denote-valid-date-p~. 1196 1197 2. If =DATE= is nil (e.g. when ~denote-prompts~ does not include a 1198 date entry), it uses the file attributes to determine the last 1199 modified date of =FILE= and formats it as an identifier. 1200 1201 3. As a fallback, it derives an identifier from the current date and 1202 time. 1203 1204 4. At any rate, if the resulting identifier is not unique among the 1205 files in the variable ~denote-directory~, it increments it such 1206 that it becomes unique. 1207 1208 In interactive use, and assuming ~denote-prompts~ includes a title 1209 entry, the ~denote-rename-file~ makes the =TITLE= prompt have 1210 prefilled text in the minibuffer that consists of the current title of 1211 =FILE=. The current title is either retrieved from the front matter 1212 (such as the =#+title= in Org) or from the file name. 1213 1214 The command does the same for the =SIGNATURE= prompt, subject to 1215 ~denote-prompts~, by prefilling the minibuffer with the current 1216 signature of =FILE=, if any. 1217 1218 Same principle for the =KEYWORDS= prompt: it converts the keywords in 1219 the file name into a comma-separated string and prefills the minibuffer 1220 with it (the =KEYWORDS= prompt accepts more than one keywords, each 1221 separated by a comma, else the ~crm-separator~). 1222 1223 For all prompts, the ~denote-rename-file~ interprets an empty input as 1224 an instruction to remove that file name component. For example, if a 1225 =TITLE= prompt is available and =FILE= is =20240211T093531--some-title__keyword1.org= 1226 then it renames =FILE= to =20240211T093531__keyword1.org=. If a file 1227 name component is present, but there is no entry for it in 1228 ~denote-prompts~, keep it as-is. 1229 1230 [ NOTE: Please check with your minibuffer user interface how to 1231 provide an empty input. The Emacs default setup accepts the empty 1232 minibuffer contents as they are, though popular packages like 1233 ~vertico~ use the first available completion candidate instead. For 1234 ~vertico~, the user must either move one up to select the prompt and 1235 then type =RET= there with empty contents, or use the command 1236 ~vertico-exit-input~ with empty contents. That Vertico command is 1237 bound to =M-RET= as of this writing on 2024-02-13 08:08 +0200. ] 1238 1239 When renaming =FILE=, the command reads its file type extension (like 1240 =.org=) and preserves it through the renaming process. Files that have 1241 no extension are left without one. 1242 1243 As a final step, it asks for confirmation, showing the difference 1244 between old and new file names. It does not ask for confirmation if 1245 the user option ~denote-rename-no-confirm~ is set to a non-nil value 1246 ([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ option]]). 1247 1248 If =FILE= has front matter for =TITLE= and =KEYWORDS=, 1249 ~denote-rename-file~ asks to rewrite their values in order to reflect 1250 the new input, unless ~denote-rename-no-confirm~ is non-nil. When the 1251 ~denote-rename-no-confirm~ is nil (the default), the underlying buffer 1252 is not saved, giving the user the change to invoking ~diff-buffer-with-file~ to 1253 double-check the effect. The rewrite of the =TITLE= and =KEYWORDS= in 1254 the front matter should not affect the rest of the front matter. 1255 1256 If the file does not have front matter but is among the supported file 1257 types (per ~denote-file-type~), the ~denote-rename-file~ adds front 1258 matter to the top of it and leaves the buffer unsaved for further 1259 inspection. It actually saves the buffer if ~denote-rename-no-confirm~ 1260 is non-nil ([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]). 1261 1262 This command is intended to (i) rename Denote files, (ii) convert 1263 existing supported file types to Denote notes, and (ii) rename 1264 non-note files (e.g. =PDF=) that can benefit from Denote's file-naming 1265 scheme. 1266 1267 For a version of this command that works with multiple files 1268 one-by-one, use ~denote-dired-rename-files~ ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files interactively]]). 1269 1270 *** The ~denote-rename-no-confirm~ option 1271 :PROPERTIES: 1272 :CUSTOM_ID: h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7 1273 :END: 1274 1275 #+vindex: denote-rename-no-confirm 1276 The user option ~denote-rename-no-confirm~ makes all commands that 1277 rename files not prompt for confirmation and save buffers outright ([[#h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca][Renaming files]]). 1278 1279 This affects the behaviour of the commands ~denote-rename-file~, 1280 ~denote-dired-rename-files~, ~denote-rename-file-using-front-matter~, 1281 ~denote-dired-rename-marked-files-with-keywords~, 1282 ~denote-dired-rename-marked-files-using-front-matter~, 1283 ~denote-keywords-add~, ~denote-keywords-remove~, and any other command 1284 that builds on top of them. 1285 1286 The default behaviour of the ~denote-rename-file~ command (and others 1287 like it) is to ask for an affirmative answer as a final step before 1288 changing the file name and, where relevant, inserting or updating the 1289 corresponding front matter. It also does not save the affected file's 1290 buffer to let the user inspect and confirm the changes (such as by 1291 invoking the command ~diff-buffer-with-file~). 1292 1293 With this user option bound to a non-nil value, buffers are saved as 1294 well. The assumption is that the user who opts in to this feature is 1295 familiar with the ~denote-rename-file~ (or related) operation and 1296 knows it is reliable. 1297 1298 Specialised commands that build on top of ~denote-rename-file~ (or 1299 related) may internally bind this user option to a non-nil value in 1300 order to perform their operation (e.g. ~denote-dired-rename-files~ 1301 goes through each marked Dired file, prompting for the information to 1302 use, but carries out the renaming without asking for confirmation 1303 ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files interactively]])). 1304 1305 ** Rename a single file based on its front matter 1306 :PROPERTIES: 1307 :CUSTOM_ID: h:3ab08ff4-81fa-4d24-99cb-79f97c13a373 1308 :END: 1309 1310 #+findex: denote-rename-file-using-front-matter 1311 In the previous section, we covered the more general mechanism of the 1312 command ~denote-rename-file~ ([[#h:7cc9e000-806a-48da-945c-711bbc7426b0][Rename a single file]]). There is also a 1313 way to have the same outcome by making Denote read the data in the 1314 current file's front matter and use it to construct/update the file 1315 name. The command for this is ~denote-rename-file-using-front-matter~. 1316 It is only relevant for files that (i) are among the supported file 1317 types, per ~denote-file-type~, and (ii) have the requisite front matter 1318 in place. 1319 1320 Suppose you have an =.org= file with this front matter ([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]): 1321 1322 #+begin_example 1323 #+title: My sample note file 1324 #+date: [2022-08-05 Fri 13:10] 1325 #+filetags: :testing: 1326 #+identifier: 20220805T131044 1327 #+end_example 1328 1329 Its file name reflects this information: 1330 1331 : 20220805T131044--my-sample-note-file__testing.org 1332 1333 You want to change its title and keywords manually, so you modify it thus: 1334 1335 #+begin_example 1336 #+title: My modified sample note file 1337 #+date: [2022-08-05 Fri 13:10] 1338 #+filetags: :testing:denote:emacs: 1339 #+identifier: 20220805T131044 1340 #+end_example 1341 1342 At this stage, the file name still shows the old title and keywords. 1343 You now invoke ~denote-rename-file-using-front-matter~ and it updates 1344 the file name to: 1345 1346 : 20220805T131044--my-modified-sample-note-file__testing_denote_emacs.org 1347 1348 The renaming is subject to a "yes or no" prompt that shows the old and 1349 new names, just so the user is certain about the change. 1350 1351 If called interactively with a prefix argument (=C-u= by default) or 1352 from Lisp with a non-nil =NO-CONFIRM= argument, this "yes or no" 1353 prompt is skipped and the renaming is done outright. 1354 1355 If called interactively with a double prefix argument (=C-u C-u= by 1356 default) or from Lisp with a non-nil =SAVE-BUFFER= argument, the 1357 buffer is saved after the front matter is updated and the file is 1358 renamed. 1359 1360 If the user option ~denote-rename-no-confirm~ is non-nil, it is 1361 interpreted the same way as a combination of =NO-CONFIRM= and 1362 =SAVE-BUFFER= ([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ option]]). 1363 1364 The identifier of the file, if any, is never modified even if it is 1365 edited in the front matter: Denote considers the file name to be the 1366 source of truth in this case, to avoid potential breakage with typos and 1367 the like. 1368 1369 ** Rename multiple files interactively 1370 :PROPERTIES: 1371 :CUSTOM_ID: h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde 1372 :END: 1373 1374 #+findex: denote-dired-rename-files 1375 #+findex: denote-dired-rename-marked-files 1376 The command ~denote-dired-rename-files~ (alias 1377 ~denote-dired-rename-marked-files~) renames the files that are 1378 marked in a Dired buffer. Its behaviour is similar to the 1379 ~denote-rename-file~ in that it prompts for a title, keywords, and 1380 signature ([[#h:7cc9e000-806a-48da-945c-711bbc7426b0][Rename a single file]]). It does so over each marked file, 1381 renaming one after the other. 1382 1383 Unlike ~denote-rename-file~, the command ~denote-dired-rename-files~ 1384 does not ask to confirm the changes made to the files: it performs 1385 them outright. This is done to make it easier to rename multiple files 1386 without having to confirm each step. For an even more direct approach, 1387 check the command ~denote-dired-rename-marked-files-with-keywords~. 1388 1389 - [[#h:f365ff7e-2140-4e14-a92f-666ae97382a4][Rename by writing only keywords]] 1390 - [[#h:ea5673cd-e6ca-4c42-a066-07dc6c9d57f8][Rename multiple files based on their front matter]] 1391 1392 ** Rename multiple files at once by asking only for keywords 1393 :PROPERTIES: 1394 :CUSTOM_ID: h:f365ff7e-2140-4e14-a92f-666ae97382a4 1395 :END: 1396 1397 #+findex: denote-dired-rename-marked-files-with-keywords 1398 The ~denote-dired-rename-marked-files-with-keywords~ command renames 1399 marked files in Dired to conform with our file-naming scheme. It does 1400 so by writing keywords to them. Specifically, it does the following: 1401 1402 - retains the file's existing name and makes it the =TITLE= field, per 1403 Denote's file-naming scheme; 1404 1405 - sluggifies the =TITLE= and adjusts its letter casing, according to 1406 our conventions; 1407 1408 - prepends an identifier to the =TITLE=, if one is missing; 1409 1410 - preserves the file's extension, if any; 1411 1412 - prompts once for =KEYWORDS= and applies the user's input to the 1413 corresponding field in the file name, rewriting any keywords that 1414 may exist while removing keywords that do exist if =KEYWORDS= is 1415 empty; 1416 1417 - adds or rewrites existing front matter to the underlying file, if it 1418 is recognized as a Denote note (per the ~denote-file-type~ user 1419 option), such that it includes the new keywords. 1420 1421 [ Note that the affected buffers are not saved, unless the user option 1422 ~denote-rename-no-confirm~ is non-nil. Users can thus check them to 1423 confirm that the new front matter does not cause any problems (e.g. 1424 with the ~diff-buffer-with-file~ command). Multiple buffers can be 1425 saved in one go with the command ~save-some-buffers~ (read its doc 1426 string). ] 1427 1428 ** Rename multiple files based on their front matter 1429 :PROPERTIES: 1430 :CUSTOM_ID: h:ea5673cd-e6ca-4c42-a066-07dc6c9d57f8 1431 :END: 1432 1433 #+findex: denote-dired-rename-marked-files-using-front-matter 1434 As already noted, Denote can rename a file based on the data in its 1435 front matter ([[#h:3ab08ff4-81fa-4d24-99cb-79f97c13a373][Rename a single file based on its front matter]]). The 1436 command ~denote-dired-rename-marked-files-using-front-matter~ extends 1437 this principle to a batch operation which applies to all marked files in 1438 Dired. 1439 1440 Marked files must count as notes for the purposes of Denote, which 1441 means that they at least have an identifier in their file name and use 1442 a supported file type, per ~denote-file-type~. Files that do not meet 1443 this criterion are ignored, because Denote cannot know if they have 1444 front matter and what that may be. For such files, it is still 1445 possible to rename them interactively ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files interactively]]). 1446 1447 ** Rename a file by changing only its file type 1448 :PROPERTIES: 1449 :CUSTOM_ID: h:85b65995-89fd-4978-bba3-7bb6c8d6f945 1450 :END: 1451 1452 #+findex: denote-change-file-type-and-front-matter 1453 The command ~denote-change-file-type-and-front-matter~ provides the 1454 convenience of converting a note taken in one file type, say, =.txt= 1455 into another like =.org=. It presents a choice among the 1456 ~denote-file-type~ options. 1457 1458 The conversion does NOT modify the existing front matter. Instead, it 1459 prepends new front matter to the top of the file. We do this as a 1460 safety precaution since the user can, in principle, add arbitrary 1461 extras to their front matter that we would not want to touch. 1462 1463 If in Dired, ~denote-change-file-type-and-front-matter~ operates on 1464 the file at point, else it prompts with minibuffer completion for one. 1465 1466 The title of the file is retrieved from a line starting with a title 1467 field in the file's front matter, depending on the previous file type 1468 (e.g. =#+title= for Org). The same process applies for keywords. 1469 1470 As a final step, the command asks for confirmation, showing the 1471 difference between old and new file names. 1472 1473 ** Rename a file by adding or removing keywords interactively 1474 :PROPERTIES: 1475 :CUSTOM_ID: h:ad4dde4a-8e88-470a-97ae-e7b9d4b41fb4 1476 :END: 1477 1478 #+findex: denote-keywords-add 1479 #+findex: denote-keywords-remove 1480 The commands ~denote-keywords-add~ and ~denote-keywords-remove~ 1481 streamline the process of interactively updating a file's keywords in 1482 the front matter and renaming it accordingly. 1483 1484 The ~denote-keywords-add~ asks for keywords using the familiar 1485 minibuffer prompt ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). It then renames the file 1486 ([[#h:3ab08ff4-81fa-4d24-99cb-79f97c13a373][Rename a single file based on its front matter]]). 1487 1488 Similarly, the ~denote-keywords-remove~ removes one or more keywords 1489 from the list of existing keywords and then renames the file 1490 accordingly. 1491 1492 Both commands accept an optional prefix argument to automatically save 1493 the buffer. Similarly, they both interpret a non-nil value for the 1494 user option ~denote-rename-no-confirm~ the same as the prefix argument 1495 ([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ option]]). 1496 1497 Furthermore, both commands call the ~denote-after-rename-file-hook~ as 1498 a final step after carrying out their task. 1499 1500 #+findex: denote-rename-add-keywords 1501 #+findex: denote-rename-remove-keywords 1502 Aliases for these commands are: ~denote-rename-add-keywords~ and 1503 ~denote-rename-remove-keywords~. 1504 1505 ** Rename a file by adding or removing a signature interactively 1506 :PROPERTIES: 1507 :CUSTOM_ID: h:b08a350f-b269-47ed-8c2a-b8ecf1b63c7f 1508 :END: 1509 1510 #+findex: denote-rename-add-signature 1511 #+findex: denote-rename-remove-signature 1512 The commands ~denote-rename-add-signature~ and 1513 ~denote-rename-remove-signature~ streamline the process of 1514 interactively adding or removing a signature from a given file ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 1515 1516 The ~denote-rename-add-signature~ prompts for a file and a signature. The 1517 default value for the file prompt is the file of the currently open 1518 buffer or the file-at-point in a Dired buffer. The signature is an 1519 ordinary string, defaulting to the selected file's signature, if any. 1520 1521 The ~denote-rename-remove-signature~ uses the same file prompt as 1522 above. It performs its action only if the selected file has a 1523 signature. Otherwise, it does nothing. 1524 1525 Both commands ask for confirmation before carrying out their action. 1526 They do so unless the user option ~denote-rename-no-confirm~ is set to 1527 a non-nil value ([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ option]]). They also 1528 both take care to reload any Dired buffers and run the 1529 ~denote-after-rename-file-hook~ as a final step. 1530 1531 ** Faces used by rename commands 1532 :PROPERTIES: 1533 :CUSTOM_ID: h:ab3f355a-f763-43ae-a4c9-179d2d9265a5 1534 :END: 1535 1536 These are the faces used by the various Denote rename commands to 1537 style or highlight the old/new/current file shown in the relevant 1538 minibuffer prompts: 1539 1540 - ~denote-faces-prompt-current-name~ 1541 - ~denote-faces-prompt-new-name~ 1542 - ~denote-faces-prompt-old-name~ 1543 1544 * The file-naming scheme 1545 :PROPERTIES: 1546 :CUSTOM_ID: h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d 1547 :END: 1548 1549 #+vindex: denote-directory 1550 Notes are stored in the ~denote-directory~. The default path is 1551 =~/Documents/notes=. The ~denote-directory~ can be a flat listing, 1552 meaning that it has no subdirectories, or it can be a directory tree. 1553 Either way, Denote takes care to only consider "notes" as valid 1554 candidates in the relevant operations and will omit other files or 1555 directories. 1556 1557 Every note produced by Denote follows this pattern by default 1558 ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]): 1559 1560 : DATE==SIGNATURE--TITLE__KEYWORDS.EXTENSION 1561 1562 The =DATE= field represents the date in year-month-day format followed 1563 by the capital letter =T= (for "time") and the current time in 1564 hour-minute-second notation. The presentation is compact: 1565 =20220531T091625=. The =DATE= serves as the unique identifier of each 1566 note and, as such, is also known as the file's ID or identifier. 1567 1568 File names can include a string of alphanumeric characters in the 1569 =SIGNATURE= field. Signatures have no clearly defined purpose and are up 1570 to the user to define. One use-case is to use them to establish 1571 sequential relations between files (e.g. 1, 1a, 1b, 1b1, 1b2, ...). 1572 1573 Signatures are an optional extension to Denote's file-naming scheme. 1574 They can be added to newly created files on demand, with the command 1575 ~denote-signature~, or by modifying the value of the user option 1576 ~denote-prompts~. 1577 1578 The =TITLE= field is the title of the note, as provided by the user. 1579 It automatically gets downcased by default and is also hyphenated 1580 ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). An entry about "Economics 1581 in the Euro Area" produces an =economics-in-the-euro-area= string for 1582 the =TITLE= of the file name. 1583 1584 The =KEYWORDS= field consists of one or more entries demarcated by an 1585 underscore (the separator is inserted automatically). Each keyword is 1586 a string provided by the user at the relevant prompt which broadly 1587 describes the contents of the entry. 1588 1589 Each of the keywords is a single word, with multiple keywords providing 1590 the multi-dimensionality needed for advanced searches through Denote 1591 files. Users who need to compose a keyword out of multiple words such 1592 as camelCase/CamelCase and are encouraged to use the 1593 ~denote-file-name-slug-functions~ user option accordingly 1594 ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). 1595 1596 #+vindex: denote-file-type 1597 The =EXTENSION= is the file type. By default, it is =.org= (~org-mode~) 1598 though the user option ~denote-file-type~ provides support for Markdown 1599 with YAML or TOML variants (=.md= which runs ~markdown-mode~) and plain 1600 text (=.txt= via ~text-mode~). Consult its doc string for the minutiae. 1601 While files end in the =.org= extension by default, the Denote code base 1602 does not actually depend on org.el and/or its accoutrements. 1603 1604 Examples: 1605 1606 : 20220610T043241--initial-thoughts-on-the-zettelkasten-method__notetaking.org 1607 : 20220610T062201--define-custom-org-hyperlink-type__denote_emacs_package.md 1608 : 20220610T162327--on-hierarchy-and-taxis__notetaking_philosophy.txt 1609 1610 The different field separators, namely =--= and =__= introduce an 1611 efficient way to anchor searches (such as with Emacs commands like 1612 ~isearch~ or from the command-line with ~find~ and related). A query 1613 for =_word= always matches a keyword, while a regexp in the form of, 1614 say, ="\\([0-9T]+?\\)--\\(.*?\\)_"= captures the date in group =\1= and 1615 the title in =\2= (test any regular expression in the current buffer by 1616 invoking =M-x re-builder=). 1617 1618 [[#h:1a953736-86c2-420b-b566-fb22c97df197][Features of the file-naming scheme for searching or filtering]]. 1619 1620 The ~denote-prompts~ can be configured in such ways to yield the 1621 following file name permutations: 1622 1623 : DATE.EXT 1624 : DATE--TITLE.EXT 1625 : DATE__KEYWORDS.EXT 1626 : DATE==SIGNATURE.EXT 1627 : DATE==SIGNATURE--TITLE.EXT 1628 : DATE==SIGNATURE--TITLE__KEYWORDS.EXT 1629 : DATE==SIGNATURE__KEYWORDS.EXT 1630 1631 When in doubt, stick to the default design. 1632 1633 While Denote is an Emacs package, notes should work long-term and not 1634 depend on the functionality of a specific program. The file-naming 1635 scheme we apply guarantees that a listing is readable in a variety of 1636 contexts. The Denote file-naming scheme is, in essence, an effective, 1637 low-tech invention. 1638 1639 ** Sluggification of file name components 1640 :PROPERTIES: 1641 :CUSTOM_ID: h:ae8b19a1-7f67-4258-96b3-370a72c43f4e 1642 :END: 1643 1644 Files names can contain any character that the file system 1645 permits. Denote imposes a few additional restrictions: 1646 1647 + The tokens "==", =__= and =--= are interpreted by Denote and should 1648 appear only once. 1649 1650 + The dot character is not allowed in a note's file name, except to 1651 indicate the file type extension. Denote recognises two extensions 1652 for encrypted files, like =.txt.gpg=. 1653 1654 By default, Denote enforces other rules to file names through the user 1655 option ~denote-file-name-slug-functions~. These rules are applied to 1656 file names by default: 1657 1658 + What we count as "illegal characters" are removed. The constant 1659 ~denote-excluded-punctuation-regexp~ holds the relevant value. 1660 1661 + Input for a file title is hyphenated. The original value is 1662 preserved in the note's contents ([[#h:13218826-56a5-482a-9b91-5b6de4f14261][Front matter]]). 1663 1664 + Spaces or other delimiters are removed from keywords, meaning that 1665 =hello-world= becomes =helloworld=. This is because hyphens in 1666 keywords do not work everywhere, such as in Org. Plus, hyphens are 1667 word separators in the title and we want to keep distinct separators 1668 for each component to make search easier and semantic 1669 ([[#h:1a953736-86c2-420b-b566-fb22c97df197][Features of the file-naming scheme for searching or filtering]]). 1670 1671 + Signatures are like the above, but use the equals sign instead of 1672 hyphens as a word separator. 1673 1674 + All file name components are downcased. Further down we document how 1675 to deviate from these rules, such as to accept input of the form 1676 =helloWorld= or =HelloWorld= verbatim. 1677 1678 Denote imposes these restrictions to enforce uniformity, which is 1679 helpful long-term as it keeps all files with the same predictable 1680 pattern. Too many permutations make searches more difficult to express 1681 accurately and be confident that the matches cover all files. 1682 Nevertheless, one of the principles of Denote is its flexibility or 1683 hackability and so users can deviate from the aforementioned 1684 ([[#h:d375c6d2-92c7-425f-9d9d-219ff47ed2a3][User-defined sluggification of file name components]]). 1685 1686 ** User-defined sluggification of file name components 1687 :PROPERTIES: 1688 :CUSTOM_ID: h:d375c6d2-92c7-425f-9d9d-219ff47ed2a3 1689 :END: 1690 1691 #+vindex: denote-file-name-slug-functions 1692 The user option ~denote-file-name-slug-functions~ controls the 1693 sluggification of file name components ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). 1694 The default method is outlined above and in the previous section 1695 ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 1696 1697 The value of this user option is an alist where each element is a cons 1698 cell of the form =(COMPONENT . METHOD)=. For example, here is the 1699 default value: 1700 1701 #+begin_example emacs-lisp 1702 '((title . denote-sluggify-title) 1703 (signature . denote-sluggify-signature) 1704 (keyword . denote-sluggify-keyword)) 1705 #+end_example 1706 1707 - The =COMPONENT= is an unquoted symbol among =title=, =signature=, 1708 =keyword=, which refers to the corresponding component of the file 1709 name. 1710 1711 - The =METHOD= is a function to format the given component. This 1712 function must take a string as its parameter and return the string 1713 formatted for the file name. Note that even in the case of the 1714 =keyword= component, the function receives one string representing a 1715 single keyword and returns it formatted for the file name. Joining 1716 the keywords together is handled internally by Denote. 1717 1718 One commonly requested deviation from the sluggification rules is to 1719 not sluggify individual keywords, such that the user's input is taken 1720 as-is. This can be done as follows: 1721 1722 #+begin_src emacs-lisp 1723 (setq denote-file-name-slug-functions 1724 '((title . denote-sluggify-title) 1725 (keyword . identity) 1726 (signature . denote-sluggify-signature))) 1727 #+end_src 1728 1729 The ~identity~ function simply returns the string it receives, thus 1730 not altering it in any way. 1731 1732 Another approach is to keep the sluggification but not downcase the 1733 string. We can do this by modifying the original functions used by 1734 Denote. For example, we have this: 1735 1736 #+begin_src emacs-lisp 1737 ;; The original function for reference 1738 (defun denote-sluggify-title (str) 1739 "Make STR an appropriate slug for title." 1740 (downcase (denote--slug-hyphenate (denote--slug-no-punct str)))) 1741 1742 ;; Our variant of the above, which does the same thing except from 1743 ;; downcasing the string. 1744 (defun my-denote-sluggify-title (str) 1745 "Make STR an appropriate slug for title." 1746 (denote--slug-hyphenate (denote--slug-no-punct str))) 1747 1748 ;; Now we use our function to sluggify titles without affecting their 1749 ;; letter casing. 1750 (setq denote-file-name-slug-functions 1751 '((title . my-denote-sluggify-title) ; our function here 1752 (signature . denote-sluggify-signature) 1753 (keyword . denote-sluggify-keyword))) 1754 #+end_src 1755 1756 Follow this principle for all the sluggification functions. 1757 1758 To access the source code, use either of the following built-in 1759 methods: 1760 1761 1. Call the command ~find-library~ and search for ~denote~. Then 1762 navigate to the symbol you are searching for. 1763 1764 2. Invoke the command ~describe-symbol~, search for the symbol you are 1765 interested in, and from the resulting Help buffer either click on 1766 the first link or do =M-x help-view-source= (bound to =s= in Help 1767 buffers, by default). 1768 1769 Remember that deviating from the default file-naming scheme of Denote 1770 will make things harder to use in the future, as files can/will have 1771 permutations that create uncertainty. The sluggification scheme and 1772 concomitant restrictions we impose by default are there for a very 1773 good reason: they are the distillation of years of experience. Here we 1774 give you what you wish, but bear in mind it may not be what you need. 1775 You have been warned. 1776 1777 ** Features of the file-naming scheme for searching or filtering 1778 :PROPERTIES: 1779 :CUSTOM_ID: h:1a953736-86c2-420b-b566-fb22c97df197 1780 :END: 1781 1782 By default, file names have three fields and two sets of field 1783 delimiters between them: 1784 1785 : DATE--TITLE__KEYWORDS.EXTENSION 1786 1787 When a signature is present, this becomes: 1788 1789 : DATE==SIGNATURE--TITLE__KEYWORDS.EXTENSION 1790 1791 Field delimiters practically serve as anchors for easier searching. 1792 Consider this example: 1793 1794 : 20220621T062327==1a2--introduction-to-denote__denote_emacs.txt 1795 1796 You will notice that there are two matches for the word =denote=: one 1797 in the title field and another in the keywords' field. Because of the 1798 distinct field delimiters, if we search for =-denote= we only match 1799 the first instance while =_denote= targets the second one. When 1800 sorting through your notes, this kind of specificity is 1801 invaluable---and you get it for free from the file names alone! 1802 Similarly, a search for ==1= will show all notes that are related to 1803 each other by virtue of their signature. 1804 1805 Users can get a lot of value out of this simple yet effective 1806 arrangement, even if they have no knowledge of regular expressions. 1807 One thing to consider, for maximum effect, is to avoid using 1808 multi-word keywords as those can get hyphenated like the title and 1809 will thus interfere with the above: either set the user option 1810 ~denote-allow-multi-word-keywords~ to nil or simply insert single 1811 words at the relevant prompts. 1812 1813 * Front matter 1814 :PROPERTIES: 1815 :CUSTOM_ID: h:13218826-56a5-482a-9b91-5b6de4f14261 1816 :END: 1817 1818 Notes have their own "front matter". This is a block of data at the top 1819 of the file, with no empty lines between the entries, which is 1820 automatically generated at the creation of a new note. The front matter 1821 includes the title and keywords (aka "tags" or "filetags", depending on 1822 the file type) which the user specified at the relevant prompt, as well 1823 as the date and unique identifier, which are derived automatically. 1824 1825 This is how it looks for Org mode (when ~denote-file-type~ is nil or the 1826 =org= symbol): 1827 1828 #+begin_example 1829 #+title: This is a sample note 1830 #+date: [2022-06-30 Thu 16:09] 1831 #+filetags: :denote:testing: 1832 #+identifier: 20220630T160934 1833 #+end_example 1834 1835 For Markdown with YAML (~denote-file-type~ has the =markdown-yaml= 1836 value), the front matter looks like this: 1837 1838 #+begin_example 1839 --- 1840 title: "This is a sample note" 1841 date: 2022-06-30T16:09:58+03:00 1842 tags: ["denote", "testing"] 1843 identifier: "20220630T160958" 1844 --- 1845 #+end_example 1846 1847 For Markdown with TOML (~denote-file-type~ has the =markdown-toml= 1848 value), it is: 1849 1850 #+begin_example 1851 +++ 1852 title = "This is a sample note" 1853 date = 2022-06-30T16:10:13+03:00 1854 tags = ["denote", "testing"] 1855 identifier = "20220630T161013" 1856 +++ 1857 #+end_example 1858 1859 And for plain text (~denote-file-type~ has the =text= value), we have 1860 the following: 1861 1862 #+begin_example 1863 title: This is a sample note 1864 date: 2022-06-30 1865 tags: denote testing 1866 identifier: 20220630T161028 1867 --------------------------- 1868 #+end_example 1869 1870 #+vindex: denote-date-format 1871 The format of the date in the front matter is controlled by the user 1872 option ~denote-date-format~. When nil, Denote uses a file-type-specific 1873 format: 1874 1875 - For Org, an inactive timestamp is used, such as 1876 =[2022-06-30 Wed 15:31]=. 1877 1878 - For Markdown, the RFC3339 standard is applied: 1879 =2022-06-30T15:48:00+03:00=. 1880 1881 - For plain text, the format is that of ISO 8601: =2022-06-30=. 1882 1883 If the value is a string, ignore the above and use it instead. The 1884 string must include format specifiers for the date. These are described 1885 in the doc string of ~format-time-string~.. 1886 1887 ** Change the front matter format 1888 :PROPERTIES: 1889 :CUSTOM_ID: h:7f918854-5ed4-4139-821f-8ee9ba06ad15 1890 :END: 1891 1892 Per Denote's design principles, the code is hackable. All front matter 1893 is stored in variables that are intended for public use. We do not 1894 declare those as "user options" because (i) they expect the user to have 1895 some degree of knowledge in Emacs Lisp and (ii) implement custom code. 1896 1897 [ NOTE for tinkerers: code intended for internal use includes double 1898 hyphens in its symbol. "Internal use" means that it can be changed 1899 without warning and with no further reference in the change log. Do 1900 not use any of it without understanding the consequences. ] 1901 1902 The variables which hold the front matter format are: 1903 1904 #+vindex: denote-org-front-matter 1905 - ~denote-org-front-matter~ 1906 1907 #+vindex: denote-text-front-matter 1908 - ~denote-text-front-matter~ 1909 1910 #+vindex: denote-toml-front-matter 1911 - ~denote-toml-front-matter~ 1912 1913 #+vindex: denote-yaml-front-matter 1914 - ~denote-yaml-front-matter~ 1915 1916 These variables have a string value with specifiers that are used by the 1917 ~format~ function. The formatting operation passes four arguments which 1918 include the values of the given entries. If you are an advanced user 1919 who wants to edit this variable to affect how front matter is produced, 1920 consider using something like =%2$s= to control where the Nth argument 1921 is placed. 1922 1923 When editing the value, make sure to: 1924 1925 1. Not use empty lines inside the front matter block. 1926 1927 2. Insert at least one empty line after the front matter block and do 1928 not use any empty line before it. 1929 1930 These help with consistency and might prove useful if we ever need to 1931 operate on the front matter as a whole. 1932 1933 With those granted, below are some examples. The approach is the same 1934 for all variables. 1935 1936 #+begin_src emacs-lisp 1937 ;; Like the default, but upcase the entries 1938 (setq denote-org-front-matter 1939 "#+TITLE: %s 1940 #+DATE: %s 1941 #+FILETAGS: %s 1942 #+IDENTIFIER: %s 1943 \n") 1944 1945 ;; Change the order (notice the %N$s notation) 1946 (setq denote-org-front-matter 1947 "#+title: %1$s 1948 #+filetags: %3$s 1949 #+date: %2$s 1950 #+identifier: %4$s 1951 \n") 1952 1953 ;; Remove the date 1954 (setq denote-org-front-matter 1955 "#+title: %1$s 1956 #+filetags: %3$s 1957 #+identifier: %4$s 1958 \n") 1959 1960 ;; Remove the date and the identifier 1961 (setq denote-org-front-matter 1962 "#+title: %1$s 1963 #+filetags: %3$s 1964 \n") 1965 #+end_src 1966 1967 Note that ~setq~ has a global effect: it affects the creation of all new 1968 notes. Depending on the workflow, it may be preferrable to have a 1969 custom command which ~let~ binds the different format. We shall not 1970 provide examples at this point as this is a more advanced feature and we 1971 are not yet sure what the user's needs are. Please provide feedback and 1972 we shall act accordingly. 1973 1974 ** Regenerate front matter 1975 :PROPERTIES: 1976 :CUSTOM_ID: h:54b48277-e0e5-4188-ad54-ef3db3b7e772 1977 :END: 1978 1979 #+findex: denote-add-front-matter 1980 Sometimes the user needs to produce new front matter for an existing 1981 note. Perhaps because they accidentally deleted a line and could not 1982 undo the operation. The command ~denote-add-front-matter~ can be used 1983 for this very purpose. 1984 1985 In interactive use, ~denote-add-front-matter~ must be invoked from a 1986 buffer that visits a Denote note. It prompts for a title and then for 1987 keywords. These are the standard prompts we already use for note 1988 creation, so the keywords' prompt allows minibuffer completion and the 1989 input of multiple entries, each separated by a comma ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). 1990 1991 The newly created front matter is added to the top of the file. 1992 1993 This command does not rename the file (e.g. to update the keywords). To 1994 rename a file by reading its front matter as input, the user can rely on 1995 ~denote-rename-file-using-front-matter~ ([[#h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca][Renaming files]]). 1996 1997 Note that ~denote-add-front-matter~ is useful only for existing Denote 1998 notes. If the user needs to convert a generic text file to a Denote 1999 note, they can use one of the command which first rename the file to 2000 make it comply with our file-naming scheme and then add the relevant 2001 front matter. 2002 2003 * Linking notes 2004 :PROPERTIES: 2005 :CUSTOM_ID: h:fc913d54-26c8-4c41-be86-999839e8ad31 2006 :END: 2007 2008 Denote offers several commands for linking between notes. 2009 2010 All links target files which are Denote files. This means that they 2011 have our file-naming scheme. Files need to be inside the 2012 ~denote-directory~ or one of its subdirectories. No other file is 2013 recognised. 2014 2015 The following sections delve into the details. 2016 2017 ** Adding a single link 2018 :PROPERTIES: 2019 :CUSTOM_ID: h:5e5e3370-12ab-454f-ba09-88ff44214324 2020 :END: 2021 2022 #+findex: denote-link 2023 The ~denote-link~ command inserts a link at point to a file specified 2024 at the minibuffer prompt ([[#h:d99de1fb-b1b7-4a74-8667-575636a4d6a4][The ~denote-org-store-link-to-heading~ user option]]). 2025 Links are formatted depending on the file type of the current note. In 2026 Org and plain text buffers, links are formatted thus: 2027 =[[denote:IDENTIFIER][DESCRIPTION]]=. While in Markdown they are expressed 2028 as =[DESCRIPTION](denote:IDENTIFIER)=. 2029 2030 When ~denote-link~ is called with a prefix argument (=C-u= by 2031 default), it formats links like =[[denote:IDENTIFIER]]=. The user 2032 might prefer its simplicity. 2033 2034 By default, the description of the link is taken from the signature of 2035 the file, if present, and the target file's front matter's title or, if 2036 that is not available, from the file name. If the region is active, its 2037 text is used as the link's description instead. If the active region 2038 has no text, the inserted link uses just the identifier, as with the 2039 =C-u= prefix mentioned above. 2040 2041 Inserted links are automatically buttonized and remain active for as 2042 long as the buffer is available. In Org this is handled by the major 2043 mode: the =denote:= hyperlink type works exactly like the standard 2044 =file:=. In Markdown and plain text, Denote performs the buttonization 2045 of those links. To buttonize links in existing files while visiting 2046 them, the user must add this snippet to their setup (it already excludes 2047 Org): 2048 2049 #+findex: denote-link-buttonize-buffer 2050 #+begin_src emacs-lisp 2051 (add-hook 'find-file-hook #'denote-link-buttonize-buffer) 2052 #+end_src 2053 2054 The ~denote-link-buttonize-buffer~ is also an interactive function in 2055 case the user needs it. 2056 2057 Links are created only for files which qualify as a "note" for our 2058 purposes ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). 2059 2060 #+vindex: denote-faces-link 2061 Links are styled with the ~denote-faces-link~ face, which looks exactly 2062 like an ordinary link by default. This is just a convenience for the 2063 user/theme in case they want =denote:= links to remain distinct from 2064 other links. 2065 2066 #+findex: denote-link-markdown-follow 2067 In files whose major mode is ~markdown-mode~, the default key binding 2068 =C-c C-o= (which calls the command ~markdown-follow-thing-at-point~) 2069 correctly resolves =denote:= links. This method works in addition to 2070 the =RET= key, which is made available by the aforementioned 2071 buttonization. Interested users can refer to the function 2072 ~denote-link-markdown-follow~ for the implementation details. 2073 2074 ** The ~denote-org-store-link-to-heading~ user option 2075 :PROPERTIES: 2076 :CUSTOM_ID: h:d99de1fb-b1b7-4a74-8667-575636a4d6a4 2077 :END: 2078 2079 #+vindex: denote-org-store-link-to-heading 2080 The user option ~denote-org-store-link-to-heading~ determines whether 2081 ~org-store-link~ links to the current Org heading (such links are 2082 merely "stored" and need to be inserted afterwards with the command 2083 ~org-insert-link~). Note that the ~org-capture~ command uses the 2084 ~org-link~ internally if it has to store a link. 2085 2086 When its value is non-nil, ~org-store-link~ stores a link to the 2087 current Org heading inside the Denote Org file. If the heading does 2088 not have a =CUSTOM_ID=, it creates it and includes it in the heading's 2089 =PROPERTIES= drawer. If a =CUSTOM_ID= exists, ~org-store-link~ use it 2090 as-is. 2091 2092 This makes the resulting link a combination of the =denote:= link type, 2093 pointing to the identifier of the current file, plus the value of the 2094 heading's =CUSTOM_ID=, such as: 2095 2096 - =[[denote:20240118T060608][Some test]]= 2097 - =[[denote:20240118T060608::#h:eed0fb8e-4cc7-478f-acb6-f0aa1a8bffcd][Some test::Heading text]]= 2098 2099 Both lead to the same Denote file, but the latter jumps to the heading 2100 with the given =CUSTOM_ID=. Notice that the link to the heading also 2101 has a different description, which includes the heading text. 2102 2103 The value of the =CUSTOM_ID= is determined by the Org user option 2104 ~org-id-method~. The sample shown above uses the default UUID 2105 infrastructure. 2106 2107 If ~denote-org-store-link-to-heading~ is set to a nil value, the 2108 command ~org-store-link~ only stores links to the Denote file (using 2109 its identifier), but not to the given heading. This is what Denote was 2110 doing in versions prior to =2.3.0=. 2111 2112 Note that the optional extension =denote-org-extras.el= defines the command 2113 ~denote-org-extras-link-to-heading~, which always links to a file+heading 2114 regardless of the aforementioned user option ([[#h:fc1ad245-ec08-41be-8d1e-7153d99daf02][Insert link to an Org file with a further pointer to a heading]]). 2115 2116 [ This feature only works in Org mode files, as other file types do 2117 not have a linking mechanism that handles unique identifiers for 2118 headings or other patterns to jump to. If ~org-store-link~ is 2119 invoked in one such file, it captures only the Denote identifier of 2120 the file, even if this user option is set to a non-nil value. ] 2121 2122 ** Insert link to an Org file with a further pointer to a heading 2123 :PROPERTIES: 2124 :CUSTOM_ID: h:fc1ad245-ec08-41be-8d1e-7153d99daf02 2125 :END: 2126 2127 #+findex: denote-org-extras-link-to-heading 2128 As part of the optional =denote-org-extras.el= extension, the command 2129 ~denote-org-extras-link-to-heading~ prompts for a link to an Org file 2130 and then asks for a heading therein, using minibuffer completion. Once 2131 the user provides input at the two prompts, the command inserts a link 2132 at point which has the following pattern: =[[denote:IDENTIFIER::#ORG-HEADING-CUSTOM-ID]][Description::Heading text]]=. 2133 2134 Because only Org files can have links to individual headings, the 2135 command ~denote-org-extras-link-to-heading~ prompts only for Org files 2136 (i.e. files which include the =.org= extension). Remember that Denote 2137 works with many file types ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 2138 2139 This feature is similar to the concept of the user option ~denote-org-store-link-to-heading~ 2140 ([[#h:d99de1fb-b1b7-4a74-8667-575636a4d6a4][The ~denote-org-store-link-to-heading~ user option]]). It is, however, 2141 interactive and differs in the directionality of the action. With that 2142 user option, the command ~org-store-link~ will generate a =CUSTOM_ID= 2143 for the current heading (or capture the value of one as-is), giving 2144 the user the option to then call ~org-insert-link~ wherever they see 2145 fit. By contrast, the command ~denote-org-extras-link-to-heading~ 2146 prompts for a file, then a heading, and inserts the link at point. 2147 2148 ** Insert links matching a regexp 2149 :PROPERTIES: 2150 :CUSTOM_ID: h:9bec2c83-36ca-4951-aefc-7187c5463f90 2151 :END: 2152 2153 #+findex: denote-add-links 2154 The command ~denote-add-links~ adds links at point matching a 2155 regular expression or plain string. The links are inserted as a 2156 typographic list, such as: 2157 2158 #+begin_example 2159 - link1 2160 - link2 2161 - link3 2162 #+end_example 2163 2164 Each link is formatted according to the file type of the current note, 2165 as explained further above about the ~denote-link~ command. The current 2166 note is excluded from the matching entries (adding a link to itself is 2167 pointless). 2168 2169 When called with a prefix argument (=C-u=) ~denote-add-links~ will 2170 format all links as =[[denote:IDENTIFIER]]=, hence a typographic list: 2171 2172 #+begin_example 2173 - [[denote:IDENTIFIER-1]] 2174 - [[denote:IDENTIFIER-2]] 2175 - [[denote:IDENTIFIER-3]] 2176 #+end_example 2177 2178 Same examples of a regular expression that can be used with this 2179 command: 2180 2181 - =journal= match all files which include =journal= anywhere in their 2182 name. 2183 2184 - =_journal= match all files which include =journal= as a keyword. 2185 2186 - =^2022.*_journal= match all file names starting with =2022= and 2187 including the keyword =journal=. 2188 2189 - =\.txt= match all files including =.txt=. In practical terms, this 2190 only applies to the file extension, as Denote automatically removes 2191 dots (and other characters) from the base file name. 2192 2193 If files are created with ~denote-sort-keywords~ as non-nil (the 2194 default), then it is easy to write a regexp that includes multiple 2195 keywords in alphabetic order: 2196 2197 - =_denote.*_package= match all files that include both the =denote= and 2198 =package= keywords, in this order. 2199 2200 - =\(.*denote.*package.*\)\|\(.*package.*denote.*\)= is the same as 2201 above, but out-of-order. 2202 2203 Remember that regexp constructs only need to be escaped once (like =\|=) 2204 when done interactively but twice when called from Lisp. What we show 2205 above is for interactive usage. 2206 2207 Links are created only for files which qualify as a "note" for our 2208 purposes ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). 2209 2210 ** Insert link to file with signature 2211 :PROPERTIES: 2212 :CUSTOM_ID: h:066e5221-9844-474b-8858-398398646f86 2213 :END: 2214 2215 #+findex: denote-link-with-signature 2216 The command ~denote-link-with-signature~ prompts for a file among 2217 those that contain a ===SIGNATURE= and inserts a link to it. The 2218 description of the link includes the text of the signature and that of 2219 the file's title, if any. For example, a link to the following file: 2220 2221 : 20230925T144303==abc--my-first-signature-note__denote_testing.txt 2222 2223 will get this link: =[[denote:20230925T144303][abc My first signature note]]=. 2224 2225 For more advanced uses, refer to the doc string of the ~denote-link~ 2226 function. 2227 2228 ** Insert links from marked files in Dired 2229 :PROPERTIES: 2230 :CUSTOM_ID: h:9cbb692e-5d8a-44a6-9193-899a07872a07 2231 :END: 2232 2233 #+findex: denote-link-dired-marked-notes 2234 The command ~denote-link-dired-marked-notes~ is similar to 2235 ~denote-add-links~ in that it inserts in the buffer a typographic list 2236 of links to Denote notes ([[#h:9bec2c83-36ca-4951-aefc-7187c5463f90][Insert links matching a regexp]]). Though 2237 instead of reading a regular expression, it lets the user mark files 2238 in Dired and link to them. This should be easier for users of all 2239 skill levels, instead of having to write a potentially complex regular 2240 expression. 2241 2242 If there are multiple buffers that visit a Denote note, this command 2243 will ask to select one among them, using minibuffer completion. If 2244 there is only one buffer, it will operate in it outright. If there are 2245 no buffers, it will produce an error. 2246 2247 With optional =ID-ONLY= as a prefix argument (=C-u= by default), the 2248 command inserts links with just the identifier, which is the same 2249 principle as with ~denote-link~ and others ([[#h:5e5e3370-12ab-454f-ba09-88ff44214324][Adding a single link]]). 2250 2251 The command ~denote-link-dired-marked-notes~ is meant to be used from a 2252 Dired buffer. 2253 2254 As always, links are created only for files which qualify as a "note" 2255 for our purposes ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). 2256 2257 ** Link to an existing note or create a new one 2258 :PROPERTIES: 2259 :CUSTOM_ID: h:b6056e6b-93df-4e6b-a778-eebd105bac46 2260 :END: 2261 2262 In one's note-taking workflow, there may come a point where they are 2263 expounding on a certain topic but have an idea about another subject 2264 they would like to link to ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). The user can always rely on 2265 the other linking facilities we have covered herein to target files that 2266 already exist. Though they may not know whether they already have notes 2267 covering the subject or whether they would need to write new ones. To 2268 this end, Denote provides two convenience commands: 2269 2270 #+findex: denote-link-after-creating 2271 + ~denote-link-after-creating~ :: Create new note in the background and 2272 link to it directly. 2273 2274 Use ~denote~ interactively to produce the new note. Its doc string or 2275 this manual explains which prompts will be used and under what 2276 conditions ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). 2277 2278 With optional =ID-ONLY= as a prefix argument (this is the =C-u= key, 2279 by default) create a link that consists of just the identifier. Else 2280 try to also include the file's title. This has the same meaning as in 2281 ~denote-link~ ([[#h:5e5e3370-12ab-454f-ba09-88ff44214324][Adding a single link]]). 2282 2283 IMPORTANT NOTE: Normally, ~denote~ does not save the buffer it 2284 produces for the new note ([[#h:bf80f4cd-6f56-4f7c-a991-8573161e4511][The ~denote-save-buffer-after-creation~ option]]). 2285 This is a safety precaution to not write to disk unless the user 2286 wants it (e.g. the user may choose to kill the buffer, thus 2287 cancelling the creation of the note). However, for this command the 2288 creation of the note happens in the background and the user may miss 2289 the step of saving their buffer. We thus have to save the buffer in 2290 order to (i) establish valid links, and (ii) retrieve whatever front 2291 matter from the target file. 2292 2293 #+findex: denote-link-after-creating-with-command 2294 + ~denote-link-after-creating-with-command~ :: This command is like 2295 ~denote-link-after-creating~ except it prompts for a note-creating 2296 command ([[*Points of entry][Points of entry]]). Use this to, for example, call 2297 ~denote-signature~ so that the newly created note has a signature as 2298 part of its file name. Optional =ID-ONLY= has the same meaning as 2299 in the command ~denote-link-after-creating~. 2300 2301 #+findex: denote-link-or-create 2302 + ~denote-link-or-create~ :: Use ~denote-link~ on =TARGET= file, 2303 creating it if necessary. 2304 2305 If =TARGET= file does not exist, call ~denote-link-after-creating~ 2306 which runs the ~denote~ command interactively to create the file. The 2307 established link will then be targeting that new file. 2308 2309 If =TARGET= file does not exist, add the user input that was used to 2310 search for it to the history of the ~denote-file-prompt~. The user 2311 can then retrieve and possibly further edit their last input, using 2312 it as the newly created note's actual title. At the ~denote-file-prompt~ 2313 type =M-p= with the default key bindings, which calls ~previous-history-element~. 2314 2315 With optional =ID-ONLY= as a prefix argument create a link with just 2316 the file's identifier. This has the same meaning as in ~denote-link~. 2317 2318 This command has the alias ~denote-link-to-existing-or-new-note~, 2319 which helps with discoverability. 2320 2321 #+findex: denote-link-or-create-with-command 2322 + ~denote-link-or-create-with-command~ :: This is like the above, 2323 except when it is about to create the new note it first prompts for 2324 the specific file-creating command to use ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). For 2325 example, the user may want to specify a signature for this new file, 2326 so they can select the ~denote-signature~ command. 2327 2328 In all of the above, an optional prefix argument (=C-u= by default) 2329 creates a link that consists of just the identifier. This has the 2330 same meaning as in the regular ~denote-link~ command. 2331 2332 Denote provides similar functionality for opening an existing note or 2333 creating a new one ([[#h:ad91ca39-cf10-4e16-b224-fdf78f093883][Open an existing note or create it if missing]]). 2334 2335 ** The backlinks' buffer 2336 :PROPERTIES: 2337 :CUSTOM_ID: h:c73f1f68-e214-49d5-b369-e694f6a5d708 2338 :END: 2339 2340 #+findex: denote-backlinks 2341 The command ~denote-backlinks~ produces a bespoke buffer which 2342 displays backlinks to the current note. A "backlink" is a link back 2343 to the present entry. 2344 2345 By default, the backlinks' buffer is designed to display the file name 2346 of the note linking to the current entry. Each file name is presented 2347 on its own line, like this: 2348 2349 #+begin_example 2350 Backlinks to "On being honest" (20220614T130812) 2351 ------------------------------------------------ 2352 2353 20220614T145606--let-this-glance-become-a-stare__journal.txt 2354 20220616T182958--feeling-butterflies-in-your-stomach__journal.txt 2355 #+end_example 2356 2357 #+vindex: denote-backlinks-show-context 2358 When the user option ~denote-backlinks-show-context~ is non-nil, the 2359 backlinks' buffer displays the line on which a link to the current 2360 note occurs. It also shows multiple occurrences, if present. It looks 2361 like this (and has the appropriate fontification): 2362 2363 #+begin_example 2364 Backlinks to "On being honest" (20220614T130812) 2365 ------------------------------------------------ 2366 2367 20220614T145606--let-this-glance-become-a-stare__journal.txt 2368 37: growing into it: [[denote:20220614T130812][On being honest]]. 2369 64: As I said in [[denote:20220614T130812][On being honest]] I have never 2370 20220616T182958--feeling-butterflies-in-your-stomach__journal.txt 2371 62: indifference. In [[denote:20220614T130812][On being honest]] I alluded 2372 #+end_example 2373 2374 Note that the width of the lines in the context depends on the 2375 underlying file. In the above example, the lines are split at the 2376 ~fill-column~. Long lines will show up just fine. Also note that the 2377 built-in user option ~xref-truncation-width~ can truncate long lines 2378 to a given maximum number of characters. 2379 2380 [[#h:893eec49-d7be-4603-bcff-fcc247244011][Speed up backlinks' buffer creation?]] 2381 2382 #+findex: denote-backlinks-mode 2383 #+vindex: denote-backlinks-mode-map 2384 The backlinks' buffer runs the major-mode ~denote-backlinks-mode~. It 2385 binds keys to move between links with =n= (next) and =p= (previous). 2386 These are stored in the ~denote-backlinks-mode-map~ (use =M-x 2387 describe-mode= (=C-h m=) in an unfamiliar buffer to learn more about 2388 it). When the user option ~denote-backlinks-show-context~ is non-nil, 2389 all relevant Xref key bindings are fully functional: again, check 2390 ~describe-mode~. 2391 2392 The backlinking facility uses Emacs' built-in Xref infrastructure. On 2393 some operating systems, the user may need to add certain executables 2394 to the relevant environment variable. 2395 2396 [[#h:42f6b07e-5956-469a-8294-17f9cf62eb2b][Why do I get "Search failed with status 1" when I search for backlinks?]] 2397 2398 Backlinks to the current file can also be visited by using the 2399 minibuffer completion interface with the ~denote-find-backlink~ 2400 command ([[#h:1bc2adad-dca3-4878-b9f0-b105d5dec6f4][Visiting linked files via the minibuffer]]). 2401 2402 #+vindex: denote-link-backlinks-display-buffer-action 2403 The placement of the backlinks' buffer is subject to the user option 2404 ~denote-link-backlinks-display-buffer-action~. Due to the nature of the 2405 underlying ~display-buffer~ mechanism, this inevitably is a relatively 2406 advanced feature. By default, the backlinks' buffer is displayed below 2407 the current window. The doc string of our user option includes a sample 2408 configuration that places the buffer in a left side window instead. 2409 Reproducing it here for the sake of convenience: 2410 2411 #+begin_src emacs-lisp 2412 (setq denote-link-backlinks-display-buffer-action 2413 '((display-buffer-reuse-window 2414 display-buffer-in-side-window) 2415 (side . left) 2416 (slot . 99) 2417 (window-width . 0.3))) 2418 #+end_src 2419 2420 ** Writing metanotes 2421 :PROPERTIES: 2422 :CUSTOM_ID: h:6060a7e6-f179-4d42-a9de-a9968aaebecc 2423 :END: 2424 2425 A "metanote" is an entry that describes other entries who have something 2426 in common. Writing metanotes can be part of a workflow where the user 2427 periodically reviews their work in search of patterns and deeper 2428 insights. For example, you might want to read your journal entries from 2429 the past year to reflect on your experiences, evolution as a person, and 2430 the like. 2431 2432 The commands ~denote-add-links~, ~denote-link-dired-marked-notes~ are 2433 suited for this task. 2434 2435 [[#h:9bec2c83-36ca-4951-aefc-7187c5463f90][Insert links matching a regexp]]. 2436 2437 [[#h:9cbb692e-5d8a-44a6-9193-899a07872a07][Insert links from marked files in Dired]]. 2438 2439 You will create your metanote the way you use Denote ordinarily 2440 (metanotes may have the =metanote= keyword, among others), write an 2441 introduction or however you want to go about it, invoke the command 2442 which inserts multiple links at once (see the above-cited nodes), and 2443 continue writing. 2444 2445 Metanotes can serve as entry points to groupings of individual notes. 2446 They are not the same as a filtered list of files, i.e. what you would 2447 do in Dired or the minibuffer where you narrow the list of notes to a 2448 given query. Metanotes contain the filtered list plus your thoughts 2449 about it. The act of purposefully grouping notes together and 2450 contemplating on their shared patterns is what adds value. 2451 2452 Your future self will appreciate metanotes for the function they serve 2453 in encapsulating knowledge, while current you will be equipped with the 2454 knowledge derived from the deliberate self-reflection. 2455 2456 ** Visiting linked files via the minibuffer 2457 :PROPERTIES: 2458 :CUSTOM_ID: h:1bc2adad-dca3-4878-b9f0-b105d5dec6f4 2459 :END: 2460 2461 #+findex: denote-find-link 2462 Denote has a major-mode-agnostic mechanism to collect all linked file 2463 references in the current buffer and return them as an appropriately 2464 formatted list. This list can then be used in interactive commands. 2465 The ~denote-find-link~ is such a command. It uses minibuffer 2466 completion to visit a file that is linked to from the current note. 2467 The candidates have the correct metadata, which is ideal for 2468 integration with other standards-compliant tools ([[#h:8ed2bb6f-b5be-4711-82e9-8bee5bb06ece][Extending Denote]]). 2469 For instance, a package such as =marginalia= will display accurate 2470 annotations, while the =embark= package will be able to work its magic 2471 such as in exporting the list into a filtered Dired buffer (i.e. a 2472 familiar Dired listing with only the files of the current minibuffer 2473 session). 2474 2475 #+findex: denote-find-backlink 2476 To visit backlinks to the current note via the minibuffer, use 2477 ~denote-find-backlink~. This is an alternative to placing backlinks 2478 in a dedicated buffer ([[#h:c73f1f68-e214-49d5-b369-e694f6a5d708][The backlinks' buffer]]). 2479 2480 ** Convert =denote:= links to =file:= links 2481 :PROPERTIES: 2482 :CUSTOM_ID: h:ed220cac-7dcb-4bb7-9243-1bb85e452e5f 2483 :END: 2484 2485 Sometimes the user needs to translate all =denote:= link types to 2486 their =file:= equivalent. This may be because some other tool does not 2487 recognise =denote:= links (or other custom links types---which are a 2488 standard feature of Org, by the way). The user thus needs to (i) 2489 either make a copy of their Denote note or edit the existing one, and 2490 (ii) convert all links to the generic =file:= link type that 2491 external/other programs understand. 2492 2493 The optional extension =denote-org-extras.el= contains two commands 2494 that are relevant for this use-case: 2495 2496 #+findex: denote-org-extras-convert-links-to-file-type 2497 + Convert =denote:= links to =file:= links :: The command ~denote-org-extras-convert-links-to-file-type~ 2498 goes through the buffer to find all =denote:= links. It gets the 2499 identifier of the link and resolves it to the actual file system 2500 path. It then replaces the match so that the link is written with 2501 the =file:= type and then the file system path. The optional search 2502 terms and/or link description are preserved ([[#h:fc1ad245-ec08-41be-8d1e-7153d99daf02][Insert link to an Org file with a further pointer to a heading]]). 2503 2504 #+findex: denote-org-extras-convert-links-to-denote-type 2505 + Convert =file:= links to =denote:= links :: The command ~denote-org-extras-convert-links-to-denote-type~ 2506 behaves like the one above. The difference is that it finds the file 2507 system path and converts it into its identifier. 2508 2509 ** Miscellaneous information about links 2510 :PROPERTIES: 2511 :CUSTOM_ID: h:dd8f2231-8d77-49b9-acc4-af525c68b271 2512 :END: 2513 2514 *** Aliases for the linking commands 2515 :PROPERTIES: 2516 :CUSTOM_ID: h:078856d9-f608-43a8-be84-f2cad4c27d0e 2517 :END: 2518 2519 #+findex: denote-insert-link 2520 #+findex: denote-show-backlinks-buffer 2521 #+findex: denote-link-insert-links-matching-regexp 2522 For convenience, the ~denote-link~ command has an alias called 2523 ~denote-insert-link~. The ~denote-backlinks~ can also be used as 2524 ~denote-show-backlinks-buffer~. While ~denote-add-links~ is 2525 aliased ~denote-link-insert-links-matching-regexp~. The purpose of 2526 these aliases is to offer alternative, more descriptive names of 2527 select commands. 2528 2529 *** The ~denote-link-description-function~ to format links 2530 :PROPERTIES: 2531 :CUSTOM_ID: h:f634427c-b451-40e2-993e-e00ac627af68 2532 :END: 2533 2534 #+vindex: denote-link-description-function 2535 The user option ~denote-link-description-function~ takes as its value 2536 the symbol of a function. This is used to format the text of the link. 2537 The default function inserts the title. If the file has a signature, 2538 it includes that as well, prepending it to the title. 2539 2540 The function specified accepts a single =FILE= argument and returns 2541 the description as a string. 2542 2543 * Choose which commands to prompt for 2544 :PROPERTIES: 2545 :CUSTOM_ID: h:98c732ac-da0e-4ebd-a0e3-5c47f9075e51 2546 :END: 2547 2548 #+vindex: denote-commands-for-new-notes 2549 The user option ~denote-commands-for-new-notes~ specifies a list of 2550 commands that are available at the ~denote-command-prompt~. This 2551 prompt is used by Denote commands that ask the user how to create a 2552 new note, as described elsewhere in this manual: 2553 2554 - [[#h:ad91ca39-cf10-4e16-b224-fdf78f093883][Open an existing note or create it if missing]] 2555 - [[#h:b6056e6b-93df-4e6b-a778-eebd105bac46][Link to a note or create it if missing]] 2556 2557 The default value includes all the basic file-creating commands 2558 ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). Users may customise this value if (i) they only 2559 want to see fewer options and/or (ii) wish to include their own custom 2560 command in the list ([[#h:11946562-7eb0-4925-a3b5-92d75f1f5895][Write your own convenience commands]]). 2561 2562 * Fontification in Dired 2563 :PROPERTIES: 2564 :CUSTOM_ID: h:337f9cf0-9f66-45af-b73f-f6370472fb51 2565 :END: 2566 2567 #+findex: denote-dired-mode 2568 One of the upsides of Denote's file-naming scheme is the predictable 2569 pattern it establishes, which appears as a near-tabular presentation in 2570 a listing of notes (i.e. in Dired). The ~denote-dired-mode~ can help 2571 enhance this impression, by fontifying the components of the file name 2572 to make the date (identifier) and keywords stand out. 2573 2574 There are two ways to set the mode. Either use it for all directories, 2575 which probably is not needed: 2576 2577 #+begin_src emacs-lisp 2578 (add-hook 'dired-mode-hook #'denote-dired-mode) 2579 #+end_src 2580 2581 #+vindex: denote-dired-directories 2582 #+findex: denote-dired-mode-in-directories 2583 Or configure the user option ~denote-dired-directories~ and then set up 2584 the function ~denote-dired-mode-in-directories~: 2585 2586 #+begin_src emacs-lisp 2587 ;; We use different ways to specify a path for demo purposes. 2588 (setq denote-dired-directories 2589 (list denote-directory 2590 (thread-last denote-directory (expand-file-name "attachments")) 2591 (expand-file-name "~/Documents/vlog"))) 2592 2593 (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories) 2594 #+end_src 2595 2596 #+vindex: denote-dired-directories-include-subdirectories 2597 The user option ~denote-dired-directories-include-subdirectories~ 2598 specifies whether the ~denote-dired-directories~ also cover their 2599 subdirectories. By default they do not. Set this option to ~t~ to 2600 include subdirectories as well. 2601 2602 The faces we define for this purpose are: 2603 2604 #+vindex: denote-faces-date 2605 #+vindex: denote-faces-delimiter 2606 #+vindex: denote-faces-extension 2607 #+vindex: denote-faces-keywords 2608 #+vindex: denote-faces-signature 2609 #+vindex: denote-faces-subdirectory 2610 #+vindex: denote-faces-time 2611 #+vindex: denote-faces-title 2612 + ~denote-faces-date~ 2613 + ~denote-faces-delimiter~ 2614 + ~denote-faces-extension~ 2615 + ~denote-faces-keywords~ 2616 - ~denote-faces-signature~ 2617 + ~denote-faces-subdirectory~ 2618 + ~denote-faces-time~ 2619 + ~denote-faces-title~ 2620 2621 For more control, we also provide these: 2622 2623 #+vindex denote-faces-year 2624 #+vindex denote-faces-month 2625 #+vindex denote-faces-day 2626 #+vindex denote-faces-hour 2627 #+vindex denote-faces-minute 2628 #+vindex denote-faces-second 2629 + ~denote-faces-year~ 2630 + ~denote-faces-month~ 2631 + ~denote-faces-day~ 2632 + ~denote-faces-hour~ 2633 + ~denote-faces-minute~ 2634 + ~denote-faces-second~ 2635 2636 For the time being, the =diredfl= package is not compatible with this 2637 facility. 2638 2639 The ~denote-dired-mode~ does not only fontify note files that were 2640 created by Denote: it covers every file name that follows our naming 2641 conventions ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). This is particularly useful for 2642 scenaria where, say, one wants to organise their collection of PDFs and 2643 multimedia in a systematic way (and, perhaps, use them as attachments 2644 for the notes Denote produces if you are writing Org notes and are using 2645 its standand attachments' facility). 2646 2647 * Automatically rename Denote buffers 2648 :PROPERTIES: 2649 :CUSTOM_ID: h:3ca4db16-8f26-4d7d-b748-bac48ae32d69 2650 :END: 2651 2652 #+findex: denote-rename-buffer-mode 2653 The minor mode ~denote-rename-buffer-mode~ provides the means to 2654 automatically rename the buffer of a Denote file upon visiting the 2655 file. This applies both to existing Denote files as well as new ones 2656 ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). Enable the mode thus: 2657 2658 #+begin_src emacs-lisp 2659 (denote-rename-buffer-mode 1) 2660 #+end_src 2661 2662 #+vindex: denote-rename-buffer-function 2663 #+findex: denote-rename-buffer 2664 #+vindex: denote-rename-buffer-format 2665 Buffers are named by applying the function specified in the user 2666 option ~denote-rename-buffer-function~. The default function is 2667 ~denote-rename-buffer~: it renames the buffer based on the template 2668 set in the user option ~denote-rename-buffer-format~. By default, the 2669 formatting template targets only the =TITLE= component of the file 2670 name ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). Other fields are explained elsewhere in 2671 this manual ([[#h:35507c18-35b1-41b9-9d80-52f54fcef3cb][The denote-rename-buffer-format]]). 2672 2673 Note that renaming a buffer is not the same as renaming a file 2674 ([[#h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca][Renaming files]]). The former is just for convenience inside of Emacs. 2675 Whereas the latter is for writing changes to disk, making them 2676 available to all programs. 2677 2678 ** The ~denote-rename-buffer-format~ option 2679 :PROPERTIES: 2680 :CUSTOM_ID: h:35507c18-35b1-41b9-9d80-52f54fcef3cb 2681 :END: 2682 2683 The user option ~denote-rename-buffer-format~ controls how the 2684 function ~denote-rename-buffer~ chooses the name of the 2685 buffer-to-be-renamed. 2686 2687 The value of this user option is a string. The following specifiers 2688 are placeholders for Denote file name components ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]): 2689 2690 - The =%t= is the Denote =TITLE= of the file. 2691 - The =%i= is the Denote =IDENTIFIER= of the file. 2692 - The =%d= is the same as =%i= (=DATE= mnemonic). 2693 - The =%s= is the Denote =SIGNATURE= of the file. 2694 - The =%k= is the Denote =KEYWORDS= of the file. 2695 - The =%%= is a literal percent sign. 2696 2697 In addition, the following flags are available for each of the specifiers: 2698 2699 - =0= :: Pad to the width, if given, with zeros instead of spaces. 2700 - =-= :: Pad to the width, if given, on the right instead of the left. 2701 - =<= :: Truncate to the width and precision, if given, on the left. 2702 - =>= :: Truncate to the width and precision, if given, on the right. 2703 - =^= :: Convert to upper case. 2704 - =_= :: Convert to lower case. 2705 2706 When combined all together, the above are written thus: 2707 2708 : %<flags><width><precision>SPECIFIER-CHARACTER 2709 2710 Any other string it taken as-is. Users may want, for example, to 2711 include some text that makes Denote buffers stand out, such as 2712 a =[D]= prefix. Examples: 2713 2714 #+begin_src emacs-lisp 2715 ;; Use the title (default) 2716 (setq denote-rename-buffer-format "%t") 2717 2718 ;; Use the title and keywords with some emoji in between 2719 (setq denote-rename-buffer-format "%t 🤨 %k") 2720 2721 ;; Use the title with a literal "[D]" before it 2722 (setq denote-rename-buffer-format "[D] %t") 2723 #+end_src 2724 2725 Users who need yet more flexibility are best served by writing their 2726 own function and assigning it to the ~denote-rename-buffer-function~. 2727 2728 * Use Org dynamic blocks 2729 :PROPERTIES: 2730 :CUSTOM_ID: h:8b542c50-dcc9-4bca-8037-a36599b22779 2731 :END: 2732 2733 [ As part of version 2.3.0, all dynamic blocks are defined in the file 2734 =denote-org-extras.el=. The file which was once called 2735 =denote-org-dblock.el= contains aliases for the new function names 2736 and dipslays a warning about its deprecation. There is no need to 2737 ~require~ the ~denote-org-extras~ feature because all of Denote's 2738 Org dynamic blocks are autoloaded (meaning that they work as soon as 2739 they are used). For backward compatibility, all dynamic blocks 2740 retain their original names as an alias for the newer one. ] 2741 2742 Denote can optionally integrate with Org mode's "dynamic blocks" 2743 facility. This means that it can use special blocks that are evaluated 2744 with =C-c C-x C-u= (~org-dblock-update~) to generate their contents. 2745 The following subsections describe the types of Org dynamic blocks 2746 provided by Denote. 2747 2748 - [[#h:50160fae-6515-4d7d-9737-995ad925e64b][Org dynamic blocks to insert links or backlinks]] 2749 - [[#h:f15fa143-5036-416f-9bff-1bcabbb03456][Org dynamic block to insert file contents]] 2750 2751 A dynamic block gets its contents by evaluating a function that 2752 corresponds to the type of block. The block type and its parameters 2753 are stated in the opening =#+BEGIN= line. Typing =C-c C-x C-u= 2754 (~org-dblock-update~) with point on that line runs (or re-runs) the 2755 associated function with the given parameters and populates the 2756 block's contents accordingly. 2757 2758 Dynamic blocks are particularly useful for metanote entries that 2759 reflect on the status of earlier notes ([[#h:6060a7e6-f179-4d42-a9de-a9968aaebecc][Writing metanotes]]). 2760 2761 The Org manual describes the technicalities of Dynamic Blocks. 2762 Evaluate: 2763 2764 #+begin_src emacs-lisp 2765 (info "(org) Dynamic Blocks") 2766 #+end_src 2767 2768 ** Org dynamic blocks to insert links or backlinks 2769 :PROPERTIES: 2770 :CUSTOM_ID: h:50160fae-6515-4d7d-9737-995ad925e64b 2771 :END: 2772 2773 [ As part of version 2.3.0, all dynamic blocks are defined in the file 2774 =denote-org-extras.el=. The file which was once called 2775 =denote-org-dblock.el= contains aliases for the new function names 2776 and dipslays a warning about its deprecation. There is no need to 2777 ~require~ the ~denote-org-extras~ feature because all of Denote's 2778 Org dynamic blocks are autoloaded (meaning that they work as soon as 2779 they are used). For backward compatibility, all dynamic blocks 2780 retain their original names as an alias for the newer one. ] 2781 2782 #+findex: denote-org-extras-dblock-insert-links 2783 The =denote-links= block can be inserted at point with the command 2784 ~denote-org-extras-dblock-insert-links~ or by manually including the 2785 following in an Org file: 2786 2787 : #+BEGIN: denote-links :regexp "YOUR REGEXP HERE" :sort-by-component nil :reverse-sort nil :id-only nil 2788 : 2789 : #+END: 2790 2791 The =denote-links= block is also registered as an option for the 2792 command ~org-dynamic-block-insert-dblock~. 2793 2794 Type =C-c C-x C-u= (~org-dblock-update~) with point on the =#+BEGIN= 2795 line to update the block. 2796 2797 - The =:regexp= parameter is mandatory. Its value is a string and its 2798 behaviour is the same as that of the ~denote-add-links~ command 2799 ([[#h:9bec2c83-36ca-4951-aefc-7187c5463f90][Insert links matching a regexp]]). Concretely, it produces a 2800 typographic list of links to files matching the giving regular 2801 expression. The value of the =:regexp= parameter may also be of the 2802 form read by the ~rx~ macro (Lisp notation instead of a string), as 2803 explained in the Emacs Lisp Reference Manual (evaluate this code to 2804 read the documentation: =(info "(elisp) Rx Notation")=). Note that 2805 you do not need to write an actual regular expression to get 2806 meaningful results: even something like =_journal= will work to 2807 include all files that have a =journal= keyword. 2808 2809 - The =:sort-by-component= parameter is optional. It sorts the files 2810 by the given Denote file name component. The value it accepts is an 2811 unquoted symbol among =title=, =keywords=, =signature=, =identifier=. 2812 When using the command ~denote-org-extras-dblock-insert-files~, this 2813 parameter is automatically inserted together with the (=:regexp= 2814 parameter) and the user is prompted for a file name component. 2815 2816 - The =:reverse-sort= parameter is optional. It reverses the order in 2817 which files appear in. This is meaningful even without the presence 2818 of the parameter =:sort-by-component=, though it also combines with 2819 it. 2820 2821 - The =:id-only= parameter is optional. It accepts a ~t~ value, in 2822 which case links are inserted without a description text but only 2823 with the identifier of the given file. This has the same meaning as 2824 with the ~denote-link~ command and related facilities ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). 2825 2826 - An optional =:block-name= parameter can be specified with a string 2827 value to add a =#+name= to the results. This is useful for further 2828 processing using Org facilities (a feature that is outside Denote's 2829 purview). 2830 2831 #+findex: denote-org-extras-dblock-insert-backlinks 2832 The same as above except for the =:regexp= parameter are true for the 2833 =denote-backlinks= block. The block can be inserted at point with the 2834 command ~denote-org-extras-dblock-insert-backlinks~ or by manually writing 2835 this in an Org file: 2836 2837 : #+BEGIN: denote-backlinks :sort-by-component nil :reverse-sort nil :id-only nil 2838 : 2839 : #+END: 2840 2841 #+findex: denote-org-extras-dblock-insert-missing-links 2842 Finally, the =denote-missing-links= block is available with the 2843 command ~denote-org-extras-dblock-insert-missing-links~. It is like 2844 the aforementioned =denote-links= block, except it only lists links to 2845 files that are not present in the current buffer. The parameters are 2846 otherwise the same: 2847 2848 : #+BEGIN: denote-missing-links :regexp "YOUR REGEXP HERE" :sort-by-component nil :reverse-sort nil :id-only nil 2849 : 2850 : #+END: 2851 2852 Remember to type =C-c C-x C-u= (~org-dblock-update~) with point on the 2853 =#+BEGIN= line to update the block. 2854 2855 ** Org dynamic block to insert file contents 2856 :PROPERTIES: 2857 :CUSTOM_ID: h:f15fa143-5036-416f-9bff-1bcabbb03456 2858 :END: 2859 2860 [ As part of version 2.3.0, all dynamic blocks are defined in the file 2861 =denote-org-extras.el=. The file which was once called 2862 =denote-org-dblock.el= contains aliases for the new function names 2863 and dipslays a warning about its deprecation. There is no need to 2864 ~require~ the ~denote-org-extras~ feature because all of Denote's 2865 Org dynamic blocks are autoloaded (meaning that they work as soon as 2866 they are used). For backward compatibility, all dynamic blocks 2867 retain their original names as an alias for the newer one. ] 2868 2869 Denote can optionally use Org's dynamic blocks facility to produce a 2870 section that lists entire file contents ([[#h:8b542c50-dcc9-4bca-8037-a36599b22779][Use Org dynamic blocks]]). 2871 This works by instructing Org to match a regular expression of Denote 2872 files, the same way we do with Denote links ([[#h:9bec2c83-36ca-4951-aefc-7187c5463f90][Insert links matching a regexp]]). 2873 2874 This is useful to, for example, compile a dynamically concatenated 2875 list of scattered thoughts on a given topic, like =^2023.*_emacs= for 2876 a long entry that incorporates all the notes written in 2023 with the 2877 keyword =emacs=. 2878 2879 #+findex: denote-org-extras-dblock-insert-files 2880 To produce such a block, call the command ~denote-org-extras-dblock-insert-files~ 2881 or manually write the following block in an Org file and then type 2882 =C-c C-x C-u= (~org-dblock-update~) on the =#+BEGIN= line to run it 2883 (do it again to recalculate the block): 2884 2885 : #+BEGIN: denote-files :regexp "YOUR REGEXP HERE" 2886 : 2887 : #+END: 2888 2889 To fully control the output, include these additional optional 2890 parameters, which are described further below: 2891 2892 : #+BEGIN: denote-files :regexp "YOUR REGEXP HERE" :sort-by-component nil :reverse-sort nil :no-front-matter nil :file-separator nil :add-links nil 2893 : 2894 : #+END: 2895 2896 - The =:regexp= parameter is mandatory. Its value is a string, 2897 representing a regular expression to match Denote file names. Its 2898 value may also be an ~rx~ expression instead of a string, as noted 2899 in the previous section ([[#h:50160fae-6515-4d7d-9737-995ad925e64b][Org dynamic blocks to insert links or backlinks]]). 2900 Note that you do not need to write an actual regular expression to 2901 get meaningful results: even something like =_journal= will work to 2902 include all files that have a =journal= keyword. 2903 2904 - The =:sort-by-component= parameter is optional. It sorts the files 2905 by the given Denote file name component. The value it accepts is an 2906 unquoted symbol among =title=, =keywords=, =signature=, =identifier=. 2907 When using the command ~denote-org-extras-dblock-insert-files~, this 2908 parameter is automatically inserted together with the (=:regexp= 2909 parameter) and the user is prompted for a file name component. 2910 2911 - The =:reverse-sort= parameter is optional. It reverses the order in 2912 which files appear in. This is meaningful even without the presence 2913 of the parameter =:sort-by-component=, though it also combines with 2914 it. 2915 2916 #+vindex: denote-org-extras-dblock-file-contents-separator 2917 - The =:file-separator= parameter is optional. If it is omitted, then 2918 Denote will use no separator between the files it inserts. If the 2919 value is ~t~ the ~denote-org-extras-dblock-file-contents-separator~ is 2920 applied at the end of each file: it introduces some empty lines and 2921 a horizontal rule between them to visually distinguish individual 2922 files. If the =:file-separator= value is a string, it is used as the 2923 file separator (e.g. use ="\n"= to insert just one empty new line). 2924 2925 - The =:no-front-matter= parameter is optional. When set to a ~t~ 2926 value, Denote tries to remove front matter from the files it is 2927 inserting in the dynamic block. The technique used to perform this 2928 operation is by removing all lines from the top of the file until 2929 the first empty line. This works with the default front matter that 2930 Denote adds, but is not 100% reliable with all sorts of user-level 2931 modifications and edits to the file. When the =:no-front-matter= is 2932 set to a natural number, Denote will omit that many lines from the 2933 top of the file. 2934 2935 - The =:add-links= parameter is optional. When it is set to a ~t~ 2936 value, all files are inserted as a typographic list and are indented 2937 accordingly. The first line in each list item is a link to the file 2938 whose contents are inserted in the following lines. When the value 2939 is =id-only=, then links are inserted without a description text but 2940 only with the identifier of the given file. This has the same 2941 meaning as with the ~denote-link~ command and related facilities 2942 ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]). Remember that Org can fold the items in a 2943 typographic list the same way it does with headings. So even long 2944 files can be presented in this format without much trouble. 2945 2946 - An optional =:block-name= parameter can be specified with a string 2947 value to add a =#+name= to the results. This is useful for further 2948 processing using Org facilities (a feature that is outside Denote's 2949 purview). 2950 2951 * Sort files by component 2952 :PROPERTIES: 2953 :CUSTOM_ID: h:9fe01e63-f34f-4479-8713-f162a5ca865e 2954 :END: 2955 2956 The =denote-sort.el= file is an optional extension to the core 2957 functionality of Denote, which empowers users to sort files by the 2958 given file name component ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 2959 2960 #+findex: denote-sort-dired 2961 The command ~denote-sort-dired~ produces a Dired file listing with a 2962 flat, filtered, and sorted set of files from the ~denote-directory~. 2963 It does so by means of three minibuffer prompts: 2964 2965 1. It first asks for a regular expression with which to match Denote 2966 files. Remember that due to Denote's efficient file-naming scheme, 2967 you do not need to write some complex regular expression. Even 2968 something like =_journal= will match only files with a =journal= 2969 keyword. 2970 2. Once the regular expression is provided, the command asks for a 2971 Denote file name component to sort files by. This is a symbol among 2972 =title=, =keywords=, =signature=, and =identifier=. 2973 3. Finally, it asks a "yes or no" on whether to reverse the sort 2974 order. 2975 2976 The resulting Dired listing is a regular Dired buffer, unlike that of 2977 ~dired-virtual-mode~ ([[#h:d35d8d41-f51b-4139-af8f-9c8cc508e35b][Use ~dired-virtual-mode~ for arbitrary file listings]]). 2978 2979 The dynamic Org blocks that Denote defines to insert file contents 2980 also use this feature ([[#h:f15fa143-5036-416f-9bff-1bcabbb03456][Org dynamic block to insert file contents]]). 2981 2982 DEVELOPMENT NOTE as of 2023-11-30 07:24 +0200: The sort mechanism will 2983 be incorporated in more functions on a case-by-case basis, subject to 2984 user feedback. For the time being, I am not documenting the functions 2985 that are only accessed from Lisp. Do not hesitate to contact me 2986 (Protesilaos) in person or on one of the development sources (mailing 2987 list or GitHub/GitLab mirror) if you have a use-case where sorting 2988 seems useful. I am happy to help but do not want to roll this feature 2989 everywhere before eliciting relevant feedback: once we add it, we are 2990 not going back. 2991 2992 * Keep a journal or diary 2993 :PROPERTIES: 2994 :CUSTOM_ID: h:4a6d92dd-19eb-4fcc-a7b5-05ce04da3a92 2995 :END: 2996 2997 Denote provides a general-purpose mechanism to create new files that 2998 broadly count as "notes" ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). Such files can be daily 2999 entries in a journal. While it is possible to use the generic 3000 ~denote~ command to maintain a journal, we provide an optional set of 3001 convenience options and commands as part of =denote-journal-extras.el=. 3002 To use those, add the following the Denote configuration: 3003 3004 #+begin_src emacs-lisp 3005 (require 'denote-journal-extras) 3006 #+end_src 3007 3008 #+findex: denote-journal-extras-new-entry 3009 #+vindex: denote-journal-extras-keyword 3010 #+vindex: denote-journal-extras-directory 3011 The command ~denote-journal-extras-new-entry~ creates a new entry in 3012 the journal. Such a file has the ~denote-journal-extras-keyword~, 3013 which is =journal= by default ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). The user can 3014 set this keyword to an arbitrary string (single word is preferred). 3015 New journal entries can be stored in the ~denote-directory~ or 3016 subdirectory thereof. To make it easier for the user, the new journal 3017 entry will be placed in ~denote-journal-extras-directory~, which 3018 defaults to a subdirectory of ~denote-directory~ called =journal=. 3019 3020 If ~denote-journal-extras-directory~ is nil, the ~denote-directory~ is 3021 used. Journal entries will thus be in a flat listing together with 3022 all other notes. They can still be retrieved easily by searching for 3023 the ~denote-journal-extras-keyword~ ([[#h:1a953736-86c2-420b-b566-fb22c97df197][Features of the file-naming scheme for searching or filtering]]). 3024 3025 #+vindex: denote-journal-extras-title-format 3026 Furthermore, the command ~denote-journal-extras-new-entry~ will use 3027 the current date as the title of the new entry. The exact format is 3028 controlled by the user option ~denote-journal-extras-title-format~. 3029 Acceptable values for ~denote-journal-extras-title-format~ and their 3030 corresponding styles are: 3031 3032 | Symbol | Style | 3033 |-------------------------+-----------------------------------| 3034 | day | Monday | 3035 | day-date-month-year | Monday 19 September 2023 | 3036 | day-date-month-year-24h | Monday 19 September 2023 20:49 | 3037 | day-date-month-year-12h | Monday 19 September 2023 08:49 PM | 3038 3039 For example: 3040 3041 #+begin_src emacs-lisp 3042 (setq denote-journal-extras-title-format 'day-date-month-year) 3043 #+end_src 3044 3045 If the value of this user option is ~nil~, then 3046 ~denote-journal-extras-new-entry~ will prompt for a title. 3047 3048 The ~denote-journal-extras-new-entry~ command also accepts an optional 3049 =DATE= argument. When called internactively, this is a universal 3050 prefix (e.g. =C-u= with the default key bindings). With =DATE=, it 3051 prompts for a date to create a new journal entry for. The date prompt 3052 can optionally use the Org date+calendar selection interface 3053 ([[#h:e7ef08d6-af1b-4ab3-bb00-494a653e6d63][The ~denote-date-prompt-use-org-read-date~ option]]). 3054 3055 In terms of workflow, using the current date as the title is better 3056 for maintaining a daily journal. A prompt for an arbitrary title is 3057 more suitable for those who like to keep a record of something like a 3058 thought or event (though this can also be achieved by the regular 3059 ~denote~ command or maybe ~denote-subdirectory~). 3060 3061 #+vindex: denote-journal-extras-hook 3062 The ~denote-journal-extras-new-entry~ command calls the normal hook 3063 ~denote-journal-extras-hook~ after it is done. The user can leverage 3064 this to produce consequences therefrom, such as to set a timer with 3065 the ~tmr~ package from GNU ELPA ([[#h:4af1f81e-e93a-43cc-b344-960032a16d42][Journaling with a timer]]). 3066 3067 #+findex: denote-journal-extras-new-or-existing-entry 3068 The command ~denote-journal-extras-new-or-existing-entry~ locates an 3069 existing journal entry or creates a new one. A journal entry is one 3070 that has ~denote-journal-extras-keyword~ as part of its file name. If 3071 there are multiple journal entries for the current date, it prompts 3072 for one among them using minibuffer completion. If there is only one, 3073 it visits it outright. If there is no journal entry, it creates one 3074 by calling ~denote-journal-extra-new-entry~ (as described above). 3075 3076 #+findex: denote-journal-extras-link-or-create-entry 3077 The command ~denote-journal-extras-link-or-create-entry~ links to the 3078 journal entry for today or creates it in the background, if missing, 3079 and then links to it from the current file. If there are multiple 3080 journal entries for the same day, it prompts to select one among them 3081 and then links to it. When called with an optional prefix argument 3082 (such as =C-u= with default key bindings), the command prompts for a 3083 date and then performs the aforementioned. With a double prefix 3084 argument (=C-u C-u=), it also produces a link whose description 3085 includes just the file's identifier. 3086 3087 ** Journaling with a timer 3088 :PROPERTIES: 3089 :CUSTOM_ID: h:4af1f81e-e93a-43cc-b344-960032a16d42 3090 :END: 3091 3092 [ Revised as part of version 2.1.0 to conform with how we 3093 now tend to the needs of users who use Denote for journaling 3094 purposes ([[#h:4a6d92dd-19eb-4fcc-a7b5-05ce04da3a92][Keep a journal or diary]]). ] 3095 3096 Sometimes journaling is done with the intent to hone one's writing 3097 skills. Perhaps you are learning a new language or wish to communicate 3098 your ideas with greater clarity and precision. As with everything that 3099 requires a degree of sophistication, you have to work for it---write, 3100 write, write! 3101 3102 One way to test your progress is to set a timer. It helps you gauge 3103 your output and its quality. To use a timer with Emacs, consider the 3104 ~tmr~ package. A new timer can be set with something like this: 3105 3106 #+begin_src emacs-lisp 3107 ;; Set 10 minute timer with the given description 3108 (tmr "10" "Practice writing in my journal") 3109 #+end_src 3110 3111 To make this timer start as soon as a new journal entry is created 3112 with the command ~denote-journal-extras-new-entry~, add a function to 3113 the ~denote-journal-extras-hook~. For example: 3114 3115 #+begin_src emacs-lisp 3116 ;; Add an anonymous function, which is more difficult to modify after 3117 ;; the fact: 3118 (add-hook 'denote-journal-extras-hook (lambda () 3119 (tmr "10" "Practice writing in my journal"))) 3120 3121 ;; Or write a small function that you can then modify without 3122 ;; revaluating the hook: 3123 (defun my-denote-tmr () 3124 (tmr "10" "Practice writing in my journal")) 3125 3126 (add-hook 'denote-journal-extras-hook 'my-denote-tmr) 3127 3128 ;; Or to make it fully featured, define variables for the duration and 3129 ;; the description and set it up so that you only need to modify 3130 ;; those: 3131 (defvar my-denote-tmr-duration "10") 3132 3133 (defvar my-denote-tmr-description "Practice writing in my journal") 3134 3135 (defun my-denote-tmr () 3136 (tmr my-denote-tmr-duration my-denote-tmr-description)) 3137 3138 (add-hook 'denote-journal-extras-hook 'my-denote-tmr) 3139 #+end_src 3140 3141 Once the timer elapses, stop writing and review your performance. 3142 Practice makes perfect! 3143 3144 Sources for ~tmr~: 3145 3146 + Package name (GNU ELPA): ~tmr~ 3147 + Official manual: <https://protesilaos.com/emacs/tmr> 3148 + Change log: <https://protesilaos.com/emacs/denote-changelog> 3149 + Git repo on SourceHut: <https://git.sr.ht/~protesilaos/tmr> 3150 - Mirrors: 3151 + GitHub: <https://github.com/protesilaos/tmr> 3152 + GitLab: <https://gitlab.com/protesilaos/tmr> 3153 + Mailing list: <https://lists.sr.ht/~protesilaos/tmr> 3154 3155 * Minibuffer histories 3156 :PROPERTIES: 3157 :CUSTOM_ID: h:82dc1203-d689-44b2-9a6c-b37776209651 3158 :END: 3159 3160 Denote has a dedicated minibuffer history for each one of its prompts. 3161 This practically means that using =M-p= (~previous-history-element~) and 3162 =M-n= (~next-history-element~) will only cycle through the relevant 3163 record of inputs, such as your latest titles in the =TITLE= prompt, and 3164 keywords in the =KEYWORDS= prompt. 3165 3166 The built-in =savehist= library saves minibuffer histories. Sample 3167 configuration: 3168 3169 #+begin_src emacs-lisp 3170 (require 'savehist) 3171 (setq savehist-file (locate-user-emacs-file "savehist")) 3172 (setq history-length 500) 3173 (setq history-delete-duplicates t) 3174 (setq savehist-save-minibuffer-history t) 3175 (add-hook 'after-init-hook #'savehist-mode) 3176 #+end_src 3177 3178 * Extending Denote 3179 :PROPERTIES: 3180 :CUSTOM_ID: h:8ed2bb6f-b5be-4711-82e9-8bee5bb06ece 3181 :END: 3182 3183 Denote is a tool with a narrow scope: create notes and link between 3184 them, based on the aforementioned file-naming scheme. For other common 3185 operations the user is advised to rely on standard Emacs facilities or 3186 specialised third-party packages. This section covers the details. 3187 3188 ** Create a new note in any directory 3189 :PROPERTIES: 3190 :CUSTOM_ID: h:c9d7c157-85a6-4bb7-bd21-d00bccf5e799 3191 :END: 3192 3193 The commands that create new files are designed to write to the 3194 ~denote-directory~. The idea is that the linking mechanism can find 3195 any file by its identifier if it is in the ~denote-directory~ 3196 (searching the entire file system would be cumbersome). 3197 3198 However, these are cases where the user needs to create a new note in 3199 an arbitrary directory. The following command can do this. Put the 3200 code in your configuration file and evaluate it. Then call the command 3201 by its name with =M-x=. 3202 3203 #+begin_src emacs-lisp 3204 (defun my-denote-create-note-in-any-directory () 3205 "Create new Denote note in any directory. 3206 Prompt for the directory using minibuffer completion." 3207 (declare (interactive-only t)) 3208 (interactive) 3209 (let ((denote-directory (read-directory-name "New note in: " nil nil :must-match))) 3210 (call-interactively 'denote))) 3211 #+end_src 3212 3213 ** Narrow the list of files in Dired 3214 :PROPERTIES: 3215 :CUSTOM_ID: h:ea173a01-69ef-4574-89a7-6e60ede02f13 3216 :END: 3217 3218 Emacs' standard file manager (or directory editor) can read a regular 3219 expression to mark the matching files. This is the command 3220 ~dired-mark-files-regexp~, which is bound to =% m= by default. For 3221 example, =% m _denote= will match all files that have the =denote= 3222 keyword ([[#h:1a953736-86c2-420b-b566-fb22c97df197][Features of the file-naming scheme for searching or filtering]]). 3223 3224 Once the files are matched, the user has two options: (i) narrow the 3225 list to the matching items or (ii) exclude the matching items from the 3226 list. 3227 3228 For the former, we want to toggle the marks by typing =t= (calls the 3229 command ~dired-toggle-marks~ by default) and then hit the letter =k= 3230 (for ~dired-do-kill-lines~). The remaining files are those that match 3231 the regexp that was provided earlier. 3232 3233 For the latter approach of filtering out the matching items, simply 3234 involves the use of the =k= command (~dired-do-kill-lines~) to omit the 3235 marked files from the list. 3236 3237 These sequences can be combined to incrementally narrow the list. Note 3238 that ~dired-do-kill-lines~ does not delete files: it simply hides them 3239 from the current view. 3240 3241 Revert to the original listing with =g= (~revert-buffer~). 3242 3243 For a convenient wrapper, consider this example: 3244 3245 #+begin_src emacs-lisp 3246 (defvar prot-dired--limit-hist '() 3247 "Minibuffer history for `prot-dired-limit-regexp'.") 3248 3249 ;;;###autoload 3250 (defun prot-dired-limit-regexp (regexp omit) 3251 "Limit Dired to keep files matching REGEXP. 3252 3253 With optional OMIT argument as a prefix (\\[universal-argument]), 3254 exclude files matching REGEXP. 3255 3256 Restore the buffer with \\<dired-mode-map>`\\[revert-buffer]'." 3257 (interactive 3258 (list 3259 (read-regexp 3260 (concat "Files " 3261 (when current-prefix-arg 3262 (propertize "NOT " 'face 'warning)) 3263 "matching PATTERN: ") 3264 nil 'prot-dired--limit-hist) 3265 current-prefix-arg)) 3266 (dired-mark-files-regexp regexp) 3267 (unless omit (dired-toggle-marks)) 3268 (dired-do-kill-lines)) 3269 #+end_src 3270 3271 ** Use ~dired-virtual-mode~ for arbitrary file listings 3272 :PROPERTIES: 3273 :CUSTOM_ID: h:d35d8d41-f51b-4139-af8f-9c8cc508e35b 3274 :END: 3275 3276 Emacs' Dired is a powerful file manager that builds its functionality 3277 on top of the Unix =ls= command. As noted elsewhere in this manual, 3278 the user can update the =ls= flags that Dired uses to display its 3279 contents ([[#h:a7fd5e0a-78f7-434e-aa2e-e150479c16e2][I want to sort by last modified, why won't Denote let me?]]). 3280 3281 What Dired cannot do is parse the output of a result that is produced 3282 by piped commands, such as =ls -l | sort -t _ -k2=. This specific 3283 example targets the second underscore-separated field of the file 3284 name, per our conventions ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). Conceretely, it 3285 matches the "alpha" as the sorting key in something like this: 3286 3287 #+begin_src emacs-lisp 3288 20220929T200432--testing-file-one__alpha.txt 3289 #+end_src 3290 3291 Consider then, how Dired will sort those files by their identifier: 3292 3293 #+begin_src emacs-lisp 3294 20220929T200432--testing-file-one__alpha.txt 3295 20220929T200532--testing-file-two__beta.txt 3296 20220929T200632--testing-file-three__alpha.txt 3297 20220929T200732--testing-file-four__beta.txt 3298 #+end_src 3299 3300 Whereas on the command line, we can get the following: 3301 3302 #+begin_example 3303 $ ls | sort -t _ -k 2 3304 20220929T200432--testing-file-one__alpha.txt 3305 20220929T200632--testing-file-three__alpha.txt 3306 20220929T200532--testing-file-two__beta.txt 3307 20220929T200732--testing-file-four__beta.txt 3308 #+end_example 3309 3310 This is where ~dired-virtual-mode~ shows its utility. If we tweak our 3311 command-line invocation to include =ls -l=, this mode can behave like 3312 Dired on the listed files. (We omit the output of the =-l= flag from 3313 this tutorial, as it is too verbose.) 3314 3315 What we now need is to capture the output of =ls -l | sort -t _ -k 2= 3316 in an Emacs buffer and then enable ~dired-virtual-mode~. To do that, 3317 we can rely on either =M-x shell= or =M-x eshell= and then manually 3318 copy the relevant contents. 3319 3320 For the user's convenience, I share what I have for Eshell to quickly 3321 capture the last command's output in a dedicated buffer: 3322 3323 #+begin_src emacs-lisp 3324 (defcustom prot-eshell-output-buffer "*Exported Eshell output*" 3325 "Name of buffer with the last output of Eshell command. 3326 Used by `prot-eshell-export'." 3327 :type 'string 3328 :group 'prot-eshell) 3329 3330 (defcustom prot-eshell-output-delimiter "* * *" 3331 "Delimiter for successive `prot-eshell-export' outputs. 3332 This is formatted internally to have newline characters before 3333 and after it." 3334 :type 'string 3335 :group 'prot-eshell) 3336 3337 (defun prot-eshell--command-prompt-output () 3338 "Capture last command prompt and its output." 3339 (let ((beg (save-excursion 3340 (goto-char (eshell-beginning-of-input)) 3341 (goto-char (point-at-bol))))) 3342 (when (derived-mode-p 'eshell-mode) 3343 (buffer-substring-no-properties beg (eshell-end-of-output))))) 3344 3345 ;;;###autoload 3346 (defun prot-eshell-export () 3347 "Produce a buffer with output of the last Eshell command. 3348 If `prot-eshell-output-buffer' does not exist, create it. Else 3349 append to it, while separating multiple outputs with 3350 `prot-eshell-output-delimiter'." 3351 (interactive) 3352 (let ((eshell-output (prot-eshell--command-prompt-output))) 3353 (with-current-buffer (get-buffer-create prot-eshell-output-buffer) 3354 (let ((inhibit-read-only t)) 3355 (goto-char (point-max)) 3356 (unless (eq (point-min) (point-max)) 3357 (insert (format "\n%s\n\n" prot-eshell-output-delimiter))) 3358 (goto-char (point-at-bol)) 3359 (insert eshell-output) 3360 (switch-to-buffer-other-window (current-buffer)))))) 3361 #+end_src 3362 3363 Bind ~prot-eshell-export~ to a key in the ~eshell-mode-map~ and give 3364 it a try (I use =C-c C-e=). In the produced buffer, activate the 3365 ~dired-virtual-mode~. 3366 3367 ** Use Embark to collect minibuffer candidates 3368 :PROPERTIES: 3369 :CUSTOM_ID: h:edf9b651-86eb-4d5f-bade-3c9e270082f0 3370 :END: 3371 3372 =embark= is a remarkable package that lets you perform relevant, 3373 context-dependent actions using a prefix key (simplifying in the 3374 interest of brevity). 3375 3376 For our purposes, Embark can be used to produce a Dired listing 3377 directly from the minibuffer. Suppose the current note has links to 3378 three other notes. You might use the ~denote-find-link~ command to 3379 pick one via the minibuffer. But why not turn those three links into 3380 their own Dired listing? While in the minibuffer, invoke ~embark-act~ 3381 which you may have already bound to =C-.= and then follow it up with 3382 =E= (for the ~embark-export~ command). 3383 3384 This pattern can be repeated with any list of candidates, meaning that 3385 you can narrow the list by providing some input before eventually 3386 exporting the results with Embark. 3387 3388 Overall, this is very powerful and you might prefer it over doing the 3389 same thing directly in Dired, since you also benefit from all the power 3390 of the minibuffer ([[#h:ea173a01-69ef-4574-89a7-6e60ede02f13][Narrow the list of files in Dired]]). 3391 3392 ** Search file contents 3393 :PROPERTIES: 3394 :CUSTOM_ID: h:76198fab-d6d2-4c67-9ccb-7a08cc883952 3395 :END: 3396 3397 Emacs provides built-in commands which are wrappers of standard Unix 3398 tools: =M-x grep= lets the user input the flags of a ~grep~ call and 3399 pass a regular expression to the =-e= flag. 3400 3401 The author of Denote uses this thin wrapper instead: 3402 3403 #+begin_src emacs-lisp 3404 (defvar prot-search--grep-hist '() 3405 "Input history of grep searches.") 3406 3407 ;;;###autoload 3408 (defun prot-search-grep (regexp &optional recursive) 3409 "Run grep for REGEXP. 3410 3411 Search in the current directory using `lgrep'. With optional 3412 prefix argument (\\[universal-argument]) for RECURSIVE, run a 3413 search starting from the current directory with `rgrep'." 3414 (interactive 3415 (list 3416 (read-from-minibuffer (concat (if current-prefix-arg 3417 (propertize "Recursive" 'face 'warning) 3418 "Local") 3419 " grep for PATTERN: ") 3420 nil nil nil 'prot-search--grep-hist) 3421 current-prefix-arg)) 3422 (unless grep-command 3423 (grep-compute-defaults)) 3424 (if recursive 3425 (rgrep regexp "*" default-directory) 3426 (lgrep regexp "*" default-directory))) 3427 #+end_src 3428 3429 Rather than maintain custom code, consider using the excellent =consult= 3430 package: it provides commands such as ~consult-grep~ and ~consult-find~ 3431 which provide live results and are generally easier to use than the 3432 built-in commands. 3433 3434 ** Bookmark the directory with the notes 3435 :PROPERTIES: 3436 :CUSTOM_ID: h:1bba4c1e-6812-4749-948f-57df4fd49b36 3437 :END: 3438 3439 Part of the reason Denote does not reinvent existing functionality is to 3440 encourage you to learn more about Emacs. You do not need a bespoke 3441 "jump to my notes" directory because such commands do not scale well. 3442 Will you have a "jump to my downloads" then another for multimedia and 3443 so on? No. 3444 3445 Emacs has a built-in framework for recording persistent markers to 3446 locations. Visit the ~denote-directory~ (or any dir/file for that 3447 matter) and invoke the ~bookmark-set~ command (bound to =C-x r m= by 3448 default). It lets you create a bookmark. 3449 3450 The list of bookmarks can be reviewed with the ~bookmark-bmenu-list~ 3451 command (bound to =C-x r l= by default). A minibuffer interface is 3452 available with ~bookmark-jump~ (=C-x r b=). 3453 3454 If you use the =consult= package, its default ~consult-buffer~ command 3455 has the means to group together buffers, recent files, and bookmarks. 3456 Each of those types can be narrowed to with a prefix key. The package 3457 =consult-dir= is an extension to =consult= which provides useful extras 3458 for working with directories, including bookmarks. 3459 3460 ** Use the ~denote-explore~ package to explore your notes 3461 :PROPERTIES: 3462 :CUSTOM_ID: h:110ae3a4-5fc6-45da-b9bb-0e294bd12981 3463 :END: 3464 3465 Peter Prevos has developed the ~denote-explore~ package which provides 3466 four groups of Emacs commands to explore your Denote files: 3467 3468 - Summary statistics :: Count notes, attachments and keywords. 3469 - Random walks :: Generate new ideas using serendipity. 3470 - Janitor :: Manage your denote collection. 3471 - Visualisations :: Visualise your Denote network. 3472 3473 The package's documentation covers the details: 3474 <https://lucidmanager.org/productivity/denote-explore/>. 3475 3476 ** Use the ~citar-denote~ package for bibliography notes 3477 :PROPERTIES: 3478 :CUSTOM_ID: h:226d66e4-b7de-4617-87e2-a7f2d6f007dd 3479 :END: 3480 3481 Peter Prevos has produced the ~citar-denote~ package which makes it 3482 possible to write notes on BibTeX entries with the help of the ~citar~ 3483 package. These notes have the citation's unique key associated with 3484 them in the file's front matter. They also get a configurable keyword 3485 in their file name, making it easy to find them in Dired and/or 3486 retrieve them with the various Denote methods. 3487 3488 With ~citar-denote~, the user leverages standard minibuffer completion 3489 mechanisms (e.g. with the help of the ~vertico~ and ~embark~ packages) 3490 to manage bibliographic notes and access those notes with ease. The 3491 package's documentation covers the details: <https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/>. 3492 3493 ** Use the ~consult-notes~ package 3494 :PROPERTIES: 3495 :CUSTOM_ID: h:8907f4bc-992a-45bc-a60e-267ed1ce9c2d 3496 :END: 3497 3498 If you are using Daniel Mendler's ~consult~ (which is a brilliant 3499 package), you will most probably like its ~consult-notes~ extension, 3500 developed by Colin McLear. It uses the familiar mechanisms of Consult 3501 to preview the currently selected entry and to filter searches via a 3502 prefix key. For example: 3503 3504 #+begin_src emacs-lisp 3505 (setq consult-notes-file-dir-sources 3506 `(("Denote Notes" ?d ,(denote-directory)) 3507 ("Books" ?b "~/Documents/books/"))) 3508 #+end_src 3509 3510 With the above, =M-x consult-notes= will list the files in those two 3511 directories. If you type =d= and space, it narrows the list to just 3512 the notes, while =b= does the same for books. 3513 3514 The other approach is to enable the ~consult-notes-denote-mode~. It 3515 takes care to add the ~denote-directory~ to the sources that 3516 ~consult-notes~ reads from. Denote notes are then filtered by the =d= 3517 prefix followed by a space. 3518 3519 The minor mode has the extra feature of reformatting the title of 3520 notes shown in the minibuffer. It isolates the =TITLE= component of 3521 each note and shows it without hyphens, while presenting keywords in 3522 their own column. The user option ~consult-notes-denote-display-id~ 3523 can be set to ~nil~ to hide the identifier. Depending on how one 3524 searches through their notes, this refashioned presentation may be the 3525 best option ([[#h:1a953736-86c2-420b-b566-fb22c97df197][Features of the file-naming scheme for searching or filtering]]). 3526 3527 ** Use the ~denote-menu~ package 3528 :PROPERTIES: 3529 :CUSTOM_ID: h:472db709-27de-4a1f-a171-c3fe0a7a9be8 3530 :END: 3531 3532 Denote's file-naming scheme is designed to be efficient and to provide 3533 valueable meta information about the file. The cost, however, is that 3534 it is terse and harder to read, depending on how the user chooses to 3535 filter and process their notes. 3536 3537 To this end, [[https://github.com/namilus/denote-menu][the ~denote-menu~ package by Mohamed Suliman]] provides the 3538 convenience of a nice tabular interface for all notes. ~denote-menu~ 3539 removes the delimiters that are found in Denote file names and 3540 presents the information in a human-readable format. Furthermore, the 3541 package provides commands to interact with the list of notes, such as 3542 to filter them and to transition from the tabular list to Dired. Its 3543 documentation expands on the technicalities. 3544 3545 ** Treat your notes as a project 3546 :PROPERTIES: 3547 :CUSTOM_ID: h:fad3eb08-ddc7-43e4-ba28-210d89668037 3548 :END: 3549 3550 Emacs has a built-in library for treating a directory tree as a 3551 "project". This means that the contents of this tree are seen as part 3552 of the same set, so commands like ~project-switch-to-buffer~ (=C-x p b= 3553 by default) will only consider buffers in the current project 3554 (e.g. three notes that are currently being visited). 3555 3556 Normally, a "project" is a directory tree whose root is under version 3557 control. For our purposes, all you need is to navigate to the 3558 ~denote-directory~ (for the shell or via Dired) and use the command-line 3559 to run this (requires the =git= executable): 3560 3561 : git init 3562 3563 From Dired, you can type =M-!= which invokes ~dired-smart-shell-command~ 3564 and then run the git call there. 3565 3566 The project can then be registered by invoking any project-related 3567 command inside of it, such as ~project-find-file~ (=C-x p f=). 3568 3569 It is a good idea to keep your notes under version control, as that 3570 gives you a history of changes for each file. We shall not delve into 3571 the technicalities here, though suffice to note that Emacs' built-in 3572 version control framework or the exceptionally well-crafted =magit= 3573 package will get the job done (VC can work with other backends besides 3574 Git). 3575 3576 ** Use the tree-based file prompt for select commands 3577 :PROPERTIES: 3578 :CUSTOM_ID: h:8f9e0971-8b30-4e7b-af79-8fed257dbcfa 3579 :END: 3580 3581 Older versions of Denote had a file prompt that resembled that of the 3582 standard ~find-file~ command (bound to =C-x C-f= by default). This 3583 means that it used a tree-based method of navigating the filesystem by 3584 selecting the specific directory and then the given file. 3585 3586 Currently, Denote flattens the file prompt so that every file in the 3587 ~denote-directory~ and its subdirectories can be matched from anywhere 3588 using the power of Emacs' minibuffer completion (such as with the help 3589 of the ~orderless~ package in addition to built-in options). 3590 3591 Users who need the old behaviour on a per-command basis can define 3592 their own wrapper functions as shown in the following code block. 3593 3594 #+begin_src emacs-lisp 3595 ;; This is the old `denote-file-prompt' that we renamed to 3596 ;; `denote-file-prompt-original' for clarity. 3597 (defun denote-file-prompt-original (&optional initial-text) 3598 "Prompt for file with identifier in variable `denote-directory'. 3599 With optional INITIAL-TEXT, use it to prepopulate the minibuffer." 3600 (read-file-name "Select note: " (denote-directory) nil nil initial-text 3601 (lambda (f) 3602 (or (denote-file-has-identifier-p f) 3603 (file-directory-p f))))) 3604 3605 ;; Our wrapper command that changes the current `denote-file-prompt' 3606 ;; to the functionality of `denote-file-prompt-original' only when 3607 ;; this command is used. 3608 (defun my-denote-link () 3609 "Call `denote-link' but use Denote's original file prompt. 3610 See `denote-file-prompt-original'." 3611 (interactive) 3612 (cl-letf (((symbol-function 'denote-file-prompt) #'denote-file-prompt-original)) 3613 (call-interactively #'denote-link))) 3614 #+end_src 3615 3616 ** Rename files with Denote in the Image Dired thumbnails buffer 3617 :PROPERTIES: 3618 :CUSTOM_ID: h:e666ced6-da75-4bdb-9be3-82c2f4455ee9 3619 :END: 3620 3621 [[#h:2d5ee9bf-e8f2-426c-8bf7-bf78bc88d1ee][Rename files with Denote using ~dired-preview~]] 3622 3623 Just as with the ~denote-dired-rename-marked-files-with-keywords~, 3624 we can use Denote in the Image Dired buffer ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files at once]]). 3625 Here is the custom code: 3626 3627 #+begin_src emacs-lisp 3628 (autoload 'image-dired--with-marked "image-dired") 3629 (autoload 'image-dired-original-file-name "image-dired-util") 3630 3631 (defun my-denote-image-dired-rename-marked-files (keywords) 3632 "Like `denote-dired-rename-marked-files-with-keywords' but for Image Dired. 3633 Prompt for KEYWORDS and rename all marked files in the Image 3634 Dired buffer to have a Denote-style file name with the given 3635 KEYWORDS. 3636 3637 IMPORTANT NOTE: if there are marked files in the corresponding 3638 Dired buffers, those will be targeted as well. This is not the 3639 fault of Denote: it is how Dired and Image Dired work in tandem. 3640 To only rename the marked thumbnails, start by unmarking 3641 everything in Dired. Then mark the items in Image Dired and 3642 invoke this command." 3643 (interactive (list (denote-keywords-prompt)) image-dired-thumbnail-mode) 3644 (image-dired--with-marked 3645 (when-let* ((file (image-dired-original-file-name)) 3646 (dir (file-name-directory file)) 3647 (id (or (denote-retrieve-filename-identifier file) "")) 3648 (file-type (denote-filetype-heuristics file)) 3649 (title (denote--retrieve-title-or-filename file file-type)) 3650 (signature (or (denote-retrieve-filename-signature file) "") 3651 (extension (file-name-extension file t)) 3652 (new-name (denote-format-file-name dir id keywords title extension signature)) 3653 (default-directory dir)) 3654 (denote-rename-file-and-buffer file new-name)))) 3655 #+end_src 3656 3657 While the ~my-denote-image-dired-rename-marked-files~ renames files in 3658 the helpful Denote-compliant way, users may still need to not prepend 3659 a unique identifier and not sluggify (hyphenate and downcase) the 3660 image's existing file name. To this end, the following custom command 3661 can be used instead: 3662 3663 #+begin_src emacs-lisp 3664 (defun my-image-dired-rename-marked-files (keywords) 3665 "Like `denote-dired-rename-marked-files-with-keywords' but for Image Dired. 3666 Prompt for keywords and rename all marked files in the Image 3667 Dired buffer to have Denote-style keywords, but none of the other 3668 conventions of Denote's file-naming scheme." 3669 (interactive (list (denote-keywords-prompt)) image-dired-thumbnail-mode) 3670 (image-dired--with-marked 3671 (when-let* ((file (image-dired-original-file-name)) 3672 (dir (file-name-directory file)) 3673 (file-type (denote-filetype-heuristics file)) 3674 (title (denote--retrieve-title-or-filename file file-type)) 3675 (extension (file-name-extension file t)) 3676 (kws (denote--keywords-combine keywords)) 3677 (new-name (concat dir title "__" kws extension)) 3678 (default-directory dir)) 3679 (denote-rename-file-and-buffer file new-name)))) 3680 #+end_src 3681 3682 ** Rename files with Denote using ~dired-preview~ 3683 :PROPERTIES: 3684 :CUSTOM_ID: h:2d5ee9bf-e8f2-426c-8bf7-bf78bc88d1ee 3685 :END: 3686 3687 The ~dired-preview~ package (by me/Protesilaos) automatically displays 3688 a preview of the file at point in Dired. This can be helpful in 3689 tandem with Denote when we want to rename multiple files by taking a 3690 quick look at their contents. 3691 3692 The command ~denote-dired-rename-marked-files-with-keywords~ 3693 will generate Denote-style file names based on the keywords it prompts 3694 for. Identifiers are derived from each file's modification date 3695 ([[#h:1b6b2c78-42f0-45b8-9ef0-6de21a8b2cde][Rename multiple files at once]]). There is no need for any custom code 3696 in this scenario. 3697 3698 As noted in the section about Image Dired, the user may sometimes not 3699 need a fully fledged Denote-style file name but only append Denote-like 3700 keywords to each file name (e.g. =Original Name__denote_test.jpg= 3701 instead of =20230710T195843--original-name__denote_test.jpg=). 3702 3703 [[#h:e666ced6-da75-4bdb-9be3-82c2f4455ee9][Rename files with Denote in the Image Dired thumbnails buffer]] 3704 3705 In such a workflow, it is unlikely to be dealing with ordinary text 3706 files where front matter can be helpful. A custom command does not 3707 need to behave like what Denote provides out-of-the-box, but can 3708 instead append keywords to file names without conducting any further 3709 actions. We thus have: 3710 3711 #+begin_src emacs-lisp 3712 (defun my-denote-dired-rename-marked-files-keywords-only () 3713 "Like `denote-dired-rename-marked-files-with-keywords' but only for keywords in file names. 3714 3715 Prompt for keywords and rename all marked files in the Dired 3716 buffer to only have Denote-style keywords, but none of the other 3717 conventions of Denote's file-naming scheme." 3718 (interactive nil dired-mode) 3719 (if-let ((marks (dired-get-marked-files))) 3720 (let ((keywords (denote-keywords-prompt))) 3721 (dolist (file marks) 3722 (let* ((dir (file-name-directory file)) 3723 (file-type (denote-filetype-heuristics file)) 3724 (title (denote--retrieve-title-or-filename file file-type)) 3725 (extension (file-name-extension file t)) 3726 (kws (denote--keywords-combine keywords)) 3727 (new-name (concat dir title "__" kws extension))) 3728 (denote-rename-file-and-buffer file new-name))) 3729 (revert-buffer)) 3730 (user-error "No marked files; aborting"))) 3731 #+end_src 3732 3733 ** Avoid duplicate identifiers when exporting Denote notes 3734 :PROPERTIES: 3735 :CUSTOM_ID: h:4a8c4546-26b3-4195-8b2c-b08a519986a4 3736 :END: 3737 3738 When exporting Denote notes to, for example, an HTML or PDF file, 3739 there is a high probability that the same file name is used with a new 3740 extension. This is problematic because it creates files with 3741 duplicate identifiers. The =20230515T085612--example__keyword.org= 3742 produces a =20230515T085612--example__keyword.pdf=. Any link to the 3743 =20230515T085612= will thus break: it does not honor Denote's 3744 expectation of finding unique identifiers. This is not the fault of 3745 Denote: exporting is done by the user without Denote's involvement. 3746 3747 Org Mode and Markdown use different approaches to exporting files. No 3748 recommended method is available for plain text files as there is no 3749 standardised export functionality for this format (the user can always 3750 create a new note using the file type they want on a case-by-case 3751 basis: [[#h:887bdced-9686-4e80-906f-789e407f2e8f][Convenience commands for note creation]]). 3752 3753 *** Export Denote notes with Org Mode 3754 :PROPERTIES: 3755 :CUSTOM_ID: h:67669d9d-17c3-45bd-8227-da57d8bc3b73 3756 :END: 3757 3758 Org Mode has a built-in configurable export engine. You can prevent 3759 duplicate identifiers when exporting manually for each exported file 3760 or by advising the Org export function. 3761 3762 Denote also provides commands to convert =denote:= links to their 3763 =file:= equivalent, in case this is a required pre-processing step for 3764 export purposes ([[#h:ed220cac-7dcb-4bb7-9243-1bb85e452e5f][Convert =denote:= links to =file:= links]]). 3765 3766 **** Manually configure Org export 3767 :PROPERTIES: 3768 :CUSTOM_ID: h:bf791e28-73e5-4ed8-88bc-e4e9b3ebaedb 3769 :END: 3770 3771 Insert =#+export_file_name: FILENAME= in the front matter before 3772 exporting to force a filename called whatever the value of =FILENAME= 3773 is. The =FILENAME= does not specify the file type extension, such as 3774 =.pdf=. This is up to the export engine. For example, a Denote note 3775 with a complete file name of =20230515T085612--example__keyword.org= 3776 and a front matter entry of =#+export_file_name: hello= will be 3777 exported as =hello.pdf=. 3778 3779 The advantage of this manual method is that it gives the user full 3780 control over the resulting file name. The disadvantage is that it 3781 depends on the user's behaviour. Forgetting to add a new name can 3782 lead to duplicate identifiers, as already noted in the introduction to 3783 this section ([[#h:4a8c4546-26b3-4195-8b2c-b08a519986a4][Export Denote notes]]). 3784 3785 **** Automatically store Org exports in another folder 3786 :PROPERTIES: 3787 :CUSTOM_ID: h:7a61a370-78e5-42a1-9650-98fee140723f 3788 :END: 3789 3790 It is possible to automatically place all exports in another folder by 3791 making Org's function ~org-export-output-file-name~ create the target 3792 directory if needed and move the exported file there. Remember that 3793 advising Elisp code must be handled with care, as it might break the 3794 original function in subtle ways. 3795 3796 #+begin_src emacs-lisp 3797 (defvar my-org-export-output-directory-prefix "./export_" 3798 "Prefix of directory used for org-mode export. 3799 3800 The single dot means that the directory is created on the same 3801 level as the one where the Org file that performs the exporting 3802 is. Use two dots to place the directory on a level above the 3803 current one. 3804 3805 If this directory is part of `denote-directory', make sure it is 3806 not read by Denote. See `denote-excluded-directories-regexp'. 3807 This way there will be no known duplicate Denote identifiers 3808 produced by the Org export mechanism.") 3809 3810 (defun my-org-export-create-directory (fn extension &rest args) 3811 "Move Org export file to its appropriate directory. 3812 3813 Append the file type EXTENSION of the exported file to 3814 `my-org-export-output-directory-prefix' and, if absent, create a 3815 directory named accordingly. 3816 3817 Install this as advice around `org-export-output-file-name'. The 3818 EXTENSION is supplied by that function. ARGS are its remaining 3819 arguments." 3820 (let ((export-dir (format "%s%s" my-org-export-output-directory-prefix extension))) 3821 (unless (file-directory-p export-dir) 3822 (make-directory export-dir))) 3823 (apply fn extension args)) 3824 3825 (advice-add #'org-export-output-file-name :around #'my-org-export-create-directory) 3826 #+end_src 3827 3828 The target export directory should not be a subdirectory of 3829 ~denote-directory~, as that will result in duplicate identifiers. 3830 Exclude it with the ~denote-excluded-directories-regexp~ user option 3831 ([[#h:8458f716-f9c2-4888-824b-2bf01cc5850a][Exclude certain directories from all operations]]). 3832 3833 [ NOTE: I (Protesilaos) am not a LaTeX user and cannot test the 3834 following. ] 3835 3836 Using a different directory will require some additional configuration 3837 when exporting using LaTeX. The export folder cannot be inside the 3838 path of the ~denote-directory~ to prevent Denote from recognising it 3839 as an attachment: 3840 <https://emacs.stackexchange.com/questions/45751/org-export-to-different-directory>. 3841 3842 **** Org Mode Publishing 3843 :PROPERTIES: 3844 :CUSTOM_ID: h:2f3451ed-2fc4-4f36-bcf2-112939963e20 3845 :END: 3846 3847 Org Mode also has a publishing tool for exporting a collection of 3848 files. Some user might apply this approach to convert their note 3849 collection to a public or private website. 3850 3851 The ~org-publish-project-alist~ variable drives the publishing 3852 process, including the publishing directory. 3853 3854 The publishing directory should not be a subdirectory of 3855 ~denote-directory~, as that will result in duplicate identifiers. 3856 Exclude it with the ~denote-excluded-directories-regexp~ user option 3857 ([[#h:8458f716-f9c2-4888-824b-2bf01cc5850a][Exclude certain directories from all operations]]). 3858 3859 *** Export Denote notes with Markdown 3860 :PROPERTIES: 3861 :CUSTOM_ID: h:44c6a34a-e9ad-4f43-a24f-12f2c5a8467e 3862 :END: 3863 3864 Exporting from Markdown requires an external processor (e.g., 3865 Markdown.pl, Pandoc, or MultiMarkdown). The ~markdown-command~ 3866 variable defines the command line used in export, for example: 3867 3868 #+begin_src emacs-lisp 3869 (setq markdown-command "multimarkdown") 3870 #+end_src 3871 3872 The export process thus occurs outside of Emacs. Users need to read 3873 the documentation of their preferred processor to prevent the creation 3874 of duplicate Denote identifiers. 3875 3876 * Installation 3877 :PROPERTIES: 3878 :CUSTOM_ID: h:f3bdac2c-4704-4a51-948c-a789a2589790 3879 :END: 3880 #+cindex: Installation instructions 3881 3882 ** GNU ELPA package 3883 :PROPERTIES: 3884 :CUSTOM_ID: h:42953f87-82bd-43ec-ab99-22b1e22955e7 3885 :END: 3886 3887 The package is available as =denote=. Simply do: 3888 3889 : M-x package-refresh-contents 3890 : M-x package-install 3891 3892 And search for it. 3893 3894 GNU ELPA provides the latest stable release. Those who prefer to follow 3895 the development process in order to report bugs or suggest changes, can 3896 use the version of the package from the GNU-devel ELPA archive. Read: 3897 https://protesilaos.com/codelog/2022-05-13-emacs-elpa-devel/. 3898 3899 ** Manual installation 3900 :PROPERTIES: 3901 :CUSTOM_ID: h:d397712c-c8c0-4cfa-ad1a-ef28cf78d1f0 3902 :END: 3903 3904 Assuming your Emacs files are found in =~/.emacs.d/=, execute the 3905 following commands in a shell prompt: 3906 3907 #+begin_src sh 3908 cd ~/.emacs.d 3909 3910 # Create a directory for manually-installed packages 3911 mkdir manual-packages 3912 3913 # Go to the new directory 3914 cd manual-packages 3915 3916 # Clone this repo, naming it "denote" 3917 git clone https://git.sr.ht/~protesilaos/denote denote 3918 #+end_src 3919 3920 Finally, in your =init.el= (or equivalent) evaluate this: 3921 3922 #+begin_src emacs-lisp 3923 ;; Make Elisp files in that directory available to the user. 3924 (add-to-list 'load-path "~/.emacs.d/manual-packages/denote") 3925 #+end_src 3926 3927 Everything is in place to set up the package. 3928 3929 * Sample configuration 3930 :PROPERTIES: 3931 :CUSTOM_ID: h:5d16932d-4f7b-493d-8e6a-e5c396b15fd6 3932 :END: 3933 #+cindex: Package configuration 3934 3935 #+begin_src emacs-lisp 3936 (require 'denote) 3937 3938 ;; Remember to check the doc strings of those variables. 3939 (setq denote-directory (expand-file-name "~/Documents/notes/")) 3940 (setq denote-save-buffer-after-creation nil) 3941 (setq denote-known-keywords '("emacs" "philosophy" "politics" "economics")) 3942 (setq denote-infer-keywords t) 3943 (setq denote-sort-keywords t) 3944 (setq denote-file-type nil) ; Org is the default, set others here 3945 (setq denote-prompts '(title keywords)) 3946 (setq denote-excluded-directories-regexp nil) 3947 (setq denote-excluded-keywords-regexp nil) 3948 (setq denote-rename-no-confirm nil) ; Set to t if you are familiar with `denote-rename-file' 3949 3950 ;; Pick dates, where relevant, with Org's advanced interface: 3951 (setq denote-date-prompt-use-org-read-date t) 3952 3953 3954 ;; Read this manual for how to specify `denote-templates'. We do not 3955 ;; include an example here to avoid potential confusion. 3956 3957 3958 (setq denote-date-format nil) ; read doc string 3959 3960 ;; By default, we do not show the context of links. We just display 3961 ;; file names. This provides a more informative view. 3962 (setq denote-backlinks-show-context t) 3963 3964 ;; Also see `denote-link-backlinks-display-buffer-action' which is a bit 3965 ;; advanced. 3966 3967 ;; If you use Markdown or plain text files (Org renders links as buttons 3968 ;; right away) 3969 (add-hook 'find-file-hook #'denote-link-buttonize-buffer) 3970 3971 ;; We use different ways to specify a path for demo purposes. 3972 (setq denote-dired-directories 3973 (list denote-directory 3974 (thread-last denote-directory (expand-file-name "attachments")) 3975 (expand-file-name "~/Documents/books"))) 3976 3977 ;; Generic (great if you rename files Denote-style in lots of places): 3978 ;; (add-hook 'dired-mode-hook #'denote-dired-mode) 3979 ;; 3980 ;; OR if only want it in `denote-dired-directories': 3981 (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories) 3982 3983 3984 ;; Automatically rename Denote buffers using the `denote-rename-buffer-format'. 3985 (denote-rename-buffer-mode 1) 3986 3987 ;; Denote DOES NOT define any key bindings. This is for the user to 3988 ;; decide. For example: 3989 (let ((map global-map)) 3990 (define-key map (kbd "C-c n n") #'denote) 3991 (define-key map (kbd "C-c n c") #'denote-region) ; "contents" mnemonic 3992 (define-key map (kbd "C-c n N") #'denote-type) 3993 (define-key map (kbd "C-c n d") #'denote-date) 3994 (define-key map (kbd "C-c n z") #'denote-signature) ; "zettelkasten" mnemonic 3995 (define-key map (kbd "C-c n s") #'denote-subdirectory) 3996 (define-key map (kbd "C-c n t") #'denote-template) 3997 ;; If you intend to use Denote with a variety of file types, it is 3998 ;; easier to bind the link-related commands to the `global-map', as 3999 ;; shown here. Otherwise follow the same pattern for `org-mode-map', 4000 ;; `markdown-mode-map', and/or `text-mode-map'. 4001 (define-key map (kbd "C-c n i") #'denote-link) ; "insert" mnemonic 4002 (define-key map (kbd "C-c n I") #'denote-add-links) 4003 (define-key map (kbd "C-c n b") #'denote-backlinks) 4004 (define-key map (kbd "C-c n f f") #'denote-find-link) 4005 (define-key map (kbd "C-c n f b") #'denote-find-backlink) 4006 ;; Note that `denote-rename-file' can work from any context, not just 4007 ;; Dired bufffers. That is why we bind it here to the `global-map'. 4008 (define-key map (kbd "C-c n r") #'denote-rename-file) 4009 (define-key map (kbd "C-c n R") #'denote-rename-file-using-front-matter)) 4010 4011 ;; Key bindings specifically for Dired. 4012 (let ((map dired-mode-map)) 4013 (define-key map (kbd "C-c C-d C-i") #'denote-link-dired-marked-notes) 4014 (define-key map (kbd "C-c C-d C-r") #'denote-dired-rename-files) 4015 (define-key map (kbd "C-c C-d C-k") #'denote-dired-rename-marked-files-with-keywords) 4016 (define-key map (kbd "C-c C-d C-R") #'denote-dired-rename-marked-files-using-front-matter)) 4017 4018 (with-eval-after-load 'org-capture 4019 (setq denote-org-capture-specifiers "%l\n%i\n%?") 4020 (add-to-list 'org-capture-templates 4021 '("n" "New note (with denote.el)" plain 4022 (file denote-last-path) 4023 #'denote-org-capture 4024 :no-save t 4025 :immediate-finish nil 4026 :kill-buffer t 4027 :jump-to-captured t))) 4028 4029 ;; Also check the commands `denote-link-after-creating', 4030 ;; `denote-link-or-create'. You may want to bind them to keys as well. 4031 4032 4033 ;; If you want to have Denote commands available via a right click 4034 ;; context menu, use the following and then enable 4035 ;; `context-menu-mode'. 4036 (add-hook 'context-menu-functions #'denote-context-menu) 4037 #+end_src 4038 4039 * For developers or advanced users 4040 :PROPERTIES: 4041 :CUSTOM_ID: h:c916d8c5-540a-409f-b780-6ccbd90e088e 4042 :END: 4043 4044 Denote is in a stable state and can be relied upon as the basis for 4045 custom extensions. Further below is a list with the functions or 4046 variables we provide for public usage. Those are in addition to all 4047 user options and commands that are already documented in the various 4048 sections of this manual. 4049 4050 In this context "public" is any form with single hyphens in its symbol, 4051 such as ~denote-directory-files~. We expressly support those, meaning 4052 that we consider them reliable and commit to documenting any changes in 4053 their particularities (such as through ~make-obsolete~, a record in the 4054 change log, a blog post on the maintainer's website, and the like). 4055 4056 By contradistinction, a "private" form is declared with two hyphens in 4057 its symbol such as ~denote--file-extension~. Do not use those as we 4058 might change them without further notice. 4059 4060 #+vindex: denote-id-format 4061 + Variable ~denote-id-format~ :: Format of ID prefix of a note's 4062 filename. The note's ID is derived from the date and time of its 4063 creation ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 4064 4065 #+vindex: denote-id-regexp 4066 + Variable ~denote-id-regexp~ :: Regular expression to match 4067 ~denote-id-format~. 4068 4069 #+vindex: denote-signature-regexp 4070 + Variable ~denote-signature-regexp~ :: Regular expression to match 4071 the =SIGNATURE= field in a file name. 4072 4073 #+vindex: denote-title-regexp 4074 + Variable ~denote-title-regexp~ :: Regular expression to match the 4075 =TITLE= field in a file name ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 4076 4077 #+vindex: denote-keywords-regexp 4078 + Variable ~denote-keywords-regexp~ :: Regular expression to match the 4079 =KEYWORDS= field in a file name ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 4080 4081 #+vindex: denote-excluded-punctuation-regexp 4082 + Variable ~denote-excluded-punctuation-regexp~ :: Punctionation that 4083 is removed from file names. We consider those characters illegal 4084 for our purposes. 4085 4086 #+vindex: denote-excluded-punctuation-extra-regexp 4087 + Variable ~denote-excluded-punctuation-extra-regexp~ :: Additional 4088 punctuation that is removed from file names. This variable is for 4089 advanced users who need to extend the ~denote-excluded-punctuation-regexp~. 4090 Once we have a better understanding of what we should be omitting, 4091 we will update things accordingly. 4092 4093 #+findex: denote-file-is-note-p 4094 + Function ~denote-file-is-note-p~ :: Return non-nil if =FILE= is an 4095 actual Denote note. For our purposes, a note must not be a 4096 directory, must satisfy ~file-regular-p~, its path must be part of 4097 the variable ~denote-directory~, it must have a Denote identifier in 4098 its name, and use one of the extensions implied by 4099 ~denote-file-type~. 4100 4101 #+findex: denote-file-has-identifier-p 4102 + Function ~denote-file-has-identifier-p~ :: Return non-nil if =FILE= 4103 has a Denote identifier. 4104 4105 #+findex: denote-file-has-signature-p 4106 + Function ~denote-file-has-signature-p~ :: Return non-nil if =FILE= 4107 has a signature. 4108 4109 #+findex: denote-file-has-supported-extension-p 4110 + Function ~denote-file-has-supported-extension-p~ :: Return non-nil 4111 if =FILE= has supported extension. Also account for the possibility 4112 of an added =.gpg= suffix. Supported extensions are those implied by 4113 ~denote-file-type~. 4114 4115 #+findex: denote-file-is-writable-and-supported-p 4116 + Function ~denote-file-is-writable-and-supported-p~ :: Return non-nil 4117 if =FILE= is writable and has supported extension. 4118 4119 #+findex: denote-file-type-extensions 4120 + Function ~denote-file-type-extensions~ :: Return all file type 4121 extensions in ~denote-file-types~. 4122 4123 #+vindex: denote-encryption-file-extensions 4124 + Variable ~denote-encryption-file-extensions~ :: List of strings 4125 specifying file extensions for encryption. 4126 4127 #+findex: denote-file-type-extensions-with-encryption 4128 + Function ~denote-file-type-extensions-with-encryption~ :: Derive 4129 ~denote-file-type-extensions~ plus ~denote-encryption-file-extensions~. 4130 4131 #+findex: denote-get-file-extension 4132 + Function ~denote-get-file-extension~ :: Return extension of =FILE= 4133 with dot included. Account for ~denote-encryption-file-extensions~. 4134 In other words, return something like =.org.gpg= if it is part of 4135 the file, else return =.org=. 4136 4137 #+findex: denote-get-file-extension-sans-encryption 4138 + Function ~denote-get-file-extension-sans-encryption~ :: Return 4139 extension of =FILE= with dot included and without the encryption 4140 part. Build on top of ~denote-get-file-extension~ though always 4141 return something like =.org= even if the actual file extension is 4142 =.org.gpg=. 4143 4144 #+findex: denote-keywords 4145 + Function ~denote-keywords~ :: Return appropriate list of keyword 4146 candidates. If ~denote-infer-keywords~ is non-nil, infer keywords 4147 from existing notes and combine them into a list with 4148 ~denote-known-keywords~. Else use only the latter set of keywords 4149 ([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]). 4150 4151 #+findex: denote-convert-file-name-keywords-to-crm 4152 + Function ~denote-convert-file-name-keywords-to-crm~ :: Make =STRING= 4153 with keywords readable by ~completing-read-multiple~. =STRING= 4154 consists of underscore-separated words, as those appear in the 4155 keywords component of a Denote file name. =STRING= is the same as 4156 the return value of ~denote-retrieve-filename-keywords~. 4157 4158 #+findex: denote-keywords-sort 4159 + Function ~denote-keywords-sort~ :: Sort =KEYWORDS= if 4160 ~denote-sort-keywords~ is non-nil. =KEYWORDS= is a list of strings, 4161 per ~denote-keywords-prompt~. 4162 4163 #+findex: denote-keywords-combine 4164 + Function ~denote-keywords-combine~ :: Combine =KEYWORDS= list of 4165 strings into a single string. Keywords are separated by the 4166 underscore character, per the Denote file-naming scheme. 4167 4168 #+findex: denote-valid-date-p 4169 + Function ~denote-valid-date-p~ :: Return =DATE= as a valid date. A 4170 valid =DATE= is a value that can be parsed by either ~decode-time~ 4171 or ~date-to-time~ .Those functions signal an error if =DATE= is a 4172 value they do not recognise. If =DATE= is nil, return nil. 4173 4174 #+findex: denote-parse-date 4175 + Function ~denote-parse-date~ :: Return =DATE= as an appropriate 4176 value for the ~denote~ command. Pass =DATE= through 4177 ~denote-valid-date-p~ and use its return value. If either that or 4178 =DATE= is nil, return ~current-time~. 4179 4180 #+findex: denote-directory 4181 + Function ~denote-directory~ :: Return path of the variable 4182 ~denote-directory~ as a proper directory, also because it accepts a 4183 directory-local value for what we internally refer to as "silos" 4184 ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories for notes]]). Custom Lisp code can 4185 ~let~ bind the value of the variable ~denote-directory~ 4186 to override what this function returns. 4187 4188 #+findex: denote-directory-files 4189 + Function ~denote-directory-files~ :: Return list of absolute file 4190 paths in variable ~denote-directory~. Files only need to have an 4191 identifier. The return value may thus include file types that are 4192 not implied by ~denote-file-type~. Remember that the variable 4193 ~denote-directory~ accepts a dir-local value, as explained in its 4194 doc string ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories for notes]]). With optional 4195 =FILES-MATCHING-REGEXP=, restrict files to those matching the given 4196 regular expression. With optional =OMIT-CURRENT= as a non-nil value, 4197 do not include the current Denote file in the returned list. With 4198 optional =TEXT-ONLY= as a non-nil value, limit the results to text 4199 files that satisfy ~denote-file-is-note-p~. 4200 4201 #+findex: denote-directory-subdirectories 4202 + Function ~denote-directory-subdirectories~ :: Return list of 4203 subdirectories in variable ~denote-directory~. Omit dotfiles (such 4204 as .git) unconditionally. Also exclude whatever matches 4205 ~denote-excluded-directories-regexp~. Note that the 4206 ~denote-directory~ accepts a directory-local value for what we call 4207 "silos" ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories for notes]]). 4208 4209 #+findex: denote-file-name-relative-to-denote-directory 4210 + Function ~denote-file-name-relative-to-denote-directory~ :: Return 4211 name of =FILE= relative to the variable ~denote-directory~. =FILE= 4212 must be an absolute path. 4213 4214 #+findex: denote-get-path-by-id 4215 + Function ~denote-get-path-by-id~ :: Return absolute path of =ID= 4216 string in ~denote-directory-files~. 4217 4218 #+findex: denote-barf-duplicate-id 4219 + Function ~denote-barf-duplicate-id~ :: Throw a ~user-error~ if 4220 =IDENTIFIER= already exists. 4221 4222 #+findex: denote-sluggify 4223 + Function ~denote-sluggify~ :: Make =STR= an appropriate slug for 4224 file names and related ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). 4225 4226 #+findex: denote-sluggify-keyword 4227 + Function ~denote-sluggify-keyword~ :: Sluggify =STR= while joining 4228 separate words. 4229 4230 #+findex: denote-sluggify-signature 4231 + Function ~denote-sluggify-signature~ :: Make =STR= an appropriate 4232 slug for signatures ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). 4233 4234 #+findex: denote-sluggify-keywords 4235 + Function ~denote-sluggify-keywords~ :: Sluggify =KEYWORDS=, which is 4236 a list of strings ([[#h:ae8b19a1-7f67-4258-96b3-370a72c43f4e][Sluggification of file name components]]). 4237 4238 #+findex: denote-filetype-heuristics 4239 + Function ~denote-filetype-heuristics~ :: Return likely file type of 4240 =FILE=. If in the process of ~org-capture~, consider the file type to 4241 be that of Org. Otherwise, use the file extension to detect the file 4242 type of =FILE=. 4243 4244 If more than one file type correspond to this file extension, use 4245 the first file type for which the :title-key-regexp in 4246 ~denote-file-types~ matches in the file. 4247 4248 If no file type in ~denote-file-types~ has the file extension, the 4249 file type is assumed to be the first one in ~denote-file-types~. 4250 4251 #+findex: denote-format-file-name 4252 + Function ~denote-format-file-name~ :: Format file name. =DIR-PATH=, 4253 =ID=, =KEYWORDS=, =TITLE=, =EXTENSION= and =SIGNATURE= are expected to 4254 be supplied by ~denote~ or equivalent command. 4255 4256 =DIR-PATH= is a string pointing to a directory. It ends with a 4257 forward slash (the function ~denote-directory~ makes sure this is 4258 the case when returning the value of the variable ~denote-directory~). 4259 =DIR-PATH= cannot be nil or an empty string. 4260 4261 =ID= is a string holding the identifier of the note. It cannot be 4262 nil or an empty string and must match ~denote-id-regexp~. 4263 4264 =DIR-PATH= and =ID= form the base file name. 4265 4266 =KEYWORDS= is a list of strings that is reduced to a single string 4267 by ~denote-keywords-combine~. =KEYWORDS= can be an empty list or a 4268 nil value, in which case the relevant file name component is not 4269 added to the base file name. 4270 4271 =TITLE= and =SIGNATURE= are strings. They can be an empty string, in 4272 which case their respective file name component is not added to the 4273 base file name. 4274 4275 =EXTENSION= is a string that contains a dot followed by the file 4276 type extension. It can be an empty string or a nil value, in which 4277 case it is not added to the base file name. 4278 4279 #+findex: denote-extract-keywords-from-path 4280 + Function ~denote-extract-keywords-from-path~ :: Extract keywords 4281 from =PATH= and return them as a list of strings. =PATH= must be a 4282 Denote-style file name where keywords are prefixed with an 4283 underscore. If =PATH= has no such keywords, which is possible, 4284 return nil ([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]). 4285 4286 #+findex: denote-extract-id-from-string 4287 + Function ~denote-extract-id-from-string~ :: Return existing Denote 4288 identifier in =STRING=, else nil. 4289 4290 #+findex: denote-retrieve-filename-identifier 4291 + Function ~denote-retrieve-filename-identifier~ :: Extract identifier 4292 from =FILE= name, if present, else return nil. To create a new one, refer to the 4293 ~denote-create-unique-file-identifier~ function. 4294 4295 #+findex: denote-retrieve-filename-title 4296 + Function ~denote-retrieve-filename-title~ :: Extract Denote title 4297 component from =FILE= name, if present, else return nil. 4298 4299 #+findex: denote-retrieve-filename-keywords 4300 + Function ~denote-retrieve-filename-keywords~ :: Extract keywords 4301 from =FILE= name, if present, else return nil. Return 4302 matched keywords as a single string. 4303 4304 #+findex: denote-retrieve-filename-signature 4305 + Function ~denote-retrieve-filename-signature~ :: Extract signature 4306 from =FILE= name, if present, else return nil. 4307 4308 #+findex: denote-retrieve-title-or-filename 4309 + Function ~denote-retrieve-title-or-filename~ :: Return appropriate 4310 title for =FILE= given its =TYPE=. Try to find the value of the 4311 title in the front matter of FILE, otherwise use its file name. This 4312 is a wrapper for ~denote-retrieve-front-matter-title-value~ and 4313 =denote-retrieve-filename-title=. 4314 4315 #+findex: denote-get-identifier 4316 + Function ~denote-get-identifier~ :: Convert =DATE= into a Denote 4317 identifier using ~denote-id-format~. =DATE= is parsed by 4318 ~denote-valid-date-p~. If =DATE= is nil, use the current time. 4319 4320 #+findex: denote-create-unique-file-identifier 4321 + Function ~denote-create-unique-file-identifier~ :: Create a new unique 4322 =FILE= identifier. Test that the identifier is unique among 4323 =USED-IDS=. The conditions are as follows: 4324 4325 - If =DATE= is non-nil, invoke ~denote-prompt-for-date-return-id~. 4326 4327 - If =DATE= is nil, use the file attributes to determine the last 4328 modified date and format it as an identifier. 4329 4330 - As a fallback, derive an identifier from the current time. 4331 4332 With optional =USED-IDS= as nil, test that the identifier is unique 4333 among all files and buffers in variable ~denote-directory~. 4334 4335 To only return an existing identifier, refer to the function 4336 ~denote-retrieve-filename-identifier~. 4337 4338 #+findex: denote-retrieve-front-matter-title-value 4339 + Function ~denote-retrieve-front-matter-title-value~ :: Return title value from 4340 =FILE= front matter per =FILE-TYPE=. 4341 4342 #+findex: denote-retrieve-front-matter-title-line 4343 + Function ~denote-retrieve-front-matter-title-line~ :: Return title line from 4344 =FILE= front matter per =FILE-TYPE=. 4345 4346 #+findex: denote-retrieve-front-matter-keywords-value 4347 + Function ~denote-retrieve-front-matter-keywords-value~ :: Return keywords value 4348 from =FILE= front matter per =FILE-TYPE=. The return value is a list 4349 of strings. To get a combined string the way it would appear in a 4350 Denote file name, use ~denote-retrieve-front-matter-keywords-value-as-string~. 4351 4352 #+findex: denote-retrieve-front-matter-keywords-value-as-string 4353 + Function ~denote-retrieve-front-matter-keywords-value-as-string~ :: Return 4354 keywords value from =FILE= front matter per =FILE-TYPE=. The return 4355 value is a string, with the underscrore as a separator between 4356 individual keywords. To get a list of strings instead, use 4357 ~denote-retrieve-front-matter-keywords-value~ (the current function uses that 4358 internally). 4359 4360 #+findex: denote-retrieve-front-matter-keywords-line 4361 + Function ~denote-retrieve-front-matter-keywords-line~ :: Return keywords line 4362 from =FILE= front matter per =FILE-TYPE=. 4363 4364 #+findex: denote-signature-prompt 4365 + Function ~denote-signature-prompt~ :: Prompt for signature string. 4366 With optional =INITIAL-SIGNATURE= use it as the initial minibuffer 4367 text. With optional =PROMPT-TEXT= use it in the minibuffer instead 4368 of the default prompt. Previous inputs at this prompt are available 4369 for minibuffer completion if the user option ~denote-history-completion-in-prompts~ 4370 is set to a non-nil value ([[#h:403422a7-7578-494b-8f33-813874c12da3][The ~denote-history-completion-in-prompts~ option]]). 4371 4372 #+findex: denote-file-prompt 4373 + Function ~denote-file-prompt~ :: Prompt for file with identifier in 4374 variable ~denote-directory~. With optional =FILES-MATCHING-REGEXP=, 4375 filter the candidates per the given regular expression. With 4376 optional =PROMPT-TEXT=, use it instead of the default "Select NOTE". 4377 4378 #+findex: denote-keywords-prompt 4379 + Function ~denote-keywords-prompt~ :: Prompt for one or more keywords. 4380 Read entries as separate when they are demarcated by the 4381 ~crm-separator~, which typically is a comma. With optional 4382 =PROMPT-TEXT=, use it to prompt the user for keywords. Else use a 4383 generic prompt. With optional =INITIAL-KEYWORDS= use them as the 4384 initial minibuffer text. 4385 4386 #+findex: denote-title-prompt 4387 + Function ~denote-title-prompt~ :: Prompt for title string. With 4388 optional =INITIAL-TITLE= use it as the initial minibuffer text. With 4389 optional =PROMPT-TEXT= use it in the minibuffer instead of the 4390 default prompt. Previous inputs at this prompt are available 4391 for minibuffer completion if the user option ~denote-history-completion-in-prompts~ 4392 is set to a non-nil value ([[#h:403422a7-7578-494b-8f33-813874c12da3][The ~denote-history-completion-in-prompts~ option]]). 4393 4394 #+vindex: denote-title-prompt-current-default 4395 + Variable ~denote-title-prompt-current-default~ :: Currently bound 4396 default title for ~denote-title-prompt~. Set the value of this 4397 variable within the lexical scope of a command that needs to supply 4398 a default title before calling ~denote-title-prompt~ and use 4399 ~unwind-protect~ to set its value back to nil. 4400 4401 #+findex: denote-file-type-prompt 4402 + Function ~denote-file-type-prompt~ :: Prompt for ~denote-file-type~. 4403 Note that a non-nil value other than ~text~, ~markdown-yaml~, and 4404 ~markdown-toml~ falls back to an Org file type. We use ~org~ here 4405 for clarity. 4406 4407 #+findex: denote-date-prompt 4408 + Function ~denote-date-prompt~ :: Prompt for date, expecting 4409 =YYYY-MM-DD= or that plus =HH:MM= (or even =HH:MM:SS=). Use Org's 4410 more advanced date selection utility if the user option 4411 ~denote-date-prompt-use-org-read-date~ is non-nil. It requires Org 4412 ([[#h:e7ef08d6-af1b-4ab3-bb00-494a653e6d63][The denote-date-prompt-use-org-read-date option]]). 4413 4414 #+findex: denote-command-prompt 4415 + Function ~denote-command-prompt~ :: Prompt for command among 4416 ~denote-commands-for-new-notes~ ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). 4417 4418 #+vindex: denote-prompts-with-history-as-completion 4419 + Variable ~denote-prompts-with-history-as-completion~ :: Prompts that 4420 conditionally perform completion against their history. These are 4421 minibuffer prompts that ordinarily accept a free form string input, 4422 as opposed to matching against a predefined set. These prompts can 4423 optionally perform completion against their own minibuffer history 4424 when the user option ~denote-history-completion-in-prompts~ is set 4425 to a non-nil value ([[#h:403422a7-7578-494b-8f33-813874c12da3][The ~denote-history-completion-in-prompts~ option]]). 4426 4427 #+findex: denote-files-matching-regexp-prompt 4428 + Function ~denote-files-matching-regexp-prompt~ :: Prompt for 4429 =REGEXP= to filter Denote files by. With optional =PROMPT-TEXT= use 4430 it instead of a generic prompt. 4431 4432 #+findex: denote-prompt-for-date-return-id 4433 + Function ~denote-prompt-for-date-return-id~ :: Use 4434 ~denote-date-prompt~ and return it as ~denote-id-format~. 4435 4436 #+findex: denote-template-prompt 4437 + Function ~denote-template-prompt~ :: Prompt for template key in 4438 ~denote-templates~ and return its value. 4439 4440 #+findex: denote-subdirectory-prompt 4441 + Function ~denote-subdirectory-prompt~ :: Prompt for subdirectory of 4442 the variable ~denote-directory~. The table uses the ~file~ 4443 completion category (so it works with packages such as ~marginalia~ 4444 and ~embark~). 4445 4446 #+findex: denote-rename-file-prompt 4447 + Function ~denote-rename-file-prompt~ :: Prompt to rename file named 4448 =OLD-NAME= to =NEW-NAME=. 4449 4450 #+findex: denote-rename-file-and-buffer 4451 + Function ~denote-rename-file-and-buffer~ :: Rename file named 4452 =OLD-NAME= to =NEW-NAME=, updating buffer name. 4453 4454 #+findex: denote-rewrite-front-matter 4455 + Function ~denote-rewrite-front-matter~ :: Rewrite front matter of 4456 note after ~denote-rename-file~ (or related) The =FILE=, =TITLE=, 4457 =KEYWORDS=, and =FILE-TYPE= arguments are given by the renaming 4458 command and are used to construct new front matter values if 4459 appropriate. With optional =NO-CONFIRM=, do not prompt to confirm 4460 the rewriting of the front matter. Otherwise produce a ~y-or-n-p~ 4461 prompt to that effect. With optional =NO-CONFIRM=, save the buffer 4462 after performing the rewrite. Otherwise leave it unsaved for 4463 furthter review by the user. 4464 4465 #+findex: denote-rewrite-keywords 4466 + Function ~denote-rewrite-keywords~ :: Rewrite =KEYWORDS= in =FILE= 4467 outright according to =FILE-TYPE=. Do the same as 4468 ~denote-rewrite-front-matter~ for keywords, but do not ask for 4469 confirmation. With optional =SAVE-BUFFER=, save the buffer 4470 corresponding to =FILE=. This function is for use in the commands 4471 ~denote-keywords-add~, ~denote-keywords-remove~, 4472 ~denote-dired-rename-files~, or related. 4473 4474 #+findex: denote-update-dired-buffers 4475 + Function ~denote-update-dired-buffers~ :: Update Dired buffers of 4476 variable ~denote-directory~. Also revert the current Dired buffer 4477 even if it is not inside the ~denote-directory~. Note that the 4478 ~denote-directory~ accepts a directory-local value for what we 4479 internally refer to as "silos" ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directories for notes]]). 4480 4481 #+vindex: denote-file-types 4482 + Variable ~denote-file-types~ :: Alist of ~denote-file-type~ and 4483 their format properties. 4484 4485 Each element is of the form =(SYMBOL PROPERTY-LIST)=. =SYMBOL= is 4486 one of those specified in ~denote-file-type~ or an arbitrary symbol 4487 that defines a new file type. 4488 4489 =PROPERTY-LIST= is a plist that consists of the following elements: 4490 4491 1. =:extension= is a string with the file extension including the 4492 period. 4493 4494 2. =:date-function= is a function that can format a date. See the 4495 functions ~denote--date-iso-8601~, ~denote--date-rfc3339~, and 4496 ~denote--date-org-timestamp~. 4497 4498 3. =:front-matter= is either a string passed to ~format~ or a 4499 variable holding such a string. The ~format~ function accepts 4500 four arguments, which come from ~denote~ in this order: =TITLE=, 4501 =DATE=, =KEYWORDS=, =IDENTIFIER=. Read the doc string of 4502 ~format~ on how to reorder arguments. 4503 4504 4. =:title-key-regexp= is a regular expression that is used to 4505 retrieve the title line in a file. The first line matching this 4506 regexp is considered the title line. 4507 4508 5. =:title-value-function= is the function used to format the raw 4509 title string for inclusion in the front matter (e.g. to surround 4510 it with quotes). Use the ~identity~ function if no further 4511 processing is required. 4512 4513 6. =:title-value-reverse-function= is the function used to retrieve 4514 the raw title string from the front matter. It performs the 4515 reverse of =:title-value-function=. 4516 4517 7. =:keywords-key-regexp= is a regular expression used to retrieve 4518 the keywords' line in the file. The first line matching this 4519 regexp is considered the keywords' line. 4520 4521 8. =:keywords-value-function= is the function used to format the 4522 keywords' list of strings as a single string, with appropriate 4523 delimiters, for inclusion in the front matter. 4524 4525 9. =:keywords-value-reverse-function= is the function used to retrieve 4526 the keywords' value from the front matter. It performs the reverse 4527 of the =:keywords-value-function=. 4528 4529 10. =:link= is a string, or variable holding a string, that 4530 specifies the format of a link. See the variables 4531 ~denote-org-link-format~, ~denote-md-link-format~. 4532 4533 11. =:link-in-context-regexp= is a regular expression that is used 4534 to match the aforementioned link format. See the variables 4535 ~denote-org-link-in-context-regexp~, ~denote-md-link-in-context-regexp~. 4536 4537 If ~denote-file-type~ is nil, use the first element of this list for 4538 new note creation. The default is ~org~. 4539 4540 #+vindex: denote-org-front-matter 4541 + Variable ~denote-org-front-matter~ :: Specifies the Org front 4542 matter. It is passed to ~format~ with arguments =TITLE=, =DATE=, 4543 =KEYWORDS=, =ID= ([[#h:7f918854-5ed4-4139-821f-8ee9ba06ad15][Change the front matter format]]) 4544 4545 #+vindex: denote-yaml-front-matter 4546 + Variable ~denote-yaml-front-matter~ :: Specifies the YAML (Markdown) 4547 front matter. It is passed to ~format~ with arguments =TITLE=, 4548 =DATE=, =KEYWORDS=, =ID= ([[#h:7f918854-5ed4-4139-821f-8ee9ba06ad15][Change the front matter format]]) 4549 4550 #+vindex: denote-toml-front-matter 4551 + Variable ~denote-toml-front-matter~ :: Specifies the TOML (Markdown) 4552 front matter. It is passed to ~format~ with arguments =TITLE=, 4553 =DATE=, =KEYWORDS=, =ID= ([[#h:7f918854-5ed4-4139-821f-8ee9ba06ad15][Change the front matter format]]) 4554 4555 #+vindex: denote-text-front-matter 4556 + Variable ~denote-text-front-matter~ :: Specifies the plain text 4557 front matter. It is passed to ~format~ with arguments =TITLE=, 4558 =DATE=, =KEYWORDS=, =ID= ([[#h:7f918854-5ed4-4139-821f-8ee9ba06ad15][Change the front matter format]]) 4559 4560 #+vindex: denote-org-link-format 4561 + Variable ~denote-org-link-format~ :: Format of Org link to note. 4562 The value is passed to ~format~ with =IDENTIFIER= and =TITLE= 4563 arguments, in this order. Also see ~denote-org-link-in-context-regexp~. 4564 4565 #+vindex: denote-md-link-format 4566 + Variable ~denote-md-link-format~ :: Format of Markdown link to note. 4567 The =%N$s= notation used in the default value is for ~format~ as the 4568 supplied arguments are =IDENTIFIER= and =TITLE=, in this order. 4569 Also see ~denote-md-link-in-context-regexp~. 4570 4571 #+vindex: denote-id-only-link-format 4572 + Variable ~denote-id-only-link-format~ :: Format of identifier-only 4573 link to note. The value is passed to ~format~ with =IDENTIFIER= as 4574 its sole argument. Also see ~denote-id-only-link-in-context-regexp~. 4575 4576 #+vindex: denote-org-link-in-context-regexp 4577 + Variable ~denote-org-link-in-context-regexp~ :: Regexp to match an 4578 Org link in its context. The format of such links is ~denote-org-link-format~. 4579 4580 #+vindex: denote-md-link-in-context-regexp 4581 + Variable ~denote-md-link-in-context-regexp~ :: Regexp to match an 4582 Markdown link in its context. The format of such links is ~denote-md-link-format~. 4583 4584 #+vindex: denote-id-only-link-in-context-regexp 4585 + Variable ~denote-id-only-link-in-context-regexp~ :: Regexp to match 4586 an identifier-only link in its context. The format of such links is 4587 ~denote-id-only-link-format~. 4588 4589 #+findex: denote-date-org-timestamp 4590 + Function ~denote-date-org-timestamp~ :: Format =DATE= using the Org 4591 inactive timestamp notation. 4592 4593 #+findex: denote-date-rfc3339 4594 + Function ~denote-date-rfc3339~ :: Format =DATE= using the RFC3339 4595 specification. 4596 4597 #+findex: denote-date-iso-8601 4598 + Function ~denote-date-iso-8601~ :: Format =DATE= according to ISO 4599 8601 standard. 4600 4601 #+findex: denote-trim-whitespace 4602 + Function ~denote-trim-whitespace~ :: Trim whitespace around string 4603 =S=. This can be used in ~denote-file-types~ to format front 4604 mattter. 4605 4606 #+findex: denote-trim-whitespace-then-quotes 4607 + Function ~denote-trim-whitespace-then-quotes~ :: Trim whitespace 4608 then quotes around string =S=. This can be used in 4609 ~denote-file-types~ to format front mattter. 4610 4611 #+findex: denote-format-string-for-org-front-matter 4612 + Function ~denote-format-string-for-org-front-matter~ :: Return 4613 string =S= as-is for Org or plain text front matter. If =S= is not a 4614 string, return an empty string. 4615 4616 #+findex: denote-format-string-for-md-front-matter 4617 + Function ~denote-format-string-for-md-front-matter~ :: Surround 4618 string =S= with quotes. If =S= is not a string, return a literal 4619 emptry string. This can be used in ~denote-file-types~ to format 4620 front mattter. 4621 4622 #+findex: denote-format-keywords-for-md-front-matter 4623 + Function ~denote-format-keywords-for-md-front-matter~ :: Format 4624 front matter =KEYWORDS= for markdown file type. =KEYWORDS= is a 4625 list of strings. Consult the ~denote-file-types~ for how this is 4626 used. 4627 4628 #+findex: denote-format-keywords-for-text-front-matter 4629 + Function ~denote-format-keywords-for-text-front-matter~ :: Format 4630 front matter =KEYWORDS= for text file type. =KEYWORDS= is a list of 4631 strings. Consult the ~denote-file-types~ for how this is used. 4632 4633 #+findex: denote-format-keywords-for-org-front-matter 4634 + Function ~denote-format-keywords-for-org-front-matter~ :: Format 4635 front matter =KEYWORDS= for org file type. =KEYWORDS= is a list of 4636 strings. Consult the ~denote-file-types~ for how this is used. 4637 4638 #+findex: denote-extract-keywords-from-front-matter 4639 + Function ~denote-extract-keywords-from-front-matter~ :: Format front 4640 matter =KEYWORDS= for org file type. =KEYWORDS= is a list of 4641 strings. Consult the ~denote-file-types~ for how this is used. 4642 4643 #+findex: denote-link-return-links 4644 + Function ~denote-link-return-links~ :: Return list of links in 4645 current or optional =FILE=. Also see ~denote-link-return-backlinks~. 4646 4647 #+findex: denote-link-return-backlinks 4648 + Function ~denote-link-return-backlinks~ :: Return list of backlinks 4649 in current or optional =FILE=. Also see ~denote-link-return-links~. 4650 4651 #+vindex: denote-link-signature-format 4652 + Variable ~denote-link-signature-format~ :: Format of link 4653 description for ~denote-link-with-signature~. 4654 4655 #+findex: denote-link-description-with-signature-and-title 4656 + Function ~denote-link-description-with-signature-and-title~ :: Return 4657 link description for =FILE=. Produce a description as follows: 4658 4659 - If the region is active, use it as the description. 4660 4661 - If =FILE= as a signature, then use the 4662 ~denote-link-signature-format~. By default, this looks like 4663 "signature title". 4664 4665 - If =FILE= does not have a signature, then use its title as the 4666 description. 4667 4668 #+vindex: denote-link-description-function 4669 + Variable ~denote-link-description-function~ :: Function to use to 4670 create the description of links. The function specified should take 4671 a =FILE= argument and should return the description as a string. By 4672 default, the title of the file is returned as the description. 4673 4674 * Troubleshoot Denote in a pristine environment 4675 :PROPERTIES: 4676 :CUSTOM_ID: h:9c4467d5-6480-4681-80fb-cd9717bf8b3b 4677 :END: 4678 4679 Sometimes we get reports on bugs that may not be actually caused by 4680 some error in the Denote code base. To help gain insight into what 4681 the problem is, we need to be able to reproduce the issue in a minimum 4682 viable system. Below is one way to achieve this. 4683 4684 1. Find where your =denote.el= file is stored on your filesystem. 4685 4686 2. Assuming you have already installed the package, one way to do this 4687 is to invoke =M-x find-library= and search for ~denote~. It will 4688 take you to the source file. There do =M-x eval-expression=, which 4689 will bring up a minibuffer prompt. At the prompt evaluate: 4690 4691 #+begin_example emacs-lisp 4692 (kill-new (expand-file-name (buffer-file-name))) 4693 #+end_example 4694 4695 3. The above will save the full file system path to your kill ring. 4696 4697 4. In a terminal emulator or an =M-x shell= buffer execute: 4698 4699 #+begin_example 4700 emacs -Q 4701 #+end_example 4702 4703 5. This will open a new instance of Emacs in a pristine environment. 4704 Only the default settings are loaded. 4705 4706 6. In the =*scratch*= buffer of =emacs -Q=, add your configurations 4707 like the following and try to reproduce the issue: 4708 4709 #+begin_example emacs-lisp 4710 (require 'denote "/full/path/to/what/you/got/denote.el") 4711 4712 ;; Your configurations here 4713 #+end_example 4714 4715 Then try to see if your problem still occurs. If it does, then the 4716 fault is with Denote. Otherwise there is something external to it 4717 that we need to account for. Whatever the case, this exercise helps 4718 us get a better sense of the specifics. 4719 4720 * Contributing 4721 :PROPERTIES: 4722 :CUSTOM_ID: h:1ebe4865-c001-4747-a6f2-0fe45aad71cd 4723 :END: 4724 4725 Denote is a GNU ELPA package. As such, any significant change to the 4726 code requires copyright assignment to the Free Software Foundation 4727 (more below). 4728 4729 You do not need to be a programmer to contribute to this package. 4730 Sharing an idea or describing a workflow is equally helpful, as it 4731 teaches us something we may not know and might be able to cover either 4732 by extending Denote or expanding this manual. If you prefer to write a 4733 blog post, make sure you share it with us: we can add a section herein 4734 referencing all such articles. Everyone gets acknowledged 4735 ([[#h:f8126820-3b59-49fa-bcc2-73bd60132bb9][Acknowledgements]]). There is no such thing as an "insignificant 4736 contribution"---they all matter. 4737 4738 + Package name (GNU ELPA): ~denote~ 4739 + Official manual: <https://protesilaos.com/emacs/denote> 4740 + Change log: <https://protesilaos.com/emacs/denote-changelog> 4741 + Git repositories: 4742 + GitHub: <https://github.com/protesilaos/denote> 4743 + GitLab: <https://gitlab.com/protesilaos/denote> 4744 4745 If our public media are not suitable, you are welcome to contact me 4746 (Protesilaos) in private: <https://protesilaos.com/contact>. 4747 4748 Copyright assignment is a prerequisite to sharing code. It is a simple 4749 process. Check the request form below (please adapt it accordingly). 4750 You must write an email to the address mentioned in the form and then 4751 wait for the FSF to send you a legal agreement. Sign the document and 4752 file it back to them. This could all happen via email and take about a 4753 week. You are encouraged to go through this process. You only need to 4754 do it once. It will allow you to make contributions to Emacs in 4755 general. 4756 4757 #+begin_example text 4758 Please email the following information to assign@gnu.org, and we 4759 will send you the assignment form for your past and future changes. 4760 4761 Please use your full legal name (in ASCII characters) as the subject 4762 line of the message. 4763 4764 REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES 4765 4766 [What is the name of the program or package you're contributing to?] 4767 4768 GNU Emacs 4769 4770 [Did you copy any files or text written by someone else in these changes? 4771 Even if that material is free software, we need to know about it.] 4772 4773 Copied a few snippets from the same files I edited. Their author, 4774 Protesilaos Stavrou, has already assigned copyright to the Free Software 4775 Foundation. 4776 4777 [Do you have an employer who might have a basis to claim to own 4778 your changes? Do you attend a school which might make such a claim?] 4779 4780 4781 [For the copyright registration, what country are you a citizen of?] 4782 4783 4784 [What year were you born?] 4785 4786 4787 [Please write your email address here.] 4788 4789 4790 [Please write your postal address here.] 4791 4792 4793 4794 4795 4796 [Which files have you changed so far, and which new files have you written 4797 so far?] 4798 4799 #+end_example 4800 4801 ** Wishlist of what we can do to extend Denote 4802 :PROPERTIES: 4803 :CUSTOM_ID: h:044a6a0f-e382-4013-8279-8bf4e64e73c0 4804 :END: 4805 4806 These are various ideas to extend Denote. Whether they should be in 4807 the core package or a separate extension is something we can discuss. 4808 I, Protesilaos, am happy to help anyone who wants to do any of this. 4809 4810 - denote-consult.el :: This can be a separate package that enhances or 4811 replaces the various prompts we have for files (and maybe more) by 4812 using the ~consult~ package. Consult provides the preview mechanism 4813 and can probably be used for more things, such as to define a source 4814 for Denote-only buffers in the ~consult-buffer~ command. If we need 4815 to tweak things in =denote.el=, I am happy to do it. For example, we 4816 could have a ~denote-file-prompt-function~ variable, which would 4817 default to ~denote-file-prompt~ (what we currently have) and would 4818 also such a hypothetical package to easily plug into what we have. 4819 4820 - denote-embark.el :: Provide integration with the ~embark~ package. 4821 This can be for doing something with the identifier/link at point. 4822 For example, it could provide an action to produce backlinks for the 4823 identifier/file we are linking to, not just the current one. 4824 4825 - denote-transient.el :: The ~transient~ package is built into Emacs 4826 29 (Denote supports Emacs 28 though). We can use it to define an 4827 alternative to what we have for the menu bar. Perhaps this interface 4828 can used to toggle various options, such as to call ~denote~ with a 4829 different set of prompts. 4830 4831 - A ~denote-directories~ user option :: This can be either an 4832 extension of the ~denote-directory~ (accept a list of file paths 4833 value) or a new variable. The idea is to let the user define 4834 separate Denote directories which do know about the presence of each 4835 other (unlike silos). This way, a user can have an entry in 4836 =~/Documents/notes/= link to something =~/Git/projects/= and 4837 everything work as if the ~denote-directory~ is set to the =~/= 4838 (with the status quo as of 2024-02-18 08:27 +0200). 4839 4840 - Signatures before identifiers :: This is probably going to increase 4841 the complixity of =denote.el= and may not be worth pursuing. But 4842 just to explore the idea: we could have an option to rearrange file 4843 names such that the signature appears before the identifier. If we 4844 can do this in a smart way, we can probably extend the principle for 4845 all file name components. Again though, this may be too complex and 4846 not worth doing. 4847 4848 - Encode the day in the identifier :: The idea is to use some coded 4849 reference for Monday, Tuesday, etc. instead of having the generic 4850 =T= in the identifier. For example, Monday is =A= so the identifier 4851 for it is something like =20240219A101522= instead of what we now 4852 have as =20240219T101522=. The old method should still be supported. 4853 Apart from changing a few regular expressions, this does not seem 4854 too complex to me. We would need a user option to opt in to such a 4855 feature. Then tweak the relevant parts. The tricky issue is to 4856 define a mapping of day names to letters/symbols that works for 4857 everyone. Do all countries have a seven-day week, for example? We 4858 need something universally applicable here. 4859 4860 Anything else? You are welcome to discuss these and/or add to the 4861 list. 4862 4863 * Publications about Denote 4864 :PROPERTIES: 4865 :CUSTOM_ID: h:ca0c38f9-fa3e-4901-947e-1b589335781d 4866 :END: 4867 4868 The Emacs community is putting Denote to great use. This section 4869 includes publications that show how people configure their note-taking 4870 setup. If you have a blog post, video, or configuration file about 4871 Denote, feel welcome to tell us about it ([[#h:1ebe4865-c001-4747-a6f2-0fe45aad71cd][Contributing]]). 4872 4873 + David Wilson (SystemCrafters): /Generating a Blog Site from Denote 4874 Entries/, 2022-09-09, <https://www.youtube.com/watch?v=5R7ad5xz5wo> 4875 4876 + David Wilson (SystemCrafters): /Trying Out Prot's Denote, an Org 4877 Roam Alternative?/, 2022-07-15, <https://www.youtube.com/watch?v=QcRY_rsX0yY> 4878 4879 + Jack Baty: /Keeping my Org Agenda updated based on Denote keywords/, 4880 2022-11-30, <https://baty.net/2022/keeping-my-org-agenda-updated> 4881 4882 + Jeremy Friesen: /Denote Emacs Configuration/, 2022-10-02, 4883 <https://takeonrules.com/2022/10/09/denote-emacs-configuration/> 4884 4885 + Jeremy Friesen: /Exploring the Denote Emacs Package/, 2022-10-01, 4886 <https://takeonrules.com/2022/10/01/exploring-the-denote-emacs-package/> 4887 4888 + Jeremy Friesen: /Migration Plan for Org-Roam Notes to Denote/, 4889 2022-10-02, <https://takeonrules.com/2022/10/02/migration-plan-for-org-roam-notes-to-denote/> 4890 4891 + Jeremy Friesen: /Project Dispatch Menu with Org Mode Metadata, 4892 Denote, and Transient/, 2022-11-19, 4893 <https://takeonrules.com/2022/11/19/project-dispatch-menu-with-org-mode-metadata-denote-and-transient/> 4894 4895 + Mohamed Suliman: /Managing a bibliography of BiBTeX entries with 4896 Denote/, 2022-12-20, <https://www.scss.tcd.ie/~sulimanm/posts/denote-bibliography.html> 4897 4898 + Peter Prevos: /Simulating Text Files with R to Test the Emacs Denote 4899 Package/, 2022-07-28, <https://lucidmanager.org/productivity/testing-denote-package/> 4900 4901 + Peter Prevos: /Emacs Writing Studio/, 2023-10-19. A configuration for authors, using Denote for taking notes, literature reviews and manage collections of images: 4902 - <https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/> 4903 - <https://lucidmanager.org/productivity/denote-explore/> 4904 - <https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/> 4905 - <https://lucidmanager.org/productivity/using-emacs-image-dired/> 4906 4907 + Stefan Thesing: /Denote as a Zettelkasten/, 2023-03-02, 4908 <https://www.thesing-online.de/blog/denote-as-a-zettelkasten> 4909 4910 + Summer Emacs: /An explanation of how I use Emacs/, 2023-05-04, 4911 <https://github.com/summeremacs/howiuseemacs/blob/main/full-explanation-of-how-i-use-emacs.org> 4912 4913 * Alternatives to Denote 4914 :PROPERTIES: 4915 :CUSTOM_ID: h:dbb51a1b-90b8-48e8-953c-e2fb3e36981e 4916 :END: 4917 4918 What follows is a list of Emacs packages for note-taking. I 4919 (Protesilaos) have not used any of them, as I was manually applying my 4920 file-naming scheme beforehand and by the time those packages were 4921 available I was already hacking on the predecessor of Denote as a means 4922 of learning Emacs Lisp (a package which I called "Unassuming Sidenotes 4923 of Little Significance", aka "USLS" which is pronounced as "U-S-L-S" or 4924 "useless"). As such, I cannot comment at length on the differences 4925 between Denote and each of those packages, beside what I gather from 4926 their documentation. 4927 4928 + [[https://github.com/org-roam/org-roam][org-roam]] :: The de facto standard in the Emacs milieu---and rightly 4929 so! It has a massive community, is featureful, and should be an 4930 excellent companion to anyone who is invested in the Org ecosystem 4931 and/or knows what "Roam" is (I don't). It has been explained to me 4932 that Org Roam uses a database to store a cache about your notes. It 4933 otherwise uses standard Org files. The cache helps refer to the same 4934 node through aliases which can provide lots of options. Personally, I 4935 follow a single-topic-per-note approach, so anything beyond that is 4936 overkill. If the database is only for a cache, then maybe that has no 4937 downside, though I am careful with any kind of specialised program as 4938 it creates a dependency. If you ask me about database software in 4939 particular, I have no idea how to use one, let alone debug it or 4940 retrieve data from it if something goes awry (I could learn, but that 4941 is beside the point). 4942 4943 + [[https://github.com/localauthor/zk][zk (or zk.el)]] :: Reading its documentation makes me think that this is 4944 Denote's sibling---the two projects have a lot of things in common, 4945 including the preference to rely on plain files and standard tools. 4946 The core difference is that Denote has a strict file-naming scheme. 4947 Other differences in available features are, in principle, matters of 4948 style or circumstance: both packages can have them. As its initials 4949 imply, ZK enables a zettelkasten-like workflow. It does not enforce 4950 it though, letting the user adapt the method to their needs and 4951 requirements. 4952 4953 + [[https://github.com/ymherklotz/emacs-zettelkasten][zettelkasten]] :: This is another one of Denote's relatives, at least 4954 insofar as the goal of simplicity is concerned. The major difference 4955 is that according to its documentation "the name of the file that is 4956 created is just a unique ID". This is not consistent with our 4957 file-naming scheme which is all about making sense of your files by 4958 their name alone and being able to visually parse a listing of them 4959 without any kind of specialised tool (e.g. =ls -l= or =ls -C= on the 4960 command-line from inside the ~denote-directory~ give you a 4961 human-readable set of files names, while =find * -maxdepth 0 -type f= 4962 is another approach). 4963 4964 + [[https://github.com/EFLS/zetteldeft][zetteldeft]] :: This is a zettelkasten note-taking system built on top 4965 of the =deft= package. Deft provides a search interface to a 4966 directory, in this case the one holding the user's =zetteldeft= notes. 4967 Denote has no such dependency and is not opinionated about how the 4968 user prefers to search/access their notes: use Dired, Grep, the 4969 =consult= package, or whatever else you already have set up for all 4970 things Emacs, not just your notes. 4971 4972 Searching through =M-x list-packages= for "zettel" brings up more 4973 matches. =zetteldesk= is an extension to Org Roam and, as such, I 4974 cannot possibly know what Org Roam truly misses and what the added-value 4975 of this package is. =neuron-mode= builds on top of an external program 4976 called =neuron=, which I have never used. 4977 4978 Searching for "note" gives us a few more results. =notes-mode= has 4979 precious little documentation and I cannot tell what it actually does 4980 (as I said in my presentation for LibrePlanet 2022, inadequate docs are 4981 a bug). =side-notes= differs from what we try to do with Denote, as it 4982 basically gives you the means to record your thoughts about some other 4983 project you are working on and keep them on the side: so it and Denote 4984 should not be mutually exclusive. 4985 4986 If I missed something, please let me know. 4987 4988 ** Alternative implementations and further reading 4989 :PROPERTIES: 4990 :CUSTOM_ID: h:188c0986-f2fa-444f-b493-5429356e75cf 4991 :END: 4992 4993 This section covers blog posts and implementations from the Emacs 4994 community about the topic of note-taking and file organization. They 4995 may refer to some of the packages covered in the previous section or 4996 provide their custom code ([[#h:dbb51a1b-90b8-48e8-953c-e2fb3e36981e][Alternatives to Denote]]). The list is 4997 unsorted. 4998 4999 + José Antonio Ortega Ruiz (aka "jao") explains a note-taking method 5000 that is simple like Denote but differs in other ways. An interesting 5001 approach overall: https://jao.io/blog/simple-note-taking.html. 5002 5003 + Jethro Kuan (the main =org-roam= developer) explains their note-taking 5004 techniques: https://jethrokuan.github.io/org-roam-guide/. Good ideas 5005 all round, regardless of the package/code you choose to use. 5006 5007 + Karl Voit's tools [[https://github.com/novoid/date2name][date2name]], [[https://github.com/novoid/filetags/][filetags]], [[https://github.com/novoid/appendfilename/][appendfilename]], and 5008 [[https://github.com/novoid/move2archive][move2archive]] provide a Python-based implementation to organize 5009 individual files which do not require Emacs. His approach ([[https://karl-voit.at/managing-digital-photographs/][blog 5010 post]] and his [[https://www.youtube.com/watch?v=rckSVmYCH90][presentation at GLT18]]) has been complemented by [[https://github.com/novoid/memacs][memacs]] 5011 to process e.g., the date of creation of photographs, or the log of 5012 a phone call in a format compatible to org. 5013 5014 [ Development note: help expand this list. ] 5015 5016 * Frequently Asked Questions 5017 :PROPERTIES: 5018 :CUSTOM_ID: h:da2944c6-cde6-4c65-8f2d-579305a159bb 5019 :END: 5020 5021 I (Protesilaos) answer some questions I have received or might get. It 5022 is assumed that you have read the rest of this manual: I will not go 5023 into the specifics of how Denote works. 5024 5025 ** Why develop Denote when PACKAGE already exists? 5026 :PROPERTIES: 5027 :CUSTOM_ID: h:b875450a-ae22-4899-ac23-c10fa9c279bb 5028 :END: 5029 5030 I wrote Denote because I was using a variant of Denote's file-naming 5031 scheme before I was even an Emacs user (I switched to Emacs from 5032 Tmux+Vim+CLI in the summer of 2019). I was originally inspired by 5033 Jekyll, the static site generator, which I started using for my website 5034 in 2016 (was on WordPress before). Jekyll's files follow the 5035 =YYYY-MM-DD-TITLE.md= pattern. I liked its efficiency relative to the 5036 unstructured mess I had before. Eventually, I started using that scheme 5037 outside the confines of my website's source code. Over time I refined 5038 it and here we are. 5039 5040 Note-taking is something I take very seriously, as I am a prolific 5041 writer (just check my website, which only reveals the tip of the 5042 iceberg). As such, I need a program that does exactly what I want and 5043 which I know how to extend. I originally tried to use Org capture 5044 templates to create new files with a Denote-style file-naming scheme but 5045 never managed to achieve it. Maybe because ~org-capture~ has some 5046 hard-coded assumptions or I simply am not competent enough to hack on 5047 core Org facilities. Whatever the case, an alternative was in order. 5048 5049 The existence of PACKAGE is never a good reason for me not to conduct my 5050 own experiments for recreational, educational, or practical purposes. 5051 When the question arises of "why not contribute to PACKAGE instead?" the 5052 answer is that without me experimenting in the first place, I would lack 5053 the skills for such a task. Furthermore, contributing to another 5054 package does not guarantee I get what I want in terms of workflow. 5055 5056 Whether you should use Denote or not is another matter altogether: 5057 choose whatever you want. 5058 5059 ** Why not rely exclusively on Org? 5060 :PROPERTIES: 5061 :CUSTOM_ID: h:b9831849-5c71-484e-b444-bac19cc13151 5062 :END: 5063 5064 I think Org is one of Emacs' killer apps. I also believe it is not the 5065 right tool for every job. When I write notes, I want to focus on 5066 writing. Nothing more. I thus have no need for stuff like org-babel, 5067 scheduling to-do items, clocking time, and so on. The more "mental 5068 dependencies" you add to your workflow, the heavier the burden you carry 5069 and the less focused you are on the task at hand: there is always that 5070 temptation to tweak the markup, tinker with some syntactic construct, 5071 obsess about what ought to be irrelevant to writing as such. 5072 5073 In technical terms, I also am not fond of Org's code base (I understand 5074 why it is the way it is---just commenting on the fact). Ever tried to 5075 read it? You will routinely find functions that are tens-to-hundreds of 5076 lines long and have all sorts of special casing. As I am not a 5077 programmer and only learnt to write Elisp through trial and error, I 5078 have no confidence in my ability to make Org do what I want at that 5079 level, hence =denote= instead of =org-denote= or something. 5080 5081 Perhaps the master programmer is one who can deal with complexity and 5082 keep adding to it. I am of the opposite view, as language---code 5083 included---is at its communicative best when it is clear and accessible. 5084 5085 Make no mistake: I use Org for the agenda and also to write technical 5086 documentation that needs to be exported to various formats, including 5087 this very manual. 5088 5089 ** Why care about Unix tools when you use Emacs? 5090 :PROPERTIES: 5091 :CUSTOM_ID: h:da1e2469-8f04-450b-a379-a854efa80a36 5092 :END: 5093 5094 My notes form part of my longer-term storage. I do not want to have to 5095 rely on a special program to be able to read them or filter them. Unix 5096 is universal, at least as far as I am concerned. 5097 5098 Denote streamlines some tasks and makes things easier in general, which 5099 is consistent with how Emacs provides a layer of interactivity on top of 5100 Unix. Still, Denote's utilities can, in principle, be implemented as 5101 POSIX shell scripts (minus the Emacs-specific parts like fontification 5102 in Dired or the buttonization of links). 5103 5104 Portability matters. For example, in the future I might own a 5105 smartphone, so I prefer not to require Emacs, Org, or some other 5106 executable to access my files on the go. 5107 5108 Furthermore, I might want to share those files with someone. If I make 5109 Emacs a requirement, I am limiting my circle to a handful of relatively 5110 advanced users. 5111 5112 Please don't misinterpret this: I am using Emacs full-time for my 5113 computing and maintain a growing list of packages for it. This is just 5114 me thinking long-term. 5115 5116 ** Why many small files instead of few large ones? 5117 :PROPERTIES: 5118 :CUSTOM_ID: h:7d2e7b8a-d484-4c1d-8688-17f70f242ad7 5119 :END: 5120 5121 I have read that Org favours the latter method. If true, I strongly 5122 disagree with it because of the implicit dependency it introduces and 5123 the way it favours machine-friendliness over human-readability in terms 5124 of accessing information. Notes are long-term storage. I might want to 5125 access them on (i) some device with limited features, (ii) print on 5126 paper, (iii) share with another person who is not a tech wizard. 5127 5128 There are good arguments for few large files, but all either prioritize 5129 machine-friendliness or presuppose the use of sophisticated tools like 5130 Emacs+Org. 5131 5132 Good luck using =less= on a generic TTY to read a file with a zillion 5133 words, headings, sub-headings, sub-sub-headings, property drawers, and 5134 other constructs! You will not get the otherwise wonderful folding of 5135 headings the way you do in Emacs---do not take such features for 5136 granted. 5137 5138 My point is that notes should be atomic to help the user---and 5139 potentially the user's family, friends, acquaintances---make sense of 5140 them in a wide range of scenaria. The more program-agnostic your file 5141 is, the better for you and/or everyone else you might share your 5142 writings with. 5143 5144 Human-readability means that we optimize for what matters to us. If (a) 5145 you are the only one who will ever read your notes, (b) always have 5146 access to good software like Emacs+Org, (c) do not care about printing 5147 on paper, then Denote's model is not for you. Maybe you need to tweak 5148 some ~org-capture~ template to append a new entry to one mega file (I do 5149 that for my Org agenda, by the way, as I explained before about using 5150 the right tool for the job). 5151 5152 ** Does Denote perform well at scale? 5153 :PROPERTIES: 5154 :CUSTOM_ID: h:863f812a-aac7-42ea-83b3-fbbdb58e08d7 5155 :END: 5156 5157 Denote does not do anything fancy and has no special requirements: it 5158 uses standard tools to accomplish ordinary tasks. If Emacs can cope 5159 with lots of files, then that is all you need to know: Denote will work. 5160 5161 To put this to the test, Peter Prevos is running simulations with R that 5162 generate large volumes of notes. You can read the technicalities here: 5163 <https://lucidmanager.org/productivity/testing-denote-package/>. 5164 Excerpt: 5165 5166 #+begin_quote 5167 Using this code I generated ten thousands notes and used this to test 5168 the Denote package to see it if works at a large scale. This tests shows 5169 that Prot's approach is perfectly capable of working with thousands of 5170 notes. 5171 #+end_quote 5172 5173 Of course, we are always prepared to make refinements to the code, where 5174 necessary, without compromising on the project's principles. 5175 5176 ** I add TODOs to my notes; will many files slow down the Org agenda? 5177 :PROPERTIES: 5178 :CUSTOM_ID: h:63c2f8d4-79ed-4c55-b3ef-e048a05802c0 5179 :END: 5180 5181 Yes, many files will slow down the agenda due to how that works. Org 5182 collects all files specified in the ~org-agenda-files~, searches through 5183 their contents for timestamped entries, and then loops through all days 5184 to determine where each entry belongs. The more days and more files, 5185 the longer it takes to build the agenda. Doing this with potentially 5186 hundreds of files will have a noticeable impact on performance. 5187 5188 This is not a deficiency of Denote. It happens with generic Org files. 5189 The way the agenda is built is heavily favoring the use of a single file 5190 that holds all your timestamped entries (or at least a few such files). 5191 Tens or hundreds of files are inefficient for this job. Plus doing so 5192 has the side-effect of making Emacs open all those files, which you 5193 probably do not need. 5194 5195 If you want my opinion though, be more forceful with the separation of 5196 concerns. Decouple your knowledge base from your ephemeral to-do list: 5197 Denote (and others) can be used for the former, while you let standard 5198 Org work splendidly for the latter---that is what I do, anyway. 5199 5200 Org has a powerful linking facility, whether you use ~org-store-link~ or 5201 do it via an ~org-capture~ template. If you want a certain note to be 5202 associated with a task, just store the task in a single =tasks.org= (or 5203 however you name it) and link to the relevant context. 5204 5205 Do not mix your knowledge base with your to-do items. If you need help 5206 figuring out the specifics of this workflow, you are welcome to ask for 5207 help in our relevant channels ([[#h:1ebe4865-c001-4747-a6f2-0fe45aad71cd][Contributing]]). 5208 5209 ** I want to sort by last modified in Dired, why won't Denote let me? 5210 :PROPERTIES: 5211 :CUSTOM_ID: h:a7fd5e0a-78f7-434e-aa2e-e150479c16e2 5212 :END: 5213 5214 Denote does not control how Dired sorts files. I encourage you to read 5215 the manpage of the =ls= executable. It will help you in general, while 5216 it applies to Emacs as well via Dired. The gist is that you can update 5217 the =ls= flags that Dired uses on-the-fly: type =C-u M-x 5218 dired-sort-toggle-or-edit= (=C-u s= by default) and append 5219 =--sort=time= at the prompt. To reverse the order, add the =-r= flag. 5220 The user option ~dired-listing-switches~ sets your default preference. 5221 5222 For an on-demand sorted and filtered Dired listing of Denote files, 5223 use the command ~denote-sort-dired~ ([[#h:9fe01e63-f34f-4479-8713-f162a5ca865e][Sort files by component]]). 5224 5225 ** How do you handle the last modified case? 5226 :PROPERTIES: 5227 :CUSTOM_ID: h:764b5e87-cd22-4937-b5fc-af3892d6b3d8 5228 :END: 5229 5230 Denote does not insert any meta data or heading pertaining to edits in 5231 the file. I am of the view that these either do not scale well or are 5232 not descriptive enough. Suppose you use a "lastmod" heading with a 5233 timestamp: which lines where edited and what did the change amount to? 5234 5235 This is where an external program can be helpful. Use a Version Control 5236 System, such as Git, to keep track of all your notes. Every time you 5237 add a new file, record the addition. Same for post-creation edits. 5238 Your VCS will let you review the history of those changes. For 5239 instance, Emacs' built-in version control framework has a command that 5240 produces a log of changes for the current file: =M-x vc-print-log=, 5241 bound to =C-x v l= by default. From there one can access the 5242 corresponding diff output (use =M-x describe-mode= (=C-h m=) in an 5243 unfamiliar buffer to learn more about it). With Git in particular, 5244 Emacs users have the option of the all-round excellent =magit= package. 5245 5246 In short: let Denote (or equivalent) create notes and link between them, 5247 the file manager organise and provide access to files, search programs 5248 deal with searching and narrowing, and version control software handle 5249 the tracking of changes. 5250 5251 ** Speed up backlinks' buffer creation? 5252 :PROPERTIES: 5253 :CUSTOM_ID: h:893eec49-d7be-4603-bcff-fcc247244011 5254 :END: 5255 5256 Denote leverages the built-in =xref= library to search for the 5257 identifier of the current file and return any links to it. For users 5258 of Emacs version 28 or higher, there exists a user option to specify 5259 the program that performs this search: ~xref-search-program~. The 5260 default is =grep=, which can be slow, though one may opt for =ugrep=, 5261 =ripgrep=, or even specify something else (read the doc string of that 5262 user option for the details). 5263 5264 Try either for these for better results: 5265 5266 #+begin_src emacs-lisp 5267 (setq xref-search-program 'ripgrep) 5268 5269 ;; OR 5270 5271 (setq xref-search-program 'ugrep) 5272 #+end_src 5273 5274 To use whatever executable is available on your system, use something 5275 like this: 5276 5277 #+begin_src emacs-lisp 5278 ;; Prefer ripgrep, then ugrep, and fall back to regular grep. 5279 (setq xref-search-program 5280 (cond 5281 ((or (executable-find "ripgrep") 5282 (executable-find "rg")) 5283 'ripgrep) 5284 ((executable-find "ugrep") 5285 'ugrep) 5286 (t 5287 'grep))) 5288 #+end_src 5289 5290 ** Why do I get "Search failed with status 1" when I search for backlinks? 5291 :PROPERTIES: 5292 :CUSTOM_ID: h:42f6b07e-5956-469a-8294-17f9cf62eb2b 5293 :END: 5294 5295 Denote uses [[info:emacs#Xref][Emacs' Xref]] to find backlinks. Xref requires ~xargs~ and 5296 one of ~grep~ or ~ripgrep~, depending on your configuration. 5297 5298 This is usually not an issue on *nix systems, but the necessary 5299 executables are not available on Windows Emacs distributions. Please 5300 ensure that you have both ~xargs~ and either ~grep~ or ~ripgrep~ 5301 available within your ~PATH~ environment variable. 5302 5303 If you have ~git~ on Windows installed, then you may use the following 5304 code (adjust the git's installation path if necessary): 5305 #+begin_src emacs-lisp 5306 (setenv "PATH" (concat (getenv "PATH") ";" "C:\\Program Files\\Git\\usr\\bin")) 5307 #+end_src 5308 5309 ** Why do I get a double =#+title= in Doom Emacs? 5310 :PROPERTIES: 5311 :CUSTOM_ID: h:0f737b7d-40e6-46a7-b1db-117c0ffcbfef 5312 :END: 5313 5314 Doom Emacs provides a set of bespoke templates for Org. One of those 5315 prefills any new Org file with a =#+title= field. So when Denote 5316 creates a new Org file and inserts front matter to it, it inevitably 5317 adds an extra title to the existing one. 5318 5319 This is not a Denote problem. We can only expect a new file to be 5320 empty by default. Check how to disable the relevant module in your 5321 Doom Emacs configuration file. 5322 5323 * Acknowledgements 5324 :PROPERTIES: 5325 :CUSTOM_ID: h:f8126820-3b59-49fa-bcc2-73bd60132bb9 5326 :END: 5327 #+cindex: Contributors 5328 5329 Denote is meant to be a collective effort. Every bit of help matters. 5330 5331 + Author/maintainer :: Protesilaos Stavrou. 5332 5333 + Contributions to code or the manual :: Abin Simon, Adam Růžička, 5334 Alan Schmitt, Ashton Wiersdorf, Benjamin Kästner, Bruno Boal, 5335 Charanjit Singh, Clemens Radermacher, Colin McLear, Damien Cassou, 5336 Eduardo Grajeda, Elias Storms, Eshel Yaron, Florian, Glenna D., 5337 Graham Marlow, Hilde Rhyne, Ivan Sokolov, Jack Baty, Jean-Charles 5338 Bagneris, Jean-Philippe Gagné Guay, Joseph Turner, Jürgen Hötzel, 5339 Kaushal Modi, Kai von Fintel, Kostas Andreadis, Kristoffer 5340 Balintona, Kyle Meyer, Marc Fargas, Matthew Lemon, Noboru Ota 5341 (nobiot), Norwid Behrnd, Peter Prevos, Philip Kaludercic, Quiliro 5342 Ordóñez, Stephen R. Kifer, Stefan Monnier, Stefan Thesing, Thibaut 5343 Benjamin, Tomasz Hołubowicz, Vedang Manerikar, Wesley Harvey, Zhenxu 5344 Xu, arsaber101, ezchi, jarofromel, leinfink (Henrik), l-o-l-h 5345 (Lincoln), mattyonweb, maxbrieiev, mentalisttraceur, pmenair, 5346 relict007. 5347 5348 + Ideas and/or user feedback :: Abin Simon, Aditya Yadav, Alan 5349 Schmitt, Aleksandr Vityazev, Alex Hirschfeld, Alfredo Borrás, Ashton 5350 Wiersdorf, Benjamin Kästner, Claudiu Tănăselia, Colin McLear, Damien 5351 Cassou, Elias Storms, Federico Stilman, Florian, Frédéric Willem 5352 Frank Ehmsen, Glenna D., Guo Yong, Hanspeter Gisler, Jack Baty, Jay 5353 Rajput, Jean-Charles Bagneris, Jens Östlund, Jeremy Friesen, 5354 Jonathan Sahar, Johan Bolmsjö, Jousimies, Juanjo Presa, Kai von 5355 Fintel, Kaushal Modi, M. Hadi Timachi, Mark Olson, Mirko Hernandez, 5356 Niall Dooley, Paul van Gelder, Peter Prevos, Peter Smith, Suhail 5357 Singh, Shreyas Ragavan, Stefan Thesing, Summer Emacs, Sven Seebeck, 5358 Taoufik, TJ Stankus, Vick (VicZz), Viktor Haag, Wade Mealing, Yi 5359 Liu, Ypot, atanasj, babusri, doolio, drcxd, fingerknight, hpgisler, 5360 mentalisttraceur, pRot0ta1p, rbenit68, relict007, sienic, sundar bp. 5361 5362 Special thanks to Peter Povinec who helped refine the file-naming 5363 scheme, which is the cornerstone of this project. 5364 5365 Special thanks to Jean-Philippe Gagné Guay for the numerous 5366 contributions to the code base. 5367 5368 * GNU Free Documentation License 5369 :PROPERTIES: 5370 :APPENDIX: t 5371 :CUSTOM_ID: h:2d84e73e-c143-43b5-b388-a6765da974ea 5372 :END: 5373 5374 #+texinfo: @include doclicense.texi 5375 5376 #+begin_export html 5377 <pre> 5378 5379 GNU Free Documentation License 5380 Version 1.3, 3 November 2008 5381 5382 5383 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 5384 <https://fsf.org/> 5385 Everyone is permitted to copy and distribute verbatim copies 5386 of this license document, but changing it is not allowed. 5387 5388 0. PREAMBLE 5389 5390 The purpose of this License is to make a manual, textbook, or other 5391 functional and useful document "free" in the sense of freedom: to 5392 assure everyone the effective freedom to copy and redistribute it, 5393 with or without modifying it, either commercially or noncommercially. 5394 Secondarily, this License preserves for the author and publisher a way 5395 to get credit for their work, while not being considered responsible 5396 for modifications made by others. 5397 5398 This License is a kind of "copyleft", which means that derivative 5399 works of the document must themselves be free in the same sense. It 5400 complements the GNU General Public License, which is a copyleft 5401 license designed for free software. 5402 5403 We have designed this License in order to use it for manuals for free 5404 software, because free software needs free documentation: a free 5405 program should come with manuals providing the same freedoms that the 5406 software does. But this License is not limited to software manuals; 5407 it can be used for any textual work, regardless of subject matter or 5408 whether it is published as a printed book. We recommend this License 5409 principally for works whose purpose is instruction or reference. 5410 5411 5412 1. APPLICABILITY AND DEFINITIONS 5413 5414 This License applies to any manual or other work, in any medium, that 5415 contains a notice placed by the copyright holder saying it can be 5416 distributed under the terms of this License. Such a notice grants a 5417 world-wide, royalty-free license, unlimited in duration, to use that 5418 work under the conditions stated herein. The "Document", below, 5419 refers to any such manual or work. Any member of the public is a 5420 licensee, and is addressed as "you". You accept the license if you 5421 copy, modify or distribute the work in a way requiring permission 5422 under copyright law. 5423 5424 A "Modified Version" of the Document means any work containing the 5425 Document or a portion of it, either copied verbatim, or with 5426 modifications and/or translated into another language. 5427 5428 A "Secondary Section" is a named appendix or a front-matter section of 5429 the Document that deals exclusively with the relationship of the 5430 publishers or authors of the Document to the Document's overall 5431 subject (or to related matters) and contains nothing that could fall 5432 directly within that overall subject. (Thus, if the Document is in 5433 part a textbook of mathematics, a Secondary Section may not explain 5434 any mathematics.) The relationship could be a matter of historical 5435 connection with the subject or with related matters, or of legal, 5436 commercial, philosophical, ethical or political position regarding 5437 them. 5438 5439 The "Invariant Sections" are certain Secondary Sections whose titles 5440 are designated, as being those of Invariant Sections, in the notice 5441 that says that the Document is released under this License. If a 5442 section does not fit the above definition of Secondary then it is not 5443 allowed to be designated as Invariant. The Document may contain zero 5444 Invariant Sections. If the Document does not identify any Invariant 5445 Sections then there are none. 5446 5447 The "Cover Texts" are certain short passages of text that are listed, 5448 as Front-Cover Texts or Back-Cover Texts, in the notice that says that 5449 the Document is released under this License. A Front-Cover Text may 5450 be at most 5 words, and a Back-Cover Text may be at most 25 words. 5451 5452 A "Transparent" copy of the Document means a machine-readable copy, 5453 represented in a format whose specification is available to the 5454 general public, that is suitable for revising the document 5455 straightforwardly with generic text editors or (for images composed of 5456 pixels) generic paint programs or (for drawings) some widely available 5457 drawing editor, and that is suitable for input to text formatters or 5458 for automatic translation to a variety of formats suitable for input 5459 to text formatters. A copy made in an otherwise Transparent file 5460 format whose markup, or absence of markup, has been arranged to thwart 5461 or discourage subsequent modification by readers is not Transparent. 5462 An image format is not Transparent if used for any substantial amount 5463 of text. A copy that is not "Transparent" is called "Opaque". 5464 5465 Examples of suitable formats for Transparent copies include plain 5466 ASCII without markup, Texinfo input format, LaTeX input format, SGML 5467 or XML using a publicly available DTD, and standard-conforming simple 5468 HTML, PostScript or PDF designed for human modification. Examples of 5469 transparent image formats include PNG, XCF and JPG. Opaque formats 5470 include proprietary formats that can be read and edited only by 5471 proprietary word processors, SGML or XML for which the DTD and/or 5472 processing tools are not generally available, and the 5473 machine-generated HTML, PostScript or PDF produced by some word 5474 processors for output purposes only. 5475 5476 The "Title Page" means, for a printed book, the title page itself, 5477 plus such following pages as are needed to hold, legibly, the material 5478 this License requires to appear in the title page. For works in 5479 formats which do not have any title page as such, "Title Page" means 5480 the text near the most prominent appearance of the work's title, 5481 preceding the beginning of the body of the text. 5482 5483 The "publisher" means any person or entity that distributes copies of 5484 the Document to the public. 5485 5486 A section "Entitled XYZ" means a named subunit of the Document whose 5487 title either is precisely XYZ or contains XYZ in parentheses following 5488 text that translates XYZ in another language. (Here XYZ stands for a 5489 specific section name mentioned below, such as "Acknowledgements", 5490 "Dedications", "Endorsements", or "History".) To "Preserve the Title" 5491 of such a section when you modify the Document means that it remains a 5492 section "Entitled XYZ" according to this definition. 5493 5494 The Document may include Warranty Disclaimers next to the notice which 5495 states that this License applies to the Document. These Warranty 5496 Disclaimers are considered to be included by reference in this 5497 License, but only as regards disclaiming warranties: any other 5498 implication that these Warranty Disclaimers may have is void and has 5499 no effect on the meaning of this License. 5500 5501 2. VERBATIM COPYING 5502 5503 You may copy and distribute the Document in any medium, either 5504 commercially or noncommercially, provided that this License, the 5505 copyright notices, and the license notice saying this License applies 5506 to the Document are reproduced in all copies, and that you add no 5507 other conditions whatsoever to those of this License. You may not use 5508 technical measures to obstruct or control the reading or further 5509 copying of the copies you make or distribute. However, you may accept 5510 compensation in exchange for copies. If you distribute a large enough 5511 number of copies you must also follow the conditions in section 3. 5512 5513 You may also lend copies, under the same conditions stated above, and 5514 you may publicly display copies. 5515 5516 5517 3. COPYING IN QUANTITY 5518 5519 If you publish printed copies (or copies in media that commonly have 5520 printed covers) of the Document, numbering more than 100, and the 5521 Document's license notice requires Cover Texts, you must enclose the 5522 copies in covers that carry, clearly and legibly, all these Cover 5523 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on 5524 the back cover. Both covers must also clearly and legibly identify 5525 you as the publisher of these copies. The front cover must present 5526 the full title with all words of the title equally prominent and 5527 visible. You may add other material on the covers in addition. 5528 Copying with changes limited to the covers, as long as they preserve 5529 the title of the Document and satisfy these conditions, can be treated 5530 as verbatim copying in other respects. 5531 5532 If the required texts for either cover are too voluminous to fit 5533 legibly, you should put the first ones listed (as many as fit 5534 reasonably) on the actual cover, and continue the rest onto adjacent 5535 pages. 5536 5537 If you publish or distribute Opaque copies of the Document numbering 5538 more than 100, you must either include a machine-readable Transparent 5539 copy along with each Opaque copy, or state in or with each Opaque copy 5540 a computer-network location from which the general network-using 5541 public has access to download using public-standard network protocols 5542 a complete Transparent copy of the Document, free of added material. 5543 If you use the latter option, you must take reasonably prudent steps, 5544 when you begin distribution of Opaque copies in quantity, to ensure 5545 that this Transparent copy will remain thus accessible at the stated 5546 location until at least one year after the last time you distribute an 5547 Opaque copy (directly or through your agents or retailers) of that 5548 edition to the public. 5549 5550 It is requested, but not required, that you contact the authors of the 5551 Document well before redistributing any large number of copies, to 5552 give them a chance to provide you with an updated version of the 5553 Document. 5554 5555 5556 4. MODIFICATIONS 5557 5558 You may copy and distribute a Modified Version of the Document under 5559 the conditions of sections 2 and 3 above, provided that you release 5560 the Modified Version under precisely this License, with the Modified 5561 Version filling the role of the Document, thus licensing distribution 5562 and modification of the Modified Version to whoever possesses a copy 5563 of it. In addition, you must do these things in the Modified Version: 5564 5565 A. Use in the Title Page (and on the covers, if any) a title distinct 5566 from that of the Document, and from those of previous versions 5567 (which should, if there were any, be listed in the History section 5568 of the Document). You may use the same title as a previous version 5569 if the original publisher of that version gives permission. 5570 B. List on the Title Page, as authors, one or more persons or entities 5571 responsible for authorship of the modifications in the Modified 5572 Version, together with at least five of the principal authors of the 5573 Document (all of its principal authors, if it has fewer than five), 5574 unless they release you from this requirement. 5575 C. State on the Title page the name of the publisher of the 5576 Modified Version, as the publisher. 5577 D. Preserve all the copyright notices of the Document. 5578 E. Add an appropriate copyright notice for your modifications 5579 adjacent to the other copyright notices. 5580 F. Include, immediately after the copyright notices, a license notice 5581 giving the public permission to use the Modified Version under the 5582 terms of this License, in the form shown in the Addendum below. 5583 G. Preserve in that license notice the full lists of Invariant Sections 5584 and required Cover Texts given in the Document's license notice. 5585 H. Include an unaltered copy of this License. 5586 I. Preserve the section Entitled "History", Preserve its Title, and add 5587 to it an item stating at least the title, year, new authors, and 5588 publisher of the Modified Version as given on the Title Page. If 5589 there is no section Entitled "History" in the Document, create one 5590 stating the title, year, authors, and publisher of the Document as 5591 given on its Title Page, then add an item describing the Modified 5592 Version as stated in the previous sentence. 5593 J. Preserve the network location, if any, given in the Document for 5594 public access to a Transparent copy of the Document, and likewise 5595 the network locations given in the Document for previous versions 5596 it was based on. These may be placed in the "History" section. 5597 You may omit a network location for a work that was published at 5598 least four years before the Document itself, or if the original 5599 publisher of the version it refers to gives permission. 5600 K. For any section Entitled "Acknowledgements" or "Dedications", 5601 Preserve the Title of the section, and preserve in the section all 5602 the substance and tone of each of the contributor acknowledgements 5603 and/or dedications given therein. 5604 L. Preserve all the Invariant Sections of the Document, 5605 unaltered in their text and in their titles. Section numbers 5606 or the equivalent are not considered part of the section titles. 5607 M. Delete any section Entitled "Endorsements". Such a section 5608 may not be included in the Modified Version. 5609 N. Do not retitle any existing section to be Entitled "Endorsements" 5610 or to conflict in title with any Invariant Section. 5611 O. Preserve any Warranty Disclaimers. 5612 5613 If the Modified Version includes new front-matter sections or 5614 appendices that qualify as Secondary Sections and contain no material 5615 copied from the Document, you may at your option designate some or all 5616 of these sections as invariant. To do this, add their titles to the 5617 list of Invariant Sections in the Modified Version's license notice. 5618 These titles must be distinct from any other section titles. 5619 5620 You may add a section Entitled "Endorsements", provided it contains 5621 nothing but endorsements of your Modified Version by various 5622 parties--for example, statements of peer review or that the text has 5623 been approved by an organization as the authoritative definition of a 5624 standard. 5625 5626 You may add a passage of up to five words as a Front-Cover Text, and a 5627 passage of up to 25 words as a Back-Cover Text, to the end of the list 5628 of Cover Texts in the Modified Version. Only one passage of 5629 Front-Cover Text and one of Back-Cover Text may be added by (or 5630 through arrangements made by) any one entity. If the Document already 5631 includes a cover text for the same cover, previously added by you or 5632 by arrangement made by the same entity you are acting on behalf of, 5633 you may not add another; but you may replace the old one, on explicit 5634 permission from the previous publisher that added the old one. 5635 5636 The author(s) and publisher(s) of the Document do not by this License 5637 give permission to use their names for publicity for or to assert or 5638 imply endorsement of any Modified Version. 5639 5640 5641 5. COMBINING DOCUMENTS 5642 5643 You may combine the Document with other documents released under this 5644 License, under the terms defined in section 4 above for modified 5645 versions, provided that you include in the combination all of the 5646 Invariant Sections of all of the original documents, unmodified, and 5647 list them all as Invariant Sections of your combined work in its 5648 license notice, and that you preserve all their Warranty Disclaimers. 5649 5650 The combined work need only contain one copy of this License, and 5651 multiple identical Invariant Sections may be replaced with a single 5652 copy. If there are multiple Invariant Sections with the same name but 5653 different contents, make the title of each such section unique by 5654 adding at the end of it, in parentheses, the name of the original 5655 author or publisher of that section if known, or else a unique number. 5656 Make the same adjustment to the section titles in the list of 5657 Invariant Sections in the license notice of the combined work. 5658 5659 In the combination, you must combine any sections Entitled "History" 5660 in the various original documents, forming one section Entitled 5661 "History"; likewise combine any sections Entitled "Acknowledgements", 5662 and any sections Entitled "Dedications". You must delete all sections 5663 Entitled "Endorsements". 5664 5665 5666 6. COLLECTIONS OF DOCUMENTS 5667 5668 You may make a collection consisting of the Document and other 5669 documents released under this License, and replace the individual 5670 copies of this License in the various documents with a single copy 5671 that is included in the collection, provided that you follow the rules 5672 of this License for verbatim copying of each of the documents in all 5673 other respects. 5674 5675 You may extract a single document from such a collection, and 5676 distribute it individually under this License, provided you insert a 5677 copy of this License into the extracted document, and follow this 5678 License in all other respects regarding verbatim copying of that 5679 document. 5680 5681 5682 7. AGGREGATION WITH INDEPENDENT WORKS 5683 5684 A compilation of the Document or its derivatives with other separate 5685 and independent documents or works, in or on a volume of a storage or 5686 distribution medium, is called an "aggregate" if the copyright 5687 resulting from the compilation is not used to limit the legal rights 5688 of the compilation's users beyond what the individual works permit. 5689 When the Document is included in an aggregate, this License does not 5690 apply to the other works in the aggregate which are not themselves 5691 derivative works of the Document. 5692 5693 If the Cover Text requirement of section 3 is applicable to these 5694 copies of the Document, then if the Document is less than one half of 5695 the entire aggregate, the Document's Cover Texts may be placed on 5696 covers that bracket the Document within the aggregate, or the 5697 electronic equivalent of covers if the Document is in electronic form. 5698 Otherwise they must appear on printed covers that bracket the whole 5699 aggregate. 5700 5701 5702 8. TRANSLATION 5703 5704 Translation is considered a kind of modification, so you may 5705 distribute translations of the Document under the terms of section 4. 5706 Replacing Invariant Sections with translations requires special 5707 permission from their copyright holders, but you may include 5708 translations of some or all Invariant Sections in addition to the 5709 original versions of these Invariant Sections. You may include a 5710 translation of this License, and all the license notices in the 5711 Document, and any Warranty Disclaimers, provided that you also include 5712 the original English version of this License and the original versions 5713 of those notices and disclaimers. In case of a disagreement between 5714 the translation and the original version of this License or a notice 5715 or disclaimer, the original version will prevail. 5716 5717 If a section in the Document is Entitled "Acknowledgements", 5718 "Dedications", or "History", the requirement (section 4) to Preserve 5719 its Title (section 1) will typically require changing the actual 5720 title. 5721 5722 5723 9. TERMINATION 5724 5725 You may not copy, modify, sublicense, or distribute the Document 5726 except as expressly provided under this License. Any attempt 5727 otherwise to copy, modify, sublicense, or distribute it is void, and 5728 will automatically terminate your rights under this License. 5729 5730 However, if you cease all violation of this License, then your license 5731 from a particular copyright holder is reinstated (a) provisionally, 5732 unless and until the copyright holder explicitly and finally 5733 terminates your license, and (b) permanently, if the copyright holder 5734 fails to notify you of the violation by some reasonable means prior to 5735 60 days after the cessation. 5736 5737 Moreover, your license from a particular copyright holder is 5738 reinstated permanently if the copyright holder notifies you of the 5739 violation by some reasonable means, this is the first time you have 5740 received notice of violation of this License (for any work) from that 5741 copyright holder, and you cure the violation prior to 30 days after 5742 your receipt of the notice. 5743 5744 Termination of your rights under this section does not terminate the 5745 licenses of parties who have received copies or rights from you under 5746 this License. If your rights have been terminated and not permanently 5747 reinstated, receipt of a copy of some or all of the same material does 5748 not give you any rights to use it. 5749 5750 5751 10. FUTURE REVISIONS OF THIS LICENSE 5752 5753 The Free Software Foundation may publish new, revised versions of the 5754 GNU Free Documentation License from time to time. Such new versions 5755 will be similar in spirit to the present version, but may differ in 5756 detail to address new problems or concerns. See 5757 https://www.gnu.org/licenses/. 5758 5759 Each version of the License is given a distinguishing version number. 5760 If the Document specifies that a particular numbered version of this 5761 License "or any later version" applies to it, you have the option of 5762 following the terms and conditions either of that specified version or 5763 of any later version that has been published (not as a draft) by the 5764 Free Software Foundation. If the Document does not specify a version 5765 number of this License, you may choose any version ever published (not 5766 as a draft) by the Free Software Foundation. If the Document 5767 specifies that a proxy can decide which future versions of this 5768 License can be used, that proxy's public statement of acceptance of a 5769 version permanently authorizes you to choose that version for the 5770 Document. 5771 5772 11. RELICENSING 5773 5774 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any 5775 World Wide Web server that publishes copyrightable works and also 5776 provides prominent facilities for anybody to edit those works. A 5777 public wiki that anybody can edit is an example of such a server. A 5778 "Massive Multiauthor Collaboration" (or "MMC") contained in the site 5779 means any set of copyrightable works thus published on the MMC site. 5780 5781 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 5782 license published by Creative Commons Corporation, a not-for-profit 5783 corporation with a principal place of business in San Francisco, 5784 California, as well as future copyleft versions of that license 5785 published by that same organization. 5786 5787 "Incorporate" means to publish or republish a Document, in whole or in 5788 part, as part of another Document. 5789 5790 An MMC is "eligible for relicensing" if it is licensed under this 5791 License, and if all works that were first published under this License 5792 somewhere other than this MMC, and subsequently incorporated in whole or 5793 in part into the MMC, (1) had no cover texts or invariant sections, and 5794 (2) were thus incorporated prior to November 1, 2008. 5795 5796 The operator of an MMC Site may republish an MMC contained in the site 5797 under CC-BY-SA on the same site at any time before August 1, 2009, 5798 provided the MMC is eligible for relicensing. 5799 5800 5801 ADDENDUM: How to use this License for your documents 5802 5803 To use this License in a document you have written, include a copy of 5804 the License in the document and put the following copyright and 5805 license notices just after the title page: 5806 5807 Copyright (c) YEAR YOUR NAME. 5808 Permission is granted to copy, distribute and/or modify this document 5809 under the terms of the GNU Free Documentation License, Version 1.3 5810 or any later version published by the Free Software Foundation; 5811 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. 5812 A copy of the license is included in the section entitled "GNU 5813 Free Documentation License". 5814 5815 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, 5816 replace the "with...Texts." line with this: 5817 5818 with the Invariant Sections being LIST THEIR TITLES, with the 5819 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. 5820 5821 If you have Invariant Sections without Cover Texts, or some other 5822 combination of the three, merge those two alternatives to suit the 5823 situation. 5824 5825 If your document contains nontrivial examples of program code, we 5826 recommend releasing these examples in parallel under your choice of 5827 free software license, such as the GNU General Public License, 5828 to permit their use in free software. 5829 </pre> 5830 #+end_export 5831 5832 #+html: <!-- 5833 5834 * Indices 5835 :PROPERTIES: 5836 :CUSTOM_ID: h:dd530040-de9d-4f2b-8dfd-d8b8f14c058e 5837 :END: 5838 5839 ** Function index 5840 :PROPERTIES: 5841 :INDEX: fn 5842 :CUSTOM_ID: h:317b8c20-6dc1-4390-a20a-d01d75a48ccb 5843 :END: 5844 5845 ** Variable index 5846 :PROPERTIES: 5847 :INDEX: vr 5848 :CUSTOM_ID: h:2f69d4fe-0804-4f7f-aa57-4e03e7f20d98 5849 :END: 5850 5851 ** Concept index 5852 :PROPERTIES: 5853 :INDEX: cp 5854 :CUSTOM_ID: h:10365e44-2fc0-4b66-a613-682fea09ee68 5855 :END: 5856 5857 #+html: -->