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.

127 lines
4.8 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
  1. #+TITLE: Org
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle org.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. Organize your plain-life in plain-text. The hallmark feature of Emacs, ~org-mode~[fn:1] is the king of markup languages. It has rich feature support for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities.
  9. * Setup
  10. Define a custom hook when ~org-mode~[fn:1] is enabled to customize the experience:
  11. + Enable ~org-indent-mode~ to indent and align text with the parent heading
  12. + Enable ~visual-line-mode~ to allow text to overflow and wrap to the next visual line
  13. + Enable ~variable-pitch-mode~ to support multiple font-pitches and monospaced fonts
  14. #+begin_src emacs-lisp
  15. (defun dotfiles/org-mode-hook ()
  16. (org-indent-mode) ;; Indent and align text.
  17. (visual-line-mode 1) ;; Allow text to overflow line.
  18. (variable-pitch-mode 1)) ;; Enable monospaced fonts.
  19. #+end_src
  20. * Config
  21. Force ~straight~ to ignore the local version of ~org-mode~[fn:1], instead downloading the most recent version available.
  22. #+begin_src emacs-lisp
  23. (straight-use-package '(org :local-repo nil))
  24. #+end_src
  25. Setup the default babel languages and structure templates, and apply customizations:
  26. + Setup ~org-mode-hook~ with our custom hook
  27. + Setup ~org-ellipsis~ to show headlines with hidden contents
  28. + Setup ~org-log-*~ for event logging
  29. + Setup ~org-src-*~ for source blocks
  30. + Setup ~org-todo-keyword~ sequence
  31. #+begin_src emacs-lisp
  32. (use-package org
  33. :hook (org-mode . dotfiles/org-mode-hook)
  34. :custom (org-ellipsis " ▾")
  35. (org-log-done 'time)
  36. (org-log-into-drawer t)
  37. (org-return-follows-link t)
  38. (org-image-actual-width nil)
  39. (org-directory dotfiles/home)
  40. (org-src-fontify-natively t)
  41. (org-src-tab-acts-natively t)
  42. (org-src-preserve-indentation t)
  43. (org-confirm-babel-evaluate nil)
  44. (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE")))
  45. :config (require 'org-tempo) ;; Required for structure templates.
  46. (add-to-list 'org-structure-template-alist '("s" . "src"))
  47. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  48. (add-to-list 'org-structure-template-alist '("e" . "example"))
  49. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  50. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
  51. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)
  52. (emacs-lisp . t))))
  53. #+end_src
  54. ** Flashcards
  55. Create study flashcards using ~org-drill~[fn:2], an extension for ~org-mode~. It uses a spaced repititon algorithm to conduct interactive drill sesslions using ~org-mode~ buffers as sources of facts to be memorized. Each drill can be restricted to topics in the current buffer, one of several, all agenda files, or a single topic across all buffers.
  56. #+begin_src emacs-lisp
  57. (use-package org-drill
  58. :after org)
  59. #+end_src
  60. ** Headline stars
  61. Make the headline stars a bit more *super* with ~org-superstar-mode~[fn:3]. Only enable this inside of a window system, as the effect can be distracting on the TTY.
  62. #+begin_src emacs-lisp
  63. (use-package org-superstar
  64. :when (window-system)
  65. :after org
  66. :hook (org-mode . org-superstar-mode))
  67. #+end_src
  68. * Methods
  69. Define some custom methods for use in the rest of the configuration.
  70. ** Tangle directory
  71. Build all of the ~org~ files within a given directory, recursively. This is used in CI.
  72. #+begin_src emacs-lisp
  73. (defun dotfiles/tangle (dir)
  74. "Recursively tangle the Org files within a directory."
  75. (interactive)
  76. (let ((org-files (directory-files-recursively dir "org")))
  77. (dolist (f org-files)
  78. (org-babel-tangle-file f))))
  79. #+end_src
  80. ** Force symbolic links
  81. Function that takes in a system and configuration file path, checks to see if the system file doesn't exist, or doesn't point to the configuration file, deleting it for the latter, then creating a symbolic link to the configuration file in place.
  82. #+begin_src emacs-lisp
  83. (defun dotfiles/symlink (src tgt)
  84. "Forces a symlink from `src' to `tgt'."
  85. (interactive)
  86. (let ((sys-file (expand-file-name tgt))
  87. (dot-file (expand-file-name src)))
  88. (when (or (not (file-exists-p sys-file))
  89. (not (equal (file-symlink-p sys-file) dot-file)))
  90. (delete-file sys-file)
  91. (make-symbolic-link dot-file sys-file))))
  92. #+end_src
  93. * Footnotes
  94. [fn:1] https://orgmode.org
  95. [fn:2] https://orgmode.org/worg/org-contrib/org-drill.html
  96. [fn:3] https://github.com/integral-dw/org-superstar-mode