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.

300 lines
8.6 KiB

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. * Superstar
  14. Make headline stars *super* with *Org superstar mode*[fn:3].
  15. #+begin_src emacs-lisp
  16. (use-package org-superstar
  17. :after org
  18. :hook (org-mode . org-superstar-mode))
  19. #+end_src
  20. * Encryption
  21. My source files are encrypted with symmetric key encryption via *GPG*[fn:2]. This enables my workflow of storing my personal notes anywhere, including checked in to a public source repository. Emacs can cache the *GPG*[fn:2] password if you trust your session.
  22. #+begin_src emacs-lisp
  23. (setq epa-file-select-keys 2
  24. epa-file-cache-passphrase-for-symmetric-encryption t
  25. epa-file-encrypt-to dotfiles/public-key)
  26. #+end_src
  27. ** Include *.gpg files
  28. Override ~org-agenda-file-regexp~ to include =.org.gpg= files.
  29. #+begin_src emacs-lisp
  30. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  31. (setq org-agenda-file-regexp
  32. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  33. org-agenda-file-regexp)))
  34. #+end_src
  35. * Improvements
  36. Real time checking and one-shot methods to check and correct common spelling and grammatical errors.
  37. ** Spelling
  38. Configure *InteractiveSpell*[fn:6] as a backend with *FlySpell*[fn:7] for real time checking and highlighting.
  39. #+begin_src emacs-lisp
  40. (use-package ispell
  41. :after org
  42. :custom (ispell-dictionary dotfiles/lang))
  43. #+end_src
  44. Toggle highlighting within buffers with =SPC t s=.
  45. #+begin_src emacs-lisp
  46. (dotfiles/leader
  47. "ts" '(flyspell-buffer :which-key "Spelling"))
  48. #+end_src
  49. ** Grammar
  50. I use *Writegood*[fn:8] to find common writing problems such as cliches and poor wording. Grammarly for the peons!
  51. #+begin_src emacs-lisp
  52. (use-package writegood-mode
  53. :after org
  54. :config (writegood-mode))
  55. #+end_src
  56. Toggle *Writegood* mode with =SPC t w=.
  57. #+begin_src emacs-lisp
  58. (dotfiles/leader
  59. "tw" '(writegood-mode :which-key "Grammar"))
  60. #+end_src
  61. * Management
  62. Download and install *Org roam*[fn:4], a plain text knowledge management system for Emacs built on top of *Org mode*[fn:1].
  63. + Notes can be arbitrarily referenced
  64. + Contexts created by linking topics and notes
  65. #+begin_src emacs-lisp
  66. (use-package org-roam
  67. :hook (after-init . org-roam-mode)
  68. :custom (org-roam-directory org-directory)
  69. (org-roam-encrypt-files t)
  70. (org-roam-capture-templates '())
  71. (org-roam-dailies-capture-templates '()))
  72. #+end_src
  73. Configure custom keybindings behind =SPC r=.
  74. + Find with =f=
  75. + Buffer with =b=
  76. + Capture with =c=
  77. #+begin_src emacs-lisp
  78. (dotfiles/leader
  79. "r" '(:ignore t :which-key "Roam")
  80. "rf" '(org-roam-find-file :which-key "Find")
  81. "rc" '(org-roam-capture :which-key "Capture")
  82. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer"))
  83. #+end_src
  84. ** Web visualizer
  85. Including the extension *Org roam server*[fn:5] will run a web application that visualizes the *Org roam*[fn:4] 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.
  86. #+begin_src emacs-lisp
  87. (use-package org-roam-server
  88. :hook (org-roam-mode . org-roam-server-mode))
  89. #+end_src
  90. ** Daily note taking
  91. Use the =daily= note feature of *Org roam*[fn:4] to capture daily notes. Create the default capture template with some preconfigured headers.
  92. #+begin_src emacs-lisp
  93. (with-eval-after-load 'org-roam
  94. (add-to-list 'org-roam-dailies-capture-templates
  95. '("d" "Default" entry (function org-roam-capture--get-point)
  96. "* %?"
  97. :file-name "docs/daily/%<%Y-%m-%d>"
  98. :head
  99. "
  100. ,#+TITLE: %<%Y-%m-%d>
  101. ,#+AUTHOR: Christopher James Hayward
  102. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  103. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  104. ")))
  105. #+end_src
  106. Place keybindings behind =SPC r d=.
  107. + Date with =d=
  108. + Today with =t=
  109. + Tomorrow with =m=
  110. + Yesterday with =y=
  111. #+begin_src emacs-lisp
  112. (dotfiles/leader
  113. "rd" '(:ignore t :which-key "Dailies")
  114. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  115. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  116. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  117. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  118. #+end_src
  119. * Organization
  120. #+ATTR_ORG: :width 420px
  121. #+ATTR_HTML: :width 420px
  122. #+ATTR_LATEX: :width 420px
  123. [[../docs/images/2021-02-13-example-agenda.gif]]
  124. More capture templates for *Org roam*[fn:4] are defined here in the context of specific domains and topics.
  125. + Configure agenda sources
  126. #+begin_src emacs-lisp
  127. (setq org-agenda-files '("~/.emacs.d/"
  128. "~/.emacs.d/docs/"
  129. "~/.emacs.d/docs/courses/"
  130. "~/.emacs.d/docs/daily/"
  131. "~/.emacs.d/docs/notes/"
  132. "~/.emacs.d/docs/posts/"
  133. "~/.emacs.d/docs/slides/"
  134. "~/.emacs.d/hosts/"
  135. "~/.emacs.d/modules/"))
  136. #+end_src
  137. + Capture template for generic documents
  138. #+begin_src emacs-lisp
  139. (with-eval-after-load 'org-roam
  140. (add-to-list 'org-roam-capture-templates
  141. '("d" "Default" entry (function org-roam-capture--get-point)
  142. "%?"
  143. :file-name "docs/${slug}"
  144. :unnarrowed t
  145. :head
  146. "
  147. ,#+TITLE: ${title}
  148. ,#+AUTHOR: Christopher James Hayward
  149. ,#+EMAIL: chris@chrishayward.xyz
  150. ")))
  151. #+end_src
  152. + Open an agenda buffer with =SPC a=
  153. #+begin_src emacs-lisp
  154. (dotfiles/leader
  155. "a" '(org-agenda :which-key "Agenda"))
  156. #+end_src
  157. ** Courses
  158. Custom capture template for courses.
  159. + Capture a new buffer with =SPC r c c=
  160. #+begin_src emacs-lisp
  161. (with-eval-after-load 'org-roam
  162. (add-to-list 'org-roam-capture-templates
  163. '("c" "Course" plain (function org-roam-capture--get-point)
  164. "%?"
  165. :file-name "docs/courses/${slug}"
  166. :unnarrowed t
  167. :head
  168. "
  169. ,#+TITLE: ${title}
  170. ,#+SUBTITLE:
  171. ,#+AUTHOR: Christopher James Hayward
  172. ,#+EMAIL: chris@chrishayward.xyz
  173. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  174. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  175. ")))
  176. #+end_src
  177. ** Modules
  178. Capture template for new modules for this project.
  179. + Capture a new buffer with =SPC r c m=
  180. + Add buffers to agenda files
  181. #+begin_src emacs-lisp
  182. (with-eval-after-load 'org-roam
  183. (add-to-list 'org-agenda-files "~/.emacs.d/modules/")
  184. (add-to-list 'org-roam-capture-templates
  185. '("m" "Module" plain (function org-roam-capture--get-point)
  186. "%?"
  187. :file-name "modules/${slug}"
  188. :unnarrowed t
  189. :head
  190. "
  191. ,#+TITLE: ${title}
  192. ,#+AUTHOR: Christopher James Hayward
  193. ,#+EMAIL: chris@chrishayward.xyz
  194. ,#+PROPERTY: header-args:emacs-lisp :tangle core.el :comments org
  195. ,#+PROPERTY: header-args :results silent :eval no-export :comments org
  196. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  197. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  198. ")))
  199. #+end_src
  200. ** Hosts
  201. Capture template for new host machines for this project. This does not cover machines that are controlled via TRAMP / SSH.
  202. + Capture a new buffer with =SPC r c h=
  203. #+begin_src emacs-lisp
  204. (with-eval-after-load 'org-roam
  205. (add-to-list 'org-roam-capture-templates
  206. '("m" "Module" plain (function org-roam-capture--get-point)
  207. "%?"
  208. :file-name "modules/${slug}"
  209. :unnarrowed t
  210. :head
  211. "
  212. ,#+TITLE: ${title}
  213. ,#+AUTHOR: Christopher James Hayward
  214. ,#+EMAIL: chris@chrishayward.xyz
  215. ,#+PROPERTY: header-args:emacs-lisp :tangle core.el :comments org
  216. ,#+PROPERTY: header-args :results silent :eval no-export :comments org
  217. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  218. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  219. ")))
  220. #+end_src
  221. * Resources
  222. [fn:1] https://orgmode.org
  223. [fn:2] https://gnupg.org
  224. [fn:3] https://github.com/integral-dw/org-superstar-mode
  225. [fn:4] https://github.com/org-roam/org-roam
  226. [fn:5] https://github.com/org-roam/org-roam-server
  227. [fn:6] https://emacswiki.org/emacs/InteractiveSpell
  228. [fn:7] https://emacswiki.org/emacs/FlySpell
  229. [fn:8] https://github.com/bnbeckwith/writegood-mode