Skip to content

Instantly share code, notes, and snippets.

@kaz-yos
Last active January 13, 2021 23:26
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kaz-yos/0c7bc69d3df6a9199b4db715b9455a30 to your computer and use it in GitHub Desktop.
Save kaz-yos/0c7bc69d3df6a9199b4db715b9455a30 to your computer and use it in GitHub Desktop.
.emacs file to run Spacemacs and regular Emacs side by side.
;;; dot_emacs.el --- -*- lexical-binding: t; -*-
;;; Select emacs config file directory depending on emacs being run
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; (package-initialize)
;; Ref: http://emacs.stackexchange.com/questions/19936/running-spacemacs-alongside-regular-emacs-how-to-keep-a-separate-emacs-d
;;; Check the current executable file and assign the appropriate user directory.
;; The unless is to avoid executing this script twice.
(unless (boundp 'dot-emacs-loaded)
(let ((emacs-exec-path (expand-file-name
;; The program name that was used to run Emacs.
invocation-name
;; The directory in which the Emacs executable was found, to run it.
invocation-directory)))
;;
;; Check if executable path contains spacemacs
;; Duplicate Emacs.app and rename it to Spacemacs.app
(when (string-match ".*spacemacs*" (downcase emacs-exec-path))
;; If so, change user-emacs-directory to spacemacs one
;; Directory beneath which additional per-user Emacs-specific files are placed.
;;
;; Clone spacemacs configurations into ~/.spacemacs.d.
;; An empty ~/.spacemacs file is also necessary.
;; As of 2016-12-25, only the develop branch is compatible.
(setq user-emacs-directory "~/.spacemacs.d/"))
;;
;; Load init.el under user directory.
(load (expand-file-name "init.el" user-emacs-directory))
;; Create a variable to indicate this script has been run.
(defvar dot-emacs-loaded t)))
@WJCFerguson
Copy link

WJCFerguson commented Mar 2, 2018

Thanks for this! Seems to work with current spacemacs. So in summary:

Download this file to ~/.emacs (if you already have a ~/.emacs, move it to .emacs.d/init.el
then:

sudo ln -s $(which emacs) $(dirname $(which emacs))/spacemacs
cd
git clone git@github.com:syl20bnr/spacemacs.git .spacemacs.d

Then you can run spacemacs. Sweet. This may get me to seriously transfer my old config to spacemacs and join the party.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment