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

Transposing Things

Bozhidar Batsov is back with another great post on recent additions to Emacs, This time it’s about transposing things in Emacs. Most experienced Emacs users are familiar with transpose-chars and transpose-words. I’ve heard it suggested the that the use of these is mostly restricted to “power users” but I’ve been using them almost as long as I’ve been using Emacs. Perry Metzger made a comment on Irreal—I can’t find it now—extolling transpose-chars and how much more efficient it is than making the switch by hand.

I use those two commands all the time, usually several times a day. Batsov says that another useful transposition command is transpose-sentences but that few people discover it. I found it simply by assuming that it must exist and using Meta+x to find it. There’s also transpose lines, which I seldom use because it usually offers surprising results in visual-line-mode.

In addition to these commands there are some others. Take a look a Batsov’s post for more details. The point of his post is how much more useful some of these commands are when combined with Tree-sitter. The transpose-sexps command, which I always thought of as useful mostly for Lisp languages, gains a lot of power when Tree-sitter is brought to bear to define what “a balanced pair” means in whatever mode you’re using in the current buffer.

Finally, there is transpose-paragraphs. While I’ve never used it, it’s obviously useful for prose editing but gains new powers with Tree-sitter that can give a meaning to “paragraph” in the mode of the current buffer.

Every Emacs user should take a look at Batsov’s post. There’s a lot of good information in it.

Posted in General | Tagged | Leave a comment

Choi’s Casual Suite Is Now Available on NonGnu ELPA

After a considerable amount of back and forth on the Emacs Devel Mailing List, Charles Choi’s Casual Suite has been accepted for inclusion on the NonGnu ELPA repository. If you’re already a Casual user, this makes no substantive difference. You can still get the suite from MELPA as you always have but it will also be available on the NonGnu repository.

Evidently Choi decided to seek NonGnu placement because some folks object to MELPA on philosophical grounds. I’m not sure I understand what the issue is other than MELPA is not officially canonized by the FSF.

To me, that’s just like insisting on a small init.el on religiously grounds. It merely means that you can’t take advantage of all Emacs has to offer. Whatever the FSF’s feeling on the issue, MELPA is, in fact, the premier ELPA repository and almost every package worth having is represented there, and many of them only there.

Still, choices are good and now we have more of them. If, for whatever reason, you have an objection to MELPA, you can still take advantage of the Casual Suite.

Posted in General | Tagged | Leave a comment

Expand Region Reimagined

Bozhidar Batsov has been blogging up a storm on recent additions to Emacs that make our editing sessions easier. His latest post is about a successor to expand-region, expreg. Batsov has been a heavy user of expand-region for many years. The problem with it is that it requires hand written functions for each language that it supports.

As a result of his recent work integrating Tree-sitter into many of his packages, he thought it would make sense to reimplement expand-region as a Tree-sitter based package so that bespoke functions wouldn’t have to be written for each language. It turns out that Yuan Fu, who implemented the Emacs builtin Tree-sitter, had already done it.

Batsov loves expreg and doesn’t see why anyone who isn’t depending on some artifact of expand-region wouldn’t adopt it. Take a look at his post for more details.

In the comments over at the Emacs subreddit Karthink says that he has a constellation of packages that depend on expand-region and that it would be very hard for him to change. Spartanork says that he had a hard time getting Tree-sitter installed. Those two comments suggest that expreg may not be for everyone.

I’ve had expand-region installed for a long time but I don’t use it as much as I should. At this point in my life, virtually all my coding is done in either Elisp or C, for which expand-region works well. It also does the right thing in a prose buffer so I see no reason to change but if you’re using a lot of languages, you should definitely check out expreg.

Posted in General | Tagged | Leave a comment

Visual Wrap Prefix Mode

As I wrote yesterday, a lot of really interesting posts popped up all of a sudden and I speculated that I might have to break my rule about not covering items that Sacha has already mentioned. I’m giving myself leave to mention at least one more post from last week.

Bozhidar Batsov has a nice post that explores Emacs line wrapping. As he says, there are basically two ways of doing that:

  1. Hard wrapping that inserts an actual newline in the text to wrap the line at the logical screen width
  2. Soft wrapping with visual-line-mode that doesn’t change the actual text but changes the representation on screen

The problem with visual-line-mode is that it doesn’t respect the indentation context and merely wraps the line at the logical screen edge, which can make the screen representation of the text seem strange. Happily, all this is fixed in Emacs 30 with visual-wrap-prefix-mode that automatically computes the indentation context and indents the text appropriately.

I never noticed this problem before, probably because I turn on visual-line-mode only for prose buffers, never for code buffers. If you are going to export those prose buffers, you really want visual-line-mode so that the text will display correctly on any screen.

Still, I was interested in visual-wrap-prefix-mode because I had never seen the bad wrapping described by Batsov. My writing is mostly straight prose without a lot of fancy indenting such as you might get with, say, poetry. The only time it comes up is with lists like the one above. When I turned visual-wrap-prefix-mode for this buffer, it did indent the subsequent lines of each item but I never really noticed the bad indentation before because it gets rendered correctly when I export it.

In any event, you should definitely take a look at Batsov’s post if you’re having word wrap problems.

Posted in General | Tagged | Leave a comment

A Diff Preview Of A Regex Replace

When it rains, it pours. Sometimes I find it hard to find an interesting topic to write about. Other times, like today, four or five topics pop up. The problem is that today is Sunday and tomorrow Sacha will be publishing her weekly Emacs News. I generally try not to write about things that she’s already covered but I may have to break that rule for some of these interesting topics.

For me, the most exciting thing I’ve found today is Bozhidar Batsov’s post on Preview Regex Replacements as Diffs. It addresses a problem we’ve all had. You want to do a query-replace-regexp on a large file—or even multiple files—but you’re a bit nervous that maybe your regex isn’t quite right and the command might make a change you don’t want. So you step through each change, which is time consuming and a pain.

As Batsov explains, that got a lot easier in Emacs 30. There’s a new command, replace-regexp-as-diff that runs the regexp replace process but instead of actually making the changes, it produces a diff file in a separate buffer. That way you can see all the changes that would be made. If you’re happy with them, you can simply apply the diff buffer as a patch with diff-ediff-patch to apply them. If you’re not happy, you can simply delete the diff buffer.

There are two related commands: multi-file-replace-regexp-as-diff and dired-do-replace-regexp-as-diff for handling multiple files. The Dired variety is probably the easiest to use because you can simply mark the files you want to change in a Dired buffer and call dired-do-replace-regexp-as-diff to generate a diff for them all.

Batsov speculates that in the age of AI, people won’t be as interested in this type of command. I disagree strongly. It’s useful not only for coding but for writing pose or any other text-based file that you might want to edit.

If you’re an Emacs user, I urge you to take a look at Batsov’s post. It’s about a really useful new(ish) feature of Emacs that you can probably make good use of.

Posted in General | Tagged | Leave a comment

Emacs For Game Development

Over at the Emacs subreddit, alraban tells a nice story about game development with Emacs. The TL;DR is that it’s amazingly good. Alraban isn’t a professional developer but has been a hobbyist since the 80s. He has, several times, tried to write a game but never made anything he felt was performant enough to ship.

Recently he decided to try again. He used the Godot engine because he wanted to work with FOSS tools but he didn’t like the builtin editor or GUI so as a long time Emacs user, he thought he’d give Emacs a try.

Airaban was amazed at how good the experience was. The amazement wasn’t that you could develop games in Emacs—of course you can; people are doing it everyday—but at how good the tooling was and at how smooth and delightful the process was. Even as a long term user who “pretty much live[d] in Emacs” he was surprised at how much tooling there was available and how good it was. As he puts it,

It was like starting a home improvement project I’d never done before, and discovering that I already had all the tools I needed in the basement.

Most of us are pretty familiar with the Emacs tooling associated with our normal tasks. The takeaway from airaban’s post is that you’re apt to be surprised at what’s available when you move to a new task.

This is a short post and only takes a couple of minutes to read. It’s well worth your time.

Posted in General | Tagged | Leave a comment

Harp: A Private Health Records App

Abhinav Tushar likes to curate what he calls macro health data. That means things like ailments, aches and pains, and other symptoms one might want to mention to the doctor during an appointment. After researching the currently available apps, he realized there was nothing that met his needs so he decided to roll his own. The result is Harp, an Android app that should soon be available on the Play Store. It’s also available for free on Fdroid. You can also checkout the source at Sourcehut. Finally, you can find out more about Harp here.

Like my favorite app Journelly, Tushar decided to keep his data in Org Mode. That, of course, brings the immediate benefit of making the data viewable and editable in Emacs or any other editor for that matter. It’s one of the reasons I’m so fond of Journelly. A couple more apps like these and we could see Org markup evolve into a sort of universal app data storage language.

Right now, only an Android version of Harp exists but his near term plans include an iOS version. That good news for those of us in the Apple camp. The main difficulty appears to be navigating the Apple App Store submission maze, which is well known for its opaque rules.

Take a look at Tushar’s post for some more of his short term goals. It looks like a handy app—and, of course, one that keeps its data in Org mode—so it’s definitely worth trying out. I’ll probably give it a try when the iOS version appears and will let you know what I think of it then.

Posted in General | Tagged , | Leave a comment

Emacs Internals Part 1

Yi-Ping Pan has an interesting post that recapitulates one of my favorite hobby horses: Emacs is actually a modern day Lisp Machine that happens to ship with an embedded editor. Pan kept trying other editors but always returned to Emacs. Finally, he stopped treating it as merely a tool and started reading the C source code. What he discovered is what I’ve been preaching for years: Emacs is actually a C-based Lisp interpreter with an embedded text editor.

Pan’s post—the first in a series about Emacs internals—recounts how Emacs grew from a set of TECO macros to a stand alone application built on its own Lisp interpreter. Other editors have tried to recreate this magic but they have all failed because of Greenspun’s Tenth Rule:

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

Emacs, on the other hand, started with an actual Lisp interpreter and layered a text editor on top of that interpreter. That enables the magic. It’s possible to modify any particular editor function simply by rewriting it in Elisp and adding it to your configuration. Similarly, you can write your own editing—or even general purpose—functions and add them to the Emacs runtime simply by adding them to your configuration.

Pan announced his post over at the Emacs subreddit and, as usual, the comments are instructive. To me, the most interesting comments lamented that Lisp was never able “to fix” the parenthesis problem. I have to admit that it makes me grumpy every time I see someone complaining about parentheses in Lisp. To me, it’s one of Lisp’s successes, not one of its failures. That’s why the planned m-expressions using a more conventional syntax never caught on. Lispers like and prefer s-expressions.

In any event, Pan’s post is worth a couple of minutes of your time. Head over and take a look.

Posted in General | Tagged | Leave a comment

A Unix/Emacs Blast From The Past

Although many of us won’t admit it, we all enjoy a bit of nostalgia. Here’s some from 20 to 25 years ago. Kids today™, they don’t know how good they have it. There’s a tendency to romance the “powerful” workstations from the turn of the century. I do the same thing with the Lisp Machines but I was there for those turn-of-the-century workstations and I can tell you from first hand experience that someone sitting in front of a run-of-the-mill laptop running Linux, FreeBSD , or even macOS is having a much better Unix/Emacs experience than the folks sitting in front of one of those old workstations had.

Nevertheless, nostalgia is strong and many would like to experience what it was like. Victor Larios is offering a trip on the tech time machine to experience what it was like back then. The “time machine” consists is a browser based recreation of the Common Desktop Environment (CDE) complete with the then popular XEmacs.

XEmacs was popular then mainly because Gnu Emacs was dragging its feet on adapting to the X Window system and it offered a better experience. I was a Vim user in those days so I can’t speak to its relative merits but all my Emacs-using colleagues were running it. GNU Emacs eventually caught up and surpassed the XEmacs implementation so XEmacs has pretty much faded into oblivion but it was state of the art back then.

In any event, if you sometimes have nostalgia pangs about the “old days” and would like to see was it was like, here’s an easy way to scratch the itch.

Posted in General | Tagged , | Leave a comment