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.

76 lines
3.0 KiB

4 years ago
  1. #+TITLE: Immutable Emacs
  2. #+AUTHOR: Christopher James Hayward
  3. #+DATE: 2021-01-19
  4. #+HUGO_BASE_DIR: ~/.local/source/website
  5. #+HUGO_SECTION: posts
  6. 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]].
  7. * Getting started
  8. 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.
  9. + Disable lockfiles
  10. + Disable backup files
  11. 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.
  12. #+begin_src emacs-lisp
  13. (defvar dotfiles/home user-emacs-directory)
  14. (defvar dotfiles/cache "~/.cache/emacs")
  15. (setq create-lockfiles nil
  16. make-backup-files nil
  17. user-emacs-directory dotfiles/cache)
  18. #+end_src
  19. * Package management
  20. [[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.
  21. + Use the development branch
  22. + Integrate with =use-package=
  23. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  24. #+begin_src emacs-lisp
  25. (setq straight-repository-branch "develop"
  26. straight-use-package-by-default t)
  27. #+end_src
  28. 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.
  29. #+begin_src emacs-lisp
  30. (defvar bootstrap-version)
  31. (let ((bootstrap-file
  32. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  33. (bootstrap-version 5))
  34. (unless (file-exists-p bootstrap-file)
  35. (with-current-buffer
  36. (url-retrieve-synchronously
  37. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  38. 'silent 'inhibit-cookies)
  39. (goto-char (point-max))
  40. (eval-print-last-sexp)))
  41. (load bootstrap-file nil 'nomessage))
  42. #+end_src
  43. Complete the integration with =use-package= by installing it with ~straight-use-package~:
  44. #+begin_src emacs-lisp
  45. (straight-use-package 'use-package)
  46. #+end_src
  47. * A E S T H E T I C S
  48. 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!
  49. #+begin_src emacs-lisp
  50. (use-package all-the-icons)
  51. (use-package doom-modeline :init (doom-modeline-mode 1))
  52. (use-package doom-themes :init (load-theme 'doom-one t))
  53. #+end_src
  54. * Conclusion
  55. 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.
  56. Enjoy it!