Skip to content

Commit

Permalink
* core-load-paths.el: Support spacemacs-cache-directory from env vari…
Browse files Browse the repository at this point in the history
…able

Support initializing the spacemacs-cache-directory from environment
variable SPACEMACSCACHE or XDG_CACHE_HOME.
  • Loading branch information
sunlin7 authored and Lin Sun committed Dec 9, 2024
1 parent 063a915 commit 56f1b49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/core-load-paths.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
;;; Code:

;;;; PATH variables/constants
(when (version<= emacs-version "28")
(eval-when-compile (require 'subr-x))) ; for the 'if-let*'

;; ~/.emacs.d
(defvar spacemacs-start-directory
Expand Down Expand Up @@ -96,7 +98,11 @@
;; because Spacemacs may be installed to a shared location and this directory
;; and its children should be per-user.
(defconst spacemacs-cache-directory
(concat user-emacs-directory ".cache/")
(if-let* ((cache-dir (getenv "SPACEMACSCACHE")))
cache-dir
(if-let* ((xdg-cache (getenv "XDG_CACHE_HOME")))
(expand-file-name "spacemacs/" xdg-cache)
(concat user-emacs-directory ".cache/")))
"Spacemacs storage area for persistent files.")

;; ~/.emacs.d/.cache/auto-save
Expand Down
11 changes: 11 additions & 0 deletions doc/DOCUMENTATION.org
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [[#dotfile-configuration][Dotfile Configuration]]
- [[#dotfile-installation][Dotfile Installation]]
- [[#alternative-dotdirectory][Alternative dotdirectory]]
- [[#alternative-cache-directory][Alternative cache directory]]
- [[#synchronization-of-dotfile-changes][Synchronization of dotfile changes]]
- [[#testing-the-dotfile][Testing the dotfile]]
- [[#dotfile-contents][Dotfile Contents]]
Expand Down Expand Up @@ -554,6 +555,16 @@ change the location of this directory.
so =~/.spacemacs= must not exist for =~/.spacemacs.d/init.el= to be used by
Spacemacs.

** Alternative cache directory
Spacemacs use the cache dir =.cache= under =user-emacs-directory=, normally it
is =~/.emacs.d/.cache/=.

If the envrionment variable =XDG_CACHE_HOME= exists, Spacemacs will use the
=spacemacs/= under the CACHE directory, for example =~/.cache/spacemacs/=.

To change the default cache directory, using the environment variable
=SPACEMACSCACHE=.

** Synchronization of dotfile changes
To apply the modifications made in =~/.spacemacs= press ~SPC f e R~. It will
re-execute the Spacemacs initialization process.
Expand Down

0 comments on commit 56f1b49

Please sign in to comment.