Skip to content

Commit 68e7e31

Browse files
sunlin7Lin Sun
authored andcommitted
* core-load-paths.el: Support spacemacs-cache-directory from env variable
Support initializing the spacemacs-cache-directory from environment variable SPACEMACSCACHE or XDG_CACHE_HOME.
1 parent 9ff035a commit 68e7e31

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

core/core-load-paths.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
;;; Code:
2828

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

3133
;; ~/.emacs.d
3234
(defvar spacemacs-start-directory
@@ -96,7 +98,14 @@
9698
;; because Spacemacs may be installed to a shared location and this directory
9799
;; and its children should be per-user.
98100
(defconst spacemacs-cache-directory
99-
(concat user-emacs-directory ".cache/")
101+
(if-let* ((spc-cache (getenv "SPACEMACSCACHE")))
102+
spc-cache
103+
(if-let* ((dot-cache (concat user-emacs-directory ".cache/"))
104+
(xdg-cache (getenv "XDG_CACHE_HOME"))
105+
(spc-cache (expand-file-name "spacemacs/" xdg-cache))
106+
((file-exists-p spc-cache)))
107+
spc-cache
108+
dot-cache))
100109
"Spacemacs storage area for persistent files.")
101110

102111
;; ~/.emacs.d/.cache/auto-save

doc/DOCUMENTATION.org

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [[#dotfile-configuration][Dotfile Configuration]]
3838
- [[#dotfile-installation][Dotfile Installation]]
3939
- [[#alternative-dotdirectory][Alternative dotdirectory]]
40+
- [[#alternative-cache-directory][Alternative cache directory]]
4041
- [[#synchronization-of-dotfile-changes][Synchronization of dotfile changes]]
4142
- [[#testing-the-dotfile][Testing the dotfile]]
4243
- [[#dotfile-contents][Dotfile Contents]]
@@ -554,6 +555,17 @@ change the location of this directory.
554555
so =~/.spacemacs= must not exist for =~/.spacemacs.d/init.el= to be used by
555556
Spacemacs.
556557

558+
** Alternative cache directory
559+
Spacemacs use the cache dir =.cache= under =user-emacs-directory=, normally it
560+
is =~/.emacs.d/.cache/=.
561+
562+
If the envrionment variable =XDG_CACHE_HOME= exists, Spacemacs will try the
563+
=spacemacs/= under the CACHE directory if the directory exists, for example
564+
=~/.cache/spacemacs/=.
565+
566+
To override the default cache directory, using the environment variable
567+
=SPACEMACSCACHE=.
568+
557569
** Synchronization of dotfile changes
558570
To apply the modifications made in =~/.spacemacs= press ~SPC f e R~. It will
559571
re-execute the Spacemacs initialization process.

0 commit comments

Comments
 (0)