Rename minimal-emacs--default-user-emacs-directory -> minimal-emacs-user-directory

This commit is contained in:
James Cherti
2024-08-12 09:27:05 -04:00
parent 3b6febd52f
commit 919544ed67
2 changed files with 16 additions and 3 deletions

View File

@@ -110,6 +110,19 @@ Always begin your `pre-init.el`, `post-init.el`, `post-early-init.el`, and `pre-
(Replace `FILENAME.el` with the actual name and DESCRIPTION with a brief description of its purpose.) (Replace `FILENAME.el` with the actual name and DESCRIPTION with a brief description of its purpose.)
### Reducing clutter in `~/.emacs.d` by redirecting files to `~/emacs.d/var/`
Emacs, by default, stores various configuration files, caches, backups, and other data in the `~/.emacs.d` directory. Over time, this directory can become cluttered with numerous files, making it difficult to manage and maintain.
One common solution to this issue is the installation of the no-littering package, which reorganizes these files into a more structured format, reducing the clutter in the `~/.emacs.d` directory.
However, an alternative lightweight approach is to simply change the default `~/.emacs.d` directory to `~/.emacs.d/var/`, which will contain all the files that Emacs typically stores in the base directory. This can be accomplished by adding the following code to `~/.emacs.d/post-early-init.el`:
```
(setq minimal-emacs-user-directory user-emacs-directory)
(setq minimal-emacs-var-dir (expand-file-name "var/" minimal-emacs-user-directory))
(setq user-emacs-directory minimal-emacs-var-dir)
```
### How to activate recentf, savehist, saveplace, and auto-revert? ### How to activate recentf, savehist, saveplace, and auto-revert?
The recentf, savehist, saveplace, and auto-revert built-in packages are already configured by `minimal-emacs.d`. All you need to do is activate them by adding the following to `~/.emacs.d/post-init.el`: The recentf, savehist, saveplace, and auto-revert built-in packages are already configured by `minimal-emacs.d`. All you need to do is activate them by adding the following to `~/.emacs.d/post-init.el`:

View File

@@ -16,19 +16,19 @@
;;; Load pre-early-init.el ;;; Load pre-early-init.el
(defvar minimal-emacs--default-user-emacs-directory user-emacs-directory (defvar minimal-emacs-user-directory user-emacs-directory
"The default value of the `user-emacs-directory' variable.") "The default value of the `user-emacs-directory' variable.")
(setq custom-theme-directory (expand-file-name "themes/" user-emacs-directory)) (setq custom-theme-directory (expand-file-name "themes/" user-emacs-directory))
(setq custom-file (setq custom-file
(expand-file-name "custom.el" (expand-file-name "custom.el"
minimal-emacs--default-user-emacs-directory)) minimal-emacs-user-directory))
(defun minimal-emacs-load-user-init (filename) (defun minimal-emacs-load-user-init (filename)
"Execute a file of Lisp code named FILENAME." "Execute a file of Lisp code named FILENAME."
(let ((user-init-file (let ((user-init-file
(expand-file-name filename (expand-file-name filename
minimal-emacs--default-user-emacs-directory))) minimal-emacs-user-directory)))
(when (file-exists-p user-init-file) (when (file-exists-p user-init-file)
(load user-init-file nil t)))) (load user-init-file nil t))))