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.

153 lines
5.7 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. * Startup
  10. Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory. How can we solve this issue? Shortly after initialization, before most packages load, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post *Immutable Emacs*[fn:1]
  11. #+begin_src emacs-lisp
  12. (setq user-emacs-directory dotfiles/cache)
  13. #+end_src
  14. Because this project uses version-control, we can disable more unwanted features:
  15. + Lock files
  16. + Backup files
  17. #+begin_src emacs-lisp
  18. (setq create-lockfiles nil
  19. make-backup-files nil)
  20. #+end_src
  21. * Packages
  22. Download and install packages using *straight.el*[fn:2], a functional package manager that integrates with *use-package*[fn:3], giving more control over sourcing packages.
  23. + Use the development branch
  24. + Integrate with *use-package*[fn:3]
  25. ** Options
  26. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  27. #+begin_src emacs-lisp
  28. (setq straight-repository-branch "develop"
  29. straight-use-package-by-default t)
  30. #+end_src
  31. ** Setup
  32. Bootstrap the package manager, downloading, installing, or configuring depending on the state of the configuration. All packages build from source, pinned to specific git commit hashes.
  33. #+begin_src emacs-lisp
  34. (defvar bootstrap-version)
  35. (let ((bootstrap-file
  36. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  37. (bootstrap-version 5))
  38. (unless (file-exists-p bootstrap-file)
  39. (with-current-buffer
  40. (url-retrieve-synchronously
  41. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  42. 'silent 'inhibit-cookies)
  43. (goto-char (point-max))
  44. (eval-print-last-sexp)))
  45. (load bootstrap-file nil 'nomessage))
  46. #+end_src
  47. ** Integration
  48. Complete the integration with *use-package*[fn:3] by installing it with *straight.el*[fn:2].
  49. #+begin_src emacs-lisp
  50. (straight-use-package 'use-package)
  51. #+end_src
  52. * Cleanup
  53. 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.
  54. #+begin_src emacs-lisp
  55. (use-package no-littering)
  56. #+end_src
  57. 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.
  58. #+begin_src emacs-lisp
  59. (setq inhibit-startup-message t
  60. initial-scratch-message "")
  61. (global-prettify-symbols-mode)
  62. (when (fboundp 'tooltip-mode)
  63. (tooltip-mode -1))
  64. (when (fboundp 'tool-bar-mode)
  65. (tool-bar-mode -1))
  66. (when (fboundp 'menu-bar-mode)
  67. (menu-bar-mode -1))
  68. (when (fboundp 'scroll-bar-mode)
  69. (scroll-bar-mode -1))
  70. #+end_src
  71. * Performance
  72. 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.
  73. #+begin_src emacs-lisp
  74. (setq gc-cons-threshold most-positive-fixnum
  75. gnutls-min-prime-bits 4096)
  76. #+end_src
  77. * Babel
  78. *Organize your plain life in plain text*
  79. *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.
  80. + Setup ~shell~ and ~emacs-lisp~ as *Babel Languages*[fn:6]
  81. + Configure *Structure Templates*[fn:7] for both languages
  82. #+begin_src emacs-lisp
  83. (use-package org
  84. :hook (org-mode . (lambda ()
  85. (org-indent-mode)
  86. (visual-line-mode 1)
  87. (variable-pitch-mode 1)))
  88. :custom (org-ellipsis " ▾")
  89. (org-log-done 'time)
  90. (org-log-into-drawer t)
  91. (org-return-follows-link t)
  92. (org-image-actual-width nil)
  93. (org-directory dotfiles/home)
  94. (org-src-fontify-natively t)
  95. (org-src-tab-acts-natively t)
  96. (org-src-preserve-indentation t)
  97. (org-confirm-babel-evaluate nil)
  98. (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE")))
  99. :config (require 'org-tempo)
  100. (add-to-list 'org-structure-template-alist '("s" . "src"))
  101. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  102. (add-to-list 'org-structure-template-alist '("e" . "example"))
  103. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  104. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
  105. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)
  106. (emacs-lisp . t))))
  107. #+end_src
  108. * Resources
  109. [fn:1] https://chrishayward.xyz/posts/immutable-emacs/
  110. [fn:2] https://github.com/raxod502/straight.el
  111. [fn:3] https://github.com/jwiegley/use-package
  112. [fn:4] https://orgmode.org
  113. [fn:5] https://chrishayward.xyz/notes/literate-programming/
  114. [fn:6] https://orgmode.org/worg/org-contrib/babel/languages/index.html
  115. [fn:7] https://orgmode.org/manual/Structure-Templates.html