Add option for .spacemacs.d/init.el .spacemacs file

Setting SPACEMACSDIR overrides location of .spacemacs.d

Add dotspacemacs-directory variable

Add dotspacemacs-directory to layer search path
This commit is contained in:
justbur 2015-05-29 13:08:48 -04:00 committed by syl20bnr
parent 7b47699f87
commit e1eed07c30
2 changed files with 36 additions and 6 deletions

View file

@ -208,12 +208,13 @@ Returns nil if the directory is not a category."
(defun configuration-layer//discover-layers ()
"Return a hash table where the key is the layer symbol and the value is its
path."
;; load private layers at the end on purpose
;; we asume that the user layers must have the final word
;; on configuration choices.
;; load private layers at the end on purpose we asume that the user layers
;; must have the final word on configuration choices. Let
;; `dotspacemacs-directory' override the private directory if it exists.
(let ((search-paths (append (list configuration-layer-contrib-directory)
dotspacemacs-configuration-layer-path
(list configuration-layer-private-directory)))
(list configuration-layer-private-directory)
(list dotspacemacs-directory)))
(discovered '())
(result (make-hash-table :size 256)))
;; depth-first search of subdirectories

View file

@ -13,9 +13,38 @@
(expand-file-name (concat spacemacs-core-directory "templates/"))
"Templates directory.")
(defconst dotspacemacs-directory
(let* ((env (getenv "SPACEMACSDIR"))
(env-dir (if env (expand-file-name (concat env "/"))))
(no-env-dir-default (expand-file-name
(concat user-home-directory
".spacemacs.d/"))))
(cond
((and env (file-exists-p env-dir))
env-dir)
((file-exists-p no-env-dir-default)
no-env-dir-default)
(t
nil)))
"Optional spacemacs directory, which defaults to
~/.spacemacs.d. This setting can be overridden using the
SPACEMACSDIR environment variable. If neither of these
directories exist, this variable will be nil.")
(defconst dotspacemacs-filepath
(concat user-home-directory ".spacemacs")
"Filepath to the installed dotfile.")
(let* ((default (concat user-home-directory ".spacemacs"))
(spacemacs-dir-init (if dotspacemacs-directory
(concat dotspacemacs-directory
"init.el"))))
(if (and (not (file-exists-p default))
dotspacemacs-directory
(file-exists-p spacemacs-dir-init))
spacemacs-dir-init
default))
"Filepath to the installed dotfile. If ~/.spacemacs exists,
then this is used. If ~/.spacemacs does not exist, then check
for init.el in dotspacemacs-directory and use this if it
exists. Otherwise, fallback to ~/.spacemacs")
(defvar dotspacemacs-verbose-loading nil
"If non nil output loading progess in `*Messages*' buffer.")