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.

132 lines
5.0 KiB

  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 *Immutable Emacs*[fn:1].
  9. + Packages are managed with *straight.el*[fn:2]
  10. + Packages are installed with *use-package*[fn:3]
  11. * Babel
  12. *Organize your plain life in plain text*
  13. *Org mode*[fn:4] is one of the hallmark features of Emacs, and provides the basis for my *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*[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:6]
  19. + Configure *Structure Templates*[fn:7] 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 *no-littering*[fn:3] to reduce the files created by Emacs.
  48. #+begin_src emacs-lisp
  49. (use-package no-littering)
  50. #+end_src
  51. 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.
  52. #+begin_src emacs-lisp
  53. (setq inhibit-startup-message t
  54. initial-scratch-message "")
  55. (global-prettify-symbols-mode)
  56. (when (fboundp 'tooltip-mode)
  57. (tooltip-mode -1))
  58. (when (fboundp 'tool-bar-mode)
  59. (tool-bar-mode -1))
  60. (when (fboundp 'menu-bar-mode)
  61. (menu-bar-mode -1))
  62. (when (fboundp 'scroll-bar-mode)
  63. (scroll-bar-mode -1))
  64. #+end_src
  65. * Methods
  66. Define some helper methods to use throughout the configuration.
  67. ** Tangle directory
  68. Build all of the *Org*[fn:4] files within a given directory, recursively.
  69. #+begin_src emacs-lisp
  70. (defun dotfiles/tangle (dir)
  71. "Recursively tangle the Org files within a directory."
  72. (let ((org-files (directory-files-recursively dir "org")))
  73. (dolist (f org-files)
  74. (org-babel-tangle-file f))))
  75. #+end_src
  76. ** Force symbolic links
  77. 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.
  78. #+begin_src emacs-lisp
  79. (defun dotfiles/symlink (src tgt)
  80. "Forces a symlink from `src' to `tgt'."
  81. (let ((sys-file (expand-file-name tgt))
  82. (dot-file (expand-file-name src)))
  83. (when (or (not (file-exists-p sys-file))
  84. (not (equal (file-symlink-p sys-file) dot-file)))
  85. (delete-file sys-file)
  86. (make-symbolic-link dot-file sys-file))))
  87. #+end_src
  88. * Performance
  89. 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 and the minimum prime bit size.
  90. #+begin_src emacs-lisp
  91. (setq gc-cons-threshold most-positive-fixnum
  92. gnutls-min-prime-bits 4096)
  93. #+end_src
  94. * Resources
  95. [fn:1] https://chrishayward.xyz/posts/immutable-emacs/
  96. [fn:2] https://github.com/raxod502/straight.el
  97. [fn:3] https://github.com/jwiegley/use-package
  98. [fn:4] https://orgmode.org
  99. [fn:5] https://chrishayward.xyz/notes/literate-programming/
  100. [fn:6] https://orgmode.org/worg/org-contrib/babel/languages/index.html
  101. [fn:7] https://orgmode.org/manual/Structure-Templates.html