Sharing init.el between several different Emacsen

Being just a beginning Emacs user, I have to restart Emacs regularly because I messed up my configuration. I also like to use ERC, which would be a pain to restart all the time. Solution: run more then one version of Emacs (something I heard John Wiegley does as well, that’s where I got the idea).

Unless you build your own Emacs with custom settings (which I have no ide how to do), all your Emacsen will use ~/.emacs.d/init.d. How to differentiate between all your different versions of Emacs?

The variable command-line-args contains the filename of your current Emacs. On OSX you can get the application name using:

(setq emacspath (nth 2 (split-string (car command-line-args) "/")))   

By the way, this has nothing to do with argv command line arguments. If you want to run shell scripts using Emacs, for that see Getting Command Line arguments on ErgoEmacs.

The relevant part of my init.d:

;;get OSX application name
(setq emacspath (nth 2 (split-string (car command-line-args) "/")))

(when (string= emacspath "")
(when (string= emacspath "")
(when (string= emacspath "")

In this way I can use for my regular editing, use Aquamacs for testing (and writing blog-posts), and for irc.

And in case you’re wondering, why don’t I just run the same version of Emacs from the command-line? Two reasons: Then all the instances have the same icon, which makes switching confusing. And second, copy/paste does not work if I start Emacs like that. Haven’t figured out why, yet.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s