Mickey on Readline

Mickey has another great post that will be immediately useful to almost every Irreal reader. The post is about the functionality of the GNU readline library. As Mickey says, almost everyone knows that readline (or at least BASH) implements the basic Emacs (or Vim) cursor movement keybindings and almost as many know about moving backward in the command history with Ctrl+r. Sadly, that’s the extent of most people’s knowledge about readline. There’s a whole lot more, though.

Mickey notes that the problem is particularly acute with Emacs users because, after all, they mostly stay in Emacs and even deal with the shell through Emacs. That means they have all that functionality automatically so they never explore what readline is capable of. I know that’s true because I wrote about readline’s functionality back in 2019 and resolved at the time to do better about using readline’s editing capabilities. Of course, I didn’t and now I know why. As an Emacs user I just didn’t use readline enough for it to stick. On the other hand, it’s mostly the same Emacs so the muscle memory should already be there.

Probably the most surprising thing about readline—and its most unknown—is its macro capability. Very much like keyboard macros in Emacs, it’s possible to record, optionally save, and playback an input sequence. That has obvious applicability for repeatedly entering some complex input string or part of one. Mickey has lots of examples so be sure to check out his post. As always with Mickey’s offerings, your time will be more than repaid.

Posted in General | Tagged , | Leave a comment

An Org-mode to DOCX Pipeline

Erik L. Arneson has a useful post that describes his method of converting an Org document to DOCX. His reason for doing that is the usual: his clients want a Word document but like all right thinking people, Arneson prefers to write in Org. His workflow lets him have both: a sane document preparation environment and an output that meets his clients’ needs.

Those of you familiar with exporting Org documents know that there are two ways of doing this. One is export directly to DOCX and the other is to use Pandoc. Most observers feel that Pandoc does a better job with DOCX so that’s what Arneson uses.

The post describes how to set up a template for the conversion so that you get a nice looking Word document. His workflow is complicated by the need to deal with several templates depending on the client and project. Because of that, he runs Pandoc from the command line but, as he admits, it’s possible to use ox-pandoc to automate all that by providing a bit of header matter in the Org document.

Having to provide a Word document is terrible, of course, but it’s depressingly common so Arneson’s how to is welcome. His post notes two negatives. First, he usually has to tweak the final Word document in LibreOffice to get it to look just right. Secondly, and much more depressing, is that many clients are now asking for a Google Docs document. That’s depressing because there’s no good Org to Google Docs pipeline but more importantly because no sane person or organization should be using Google Docs. Irreal has discussed this last point so many times that most of you are probably tired of reading about it. Still …

Regardless, if you have to produce Word documents but prefer a sane editing environment, take a look at Arneson’s post.

Posted in General | Tagged , | Leave a comment

Speeding Up Emacs Garbage Collection

Tyler Dodge over at Living the Dream Blog has a very interesting post on his research on Emacs garbage collection time. He discovered that a a simple parameter change could reduce garbage collection wall clock time by 50%.

The change has to do with the size of blocks allocated to hold cons cells. The TL;DR is that increasing the size improves locality and produces a significant decrease in run time for garbage collection. Take a look at the post for the details but the interesting thing is that the change itself is simply a change to a single parameter.

From what I can tell, the commit that Dodge describes is to his fork of the Emacs distribution but it’s certainly something that deserves consideration by the Emacs maintainers. To be sure, Dodge’s experiment was restricted to the macOS platform but it will probably apply to other platforms as well.

The post is fairly short and well worth spending a couple of minutes reading. It’s a reminder how a simple change can have profound effects.

Posted in General | Tagged | Leave a comment

Another Hugo Blogging Workflow

Andrey Listopadov has (yet another) post on blogging with Hugo. His post is distinguished by his attempt to be comprehensive. He says that when he was trying to start blogging all the “how to” posts were too shallow to be helpful and that he wanted his to be truly useful. His other desire was to show how to use Emacs and Org-mode in the workflow.

If you want a static blog—and there are plenty of reasons to prefer that—then this is a very useful post to read. Even if you don’t want to write in Emacs and Org there is a lot of useful information on how to get started. Most of the information is a step-by-step guide to setting up a Hugo blog so I won’t repeat it here; take a look at the post for the details.

One of the things I liked most about his post was a sort of afterthought. Listopadov asks if you, the reader, should start blogging. He concludes that, yes, you should. His reason for thinking so is neatly captured by Daniel Boorstin’s (the 12th Librarian of Congress) famous quote, “I write to find out what I think.” Actually, the full quote is even better: “I write to find out what I think. After all, the bars aren’t open that early.” Humor aside, it’s a great point. I often find that I don’t understand something until I write about it. If you’re an engineer, you may find that you’ll understand a problem better after writing about it. What better place to do that than a blog?

Posted in General | Tagged , | Leave a comment

Playing YouTube Videos in Emacs

Marcin Borkowski often watches long YouTube videos (frequently lectures) and sometimes can’t watch the whole thing in a single sitting. A couple of weeks ago, he wrote a post about capturing the elapsed play time where he left off and adding it to a link to the video that he maintained within Org-mode. That way when he followed the link, the video would start where he left off.

He’s discovered what he describes as a “much much better solution” to the problem. And it really is. He leverages a youtube-dl fork and mpv to play YouTube videos directly from Emacs. That’s already pretty nice but mpv can also remember where you left off so that you don’t need anything fancy to help you remember. There are a couple of ways of doing that so be sure to check out Borkowski’s post for the details.

Oddly, the code to do all this is simpler and shorter than the code to capture the time and add it to a link. If you want to store links to YouTube videos for later watching and be able to remember how much you’ve watched, this is a great solution.

Posted in General | Tagged , | Leave a comment

Undo In Region

Over at the Emacs subreddit, tms9918 says he sometimes changes a line, make changes in other parts of the file, and then wants to restore that first line. He was asking if there was anyway of doing that. There is, of course, as I’ve written before. The thing is, tms9918’s post was full of comments expressing wonder at how the commenter didn’t already know this. That led me to believe that a reprise of the issue was called for, especially since it’s so useful.

It is, after all, a situation that comes up often: you make a series of changes and then find that you want to undo one of the earlier changes. It’s extraordinarily easy to do. All you need do is highlight the region you want to restore and undo will apply only in that region. It works out-of-the-box if you’re using the default Emacs undo system. If you’re using undo-tree, you have to set undo-tree-enable-undo-in-region to t in your configuration.

You don’t need this all the time, of course, but when you do it’s easy to remember how to do it. There’s not special key binding to know or lookup. You simply highlight the region you want to restore and invoke undo in the usual way. Try it out; you’ll be delighted.

Posted in General | Tagged | Leave a comment

Organizing Your Life With Org Mode

Karl Voit has reposted an article from 2018 on using Org-mode to organize your life. Voit, as many of you know, is very interested in personal information managers (PIMs) and curating information for later retrieval. He says that when he discovered Org-mode, he knew he had found a tool to last him a lifetime. Partly that’s because the functionality is so rich and extensible but mainly because everything is in text.

Having everything in text future proofs Org mode because the files will always be readable by any application that can deal with ASCII or UTF-8. To be sure, you won’t have all the display and processing capabilities outside of Emacs but the files are still readable and easy to translate into any format.

Voit compares Org-mode to a box of Lego blocks. Everyone can take whatever blocks they want from the box and build a customized work environment tailored exactly to their workflow. Voit says he spends about 90% of his computer time inside Org-mode. That seems a lot but Org enables so many different workflows from literate programming, to document preparation, to record keeping, to blogging, to handling agendas and itineraries that it’s easy to use it for just about everything.

Org-mode is probably the most important part of my workflow and I wouldn’t want to do without it. If you aren’t already using Org, take a look at Voit’s post to get an idea of why you might want to.

Posted in General | Tagged , | Leave a comment

Mickey on Generating TOTP Codes

Happily for us Emacsers, Mickey has been blogging up a storm on Emacs topics lately. His latest offering is on generating TOPT codes with Emacs. TOPT is “Time-Based One-Time Password”. If that doesn’t mean anything to you, it’s the basis of those two-factor fobs that many us do or have carried around that gives you code to use as part of a login. Here’s one example but there are many others.

The fobs work by combining the time with a domain-specific secret and hashing them with SHA1 to generate the code. The TOTP protocol handles things like the inevitable time drift of the fob’s clock. At bottom, though, there’s nothing very mysterious about the protocol and it’s certainly possible to roll your own.

Mickey has done just that. He’s slightly modified Jürgen Hötzel’s totp.el and provided his own version of a base-32 decoder so that the resulting implementation is standalone. You can add his code to your init.el and generate your TOTP codes directly from within Emacs. The only thing you need is the secret but that is typically provided the the TOTP provider. Be sure to check out Mickey’s post for all the details.

If nothing else, this is a nice way of reducing your “everyday carry”, something that we here at Irreal are always interested in doing. If you’re logging in using Emacs, it’s also a way of avoiding the trauma of having to leave Emacs. What’s not to like?

Posted in General | Tagged | Leave a comment

Red Meat Friday: Copilot and Copyrights

Three weeks ago I wrote in Red Meat Friday: VS Code As A Venus Flytrap about Geoffrey Huntley’s post on how VS Code is all part of Microsoft’s plan to destroy open source and pull everyone into software as a service development tools. If you weren’t convinced, here’s some more evidence.

Vice has an article about a group of GitHub users who want to sue Microsoft over the appropriation of their code. The complaint centers on Copilot, an AI based plugin for VS Code that offers code completion suggestions. Copilot was trained on “tens of millions of public repositories” including GitHub. The problem is that Copilot can sometimes emit verbatim or essentially verbatim code from those repositories. This use of their code, the plaintiffs allege, violates the software licenses most of which require, among other things, attribution of its source. Copilot, of course, doesn’t do that; it just spits out the code.

It’s easy to take the position of, “Meh, who cares? The whole point of making the code public and open source is to share it.” The reason you should care is not some obscure technicality in the licenses. The reason is articularly explained by programmer and lawyer Matthew Butterick who is spearheading the lawsuit.

You should definitely read his post that lays out the real problem but the TL;DR is that it divorces the consumer of the open source code from the community that produced it. By using Copilot there is no need to seek out, find, and interact with the communities that produce the code so those communities will wither and die realizing Microsoft’s long held goal of doing away with them.

Posted in General | Tagged | Leave a comment

The Lisp Community

Here’s a charming post on the Lisp community. I like it for a couple of reasons. The first is that Owmagow wasn’t afraid to dig in and figure things out even though he realized there were already libraries available to do what he needed. Rather than use a black box with no understanding of what was going on, he figured it for himself.

The second, more important thing, is what he had to say about the Lisp community. It’s a common place in the tech world to say that the Lisp community is intolerant and unwelcoming. I’ve never found that and Owmagow agrees. He remarks specifically about how welcoming, helpful, and knowledgeable he found Lispers. He contrasts this with the Java community where he says, “asking for help was usually its own special type of hell.”

It’s probably true that the Lisp community doesn’t suffer fools gladly—especially those who want to do away with parentheses—but I’ve always found them ready to help anyone who comes in good faith. It’s sad, in a way, that this is worth remarking about but the Lisp community does have a reputation—probably undeserved—for being difficult. I hope Owmagow’s post will help change that.

Posted in General | Tagged , | Leave a comment