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.

116 lines
4.3 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
  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. ** Headline stars
  55. Make the headline stars a bit more *super* with ~org-superstar-mode~[fn:2]. Only enable this inside of a window system, as the effect can be distracting on the TTY.
  56. #+begin_src emacs-lisp
  57. (use-package org-superstar
  58. :when (window-system)
  59. :after org
  60. :hook (org-mode . org-superstar-mode))
  61. #+end_src
  62. * Methods
  63. Define some custom methods for use in the rest of the configuration.
  64. ** Tangle directory
  65. Build all of the ~org~ files within a given directory, recursively. This is used in CI.
  66. #+begin_src emacs-lisp
  67. (defun dotfiles/tangle (dir)
  68. "Recursively tangle the Org files within a directory."
  69. (interactive)
  70. (let ((org-files (directory-files-recursively dir "org")))
  71. (dolist (f org-files)
  72. (org-babel-tangle-file f))))
  73. #+end_src
  74. ** Force symbolic links
  75. 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.
  76. #+begin_src emacs-lisp
  77. (defun dotfiles/symlink (src tgt)
  78. "Forces a symlink from `src' to `tgt'."
  79. (interactive)
  80. (let ((sys-file (expand-file-name tgt))
  81. (dot-file (expand-file-name src)))
  82. (when (or (not (file-exists-p sys-file))
  83. (not (equal (file-symlink-p sys-file) dot-file)))
  84. (delete-file sys-file)
  85. (make-symbolic-link dot-file sys-file))))
  86. #+end_src
  87. * Footnotes
  88. [fn:1] https://orgmode.org
  89. [fn:2] https://github.com/integral-dw/org-superstar-mode