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 23, 2024
1 parent 9ff035a commit 68e7e31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 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,14 @@
;; 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* ((spc-cache (getenv "SPACEMACSCACHE")))
spc-cache
(if-let* ((dot-cache (concat user-emacs-directory ".cache/"))
(xdg-cache (getenv "XDG_CACHE_HOME"))
(spc-cache (expand-file-name "spacemacs/" xdg-cache))
((file-exists-p spc-cache)))
spc-cache
dot-cache))
"Spacemacs storage area for persistent files.")

;; ~/.emacs.d/.cache/auto-save
Expand Down
12 changes: 12 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,17 @@ 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 try the
=spacemacs/= under the CACHE directory if the directory exists, for example
=~/.cache/spacemacs/=.

To override 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 68e7e31

Please sign in to comment.