OrgFolio

Chris Maiorana takes a lot of notes. He’s a writer after all. Once he’s taken those notes, he wants an easy and convenient way of viewing them. These days that usually means viewing them as a Web page.

Org mode, of course, has all the machinery in place to do this essentially automatically but Maiorana has some problems with it. He has multiple notebooks and finds it a pain to set up the ox-publish scaffolding for each one.

But this is Emacs so, of course, it’s easy to automate the process. Maiorana did that by writing a simple script, he calls OrgFolio, that

  1. Deletes the existing Web content
  2. Builds the scaffolding to export the Org files and exports them
  3. Copies any static content, such as CSS files
  4. Spins up a local Web server to show the content

All of this is kicked off from the command line with a call to Emacs in batch mode. It’s easy and has no overhead. It does require building everything from scratch,. which could be a problem for a large set of notes. That’s one of the reasons that Maiorana keeps a separate notebook for each topic.

I take copious notes about everything but they’re mainly for me so I see no need to export them to HTML. I’m perfectly happy to see them in plain text, just as I wrote them. That said, I do write them—complete with Org markup— as if they were going to be exported.

Still, if you take a lot of notes and would like to consume them as a Web page on your own private Web site, take a look at Maiorana’s post. His Elisp script is easy to read and modify if you want to adjust it for your own needs.

Posted in General | Tagged , | Leave a comment

Mistake: Not Embracing Emacs Fully From The Beginning

Eric MacAdie has a contribution to this month’s Emacs Carnival that talks about his major mistake in learning and using Emacs. That “mistake”, he says, was not embracing Emacs completely when he was introduced to it. Instead, he learned only a few commands—he estimates about a dozen—and limped along with those. He might as well have been using Notepad.

Fortunately MacAdie did finally fully embrace Emacs and started to learn as much as he could about what it had to offer. This wouldn’t have been much of a story except that I keep seeing people expressing the attitude that they’re too busy to learn Emacs. “Why doesn’t it just work out of the box?”, they ask.

The thing is, it does work out of the box. To be sure, your Emacs life will doubtless involve customizing it to fit your specific workflow but Emacs is perfectly usable without making a single change. The thing is, you have to be willing, as MacAdie was, to actually make the effort to learn Emacs in order to realize its full power.

Learning Emacs is not trivial but it’s also not that hard. Irreal has published plenty of stories detailing its advanced use by non-technical people, most recently here. If you want to advance beyond, say Notepad, put in the effort to learn Emacs. It will reward you far in excess of your effort.

Posted in General | Tagged | Leave a comment

Chris Maiorana On Hl-line-mode

A couple of years ago, I wrote about Chris Maiorana’a post suggesting that writers adopt a one-line-per-sentence workflow. You can read his post on the matter to see his arguments on why. At the time, I wrote that I used that method for my two books but because it worked better with the [GT]roff typesetter rather than for any writer workflow reasons. Since moving to Org mode for my writing I’ve given it up not least because it doesn’t play well with WordPress where a lot of my writing ends up.

Maiorana is back with another post on the subject that those who embrace the method may find useful. His idea is to use Emacs’ hl-line-mode to highlight the current line. That brings some other benefits to the one-line-per-sentence method that Maiorana describes in his latest post.

I used to use hl-line-mode, although not in conjunction with one-line-per-sentence, but stopped because it interacted poorly with some other mode—probably visual-line-mode where it highlights whole paragraphs. Even when I was using it, I sometimes found it annoying despite it being useful for locating the current line. I’m sure I’m in the minority on that so you should definitely give it a try if you’re not familiar with it. It’s builtin so you can simply toggle it on for the current buffer with Meta+x hl-line-mode to try it out.

Posted in General | Tagged | Leave a comment

Saving Emacs Buffers Automatically

A couple of months ago, I wrote about friction in saving files. Emacs, of course, tries to protect you from unsaved buffers by periodically backing them up to a special file. Recovering data from that file can be a bit finicky and since Emacs and modern computers don’t crash very often, you don’t get a lot of practice.

A long time ago, Bozhidar Batsov solved that problem with super-save that saved buffers whenever the buffer loses focus or perhaps every few seconds. It’s all configurable, of course. In the mean time, James Cherti wrote buffer-guardian.el that does pretty much the same thing.

Cherti’s solution took advantage of more recent Emacs features to provide a more reliable solution. When Batsov “stumbled upon buffer-guardian.el” he decided to revisit super-saver, which he hadn’t touched since 2023. He’s improved the detection of buffer focus change no matter how it’s invoked. There are a several other improvements that you can read about in Batsov’s post.

I’m inclined not to like my software doing things automatically that I’m used to asking for explicitly so neither buffer-guardian nor super-saver appeal to me but I’m probably in the minority on this so many of you probably will like using one of these packages. As I say, I don’t use either one so I can’t comment on their relative merits but they both seem like useful and worthy packages.

If you’re bad about saving your files and worry that you may lose work, you should take a look at these packages. One or both of them may be just what you need.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: User Hostile Websites

A month ago I wrote about why I was still using an ad blocker. The TL;DR was that unfiltered websites have become too horrible to be usable. Ads popup to cover the content you’re trying to read, videos play—and loudly—without being invited, and the site doesn’t stabilize for quite a while. Sometimes this activity continues for as long as you’re on the site. Take a look at this site without an ad blocker to see what I mean.

I’m not the only one who has noticed this. Over a Daring Fireball, John Gruber has a post that discusses this problem by reporting on Shubham Bose’s post on The 49MB Web Page. Bose’s post gets its name from this experience:

I went to the New York Times to glimpse at four headlines and was greeted with 422 network requests and 49 megabytes of data. It took two minutes before the page settled.

Gruber and Bose explore this phenomenon and explain why it happens. It’s obvious that the dreadful user experience that these sites deliver aren’t for the readers’ benefit but, they argue, they’re also not for news sites’ benefit. The only ones who benefit are the diseased surveillance-based advertising industry.

The readers lose because it takes time and cognitive overload to read a simple story. The news sites lose because abusing readers is not sustainable and those readers will abandon the news sites when they’ve had enough. But the news sites have decided on the short term advantage of a few ad impressions rather than the long term advantage of sustaining and growing their readership. As I said, only the execrable surveillance-based advertisers win.

It’s way past time that we, the readers, started refusing to play this game and simply ignore the sites that abuse us. My guess is that it would have already happened were it not for the fact that every sane person is using an ad blocker.

Posted in General | Tagged | Leave a comment

Surround.el

That didn’t take long. After yesterday’s post on adapting Bozhidar Batsov’s delete-surrounding-pair function to handle Org markup, Batsov is back with a post on surround.el, a port of surround.vim from Michael Kleehammer. The point of delete-surrounding-pair was to (sort of) emulate Vim’s surround plugin. Now with support.el, there’s no longer a need for delete-surrounding-pair.

Surround does everything delete-surrounding-pair did and a lot more. You can delete surrounding pairs, add pairs, change pairs, mark or kill the content between the pairs, or even kill the text and the surrounding pair. It really is a splendid package and I’ve already added it to my configuration and deleted my adaption of delete-surrounding-pair.

Surround will check if the pair you’re operating on has different opening and closing characters and do the right thing automatically. The other nice thing is that there aren’t a lot of key sequences to remember. Once you pick a prefix that you’ll remember the (single) action keys are mnemonic and easy to remember. In any event, which-key pops up a reminder.

I installed it with the recommended prefix of Meta+ but keep wanting to invoke it with Hyper+ so I’ll probably change it but, regardless, I’m already enjoying using it.

Take a look at Batsov’s post or the Github repository for all the details. Batsov’s post has some recommendations on when you should use it and Kleehammer’s repository has information on shortcuts and auto mode, which you should read. This is a really useful package and I recommend that everyone take a look at it.

Posted in General | Tagged | Leave a comment

Delete Org Markup Pairs

The other day I wrote about Bozhidar Batsov’s post on deleting paired delimiters in Emacs and mentioned that he included a bit of Elisp that—sort of—duplicated the behavior of Vim’s surround.vim. The idea is that if you are in a delimited expression and invoke the function, it will ask what delimiter you want to delete and will delete the closest enclosing pair. That obviously has some shortcomings such as not recognizing if one of the delimiters is in, say, a string. Still it’s handy code that does the right thing in most cases.

The code was interesting but I thought I didn’t need it because delete-pair already handled all the cases I was concerned with. As I was writing about Batsov’s post, I had something like =some text= and realized that I didn’t want it displayed in monospace after all. Since delete-pair was on my mind, I tried it but of course it didn’t work because = isn’t a delimiter that delete-pair recognizes so I deleted them by hand.

Later, I realized that I could simply add the Org markup pairs I was interested in to Batsov’s code so I did that and added it to my init.el. It worked perfectly and now I have an easy way of deleting Org markup .

It’s worth noting that Org mode gives you a way to do the opposite too: if you highlight some text and call org-empasize (Ctrl+c Ctrl+x Ctrl+f) it will add the Org markup you choose to the highlighted text.

Note

After I wrote this post, I found out about surround.el. More about that tomorrow.

Posted in General | Tagged , | Leave a comment

Non Programmer Use Of Emacs

A recurrent theme here at Irreal is that Emacs is for everyone, not just programmers. Every time I find an example of this I try to write about it. It’s a point that Protesilaos Stavrou made in his recent FOSS @ Oxford talk.

Now, in a lovely piece of serendipity, we have Randy Ridenour providing a real world example. Ridenour is a Philosophy professor and, as he himself says, is by no means a programmer. Still, as Prot suggested, he has learned enough to automate some of his Emacs tasks. He started by copying other people’s code but tried to understand what it did.

Now he needs to convert quiz questions from one format to another for the learning management system that his university uses—see his post for the details. This amounts to running a series of regular expression replacements, which he did by hand for a while. Then he realized—as I always find myself doing—that he could just write a bit of Elisp to automate the process.

Ridenour isn’t a programmer and he isn’t a young turk who grew up with all this technology. He’s old enough to have a married daughter so while he may or may not qualify for the Irreal Geezer Club, he is obviously well along in his career. And yet he finds it easy to learn enough Elisp to reduce the friction in his workflow. His colleagues are probably still grumbling about how hard it is to deal with the quizzes but he’s turned all those problems over to Emacs.

Posted in General | Tagged | Leave a comment

Why You Should Use use-short-answers

A perennial problem for Emacs users are the yes/no prompts that require answering “yes” or “no” instead of just “y” or “n”. The usual solution—adopted by almost everyone—is to alias yes-or-no-p to y-or-n-p. Sometime around Emacs 28 or 29 the new variable use-short-answers was introduced as another way of solving the problem.

The last time I wrote about solving the yes-or-no-p problem, I said,

I’ve had my original aliasing code for at least 17 years and see no reason to change it. When use-short-answers was first introduced, I thought I should adopt it but I never did and as far as I can see, it doesn’t make any difference.

That statement was wrong in two ways. First, as related by Bozhidar Batsov, the alias trick doesn’t always work with native compilation because the call to yes-or-no-p may have been compiled before the alias is made. For that reason, use-short-answers is the better solution because it always work.

The second way it was wrong is that when I went to add use-short-answers to my init.el, I discovered that I had already done so, probably back in Emacs 29.

Posted in General | Tagged | Leave a comment

Removing Paired Delimiters In Emacs

Bozhidar Batsov has a nice post on delete-pair. It’s almost a case of the Baader-Meinhoff Phenomenon. Five months ago—before I wrote about it—I’d never heard of delete-pair and now it’s popping up on Batsov’s blog. Batsov, himself, doesn’t remember hearing about it before either.

For those who came in late, delete-pair does just what it says on the tin: delete the delimiter at point and its matching closing sibling. It’s actually quite flexible and usable in surprising ways as you can see from the_cecep’s original post that inspired mine.

The delete-pair command came to Batsov’s attention because it interacted poorly with his Neocaml package. That turned out to be because delete-pair makes assumptions that might not hold for languages with unusual syntax.

Batsov’s post is mostly a summary of what he found from researching the deletions of pairs in Emacs. For Lisp languages, all you need is paredit which has multiple ways of removing a delimiter pair. Probably the easiest is paredit-splice-sexp.

There’s also smartparens that also has several ways of removing a delimiter pair and has the advantage of working in all languages, not just Lisps. Batsov finds it too heavyweight for his needs but lots of folks swear by it.

Finally, there’s the builtin electric-pair-mode, which keeps delimiters balanced, pairs nicely with delete-pair, and is probably all most people need.

Take a look at Batsov’s post for more details and for a bit of Elisp that recreates Vim’s vim-surround. I was glad to see his post because I was right on the verge of forgetting delete-pair even though I’ve assigned it a keyboard shortcut.

Posted in General | Tagged | Leave a comment