• Stars
    star
    644
  • Rank 69,893 (Top 2 %)
  • Language
    Emacs Lisp
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Emacs profile switcher
     ___           ___           ___           ___           ___           ___           ___
    /  /\         /__/\         /  /\         /__/\         /  /\         /  /\         /  /\
   /  /:/         \  \:\       /  /:/_       |  |::\       /  /::\       /  /:/        /  /:/_
  /  /:/           \__\:\     /  /:/ /\      |  |:|:\     /  /:/\:\     /  /:/        /  /:/ /\
 /  /:/  ___   ___ /  /::\   /  /:/ /:/_   __|__|:|\:\   /  /:/~/::\   /  /:/  ___   /  /:/ /::\
/__/:/  /  /\ /__/\  /:/\:\ /__/:/ /:/ /\ /__/::::| \:\ /__/:/ /:/\:\ /__/:/  /  /\ /__/:/ /:/\:\
\  \:\ /  /:/ \  \:\/:/__\/ \  \:\/:/ /:/ \  \:\~~\__\/ \  \:\/:/__\/ \  \:\ /  /:/ \  \:\/:/~/:/
 \  \:\  /:/   \  \::/       \  \::/ /:/   \  \:\        \  \::/       \  \:\  /:/   \  \1.0 /:/
  \  \:\/:/     \  \:\        \  \:\/:/     \  \:\        \  \:\        \  \:\/:/     \__\/ /:/
   \  \::/       \  \:\        \  \::/       \  \:\        \  \:\        \  \::/        /__/:/
    \__\/         \__\/         \__\/         \__\/         \__\/         \__\/         \__\/



                                 ... ........,**********,...
                          .%*....       .,/(((#//(//*,*,,,*.,#%&(,,/(##.
                            %/..                          ,,  ,*,*/(%%.
                             %/*.                         .. .,,.,#%&
                              &(,.                       .. ....((%&.
                               ,#,.                     ..  ...*/#%
                                .#,..                   .  ..,/(%#
                                 .#,.                  ..  .,,(#%
                                   #*,.               .. .,,.(%(
                                  ***//((((((((//****,,**//,/  .
                                  ///((#%%%%%%%##(///////*./,,,,
                                   /#(##%%%%%%%%%##(((//*.(**,*
                                    .(/###%%%%%%##(((/// (/,,,
                                     */(##%%%%##(((/((/(/*.
                                     *((###%%%%%%%%%%%&&(*..
                                     .((###%%%%%%%%##((####/,//
                                     **//((###(###%%%#%%#&/%(%#(.
                                    **//(((((((/((##%#%#/%##%*/.
                                   ***///(/(((/////((((%**../..   //
                                  **//(((###(((((//////%/***(,..   /&
                                  ,####%%%%%%%%###((//(%,*/((/**    #*
                                  ./,,                *%..,..*&%    ,#
                                 ,(,.                 *%   .../%&    @
                                *#,.                  *%,  ....,%&   &.
                               (/,                   .&&&%/   ..,%&  %,
                              %/,                        ((.   .,,%&%%/,
                             #*.                                .*(%%%@,
                            #,.                                 ..,,%&.,
                           ,/....                              .... ,%%
                           %,,.....                  ......   ,* ....#&.
                           #,,,,..      .....................  ....,/#%*
                           #*,,*.......  ...................,,,****/(%%,
                           ,(*/**,.......................,,,,,**//###%#
                            /#/(((/**,...  .............,,,,/(##%%%##@
                             /.*/((/,,,,,.,/(###########(/(((((#%%#&&
                               ,(#(/,,.......,,,,,,,,/(///(#%%%%#
                                ./(*,..                  ..,*((#&/
                                    ...,..,..,/###(//(#(/*,.. .

Chemacs

This is the “classic” version of Chemacs, which goes into ~/.emacs, and which does not support early-init.el. We generally recommend using plexus/chemacs2 instead.

Contributions should generally go towards Chemacs2. They can be backported later if there is interest in that.

Chemacs is an Emacs profile switcher, it makes it easy to run multiple Emacs configurations side by side.

Think of it as a bootloader for Emacs.

Rationale

Emacs configuration is either kept in a ~/.emacs file or, more commonly, in a ~/.emacs.d directory. These paths are hard-coded. If you want to try out someone else’s configuration, or run different distributions like Prelude or Spacemacs, then you either need to swap out ~/.emacs.d, or run Emacs with a different $HOME directory set.

This last approach is quite common, but has some real drawbacks, since now packages will no longer know where your actual home directory is.

All of these makes trying out different Emacs configurations and distributions needlessly cumbersome.

Various approaches to solving this have been floated over the years. There’s an Emacs patch around that adds an extra command line option, and various examples of how to add a command line option in userspace from Emacs Lisp.

Chemacs tries to implement this idea in a user-friendly way, taking care of the various edge cases and use cases that come up.

Installation

Clone the Git repository, and run install.sh

$ git clone https://github.com/plexus/chemacs.git
$ cd chemacs
$ ./install.sh
OK      Creating symlink ~/.emacs -> /home/arne/chemacs/.emacs

The install script will symlink ~/.emacs to the Chemacs script. If you already have a ~/.emacs you need to move it out of the way first

$ ./install.sh
WARN    chemacs can't be installed, ~/.emacs is in the way

By symlinking you can easily update Chemacs with a git pull. Chemacs is not available on ELPA/MELPA because its special position in the Emacs boot process would cause a chicken and egg problem.

There’s a similar script for Windows called install.ps1.

$ git clone https://github.com/plexus/chemacs.git
$ cd chemacs
$ .\install.ps1
OK copying file to ~/.emacs

The Windows script copies the ~/.emacs file rather than symlinking it, as symlinks in Windows require elevated privileges. To update the file, run install.ps1 a second time, if necessary - it uses hashing to detect changes and prompts for conformation before overwriting

$ .\install.ps1
WARN content is different between C:\Users\Me\.emacs and C:\Users\Me\repos\chemacs\.emacs
WARN chemacs may already be installed OR something else may be in the way
Do you want to overwrite C:\Users\Me\.emacs?: y
OK updated chemacs files successfully.

Usage

Chemacs adds an extra command line option to Emacs, --with-profile. Profiles are configured in ~/.emacs-profiles.el. If this file does not exist Chemacs will create it with a default profile pointing at ~/.emacs.d.

If no profile is given at the command line then the default profile is used, so if you currently have your emacs configuration in ~/.emacs.d then Chemacs will, by default, use your existing configuration.

$ emacs --with-profile my-profile

.emacs-profiles.el

This file contains an association list, with the keys/cars being the profile names, and the values/cdrs their configuration.

The main thing to configure is the user-emacs-directory

(("default" . ((user-emacs-directory . "~/.emacs.d")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs"))))

Chemacs will set this to be the user-emacs-directory in use, and load init.el from that directory.

Other things you can configure

  • custom-file : The file where Customize stores its customizations. If this isn’t configured, and the custom-file variable is still unset after loading the profile’s init.el, then this will get set to the profile’s init.el
  • server-name : Sets the server-name variable, so you can distinguish multiple instances with emacsclient -s <server-name>.
  • env An association list of environment variables. These will get set before loading the profile, so they can influence the initialization, and they are visible to any subprocesses spawned from Emacs.
  • straight-p Enable the Straight functional package manager.

Store .emacs-profiles.el together with your dotfiles. If you’re not yet keeping a version controlled directory of dotfiles, then check out 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:

(("default" . ((user-emacs-directory . "~/.emacs.d")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs")))
 ("prelude" . ((user-emacs-directory . "~/prelude"))))

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:

$ echo 'spacemacs' > ~/.emacs-profile

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:

$ echo 'prelude' > ~/.emacs-profile

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, and doing extra customization from ~/.spacemacs or ~/.spacemacs.d/init.el. This makes it tedious to switch between version of Spacemacs, or between different Spacemacs configurations.

With Chemacs you can point your user-emacs-directory to wherever you have Spacemacs installed, and use the SPACEMACSDIR environment variable to point at a directory containing `init.el` (or creating it on first run) with customizations that are applied on top of the base install.

(("spacemacs" . ((user-emacs-directory . "~/spacemacs")
                 (env . (("SPACEMACSDIR" . "~/.spacemacs.d")))))

 ("spacemacs-develop" . ((user-emacs-directory . "~/spacemacs/develop")
                        (env . (("SPACEMACSDIR" . "~/.spacemacs.d")))))

 ("new-config" . ((user-emacs-directory . "~/spacemacs/develop")
                  (env . (("SPACEMACSDIR" . "~/my-spacemacs-config"))))))

DOOM emacs

You can add an entry similar to the following to your .emacs-profiles.el

In the following snippet ~/doom-emacs is where you have cloned doom emacs.

(Depending on when you read this) DOOMDIR support is only in develop branch of doom emacs. Check commit history of master branch of doom emacs

("doom" . ((user-emacs-directory . "~/doom-emacs")
           (env . (("DOOMDIR" . "~/doom-config")))))

Please refer to this discussion for details.

LICENSE

Copyright © Arne Brasseur 2018-2020

Distributed under the terms of the GPL v3.

More Repositories

1

chestnut

Application template for Clojure + ClojureScript web apps
Clojure
1,317
star
2

chemacs2

Emacs version switcher, improved
Emacs Lisp
649
star
3

yaks

Ruby library for building hypermedia APIs
Ruby
236
star
4

a.el

Emacs Lisp functions for dealing with association lists and hash tables. Inspired by Clojure.
Emacs Lisp
83
star
5

html-to-hiccup

Emacs package that turns HTML into Hiccup syntax
Emacs Lisp
65
star
6

hexp

Ruby virtual DOM for HTML
Ruby
57
star
7

ting

Parse/Generate pinyin, bopomofo, wade-giles and more using Ruby
Ruby
49
star
8

typecheck

Ruby
45
star
9

chruby.el

Emacs support for the Chruby version switcher for Ruby
Emacs Lisp
35
star
10

macros

Ruby
32
star
11

autodoc

Automate the publishing of generated docs
Shell
26
star
12

analects

Public datasets on the Chinese language, accessible from Ruby
Ruby
23
star
13

dotfiles

Shell
20
star
14

slippery

Because Slippery slides are the best slides.
CSS
19
star
15

unrepl.el

Clojure
16
star
16

gas-of-life

JavaScript
14
star
17

asset_packer

Ruby
11
star
18

.emacs.d

My Emacs configuration
Emacs Lisp
11
star
19

tracer-gui

Trace Ring requests and inspect them in a GUI
Clojure
11
star
20

integreat

Clojure
10
star
21

cljs-test-example

Clojure
7
star
22

plexmacs

Emacs Lisp
7
star
23

kramberry

Kramdown-style Markdown parser for Clojure/script
HTML
7
star
24

emacs-clojure-utils

Emacs Lisp
6
star
25

svg-slides

Turn an SVG file into a presentation.
JavaScript
6
star
26

tablizer

Format HTML tables as text. Demo Clojure CLI tools.
Clojure
6
star
27

xterm-sci

Clojure
6
star
28

fzip

Ruby
5
star
29

hillchart

Clojure
5
star
30

syna.esth.etic

Glitch images by applying sound effects.
Clojure
5
star
31

analects-data

Ruby
5
star
32

ruby_lisp

Ruby
4
star
33

ansible_playbooks

Server configuration, in particular for the Clojurians Slack Log site
Shell
4
star
34

attendomat

An extension to Google Sheets to help with the managing of attendees for ClojureBridge Berlin.
JavaScript
4
star
35

fp

Ruby
3
star
36

give-a-safer-web

3
star
37

seed

Clojure
3
star
38

my-reagent-project

Clojure
3
star
39

annikki

Annikki web-app, logbook for Anki
Python
3
star
40

rubydataspec

Ruby
3
star
41

hoc-schedule

Clojure
2
star
42

hellocljs

Clojure
2
star
43

mtgcollection

Clojure
2
star
44

cljs-timezone-wheel

ClojureScript/Reagent port of the very cool Timezone Wheel by @dayitastic.
Clojure
2
star
45

fern

Clojure
2
star
46

active_merchant-realex3ds

Ruby
2
star
47

walkclj

Navigate Clojure parse trees from parseclj as s-expressions
Emacs Lisp
2
star
48

slack-archivist

CSS
2
star
49

clojars-stats

Download statistics from Clojars by day
2
star
50

alsa-seq-ruby

ALSA sequencer API through Ruby FFI
Ruby
2
star
51

inkscape-slides

Create slides from an Inkscape SVG
JavaScript
2
star
52

chatty

Clojure
2
star
53

choes

Switch between the many colors of Shoes
Shell
2
star
54

fn

Ruby
2
star
55

SAM

HTML
1
star
56

mazecodes

Clojure
1
star
57

rups

Ruby
1
star
58

sesame

Clojure
1
star
59

togl

Flexible Ruby feature flag library
Ruby
1
star
60

cauldron

Clojure
1
star
61

finn-chamber

Clojure
1
star
62

pie-a-la-mode

Clojure
1
star
63

yakports

JavaScript
1
star
64

proxi

Ruby
1
star
65

ember-hypermedia

CoffeeScript
1
star
66

chef-phppgadmin

Chef cookbook for PhpPgAdmin
Ruby
1
star
67

assetlog

Demo app for Adobe I/O Events webhooks
JavaScript
1
star
68

ChengyuDaily

Java
1
star
69

herbie

Music player based on Ruby, Ncurses and Gstreamer
Ruby
1
star
70

reagent-ajax-json-example

Clojure
1
star
71

attribs

Ruby
1
star
72

ruby-code-of-conduct

JavaScript
1
star
73

beadicious

Clojure
1
star
74

hexp-blog

Ruby
1
star
75

advent-of-code

Clojure
1
star
76

filebak

Clojure
1
star
77

secretsanta

Clojure
1
star
78

plexmacs-elpa

See plexus/plexmacs
Emacs Lisp
1
star
79

sesame-seed

Clojure
1
star