Why You Should Use use-short-answers

A perennial problem for Emacs users are the yes/no prompts that require answering “yes” or “no” instead of just “y” or “n”. The usual solution—adopted by almost everyone—is to alias yes-or-no-p to y-or-n-p. Sometime around Emacs 28 or 29 the new variable use-short-answers was introduced as another way of solving the problem.

The last time I wrote about solving the yes-or-no-p problem, I said,

I’ve had my original aliasing code for at least 17 years and see no reason to change it. When use-short-answers was first introduced, I thought I should adopt it but I never did and as far as I can see, it doesn’t make any difference.

That statement was wrong in two ways. First, as related by Bozhidar Batsov, the alias trick doesn’t always work with native compilation because the call to yes-or-no-p may have been compiled before the alias is made. For that reason, use-short-answers is the better solution because it always work.

The second way it was wrong is that when I went to add use-short-answers to my init.el, I discovered that I had already done so, probably back in Emacs 29.

Posted in General | Tagged | Leave a comment

Removing Paired Delimiters In Emacs

Bozhidar Batsov has a nice post on delete-pair. It’s almost a case of the Baader-Meinhoff Phenomenon. Five months ago—before I wrote about it—I’d never heard of delete-pair and now it’s popping up on Batsov’s blog. Batsov, himself, doesn’t remember hearing about it before either.

For those who came in late, delete-pair does just what it says on the tin: delete the delimiter at point and its matching closing sibling. It’s actually quite flexible and usable in surprising ways as you can see from the_cecep’s original post that inspired mine.

The delete-pair command came to Batsov’s attention because it interacted poorly with his Neocaml package. That turned out to be because delete-pair makes assumptions that might not hold for languages with unusual syntax.

Batsov’s post is mostly a summary of what he found from researching the deletions of pairs in Emacs. For Lisp languages, all you need is paredit which has multiple ways of removing a delimiter pair. Probably the easiest is paredit-splice-sexp.

There’s also smartparens that also has several ways of removing a delimiter pair and has the advantage of working in all languages, not just Lisps. Batsov finds it too heavyweight for his needs but lots of folks swear by it.

Finally, there’s the builtin electric-pair-mode, which keeps delimiters balanced, pairs nicely with delete-pair, and is probably all most people need.

Take a look at Batsov’s post for more details and for a bit of Elisp that recreates Vim’s vim-surround. I was glad to see his post because I was right on the verge of forgetting delete-pair even though I’ve assigned it a keyboard shortcut.

Posted in General | Tagged | Leave a comment

Prot’s Video From His FOSS @ Oxford Talk

Just a quick post today to note that Protesilaos Stavrou (Prot) has published the video from his FOSS @ Oxford talk that I wrote about yesterday. Actually, he says that it’s a modified version of that talk so I don’t know if a video of the actual talk will appear or not.

In any event, the video tracked very well with the transcript that I wrote about in yesterday’s post. The video is a little easier to follow because you can see the changes to the text that he makes during his talk. If you’re the type of person that gets more out of a video than reading a transcript, be sure to take a look. The video is fairly long at 42 minutes, 40 seconds long so you’ll have to put some time aside for it but it’s definitely worth your while.

Posted in General | Tagged | Leave a comment

Prot On Emacs At FLOSS @ Oxford

Protesilaos Stavrou (Prot) recently gave a talk to the FOSS @ Oxford event on the power of Emacs and why he uses it. The video for the talk is not yet available but he does have the transcript that he used for delivering the presentation.

It was a nice talk that explained why Prot believes Emacs is a tool that everyone using a computer should be familiar with and make use of. The TL;DR is that Emacs is extensible and can integrate all the (text-based) tasks you need to perform on your computer. If, as a trivial example, you develop a color and font style that is pleasing to you, you need only implement it once: Emacs will use it for whatever tasks you like. Non trivially, you can arrange for various tasks to communicate with each other and share information if they need to.

Prot stresses a point that Irreal has often made: You don’t have to be a programmer to make good use of Emacs. Writers, teachers, liberal arts academics, and many others can and do leverage Emacs to make their work easier. Of course, if you know a bit of Elisp it’s even better because you can extend Emacs to do whatever you need. Prot himself is not a programmer but he taught himself Elisp and is now a significant contributor to Emacs.

The takeaway from Prot’s talk is that Emacs is all about freedom. Freedom to make whatever changes you like, freedom to explore the source code and see how Emacs does things, and freedom to share with others and learn from them.

Take a look at the transcript or wait for the video if you prefer visual presentations. In either case, it’s well worth your time.

Posted in General | Tagged | Leave a comment

Code Formatting With Emacs

Code formatters. Many people swear by them and always run their code through a formatter before checking it in. I’ve never seen the need for them. I have strong feelings about code format and I always write my code to that format: no need for a separate formatter. At the same time, I recognize that others have strong feelings about their preferred format so I never want to reformat someone else’s code.

There are, in every organization, control freaks who think it critically important that everyone’s code look the same. I’ve never accepted that premise and have ignored formatting guidelines. Somehow, I’ve always managed to get away with that minor recalcitrance.

Still, some people appear to like code formatters and for those people, Bozhidar Batsov has an interesting post on code formatters and how to use them in Emacs. It turns out that there’s a plethora of formatters with slightly different behavior to choose from

Happily the Lisp languages—which I use almost exclusively these days—don’t really need one since for a Lisp, code formatting is really just a matter of indentation, which Emacs handles on its own. Other languages need more work.

One of the problems with code formatters run from within Emacs is that they can freeze Emacs while they run. This is the case of formatters that run before the file is saved. There are formatters that run after the save by asynchronously reading the saved file, reformatting it, and writing it back to disk. This has the small defect that an unformatted file exists on disk for a short while.

Batsov’s post covers reformatters implementing both methods. Some of them allow extensive configuration of the reformatting rules. Others enforce a fixed format. Take a look at Batsov’s post for a really good rundown of all the possibilities.

Posted in General | Tagged | Leave a comment

Displaying Attached Image Files

Over at The Art of Not Asking Why, JTR has a nice post on attaching an image file to an Org file and displaying it inline. He begins by reviewing how to display an image file inline in an Org file and how to attach any file to an Org file. Most experienced Org users are familiar with all this. I used them just the other day to attach a delivery receipt for my tax papers to my accountant.

It’s the second half of his post that’s interesting. It turns out that when you attach a file to an Org file, the link to the attached file is added to org-stored-links just as if you had run org-store-link (bound to Ctrl+c l by default). That means you can insert the image in line by simply running org-insert-link (bound to Ctrl+c Ctrl+l by default) as usual.

Take a look at JTR’s post for all the details. If you often attach image files to an Org file and want to display them inline as well, this workflow is easy and efficient.

Posted in General | Tagged , | Leave a comment

Happy 53rd Birthday To Dark Side Of The Moon

As I do every year on this day, I want to wish Happy Birthday to Dark Side of the Moon, the best album of all time by the best rock band of all time, Pink Floyd. Of course, you’re free to disagree. I absolutely support your right to be wrong.

I used to feature a track from Dark Side of the Moon with each yearly post but I’ve run out of songs from that album so I’ve moved on to tracks from other Albums that I really like. This year’s track is Lost for Words from a rehearsal for the Pulse tour. If the video doesn’t appear on your screen, click on “Watch video on YouTube”.

I like this video for two reasons. First, you don’t usually see Gilmour playing a straight guitar but he brings the same amazing technique to it that he uses on his electric guitar. Second, these guys don’t mess around. Even though it’s a rehearsal for a song they’ve probably played hundreds of times, they treat it just like a live show complete with their signature light show.

I hope you enjoy the video as much as I do. In the meantime, join me in wishing a happy 53rd birthday to an iconic and enduring album.

Posted in General | Tagged | Leave a comment

How CHM Recovered The Unix v4 Tape

I’ve written a few posts [1, 2, 3] on the recently discovered Unix v4 tape. The tape is significant because it is the only known extant copy of Unix v4. Unix v4 is significant because it was the first copy of Unix to be written mostly in C. The TL;DR of those posts centers around the difficulty of reading the tape or even if it would be possible. In the end, of course, they did manage to read the tape and recover the code.

The Computer History Museum (CHM) has a very nice video featuring the people involved that recounts how hard recovering the tape was. It wasn’t possible to simply mount the tape on a drive and read it. Rather, they tapped into the electronics of the tape reader where the analog signals came off the tape head but before they were decoded into digital. The analog data was then processed by a program that recovered the digital information from the analog signals.

How they happened to have the technology to do this is an interesting story in itself and is told by the people who developed it along with the problem they were trying to solve when they did. We also hear from the people who discovered the tape and their evolving reactions to it. At first, they merely thought that finding the tape—an ancient technology at that time—was sort of cool but they didn’t think much of it. It wasn’t until after a bit of research that they realized what they had and got in touch with the CHM.

The video is 16 minutes, 37 seconds long but it tells an interesting story and is worth a quarter hour of your time.

Posted in General | Tagged , | Leave a comment

Abrams On Literate Programming Redux

Howard Abrams has a video and associated post that updates his post on the same subject from 11 years ago. As with yesterday’s post, the video is from EmacsConf 2024 but someone just reposted it to reddit and it’s definitely worth taking a look at.

Abrams is explicit that by “literate programming” he means using code blocks and Babel in Org mode files. It’s an extremely powerful workflow. You can execute those code blocks in place or you can use org-babel-tangle to export the code to a separate file.

The majority of his video and post discuss ways of working with those Org files. One simple example is that he uses the local variables feature of Emacs files to set a hook that automatically tangles the file every time he saves it. That keeps the parent Org file and the generated code file in sync. He also has some functions that leverage Avy to find and execute a code block without changing the point’s location.

Finally, he talks about navigating his—possibly multi-file—projects. We wants to do the usual things like jumping to a function definition or getting a list of where a function is called. Emacs, of course, has functions for that but they don’t work in Org files. So Abrams wrote his own extension to the xref API based on ideas from dumb-jump.

Abrams drew all this together with a hydra that makes it easy for him to call any of his functions. He moves a bit rapidly in the video so you might want to read the post first in order to follow along. The video is 16 minutes, 38 seconds long so plan accordingly.

Posted in General | Tagged , | Leave a comment

A Video On The Casual Suite

Those of you that hang out on Irreal know that I think highly of Charles Choi’s Casual Suite. It’s just what you need for modes that have a lot of seldom used commands or modes that themselves are seldom used. The idea is that rather than having to remember the appropriate key sequences or command names, you merely bring up a transient menu and choose the operation from it.

That’s a bit of a simplification since Casual is actually a bit more nuanced. Back in 2024, Choi produced a video for EmacsConf 2024—which someone has just reposted—that explores some of those nuances.

The use of Casual is not an either or decision. Often times you know many of the commands of a certain mode—Dired or Calc, say—but haven’t memorized the commands for some of the more obscure or little used commands. That’s where Casual really shines. For sequences or commands you don’t remember, you simply bring up the menu with a key sequence that is the same for all casual menus and use it to select the operation you need. If you already know the sequence, you just use it without bothering with Casual at all.

Choi has a user guide for Casual that documents the current state of Casual and shows you what modes are covered. That list has grown since his video.

For those of you who care about such things, Choi has just made the Casual Suite available on NonGnu Elpa as well as Melpa. Watch the video and see if Casual may not be a worthwhile addition to your Emacs packages repertoire.

Posted in General | Tagged | Leave a comment