Alphabetical Lists In Org Mode

The other day, I wrote that you never stop learning Emacs. There’s always something new to learn. I just saw a post that reminded me that—at least for me—you never stop relearning Emacs either.

The post asked about why indentation was not working properly for alphabetical lists. I didn’t understand the question. I didn’t have any problems with Alphabetical lists and I was sure I hadn’t done anything special to enable them. One of the commenters explained that what the poster was experiencing was the expected behavior because by default Org Mode doesn’t recognize alphabetical lists and that he needed to set org-list-allow-alphabetical to t, to enable them.

I called describe-variable on org-list-allow-alphabetical and it told me that the default value was nil but that it had been reset to t. Where did that come from? I searched my Git logs and discovered that I had made the change 11 years ago. I have no memory of why I did it or what problem I was trying to solve.

In a sense, it doesn’t matter because I now have things set correctly for my workflow but what if someone had asked me the same question the poster asked? I wouldn’t have been able to help them because the issue had disappeared from my consciousness.

In any event, if you want to use alphabetical lists, be sure to enable org-list-allow-alphabetical.

Posted in General | Tagged , | Leave a comment

Emacs: Saving You From Yourself

Another quickie today. Evan Moses has a short post that shows how he solved a problem particular to his workflow. He’s an Evil user, which means that when he wants to save a buffer he types :w. Unfortunately, he’s prone to fat fingering that command and types :w2 instead. That writes the buffer to a file named “2” instead of the file that the buffer is visiting.

We can all relate. Most of us have some sort of similar mistyping that we’re prone to make. But this is Emacs and it’s infinitely configurable so Moses decided to save himself further grief by writing a bit of Elisp.

He simply wrote a function to check whether or not the argument to evil-write is 2. If it is, the function asks if he really wants to save to a file named 2. The function returns the result of that question.

Then he advised evil-write to run his function before writing and to abort the write if the function returns nil. You can check out the code in his post. It’s simple and exactly what you’d expect.

I’m writing about this not because I think many people are fat fingering w as w2 but because it’s another example of how Emacs’ unsurpassed configurability lets you fix small but annoying problems. Notice how simple the solution is. You don’t have to rewrite the evil-write function. You just tell Emacs to run your function first so that it can ask if saving to the file 2 is what you really want.

Posted in General | Tagged | Leave a comment

Working With Docstrings

Charles Choi has been writing a lot of Elisp lately and being a scrupulous developer, is careful to write informative and useful docstrings. Being conscientious, he’s careful to check the formatting of his docstrings by calling describe-function. That sounds simple enough but, as Choi, says, it’s actually a pain involving several steps and moving around in the text of the function.

Of course, being a programmer, Choi decided to automate the process. That’s a win because it makes it easier to (repeatedly) check the docstring resulting in better documentation for the end user.

Another issue that Choi addresses is the number spaces at the end of a sentence. That, of course, is a minefield and whatever you do is sure to offend someone. But a good case can be made that since docstrings are almost always displayed in a monospaced font, there should be two spaces at the end of a sentence.

There are some problems though. Fill-paragraph won’t enforce the value of sentence-end-double-space if sentences end with a single space. As usual, Emacs has us covered. Instead of just calling fill-paragraph you can first call repunctuate-sentences. That will add two spaces after each sentence, which is just what you want in these circumstances. Take a look at Choi’s post for the details.

Docstrings seem like a small thing but done right, they can be very useful. Choi’s post demonstrates some ways to make writing them a bit easier.

Posted in General | Tagged | Leave a comment

Defining Eshell Commands

It’s a commonplace in the Emacs community that you never stop learning Emacs. No matter how long you’ve been using it, there’s always something new to discover. The truth of that maxim was brought home to me today when I came across an Emacs subreddit post from rvc09 asking how he could run a predetermined set of commands in Eshell as with a script in other shells.

I’ve never needed to do that so I hadn’t thought about how I would go about it. It turns out that the answer is simple but not at all obvious. Scroot had the answer. It turns out that you can define an Elisp function eshell/some-command and run it in Eshell by calling some-command.

But wait, there’s more. Within such a function you can use eshell-command1 to call any Eshell command. Those two facts allow you to essentially define a script that you can run from within Eshell.

As I said, I had no idea about this. It’s just another point on the never ending arc of my Emacs journey of discovery.

Footnotes:

1

Scroot says it’s eshell-run-command but that function doesn’t exist in my Emacs 29.3 installation, so I’m pretty sure he meant eshell-command.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: A Shot Across The Bow

Virtually every regular Irreal reader knows that I’m not a Google fan. Along with Meta, they’ve done everything they can to hijack the free and open Web and turn it into a proprietary money machine. I can’t remember taking their side on anything for many years.

Today, though, I stand with them in a looming fight against what I consider an outrageous extortion attempt on the part of the news media. Those of you of, um, a mature age will remember when the press thought its job was to confront government and question their every move. Now, though, they’re just like every other big organization and look to government to give them a leg up against their competitors.

The latest example is the pending California Journalism Preservation Act (CJPA). It basically says that Google and others will have to pay news media for the privilege of linking to their stories. Think about that for a moment. It’s a tax on saying, “Hey look over there. That’s interesting.”

In essence, though, it’s simply a shakedown. We know this because all large sites invest heavily in SEO: they want those links. The links drive traffic to their sites, increase readership. and drive engagement. The dying media, though, long ago abandoned their traditional role and no longer have any idea of how to leverage those links to their advantage. Instead, they simply demand unearned payment. The whole thing reminds me of the fable of the stolen smell.

Google, of course, is not amused. In an obvious warning to California media, they are testing removing links to some California media “to measure the impact of the legislation on our product experience”. Testing, blah, blah, blah. The intent is obvious. It’s to ask the question, “how would you like it if those links disappeared?”

It costs media nothing to have Google link to their stories. Indeed, it helps them. Google’s behavior has been so egregious that it’s easy to take the side of the newspapers but that’s a mistake. If the media were really concerned about links somehow stealing their content they would try to stop even small sites like Irreal from linking to them. They would, in fact, implement a paywall like The New York Times and the Wall Street Journal. They don’t do that, of course, because they know nobody would pay for it. Easier to just demand tribute from Google.

Google has done this before but they’ve always caved in the end. I hope they stand firm this time. If they don’t, they can look forward to many more such demands.

Posted in General | Tagged | Leave a comment

Beautifying Org Mode

As you all know, I’m not much for editor bling even though I care immensely what my finished text looks like. Still, I did take to heart Charles Choi’s recommendation to use proportional fonts for prose. The idea is that it’s easier to read and edit prose when it’s in a proportional font. That aside, the only other “beautification” I make to my Org buffers is to use the previous default of a larger font and different color for the title. Org did away with that some time ago but I resurrected it with

(set-face-attribute 'org-document-title nil :foreground "midnight blue"
                      :weight 'bold :height 1.44))

If you adhere to a less austere style in your Emacs buffers, you should take a look at Diego Zamboni’s recent post on Beautifying Org Mode in Emacs. He’s got a lot of nice ideas for customizing the look of your org buffers without resorting to a wholesale theme change.

His changes mainly consist of changing the font faces and sizes for the various headline levels and for ensuring that code fragments were still rendered in a monospace font. He also sets visual-line-mode on to make things look better in proportional fonts. I do that too but to solve formatting problems when exporting to HTML.

He hides the emphasis markup, which I definitely don’t like but he also made a simple change to make list bullets appear as actual bullets (•) rather than the default -. He makes some other suggestions, as well, so it’s well worth taking a look at his post if you’re interested in gussying up your Org buffers.

Posted in General | Tagged , | Leave a comment

An Interview With Daniel Semyonov

Those of you who have been around for a while will remember Sacha Chua’s video interviews with various Emacs luminaries. Those were before the birth of her daughter and as any parent will tell you, young children can gobble up whatever discretionary time you have so it’s little wonder she hasn’t done any interviews lately.

Sadly, she hasn’t reinstituted her interviews but she does this have this offering from Emanuel Berg with an interview of Daniel Semyonov. It’s not a video and it’s a bit shorter than Sacha’s old interviews but it’s still interesting.

Semyonov is a young programmer from a remote area without a lot of resources yet he was able to bootstrap his knowledge and has contributed to several open source projects. Most recently he has worked on the Gnus backend for Atom feeds.

One of the things I liked most about the interview was Semyonov’s discussion of how Emacs and learning Elisp kickstarted his programming in general and his open source contributions in particular.

It’s a short interview and worth a couple minutes of your time. Perhaps others will share their interviews with Sacha, and she with us.

Posted in General | Tagged | Leave a comment

Emacs Nerd Porn

For all you Emacs nerds out there here’s a bit of porn. It’s almost like those joke pictures you see of Emacs setups but this one appears to be real.

As much as I like the idea of this environment, I’m not sure that I’d want to use it. As some of the commenters noted, it’s going to make your neck sore but for me the question is why you need to see all that information? Sure, it’s useful to be able to see two or even three files at the same time when you’re working but I’m not sure why you need to see eight or nine at once. It seems like lurking distraction to me.

I get that you might want to have, say, an email buffer and maybe even a text message buffer open but I’m at a loss of what to do with nine visible buffers. Of course, it’s different strokes for different folks so whatever works for you is okay with me.

And I gotta admit it looks really cool and is sure to give you nerd creds from just about everybody.

Posted in General | Tagged | Leave a comment

A Comparison Of Markdown Editors

Although I find it hard to believe, the Minions assure me that there are still people who prefer writing in Markdown rather than Org-mode. I don’t want to relitigate that issue here. If you’re interested in why no right thinking person would prefer Markdown to Org—even without Emacs—I refer you to Karl Voit’s detailed analysis of Org’s superiority. Objectively, it’s just a better markup language and that’s before we get to Babel.

Regardless, there are those who use Markup either because they have to or because they really do prefer it. That leads to the question of which editor is best for writing in Markdown. (That issue doesn’t come up with Org-mode, of course.) Needless to say, we Emacs partisans dismiss this as a silly question because we think all editing tasks are best done with Emacs. Less biased folks may demur.

Franco Pasut is one such person and he analyzes the four editors

  • Vim
  • Emacs
  • Sublime Text
  • VS Code

all of which have facilities for helping you edit Markdown. He looks at each editor both out-of-the-box and with Markdown specific add-ons.

I’ll let you read his post for the details but as a spoiler, I’ll tell you that Emacs is not his first choice even though he is an Emacs user.

Posted in General | Tagged , | Leave a comment

Sparse Trees

Emacs Elements has a short video on sparse trees. The TL;DR is that sparse trees give you a method of filtering an Org file to show only the information that you’re interested in. The information can be random text, a tag, a property, deadlines, dates, or date ranges.

Unfortunately, the video doesn’t capture the full power of sparse trees. It makes it seem as if all it does is highlight the matches in the visible buffer but sparse trees are actually much more powerful. If you have a large file, it will hide any non-relevant data except for context. The rules for what constitutes “context” are slightly complex so you should take a look at the documentation for the full story.

My only complaint is that I can’t find a way to restore the original buffer after invoking a sparse tree filtering other than reloading or rebuilding the file. You can turn off the highlighting but I can’t figure out how to get the original buffer back. This is Emacs so I’m sure there’s a way but I haven’t found it1.

Another nice feature of sparse trees is that you can “stack them”. That is, after forming a sparse tree representation of the buffer you can refine that representation with further filtering.

The video is only 5 minutes, 12 seconds so it’s easy to find time for it. It will give you a good overview but you really need to check the documentation for the complete story.

UPDATE [2024-04-14 Sun 19:27]:

I just noticed that the fix for restoring the previous buffer state no longer works so we’re back to no solution to this problem.

Footnotes:

1

According to this Stack Overflow entry, there is no good way of doing this. One responder does give some code that appears to do the job.

Posted in General | Tagged , | Leave a comment