Debugging Elisp

Jon Eskin has a revealing post that shows how easy it is to use the Elisp debugger. The debugger, Edebug, is documented in the Emacs Lisp manual so of course it’s always available in your Emacs session.

What I liked about the post was that it shows how easy it is to use Edebug to solve a problem even if you don’t really know the code base. Usually when you think about a debugger, there’s a supposition that it will be complex, hard to use, and have lots of mysterious commands. Eskin’s post shows otherwise.

The entire debugging session involved two commands. First, the suspect function is intrumented with Ctrl+u Meta+Ctrl+x so that Eskin could step through the function and see what it was doing. It turned out that a variable was being unexpectedly changed. To track down the culprit, Eskin put a watchpoint on the variable and was able to see exactly what was changing it. After that, the problem and its fix was obvious.

There’s more to Edebug, of course, but it’s amazing how far you can get with just the two commands that Eskin used. Notice that Eskin wasn’t writing Elisp code, he merely wanted to track down a problem in existing code. That shows that Edebug can be useful to many different types of users. If you aren’t already familiar with Edebug, take a look at Eskin’s post and then read over the Edebug chapter in the Elisp manual.

Posted in General | Tagged | Leave a comment

Plan 9: If It’s Not Broke, Don’t Fix It

I just came across an interesting article that appears to be from Francesco Nidito—although I’m not sure about the provenance—concerning the Plan 9 operating system. The gist of the post was that Plan 9 was a brilliant piece of software but that it didn’t solve any real problems.

The most salient example of this was Plan 9’s fulfillment of the Unix promise that everything is a file. Unix broke that promise as soon as networking was introduced and the socket interface was implemented. Plan 9 provided a much more Unix-like networking interface that made networking connections look like files. The problem, according to the post, was that no one considered the socket interface a problem. Most users didn’t consider Unix broken in any significant way.

I have a couple of problems with the post. The first is the assertion that Plan 9 failed because AT&T didn’t have any experience in selling software. That was true—perhaps even more true—when Unix was introduced, yet Unix survived and thrived. It had all the same problems concerning incompatibility and the need to reprogram existing applications that Plan 9 had yet was successful.

Far from never hearing about it, I actually had a running Plan 9 instance and contra the article it had at least two excellent code editors, Acme and Sam. What it did lack and what I consider its fatal failure—and my second problem with the post—was its lack of a Web browser. If it had had one, Plan 9, like Linux, could have gained traction in the nerd community and leveraged that to more a general acceptance. Being able to browse the web is the sine qua non for any workstation OS these days so Plan 9 was going nowhere without one. Oddly, the Plan 9 faithful never considered this a problem worth solving and as a result Plan 9 lives on mainly as Plan 9 From User Space, a port of many of Plan 9’s tools and libraries to other operating systems.

It’s too bad. Plan 9 was a better Unix and it’s program from anywhere paradigm was a powerful and compelling feature. It’s too bad it didn’t succeed.

Posted in General | Tagged | Leave a comment

The Origins of PostScript

The IEEE Spectrum has a lovely article about the origins and early history of PostScript and how it jumpstarted desktop publishing and arguably digital printing. Most Irreal readers probably know the rudiments of the story. PostScript was developed at Adobe Systems for electronic printing and rapidly became the standard for digital printers.

The actual story is more complicated. Previous digital printing technology involved producing handcrafted bitmapped images of each character in each font of each typeface. Adobe’s plan was to describe each character of a typeface mathematically (using Bézier curves) and scale (or even rotate) the descriptions mathematically for each font.

One of the hardest problems was dealing with the different resolutions of various printers. The 300 DPI resolution of the early laser printers were from different from the, say, 1200 DPI of commercial printers. The fix involves flipping bits at the critical points of a character where the jaggedness appears at lower resolutions. This was accomplished by means of “hints” for each character and associated procedures for each resolution.

One of the interesting parts of the article was a video of Chuck Geschke talking about how Adobe came to focus on PostScript. The original plan, as I understand it, was to produce computer driven printing presses. Early on, both DEC and Apple approached Adobe and said essentially the same thing: “We already from computers and have a deal with a printer manufacturer for a printer but we’re having trouble getting the computer to talk to the printer. Sell us your software.” In both cases Adobe demurred, citing its business plan and its obligations under it. Later one of their investors said that DEC and APPLE had been right and that they should focus on the software that later became PostScript.

It’s a really interesting article and well worth a few minutes of your time. These days, of course, PostScript has pretty much taken over digital printing and it’s worth taking a look at how it all began.

Posted in General | Tagged | Leave a comment

Use-package Merged into Emacs 29

Stefan Kangas just announced that use-package has been merged into the emacs-29 branch. I’m inclined to take a conservative view towards moving packages into core Emacs, believing that a package should prove its worth and stability over an extended time before being considered for core.

The use-package macro has clearly met that standard. It really does make configuring packages simpler and the size of the configuration files smaller. Like many of our most useful tools, use-package was intended to make things a bit easier for its author, John Wiegley. He put it on GitHub and soon many people were using it and offering extensions. The :ensure keyword, for example, was implemented by one those users. Wiegley himself doesn’t use it because his workflow is a bit different.

The use-package package is a small thing but it does make my life simpler and I’m glad to see it get merged into core. Thanks to Wiegley, Kangas, and the others who made this happen.

Posted in General | Tagged | Leave a comment

Prot On Clojure and Cider

As most Irreal readers know, Protesilaos Stavrou (Prot) is looking for a new job. Part of his preparations is learning Clojure so of course he’s produced a video on using Clojure in Emacs with Clojure. It’s an elementary exposition but definitely worth watching.

The main point of the video is not Clojure itself but rather the use of Cider and the evaluation of expressions in the context of the code buffer. He shows how you can evaluate an expression from within the code buffer and how you can easily switch to the Clojure REPL to try things out.

It’s another example of exploratory programming that I’ve written about before. If you haven’t experienced it, it’s hard to overstate the value of having the REPL always available to test out functions or even expressions. It makes programming much more efficient and fun.

The video is just short of 27 minutes so you’ll have to schedule some time. Prot has promised more videos on Clojure, which I’m looking forward to. In the mean time, if you want to get a sense of what using Cider is like, take a look at his video. If you want another example, check out Mike Zamansky’s video on Day 1 and 2 of the 2022 Advent of Code challenge. He uses Clojure and demonstrates its use on nontrivial problems.

Posted in General | Tagged | Leave a comment

Update On The Org-9.6 Problem

Yesterday, I wrote about Org-9.6 failing to load after my weekly update. I’m happy to report that due to the advice of the excellent Irreal readers Fran Burstall and Mike S, I have resolved the problem.

The problem turns out to be that files from the builtin Org 9.5.5 were out of date and causing the org-assert-version macro to fail. The secret is to install the new Org before any .org files are loaded causing files from the builtin Org to be loaded. That can happen, for example, if you have Org agenda files, which will be loaded before you’ve done anything with Emacs other than load it.

If you’re having the same problem, here’s what I did to resolve it:

  1. Uninstall Org-9.6
  2. Make sure the Org-9.6 directory in your Elpa repository is deleted
  3. Start Emacs with the -Q option
  4. Install Org-9.6 with package.el
  5. Quit Emacs and restart it.
  6. Check that you’re running Org-9.6 with Meta+x org-version

My understanding is that this problem occurs because Org has a builtin version which can easily interfere with a later version that you’re trying to load. It’s a good thing to keep in mind.

Posted in General | Tagged , | Leave a comment

PSA: Beware of Error With Org 9.6

My usual routine is to update my Emacs packages on Sunday. After my last update, I restarted Emacs and Org wouldn’t load, complaining that org-assert-version was an invalid function. After a bit of messing around, I uninstalled Org-9.6 from my Elpa repository and deleted all the files. When I restarted Emacs, I got the builtin version of Org, Org-9.5.5, which worked perfectly.

The Org mailing list has a short thread on the problem but it’s hard to figure out what’s going on. Apparently org-assert-version is intended to deal with the repository being corrupted by files from different versions. There’s been a bit of pushback on org-assert-version and a patch intended to fix the invalid function problem by Bastien also received some pushback so it’s not clear when the issue will be resolved.

I’m pretty certain it’s not a mixed versions problem because I nuked my Org-9.6 repository, did a fresh install, and still got the error. I’m happy enough running 9.5.5 but I do wish this would get resolved.

In the mean time, if you see this problem, just uninstall 9.6 and let the builtin version take over. The Org maintainers are very good at getting things like this fixed so I’m confident that when I do my updates this coming Sunday, the situation will be resolved.

Posted in General | Tagged , | Leave a comment

Howard Abrams On Why You Should Use Eshell

Regular Irreal readers know that I’m a fan of Howard Abrams’ posts and videos on Emacs. Abrams gave a talk at EmacsConf 2022 on the Top 10 reasons why you should be using Eshell. He felt that the talk was a little compressed so he wrote a separate blog post that covers the same material.

I found that the best strategy is to listen to the talk and then read the post to fill in any details that you might have missed in the video. The video ran to 14 minutes so it should be easy to find time for it.

Like much useful software, Eshell is pretty easy for trivial operations but also has powerful, advanced features that are very useful but harder to learn. The canonical example of this is file glob filters. They’re also available in Zshell and I’m always promising myself to learn them but unless I use them all the time I tend to forget the details.

Abrams also demonstrates some of his bespoke code that he uses to make using Eshell easier. For applications that require things like cursor addressing, he uses vterm but for most things he prefers Eshell. The nice thing, he says, is that Eshell is both a shell and an Elisp REPL at the same time. Again, the syntax is a bit different from Bash or Zshell so you need to use it regularly to internalize it.

Spend 14 minutes with the video and if you like what you see, take a look at his blog post. Definitely worthwhile if you do a lot of shell work. And, of course, you can stay in Emacs while you’re doing it.

Posted in General | Tagged | Leave a comment

Zamansky Returns

It’s Advent of Code time again and, as is his wont, Mike Zamansky is meeting the challenge and blogging about his results. Even better, he’s posted a video on his solutions to the first two problems.

The video isn’t about Emacs directly but, of course, all the work is done in Emacs. Because Zamansky mostly uses Clojure for his hobbyist programming, he uses the Cider package for his programming and the video serves as a nice illustration of using Cider and Emacs as a very nice programming environment.

Although the video is nominally about Clojure, his solutions would work, mutatis mutandis, with any Lisp. He uses the threading macros, which although not strictly necessary make things a little clearer. If you program in any of the Lisps, you’ll almost certainly enjoy the video and his solutions to the problems.

Irreal readers know that Zamansky is planning to retire at the end of the Spring semester but if he continues to produce videos like this one, we’ll all be pleased. Even if the videos aren’t specifically about Emacs, it’s useful to see examples of using Emacs to solve real problems. Regardless, enjoy this video and let Zamansky know you liked it so we can guilt encourage him to produce more. I always learn a lot from his videos and hope he produces more.

Posted in General | Tagged | Leave a comment

A Browser-based Org File Viewer

Kiran Gopinathan has built an interesting little app to view Org files in the browser. If you’re like me and want to stay in Emacs as much as possible, you may be wondering anyone would build such a thing. Gopinathan recognizes that and address it in his reddit post announcing the project.

It’s not too hard to imagine using this to share Org files with your unenlightened colleagues who don’t use Emacs. Gopinathan appears to use it as a way of providing a nice presentation of his time tracking data. I’m sure others can think of more applications for something like this.

The GitHub repository has animated GIFs to show the app in action. If you think you might be interested in such a thing, take a look at the GitHub repository. It explains the full functionality with those animated GIFs.

Posted in General | Tagged , | Leave a comment