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.

79 lines
3.1 KiB

4 years ago
4 years ago
4 years ago
  1. #+TITLE: Immutable Emacs
  2. #+AUTHOR: Christopher James Hayward
  3. #+DATE: 2021-01-19
  4. #+ROAM_KEY: https://chrishayward.xyz/posts/immutable-emacs/
  5. #+HUGO_BASE_DIR: ~/.local/source/website
  6. #+HUGO_AUTO_SET_LASTMOD: t
  7. #+HUGO_SECTION: posts
  8. You can easily create an *Immutable* and *100% Reproducible* custom Emacs configuration with very little effort. My inspiration for this came from the =Emacs From Scratch= series by [[https://youtube.com/c/SystemCrafters][System Crafters]].
  9. * Getting started
  10. Emacs created *lots* of files relative to ~user-emacs-directory~, which are *not* part of this configuration and do not belong in the same directory.
  11. + Disable lockfiles
  12. + Disable backup files
  13. To acheive this functionality, before anything else happens we change this directory to ~~/.cache/emacs~, while keeping the old value of ~user-emacs-directory~ in our own variable.
  14. #+begin_src emacs-lisp
  15. (defvar dotfiles/home user-emacs-directory)
  16. (defvar dotfiles/cache "~/.cache/emacs")
  17. (setq create-lockfiles nil
  18. make-backup-files nil
  19. user-emacs-directory dotfiles/cache)
  20. #+end_src
  21. * Package management
  22. [[https://github.com/raxod502/straight.el][Straight]] is a 100% functional package manager for Emacs, with integration for =use-package=, a common way to download / configure / install Emacs packages.
  23. + Use the development branch
  24. + Integrate with =use-package=
  25. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  26. #+begin_src emacs-lisp
  27. (setq straight-repository-branch "develop"
  28. straight-use-package-by-default t)
  29. #+end_src
  30. Bootstrap the package manager, downloading, installing, or configuring depending on the state of the configuration. All packages are downloaded and built from source, and can be pinned to specific git commit hashes.
  31. #+begin_src emacs-lisp
  32. (defvar bootstrap-version)
  33. (let ((bootstrap-file
  34. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  35. (bootstrap-version 5))
  36. (unless (file-exists-p bootstrap-file)
  37. (with-current-buffer
  38. (url-retrieve-synchronously
  39. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  40. 'silent 'inhibit-cookies)
  41. (goto-char (point-max))
  42. (eval-print-last-sexp)))
  43. (load bootstrap-file nil 'nomessage))
  44. #+end_src
  45. Complete the integration with =use-package= by installing it with ~straight-use-package~:
  46. #+begin_src emacs-lisp
  47. (straight-use-package 'use-package)
  48. #+end_src
  49. * A E S T H E T I C S
  50. If you've ever looked at default Emacs, you know that it's one of the ugliest GUI applications out of the box. Including a few packages, cherry picked from ~Doom~ can bring Emacs out of the eightes!
  51. #+begin_src emacs-lisp
  52. (use-package all-the-icons)
  53. (use-package doom-modeline :init (doom-modeline-mode 1))
  54. (use-package doom-themes :init (load-theme 'doom-one t))
  55. #+end_src
  56. * Conclusion
  57. Now that the *stateful* and *immutable* files are seperated, and the default look has been improved *slightly* you're left with a clean, immutable, and reproducible Emacs configuration to continue hacking on.
  58. Enjoy it!