FSM Diagrams in LaTeX

I’ve written several times about my use and affection for finite state automata in programming. It’s amazing how often it can reduce a complex problem to a triviality. The first stage in taking advantage of this method is to draw a state transition diagram. Once you’ve got the diagram, it’s easy to write the code.

After writing the code, you’ll want to document the program and that will include the state diagram. Traditionally, I’ve used the Graphviz dot program to produce these diagrams but it can also be done directly from LaTeX.

Alexander Hayes has a short post that shows how to use LaTeX to generate FSM diagrams. It’s not a comprehensive tutorial, although he does give a link to one, but it’s still useful for getting an idea of how to produce such diagrams.

Documentation is always a pain, of course, so it’s nice to discover tools that make it easier. Even if you usually write in, say, Org mode, you can still include the requisite LaTeX for the diagrams or you can generate them separately and include the generated diagram in your text.

The nice thing about this solution is that it uses easily available, open source tools that most developers are going to have installed anyway. If you use state diagrams and have to document them, take a look at Hayes’ post.

Posted in General | Tagged | Leave a comment

A Discussion of Markup Languages

Alex Kladov has a post that discusses various markup languages and what makes a great one. He considers

  • Markdown
  • AsciiDoctor
  • LaTeX
  • reStructuredText
  • HTML

He finds them all lacking in various ways. He believes that any markup that’s tied to a particular target language—he puts Markdown is this category, unfairly I think—is already losing. He believes that the parsing (and syntax) of the input language should be decoupled from the target language and the driver that produces it.

If you look at the above list, you’ll notice a glaring omission: Org mode is missing. That’s too bad because Org meets most of the criteria that Kladov calls out. It’s got a simple, lightweight syntax; it’s tree structured; and has a simple format for links, lists, and tables. Perhaps most importantly for Kladov, Org mode markup syntax is not tied to any particular target language. Indeed, there are several targets and new ones are being added all the time. Even with a given target language, Org mode is flexible and extensible. You can mark some text as belonging to a particular environment with the name of your choice and define the semantic meaning of the environment with CSS or a LaTeX environment who definition you can include in a couple of ways. See this post for details.

Of course, ports notwithstanding, Org is mostly tied to Emacs. Much of the simplicity of writing in Org is because of shortcuts built into Emacs. Regardless, if you want the best and most flexible markup language, you should be using Org. Karl Voit makes a strong case that Org is the superior markup language and I certainly agree. It would have been interesting to see Kladov’s take.

Posted in General | Tagged , | Leave a comment

EmacsConf 2022 is Coming

Leo Vivier announces on the Emacs subreddit that the 2022 EmacsConf is scheduled for December 3rd and 4th. The conference will be live streamed so you needn’t travel to participate. Most of us won’t be able to watch the whole thing live but here’s a schedule in case you’re particularly interested in a particular talk.

The conference guide doesn’t say (that I can find) whether or not the recordings of the talks will be available for later viewing but they almost certainly will be. The organizers are promising more information as the conference itself approaches.

UPDATE [2022-11-07 Mon 11:32]: Sacha notes in the comments that they will be posting the videos.

Posted in General | Tagged | Leave a comment

Emacs Modifier Keys in X-Windows

Most Irreal readers know that Emacs offers the Hyper and Super modifier keys for use in keybindings. Less well known is that there is also an Alt key. It’s not the Alt key that appears on most modern keyboards that Emacs usually maps to Meta but a separate modifier. Sadly, we no longer have the Space-cadet keyboard so special effort is required to map them to existing keys. Usually, this means giving special meanings to the right modifier keys and perhaps the Window key if you have one.

This isn’t too hard on macOS but can be tricky under X. Over at Emacs Notes there’s a very nice post that shows you how to use the xkb file to set up all these keys. It’s very fussy but only needs to be done once. After that, you can enjoy the full set of Emacs modifier keys.

In the Emacs Next Step branch there are variables to set up the modifiers so you can simply add them to your init.el, possibly conditionally evaluated, to make your configuration portable to other OS environments.

The utility of doing all this may not be clear but I use Hyper as a modifier for many operations—either existing or homegrown—that aren’t already mapped. Once you have these keys, you’ll find all sorts of uses for them.

Posted in General | Tagged | Leave a comment

The Coverup Begins to Unravel

Irreal has long been suspicious about the back story of COVID-19. As I’ve written before, if you put on your scientific hat, the only possible conclusion is that there’s not yet any definite resolution to covid-19’s genesis. But if you think about it as an intelligent, knowledgeable citizen, the story being flogged by the press and the various governments involved just doesn’t pass the smell test. The unremitting insistence that any explanation other than the zoonotic one was a conspiracy theory and that there was nothing to see, please move on, left even the least cynical of folks wondering what was going on.

Now the coverup is beginning to unravel. Two recent revelations herald the unraveling. The first is a paper by Buttel, Washburne, and VanDongen claiming that an endonuclease fingerprint of the virus indicates that it was synthetic. That means, of course, that the lab leak hypothesis that many felt was the best explanation of COVID-19 is correct. If you know a little biology or chemistry, this article by Anandamide steps you through the analysis and even points you at the SnapGene Viewer tool that helps you with the analysis.

The second is a joint ProPublica/Vanity Fair article that reports on an extensive Senate investigation of documents obtained from Wuhan laboratory that strongly suggests that there was a serious biosecurity breach at the Wuhan labs just prior to the emergence of COVID-19. The story is very complex and involves plumbing the mind numbing depths of Chinese Communist “Party Speak”. Read the article for details. It’s long and complex but worth your attention.

That (even) the U.S. officials responsible for enabling and covering up this debacle will be brought to justice is probably too much to hope for but we can at least hope for an end to the dangerous and probably useless gain-of-function research before it manages to kill us all.

Posted in General | Tagged | Leave a comment

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