{"id":3220,"date":"2016-06-14T08:19:58","date_gmt":"2016-06-14T12:19:58","guid":{"rendered":"http:\/\/fgiasson.com\/blog\/?p=3220"},"modified":"2016-11-17T13:48:05","modified_gmt":"2016-11-17T18:48:05","slug":"my-optimal-gnu-emacs-settings-for-developing-clojure-revised","status":"publish","type":"post","link":"https:\/\/fgiasson.com\/blog\/index.php\/2016\/06\/14\/my-optimal-gnu-emacs-settings-for-developing-clojure-revised\/","title":{"rendered":"My Optimal GNU Emacs Settings for Developing Clojure (Revised)"},"content":{"rendered":"<p>It has been 2 years since I <a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2014\/05\/22\/my-optimal-gnu-emacs-settings-for-developing-clojure-so-far\/\">last revised my optimal GNU Emacs settings for developing Clojure<\/a>. Since then, many things have changed in the Cider\/Emacs ecosystem and it is why a revision of these settings is now warranted.<\/p>\n<p>There is one set of settings that I will <b>not<\/b> discuss in this blog post, and these are all the settings related to Literate Programming using Org-mode. Since much needs to be said about these, they will be the topic of a subsequent blog post that will focus exclusively on that matter.<\/p>\n<p><!--more--><\/p>\n<div id=\"outline-container-orgd23132c\" class=\"outline-2\">\n<h3 id=\"orgd23132c\">GNU Emacs<\/h3>\n<div id=\"text-orgd23132c\" class=\"outline-text-2\">\n<p>GNU Emacs is an awesome programming interface. It is said to be the programmable programming interface. It is terrific but it comes at a price: steep learning curve and much time spent testing and configuring useful packages. However, once these hurdles are passed, the sun starts to shine and a joyful journey begins.<\/p>\n<p>I am personally developing on Windows 10, but these steps should be platform agnostic. You only have to download and install the latest <a href=\"http:\/\/www.gnu.org\/software\/emacs\/#Obtaining\">GNU Emacs 24 version<\/a>.<\/p>\n<p>The first thing you have to do is to locate your <code>.emacs<\/code> file. All the configurations I am defining in this blog post goes into that file.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-org8789dbd\" class=\"outline-2\">\n<h3 id=\"org8789dbd\">Packages<\/h3>\n<div id=\"text-org8789dbd\" class=\"outline-text-2\">\n<p>Once Emacs is installed, the first thing you have to do is to install all the packages that are required to develop in Clojure or that will make your life easier for handling the code. The packages that you have to install are:<\/p>\n<ol class=\"org-ol\">\n<li><a href=\"https:\/\/github.com\/clojure-emacs\/cider\">cider<\/a>\n<ul class=\"org-ul\">\n<li>Clojure Integrated Development Environment and REPL. This is the actual Clojure IDE. It includes everything to work with Clojure in Emacs. It runs the REPL, it has a debugger, etc.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"http:\/\/company-mode.github.io\/\">company<\/a>\n<ul class=\"org-ul\">\n<li>In-buffer auto-completion framework. This is now the best integrated auto-complete for Cider.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/github.com\/oneKelvinSmith\/monokai-emacs\">monokai-theme<\/a>\n<ul class=\"org-ul\">\n<li>This is a new theme that is pleasant to look at and that works pretty well with Clojure code.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/github.com\/jlr\/rainbow-delimiters\">rainbow-delimiters<\/a>\n<ul class=\"org-ul\">\n<li>Highlight nested parenthesis, brackets, braces a different color at each depth \u00e2\u20ac\u201c This is really handy to visually see where you are with your parenthesis. An essential to have (in my view).<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/github.com\/nschum\/highlight-symbol.el\">highlight-symbol<\/a>\n<ul class=\"org-ul\">\n<li>Highlight all occurrences of a symbol in a buffer. This is really handy to find occurrences of variables, or function calls, etc.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/github.com\/syohex\/emacs-helm-ag\">heml-ag<\/a>\n<ul class=\"org-ul\">\n<li>High performance file system search function. This is essential to find all occurrences of a <code>[regex]<\/code> pattern within local files.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Before installing them, we have to tell Emacs which package repositories it has access to so as to find these packages. At the top of your <code>.emacs<\/code> file, put:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Define packages archives repositories<\/span>\n<span style=\"color: #a1efe4;\">(<\/span><span style=\"color: #f92672;\">require<\/span> '<span style=\"color: #ae81ff;\">package<\/span><span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #a1efe4;\">(<\/span>add-to-list 'package-archives\n  '<span style=\"color: #e6db74;\">(<\/span><span style=\"color: #e6db74;\">\"melpa-stable\"<\/span> . <span style=\"color: #e6db74;\">\"http:\/\/melpa-stable.milkbox.net\/packages\/\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #a1efe4;\">(<\/span>add-to-list 'package-archives \n  '<span style=\"color: #e6db74;\">(<\/span><span style=\"color: #e6db74;\">\"marmalade\"<\/span> . <span style=\"color: #e6db74;\">\"https:\/\/marmalade-repo.org\/packages\/\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>  \n\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Initialize all the ELPA packages (what is installed using the packages commands)    <\/span>\n<span style=\"color: #a1efe4;\">(<\/span>package-initialize<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<p>If you are editing your <code>.emacs<\/code> file directly into Emacs, and you can re-evaluate the settings file using Emacs, then by moving the cursor at each top-level expression end (after closing parenthesis) and press <code>C-x C-e<\/code>. However, it may be faster just to close and restart Emacs to take the new settings into account. You can use any of these methods for the following set of settings changes.<\/p>\n<p>Before changing any more settings, we will first install all the required packages using the following sequence of commands:<\/p>\n<pre class=\"example\">M-x package-install [RET] cider [RET]\nM-x package-install [RET] company [RET]\nM-x package-install [RET] monokai-theme [RET]\nM-x package-install [RET] rainbow-delimiters]] [RET]\nM-x package-install [RET] highlight-symbol [RET]\nM-x package-install [RET] helm-ag [RET]\n<\/pre>\n<p>Additionally, you could have used <code>M-x package-list-packages<\/code>, then move your cursor in the buffer to the packages\u00e2\u20ac\u2122 line. Then press <code>i<\/code> (for install) and once all the packages are selected, you could have press <code>x<\/code> (execute) to install all the packages all at once.<\/p>\n<p>In the list of commands above, <code>M-x<\/code> is the &#8220;meta-key&#8221; normally bound to the left Alt key on your keyboard. So, <code>M-x<\/code> usually means Alt-x.<\/p>\n<p>Now that all the packages are installed, let\u00e2\u20ac\u2122s take a look at how we should configure them.<\/p>\n<h3>Installing Leiningen or Boot<\/h3>\n<p>An important piece of software to install is a build tool for Clojure. The two most popular choices are <a href=\"http:\/\/leiningen.org\/\">Leiningen<\/a> and <a href=\"http:\/\/boot-clj.com\/\">Boot<\/a>.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgb34df7\" class=\"outline-2\">\n<h3 id=\"orgb34df7\">Installing Platinum Searcher<\/h3>\n<div id=\"text-orgb34df7\" class=\"outline-text-2\">\n<p>For the <code>helm-ag<\/code> package, you will have to install the <a href=\"https:\/\/github.com\/monochromegane\/the_platinum_searcher\">Platinum Searcher<\/a> application. Installing it on Windows is quite simple. Just download the proper package, and extract the <code>pt.ex<\/code> file somewhere on your computer (let&#8217;s say in <code>c:\/platinum-searcher<\/code>). We will configure it later.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgef0808d\" class=\"outline-2\">\n<h3 id=\"orgef0808d\">Configuring Keyboard<\/h3>\n<div id=\"text-orgef0808d\" class=\"outline-text-2\">\n<p>If you are using an English\/US keyboard, you can skip this section. Since I use a French Canadian layout (On an English\/US Das Keyboard!), I had multiple issues to have my keys working since all the binding changed in Emacs. To solve this problem, I simply had to define that language configuration option. Then I had to start using the right Alt key of my keyboard to write my brackets, curly brackets, etc:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Enable a Canadian French keyboard layout<\/span>\n<span style=\"color: #a1efe4;\">(<\/span><span style=\"color: #f92672;\">require<\/span> '<span style=\"color: #ae81ff;\">iso-transl<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org9a115dd\" class=\"outline-2\">\n<h3 id=\"org9a115dd\">Configure Text Editor<\/h3>\n<div id=\"text-org9a115dd\" class=\"outline-text-2\">\n<p>There are a few settings we have to specify related to the Emacs text editor. We want to send the comment columns of Clojure comments to column 70 and we want to force the usage of <code>UTF-8<\/code> as the default encoding. Finally we want to start emacs maximized in Windows:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">UTF-8 as default encoding<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>set-language-environment <span style=\"color: #e6db74;\">\"UTF-8\"<\/span><span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Set the default comment column to 70<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>setq-default comment-column 70<span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Every time a window is started, make sure it get maximized<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-to-list 'default-frame-alist '<span style=\"color: #e6db74;\">(<\/span>fullscreen . maximized<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgbe42430\" class=\"outline-2\">\n<h3 id=\"orgbe42430\">Configuring Fonts<\/h3>\n<div id=\"text-orgbe42430\" class=\"outline-text-2\">\n<p>There is a new wonderful coding font that I discovered recently called the <a href=\"http:\/\/input.fontbureau.com\/\">Input (Font for Code)<\/a>. This is a really neat font that works particularly well. You just have to go to their site, define the characteristics you want for it, download and install it locally.<\/p>\n<p>Once it is installed on your system, configure it that way in <code>.emacs<\/code>:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Use the Input font size 12<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>set-default-font <span style=\"color: #e6db74;\">\"Input-12\"<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgd45d532\" class=\"outline-2\">\n<h3 id=\"orgd45d532\">Cider<\/h3>\n<div id=\"text-orgd45d532\" class=\"outline-text-2\">\n<p>Now that the general Emacs settings are configured, let&#8217;s focus on Cider. We want to make sure that we enter in cider mode when entering in Clojure major mode. Then we have to specify that we want to use company-mode as the auto-completion framework and finally we want to specify that when we enter via the client in Cider, that we want a new line <b>and<\/b> to indent that new line according to where we are in the code.<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Enter cider mode when entering the clojure major mode<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-hook 'clojure-mode-hook 'cider-mode<span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Turn on auto-completion with Company-Mode<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-company-mode<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-hook 'cider-repl-mode-hook #'company-mode<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-hook 'cider-mode-hook #'company-mode<span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Replace return key with newline-and-indent when in cider mode.<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-hook 'cider-mode-hook '<span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">lambda<\/span> <span style=\"color: #66d9ef;\">()<\/span> <span style=\"color: #66d9ef;\">(<\/span>local-set-key <span style=\"color: #fd971f;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"RET\"<\/span><span style=\"color: #fd971f;\">)<\/span> 'newline-and-indent<span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgaa10524\" class=\"outline-2\">\n<h3 id=\"orgaa10524\">Show Parenthesis Mode<\/h3>\n<div id=\"text-orgaa10524\" class=\"outline-text-2\">\n<p>Another handy feature is to enable, by default, the show-parent-mode configuration option. That way, every time the cursor points to a parenthesis, the parent parenthesis will be highlighted into the user interface. This is an essential must-have with Par Edit:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Show parenthesis mode<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>show-paren-mode 1<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org9d42967\" class=\"outline-2\">\n<h3 id=\"org9d42967\">Rainbow Delimiters<\/h3>\n<div id=\"text-org9d42967\" class=\"outline-text-2\">\n<p>Another essential package to have helps you out in maintaining these parenthesis. The rainbow delimiters will change the color of the parenthesis depending on how &#8220;deep&#8221; they are into the structure. Another essential visual cue:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">rainbow delimiters<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-hook 'prog-mode-hook #'rainbow-delimiters-mode<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org6274975\" class=\"outline-2\">\n<h3 id=\"org6274975\">Monokai Theme<\/h3>\n<div id=\"text-org6274975\" class=\"outline-text-2\">\n<p>The Monokai theme is joyful and really fun to work Clojure code with. This is the current theme I use.<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Set theme &amp; font size<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>add-to-list 'custom-theme-load-path <span style=\"color: #e6db74;\">\"~\/.emacs.d\/lib\/monokai-theme\"<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>load-theme 'monokai t<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<p>There is another configuration we need to do which is to make sure that the theme&#8217;s colors are used by <code>company-mode<\/code> such that the popup contextual menus are properly themed:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;;<\/span>\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Update the color of the company-mode context menu to fit the Monokai theme<\/span>\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">@source: https:\/\/github.com\/search?q=deftheme+company-tooltip&amp;type=Code<\/span>\n<span style=\"color: #75715e; font-style: italic;\">;;<\/span>\n<span style=\"color: #a1efe4;\">(<\/span><span style=\"color: #f92672;\">deftheme<\/span> <span style=\"color: #66d9ef; font-style: italic;\">monokai-overrides<\/span><span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #a1efe4;\">(<\/span><span style=\"color: #f92672;\">let<\/span> <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #66d9ef;\">(<\/span>class '<span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>class color<span style=\"color: #a6e22e;\">)<\/span> <span style=\"color: #a6e22e;\">(<\/span>min-colors 257<span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n      <span style=\"color: #66d9ef;\">(<\/span>terminal-class '<span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>class color<span style=\"color: #a6e22e;\">)<\/span> <span style=\"color: #a6e22e;\">(<\/span>min-colors 89<span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n\n  <span style=\"color: #e6db74;\">(<\/span>custom-theme-set-faces\n   'monokai-overrides\n\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Linum and mode-line improvements (only in sRGB).<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>linum\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>,class <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#75715E\"<\/span>\n              <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#49483E\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>mode-line-inactive\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>,class <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:box<\/span> <span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #f92672;\">:line-width<\/span> 1 <span style=\"color: #f92672;\">:color<\/span> <span style=\"color: #e6db74;\">\"#2c2d26\"<\/span> <span style=\"color: #f92672;\">:style<\/span> nil<span style=\"color: #66d9ef;\">)<\/span>\n                    <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#2c2d26\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Custom region colouring.<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>region\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>,class <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#75715E\"<\/span>\n              <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#49483E\"<\/span><span style=\"color: #a6e22e;\">)<\/span>\n      <span style=\"color: #a6e22e;\">(<\/span>,terminal-class <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#1B1E1C\"<\/span>\n                       <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#8B8878\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Additional modes<\/span>\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Company tweaks.<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>company-tooltip-common\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#F8F8F0\"<\/span>\n         <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#474747\"<\/span>\n         <span style=\"color: #f92672;\">:underline<\/span> t<span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>company-template-field\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:inherit<\/span> company-tooltip\n         <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#C2A1FF\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>company-tooltip-selection\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#349B8D\"<\/span>\n         <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#BBF7EF\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>company-tooltip-common-selection\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#F8F8F0\"<\/span>\n         <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#474747\"<\/span>\n         <span style=\"color: #f92672;\">:underline<\/span> t<span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>company-scrollbar-fg\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#BBF7EF\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>company-tooltip-annotation\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:inherit<\/span> company-tooltip\n         <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#C2A1FF\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Popup menu tweaks.<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>popup-menu-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#A1EFE4\"<\/span>\n         <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#49483E\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>popup-menu-selection-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #f92672;\">:background<\/span> <span style=\"color: #e6db74;\">\"#349B8D\"<\/span>\n         <span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#BBF7EF\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Circe<\/span>\n   `<span style=\"color: #66d9ef;\">(<\/span>circe-prompt-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#C2A1FF\"<\/span> <span style=\"color: #f92672;\">:weight<\/span> bold<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>circe-server-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#75715E\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>circe-highlight-nick-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#AE81FF\"<\/span> <span style=\"color: #f92672;\">:weight<\/span> bold<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>circe-my-message-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:foreground<\/span> <span style=\"color: #e6db74;\">\"#E6DB74\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n\n   `<span style=\"color: #66d9ef;\">(<\/span>circe-originator-face\n     <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>t <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">:weight<\/span> bold<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orga39459\" class=\"outline-2\">\n<h3 id=\"orga39459\">helm-ag<\/h3>\n<div id=\"text-orga39459\" class=\"outline-text-2\">\n<p>It is essential to have a local file system search functionality. This is what <code>helm-ag<\/code> provides. I configured it to use the Platinum Searcher. I also bound it to the key <code>M-s<\/code> for easy invocation:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Configure helm-ag<\/span>\n<span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">Make sure to have Platinum Searcher installed: https:\/\/github.com\/monochromegane\/the_platinum_searcher<\/span>\n\n<span style=\"color: #a1efe4;\">(<\/span>custom-set-variables\n '<span style=\"color: #e6db74;\">(<\/span>helm-ag-base-command <span style=\"color: #e6db74;\">\"C:\/platinum-searcher\/pt -e --nocolor --nogroup\"<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span>\n\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"M-s\"<\/span><span style=\"color: #e6db74;\">)<\/span> 'helm-do-ag<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org54b4fe1\" class=\"outline-2\">\n<h3 id=\"org54b4fe1\">Syntax Highlighting<\/h3>\n<div id=\"text-org54b4fe1\" class=\"outline-text-2\">\n<p>It is often handy to be able to highlight symbols within a buffer. I use <code>highlight-symbol<\/code> for that purpose but I re-mapped its functionalities to keys more meaningful and natural to me:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">; <\/span><span style=\"color: #75715e; font-style: italic;\">Syntax Highlighting<\/span>\n<span style=\"color: #a1efe4;\">(<\/span><span style=\"color: #f92672;\">require<\/span> '<span style=\"color: #ae81ff;\">highlight-symbol<\/span><span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"C-\u00c3\u00a9\"<\/span><span style=\"color: #e6db74;\">)<\/span> 'highlight-symbol-at-point<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"C-.\"<\/span><span style=\"color: #e6db74;\">)<\/span> 'highlight-symbol-next<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"C-,\"<\/span><span style=\"color: #e6db74;\">)<\/span> 'highlight-symbol-prev<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">(<\/span>kbd <span style=\"color: #e6db74;\">\"C-;\"<\/span><span style=\"color: #e6db74;\">)<\/span> 'highlight-symbol-query-replace<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org724392f\" class=\"outline-2\">\n<h3 id=\"org724392f\">Binding Some Keys<\/h3>\n<div id=\"text-org724392f\" class=\"outline-text-2\">\n<p>I like to bind some behaviors to the F-keys. What I want is to be able to run Cider and to switch frames (windows within monitors) in a single click. I also added a shortkey for starting speedbar for the current buffer; it is an essential for managing project files. What I did is to bind these behaviors to these keys:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">[<\/span>f9<span style=\"color: #e6db74;\">]<\/span> 'cider-jack-in<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">[<\/span>apps<span style=\"color: #e6db74;\">]<\/span> 'other-frame<span style=\"color: #a1efe4;\">)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>global-set-key <span style=\"color: #e6db74;\">[<\/span>f11<span style=\"color: #e6db74;\">]<\/span> 'speedbar<span style=\"color: #a1efe4;\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org97ffd99\" class=\"outline-2\">\n<h3 id=\"org97ffd99\">Fixing the Scroll<\/h3>\n<div id=\"text-org97ffd99\" class=\"outline-text-2\">\n<p>There is one thing that I really didn&#8217;t like, and it was the default behavior of the scrolling of Emacs on Windows. After some searching, I found the following configurations that I could fix to have a smoother scrolling behavior on Windows:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-elisp\"><span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">scroll one line at a time (less \"jumpy\" than defaults)<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>setq mouse-wheel-scroll-amount '<span style=\"color: #e6db74;\">(<\/span>1 <span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #fd971f;\">(<\/span>shift<span style=\"color: #fd971f;\">)<\/span> . 1<span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a1efe4;\">)<\/span> <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">one line at a time<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>setq mouse-wheel-progressive-speed nil<span style=\"color: #a1efe4;\">)<\/span> <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">don't accelerate scrolling<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>setq mouse-wheel-follow-mouse 't<span style=\"color: #a1efe4;\">)<\/span> <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">scroll window under mouse<\/span>\n<span style=\"color: #a1efe4;\">(<\/span>setq scroll-step 1<span style=\"color: #a1efe4;\">)<\/span> <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">keyboard scroll one line at a time<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org11540f9\" class=\"outline-2\">\n<h3 id=\"org11540f9\">Conclusion<\/h3>\n<div id=\"text-org11540f9\" class=\"outline-text-2\">\n<p>The Emacs\/Clojure ecosystem has improved quite a lot in the last two years thanks to Cider and the decision they made in its development. The configuration of Cider is now much simpler with <code>company-mode<\/code>. This blog post provides the latest improvement I did to my setup.<\/p>\n<p>As I said in my introduction, there is a whole bunch of settings that I did <b>not<\/b> include in this blog post related to configuring <code>org-mode<\/code> for doing <a href=\"https:\/\/fgiasson.com\/blog\/index.php\/category\/programming\/literate-programming\/\">Literate Programming<\/a> in Clojure. I will discuss these in its own blog post, likely to be published within the next week.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>It has been 2 years since I last revised my optimal GNU Emacs settings for developing Clojure. Since then, many things have changed in the Cider\/Emacs ecosystem and it is why a revision of these settings is now warranted. There is one set of settings that I will not discuss in this blog post, and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[251,279,66],"tags":[278,252,254],"class_list":["post-3220","post","type-post","status-publish","format-standard","hentry","category-clojure","category-emacs","category-programming","tag-cider","tag-clojure-2","tag-emacs"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3220"}],"version-history":[{"count":6,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3220\/revisions"}],"predecessor-version":[{"id":3507,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3220\/revisions\/3507"}],"wp:attachment":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}