RSSAmplifier

Blog

Endless Parentheses

endlessparentheses.comRSS feed ↗153 posts

Latest posts

What tests you shouldn’t write: an essay on negative tests

Software tests are great! I’m fortunate enough to have only worked with code-bases with reasonable-to-excellent test coverage, and I wouldn’t want to work in a world without tests. In fact, a thoroughly tested system is nothing short of liberating. That said, tests are not free. I’m not talking about CI time, that is a cost but it’s usually reducible. Nor am I referring to the effort it takes to…

Mold Slack entirely to your liking with Emacs

Although fine-tuning your slack notifications is already reason enough to run slack in Emacs, that’s only the beginning. Once everything is up and running you get to decide what you want out of your slack. Some of the snippets below simply make up for missing functionality, other customize the package beyond what you can do on the Slack Webapp. Priorities first. The most important improvement you…

Turbo up your Ruby console in Emacs

Keeping a REPL (or a console) always by your side is never a bad habit, and if you use an IDE-package (like Robe for Ruby, or Cider for Clojure) it’s nigh unavoidable. Being an essential part of your environment, it would be ridiculous not to invest some time optimizing it. One obvious optimization is to bind a key to your “start console” command, but that’s just the start. You pretty much never…

It’s Magit! And you’re the magician!

There’s nothing I can praise about Magit that hasn’t been written in a dozen blogs already, but since Jonas started a kickstarter campaign for it I knew I had to say something. If you use Magit, you already know the greatness of it. And if you don’t, hopefully I can convince you to try it in time to back the campaign. I could go on and on about the virtues of this gem. It’s probably the package…

Keep your Slack distractions under control with Emacs

There’s no denying slack is a useful tool for intrateam communication, but it’s also a powerful source of distractions. Though I can’t just turn it off all day, I can certainly keep the spam in check. Slack’s Webapp does allow you to partially mute certain channels, but that’s about as far as it goes. On the other hand, with the power of Emacs and the Alert package, we can perfectly filter out…

Emacs 25 is out! What are the new features and what were my predictions

Four Saturdays ago, on September 17, Emacs 25 was finally released . Almost two years before that, I wrote a post predicting a few Big things to expect from Emacs 25 . Throughout the months since then, I’ve also been reporting interesting new features as they arrived on the dev builds. Today, we compile a list of all of those news posts, and review which predictions I actually got right. News…

A quick guide to directory-local (or project-specific) variables

One of the questions we get most often about CIDER is “can I configure X on a per-project basis?”. Occasionally, you find someone suggesting (or even implementing) some sophisticated configurable variable trying to account for multiple simultaneous use-cases. Fortunately that’s one effort we don’t need to make. Emacs already has that built-in in the form of directory-local variables (dir-local for…

A few paredit keys that take over the world

Once you learn paredit, you really can’t go back. Even when you’re not editing lisp you crave for the ease of manipulating everything as balanced sexps. Although that’s (sadly) not always possible, you can still hack your way into a bit of guilty paren-pleasure in pretty much any editing session. While not all programming languages are lisps, most of them do have brackets and quotes. And paredit…

Restarting the compilation buffer in comint-mode

After last week's post , Clément Pit-Claudel informed us of an alternative method for providing input to compilations. I have no idea how I’d never learned about that before, but I figure that other people might be in the same situation so it’s worth a post. Have a look at the Update at the end of the post. I’ve also updated an older post accordingly: Better compile command . Comment on this.

Provide input to the compilation buffer

The Emacs compile command is a severely underused tool. It allows you to run any build tool under the sun and provides error-highlighting and jump-to-error functionality for dozens of programming languages, but many an Emacser is still in the habit of switching to a terminal in order to run make , lein test , or bundle exec . It does have one limitation, though. The compilation buffer is not a…

Fill and unfill paragraphs with a single key

fill-paragraph is probably among the most underappreciated Emacs commands. I use it dozens of times a day, and never stop to think of just how awesome and practical it is. Still, we can make it a little bit better. Every once in a while I need to “unfill” (or “unwrap”) a paragraph that’s broken over many lines. By being clever enough, we can make this into a free feature . There’s never any reason…

A review of Mickey Petersen’s “Mastering Emacs” book, for beginners and advanced users

I wish I had reviewed this book when it first came out, over one year ago. Alas, those were busier times and this piece of work deserved more than a short post hastily written between seminars and group meetings. Fortunately, Mickey has unknowingly gifted me a second opportunity, by making it half-off for its 1 year anniversary, and you have until tomorrow to grab the discount. When it comes to…

Locally configure or disable show-paren-mode

show-paren-mode is a minor-mode that highlights the bracket at point (be it round, square, or curly) as well as its corresponding open/close counterpart. I find it a must-have for Elisp and Clojure programming. On the other hand, when editing Ruby code, it also highlights whole block delimiters, like def , do , if , and end , and all that must-haviness quickly turns into in-your-faceviness. The…

validate.el: Schema validation for Emacs-Lisp

Emacs’ customizable variables (a.k.a., defcustom ) are allowed to specify a :type parameter for setting its custom-type. The customize interface uses this information to produce a sophisticated menu for the user to customize that variable. However, a large fraction of users use setq to directly edit custom variables, and even some packages programmatically change the value of other package’s…

Disable Mouse only inside Emacs

As laptop touchpads seem to be steadily increasing in size, one unfortunate consequence is that it becomes increasingly harder to avoid touching them by accident while you type. Most systems have safeguards in place that disable the touchpad as you’re typing, but they always seem to fall short for me when it comes to Emacs. While in Emacs, my hands are permanently resting on the keyboard (and over…

ANSI-colors in the compilation buffer output

Countless build tools and shell scripts use ANSI escape codes to colorize their output. This provides impressive improvements to readability when running from a terminal that supports them, but tends to cause a catastrophic mess anywhere else. Emacs’ compilation buffer is one such place. It doesn’t support ANSI colors by default, but that’s very easy to fix. Emacs already has a library for…

Emacs is available on Chromebook and Chrome

Are you a Chromebook user or thinking of becoming one? Are you a die-hard Emacser who needs to see it run even in your browser for no good reason (no judgement)? Either way, Emacs has you covered. Thanks to the efforts of Pete Williamson (and friends), there is now an Emacs port for Chromebook and Chrome. If that spikes your interest, you should read his post about it on Google Plus, which…

Improving Projectile with extra commands

Admittedly, I’m a very late passenger in this boat — only after 4 years of using Emacs did I decide to try a project manager. Nowadays I can’t even remember my daily workflow without Projectile . This package mostly stays out of your way, and provides a series of useful commands for dealing with a project (which are aware of a lot of languages out-of-the-box). As usual, you can find details…

Running Emacs on Android

As Android phones rise in power, bluetooth keyboards become cheaper, and your addiction to Emacs grows, it’s only natural that you start thinking of combining the three. Fortunately for you, it’s not as hard as it used to be. In fact, it’s perfectly possible to reproduce (most of) your desktop config, if you know how to get past a few obstacles. I was going to precede these instructions with a…

Eval-result-overlays in Emacs-lisp

One of the things I like most in CIDER is how evaluation results are displayed by inline overlays. And yet, for some reason, it’s taken me almost a year to transfer that to Elisp. It’s the tiniest of changes — you’re just taking something that would be displayed in the minibuffer and moving it up a dozen or so lines — but the difference is palpable. By displaying the result inline,…

Leave the cursor at start of match after isearch

Have you ever stopped to think about why isearch leaves point at the end of the match? It does make some intuitive sense to leave you after the characters you have just typed, but that doesn’t make it the most practical behaviour. This is something I’d never even given half a thought in the past, but it’s one of the first things a friend questioned me as he was diving into Emacs (yes, the same one…

A small improvement to clj-refactor

I’ve said before that clj-refactor is a magical package , and you wouldn’t catch me bad-mouthing it in a million release cycles, but it’s impossible to please everybody. One consistent annoyance I have with it, is that I always have to type Tab twice after invoking cljr-add-require-to-ns . That’s because I only ever use requires of the form [x.y :as y] , so I always have to skip the first two…

Conditional breakpoints in the CIDER Debugger

CIDER 0.11.0 has been out for less than week and already the snapshots are getting new features. This one comes from a gentleman called Chris Perkins . It provides an easy way to automatically skip some breakpoints during evaluation, and it even comes with 300 brand new lines of tests. The feature is very straightforward, and is already available on the snapshots of 0.12.0 . You’ve always been…

Commands to thread and unwind code in Emacs-Lisp

As you may remember , one of the commands I like the most from the clj-refactor package are the ones that thread and unwind Clojure code forms for you. Now that Emacs is also getting built-in threading macros , I figured the best way to give them a fair chance in life is to also make them pretty convenient to use. The point here is that you can place point before a paren, invoke a command, and a…

New in Emacs 25.1: More flow control macros

One of my personal favorite new additions to Emacs 25 is, in fact, completely invisible to most users. The new macros if-let and when-let , although simple in purpose, are a delight to use and are frequently finding their way into my code. The other two additions, thread-first and thread-last , are a bit more specific, and take a bit getting-used-to if you’ve never seen them before. The two *-let…

New in Emacs 25.1: map.el library

Another library by the productive Nicolas Petton. map.el is a cousin to seq.el ( remember? ), but instead of manipulating plain sequences, it manipulates map-like collections (also known as dictionaries). The range of functions should include everything you expect, from map-values and map-keys to get a list of the values and keys (duh), to general getters and setters like map-elt and map-put .…

New in Emacs 25.1: EWW improvements

In the upcoming version, EWW is getting a number of small improvements. This web browser, written by Lars Ingebrigtsen, is something of a new kid on the block, as it just came to life at the very end of the Emacs 24 cycle. Although it’s hard, if not impossible, to reliably render HTML inside an editor that’s 100% line-based, EWW tends to find a reasonable compromise and deserves at least a short…

New in Emacs 25.1: Easily search for non-ASCII characters

Since last week’s post was about Unicode characters, it makes sense to continue that trend today. This feature might go unnoticed by a lot of people who live in an ASCII world, but it will probably jump out at everyone else at one point or another. The name, if a bit odd, is “character-folding search”. In Emacs 25, Isearch can find a wide range of Unicode characters (like á, ⓐ, or 𝒶) when you…

New in Emacs 25.1: Round quotes in Help buffers

Don’t be fooled by the apparent simplicity of this feature. Its implementation has been the most controversial addition to the upcoming Emacs release — to a comical degree . This post, however, is not about arguments or implementation, it’s about Emacs 25. And this little nugget is all set for the next release. The feature is simple, next time you’re reading a docstring (maybe via C-h f or…

Quickly search for occurrences of the symbol at point

Isearch is one of Emacs’ most useful (and probably most used) features. Getting in the habit of quickly hitting C-s followed by 2–4 letters will forever change the way you navigate buffers, and adding it to your repertoire is a tremendous productivity improvement. What, then, could we possibly improve on such a phenomenal command? One of the search actions I find myself doing a lot is to…

An improvement to Emacs auto-correct

My Emacs auto-correct is one of the oldest posts on this blog, and I still see it pop up here and there on occasion. Last week, Norman Ramsey asked about an improvement to that command and I figured it’s worth an update post. As of today, the code in the post will search backwards for a typo, instead of just correcting the current word. So you can invoke it without trouble even if the typo…

Define context-aware keys in Emacs

What do you do if you want to override a key only in a certain context? Take this Quotation Marks post as an example. We want to change the " key in general, but retain the regular behaviour if we’re inside a code-block. In this case the solution was to just call the old behaviour manually, but what if you’re writing a more general command and you don’t know what this “old behaviour” is? As it…

New in Emacs 25.1: Have prettify-symbols-mode reveal the symbol at point

I’ve written before about what prettify-symbols-mode can do for your buffers, ranging from pure eye-candy to signficant readability improvements . Simply put, this minor-mode “disguises” some strings in your buffer to look like something else. For instance, in emacs-lisp-mode it makes lambda be displayed as λ , and (for the next release) it’ll apply to a wide range of symbols in (la)tex-mode too.…

Faster pop-to-mark command

Today’s tip is one I learned from Magnar . A lot of Emacsers don’t know this, but most commands that move point large distances (like isearch or end-of-buffer ) push the old position to the mark-ring . The advantage is that you can easily jump back through this history of positions by hitting C-u C-SPC . This is a hugely convenient take-me-back-to-that-last-place command. The only problem is that…

Improving Emacs file-name completion

Although there’s a surprising number of packages offering alternative minibuffer selection systems, the default minibuffer completion in Emacs is nothing to be scoffed at. Hitting Tab in the minibuffer gives you a slightly beefed up version of the bash completion, and after all these years that is still my preferred method for completing file-names (though I do have some custom-written…

Marking Emacs chat buffers as read (erc, jabber, etc)

I’m an occasional user of some of the Emacs chat clients. Erc and jabber are both powerful packages, and it’s great to be able to use Slack, Gitter, and Google Chat from the cosy comfort of my Emacs frame. If I have one complain, though, it’s that neither of them has a functionality for keeping track of what part of the conversation I’ve already read. Of course, this is Emacs. And the solution is…

Using Paradox for Github notifications

A few weeks ago I noticed a new package on Melpa called github-notifier by Chunyang, which displays a count of your Github notifications on the mode-line. Instead of just installing the package like a normal person, I had an urge to try and see how hard it would be to write from scratch. Paradox already has a function for interacting with the Github API, so it’s just a matter of putting it to…

Update on tdd-mode with CIDER

I can’t write a whole new post this week due to being buried under some once-in-a-lifetime stuff. Still, the Monday post is one I refuse to miss, so I leave you today with an update on last weeks post. Running tests on file save really didn’t work out for me, because I’ve configured CIDER to save files before loading them when I use cider-load-file . So the tests were always being run against…

Test-Driven-Development in CIDER and Emacs

As I was catching up on a few Parens of the Dead episodes this weekend, I was amused at how Magnar set up his Emacs to run tests whenever the file is saved. At first I thought it wasn’t for me (I’m one of those who obsessively saves every few seconds), but I’ve been trying it out lately and it’s starting to grow on me. At its core, all you really need is an hook. But I walked the extra yard and…

New Clojure lib: lazy-map

The concept of a lazy-map might sounds odd at first. How do you know if a map contains an entry without resolving the whole map? But it’s not the entries that are lazy, it’s the values they hold. See this example from the Readme: user> ( def my-map ( lazy-map { :cause ( do ( println "Getting Cause" ) :major-failure ) :name ( do ( println "Getting Name" ) "Some Name" )})) # 'user/my-map user> (…

Using prettify-symbols in Clojure and Elisp without breaking indentation

prettify-symbols-mode is a very nice minor-mode that is a little too modest for its own good. You can turn it on right now if you’re using a recent Emacs, but it’ll do nothing more than turn lambda into λ in emacs-lisp-mode . Still, it’s powerful and versatile and deserves that you give it a try. To extend its feature-set you can install packages or customize it yourself, and that’s what we’re…

clj-refactor — Unleash your Clojure wizard.

When I first started learning Clojure, I was charmed by how well integrated CIDER was with Emacs. In many ways, it felt just like writing Emacs-lisp. Nowadays, that feeling has gone slightly past the goal mark, and there are actually features I miss when I’m writing elisp. Clj-refactor is one of them. This package is a Swiss knife of refactoring utilities for Clojure. From simple operations like…

Changing the org-mode ellipsis

The dot-dot-dot ellipsis that org-mode uses to indicate hidden content is usually just fine. It’s only when you’re staring at a document where every line is a folded headline, that you start to feel like they’re a little too much “in your face”. I have a few org files with thousands of lines and hundreds of headlines, and changing that ... to something shorter greatly reduces visual clutter. The…

Beacon — Never lose your cursor again

What started out as a cute idea I was playing around with, eventually turned to be one of my favorite packages. Beacon won’t help you type faster, code better, or cure cancer like some of the other packages. Its effect is mostly cosmetic, but with practical benefits. Put simply, if you turn on this minor mode, whenever the window scrolls up or down a light will blink on your cursor. That’s it. At…

Improving LaTeX equations with font-lock

It’s difficult for me to spend much time interacting with a major-mode and not find something to tweak. Even when that mode is my oldest companion in the world of Emacs, something will surely pop up. So it’s only fitting that in the final week of my thesis submission deadline I start tinkering with latex-mode again. I wrote the following snippet after compiling a recent Emacs snapshot which…

Paradoxical Hydras

Quick update to say that I’m quite pleased with the Hydra package. Turns out it’s not just eye-candy on top of keymaps, it also offers convenient functionality that is rather dull to implement on plain keymaps. If you use Paradox , next time you upgrade you’ll find that a sneaky hydra has made its way into it. It’s a very simple one under the f key, but it’s a nice improvement over the plain…

Multiple Cursors keybinds

The Multiple Cursors package has been given much praise throughout the Emacsphere. It has a smaller use-case than keyboard macros, but it is usually quicker and just plain looks awesome. To make full use of its commands, I combine two of the concepts I've explained here before, rebinding M-number and intuitive keymaps . I won’t go into what this package is, as Magnar already has a whole video on…

Better time-stamps in org-export

org-mode has a very useful command, org-time-stamp , which helps you insert dates from a calendar. So you can quickly type C-c . RET to insert <2015-10-05 Mon> , for instance. These time-stamps are used by Org in a variety of ways, so they are wrapped in <> to make them easy to parse. The downside being that they look less than optimal when exported. I was bit by this again today while updating…

Predicting the future with M-n

This is one of those small functionalities that makes your life considerably easier, and yet a surprising number of people don’t know about it. When Emacs prompts you for something in the minibuffer, you might be aware that you can navigate back and forth in the prompt’s history with M-p and M-n , but did you know you can even step into the future? Well, sort of&#x2026; At least that’s the spirit.…

Flycheck a directory and report the results

This weekend I found myself doing some heavy-weight refactoring in CIDER. This is the kind of situation where Flycheck helps a lot, but I still needed it to do a bit more. Every time I made a significant change to a file, I had to visit 3 or 5 other files and trigger Flycheck on each one of them. It wasn’t long before I decide there had to be a way to just Flycheck a whole directory. Enter…