Fast Emacs Startup by Dumping

Many Emacs users obsess about the editor’s startup time. I’ve never understood this. Even if Emacs takes 15 seconds or more to start, who cares? The thing is that if you are using Emacs correctly, you need only start it when you boot your machine or, perhaps, update your packages. The point is, starting Emacs is, or should be, a rare event.

When I moved to Emacs from Vim 15 or 16 years ago, the hardest thing to get used to was not firing up my editor when I needed it. The correct operation was to simply start it once and switch focus to it when I needed it. Even if you can’t break the “startup the editor when I need it” habit, you can still start it once in server mode and simply invoke emacsclient when you need the editor.

Still, some folks can’t let go of the startup time issue. For those people, mmontone has a solution: dump the Emacs image after it has loaded all its packages and been completely configured. You can see exactly how to do it by following the link but Eli Zaretskii notes in the comments that the technique is not yet 100% reliable and you may have to tweak your configuration a bit to get it to work. Even so, mmontone says it’s working well for him.

Again, you’ll be much happier if you accept that Emacs should be started rarely and can wean yourself from worrying about how long those infrequent startups take.

Posted in General | Tagged | Leave a comment

Entering Special Characters with Abbrev

As I’ve said before, I do almost all my writing in Org-mode so entering special characters is easy. I can either use the built-in Org characters or drop into TeX input mode. But, of course, I’m not always in Org-mode. Sometimes I want a special character when entering a Git description—most often → but occasionally others—and there are other situations where I need them as well.

My solution—that I learned from Xah Lee—is to use the abbrev system that’s built into Emacs. Thus, I have the abbreviation /ra for →. The other day, I saw this post by The Emacs Cat on using abbrev for inputting special characters anywhere within Emacs. It’s basically the same system that I use except that I depend on hippie expand to resolve my abbreviations rather than having them expand automatically, which I find jarring.

The Emacs Cat begins each of the abbreviation keys with 8 to avoid having accidental expansions. That’s a good solution and one that many may prefer. Regardless of which method you employ, using abbrev-mode to enter special characters that you need frequently is a win. You can always drop back to insert-char, bound to Ctrl+x 8 Return, to enter those that you don’t use often.

Take a look at The Emacs Cat’s post for the details on how to set things up.

Posted in General | Tagged | Leave a comment

Time Tracking With Org-mode

Jeremy Friesen over at Takes on Rules has an interesting post on using Org-mode for his workflow. The exact situation is a bit more complex but it’s best thought of a way of time tracking.

Rather than use a packaged solution like Org-roam, Friesen rolls his own using the Org-capture template system. The basic idea is that he has projects and tasks in support of those projects. As he starts work on a project, he captures that project and further tasks are all accumulated under that project.

At the end of the month he runs org-clock-report to generate a time report for all the projects and tasks. It’s a nice workflow. One could, of course, prompt for the project for each task entry but whether that’s optimal or not depends on the individual workflow. Either way, it’s a good way of capturing the details of a workflow.

Posted in General | Tagged , | Leave a comment

Configuring Eshell

As most of you know, I’m a big fan of Eshell. It’s easy to pop in and out of it and I really enjoy its tight integration with the rest of Emacs, particularly the ability to cd to a remote machine.

Still, it’s not a “normal” Unix shell so muscle memory is useless when you want to do things like set an alias, configure the prompt, or enable color output. Fortunately, The Emacs Cat has a helping hand. In a post entitled Eshell Aliases, Prompt, And Colors, The Emacs Cat tells us exactly how to configure these Eshell features.

One thing that the post doesn’t mention is how add an alias directly from Eshell without editing your init.el or eshell/alias file. Eshell is famously lacking in documentation and it’s hard to find documentation on setting an Eshell alias. For the record, it’s here.

Setting the prompt is very fussy. Basically, you need to provide a function whose output is the prompt. The post has an example of a complex prompt that’s probably more than most people need but it’s a good go-by.

Finally, enabling color output isn’t hard but requires setting a hook function. All the details are in the post so be sure to take a look.

It’s nice to have this post because it removes some barriers to using Eshell. That is, I think, a good thing because Eshell is a powerful part of Emacs that can make all our workflows more frictionless.

Posted in General | Tagged | Leave a comment

Using Emacs to Write the Perfect Sentence

Chris Maiorana has an interesting video on using Emacs to level up on your writing. He was inspired by Jordan Peterson’s writing application essay.app. Maiorana realized that essay was pretty much like Org-mode except that it has a feature missing from Org: you can select a sentence and have it appear in a second window where you can write various versions of it and select the one you like the best. After selecting your favorite, that version is exported back to the text in the original window.

Peterson claims and Maiorana agrees that this method in effective in writing the best possible sentence. Org-mode doesn’t support this, of course, but as Maiorana demonstrates, it’s pretty easy to implement. Maiorana isn’t a programmer so his code is pretty simple but works well.

When he described the problem, my first thought was to use an indirect buffer. One of the commenters, Leslie Russell, had the same thought and came up with a slightly better implementation. It’s still pretty elementary and easy to follow. If you’re interested in something like this, grab Russell’s code (use the second version). You can just paste it into your init.el and give it a try.

I haven’t used this method but it’s certainly true that the best way to improve a piece of writing to try rewriting it. This code makes it easy to do that in sentence sized bites.

Posted in General | Tagged , | Leave a comment

John Cook on Literate Programming

John D. Cook has another post in his series of posts discussing the use of Org mode in his professional duties as a consulting mathematician. This time he discusses the pros and cons of literate programming.

He recounts the story of a blog post that had some errors that he believes might have been avoided if he’d used literate programming. He rewrote the post using literate programming and had a few observations.

First, he found that it was harder to compose the post using literate programming. There’s a lot of little markup details that you have to deal with that aren’t necessary when you just paste in a value from a separate computation. Still, that effort pays dividends if you have to update your post with new parameters and can help reduce errors.

I’ve reached the point where I do all my writing in Org-mode and always do any necessary computations in a code block. It’s a real win because if parameters change I just need to change it in one place and regenerate the document and I don’t need to worry about errors induced by pasting in values.

Take a look at Cook’s post for the point of view of someone who, although technical, is not really part of the developer community.

Posted in General | Tagged , | Leave a comment

RMS on the Development of Emacs

I know I’ve written about this before but someone posted a link to a transcript of RMS’s 2002 speech on Lisp and the development of Emacs. It’s an interesting read. Along the way RMS tells the heartbreaking story of the destruction of the MIT AI Lab and the resulting war between Symbolics and Lisp Machines Incorporated (LMI). He tells the now famous story of his independently reimplementing every change Symbolics introduced so that LMI would have them too.

RMS eventually tired of punishing Symbolics and realized that if he wanted to recreate the camaraderie of the AI Lab he was going to have to build a new, free (in the GNU sense) operating system. He was tempted by Lisp but realized that the hardware wasn’t available to support such an endeavor so GNU, as we know it today, was born.

The two parts of his talk that I liked the best are, first, his recounting of the early history of Emacs and its genesis in the TECO editor. The second part I liked was his explanation of why having an embedded Lisp interpreter in programs like Emacs is such a win. His dream of having Guile scheme being a target language for other languages’ compilers didn’t bear fruit and neither, mostly, did the idea of having Guile be a universal extension language. That’s too bad, especially considering what we got instead.

In any event, if you care at all about the history of Emacs and GNU, this presentation is worth reading.

Posted in General | Tagged | Leave a comment

Leslie Lamport on Deconstructing the Bakery Algorithm

The ACM has a short, delightful video featuring Leslie Lamport talking about his recent discovery of a surprising connection between two of his papers from the 1970s. Those papers, one usually called the Bakery algorithm and the other usually called the Time Clocks paper are well known within the distributed computing community and are still studied today.

The Bakery algorithm, that Irreal discussed previously, ensures that distributed processes execute a critical region one at a time. The Time Clocks paper discusses a distributed state machine algorithm. Lamport, in the process of writing a recent paper, discovered that the two algorithms are related and that each can be derived from the other.

Lamport explains this in a paper in the latest (September 2022) Communications of the ACM. The paper itself is here. The video is only 3 minutes 14 seconds long so it will be easy to find time for it.

Emacsers will enjoy discovering that Lamport is an Emacs user. Mechanical keyboard aficionados will appreciate his choice of an IBM Model M, which as everyone knows, is the worlds best keyboard. Finally, for those Math nerds who, like me, are lusting after his “You want proof?” T-shirt, you can get them from Cotton Expressions.

Posted in General | Tagged , | Leave a comment

Increasing the Max Open Files in Emacs on macOS

From time to time I see complaints about Emacs having too many open files on macOS. This is because Apple has set the default number of open files for a process at 1024. Sadly, you can’t fix this by upping the limit with ulimit.

There is, however, a fix although it’s a bit complicated. You have to make adjustments to both macOS and Emacs. Happily Jiacai Liu has a step-by-step procedure for upping the limit. The TL;DR is that you have to add a couple of files to your macOS installation and go through a fussy operation to get them installed. Then you have to recompile Emacs with defines for FD_SETSIZE and DARWIN_UNLIMITED_SELECT.

Apparently the problem manifests itself when you’re using Emacs with LSP so if you’re an LSP user, you may have go through the—admittedly painful—process. I haven’t run into this problem yet and part of the reason for this post is to help me remember what to do in case I do. If you’re an Emacs user on macOS, you may want to bookmark Liu’s post in case you run into the problem.

Posted in General | Tagged , | Leave a comment

Emacs Shortcuts

Just a quickie today.

Vernon Grant has compiled a list of Emacs shortcuts that he finds useful and uses everyday. Almost all of them are core Emacs shortcuts so they should be available to all Emacs users. It’s useful to read through to learn new bindings or recall ones you haven’t used for a while and have forgotten.

The list is in a GitHub repository so it’s easy to bookmark if you want to refer back to it. The list is in the README, which is a markdown file so it’s easy to capture and print if you want a cheat sheet. Here’s the file in markdown mode if you’re interested in making your own copy.

Posted in General | Tagged | Leave a comment