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

Red Meat Friday: The Law of Unintended Consequences

When I added this item to my blog queue, I marked it as a Red Meat Friday post but now that I’m actually writing it, I’m having second thoughts. That’s because there’s nothing really controversial here. Everyone agrees—or should agree—with the conclusion: Before embarking on an endeavor, you should ask yourself, “What could go wrong?”

That’s because of the law of unintended consequences. Even though your intentions are pure and good, there’s always the possibility that something could go wrong and it pays to consider what that something might be.

Here’s an amusing example. Amusing at least if you aren’t Australian:

What could go wrong? We’ll import a couple dozen rabbits and have a nice hunting excursion. Billions of bunnies later, they’re asking, “Who could have imagined?” Well, anyone who knows anything about rabbits or the Fibonacci Sequence could easily have imagined what could go wrong if only they’d stopped to ask the question.

Here in the United States, we have the examples of Kudzu and opossums as rat control among many others. And, of course, the French had their infamous wealth tax. At no point did anyone stop to ask, “What could go wrong?” The answers, in retrospect, are all too obvious.

Posted in General | Tagged | Leave a comment

Org Footnote Assistant

Andrea Lazzarini has an interesting, small package to help with footnote creation and editing in Org buffers. The package offers some amenities such as easily moving between footnotes but, to me, the major win is displaying or editing a footnote in a cloned indirect window similar to the way editing a code block works after invoking org-edit-special to call org-edit-src-code.

That doesn’t matter too much for short texts such as a blog post but for longer-form texts where you can’t see the whole buffer, it makes it easier to create and edit footnotes because you can see the context of the footnote. If you’ve edited the contents of a code block using this paradigm, you know how powerful and convenient it is.

My only complaint is that the package doesn’t define or override keybindings to find or edit a footnote. That’s easy enough to do yourself, of course, but I’m a bit surprised it isn’t already there.

As far as I can tell, org-footnote-assistant is not in MELPA and Lazzarini doesn’t mention any plans one way or the other. Still, it’s a single file so it would be easy to install it manually. The project is less than a week old so I’m sure issues with an ELPA repository and keybindings will be addressed as the project matures.

Posted in General | Tagged , | Leave a comment

A Slight Isearch Improvement

Today’s post is a quick and simple tip from Zachary Kanfer on improving isearch. He likes the way isearch finds its results incrementally but is unhappy with the lack of context concerning the number of results found at each step.

It turns out that it’s easy to fix this. There is a configuration item, isearch-lazy-count, that when set to t will cause the count of prospective matches to be displayed in the minibuffer. There are a couple more configuration items that control the placement and format of the count. See Kanfer’s post for the details.

An alternative, that I use, is swiper-isearch. It also provides a count and displays the line containing each match in the minibuffer. I like it better and remapped Ctrl+s to it instead of isearch. Nonetheless, I have Super+s mapped to isearch so I can use it when I like. It’s worthwhile adding the prospective match count to isearch and it’s easy to do so I will probably add it to my configuration.

Posted in General | Tagged | Leave a comment