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?
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
;;get OSX application name (setq emacspath (nth 2 (split-string (car command-line-args) "/"))) (when (string= emacspath "Emacs.app") (emacsapp) ) (when (string= emacspath "Emacs2.app") (emacsapp-irc) ) (when (string= emacspath "Aquamacs.app") (aquamacs) )
In this way I can use Emacs.app for my regular editing, use Aquamacs for testing (and writing blog-posts), and Emacs2.app 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.