Casual RE-Builder Improved

I recently wrote about Casual RE Builder, one of Charles Choi’s Casual Suite apps. As I wrote then, it goes a long ways towards making RE-builder usable for those of us who can’t remember all the commands necessary to export the resulting regex to a useful place.

While he was working on Casual RE-builder, Choi discovered that sometimes—usually in the Dired subsystem—Emacs expects “grep-like” regular expressions rather than the Emacs style. This is undoubtedly because Emacs outsources certain tasks to external grep routines. The fact that the particular regexp subset used depends on what flavor of grep you have installed makes things even more complicated. If you’re like me, all of this is news to you. Somehow, I’ve managed to stumble through using Dired without realizing that it was pulling a bait-and-switch on me.

Regardless, Choi has come to the rescue. He’s changed Casual RE-builder to add an option to export the regexps from RE-builder in grep format. It’s a small thing but it makes Casual RE-builder even more useful.

I’ve already installed Casual RE-builder and presumably I’ll get Choi’s latest changes with my next update. This is, I say again, a really useful package and if you use regexps at all in Emacs, you should take a look at it.

Posted in General | Tagged | Leave a comment

A Blast From The Past: Stderr

I’ve written about this before but that was 9 years ago and it’s a great story so perhaps a reprise is due. The story is about the birth of stderr. As I wrote last time, the concept seems so natural and necessary that it’s hard to believe that it wasn’t invented at the same time as stdout but it wasn’t.

In these days of cheap laser printers that just about anyone can afford, it’s hard to comprehend how difficult and messy things were when the Unix typesetting program, troff, was written. In those days, the C/A/T typesetter—the machine that did the actual typesetting—was a washing machine sized device that was driven by a separate computer. Unlike today’s printers, the C/A/T didn’t produce finished copy. Rather it produced a film that had to be developed separately to produce a hard copy.

Given all this, those early users wanted to limit errors as much as possible so they could avoid repeating this messy and difficult process. Then one day, several users got a printout saying that such and such a file couldn’t be opened. A couple of days later, after grumbling to the appropriate people, stderr was introduced so that errors would be delivered on a different channel.

I love this story because it not only tells us the history of one of the fundamental Unix mechanisms but also gives us an idea of what the early days of computer typesetting were like.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: Roundabouts

I grew up on the South Shore of Massachusetts and as far as I knew there was only one roundabout (Massachusetts calls them rotaries) in the world. It was on Cape Code and although I never thought much about it as a child, once I started driving, approaching it always raised my stress level. I really hated it and always thought that this time I was going to get into a crash trying to maneuver through it.

As most of you know, I now live in Florida and I have discovered that roundabouts are more common than I thought. My impression is that they’re even more ubiquitous in Europe but, of course, I have no direct experience. One thing I know for sure: I don’t like them.

I am not, it appears, alone in my hatred of them. As Andy Boenau says at the link, there are few things that unite people as much as their dislike of roundabouts. Still, he says, they are the safest way of routing traffic flow through intersections. He’s got the statistics to prove it but as he says, no one wants to hear about it. They (we) are all united in our hatred of roundabouts and nothing seems able to convince us otherwise.

Traffic engineers claim that, among other things, they slow traffic down and thus make it safer than, say, intersections controlled by traffic lights. Bah! My experience has been that what actually happens is that cars speed up so that someone entering the roundabout can’t get in front of them.

None of that matters. It appears that despite near universal disapprobation, traffic engineers are intent on foisting these monstrosities on us. There is little that you or I can do to stop the madness but at least I feel better after ranting about it.

Posted in General | Tagged | Leave a comment

Learn Vim or Emacs

Kris Brandow has a (very) short video—I think it’s part of a podcast—advancing the idea that you should learn Vim or Emacs. Irreal, of course, is not going to argue with that but I wish he’d given more reasons why you should. What he does say is that you’ll discover you can be more productive with Vim or Emacs than you can with an IDE but doesn’t explain why that is. You should, he says, just try them.

One of the other people on the video objected that you don’t “just try” Emacs. It’s a commitment that takes dedication and effort to learn. That is certainly true of Emacs as we all know but it’s true of Vim as well. It’s not as hard to master as Emacs but there’s a surprising amount to know before you can consider yourself to have mastered it. That’s the problem with saying, “Just try it.” You won’t see real benefits from either editor until you’ve put a some time and effort into learning them.

The most depressing thing about the video is that Brandow described his suggestion as an “unpopular opinion”. I suppose that it might be unpopular among a certain segment of our community but there are also those who think that Javascript is a great, well thought out programming language. Ours is nothing if not a vibrant community with a diversity of opinion.

Posted in General | Tagged | Leave a comment

Gluing Emacs Features Together

Álvaro Ramírez has a very revealing post about the compounding benefits of learning a bit of Elisp. Studying how Emacs works and learning its various features pays huge dividends but, says Ramírez, learning some Elisp can compound those dividends and enable you to mold Emacs to a tool hyperspecialized to your needs.

He starts by postulating two features that you realize would be even more useful if you could somehow combine them. Then he gives a specific example. He considers the two packages symbol-overlay and multiple-cursors. The symbol-overlay package highlights all occurrences of the symbol under point in the current buffer and, of course, multiple-cursors lets you perform the same operation in multiple places at the same time.

He uses them both all the time but realized that it would be very handy if he could invoke multiple-cursors with a cursor on each occurrence of the symbol under point. He needed, in short, to combine the action of symbol-overlay and multiple-cursors.

That turns out to be fairly easy if you know some Elisp. Ramírez walks us through how he figured out how to do it and shows the Elisp that does it. There’s not a lot of code (about 20 lines), it’s easy to understand, and it serves as a great example of how a bit of Elisp can work magic. Finally, he made an animated GIF that shows it in action.

This is a nice post and it provides some code that you may find useful for your own workflow. Take a few minutes to give it a look.

Posted in General | Tagged | Leave a comment

Casual RE Builder

Charles Choi has another great addition to his Casual Suite. This time it’s an interface to the re-builder command. There are two things that everyone agrees about Emacs regular expressions:

  1. They’re very powerful and useful
  2. They have an arcane syntax and are hard to use

Well really, they’re not that much different from other RE syntaxes but there is enough difference to make using them harder than it should be. Indeed, many folks who everyone would agree are master Emacs users constantly bemoan the RE syntax and wish it were replaced with something else such as Perl Compatible REs.

Happily, there’s a tool, re-builder, that can help. I’ve written about it here and here. Unhappily, I find it really hard to use. Finding a good regexp is easy enough but it’s hard to remember how to export that regexp for use in your code or the current command.

That’s where Choi’s Casual RE-builder comes in. Like other members of the Casual Suite, when you need to remember some of the arcane commands, you can simply invoke a handy transient menu to remind you.

As much as I like re-builder, I almost never use it because I can never remember how to export the resulting regexp to where I need it. Choi’s RE-builder solves this problem and, to my mind, increases the utility of re-builder a great deal.

If you have troubles with Emacs regexs or have found re-builder too hard to use, you should take a look at Choi’s RE-builder app.

Posted in General | Tagged | Leave a comment

Relative Line Numbers

Just a quickie from something that I’ve had in the queue for a while. Chris Maiorana has a short post on relative line numbers. The idea is that the current line—the line you’re on—is considered line 0 and the lines above and below it are labeled as the number of lines away from the current line.

That’s handy if you’re interested in, say, 5 lines above or below the current line because they’re labeled as that. I love the idea but, truth to tell, I have never found a compelling use case for them. Maiorana says it handy for authors who want to know how many lines there are in the current paragraph but offers no other reason to adopt them.

Still, lots of people seem to like them and they’re certainly easy to turn on. Take a look at Maiorana’s post for the details.

Posted in General | Tagged | Leave a comment

A Spelling Transient

Over at DyerDwelling there’s another nice example of using a transient menu to capture the keystrokes for a set of packages. This time it’s for some spelling related packages. The author couldn’t make up his mind on what keystrokes he wanted for the various commands so he decided to implement a menu instead.

If you’ve been reading Irreal lately, you know that I’m a big fan of this approach, especially as realized by Charles Chou’s Casual Suite. Nonetheless, I’m not sure that a menu is the best solution here. At least not for commands that do things like correct the last misspelling. I use commands like that constantly and want them instantly available without having to wade through a menu.

Still, we can have it both ways. There’s no reason to restrict yourself to one approach. You can have a menu as described in the DyerDwelling post and still specify keybindings for the commands you use all the time. And to be fair, you can also think of the sequence to invoke the menu and the option choice as a single, slightly longer, key sequence.

I’m again impressed at how easy it is to set up a transient menu. Take a look at the code in the DyerDwelling post to see for yourself.

Posted in General | Tagged | Leave a comment

Org Template Fundamentals

Forward

Does anyone know what happened to Emacs Elements? As I was getting ready to publish this post, I notices that the below linked video was gone and that Google said it had been deleted by the author. On further investigation, I see that the entire playlist is gone.

I did find this post on the Emacs subreddit but it doesn’t have any information: just others wondering what happened to the site, and mourning its loss. If you know anything, please leave a comment.

My original post is below but, of course, none of the links lead anywhere interesting.

Original Post

Emacs Elements has a nice video up on Org mode capture templates. This video concentrates on the structure and meaning of the templates.

Org templates are one of the most useful ways of using Org to capture and record various types of data. I use them to capture tax, health, journal, TODO, email, and blogging data. They’re easy to adapt for capturing data in several formats and to annotate the captured information.

Building the templates is a bit fussy and you have to get them just right or they won’t work. That said, they have a reasonable format and aren’t too hard to learn. Even if you don’t want to build them yourself you can still use the Emacs configure subsystem.

The video is relatively short—7 minutes, 37 seconds—so there’s no point in recapitulating it here. Spend a few minutes with it to find out the sorts of things that are possible and use the excellent Org documentation to fill in any blanks.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: Is C Useful For Understanding How Computers Work

This post didn’t start as a Red Meat Friday item but as I worked on it, I got so exercised I decided it really should be one. For me, the question of whether C helps with understanding how computers work always evokes the response, “Well, Duh! Of course. Why are you even asking?” Anyone who has actually programmed in C—programmed, not just written hello_world.c or other such toy programs—will have the same response.

Negative responses mostly come from users of languages like Python, Java, Ruby, or one of the many other higher level languages that abstract away all of the low level details of what’s actually going on in the hardware. These people invariably argue that, really, C isn’t a low level language either because it doesn’t address such low level details as pipelining or speculative execution. Those arguments merely prove that these people have no idea what they’re talking about. No programming language addresses those issues. C is a low-level programming language because it maps reasonably well to the assembly language of a generalized model of a machine with registers, a stack, and a flat memory model. Even X86 CPUs in real mode can be represented by that model so it’s a useful concept.

Yet the question gets asked over and over again and the comments invariably bring up the same silliness. A huge amount of useful code gets written in Python and the other higher order languages so programmers who write only in those languages are by no means a lesser breed but it’s certainly true that most of them probably have no more idea of what’s going on under the hood than the average homemaker has about the physics of cooking. Both produce useful results but it’s silly to believe that their understanding of the underlying processes is as good as that of professional chefs or C programmers.

The TL;DR is that you can be a great programmer who sticks to, say, Python and produce extraordinary useful programs but if you only know Python, you probably don’t have much idea of how computers work. If you want to find out, programming in C is a good way to do that.

Posted in General, Programming | Tagged , | Leave a comment