Setting up Emacs for Clojure Programming Within Seconds
This is a short note how you can set up your Emacs editor for programming in Clojure within seconds.
The settings are explained in the Brave Clojure tutorial.
I personally in my Ubuntu Linux home folder created a folder named emacs
to put there all kind of settings for my emacs
. Here, I create a folder for clojure
in this folder and enter:
$ mkdir -p ~/emacs/clojure
$ cd ~/emacs/clojure
Then, I git clone
a folder containing the init.el
file with all necessary settings for clojure programming by:
$ git clone https://github.com/flyingmachine/emacs-for-clojure
And now comes the step and knowledge which took most of the time to find it out:
Usually emacs people do something like
$ mv ~/.emacs.d ~/.emacs.d.orig
$ mv ~/some_settings_folder ~/.emacs.d
And later have to name the renamed folders back. This is quite error prone.
A better solution is to start your emacs by:
$ env HOME=$HOME/emacs/clojure/emacs-for-clojure emacs &
This defines the folder containing the init.el
for emacs as $HOME
for the command emacs &
. The disadvantage however is, if you call system commands from within your script using absolute paths or paths requiring your actual $HOME
.
The advantage however is that you don’t have to rename folders which can mess things up a lot.
Since I want to call emacs for ruby programming by the command cljem
(for cljemacs), I add to my ~/.bashrc
file:
alias cljemacs="env HOME=$HOME/emacs/clojure/emacs-for-clojure emacs &"
alias cljem="cljemacs"
And source
the ~/.bashrc
, and can call my emacs with ruby settings by:
$ cljem
In my particular case, since I have my emacs
locally installed in a conda
envrionment named emacs
, I entered into my ~/.bashrc
:
alias cljemacs="source activate emacs && env HOME=$HOME/emacs/clojure/emacs-for-clojure emacs &"
alias cljem="cljemacs"
This activates first the conda environment by source activate emacs
(or conda activate emacs
, before it calls emacs
with the newly defined $HOME
.
The init.el
file of emacs-for-clojure
takes care of all necessary installations in emacs’ site.