Define new variable: spacemacs-start-directory.

With this new variable, user can load spacemacs anywhere, e.g.
"~/.emacs.d/spacemacs/". Only user's cache directory is still hard-coded
as "~/.emacs.d/.cache/". If user want to use spacemacs this way, drop
one line as the below in "~/.emacs.d/init.el":

    (setq spacemacs-start-directory "~/.emacs.d/spacemacs/")
    (load-file (concat spacemacs-start-directory "init.el"))
This commit is contained in:
Exaos-memes 2016-06-23 00:19:12 -04:00 committed by syl20bnr
parent bef22b40a4
commit 904f7ea665
9 changed files with 33 additions and 32 deletions

View File

@ -28,11 +28,11 @@
"Configuration layer templates directory.")
(defconst configuration-layer-directory
(expand-file-name (concat user-emacs-directory "layers/"))
(expand-file-name (concat spacemacs-start-directory "layers/"))
"Spacemacs contribution layers base directory.")
(defconst configuration-layer-private-directory
(expand-file-name (concat user-emacs-directory "private/"))
(expand-file-name (concat spacemacs-start-directory "private/"))
"Spacemacs private layers base directory.")
(defconst configuration-layer-private-layer-directory

View File

@ -39,7 +39,7 @@
(dolist (l layers)
(let ((layer-name (file-name-nondirectory l))
(target-path (concat (file-relative-name
l (concat user-emacs-directory "layers"))
l (concat spacemacs-start-directory "layers"))
"/README.org")))
(insert (format "- [[file:%s][%s]]\n" target-path layer-name))))
(dolist (c categories)
@ -66,7 +66,7 @@
;; uncomment this line if any new layer is added at the root level
;; (insert "* General layers\n")
(spacemacs//generate-layers-from-path configuration-layer-directory "*")
(write-file (concat user-emacs-directory "layers/LAYERS.org"))))
(write-file (concat spacemacs-start-directory "layers/LAYERS.org"))))
(defun spacemacs//format-toc (&rest r)
(if (not (null (car r)))
@ -198,7 +198,7 @@ preprocessors for the exported .org files."
ga('create', 'UA-28326243-2', 'auto'); ga('send', 'pageview');
</script>")
(publish-target (concat user-emacs-directory "export/"))
(publish-target (concat spacemacs-start-directory "export/"))
(org-html-htmlize-output-type 'css)
(org-publish-project-alist
`(("spacemacs"
@ -214,7 +214,7 @@ preprocessors for the exported .org files."
:headline-levels 4
:html-head ,header)
("layers-doc"
:base-directory ,(concat user-emacs-directory "layers/")
:base-directory ,(concat spacemacs-start-directory "layers/")
:base-extension "org"
:recursive t
:publishing-directory ,(concat publish-target "layers/")
@ -229,7 +229,7 @@ preprocessors for the exported .org files."
:publishing-directory ,(concat publish-target "doc/")
:publishing-function org-publish-attachment)
("layers-doc-static"
:base-directory ,(concat user-emacs-directory "layers/")
:base-directory ,(concat spacemacs-start-directory "layers/")
:base-extension "jpg\\|png\\|gif"
:recursive t
:publishing-directory ,(concat publish-target "layers/")

View File

@ -12,7 +12,7 @@
;; paths
(defconst spacemacs-core-directory
(expand-file-name (concat user-emacs-directory "core/"))
(expand-file-name (concat spacemacs-start-directory "core/"))
"Spacemacs core directory.")
(defconst spacemacs-info-directory
(expand-file-name (concat spacemacs-core-directory "info/"))
@ -40,13 +40,13 @@
(expand-file-name (concat spacemacs-cache-directory "auto-save/"))
"Spacemacs auto-save directory")
(defconst spacemacs-docs-directory
(expand-file-name (concat user-emacs-directory "doc/"))
(expand-file-name (concat spacemacs-start-directory "doc/"))
"Spacemacs documentation directory.")
(defconst spacemacs-assets-directory
(expand-file-name (concat user-emacs-directory "assets/"))
(expand-file-name (concat spacemacs-start-directory "assets/"))
"Spacemacs assets directory.")
(defconst spacemacs-test-directory
(expand-file-name (concat user-emacs-directory "tests/"))
(expand-file-name (concat spacemacs-start-directory "tests/"))
"Spacemacs tests directory.")
(defconst user-home-directory
@ -64,8 +64,8 @@
;; load paths
(mapc 'add-to-load-path
`(
,(concat user-emacs-directory "core/")
,(concat user-emacs-directory "core/libs/")
,(concat user-emacs-directory "core/aprilfool/")
,(concat spacemacs-start-directory "core/")
,(concat spacemacs-start-directory "core/libs/")
,(concat spacemacs-start-directory "core/aprilfool/")
,(concat user-dropbox-directory "emacs/")
))

View File

@ -85,8 +85,8 @@ found."
(message "Start checking for new version...")
(async-start
`(lambda ()
,(async-inject-variables "\\`user-emacs-directory\\'")
(load-file (concat user-emacs-directory "core/core-load-paths.el"))
,(async-inject-variables "\\`spacemacs-start-directory\\'")
(load-file (concat spacemacs-start-directory "core/core-load-paths.el"))
(require 'core-spacemacs)
(spacemacs/get-last-version))
(lambda (result)
@ -144,7 +144,7 @@ version and the NEW version."
(defun spacemacs/git-has-remote (remote)
"Return non nil if REMOTE is declared."
(let((proc-buffer "git-has-remote")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(when (eq 0 (process-file "git" nil proc-buffer nil "remote"))
(with-current-buffer proc-buffer
(prog2
@ -155,7 +155,7 @@ version and the NEW version."
(defun spacemacs/git-add-remote (remote url)
"Add a REMOTE with URL, return t if no error."
(let((proc-buffer "git-add-remote")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog1
(eq 0 (process-file "git" nil proc-buffer nil
"remote" "add" remote url))
@ -164,7 +164,7 @@ version and the NEW version."
(defun spacemacs/git-remove-remote (remote)
"Remove a REMOTE, return t if no error."
(let((proc-buffer "git-remove-remote")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog1
(eq 0 (process-file "git" nil proc-buffer nil
"remote" "remove" remote))
@ -173,7 +173,7 @@ version and the NEW version."
(defun spacemacs/git-fetch-remote (remote)
"Fetch last commits from REMOTE, return t if no error."
(let((proc-buffer "git-remove-remote")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog1
(eq 0 (process-file "git" nil proc-buffer nil
"fetch" remote))
@ -182,7 +182,7 @@ version and the NEW version."
(defun spacemacs/git-fetch-tags (remote branch)
"Fetch the tags for BRANCH in REMOTE repository."
(let((proc-buffer "git-fetch-tags")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog2
;; seems necessary to fetch first
(eq 0 (process-file "git" nil proc-buffer nil
@ -195,7 +195,7 @@ version and the NEW version."
(defun spacemacs/git-hard-reset-to-tag (tag)
"Hard reset the current branch to specifed TAG."
(let((proc-buffer "git-hard-reset")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog1
(eq 0 (process-file "git" nil proc-buffer nil
"reset" "--hard" tag))
@ -204,7 +204,7 @@ version and the NEW version."
(defun spacemacs/git-latest-tag (remote branch)
"Returns the latest tag on REMOTE/BRANCH."
(let((proc-buffer "git-latest-tag")
(default-directory (file-truename user-emacs-directory))
(default-directory (file-truename spacemacs-start-directory))
(where (format "%s/%s" remote branch)))
(when (eq 0 (process-file "git" nil proc-buffer nil
"describe" "--tags" "--abbrev=0"
@ -223,7 +223,7 @@ version and the NEW version."
(defun spacemacs/git-checkout (branch)
"Checkout the given BRANCH. Return t if there is no error."
(let((proc-buffer "git-checkout")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(prog1
(eq 0 (process-file "git" nil proc-buffer nil
"checkout" branch))
@ -232,7 +232,7 @@ version and the NEW version."
(defun spacemacs/git-get-current-branch ()
"Return the current branch. Return nil if an error occurred."
(let((proc-buffer "git-get-current-branch")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(when (eq 0 (process-file "git" nil proc-buffer nil
"symbolic-ref" "--short" "-q" "HEAD"))
(with-current-buffer proc-buffer
@ -249,7 +249,7 @@ version and the NEW version."
"Returns the hash of the head commit on the current branch.
Returns nil if an error occurred."
(let((proc-buffer "git-get-current-branch-head-hash")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(when (eq 0 (process-file "git" nil proc-buffer nil
"rev-parse" "--short" "HEAD"))
(with-current-buffer proc-buffer
@ -266,7 +266,7 @@ Returns nil if an error occurred."
"Non-nil if the user's emacs directory is not clean.
Returns the output of git status --porcelain."
(let((proc-buffer "git-working-directory-dirty")
(default-directory (file-truename user-emacs-directory)))
(default-directory (file-truename spacemacs-start-directory)))
(when (eq 0 (process-file "git" nil proc-buffer nil
"status" "--porcelain"))
(with-current-buffer proc-buffer

View File

@ -328,7 +328,7 @@ If TYPE is nil, just remove widgets."
:action
(lambda (&rest ignore)
(funcall 'spacemacs/view-org-file
(concat user-emacs-directory
(concat spacemacs-start-directory
"CHANGELOG.org")
(format "Release %s.x"
spacemacs-buffer-version-info)

View File

@ -22,7 +22,8 @@
(message (concat "Your version of Emacs (%s) is too old. "
"Spacemacs requires Emacs version %s or above.")
emacs-version spacemacs-emacs-min-version)
(load-file (concat user-emacs-directory "core/core-load-paths.el"))
(defvar spacemacs-start-directory user-emacs-directory)
(load-file (concat spacemacs-start-directory "core/core-load-paths.el"))
(require 'core-spacemacs)
(spacemacs/init)
(spacemacs/maybe-install-dotfile)

View File

@ -164,7 +164,7 @@
(defun spacemacs/rcirc-notify-beep (msg)
"Beep when notifying."
(let ((player "mplayer")
(sound (concat user-emacs-directory "site-misc/startup.ogg")))
(sound (concat spacemacs-start-directory "site-misc/startup.ogg")))
(when (and (executable-find player)
(file-exists-p sound)))
(start-process "beep-process" nil player sound)))

View File

@ -170,7 +170,7 @@
;; CONTRIBUTING.org is a special case as it should be at the
;; root of the repository to be linked as the contributing
;; guide on Github.
(concat user-emacs-directory candidate)
(concat spacemacs-start-directory candidate)
(concat spacemacs-docs-directory candidate))))
(cond ((and (equal (file-name-extension file) "md")
(not helm-current-prefix-arg))

View File

@ -92,7 +92,7 @@
;; CONTRIBUTING.org is a special case as it should be at the
;; root of the repository to be linked as the contributing
;; guide on Github.
(concat user-emacs-directory candidate)
(concat spacemacs-start-directory candidate)
(concat spacemacs-docs-directory candidate))))
(cond ((equal (file-name-extension file) "md")
(condition-case-unless-debug nil