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.

117 lines
5.2 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: Core
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle core.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. Minimal configuration to make Emacs usable for my own personal workflow. This does little in the ways of improving the visuals, only removing what's included by default and not required. Read more about my technique in my post [[https://chrishayward.xyz/posts/immutabe-emacs/][Immutable Emacs]][fn:1]
  9. + Packages are managed with [[https://github.com/raxod502/straight.el][straight.el]][fn:2]
  10. + Packages are installed with [[https://github.com/jwiegley/use-package][use-package]][fn:3]
  11. * Babel
  12. *Organize your plain life in plain text*
  13. [[https://orgmode.org][Org-mode]][fn:4] is one of the hallmark features of Emacs, and provides the basis for my [[https://chrishayward.xyz/notes/literate-programming/][Literate Programming]][fn:5] platform. It's essentially a markdown language with rich features for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities.
  14. + Force *straight.el*[fn:2] to ignore the local version of *Org-mode*[fn:4]
  15. #+begin_src emacs-lisp
  16. (straight-use-package '(org :local-repo nil))
  17. #+end_src
  18. + Setup ~shell~ and ~emacs-lisp~ as *Babel Languages*[fn:4]
  19. + Configure *Structure Templates*[fn:4] for both languages
  20. #+begin_src emacs-lisp
  21. (use-package org
  22. :hook (org-mode . (lambda ()
  23. (org-indent-mode)
  24. (visual-line-mode 1)
  25. (variable-pitch-mode 1)))
  26. :custom (org-ellipsis " ▾")
  27. (org-log-done 'time)
  28. (org-log-into-drawer t)
  29. (org-return-follows-link t)
  30. (org-image-actual-width nil)
  31. (org-directory dotfiles/home)
  32. (org-src-fontify-natively t)
  33. (org-src-tab-acts-natively t)
  34. (org-src-preserve-indentation t)
  35. (org-confirm-babel-evaluate nil)
  36. (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE")))
  37. :config (require 'org-tempo)
  38. (add-to-list 'org-structure-template-alist '("s" . "src"))
  39. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  40. (add-to-list 'org-structure-template-alist '("e" . "example"))
  41. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  42. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
  43. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)
  44. (emacs-lisp . t))))
  45. #+end_src
  46. * Cleanup
  47. Despite having our *stateful* and *immutable* configurations seperate, it's good practice to make efforts to reduce the trash created by Emacs. Install [[https://github.com/emacs-collective/no-littering][no-littering]][fn:6] to reduce the files created by Emacs. Now that we've taken care of how it acts, we can work on how it looks. Emacs' default user interface is *horrendous*, let's do something about that. Emacs has a long history of running on machines without gigabytes of available memory, let it realize its full potential by increasing the garbage collection threshold.
  48. #+begin_src emacs-lisp
  49. (use-package no-littering
  50. :custom (inhibit-startup-message t)
  51. (initial-scratch-message "")
  52. (comp-deferred-compilation t)
  53. (custom gc-cons-threshold most-positive-fixnum)
  54. :config (global-prettify-symbols-mode)
  55. (when (fboundp 'tooltip-mode)
  56. (tooltip-mode -1))
  57. (when (fboundp 'tool-bar-mode)
  58. (tool-bar-mode -1))
  59. (when (fboundp 'menu-bar-mode)
  60. (menu-bar-mode -1))
  61. (when (fboundp 'scroll-bar-mode)
  62. (scroll-bar-mode -1)))
  63. #+end_src
  64. * Methods
  65. Define some helper methods to use throughout the configuration.
  66. ** Tangle directory
  67. Build all of the *Org*[fn:4] files within a given directory, recursively.
  68. #+begin_src emacs-lisp
  69. (defun dotfiles/tangle (dir)
  70. "Recursively tangle the Org files within a directory."
  71. (let ((org-files (directory-files-recursively dir "org")))
  72. (dolist (f org-files)
  73. (org-babel-tangle-file f))))
  74. #+end_src
  75. ** Force symbolic links
  76. 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.
  77. #+begin_src emacs-lisp
  78. (defun dotfiles/symlink (src tgt)
  79. "Forces a symlink from `src' to `tgt'."
  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. * Resources
  88. [fn:1] https://chrishayward.xyz/posts/immutable-emacs/
  89. [fn:2] https://github.com/raxod502/straight.el
  90. [fn:3] https://github.com/jwiegley/use-package
  91. [fn:4] https://orgmode.org
  92. [fn:5] https://chrishayward.xyz/notes/literate-programming/
  93. [fn:6] https://github.com/emacs-collective/no-littering