<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matheus Moreira</title>
    <description>The latest articles on Forem by Matheus Moreira (@matheusemm).</description>
    <link>https://forem.com/matheusemm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F344232%2Fea6c6797-6bee-4ac8-b2d8-cfb342345431.jpg</url>
      <title>Forem: Matheus Moreira</title>
      <link>https://forem.com/matheusemm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/matheusemm"/>
    <language>en</language>
    <item>
      <title>Simple Emacs configuration for Clojure development</title>
      <dc:creator>Matheus Moreira</dc:creator>
      <pubDate>Tue, 03 Mar 2020 13:37:23 +0000</pubDate>
      <link>https://forem.com/matheusemm/simple-emacs-configuration-for-clojure-development-11i3</link>
      <guid>https://forem.com/matheusemm/simple-emacs-configuration-for-clojure-development-11i3</guid>
      <description>&lt;p&gt;I suppose that most programmers have, together with their preferred IDE (such as &lt;a href="https://www.jetbrains.com/idea/"&gt;Intellij IDEA&lt;/a&gt;, &lt;a href="https://www.eclipse.org/eclipseide/"&gt;Eclipse&lt;/a&gt; and &lt;a href="https://visualstudio.microsoft.com/"&gt;Visual Studio&lt;/a&gt;), a lighter code editor for smaller coding tasks. I remember using &lt;a href="https://notepad-plus-plus.org/downloads/"&gt;Notepad++&lt;/a&gt;, changing to &lt;a href="https://www.sublimetext.com/"&gt;Sublime Text&lt;/a&gt; at some point, than more recently to &lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt;. My current "light" editor of choice is &lt;a href="https://www.gnu.org/s/emacs/"&gt;Emacs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The main reason for choosing Emacs is that I wanted a great coding experience when developing in &lt;a href="https://clojure.org/"&gt;Clojure&lt;/a&gt;. I tried to use Intellij IDEA with &lt;a href="https://cursive-ide.com/"&gt;Cursive&lt;/a&gt; but even though I am familiar with the IDE (I use it daily to write Java and Kotlin code), it doesn't feel right with Clojure, a heavy weight tool with a slim language... So I resorted to simpler code editors, but never found a setup that was appealing.&lt;/p&gt;

&lt;p&gt;I don't think we can say that Emacs is "light" or "simple". It can be a beast... I tried many times to learn it but the learning curve can be discouraging. Only recently I read a post where the author gave a suggestion that is helping me learn Emacs step by step: &lt;a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/M_002dx.html"&gt;&lt;code&gt;M-x&lt;/code&gt;&lt;/a&gt; is your friend. :-) Learn a few basic keybindings and start using the editor, use &lt;code&gt;M-x&lt;/code&gt; for actions you don't know the binding. With time you'll memorize bindings for actions that you repeteadly use.&lt;/p&gt;

&lt;p&gt;That tip took care of the anxiety I had when using Emacs without knowing my way around it! Time to setup my Clojure development environment and start writing some serious code! Or not... Emacs is a black hole of packages, options, ways of organizing your configuration.&lt;/p&gt;

&lt;p&gt;To simplify things I used the configuration suggested on the book &lt;a href="https://www.braveclojure.com/basic-emacs/"&gt;Clojure for the Brave and True&lt;/a&gt; and tried &lt;a href="https://www.spacemacs.org/"&gt;Spacemacs&lt;/a&gt; with the &lt;a href="https://www.spacemacs.org/layers/+lang/clojure/README.html"&gt;Clojure layer&lt;/a&gt;. The problem is that I am the kind of guy that wants to know &lt;strong&gt;why&lt;/strong&gt; things work the way they work, I wanted to be able to replicate parts of these setups and understand them.&lt;/p&gt;

&lt;p&gt;After a lot of trials, errors and frustrations I finally came up with a initial setup that I am happy with! I think it is good enough for my taste and a small starting point for further customization, and that is why I decided to share it. &lt;a href="https://gist.github.com/matheusemm/d3b216a0369c3af6f4d83549276bacb1/5706bf75f52e3d37d521d3b6eaddeafbf091bd2c"&gt;Check out this gist&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;A quick overview of what this configuration does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adds &lt;a href="https://melpa.org/"&gt;Melpa&lt;/a&gt; as an additional packages source.&lt;/li&gt;
&lt;li&gt;Sets &lt;a href="https://dank.sh/"&gt;Dank Mono&lt;/a&gt; as default font. Change the &lt;code&gt;:family&lt;/code&gt; attribute to your preferred font.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/bbatsov/zenburn-emacs"&gt;zenburn theme&lt;/a&gt;, super nice.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="http://www.dr-qubit.org/undo-tree.html"&gt;undo-tree&lt;/a&gt;, a package that gives visual clues of your changes history. Reading the docs I discovered that Emacs has a very powerful redo/undo system and undo-tree makes full use of it.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/abo-abo/swiper"&gt;ivy&lt;/a&gt;, a completion system. I opted for ivy because it is cider and other packages recommend it.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/nonsequitur/smex"&gt;smex&lt;/a&gt;, a package that improves the use of &lt;code&gt;M-x&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/bbatsov/projectile"&gt;projectile&lt;/a&gt; to help navigate between files in a project.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://magit.vc/"&gt;magit&lt;/a&gt; for Git interaction. You'll be able to do a lot with only two keybindings!&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/purcell/exec-path-from-shell"&gt;exec-path-from-shell&lt;/a&gt;, that is used to set Emacs path from your shell's path (I use it because my current OS is MacOS, I think it is not required for Windows).&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://www.flycheck.org/"&gt;flycheck&lt;/a&gt; and &lt;a href="https://github.com/borkdude/flycheck-clj-kondo"&gt;flycheck-clj-kondo&lt;/a&gt;. Flycheck-clj-kondo is a nice linting and analysis tool for Clojure, highly recommended.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://company-mode.github.io/"&gt;company-mode&lt;/a&gt;, a package that is used for code completion.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/clojure-emacs/clojure-mode"&gt;clojure-mode&lt;/a&gt;, &lt;a href="https://github.com/clojure-emacs/cider"&gt;cider&lt;/a&gt; and &lt;a href="https://github.com/clojure-emacs/clj-refactor.el"&gt;clj-refactor&lt;/a&gt;, the main packages for Clojure development.&lt;/li&gt;
&lt;li&gt;Installs &lt;a href="https://github.com/justbur/emacs-which-key"&gt;which-key&lt;/a&gt;. This makes using &lt;code&gt;M-x&lt;/code&gt; much easier because it presents "next keys" options based on a prefix keybinding. E.g. You press &lt;code&gt;C-c&lt;/code&gt; and it shows further keys that can complete the keybinding. Super nice!&lt;/li&gt;
&lt;li&gt;Performs other simple configurations (under &lt;code&gt;editing&lt;/code&gt;, &lt;code&gt;ui&lt;/code&gt; and &lt;code&gt;misc&lt;/code&gt;). These came mainly from the Clojure from the Brave and True setup.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I recommend that you take some time and read at least a bit of each package's documentation. You'll better understand not only the configuration file but the &lt;strong&gt;capabilities&lt;/strong&gt; that each tool provide. Let me know if this configuration is useful for you and if you have any suggestions on how to improve it.&lt;/p&gt;

&lt;p&gt;Godspeed.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;Cover photo by &lt;a href="https://unsplash.com/@ussamaazam?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Ussama Azam&lt;/a&gt; on &lt;a href="https://unsplash.com/@ussamaazam?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>clojure</category>
      <category>ide</category>
    </item>
  </channel>
</rss>
