Merge pull request #7 from lazyatom/patch-1

Allow selection of default profile using a file
This commit is contained in:
Arne Brasseur 2018-09-18 13:42:47 +02:00 committed by GitHub
commit 2a1f418ef8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

14
.emacs
View file

@ -32,6 +32,9 @@
;; (custom-file . "~/.spacemacs.d/custom.el")
;; (env . (("SPACEMACSDIR" . "~/.spacemacs.d"))))))
;;
;; If you want to change the default profile used (so that, for example, a
;; GUI version of Emacs uses the profile you want), you can also put the name
;; of that profile in a ~/.emacs-profile file
;; ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;; this must be here to keep the package system happy, normally you do
@ -39,6 +42,7 @@
;; (package-initialize)
(setq chemacs-profiles-path "~/.emacs-profiles.el")
(setq chemacs-default-profile-path "~/.emacs-profile")
(when (not (file-exists-p chemacs-profiles-path))
(with-temp-file chemacs-profiles-path
@ -50,6 +54,14 @@
(goto-char (point-min))
(read (current-buffer))))
(setq chemacs-default-profile
(if (file-exists-p chemacs-default-profile-path)
(with-temp-buffer
(insert-file-contents chemacs-default-profile-path)
(goto-char (point-min))
(read (current-buffer)))
"default"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun chemacs-get-emacs-profile (profile)
@ -106,4 +118,4 @@
;; Or if none given, load the "default" profile
(when (not (member "--with-profile" command-line-args))
(chemacs-load-profile "default"))
(chemacs-load-profile (chemacs-default-profile)))

View file

@ -149,6 +149,36 @@ a version controlled directory of dotfiles, then check out
[[https://github.com/plexus/dotfiles/blob/master/connect-the-dots][connect-the-dots]]
for a helpful script to do that.
** Changing the default profile (e.g. for GUI editors)
Where it is not possible to use the =--with-profile= flag, the default profile
can be set using a =~/.emacs-profile= file.
If your =~/.emacs-profiles.el= file contains the following:
#+BEGIN_SRC emacs-lisp
(("default" . ((user-emacs-directory . "~/.emacs.d")))
("spacemacs" . ((user-emacs-directory . "~/spacemacs")
("prelude" . ((user-emacs-directory . "~/prelude"))))
#+END_SRC
you can create a file called =~/.emacs-profile=, containing the name of the
profile you'd like to be used when none is given on the command line:
#+BEGIN_SRC shell
$ echo 'spacemacs' > ~/.emacs-profile
#+END_SRC
This will set the default profile to be the "spacemacs" profile, instead of
"default". You can change the default by simply changing the contents of this
file:
#+BEGIN_SRC shell
$ echo 'prelude' > ~/.emacs-profile
#+END_SRC
If this file doesn't exist, then "default" will be used, as before.
** Spacemacs
Spacemacs is typically installed by cloning the Spacemacs repo to =~/.emacs.d=,