Skip to content

Commit

Permalink
core-dotspacemacs: cleaning up (syl20bnr#15661)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucius Hu <lebensterben@users.noreply.github.com>
  • Loading branch information
lebensterben and lebensterben authored Jul 25, 2022
1 parent 45bf382 commit 861ea13
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions core/core-dotspacemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,35 @@
Useful for users in order to given them a hint of potential bottleneck in
their configuration.")

(let* ((env (getenv "SPACEMACSDIR"))
(env-dir (when env (expand-file-name (concat env "/"))))
(env-init (and env-dir (expand-file-name "init.el" env-dir)))
(no-env-dir-default (expand-file-name
(concat user-home-directory
".spacemacs.d/")))
(default-init (expand-file-name ".spacemacs" user-home-directory)))
(defconst dotspacemacs-directory
(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.")

(defvar dotspacemacs-filepath
(let ((spacemacs-dir-init (when dotspacemacs-directory
(concat dotspacemacs-directory
"init.el"))))
(cond
(env-init)
((file-exists-p default-init) default-init)
((and dotspacemacs-directory (file-exists-p spacemacs-dir-init))
spacemacs-dir-init)
(t default-init)))
"Filepath to the installed dotfile. If SPACEMACSDIR is given
then SPACEMACSDIR/init.el is used. Otherwise, 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"))
(defconst dotspacemacs-directory
(let* ((spacemacs-dir-env (getenv "SPACEMACSDIR"))
(spacemacs-dir (if spacemacs-dir-env
(expand-file-name spacemacs-dir-env)
(expand-file-name ".spacemacs.d" user-home-directory))))
(when (file-directory-p spacemacs-dir)
spacemacs-dir))
"Directory containing Spacemacs customizations (defaults to nil).
- If environment variable SPACEMACSDIR is set and the directory exists,
use that value.
- Otherwise use $HOME/.spacemacs.d if it exists.")

(defconst dotspacemacs-filepath
(let* ((spacemacs-dir-env (getenv "SPACEMACSDIR"))
(spacemacs-init (if spacemacs-dir-env
(expand-file-name "init.el" spacemacs-dir-env)
(expand-file-name ".spacemacs" user-home-directory))))
(if (file-regular-p spacemacs-init)
spacemacs-init
(let ((fallback-init (expand-file-name ".spacemacs.d/init.el"
user-home-directory)))
(if (file-regular-p fallback-init)
fallback-init
spacemacs-init))))
"Filepath to Spacemacs configuration file (defaults to ~/.spacemacs).
- If environment variable SPACEMACSDIR is set and SPACEMACSDIR/init.el
exists, use that value.
- Otherwise use ~/.spacemacs if it exists.
- Otherwise use $HOME/.spacemacs.d/init.el if it exists.")

(spacemacs|defc dotspacemacs-distribution 'spacemacs
"Base distribution to use. This is a layer contained in the directory
Expand Down Expand Up @@ -907,8 +904,7 @@ before copying the file if the destination already exists."
(format "%s already exists. Do you want to overwrite it ? "
dotspacemacs-filepath)) t)))
(when copy?
(copy-file (concat dotspacemacs-template-directory
".spacemacs.template")
(copy-file (expand-file-name ".spacemacs.template" dotspacemacs-template-directory)
dotspacemacs-filepath t)
(message "%s has been installed." dotspacemacs-filepath))))

Expand Down

0 comments on commit 861ea13

Please sign in to comment.