Emacs & Lisp ... a match made in heaven

2020-04-12 Software Engineering Tips & Tricks Nerdy Emacs Lisp

At community (as everywhere these days) we are not using one programming language, we are using a set of programming languages, means for one week I find myself writing a lot of elixir, the next week I write go, the week afterwards I need to fix some of our terraform configurations and on the weekend I am fixing a bug in a scala project.

What you need to survive (and stay sane) in such polyglot software engineering environment is a an IDE that is highly configurable and highly extensible (so that you get all the good stuff (auto-complete, code-navigation, on-the-fly syntax checking, …).

For me that IDE is (obviously :)) Emacs (Emacs makes all computers special!!!).

There are lots of good frameworks and solutions that turn Emacs into an IDE for the programming language of your choice (e.g. intero (for haskell), alchemist (for elixir), ensime (for scala), …), but lately I have ditched these for Language Server Based (LSP) based configurations.

Now I only need to memorize one set of key-strokes.

But the real killer is (as always) that even if something is not really working (yet) there is a good chance you can make work (with a couple of lines of elisp code).

In that context I invested the Easter weekend to refresh my elisp skills and my elisp configuration.

I reviewed all available tutorials and have to say that the original GNU/Emacs elisp documentation is still very good. Working through it will give you a good start into what you need to know to get the job done.

Now the only other thing you need is a working IDE to write emacs-elisp code. Fortunately Emacs comes with good support out of the box. On top of it I suggest …

  • to install the emacs lisp source code (run sudo apt install emacs26-el). With that you can use the normal code navigation M-./M-, to jump around in your code and also into the implementation of the elisp functions
  • to use company-mode to auto-complete symbols
  • to use flycheck to do on the fly code checking (but disable the checking the doc to get rid of the warning about the missing headers/footers)
  • to use yasnippet to get a couple of good snippets to save you some typing
  • to use elisp-format to format the code before saving it
  • and last but not least: use C-x C-e to evaluate expression, while you build the code in an elisp file or use M-x ielm to develop the code with an interpreter.

Have fun and lisp long and prosper