If you're new to emacs, check out this introductory tutorial!
~/.emacs
or ~/.emacs.d
if they exist. (Windows users, your
emacs files will probably live in
C:\Users\your_user_name\AppData\Roaming\
. So, for example, you
would delete C:\Users\jason\AppData\Roaming\.emacs.d
.) This is
where Emacs looks for configuration files, and deleting these files
and directories will ensure that you start with a clean slate.emacs-for-clojure-book1
. Run mv path/to/emacs-for-clojure-book1 ~/.emacs.d
.Then open Emacs. The first time you start, it will take a few minutes, because it needs to download and install around fifty packages. You will see some warnings pop up, but they are only style suggestions for the packages being loaded.
Since you're working in Clojure, we assume you have it and its prerequisites installed (see this guide for those instructions). Additionally, you're likely to want to have Leiningen installed, since many many projects use it for running builds, tests, and tasks.
To support specific features of this emacs configuration, there are three more prerequisites:
M-x all-the-icons-install-fonts
. You will only
need to do this once.One of the capabilities that comes in very handy is searching for some text
across all the files within your project. You can use git for that with the following
command: M-x counsel-git-grep
. This works just fine, with the caveat that it
must be in a directory version-controlled with git. There are quite a few
alternative search utilities, but you'll have to install them separately. In
practice, you'll probably settle on one you like and use it exclusively. Here
are the links, along with the emacs command to invoke each:
M-x counsel-ack
M-x counsel-ag
M-x counsel-pt
M-x counsel-rg
This will allow you to edit Clojure files with syntax-aware highlighting and structural editing via paredit, which means it will keep all your delimiters for nested forms balanced (think parens, square brackets, and curly braces). Check out this animated guide to paredit. It's one of those things that seems strange at first, but once you get used to it, you won't want to edit Clojure without it!
Other excellent capabilities you'll want to know about include:
Each package we use gets updated by its authors, at whatever cadence works for them. It's a good idea to stay up-to-date, to get improvements and bug fixes. It's analogous to keeping the software up-to-date in your operating system.
When you run M-x list-packages
it refreshes the cache of all the package
repositories, and then tells you in the status line whether there are any
updates to install. Press U
to mark all upgradeable packages for installation,
and then press x
to execute the installation. You will be prompted to confirm,
and when you press y
the package updates will be installed. Press q
to exit
the package list when it's finished.
If you ever get curious to look, you can find all the installed packages in ~/.emacs.d/elpa
.
I've tried to separate everything logically and document the purpose
of every line. init.el
acts as a kind of table of
contents. It's a good idea to eventually go through init.el
and the
files under the customizations
directory so that you know exactly
what's going on.
Emacs has decent support for CSS, HTML, JS, and many other file types out of the box, but if you want better support, then have a look at my personal emacs config's init.el. It's meant to read as a table of contents. The emacs.d as a whole adds the following:
tagedit
to give you paredit-like functionality when editing htmlIn general, if you want to add support for a language then you should be able to find good instructions for it through Google. Most of the time, you'll just need to install the "x-lang-mode" package for it.