Elfeed-webkit Update

The other day I wrote about installing elfeed-webkit to render my RSS feed as proper HTML. I was pretty impressed with it when I first tried it and now I’m even more of a fan. Before elfeed-webkit, I spent a lot of time switching between Elfeed and Safari so that I could read interesting posts that came up in the feed. It doesn’t seem like it would take that much time but since the change, my RSS workflow seems faster and easier.

A secondary advantage is that Emacs has more functionality now that I have XWidgets enabled. At first I wondered if I could get eww to do a better job rendering sites by using Webkit. That turned out to be a bust but I did discover xwidget-webkit-broswse-url that will render a site in decent HTML but it’s not a proper Browser so it’s pretty much restricted to viewing a specific URL. You can follow links and control videos but there are no bookmarks, content filtering, or other Browser amenities. Still, it does help keep me in Emacs and a lot of times I just want to visit a page from Emacs and it works perfectly for that.

In my original post, I noted a couple of problems. The first was the possibility of being inundated with ads because of the lack of content filtering. That’s basically a nonissue for the sites I read although occasionally a feed item will send me off to a “commercial” site that does have a lot of intrusive pop-up adds but it doesn’t happen often.

The second problem was that I couldn’t get t to toggle elfeed-webkit on and off. I thought maybe something else was grabbing the t binding to I changed it to w but that didn’t work either. I solved that by binding a global key to toggle elfeed-webkit and that worked fine (but see below).

Finally, I recently upgraded my email client mu/mu4e and a helper function I wrote to display the post in eww stopped working. While investigating that, I discovered that mu4e will display an email with webkit, which is what I really want so I’m now using that instead of eww.

While investigating the email issue I discovered that the XWidget library does indeed capture the t key as well as the w key. The t doesn’t appear to do anything useful as its definition

(define-key map "t" (lambda () (interactive) (message "o"))) ;FIXME: ?!?

shows. I don’t know how it was working for Grabo; perhaps he’s using the Emacs 29 pretest and it has removed the useless binding. In any event, I simple changed my toggle key to x and now it works perfectly.

That leaves only one small problem. One of the sites I follow, Daring Fireball, has the unusual property that its RSS URL is not the site itself but the site it’s linking to. That means that I miss the Daring Fireball commentary and go straight to the linked site. I’m considering adding code to implement a tag that inhibits rather than enables elfeed-webkit. In the meantime, I’m simply toggling elfeed-webkit off when I get to a Daring Fireball post.

All in all, I’m really happy with elfeed-webkit and recommend it wholeheartedly.

Posted in General | Tagged | Leave a comment

Org Blk URI

Just a quickie. I stumbled across a post from Andrea that describes his package Org Blk URI. It’s pretty simple: it’s just a way of extracting the content at a URL into an Org source block.

That’s handy for capturing Web content that is apt to be ephemeral. The example Andrea gives is a job ad and, of course, we’ve all run across Web pages that might not remain available but that we’d like to retain. This package is a nice way of capturing them into an Org file that we control.

I haven’t installed yet but it seems like a handy tool to have.

Posted in General | Tagged , | Leave a comment

PDF at 30

PDF. It’s a ubiquitous standard that seems like it’s always been here. How else would you prepare a document that could be printed on virtually any printer or displayed on any screen in the best possible resolution?

But, it turns out, PDF is only 30 years old and even after its introduction, it took a long time to gain traction. When Rich Stevens published the first edition of Unix Network Programming in 1990, he hand carried the Troff output on a series of floppy disks to a typesetting service that printed camera ready copy for his publisher. Things got better. When I published my first book—also written with Troff—I simply emailed the PostScript files to the (same) publisher. By the time I completed my second book, the publisher said, “Just send us a PDF file.” Now PDF is the universal file format for producing human readable print quality output.

The incomparable Professor David Brailsford on Computerphile remembers the early days of PDF and how it completely changed his career. Even he, he says, underestimated how long it would take PDF to gain traction. Part of what moved things along was the introduction of laser printers that, although they didn’t provide the resolution of a traditional typesetter, were good enough.

Soon, of course, they were more than good enough, equaled the resolution of the old guard typesetters, and replaced them. These days, even industrial printers are laser based and all input comes to them as PDF. The ’P’ stands for “Portable” after all and it has more than lived up to its promise.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Latex vs. Word

The minions hate Word even more than they hate dark themes so they insisted I run with this:

Like last week’s Red Meat Friday, you’d think this one is so non-controversial that it hardly merits inclusion in a Red Meat Friday post but according to the comments, some people actually defend using Word instead of LaTeX for mathematics.

To those who think this, I can only second the look from the two women in the front of the picture. Actually, I’d go further and extend that unbelieving look to anyone who uses Word for any writing. But that’s just me. And the minions.

Thanks to John Cook and his TeX and Typography feed for the link.

Posted in General | Tagged | Leave a comment

Elfeed-webkit

I just stumbled across a post by Fritz Grabo about his package elfeed-webkit. When I first saw it, I thought it was interesting and worth a look. After reading more about it, I knew I had to install it. That wasn’t entirely easy because I had to recompile my Emacs to support xwidgets. But I liked the idea of the package enough to press on and add xwidgets to my Emacs.

After that, it was simply a matter of installing elfeed-webkit from MELPA. When I toggled it on with Meta+x elfeed-webkit-toggle all my elfeed results were rendered directly in the Elfeed buffer. Sometimes—for example, when I want to save a page for an Irreal post—I need to go to the browser and rerender the page. That’s simply done by pressing the v key.

You’re supposed to be able to toggle elfeed-webkit on and off with a t after you configure it in your init.el but I can only get it to toggle on, not off. Doubtless, I have some misconfiguration but that’s research for another day. You can also add a tag to individual feeds to turn it on but I haven’t tested that yet (I installed it just before I started this post).

So far, I really like this package. It (mostly) keeps me in Emacs and renders the pages perfectly. A comment in the original reddit post complained that Webkit was going to deluge my feeds with dozens of ads but I didn’t notice that with my admittedly limited testing. The nice thing is that you’re not really committed. It’s easy to turn it off or even uninstall it if you don’t like it. The worst that happens is that you end up with support of xwidgets in your Emacs.

Posted in General | Tagged | Leave a comment

Emacs Badges

As far as I know, it started with this reddit post. It was a request for a “built with Emacs” badge. Those badges were the type of thing you used to see on Web sites. I’m pretty sure I had it on one of my old Web sites1 but I don’t see them as much now. In any event, MichalNemecek had seen one for Vim and wanted to put it on his site. The problem was that he’d switched to Emacs and was looking for something similar for Emacs users.

Since then, I’ve seen several mentions of this page from Lulu Cathrinus Grimalkin that has a collection of Emacs badges. It even has the famous—or is it infamous—kitchen sink Emacs badge. If you’re into this sort of thing and would like to add an Emacs badge to your site, Grimalkin’s page is a handy reference.

I’m guessing that the reason you don’t see these very much anymore is that blogs and sites are mostly no longer handmade but use something like WordPress, Hugo, or one of the other site generators. That and the fact blogs are no longer the exclusive domain of nerds. These days, the average blogger has probably never heard of Emacs or Vim.

In any event, if you want one of those badges, now you know were to find it.

Footnotes:

1

After I wrote that, I remembered that I had something similar (but for Org mode) on the placeholder for my “new” Web site. Of course, that was 12 years ago so my point stands.

Posted in General | Tagged | Leave a comment

Emacs Elements on Emacs Regular Expressions

Over at Emacs Elements there’s a nice video that explores Emacs regular expressions. One the one hand, virtually everyone hates Emacs regular expressions and wishes that Emacs used Perl compatible regexes instead. On the other hand, a case can be made that Emacs regexes are optimized for the typical Emacs use cases. In either case, it’s an old war and a boring one. One can arrange to use Perl regexes but most of us just accept the pain and use the default.

Still, even for those of us who have accepted the inevitable, the rules governing Emacs regexes can seem arcane and sometimes needlessly complex. Why, for example, do we have to use [0-9] instead of \d to specify a digit?

Emacs Elements’ latest video is a nice précis of the rules and conventions for using regexes in Emacs. The three parts that I really liked were

  1. Listing the exact characters that need to be escaped
  2. A good explanation of how to search using syntax classes
  3. An explanation of the non-greedy operators

but the video covered most aspects Emacs regular expressions and is a good explanation or refresher for those who have occasion to use them. The video is 22 and a quarter minutes so you’ll probably have to schedule some time but it’s definitely worth watching.

Posted in General | Tagged | Leave a comment

The Story of Mel

There’s a charming piece of foundation lore that every programmer in my cohort read and admired: The Story of Mel. Even when I was writing assembly language exclusively, the story was about a bygone era and techniques that no one still used. But Mel was cast as a “real programmer” of the sort no longer extant but nevertheless worthy of our praise and admiration.

I don’t know if younger programmers know about Mel so if you don’t, follow the link and read the story of Mel. I’ll be here when you get back. Even when I was young and naive, I didn’t believe the story was real and always considered it an apocryphal story about a sort of Platonic ideal of the perfect programmer. Everyone I know shared that opinion.

It turns out, though, we were all wrong and Mel really did exist and really did write the famous Black Jack program. His name was Mel Kaye and was still alive until 2018. You can read all about Mel and his family tree back to when his ancestors came to America at the link.

Apparently, the hack described in The Story of Mel is real too. The idea of that sort of bit twiddling, let alone optimizing your code for drum memory, is completely foreign to the current milieu but it did once exist and we can only marvel that it was once real.

Posted in General | Tagged | Leave a comment

Debugging With Print

Álvaro Ramírez has a guilty secret: he sometimes debugs code by inserting print statements into it. I was really happy to see his post because it’s a guilty secret that we share. Debuggers and similar tools are great and really useful but sometimes it just seems like putting in a couple of print statements is easier.

Ramírez is even lazier than I am—which some say, not without reason—makes him a better programmer than me. In any event, rather than printing a descriptive message indicating where in the code the message came from, he’s more apt to just print something like “yay” or “got here”. That’s fine when there’s only one such statement but is less useful when there are a number of similar print statements. Ramírez’s way of dealing with this is to add a numerical suffix—yay1, yay2, ⋯ —to distinguish which print he got to.

After a while, it became a chore to keep track of the latest suffix. Ramírez’s solution was to write a bit of Elisp that searches through the buffer for the keyword, “yay” or whatever, records the highest numerical suffix, and inserts a print for the keyword with the next value of the suffix. Of course, being Ramírez, he had to tweak the code to be a bit more flexible. That included an option to insert random words instead of a fixed keyword with a numerical suffix.

Often, a debugger is the right solution. After all, when you stop at a breakpoint you can query the executable for the values of various variables and other useful information. Still, sometimes it’s overkill and a simple print is all you need. If you find yourself inserting a lot of prints, Ramírez’s solution may be just what you need. Take a look at his post for more information.

Posted in Programming | Tagged | Leave a comment

Emacs Keyboard Macros

There’s another nice video over at Emacs Elements. This time it’s about using keyboard macros in Emacs. Keyboard macros really are a super power and it’s worth spending a few minutes learning some of the details.

Most of us know that you start defining a macro with F3 (or the older Ctrl+x () and end it with F4 (or Ctrl+x )). But wait: there’s more. You can also add a counter that gets incremented each time the macro is run. The video gives a simple example but it’s much more useful than the video suggests.

One of the most obscure but potentially useful features is the ability to enter recursive editing mode in the middle of a macro. That allows you to enter custom text or even do custom editing for each invocation of the macro. It can be tremendously useful in real world editing.

One thing I learned from the video is that you can apply a macro to a region. The rules are subtly different: you edit the first line and then the changes are applied to the other lines in the region. There’s no need to move to the beginning of the next line.

The video is 16 and a quarter minutes so it should be easy to fit in. It’s definitely worth a few minutes of your time. If you aren’t already using keyboard macros, you’re missing out on a lot of power.

Posted in General | Tagged | Leave a comment