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

Hippie Expand

Over at Mastering Emacs, Mickey has a nice post on one of Emacs’ hidden gems: hippie expand. The odd thing is that although it is the most capable expander built into Emacs, it does not have a default binding. As Mickey points out, its much less versatile cousin, dynamic abbrev does have a binding but hippie expand does everything it does so there’s no reason to bother with it.

Mickey suggests remapping the binding for dynamic abbrev to hippie expand since it’s unlikely Emacs will ever change the current default. Of course, that’s part of the power of Emacs: you don’t have to put up with the way things are; you can change them to suit yourself.

I’ve been using hippie expand for years and have it bound to Meta+Tab, which seems natural to me for a completion mechanism. Dynamic abbrev is bound to Meta+/, which isn’t as natural but may be easier to type. After reading Mickey’s post I’m going to remap Meta+/ to hippie expand and see if I like it. Of course, Meta+Tab is burned into my muscle memory so I’ll probably forget to use it.

In any event, be sure to take a couple of minutes to read Mickey’s post. As usual it’s well written, informative, and well worth your time.

Posted in General | Tagged | Leave a comment

The NSA, Ciphers, and Backdoors

For many years, we’ve been living in a sort of golden age of digital encryption. This is no longer of interest just to the military or other federal agencies that want to secure their data. Indeed, our economy depends upon encryption to secure everything from our routine banking and credit card transactions to keeping our texts and browsing secure.

Sadly, most of the encryption methods are reaching their end of life. The problem is quantum computing, which makes brute forcing these methods practical. The good news is that new methods that are resistant to quantum computer attacks are being developed and will shortly be deployed.

The standardization of these new methods is being handled by the National Institute of Standards and Technology (NIST) but, of course, all the real expertise resides at the NSA, which is involved with new standards. The problem is that no one trusts the NSA to not weaken the methods or arrange for a backdoor that they can use to spy on our communications.

The NSA has no one but themselves to blame. There have been several documented cases of the NSA trying to sneak backdoors into both national and private crypto primitives. This time, though, the NSA is crossing its heart and promising not to put any backdoors into the new standards. The demurrals are being met with substantial skepticism.

One doesn’t have to be overly cynical to be suspicious. The NSA, after all, does have a history of doing exactly what people are suspecting them of doing. On the other hand, they are, sometimes, honest brokers. Back in the early 1970s when DES was being developed, the NSA suggested some mysterious and unexplained changes to the S-boxes at the heart of the method. People were very suspicious but a couple of decades later it was revealed that those changes were, in fact, to harden DES against the still secret differential cryptanalysis method for breaking ciphers.

Things are different now. The NSA no longer has an (American) monopoly on cryptographic knowledge and techniques. Whatever they propose will be put under the microscope and it’s unlikely those doing the investigations will keep their findings secret.

Posted in General | Tagged | Leave a comment