Customizing Org Mode Exports

I have a longstanding fascination with document layout. It’s something I first learned from Rich Stevens. His books were always visually beautiful with a layout that showed an obsessive attention to detail. Fortunately, he wrote about his process extensively on his Website and was generous with his help when I was laying out my first book.

Like Stevens, I wrote and typeset my books with Groff. These days, I do all my writing with Org mode so I’m always interested in ways the make Org mode exports look better. I recently I came across two posts that address this very problem.

The first is by Norman Walsh. His interest is customizing PDF output from Org files. He didn’t like the way the default output made his documents look like academic papers. He includes output from both the default method and his customized method so that you can see the differences.

The second is by Colin McLear, a teacher who wants to use the same Org file to produce

  1. A set of notes for his students
  2. A set of slides for his lectures
  3. A handout version of the slides with additional content

Walsh’s post contains all his configuration except his setup files. Those are available in his GitHub repository.

Neither of these setups are likely to be exactly what you want but they’re ripe with ideas and show you how to make your own customizations. The ability to do this means that there’s no reason to do your writing in anything but Org. If you have special output requirements, it’s pretty easy to realize them with some simple configuration.

UPDATE [2023-01-14 Sat 18:55]: Added link to McLear’s post.

Posted in General | Tagged , | Leave a comment

Referring To Lines Between Regular Expressions In Org

Sacha Chua has a problem. From an Org file, she’d like to link to and possibly include a set of consecutive lines in another (or, I suppose, the same) file. The problem is that the target file may not be static so using line numbers, which are subject to change, doesn’t work.

Her solution is to define a custom link that includes two regular expressions. That way, she can link to and include the lines between the two regexps. Check out her post for an example and a few more details.

Most of Sacha’s post is the code that defines the new link type and that, of course, is worth studying just to see how one goes about doing that even if you aren’t interested in the problem Sacha’s solving. Like all of Sacha’s posts, it’s definitely worth taking a look at.

Posted in General | Tagged , | Leave a comment

Completions In Emacs 29

Speaking of Emacs 29 goodness, Robert Enzmann has a post that describes the new completions functionality in Emacs 29. Those changes mainly involve new configuration settings that subtly change how completions work.

The first set of settings items configure what happens when you press Tab to trigger a completion. These items mainly determine how many times you have to press Tab to get the completion list. There are two new settings for completion-auto-help:

  1. always, which displays the completion buffer after any attempt to compile
  2. visible, which displays completions only if they are already visible

Enzmann has some animated GIFs that show these options in action and help you understand how they work.

The second set of configuration items determine when the completions buffer is selected. The new options allow for the selection of the completions buffer either automatically or after the second Tab.

There are some new commands for navigating the completion buffer. You can take a look at Enzmann’s post to see these commands. As he says, you may want to change the bindings for them because the defaults use the arrow keys.

There’s also new functionality that allows the items in the completion buffer to be sorted according to user determined criteria. For example, Enzmann sorts his first by the frequency with which he uses them and secondly by length. This works by providing a sort routine so virtually any sorting criteria is possible.

Finally, there are a couple of minor items that determine the height of the completion buffer and the format of the items in that buffer.

Enzmann’s post is a nice précis of the new completion functionality and worth a read for those looking forward to the release of Emacs 29.1.

Posted in General | Tagged | Leave a comment

Emacs 29 Feature Freeze

There’s some good news on the Emacs front. Eli Zaretskii writes that it’s time for a feature freeze on Emacs 29. This is, of course, the first step in the final Emacs 29 release process. Eli says the goal is to release the first pretest of Emacs 29.1 in “a month or so”.

The Emacs 29 release cycle seems faster than usual, which is also good news. We all want a stable release but we also want the Emacs 29 goodness as soon as possible. The nice thing is that we can depend on Eli and the rest of the development team to do the right thing. We can be confident that there will be no release before its time but also that the developers are committed to getting it to us as soon as reasonably possible.

As I always say when I write about these events, I want to give my profound thanks to all the developers who selflessly contribute their time and effort for the benefit of all of us in the Emacs community.

Posted in General | Tagged | Leave a comment

Org Headline Tips

Nicolas Martyanoff has a (very) short post on some tips for dealing with Org mode headlines. There are three of them:

Do not split lines when adding headlines
This is a way to add another headline even if you are in the middle of some text. It’s simply a matter of adding a configuration item.
Jumping to a headline
This is a way of finding a headline in a large Org file. It’s advantage over a simple search is that you get completion.
Don’t Highlight TODO entries
By default Org will highlight the entire headline for a TODO entry. You can easily arrange to highlight only the TODO keyword if you prefer that behavior.

These are all simple configuration items and easy to implement if you want them. It’s not a huge thing and probably won’t have a large impact on your workflow but they do offer a way to make Org present data in a way more pleasing to you.

If you’re an Org user, this post is well worth the minute or two it will take to read it. Emacs (and Org) after all, are all about making your workflow easier and more pleasant. Martyanoff’s post offers a small way to do that.

Posted in General | Tagged , | Leave a comment

Exporting Org To Standard Manuscript Format

Chris Maiorana has a very nice video up on how he configured Org mode to export to standard manuscript format. The standard manuscript format is the format that’s used—or at least used to be used—for submitting manuscripts for novels and short stories. Most of us have no use for that, of course, but the video is still useful because it shows us how to customize the output that Org generates when you export to LaTeX.

Most of the configuration involves the org-latex-classes templates, which are pretty easy to figure out. You can specify the document class and what LaTeX the Org headers map into. The other configuration is making some global changes to prevent Org from adding superfluous information to the LaTeX output.

See the video for the details. There’s also a link to his configuration so you don’t have worry about writing it down. The video is only 8 minutes, 40 seconds so it should be easy to find time for it.

Posted in General | Tagged , | Leave a comment

Reasons For and Against Emacs

Matthew Weber is a Vim guy. He really loves Vim and finds it the ideal editor for him. Still, he’s not dogmatic about it and acknowledges its shortcomings. He’s tried Emacs several times and could never make it stick but, again, he’s not dogmatic about it.

Although I somehow missed it, Sacha pointed me at one of Weber’s recent videos in which he gives five reasons to use Emacs and one reason not to. It’s a fair summary and although some Emacsers and some Vimmers will argue with some of his points, the presentation is balanced with plenty for each side to agree and disagree with.

I agree with all his reasons to use Emacs although I wouldn’t call them the best reasons to do so. I also agree that there are reasons not to use Emacs but not the one Weber gives. That reason boils down to Emacs has more “stuff” in it than you’ll use and even though you have to enable it, it’s still there and that’s bad for some reason. It’s bad even if one of those unused capabilities turns out to be just what you need as your workflow evolves.

Although Weber doesn’t make the point explicitly, he believes, as do I, that the choice between Emacs and Vim depends on what you want. If you’re looking for a fast, powerful editor and don’t care about having it do other chores for you, Vim is the best choice. If you’re looking for a computing environment that can perform a myriad of chores in a unified way and, by the way, also has an excellent editor, then Emacs is for you. As I often say, Emacs is for the type of person who really wants a Lisp machine even if they don’t know it or even if they don’t know or care about Lisp.

Regardless, it’s an interesting video and worth a few minutes of your time. The run time is just shy of 16 minutes so plan accordingly.

Posted in General | Tagged | Leave a comment

Another Take On Rss

I’ve written numerous posts—the latest one here—about my admiration for RSS and how I use it to deliver interesting posts directly to my Emacs. I’m an unabashed fan and have never understood those who claim it died when Google Reader was discontinued. I don’t feel the need to have my technology choices validated by Google and neither, apparently, do scores of over people who continue to use and benefit from RSS.

Jake Zimmerman has a contrary take. He wasn’t around when Google Reader was extant and everyone agreed that RSS was the way to curate your blog reading. He’s a newcomer who has only been using it for a week and he has some gripes.

He has two main problems. The first is that it can be difficult to find a link to a feed or even determine if there is one. Many sites have a link embedded in the HTML but browsers don’t reveal it so unless the site has an RSS button or link, the user is reduced to making a guess at the feed name and trying to add it to their RSS client. I can’t remember ever having this problem. Every site I visit either has an RSS link or it’s easily discoverable with a DuckDuckGo search.

His second problem is with RSS clients. He can’t find one that works the way that he likes. His requirements are pretty specific: he wants to do everything in the browser and he wants to be able to read his feeds on his phone. I, of course, don’t have either of those problems. I read my feeds in Emacs with Elfeed, which is very configurable and being written in Elisp is easy customize. That means, of course, that I can’t read my feeds on my iPhone or iPad but I’ve never felt the need to do that.

Finally Zimmerman complains that he’s finding it hard to discover a good set of feeds. He either gets feeds that give him too much or not enough. I suspect that this is an operational matter. I generally get about 90 links a day but I don’t read them all. Many are obviously about something I’m not interested in so I just skip them. For the rest, I either read the post in Elfeed if it’s given or press a single key to pop the post up in my browser if not.

I take Zimmerman’s point that RSS can be a little fussy to use but not nearly so much as the alternative of checking each blog periodically to discover if there’s anything new worth reading. Still, Zimmerman has some points and his post is worth reading.

Posted in General | Tagged , | Leave a comment

Happy New Year

The Irreal staff is still recovering from our virtual Bacchanalia1 last night so today we’ll just say

Happy New Year!

Footnotes:

1

Actually, it was just a matter of staying up until midnight and toasting the new year in with a bit of champagne.

Posted in General | Leave a comment

Checking A Word List

Daniel Lemire has a post that poses an interesting challenge. Suppose you have a list of words—Lemire uses “ftp”, “file”, “http”, “https”, “ws”, “wss”—and want to check if some other word is in the list.

Unless you believe in Zawinski’s law, you might choose regular expressions, especially if you’re writing in Elisp. But as Lemire points out, that’s going to be pretty slow. My first thought was to use regexp-opt to generate an optimized regular expression. For the list above, regexp-opt returns the regex "\\(?:f\\(?:ile\\|tp\\)\\|https?\\|wss?\\)", which will be faster than the obvious regexp but probably still not that fast if the check is going to be made many times.

Lemire offers some other solutions—in C++—including the obvious one of just sequentially checking the list. For a longer list, that could be sped up with a binary search but probably wouldn’t help much with the short list we have. He also offers some other solutions based on padding the input string. He has some benchmark results if you’re interested in the relative times.

One solution that he doesn’t mention is the one I would think of first: check inclusion with some sort of hashing operation. The obvious solution of that sort is to just put the list words in a hash table and check the input word by looking it up. That’s going to be very fast, especially if the list is long.

Perfect hashing seems like another good solution for a short list and will be fast to eliminate a candidate word but if you get a hit, you still have to check for a match. In any event, since the word list is known beforehand, you can adjust whatever hashing strategy you use to be as fast as possible. String comparisons are probably going to be the bottle neck is any reasonable solution so it’s important that the solution minimize those as much as possible.

It’s a nice problem and well worth thinking about.

Posted in Programming | Tagged | Leave a comment