So true and so often disregarded

Hat tip to Karl Voit.

Posted in Programming | Tagged | Leave a comment

Emacs 25.1

As you surely know by now, Emacs 25.1 is out and available for download at the usual places. Check the Emacs download page for a mirror near you. They also have pointers to some precompiled binaries if you prefer that.

I built and installed the new version with no problems at all. The compile even seemed snappier than I remember. If you're on OS X and want to use eww you need to use a slightly different configure line. I explained how to compile Emacs with eww on OS X for version 24.4 but the procedure is the same.

Meanwhile, Mickey has an excellent annotation of the NEWS file for the new version. You should be sure to give it a read to find out what's new and changed. One thing I learned is that if you want dynamic modules you have to specify that on the configure line. I haven't done that yet but if you want it be sure to add it.

I'm writing this with Emacs 25.1 but I just finished compiling and installing it so I haven't done much with it yet. So far, though, everything seems fine. If you haven't been living on the bleeding edge and using the development version, you can finally install the new Emacs.

Thanks to the many people under the excellent leadership of John Wiegley for this release. I know it was a big change and a lot of work.

Posted in General | Tagged | Leave a comment

Repeating a Command

Zachary Kanfer has a nice post on how to repeat a command with a single keystroke. A familiar instance of this is the old-style keyboard macro execution. After defining the macro, you can execute it with 【Ctrl+x e】 and then execute it additional times by simply typing 【e】. Kanfer wants to be able to do this for his own commands.

The trick is to use a transient keymap. Once you use a key in a transient keymap, the keymap goes away so the key will revert to its old meaning. This is a handy trick that's useful in other circumstances too. For example, here is my code for invoking the ping utility in a full-frame buffer and then restoring the previous window configuration.

 1: (defun net-utils-restore-windows ()
 2:   "Restore windows and clean up after ping."
 3:   (interactive)
 4:   (kill-buffer (current-buffer))
 5:   (jump-to-register :net-utils-fullscreen))
 7: (defadvice net-utils-run-program (around net-utils-big-page activate)
 8:   (window-configuration-to-register :net-utils-fullscreen)
 9:   (let ((buf ad-do-it))
10:     (switch-to-buffer buf)
11:     (delete-other-windows)
12:     (set-transient-map
13:       (let ((map (make-sparse-keymap)))
14:         (define-key map (kbd "q") 'net-utils-restore-windows)
15:         map))
16:     (message "Type \"q\" to restore other windows.")))

After the ping operation finishes and we've inspected the results, we want to restore the previous window configuration by typing 【q】. As shown on lines 1215, we do that by defining a transient map. After typing 【q】 the transient map disappears and 【q】 reverts to simply being a letter.

Posted in General | Tagged | 7 Comments

On Emacs Being an OS

Katherine Cox-Buday has a lovely 8-tweet long sequence in which she outlines how she uses Emacs to perform a periodic, tedious chore. It's worth looking at to see if you can get some ideas from it. Here's the last tweet in the sequence. (Click on the tweet to see the whole sequence.)

What struck me, though, is her remark that “So yes, it is an OS, but that's a feature!” I've always taken that joke to be a comment about Emacs' editor function not an indictment that you can reasonably compare Emacs to an OS. I've also taken it as a given that yes, of course, it's a feature.

That may be because I yearn for a Lisp Machine and Emacs gives me some semblance of that. On the other hand, how can you not like the fact that Emacs can do so much? What do you think? Is the fact that Emacs is like an OS a bug or a feature? You already know my answer.

UPDATE [2016-09-16 Fri]: also → always.

Posted in General | Tagged | 3 Comments

Capturing Images with Org Mode

Back in January, I came across a post by Arne Babenhauserheide on capturing images into Org. It looked interesting but required Image Magick, which doesn't play well with OS X1. I thought at the time that it would be pretty easy to adapt but I never got around to it.

Then the other day, I came across this reddit post that pointed to a Stack Overflow post on the same question. That bit of code handles both the Linux and OS X case so I thought I should install it and try it out. But then I saw a comment on the reddit post that pointed to abo-abo's org-download over on GitHub.

Abo-abo's code looks like it can be configured to handle Linux, OS X, or windows and it's available on Melpa. Coming from abo-abo, it's sure to receive any necessary updates so if you're looking for a nice utility to grab images and insert them into Org files, you should give it a look.



You have to use the X-server when running it on OS X.

Posted in General | Tagged , | Leave a comment

Abrams on Yasnippet

Howard Abrams over at has posted a very nice tutorial on yasnippet. I learned a couple of things I didn't know so you may find it worth a few minutes too.

First off, I was only dimly aware that you can bring up a template for a new snippet with 【Ctrl+c Ctrl+n】. What's really nice is that the template is a snippet so you can tab through it filling in the fields like any other snippet. I always have to copy an existing snippet into my buffer to get all the boiler plate. This is a lot easier.

More importantly, Abrams shows us how to use yas-expand-snippet to treat any text as a snippet even if it hasn't been added to the snippet collection. That may not seem like much but it turns out to be tremendously useful. Abrams gives an interesting use case where he combines auto-insert with yas-expand-snippet to fill in the boiler plate at the top of many programming files.

It's a good tutorial and well worth taking a look at. It shows some of the power of yasnippet that you may not know about.

Posted in General | Tagged , | 1 Comment

Copying Text with a Mouse in OS X and Emacs

Ben Maughan over at Pragmatic Emacs has a nice tip for those of you using Emacs on OS X. It turns out that it's easy to copy text to the kill ring with a mouse. I agree with Maughan that it's not something I want because I try to avoid the mouse when I'm in Emacs but many people feel otherwise.

If you'd like to be able to easily copy text to the kill ring with a mouse, take a look at Maughan's post to see how easy it is1.



Hint: It's a single line in your emacs.el.

Posted in General | Tagged | Leave a comment

Refactoring with counsel-ag

Back in January of 2015, I wrote about an excellent post from abo-abo on his refactoring workflow. If you haven't read his post be sure to take a few minutes to read it. The basic idea was that he wanted to change all occurrences of an identifier in all files in a given directory. He does that by finding each occurrence with rgrep, making the rgrep result buffer writable with wgrep, then using iedit to change all occurrences at once.

Samuel Barreto has a similar workflow that uses counsel-ag. He uses the evil substitution command rather than iedit to make his change but that's a detail. Take a look at his post for the details. If you're using ag or looking for a reason to install it, his workflow is very appealing. I wouldn't be surprised if abo-abo is using it himself now. If you often find yourself making this sort of global change, you really need to check out these workflows.

Posted in General | Tagged | Leave a comment

Put imenu Output in a Buffer

Grant over at Wisdom and Wonder has a short post that points us to imenu-list. That's a minor mode that puts the output of imenu into a separate buffer where you may find it easier to work with. If you follow the link to imenu-list's GitHub page you can see a screen shot of it in action.

Somehow, I've never warmed up to imenu but perhaps this will help. You can think of imenu-list as being sort of like occur and use it in a similar way. If you find yourself jumping around a program buffer a lot, you may want to give imenu-list a try.

Posted in General | Tagged | 1 Comment

Calling eww from Dired

If you have files that you read in eww, here's a suggestion that might make your workflow a bit easier:

Posted in General | Tagged | Leave a comment