Reinstall Packages

Someone posted a link to an old Bozhidar Batsov post that discusses a nifty little function that automates a simple but annoying manual process. Those of you who use package.el or the use-package macro are probably familiar with the problem. You update a package but it doesn’t load or work correctly. Usually, this is the result of byte compilation problems.

The answer is to uninstall the package and then install it again. It’s not hard but it is a pain. Batsov’s solution is to simply capture the process in a small function. The whole thing amounts to:

  1. Unloading the package
  2. Reinstalling the package
  3. Requiring the package

To make things really easy, he also has an interactive version that does a completing read to specify the package to reinstall. The completing read is populated with the complete package list so it’s easy to get the name right.

If you handle your packages with package.el you should definitely take a look at Batsov’s post. It’s short and easy to read and it’s also easy to just copy his code and insert it right into your init.el.

Posted in General | Tagged | Leave a comment

Lab Notebooks

I love the idea of lab notebooks. I was trained in the sciences but that training was in Mathematics so the idea of lab notebooks didn’t play much of a role. In the experimental sciences and most engineering disciplines, they are not merely crucial but required. If questions arise as to the provenance or precedence of some idea, the lab notebook can be a lifesaver.

When I worked for a computer manufacturer, even the field engineers were required to keep lab notebooks and to turn them in if they left. A crucial aspect of such notebooks is forensics but they can be much more.

Sam Bleckley has a nice post on lab notebooks and why they can be helpful even for software developers. He a software developer but nonetheless keeps a lab notebook for each client. Forensics and proof of precedence are part of that, of course, but as he points out we often try solutions that don’t work out and those experiments aren’t committed anywhere so other developers or our future selves won’t have access to that information and are apt to repeat the failed experiment. By keeping a lab notebook, that information is captured and made available when needed in the future.

I agree with all that but to tell the truth, the thing I liked most about Bleckley’s post is his link to Vela Labnotebooks. These are really beautiful notebooks and have things like numbered pages, a table of contents, and other amenities that make capturing your work easy. I much prefer to keep a digital notebook but for forensic reasons that isn’t always possible. When it isn’t, these Vela notebooks are a great solution.

Posted in General | Tagged | Leave a comment

Hiding Files From Dired Display

Emacs Elements has a short video that explains something I didn’t know. You can tell Dired to not display certain files. My first thought was, “Why would I want that?” After all, if you have a file you probably want to know it’s there when you list a directory.

The justification from the video is that Emacs Elements main computer runs Windows and that OS adds a lot of files and directories whose purpose you may not even know. I was in the middle of feeling sorry for Windows users when I realized that macOS does the same thing and, sure enough, I don’t know what many of them are for.

My mental firmware automatically filters them out so I’m barely aware of them but if the idea of all these files that you never interact with bothers you and you’re a Dired user, the answer is simple. You simply add the file you want to omit to the dired-omit-files variable. It’s a regular expression so you can add file patterns if you need to. On my Emacs, it’s already set to omit ., .., auto-save files, and lock files.

The variable has effect only when dired-omit-mode is t. If you really want to see everything in the buffer you can toggle the hiding with Ctrl+x Meta+o.

The video is only 3 minutes, 34 seconds so you’ll have no problem fitting it in. The problem it describes is a small thing but there’s no reason to clutter up your directory listings and your mind with junk you don’t care about.

Posted in General | Tagged | Leave a comment

Quick Accents

As I mentioned previously, I’m learning Spanish so worrying about accented characters has become a way of life. The above post talks about one of Prot’s videos that discusses how to change the input method for Emacs only rather than at the system level. That’s important because changing the system keyboard can interfere with what Emacs is expecting.

Sometimes, though, you want to enter a single accented character such as with résumé or piña colada in otherwise normal English text. Chris Maiorana has just the thing for this. He has both a post and a video that explains how to do it. They’re definitely worth your attention even if you never need to write in anything besides English. The TL;DR is that you call insert-char and ask for the non-spacing accent mark. Watch the video to see all the details. It’s only 3 minutes and 12 seconds so you slip it in at almost any time.

There are a couple of things worth mentioning about his method:

  1. You don’t need to highlight the character you want to accent. Just put the point immediately after it. That makes it easy to put in the accents as you type.
  2. Rather than using Meta+x insert-char you can simply use Ctrl+x 8 Return and then type the accent you want.

I wish I had known about this method earlier. I always did it by looking up the accented char itself rather than simply adding the accent to whatever character I needed.

Posted in General | Tagged | Leave a comment

Emacs 29.2

Good news from Eli Zaretskii. In a post to the Emacs Devel list he announced that Emacs 29.2 has been released and is ready for downloading. It’s a maintenance release that fixes some bugs but there are no new features. You can read all about the changes in the change logs.

As usual, our greatest thanks to Eli and the other developers who work so hard and selflessly to bring us these updates. They get plenty of abuse but never enough gratitude for their efforts.

Posted in General | Tagged | Leave a comment

Zamansky: Learning Elisp #16

Mike Zamansky is back after the holidays with another video on learning Elisp. This video starts a new project on using Web APIs in an Elisp application. Specifically, the purpose of the project is to implement an interactive thesaurus that you can use while writing in Emacs.

The basic plan is to leverage the Merriam-Webster dictionary API to map a word into its synonyms. The API is free to use but you need to register and get a key first. Once you have the key, you need merely query the API with the word you want synonyms for and your key. The answer comes back as a complex JSON structure that must be parsed to get the answer.

Zamansky’s plan is to first get the JSON structure and then to process it. This video considers the first part of the plan. That turns out to be pretty easy. You make the query and receive the answer with url-retrieve-synchronously. The only problem is that url-retrieve-synchronously puts the answer in a separate buffer so you need to use with-current-buffer to extract the JSON from the temporary buffer that url-retrieve-synchronously creates.

The whole thing takes a function that is only 9 lines of Elisp. That’s a lot of processing for just a few lines of code and is a great example of how concise Elisp—and indeed, any Lisp—can be in expressing an algorithm.

The next video will consider processing the JSON to extract the synonyms and replace the target word with one of them. The current video is 21 minutes, 16 seconds so you’ll definitely need to set some time aside for it but as usual with Zamansky’s videos, it’s a worthwhile investment.

Posted in General | Tagged , | Leave a comment

Another C Failure

As a sort of coda to yesterday’s post on the errors in the C code running the Toyota acceleration system, here’s another example of a spectacular failure in C code that resulted in huge losses for AT&T, caused loss of service for many phone users, and even caused the delay of hundreds of airlines flights.

What’s different in this incident was that it happened at AT&T where C was invented and where there were serious testing protocols in place. Nevertheless, a single misplaced break in a switch statement caused a cascade of errors that brought down a significant portion of the AT&T switching system. The first level of remediation was to fall back to the previous version of the switching software. That happened relatively quickly (about 9 hours) but it took much longer for the engineers to figure out what happened and where the error was. That took about 2 weeks.

The point here is not to feed the anti-C trolls or to stump for Rust, Ada, or any other supposed “safe” language. Rather, it’s to underline the well known fact that even with first class engineers, any large program—regardless of what language it’s written in—will inevitably have errors and some of them will be corner cases that are hard to test for.

The real surprise here is how few such incidents AT&T experienced. Their testing and review processes really did make a difference but nothing can prevent all errors.

Posted in General | Tagged | Leave a comment

A Fatal C Error

If you’ve been around Irreal for a while, you know that I spent the majority of my software career writing C code. I love C and don’t have a lot of patience for snark about it from those who have never bothered to master it or even use it non-trivially.

Still, I can promise you that given 500,000 lines of C you’re going to find errors. Probably lots of them. Who would want to put their safety or even their lives in the care of such a monster? Yet that’s exactly what we all do everyday. Modern automobiles are run almost entirely by computers running probably millions of lines of code. If you’re a software developer, this should terrify you.

Here’s a case in point. Toyota’s cars have—or at least had—an acceleration system run by over 500,000 lines of C code. After more than a decade of “sudden unintended acceleration” incidents and several recalls in which Toyota blamed floor mats getting stuck under the accelerators, one victim hired a couple of embedded system engineers to examine the code. Toyota, of course, vigorously objected but the review took splace anyway. I’ll let you watch the video to see what they found.

In some ways, the video is an advertisement for Rust. At the end, the narrator says that these problems could be ameliorated by using a “safe” language like Rust. Those of us who have been around for a while know there’s no such thing. On the other hand, C probably isn’t the best choice for this sort of application.

NASA famously uses C safely but they have an extraordinarily comprehensive review and testing process and very strict coding standards. No automobile manufacturer is going to—or probably could afford to—run a similar program. It makes you yearn for the old days of mechanical interfaces.

It’s an interesting video. It’s 10 minutes, 6 seconds long so it should be easy to fit in.

Posted in General | Tagged | Leave a comment

Prot On Mode Line Colors

I said that I was over writing about marking the active window and changing mode line colors, but, as they say, never say never. If all you want to do is change the color of the active mode line to something that stands out more than the default slightly darker gray, all you need to do is follow Ignacio Paz Posse’s advice that I described previously.

But if you want to understand what’s really going on, Prot has new video that explores mode line colors in depth. Part of the video is about how to work with his custom themes but most of it is applicable to any—or no—theme.

The video has some really useful information such as how to get a color palette of all the themes installed on your system and how to get a palette of all available colors so you can choose whatever appeals to you. He also explains the difference between the set-face-attribute command, which I used to change my mode line color, and the related custom-set-faces command which is similar but sets colors that aren’t overridden by a change of theme. See the video for more on this and how it works.

The video is just over 34 minutes so you’ll need to set some time aside but it packs a lot of information into those 34 minutes so if you have any interest in adjusting your mode line colors, it’s a must see.

Posted in General | Tagged | Leave a comment

Browsing In Emacs

Norman Walsh has an interesting post in which he discusses discovering browsing in Emacs. More specifically, he discovered how to follow a link in an Email and have the result displayed in Emacs. He’s using WebKit with Xwidgets so that means more than just using EWW.

In his setup, which judging from the screenshot is on a Mac, typing return on a link in an email renders the link in HTML in the Emacs buffer. He doesn’t say what email client he’s using but with mu4e, which I use, that doesn’t happen. Rather, the link opens in the browser. At first I thought that I must have some sort of configuration item causing the difference but I couldn’t find anything. In any event, it doesn’t matter for mu4e because if it detects you have Xwidgets installed it will automatically include a binding (ax) to render the email in HTML. From there, you can follow any other links by clicking on them.

That’s pretty nice, but it gets better. I also have elfeed-webkit installed so that I can read my elfeed RSS entries in HTML as well. What actually happens is that elfeed-webkit follows the source link in the RSS and renders it in HTML. You can configure it to automatically include or exclude specific sites if you need to.

The takeaway from all this is that it’s possible to render emails, elfeed entries, and various other links in HTML directly in an Emacs buffer. Walsh discovered one aspect of a much larger field of possibilities. Emacs has gotten pretty good at handling HTML within Emacs. There are still a few dark corners but things are getting better and better. I’m looking forward to the day I can finally ditch my browser.

Posted in General | Tagged | Leave a comment