I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
8.0 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #+TITLE: Writing
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle writing.el :comments org
  5. #+PROPERTY: header-args :results silent :eval no-export :comments org
  6. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  7. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  8. #+ATTR_ORG: :width 420px
  9. #+ATTR_HTML: :width 420px
  10. #+ATTR_LATEX: :width 420px
  11. [[../docs/images/2021-02-13-example-roam.png]]
  12. I am using *Org mode*[fn:1] extensively throughout my writing. Most of the improvements are done in the [[file:core.org][Core]] module, but all of the management, encryption, synchronization, and organization of all of my writing happens here.
  13. * Improvements
  14. Real time checking and one-shot methods to check and correct common spelling and grammatical errors.
  15. ** Spelling
  16. Configure *InteractiveSpell*[fn:2] as a backend with *FlySpell*[fn:3] for real time checking and highlighting.
  17. #+begin_src emacs-lisp
  18. (use-package ispell
  19. :after org
  20. :custom (ispell-dictionary dotfiles/lang))
  21. #+end_src
  22. Toggle highlighting within buffers with =SPC t s=.
  23. #+begin_src emacs-lisp
  24. (dotfiles/leader
  25. "ts" '(flyspell-buffer :which-key "Spelling"))
  26. #+end_src
  27. ** Grammar
  28. I use *Writegood*[fn:4] to find common writing problems such as cliches and poor wording. Grammarly for the peons!
  29. #+begin_src emacs-lisp
  30. (use-package writegood-mode
  31. :after org
  32. :config (writegood-mode))
  33. #+end_src
  34. Toggle *Writegood* mode with =SPC t w=.
  35. #+begin_src emacs-lisp
  36. (dotfiles/leader
  37. "tw" '(writegood-mode :which-key "Grammar"))
  38. #+end_src
  39. * Knowledge base
  40. Download and install *Org roam*[fn:5], a plain text knowledge management system for Emacs built on top of *Org mode*[fn:1].
  41. + Notes can be arbitrarily referenced
  42. + Contexts created by linking topics and notes
  43. + Install dependencies on *Debian/Ubuntu* systems
  44. + Configure custom keybindings for roam behind =SPC r=
  45. + Find with =f=
  46. + Insert with =i=
  47. + Buffer with =b=
  48. + Capture with =c=
  49. #+begin_src emacs-lisp
  50. (use-package org-roam
  51. :hook (after-init . org-roam-mode)
  52. :custom (org-roam-directory org-directory)
  53. (org-roam-capture-templates '())
  54. (org-roam-dailies-capture-templates '())
  55. :config (dotfiles/leader "r" '(:ignore t :which-key "Roam")
  56. "ri" '(org-roam-insert :which-key "Insert")
  57. "rf" '(org-roam-find-file :which-key "Find")
  58. "rc" '(org-roam-capture :which-key "Capture")
  59. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")))
  60. #+end_src
  61. ** File slugs
  62. The default behaviour of ~org-roam~ when creating a title slug is to replace any non alpha numerical (whitespace) to ~_~. I wanted to change this to use ~_~ and have done so here in my own definition. The only substantial difference from the original definition is the character used.
  63. + Define a new ~title-to-slug~ function
  64. + Override ~org-roam-title-to-slug-function~
  65. #+begin_src emacs-lisp
  66. (with-eval-after-load 'org-roam
  67. (require 'cl-lib)
  68. (defun dotfiles/title-to-slug (title)
  69. "Convert TITLE to a filename-suitable slug."
  70. (cl-flet* ((nonspacing-mark-p (char)
  71. (eq 'Mn (get-char-code-property char 'general-category)))
  72. (strip-nonspacing-marks (s)
  73. (apply #'string (seq-remove #'nonspacing-mark-p
  74. (ucs-normalize-NFD-string s))))
  75. (cl-replace (title pair)
  76. (replace-regexp-in-string (car pair) (cdr pair) title)))
  77. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric.
  78. ("--*" . "-") ;; Remove sequential dashes.
  79. ("^-" . "") ;; Remove starting dashes.
  80. ("-$" . ""))) ;; Remove ending dashes.
  81. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  82. (downcase slug))))
  83. (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug))
  84. #+end_src
  85. ** Web visualizer
  86. Including the extension *Org roam server*[fn:6] will run a web application that visualizes the *Org roam*[fn:5] database. Available whenever the editor is running at https://localhost:8080. The image at the top of this page is an example of the application running.
  87. #+begin_src emacs-lisp
  88. (use-package org-roam-server
  89. :hook (org-roam-mode . org-roam-server-mode))
  90. #+end_src
  91. ** Daily note taking
  92. Use the =daily= note feature of *Org roam*[fn:5] to capture daily notes. Create the default capture template with some preconfigured headers.
  93. #+begin_src emacs-lisp
  94. (with-eval-after-load 'org-roam
  95. (add-to-list 'org-roam-dailies-capture-templates
  96. '("d" "Default" entry (function org-roam-capture--get-point)
  97. "* %?"
  98. :file-name "docs/daily/%<%Y-%m-%d>"
  99. :head
  100. "
  101. ,#+TITLE: %<%Y-%m-%d>
  102. ,#+AUTHOR: Christopher James Hayward
  103. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  104. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  105. ")))
  106. #+end_src
  107. Place keybindings behind =SPC r d=.
  108. + Date with =d=
  109. + Today with =t=
  110. + Tomorrow with =m=
  111. + Yesterday with =y=
  112. #+begin_src emacs-lisp
  113. (dotfiles/leader
  114. "rd" '(:ignore t :which-key "Dailies")
  115. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  116. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  117. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  118. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  119. #+end_src
  120. ** Capture templates
  121. + Capture template for generic documents
  122. #+begin_src emacs-lisp
  123. (with-eval-after-load 'org-roam
  124. (add-to-list 'org-roam-capture-templates
  125. '("d" "Default" entry (function org-roam-capture--get-point)
  126. "%?"
  127. :file-name "docs/${slug}"
  128. :unnarrowed t
  129. :head
  130. "
  131. ,#+TITLE: ${title}
  132. ,#+AUTHOR: Christopher James Hayward
  133. ,#+EMAIL: chris@chrishayward.xyz
  134. ")))
  135. #+end_src
  136. Custom capture template for courses.
  137. + Capture a new buffer with =SPC r c c=
  138. #+begin_src emacs-lisp
  139. (with-eval-after-load 'org-roam
  140. (add-to-list 'org-roam-capture-templates
  141. '("c" "Course" plain (function org-roam-capture--get-point)
  142. "%?"
  143. :file-name "docs/courses/${slug}"
  144. :unnarrowed t
  145. :head
  146. "
  147. ,#+TITLE: ${title}
  148. ,#+SUBTITLE:
  149. ,#+AUTHOR: Christopher James Hayward
  150. ,#+EMAIL: chris@chrishayward.xyz
  151. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  152. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  153. ")))
  154. #+end_src
  155. ** Agenda integration
  156. #+ATTR_ORG: :width 420px
  157. #+ATTR_HTML: :width 420px
  158. #+ATTR_LATEX: :width 420px
  159. [[../docs/images/2021-02-13-example-agenda.gif]]
  160. More capture templates for *Org roam*[fn:5] are defined here in the context of specific domains and topics.
  161. + Configure agenda sources
  162. #+begin_src emacs-lisp
  163. (setq org-agenda-files '("~/.emacs.d/"
  164. "~/.emacs.d/docs/"
  165. "~/.emacs.d/docs/courses/"
  166. "~/.emacs.d/docs/daily/"
  167. "~/.emacs.d/docs/notes/"
  168. "~/.emacs.d/docs/posts/"
  169. "~/.emacs.d/docs/slides/"
  170. "~/.emacs.d/hosts/"
  171. "~/.emacs.d/modules/"))
  172. #+end_src
  173. + Open an agenda buffer with =SPC a=
  174. #+begin_src emacs-lisp
  175. (dotfiles/leader
  176. "a" '(org-agenda :which-key "Agenda"))
  177. #+end_src
  178. ** Navigation and search
  179. Use *Deft* to search and navigate the knowledge base with text filtering.
  180. #+begin_src emacs-lisp
  181. (use-package deft
  182. :after org-roam
  183. :custom (deft-recursive t)
  184. (deft-directory org-directory)
  185. (deft-default-extension "org")
  186. (deft-use-filter-string-for-filename t)
  187. :config (dotfiles/leader "rs" '(deft :which-key "Search (deft)")))
  188. #+end_src
  189. * Footnotes
  190. [fn:1] https://orgmode.org
  191. [fn:2] https://emacswiki.org/emacs/InteractiveSpell
  192. [fn:3] https://emacswiki.org/emacs/FlySpell
  193. [fn:4] https://github.com/bnbeckwith/writegood-mode
  194. [fn:5] https://github.com/org-roam/org-roam
  195. [fn:6] https://github.com/org-roam/org-roam-server