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.

240 lines
7.5 KiB

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:6] as a backend with *FlySpell*[fn:7] 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:8] 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:4], 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. #+begin_src emacs-lisp
  44. (use-package org-roam
  45. :hook (after-init . org-roam-mode)
  46. :custom (org-roam-directory org-directory)
  47. (org-roam-capture-templates '())
  48. (org-roam-dailies-capture-templates '()))
  49. #+end_src
  50. Configure custom keybindings behind =SPC r=.
  51. + Find with =f=
  52. + Insert with =i=
  53. + Buffer with =b=
  54. + Capture with =c=
  55. #+begin_src emacs-lisp
  56. (dotfiles/leader
  57. "r" '(:ignore t :which-key "Roam")
  58. "ri" '(org-roam-insert :which-key "Insert")
  59. "rf" '(org-roam-find-file :which-key "Find")
  60. "rc" '(org-roam-capture :which-key "Capture")
  61. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer"))
  62. #+end_src
  63. ** File slugs
  64. 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.
  65. + Define a new ~title-to-slug~ function
  66. + Override ~org-roam-title-to-slug-function~
  67. #+begin_src emacs-lisp
  68. (with-eval-after-load 'org-roam
  69. (require 'cl-lib)
  70. (defun dotfiles/title-to-slug (title)
  71. "Convert TITLE to a filename-suitable slug."
  72. (cl-flet* ((nonspacing-mark-p (char)
  73. (eq 'Mn (get-char-code-property char 'general-category)))
  74. (strip-nonspacing-marks (s)
  75. (apply #'string (seq-remove #'nonspacing-mark-p
  76. (ucs-normalize-NFD-string s))))
  77. (cl-replace (title pair)
  78. (replace-regexp-in-string (car pair) (cdr pair) title)))
  79. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric.
  80. ("--*" . "-") ;; Remove sequential dashes.
  81. ("^-" . "") ;; Remove starting dashes.
  82. ("-$" . ""))) ;; Remove ending dashes.
  83. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  84. (downcase slug))))
  85. (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug))
  86. #+end_src
  87. ** Web visualizer
  88. 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.
  89. #+begin_src emacs-lisp
  90. (use-package org-roam-server
  91. :hook (org-roam-mode . org-roam-server-mode))
  92. #+end_src
  93. ** Daily note taking
  94. Use the =daily= note feature of *Org roam*[fn:4] to capture daily notes. Create the default capture template with some preconfigured headers.
  95. #+begin_src emacs-lisp
  96. (with-eval-after-load 'org-roam
  97. (add-to-list 'org-roam-dailies-capture-templates
  98. '("d" "Default" entry (function org-roam-capture--get-point)
  99. "* %?"
  100. :file-name "docs/daily/%<%Y-%m-%d>"
  101. :head
  102. "
  103. ,#+TITLE: %<%Y-%m-%d>
  104. ,#+AUTHOR: Christopher James Hayward
  105. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  106. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  107. ")))
  108. #+end_src
  109. Place keybindings behind =SPC r d=.
  110. + Date with =d=
  111. + Today with =t=
  112. + Tomorrow with =m=
  113. + Yesterday with =y=
  114. #+begin_src emacs-lisp
  115. (dotfiles/leader
  116. "rd" '(:ignore t :which-key "Dailies")
  117. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  118. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  119. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  120. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  121. #+end_src
  122. ** Capture templates
  123. + Capture template for generic documents
  124. #+begin_src emacs-lisp
  125. (with-eval-after-load 'org-roam
  126. (add-to-list 'org-roam-capture-templates
  127. '("d" "Default" entry (function org-roam-capture--get-point)
  128. "%?"
  129. :file-name "docs/${slug}"
  130. :unnarrowed t
  131. :head
  132. "
  133. ,#+TITLE: ${title}
  134. ,#+AUTHOR: Christopher James Hayward
  135. ,#+EMAIL: chris@chrishayward.xyz
  136. ")))
  137. #+end_src
  138. Custom capture template for courses.
  139. + Capture a new buffer with =SPC r c c=
  140. #+begin_src emacs-lisp
  141. (with-eval-after-load 'org-roam
  142. (add-to-list 'org-roam-capture-templates
  143. '("c" "Course" plain (function org-roam-capture--get-point)
  144. "%?"
  145. :file-name "docs/courses/${slug}"
  146. :unnarrowed t
  147. :head
  148. "
  149. ,#+TITLE: ${title}
  150. ,#+SUBTITLE:
  151. ,#+AUTHOR: Christopher James Hayward
  152. ,#+EMAIL: chris@chrishayward.xyz
  153. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  154. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  155. ")))
  156. #+end_src
  157. ** Agenda integration
  158. #+ATTR_ORG: :width 420px
  159. #+ATTR_HTML: :width 420px
  160. #+ATTR_LATEX: :width 420px
  161. [[../docs/images/2021-02-13-example-agenda.gif]]
  162. More capture templates for *Org roam*[fn:4] are defined here in the context of specific domains and topics.
  163. + Configure agenda sources
  164. #+begin_src emacs-lisp
  165. (setq org-agenda-files '("~/.emacs.d/"
  166. "~/.emacs.d/docs/"
  167. "~/.emacs.d/docs/courses/"
  168. "~/.emacs.d/docs/daily/"
  169. "~/.emacs.d/docs/notes/"
  170. "~/.emacs.d/docs/posts/"
  171. "~/.emacs.d/docs/slides/"
  172. "~/.emacs.d/hosts/"
  173. "~/.emacs.d/modules/"))
  174. #+end_src
  175. + Open an agenda buffer with =SPC a=
  176. #+begin_src emacs-lisp
  177. (dotfiles/leader
  178. "a" '(org-agenda :which-key "Agenda"))
  179. #+end_src
  180. * Resources
  181. [fn:1] https://orgmode.org
  182. [fn:4] https://github.com/org-roam/org-roam
  183. [fn:5] https://github.com/org-roam/org-roam-server
  184. [fn:6] https://emacswiki.org/emacs/InteractiveSpell
  185. [fn:7] https://emacswiki.org/emacs/FlySpell
  186. [fn:8] https://github.com/bnbeckwith/writegood-mode