Crazy Mode

As a follow on to my discussions of Mickey’s posts about Hippie Expand and abbrev, Mohammed Sadiq has a post on his Crazy Mode project. It’s another completion framework that is aimed at providing efficient shortcuts when you’re coding.

Take a look at the Sadiq’s post for some examples. Again, these are substitutions that happen automatically so, if you’re like me, you might not embrace the package but if you don’t mind your editor making changes to your input automatically, it looks like it could be a really useful addition to your toolkit.

Currently, crazy mode is mostly useful for C and C-like languages so it’s not universally applicable but if you write in one of those languages, it should help make your coding a bit more efficient.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Ties

This is barely Red Meat Friday material because almost everyone here will agree with it and find it noncontroversial. Nonetheless, the minions assure me that there are plenty of suits in our industry who will object strenuously.

The issue is neckties. Stephen Johnson over at LifeHacker says it’s time to Throw Your Neckties in the Damn Garbage Already. It’s hard to take his arguments about the health risks seriously but most of us will be onboard emotionally.

Oddly, the comments were almost universally dismissive of the post. It’s inarguable that ties are an anachronistic fashion accessory that serves no real purpose but people seem have an intense sentimental attachment to them. It’s not unlike those who insist on torturing our children by making them learn the now useless cursive writing system except they want to torture adults instead of children.

I haven’t worn a tie in years and have no plans to wear one in the future. For those occasions that require a suit, I generally wear a turtleneck with the suit and no one seems to mind. I suppose if I attended an event requiring a Tuxedo, I’d swallow my good sense and wear a (gasp) bow tie but that’s the only exception I can think of.

Tie wearers are sure to look down on us refuseniks as a bunch of rubes but, really, who’s acting irrationally?

Posted in General | Tagged | Leave a comment

Leslie Lamport

Most of you probably know Leslie Lamport as the original author of LaTeX but within the computer science community, he’s mostly known for his work on distributed systems. Like Knuth, Lamport was trained as a mathematician but rather than pursue a career in the analysis of algorithms, Lamport devoted himself to solving problems he found in industry.

In this short video, Lamport talks about his approach to computer science and some of the interesting problems he solved. Interestingly, he stumbled onto the thing he’s best know for, distributed computing, by accident. He received a paper on distributed databases and realized that relativity theory—yes, really—could be brought to bear to show the proposed algorithm was wrong. Until he wrote the paper explaining his findings, he says, he had never thought about distributed systems.

Lamport’s career is an inspiring example to those who want to pursue a career in computer science research but aren’t interested in being an academic. His entire career has been spent in industry but he’s authored almost 200 papers in computer science.

The Bakery Algorithm that Lamport mentions in the video is available here. It’s short and easy to read for those interested. Lamport says he didn’t design the algorithm to be as robust as it is but discovered how effective it is when he devised the proof of its correctness.

It’s an interesting video and only 7 minutes, 49 seconds long so you should definitely spend the time to watch it.

Posted in General | Tagged | Leave a comment

Emacs, Xwidgets, and macOS

As I’ve written many times, the only non-Emacs application that gets any significant use on my computer is Safari. If I could find a way of putting Safari’s functionality into Emacs, I’d be very close to never having to leave Emacs. I still use iMessage for texting, the excellent RadarScope for tracking the weather in real time (a surprisingly important capability when you live in Florida), Contacts for my address book, and a few other seldomly used applications but almost all my tube time is spent in Emacs and Safari.

The answer to this has been known for a long time. Way back in 2016, I wrote about using Xwidgets to embed WebKit in Emacs. Six and a half years later, I still haven’t done anything about it—the very definition of a slacker. Comes now Aimé Bertrand with a post on Using Emacs support for Xwidgets on macOS to shame me further. The post explains how to use WebKit for things like mail (with Mu4e) and browsing. If you’re an Emacs/macOS user, be sure to take a look.

If you’re using one of the precompiled Emacs distributions, you may already have Xwidgets installed. The easy way to find out is to run xwidget-webkit-browse-url. If that succeeds, you should be good to go. If it fails with a message about Emacs not being compiled with Xwidgets support, you will need to recompile Emacs with Xwidgets specified. See this Emacs Wiki page for details but it’s pretty simple.

So now I have two things to feel guilty about: not compiling Emacs with Xwidgets support and not compiling Emacs with native compilation support. I intend to remedy both of these shortly. No, really.

Posted in General | Tagged | Leave a comment

Too Many Open Files

Ben Simon has a post about a problem that can come up with Emacs running on macOS. The problem is that Emacs will report “too many open files” when attempting to open a file. It turned out to be a hard problem to solve.

Simon tried all sorts of ways to increase the limit of open files but nothing worked. Finally, he discovered a post by another person suffering from the problem. It turns out that you can run file-notify-rm-all-watches to inhibit the error. That seemed easy enough but when he tried, he found that the function didn’t exist. After some Googling, he found the code for the function and added it to his configuration. After that, he could recover from the error by simply running the function.

I’m running the latest official release (28.1) and file-notify-rm-all-watches isn’t defined for my Emacs either. It is, however, in the latest version of filenotify.el that has been merged into the Emacs28 branch of the git repository. Doubtless, it will be available in the next release. In the meantime, you can simply add it yourself as Simon did. It’s only 7 lines so it’s an easy addition.

I’ve never encountered this error and that’s probably true for most of you. If you have encountered it, this fix is much easier than having to restart Emacs.

Posted in General | Tagged | Leave a comment

A Million Words

The other day I wondered how many words I’ve written for Irreal. All my posts exist as org files in my ~/org/blog directory so a reasonable estimation can be had by

cd ~/org/blog
cat *.org | wc -w
1040421

Over a million words! Irreal is almost 13 years old so this is not too surprising but to me it seems astounding. If I’d thought about it back when I was in high school, I probably wouldn’t have estimated that my total lifetime output would exceed 100,000 words.

Let’s see how many posts that is:

ls -1 *.org | wc -l

I’ve written 4308 posts so the average post is 241 words long. That means that a few words written everyday for 13 years adds up to a lot. I’m going to go take a nap.

Posted in Blogging | Tagged | Leave a comment

Using Abbrev to Autocorrect

In his post on hippie expand, Mickey Petersen mentioned the abbrev command and its utility as a way of making on-the-fly corrections to common typos and misspellings. I really, really hate having my editor or any input device automatically make corrections but lots of people swear by it. It’s easy to see why. If you commonly type “mroe” for “more” it’s convenient to have the correction made automatically. With Emacs, it is, of course, easy to arrange that.

Mickey has a new post on Correcting Typos and Misspellings with Abbrev. In that post he outlines how he uses abbrev to create and maintain a list of corrections that are automatically applied as he types. In the hippie expand post he mentioned that he grabbed a list of common misspellings and typos from Wikipedia and converted it to a set of abbrev entries. In the comments to that post he was asked to expand on this and his current post is largely devoted to his explanation.

He gives a link to the Wikipedia list and then explains how he converted it to abbrev entries. You won’t be surprised to learn that the conversion involved a keyboard macro. It is, in any event, a simple process and when you’re done you have a list of words to be automatically corrected.

If you like this sort of thing, you should definitely spend a few minutes to read Mickey’s post. Abbrev mode is just one of Emacs’ expansion mechanisms but it serves an important niche for many people and is definitely worth knowing about.

Posted in General | Tagged | Leave a comment

Looping Through Org Headings

I’ve got several functions that do some sort of processing on Org files. Many of them were written years ago when I was just starting with Org-mode and as a result, they often take a naive approach to, say, locating Org top level headers. My typical solution was to do a regular expression search on something like ^\\*[ *].

There are, of course, better ways and Kaushal Modi over at A Scripter’s Notes shows us one of them. If you want to loop through all Org headers and do something to each entry, Org has a function just for that, org-map-entries. This mapping function will loop through each Org entry and call a function (with no arguments) that can assume the point is at the beginning of the heading.

You can filter the entries to look at by things such as tags, properties, or the level of the header. You can filter on the absence or presence of a tag or tags, or for any tags or properties satisfying a regular expression.

Modi ends his post with an example of adding a property to each heading. The org-map-entries function is versatile and useful and makes dealing with Org files programmatically a bit easier. If you do any Elisp programming involving Org files, be sure to take a look at Modi’s post.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: Managers and Technical Expertise

Some people like to pretend that Elon Musk is naive and not very bright. You can love him or hate him but that characterization is just silly. Besides being the richest man in the world (all of which he earned) he is the founder, CEO, and chief engineer of SpaceX and its offshoot Starlink, the CEO and product architect of Tesla, founder of The Boring Company and a cofounder of Neuralink.

But for those of us in the software development business, the proof of his brilliance is this tweet:

Just think of how much better all our lives would be if that precept were universally applied.

Posted in General | Tagged | Leave a comment

Emacs Completion Mechanisms

In a nice followup to yesterday’s post on Hippie Expand, deltille asks for clarification on the Emacs’ completion methods. His post was in response to Mickey’s article about hippie expand. Detille is a new Emacs user and is confused about when to use the various expansion Emacs mechanisms—there’s a lot of them—for completion.

Mickey jumps in with an excellent overview of the various methods and why you might want to use one or the other. To my mind, there’s a pretty bright line. If you want syntax-aware editing mediated by an LSP process then you should use completion-at-point or whatever your LSP package uses. If, like me, you’re mainly concerned with just minimizing typing, hippie-expand is the best bet. You can configure it to sequentially try any of the other methods. I use it many times a day and love it.

That leaves templates. If you want to expand a keyword into some text, perhaps with substitutions, then Yasnippet is a very nice solution. Mickey has some other recommendations but unless you have some special needs, Yasnippet is a good answer.

If, like many people, you’re confused by the plethora of completion/expander methods, take a look at this reddit post and Mickey’s answer.

Posted in General | Tagged | Leave a comment