Optimizing Startup With Use-package

James Cherti has another excellent post, this time on optimizing Emacs startup with use-package. The idea is that many configurations load a substantial number of packages and that this can cause a significant increase in startup time.

Most of you know by now that we here at the Irreal bunker refuse to worry about that because, after all, we hardly ever restart Emacs. Still, plenty of people do worry about it and there’s nothing wrong with learning a few easy to implement principles that will speedup Emacs startup without having to obsess about tiny details.

The TL;DR is to get use-package to defer loading of packages until they are actually needed. Most Emacers who aren’t complete n00bs already know this. The question is, how exactly, to specify the use-package commands to achieve that.

The obvious answers aren’t the right ones. For example, the :defer keyword seems like the natural answer but Cherti explains why this isn’t usually necessary and that it doesn’t do what you probably think it does. It’s much better to use one of the commands that implicitly defer loading but also arrange for autoloading the required functions when they’re needed.

Cherti also explains how to get use-package to add logging information to the *Messages* buffer to help with understanding the load process. There’s a lot of information in Cherti’s post and it serves as a handy reference for how to use use-package to control the loading of packages at startup time. If you’re at all worried about startup time or just want to understand how to use use-package to control package loading, take a look at his post.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: The EU Is Becoming Tiresome

Apologies to my European friends but the EU—or rather its regulators—is becoming tiresome. It’s bad enough that they treat American tech companies as piggy banks—like this almost billion dollar fine because Uber used automated systems to identify and temporarily suspend drivers suspected of fraud—and promulgate regulations that provide European citizens absolutely no benefit while depriving them of the latest technology such as the enhanced Siri from Apple. According to that last link, even European citizens are fed up and protesting the silliness. It doesn’t seem to have had any effect. The regulators keep right on disrupting everybody and everything because…reasons.

Even the much vaunted GDPR cookie rules that were supposed to protect us from online snooping have only made matters worse (see footnote) and subjected the whole world to annoying dickovers assuring us that they value our privacy so would we please let them surveil our activities. Really, their whole regulatory establishment is in need of adult supervision.

All of that is bad enough but this is going too far. Despite repeated, failed attempts to mandate an encryption backdoor, the Commission is trying again. This despite the unanimous opinion of virtually everyone who knows what they’re talking about that a “safe” backdoor is imposible and among other things would be disastrous for digital commerce of all types. Meanwhile, the bad guys will simply roll their own.

What’s worse is that this latest effort will only encourage other jurisdictions to do the same thing. We here in the U.S. can look forward to similar proposals soon.

Posted in General | Tagged | Leave a comment

The Vim UserGettingBored Autocmd

Evan Hahn has an amusing post about the Vim UserGettingBored autocmd. Autocmds in Vim are essentially like hook functions in Emacs. They get fired when certain events happen in the editor.

Way back before Vim 6.0, Bram Moolenaar added the UserGettingBored autocmd to the Vim documentation. It was a joke and the command didn’t actually do anything—or rather, it was never invoked and didn’t really exist. It was like an Emacs hook that was documented but didn’t actually occur. The documentation said “When the user hits CTRL-C. Just Kidding.” In 2013 the documentation changed to “When the user presses the same key 42 times. Just kidding! :-)” and, there were various other tweaks along the way. Finally, in 2022 an unofficial plugin was created by Mike Smith that actually implemented the autocmd and did something. You can read what it was in Hahn’s post.

None of this matters at all, of course, except to provide evidence that Vim users can be as whimsical as us Emacs users. You probably won’t see anything like this in VSCode. It wouldn’t be “professional”.

Posted in General | Tagged , , | Leave a comment

The Newcomers Presets Theme

As the result of a long standing discussion on the Emacs devel list, Emacs 31 comes with what amounts to a starter kit called newcomers-presets1. The idea is to provide newcomers with a set of useful configurations to help them ease into Emacs. It is, however, much more than training wheels for n00bs. The presets described in it are ones that most experienced Emacs users are already using.

I know this because last April Sacha Chua wrote a splendid post that describes what’s in it. I somehow missed it back when she first posted it but she mentioned it in the latest Emacs News. As I’ve said before, I don’t usually write about things that she’s already covered in Emacs News but I broke that rule yesterday so I might as well break it again, especially since her post is especially worth your attention.

When newcomers-presets was first introduced I didn’t pay too much attention to it but then Prot recommended it for experienced users as well as beginners. The problem was that I was unclear on what exactly it did. Then I saw the reference to Chua’s post. It has a comprehensive list of what it does along with a explanation for each setting.

I won’t be using it because I’m not a fan of starter kits for experienced users and because even if I like everything in it today, it could change tomorrow. It’s better, in my opinion, to see what’s in it and add the things you think are useful to your own configuration. Chua includes a handy “Copy code” button with each item to make that easy.

Footnotes:

1

For some reason it’s described and implemented as a “theme” but actually has little to do with themes as we normally think of them.

Posted in General | Tagged | Leave a comment

Wordcraft

I do a lot of writing, almost all of it in Emacs so I’m always happy to see how other people use our editor of choice for writing. The latest example I’ve found is from JTR over at The Art Of Not Asking Why. His post considers some simple expansion functions in Emacs.

He starts off with dictionaries. As many of you know, I’ve been a Webster 1913 dictionary user ever since James Somers explained why I (and you) should be. I have gone through many iterations of integrating it into Emacs but have converged on the same solution that JTR uses: the built in dictionary-search function built into Emacs that we both have configured to use the online collection dict.org, although I still have a local copy from my previous iterations.

The dict.org collection is nice because it contains several dictionaries besides Webster’s, and dictionary-search will return entries from all of them that have the word you’re looking for. The best part is that it’s trivial to set up You don’t have to download dictionaries or packages. You simply set a variable saying you want to use dict.org and that’s it. There are some nuances with that so be sure to read JTR’s post or the documentation.

JTR’s post is worth reading just for his dictionary advice but there’s more.

Next he briefly discusses Hippie Expand, a way of completing words based on a list of functions that you can specify. I’ve been using it for a long time, but his list of completion functions was more complete than mine so I stole it.

Finally, he considers ispell. If you’ve been following along, you’ll know that I recently started using Jinx instead of ispell but JTR showed me a couple of things I didn’t know about. I’ve always used ispell with flyspell so I never learned some of its extra tricks. One of those is a sort of fuzzy search for a word you’re not sure how to spell. That happens to me a lot so I was glad to find out about ispell’s ability to handle it.

The other thing you can do with ispell is to use it as a quick way of doing a replace. Take a look at JTR’s post for more on both those functions.

JTR’s post is from last week so Sacha will doubtless cover it before you see this but I had a lot to say about it so I decided to write about it anyway. It’s definitely worth a careful reading.

Posted in General | Tagged | Leave a comment

Recipe Cards

Today’s topic seems odd for Irreal. Even tagging it as “Tech” seems odd but bear with me. If you’re like me and have a hard time following most recipes, today’s post has a solution. It’s all about a new format for recipe cards. A lot of the reason many of us nerds have a difficult time with cooking is the standard recipe card. We want it to be like a program we’d write but it isn’t really like that. You can make the case that the list of ingredients that typically start the standard recipe card is the data declaration and the (dense) text that follows are the commands but that remains unconvincing, at least to me.

The format recommended at the above link was invented by software engineer Michael Chu. He brings an engineer’s sensibilities to the problem. Take a look at the sample recipe cards at the link. Notice how the whole process just jumps out at you. It’s immediately clear what you do with what and in what order.

The only problem with the system is that it’s been completely ignored by the people who write recipes. There are a couple of solutions. First, Chu maintains a site, cookingforengineers.com, that uses the system.

Second, @juanbuis, whose tweet started the rediscovery of Chu’s system, built a site that accepts a standard recipe and spits out one in Chu’s format. The minions generally discourage me from entering the bunker’s kitchen so I haven’t tried it but it seems useful.

Take a look at that first link and I think you’ll agree that it’s a worthy topic for Irreal and deserves the “Tech” tag.

Posted in General | Tagged | Leave a comment

Maiorana On Directory Local Variables

Chris Maiorana has a useful post on directory local variables. The idea is that rather than putting a lot of context specific configuration in your init.el file, you can put those configurations in a .dir-locals.el file and they will be set only when you open a file in that directory.

I really like the idea of directory local variables but it has never worked well for me. That’s mainly because I usually wanted to execute some code using the eval keyword. That always causes some problems involving a stack overflow, no matter how simple the code is. Lately, I’ve been using them a lot in conjunction with Jinx, which has the nice feature of adding words to the local file or local directory in addition to the other usual options.

I find that really useful for my blogging. I can add post specific words to the post source file itself or I can add them to all posts in my blog directory. Maiorana uses then to set things like compilation settings, fill and wrap settings, and indentation styles.

If you have different workflows with different setting needs, directory local variables is a very nice way of dealing with them. Of course, not everything should go in a directory local variable. Some things apply to all your buffers and should go in your init.el but for those things that are specific to particular workflows, directory local variables are just what you need.

Posted in General | Tagged | Leave a comment

Emacs Configuration Organization

Emacs configurations are like well shuffled card decks: no two are alike. But, as Arlo Guthrie famously sang, that’s “not what I came to tell you about”. Rather, this post is about differing organizations for those Emacs configurations.

The idea was suggested to me by a post from Andros Fenollosa on his own Emacs configuration. Fenollosa says that he doesn’t use any of the all-in-one configurations like Spacemacs or Doom because they include too much and are hard to understand and make changes to. He also doesn’t use the popular literate configuration method using Org mode because it’s just another layer of complexity that can go wrong.

His idea is to to have a separate file for each “area of responsibility” and to use init.el as a sort of index that loads them in order. I like that idea but don’t use separate files. I keep everything in init.el and just organize it in sections.

Still, Fenollosa has a good argument for the separate files but I think I get the same benefits with a single file broken into sections. Actually, it’s not quite true that everything is in a single file. I run Emacs on several type of systems and keep the system/OS specific information in separate files that I load conditionally based on the system and OS type1. That way I don’t have a lot of conditionals dealing with system/OS type in init.el itself.

There aren’t as many ways of organizing your Emacs configuration as there are configurations but there are a lot of them. What principle do you use?

Footnotes:

1

If you’re interested, here’s the code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Pull in system and platform specific configurations                    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Just keep on going if the requisite file isn't there.
;; Manipulations in second load is for "gnu/linux" → "linux"

(load (car (split-string (system-name) "\\.")) t)
(load (car (reverse (split-string (symbol-name system-type) "/"))) t)
Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: Acronym Of The Day

Rick Manelius has proposed a new acronym: AI;DR. It stands for “AI; Didn’t Read”. He says that it actually originated with @seclilc here. Manelius isn’t an AI hater and, if fact, uses it himself. It’s just that he objects to asking someone a question and getting back an unedited—and probably unread—answer from a chat bot in reply. His new policy, he says, is that if you can’t be bothered to read and edit it, then he’s not going to bother reading it.

Really, responding to someone’s question with a buffer full of AI slop is profoundly disrespectful and will cause you to forfeit the goodwill and respect of your victim. If you want a less touchy-feely explanation, Manelius has an update pointing to dontpastetheai, which expresses the same sentiment in less circumspect language.

I’m sympathetic to all of this. If I ask someone a question, it’s because I want the benefit of their wisdom not some distilled twaddle that may not even be correct. If they don’t know or don’t have time at the moment to provide a detailed answer, I’m fine with their saying so. Just don’t send me some slop that even they can’t be bothered reading.

Posted in General | Tagged | Leave a comment

Tweaking Emacs Scrolling Behavior

For me, one of the most difficult Emacs behaviors—or at least “normal” Emacs behaviors—to understand is scrolling. The default behavior is so unintuitive and jarring that it kept me from embracing Emacs for a long time. It was only after I took the plunge that I discovered that that behavior, like everything else in Emacs, is configurable.

That was almost 20 years ago when I was just starting and knew next to nothing about Emacs configuration but I was able find the solution on the Internet. Here’s what I’ve had in my init.el almost from the beginning:

(setq    ;set reasonable scrolling
 scroll-margin 0
 scroll-conservatively 100000
 scroll-preserve-screen-position 1)

Back then, I had no idea what any of it meant, only that it made Emacs scrolling rational by my standards. It’s been sitting there undisturbed ever since.

Now James Cherti has a really excellent post that expains all the fine points of configuring scrolling. He explains the above lines, which most people probably have in their configuration. If you want Emacs scrolling to behave as it does in every other application, you can leave them as is but you can tweak the behavior a bit if you like. Cherti has all the details.

But wait. There’s more. There are similar settings for horizontal scrolling that you might like. I’ve never had any problem with horizontal scrolling—probably because I’ve always wrapped lines in one way or another—but they’re there if you need them.

There are some other tweaks that you can apply to delay fontification during scrolling to speed things up a bit. Again, this is not something that I use but if you deal with large files, you may find it useful.

In Emacs 29 and later you can set pixel-precise scrolling to make scrolling over images more pleasant. There are a few other tweaks in Cherti’s post so you should definitely take a look at it. There’s a lot of good content and even if you use only a bit of it, you will find his post worthwhile.

Posted in General | Tagged | Leave a comment