Mastering Emacs Book Review

Over at LWN.net, Jake Edge has a book review of Mickey Peterson’s excellent Mastering Emacs. Edge is a long time Emacs user who never got around to really mastering the editor. Through a long process starting with a fascination with Lisp, Edge became determined to learn more about Emacs. Part of that journey involved finding and reading Mastering Emacs.

Edge notes that the book takes a long time to get to actually editing text. Rather, it spends time nailing down the terminology and philosophy behind Emacs. He says, and I agree, that that was an excellent approach. As he says, Peterson approaches the material in a way that make sense for a narrative rather than a reference. He also says that although the organization of the book may seem a bit strange at first, the key to understanding it and Emacs is to recognize that Emacs is a tinkerer’s editor.

When he got to the editing part of the book, Edge discovered that actions in Emacs are subtly different from other editors. For example, when you “kill” text you don’t delete it, you merely move it to the kill ring. That means it available for reinsertion elsewhere, where “elsewhere” means some place in the same buffer or even in another buffer. In fact, with the proper configuration, you can even insert it into a completely separate application.

Another interesting part of the post is the comments. Other than a long, silly, and ultimately pointless argument over whether the book is somehow evil for not being “free”, they tell the story of how other users came to know and champion Emacs.

If, like me, you enjoy other people’s Emacs stories, this is a nice article. And, as I say, the comments are worth a bit of time too.

Posted in General | Tagged | Leave a comment

Prompting For Kill Buffer

Christian Tietze has a, for me, provocative post on the Emacs 29.1 kill-buffer prompt. I am a stickler for accuracy and consistency: just ask my family that has to endure my rants about inconsistencies between episodes of TV series. Tietze makes me look like an amateur.

His post laments the change in the kill-buffer prompt in Emacs 29.1. It used to be something like “Buffer modified; kill anyway? Yes or No”. Emacs 29.1 added a third option: “Save and then kill”. His problem is that the “Yes” or “No” answers are now ambiguous. At least as far as his muscle memory is concerned.

Tietze advised the kill-buffer--possibly-save function to change the prompts to:

  • Save and kill buffer
  • Discard and kill buffer without saving
  • Cancel. Exit without doing anything

These prompts have the advantage of being consistent and clear. Still, almost all of us won’t care. We may grump that the prompt lacks consistency but we’ll adapt. Tietze is different and fixed things to be more rational.

The point of this Irreal post is that Tietze’s post is an allegory on the ability of Emacs to let you have it your way. Tietze could have just sucked it up and dealt with the new prompts or he could have filed a complaint to, say, Emacs-devel and hoped that he wouldn’t be ignored. Instead, he simply fixed it in his own environment and wrote about it in case others or the Emacs developers wanted to do likewise.

To me, this represents the best about free software. Not only do we have the source code but it is, in fact, easy to modify Emacs’ behavior without recompiling the app. I don’t know of any other app with this level of adaptability.

Posted in General | Tagged | Leave a comment

The Joys of Hippie Expand

Over at the Emacs Elements Channel there’s an excellent video on Hippie Expand, The main problem with Hippie Expand is its name. It gives you no clue as to what it does or why you might want to use it. The TL;DR is that Hippie Expand will try a sequence of completion methods until you find the correct one. It is, in that way, better than any individual completion method.

Being Emacs, it is, of course, configurable. You can specify what completion methods to try and in what order to try them. There is, really, no reason to use any other method. Even if you have some method that Hippie Expand doesn’t use, you can simply add it to the list of methods that Hippie Expand uses. I long ago tweaked the order of the methods but I no longer remember why.

Hippie Expand can be a little confusing because some of the methods may offer more than one completion. In that case, subsequent invocations will offer those completions before moving on to the next method. That’s exactly the behavior you want, of course.

The video demonstrates how to jump to a particular completion method in the list. You have to know the method’s position in the list to use that so it’s not as useful as you might think. All in all though, Hippie Expand is a very useful method that’s worth knowing about.

The video is 12 minutes, 51 seconds so plan accordingly. It’s a good video and a real help in understanding what Hippie Expand does and why you should be using it. It’s definitely worth your time to watch it.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Politicians and Mathematics

Irreal doesn’t do politics but it’s no secret that we hold politicians in low esteem. It’s always a battle between politicians and journalists for the rank of the least respectable profession. I was reminded of all this by an article about the infamous Indiana bill to legally define the value of Pi as 3.2.

For a long time I’ve considered this an urban legend. I remember reading years ago that it simply wasn’t true. When I read the Mental Floss article I did some minimal research and Wikipedia, at least, agrees that the story is real. To be fair, the bill was really about squaring the circle—a mathematical impossibility—but a consequence of the bill was that the value of Pi is 3.2. Fortunately, happenstance intervened and the bill wasn’t passed.

You may think that this story falls into the “Boy! Them old folks: weren’t they silly” category and thank goodness we’re more sophisticated today. But we aren’t. The exact same dynamic can be seen in the UK Online Safety Bill that attempted to magically legislate into existence a “safe” backdoor to end-to-end encryption. As with the attempt to legislate the value of Pi, it was an attempt by politicians to legally instantiate their desire into existence despite assurances from those who actually knew what they were talking about that it wasn’t possible.

In both cases, saner heads prevailed although in the case of the UK bill it was merely a strategic retreat. Even that wouldn’t have happened if Apple, Meta, and others hadn’t threatened to withdraw popular services from the UK if the bill passed.

Irreal is the first to reject arguments from authority but if every single expert is telling you something isn’t possible, it seems to me that you have an obligation to provide evidence that they are the ones who are wrong. Politicians proclaiming “they could do it if they wanted” is not an example of that evidence.

UPDATE [2023-09-18 Mon 11:35]: substantiate → instantiate.

Posted in General | Tagged , | Leave a comment

Another Mode Line Implementation

After watching and writing about Prot’s video on custom mode lines I’ve been experiencing a vague urge to customize my own. Adding to that urge has been a couple of posts by James Dyer who has also felt the urge. The first used Prot’s post as a jumping off point for his own customization. Now Dyer is back with his latest iteration.

Dyer has a list of goals for his ideal mode line. The ones that resonate with me are:

  • Show the full path name. I often wish for this, not for the same reason as Dyer but because I occasionally start a post in ~/org/ rather than ~/org/blog/ and having the full path name would help me realize this earlier.
  • A Clear indication of file modification. That’s not usually a problem for me but the three side-by-side indicators can be confusing if one other than the modified indicator is lit.
  • Efficient information display. Unlike Prot, Dyer and I like to have as much information as possible displayed. We both want the row and column of the point displayed, and would like at least the important minor modes indicated.

Dyer includes the code for his mode line configuration. To really understand it you should watch Prot’s video. Perhaps you, too, will feel the urge for a bit of mode line customization.

UPDATE [2023-09-11 Mon 11:41]: Added link to second Dyer post.

Posted in General | Tagged | Leave a comment

More Sqlite-mode Extensions

Álvaro Ramírez has extended his extensions to the Emacs 29 Sqlite mode. I no longer have to interact with SQL databases for work but these days seemingly every application uses an sqlite database. Why not? Sqlite databases don’t require a heavy weight database. They’re just local files accessed with a simple, robust library that allows the access and modification of the database with the SQL language.

Emacs 29 has an sql-mode that allows minimal interaction with an sqlite database. Ramírez has extended those capabilities in a useful way. Take a look at his post and animated gifs to see what you can do.

He says that the code is still experimental but if you need to work with sqlite databases, it may be just what you need. The code is available on GitHub and is a single relatively short file so it would be easy to added it to your configuration and try it out. If you need to interact with sqlite databases, you should definitely take a look at Ramírez’s post.

Posted in General | Tagged | Leave a comment

Elisp One Sexp At A Time

Some of the Irreal posts that make me the happiest are those that reveal a single tip that helps readers improve their workflow. Tony Aldon has an ongoing video project that presents a single piece of Elisp that performs some useful task. These are really useful and worth checking out to see if you learn something new. Mostly, they’re about 2 minutes long so it’s easy to fit one of them in with your morning coffee. So far, he’s been doing one a day.

The list of videos so far is:

  • How to match 47 characters in a string with Emacs Lisp
  • How to put the value of an Org property in the kill-ring with Emacs Lisp
  • Do you know how to generate html strings with Emacs Lisp
  • How to add html attributes with the Emacs package Jack
  • How to check for a regexp match after point with Emacs Lisp
  • How to insert foo at the end of buffer without changing point with Emacs Lisp
  • How to check for the states of buffer-local variables in Emacs Lisp
  • How to turn a function into a command in Emacs Lisp
  • How to insert strings in a given buffer in Emacs Lisp
  • How to list files in a given directory in Emacs Lisp
  • How to replace regexp in buffers in Emacs Lisp
  • How to search for regexp in buffers in Emacs Lisp
  • What influence does case-fold-search have on searches in Emacs Lisp
  • How to manipulate the match data in Emacs Lisp
  • How to replace regexp in buffers in Emacs Lisp

These are really useful and a nice way to learn some Elisp. They serve as an excellent adjunct to Mike Zamansky’s series on Learning Elisp.

Posted in General | Tagged | Leave a comment

Task Management With Org Agenda

Denis Kyashif has a nice post on how he uses the Org mode agenda to handle his task management. He has two main requirements:

  1. It should be easy to add tasks to his task list.
  2. It should be easy to read his task list and figure out what to do next.

He said that it took him a while to find a task management system that met those needs but like many of us, he settled on Emacs and Org mode.

The salient feature of Kyashif’s Org work flow is that the Org configuration is pretty much out of the box. He doesn’t have a lot a special configurations or special functions. He just uses Org and Org agenda in its default mode. It’s a nice example of how powerful and useful Org mode is for task management.

The real structure on his workflow comes not from Org or its configuration but from his self imposed restraints. He says, for example, that not everything needs to be on the task list. He keeps everything in a single file with each “project” having a top level heading. He tags those so that each sub heading will inherit it making search for the project tasks easy.

It’s a nice workflow and his post is worth reading if you’re searching for your own task management system.

Posted in General | Tagged , | Leave a comment

Compiler Humor

Apropos of Nothing, as Cheryl Crow once put it, here’s something you don’t see very often: compiler humor. From another era when engineers were still allowed to inject whimsy into software, Tony Cunningham offers us a selection of error messages from Apple’s MPW C compiler. Take a look. Some of them are hilarious; they’re all amusing.

You don’t see this anymore, of course. The suits came along and insisted that such things weren’t “professional” and trivialized the very important products that they were trying to sell to other humorless drones.

There’s a long tradition of this sort humor, especially in the Unix world. There’s the famous “bug” listed at the end of the tunefs man page: You can tune a file system, but you can’t tunafish. That joke was in the BSD Unix distribution until the suits discovered it and had it removed. Then there was the in-joke values of β will give rise to dom! error diagnostic from the Version 6 mv utility. Dennis Ritchie explains the joke at the link.

Part of the hacker psyche is a delight in playful humor and it’s sad that the sort of droids that used to read Datamation have done everything they can to stamp it out. These days the humor exists—if it exists at all—in the source code where the suits are unlikely to discover it.

Posted in General | Tagged , | Leave a comment

Org Agenda Tasks

Charles Choi has published an interesting post on defining org agenda tasks. All Org users, I’m sure, are familiar with the Org Agenda that lists the Org headlines in each of the files in org-agenda-files and provides a link to each of those headlines.

The agenda is actually pretty malleable. Lots of people—perhaps most people—use it as a sort of calendar to list and track their tasks and appointments. I do some of that too but I also use it as a sort of log file of my daily activities. It’s easy to adopt it to your particular workflow.

To a first approximation, Choi’s post deals with ways of controlling when items appear in the agenda. For example, you may want a task to appear in the agenda around the time you’re supposed to start working on it and stop appearing when it’s completed. There are all sorts of nuances controlling the display of agenda items and even the experienced Org user may not be familiar with them all.

Choi then moves on to clocking tasks and how to handle that from the agenda. It is, he says, easiest to start and stop the clock from the agenda. In addition, there are speed keys to display the times spent on a task. Something I didn’t know was that you can arrange for a timer to persist over Emacs invocations. Choi explains how to set this up. If you’re using clocking, you should definitely do this.

Finally, Choi ends his post with a short list of best practices for dealing with the agenda. The post is definitely worth a few minutes of your time.

Posted in General | Tagged , | Leave a comment