Setting Up emacs

Will Schenk has a post that may interest some of you. It’s about setting up a new Emacs instance. It’s not that he’s a n00b; he just wants to set up a nice clean instance. You can argue with his choice of themes and the packages that he chooses but the post is handy nonetheless.

He starts with installing emacs-plus from Homebrew along with the Roboto fonts. Then he disables package.el in favor of straight.el. Lots of folks have abandoned the default package.el in favor of straight.el or one of the other alternatives but I’ve never felt the need. The default system works well for me and I don’t need the pain of worrying about another package to wrangle my packages. Still, straight.el appears to be a good choice if you do feel the need for another package manager.

Next, he installs Org and counsel. Those are pretty much mandatory and I definitely agree with those choices. The last major decision is to install the Nano theme. I don’t use any theme, preferring to simply set my background to a light tan (oldlace) and otherwise use the Emacs defaults. I’ve been doing that for years and have never felt the need to change. But lots of people love Nano so if you’re looking for theme, you should take a look at it.

Schenk installs some other packages so be sure to take a look at his post to see what he’s decided on.

Posted in General | Tagged | Leave a comment

Red Meat Friday: A Conversation With An Emacs User

A conversation with a typical Emacs user:

Interview with an Emacs Enthusiast in 2033 [Colorized]
by u/miversen33 in emacs

What makes this so funny is that every outrageous statement the protagonist makes is something that we’d agree with. Sort of.

So this one is for all you Vim users and other heathen.

Posted in General | Tagged , | Leave a comment

The Other Shoe Drops

If you’re an inquisitive, rational person and haven’t been assimilated by one of the hive minds, you’ve always known deep down that COVID-19 resulted from a lab leak even if there was not yet any definitive evidence to prove that conclusion. If nothing else, you could tell from the furious dismissal of the notion by those who had the most to lose from that explanation. Once they floated the idea that the lab leak hypothesis was racist, it was all but certain that those pushing back were hiding something.

Now, it seems, the other shoe has dropped. Michael Shellenberger, Matt Taibbi, and Alex Gutentag have an article in Shellenberger’s Public substack that reports that “Patient 0” of the COVID-19 epidemic was Ben Hu a researcher at the Wuhan Institute of Virology who was working on—you guessed it—gain-of-function research.

Irreal has always felt and has often written that the best explanation for the lies and push back was given by Jamie Metzl who said,

“If the pandemic started as part of a lab leak, it had the potential to do to virology what Three Mile Island and Chernobyl did to nuclear science.”

Now it’s becoming clearer and clearer that a lab leak is exactly what happened. Virologists who resisted this conclusion will have a lot to answer for but not nearly as much as the outright liars in our government who deserve criminal prosecution for lying under oath and perhaps even for having a hand in unleashing this horror on the world. Matt Tiabbi has a separate article on the probable fallout of these revelations. Read both articles if only because so many people don’t want you to.

Posted in General | Tagged | Leave a comment

Define-keymap

Zachary Kanfer has a useful post for those of you who want to reduce to a bare minimum the amount of code you have to write to configure Emacs. Kanfer was bothered by all the boilerplate you have to enter to make a keymap so he decided to write a couple of functions that simplified the process. While getting ready to publish his code, he discovered define-keymap. It is, strictly speaking, an Emacs 29 functionality but Emacs 28 has the compat-29.el module that backports define-keymap and other functionality to older Emacs versions. The nice thing about it is that it removes all the complexity and boiler plate involved in making a key map. Basically all you do is list the bindings (as text strings) and the corresponding functions. It could hardly be easier.

Personally, I’ve never found the old way of defining keymaps that onerous—although it can be hard to remember the exact spell if you aren’t doing it all the time—so I’m not going to jump into using define-keymap but I could see myself using it if I needed a quick keymap and didn’t want to look up the make-keymap incantation.

If you’re on Emacs 29, Emacs 28, or possibly older versions, invoke describe-function on define-keymap to see all the details. If you’re into simplifying your init.el, take a look at Kanfer’s post to see one way of doing that.

Posted in General | Tagged | Leave a comment

Prot Video on Org Mode

After watching and writing about Protesilaos Stavrou’s video on searching and replacing in Emacs, I went back and watched his previous video on Org mode basics. Although I’m late to the party with this post, the video is interesting enough that I felt it was worth writing about.

Although Prot mostly restricts himself to Org mode markup, he does his usual comprehensive coverage of the material. He starts with explaining the emphasis markers (bold, italics, etc.) and gives an excellent explanation of the difference between verbatum and code. Although these both render the same in every export format I know of, it’s perfectly reasonable that some new exporter could render them differently.

Most of the rest of the video considers optimal ways of entering text in an Org buffer. He starts with headings and shows how to add additional headers at the same or lower levels, mark them as TODO items, and how to promote and demote a heading’s level. One of the most interesting things that I learned about was org-indent-mode. It provides a virtual display of an Org buffer in which headings, subheadings, lists, sublists, and other constructs are indented according to their level. The underlying file is unchanged so the exporters don’t get confused by manually added indentation. Although Prot doesn’t mention it, you can make the mode persist by adding indent to the #+STARTUP keyword in the header.

As with all of Prot’s videos, this one is well worth your time. You’ll probably learn a thing or two even if you’re already familiar with Org markup. The video is 48 and a half minutes so you’ll need to schedule some time but it’s worth it.

Posted in General | Tagged , | Leave a comment

Emacs Elements Video on Narrowing

A useful but underused Emacs facility is narrowing. The idea is that you can limit the visibility of a buffer’s text to a region, function, or an Org mode subtree. The rest of the buffer is still there but you can’t see or access it. The operations are pretty simple but still seem hard to remember for many people.

Over at Emacs Elements Channel there’s a new video on narrowing and how to use it. As I said, it’s really pretty simple despite the problem some folks have with remembering the keystrokes. The biggest problem is widening or undoing a narrowing. I don’t understand these problems even though I had them myself.

Artur Malabarba to the rescue. In his now, sadly, abandoned site, Endless Parentheses, he presents the narrow-or-widen-dwim function that makes using narrowing trivial. If you call it and the narrowing is already in effect, it widens the narrowed text. Otherwise it narrows to the proper text given the context. As I say in the above post, I don’t think I’ve called any of the narrowing functions directly since I installed it. Like Malabarba, I put it in my “toggle” key map so it’s easy to remember and use.

The video is only 6 minutes, 12 seconds long so it should be easy to watch. After you do, be sure to check out Malabarba’s function. It will make using narrowing easy. I installed it 9 years ago and haven’t used anything else for narrowing since.

Posted in General | Tagged | Leave a comment

Emacs Search and Replace

Protesilaos Stavrou (Prot) has a really, really excellent video on the Emacs search/replace functionality. Except for a short section at the end, it doesn’t consider external packages; it’s about the default functionality. Although Prot says the video considers only the basics and is not meant to be comprehensive, it is, in fact, a fairly complete explanation of how you can search and replace out-of-the-box with Emacs.

Prot starts, of course, with isearch. You wouldn’t think there’s that much to know other than, say, being able to search in reverse but there’s much, much more. You can, for example, move forward and backwards within the matches using Ctrl+s / Ctrl+r (with the default bindings). That’s pretty well known but did you know that you can exit the search with any motion command? That’s really handy if you want to position the cursor at, say, the beginning of the target word. Just type Meta+b to exit the search and put the cursor at the start of the word. There’s plenty more functionality including putting the results in an occur buffer so take a look at the video for the details.

Of course, you can also do regular expression searches. I generally use swiper-isearch from the Swiper/Ivy package to do my searches and one of its features that I really like is that a single space in a regex is interpreted as .*?. That covers a surprisingly large fraction of the cases that you use more complex regexes for. It turns out, that you can configure isearch-forward-regexp (and its backward sibling) to the do same thing. See the video for the magic incantation.

The search commands all have corresponding search/replace variants and Prot covers those too. Most of the extra functionality that Prot describes for searching applies to those commands too.

Finally the video considers occur and wgrep and how you can move to these from any of the search commands. There’s a lot of material so you need to watch it to see everything that’s available. The video is just short of an hour (53 minutes, 2 seconds) so you’ll need to schedule it but believe me, it’s worth your time.

Posted in General | Tagged | Leave a comment

Clocktables

Over at the Straightforward Emacs channel, Jake B. has an informative video on Org mode clocktables. Most Org mode users knows that you can clock in and out of Org headings giving you a way of tracking the time you spend on various tasks. That’s really handy if you’re charging for your time or if your employer requires a periodic report on the time you spent on various jobs.

That’s great but there’s much more. You can at any time generate a clocktable that will list the total time spent on each task and show a breakdown of the various times spent working on each task. Again, this is pretty well known but it turns out it’s possible to configure a clocktable in various ways to get the exact information you need displayed in the way you need it to be displayed. That includes specifying a time block—such as today, yesterday, thismonth, etc—to delimit the data included.

Jake B walks us through all that starting with a simple default table for a single heading. He uses that to show some of the configuration options and then moves on to generating a table for the whole file. Finally, he shows two ways of including data from more than one file. The first way specifies each file individually while the second is a tiny bit of Elisp that shows how to include any file matching a regular expression using directory-files-recursively.

The video is 11 minutes 47 seconds long so it shouldn’t be too hard to fit in. It is, in any event, well worth the time to view it.

Posted in General | Tagged , | Leave a comment

The Old Days

I ran across this amazing picture on Massimo, a splendid site that offers several fascinating and unusual tweets a day. If you like being surprised and astounded, give Massimo a look.

The picture is of the original IBM hard drive. Look at that monster. It took 3 or 4 men just to push it up the ramp into the truck. It looks like it must hold petabytes and petabytes of data but nope: 5 megabytes.

The minions are fond of reminding me of my advancing years but even I’m not old enough to remember this beast. When I started, on a mainframe, the drives were roughly the size of a (small) washing machine. I have no memory of how much data they held but it was surely a lot more than 5 MB.

These days you can wear gigabytes on your wrist so storage capacity is making progress. It would be interesting to know what the clock speed of the computer that giant disk was destined for. I’m pretty sure it would be underwhelming too.

Posted in General | Tagged | Leave a comment

SICP and Emacs

As you all know by now, I really love SICP and consider it among the best—if not the best—books on computer science of all time. I didn’t read it until fairly late in my career and yet I can’t overstate how much I learned from it and how much it changed the way I think about our craft. There are those—including Abelson and Sussman—who say that the approach employed by SICP is no longer applicable but I disagree vehemently. If you don’t understand its lessons then you don’t understand computer programming no matter how many robots you program.

You won’t really understand those lessons unless you work most of the problems. I mostly skipped over them on my first reading but later went back to reread SICP and work the problems. Again, I learned new things and deepened my understanding of what I thought I already knew.

Getting, finally, to the point, Konstantinos Chousos has just started reading SICP and is working the exercises as he goes along. He has a blog post that describes his workflow for studying the book. His is by no means to only such workflow possible but it’s a good one and worth emulating if you, too, want to become enlightened by SICP.

The TL;DR is that he installed SICP as an Info file so he can read it in Emacs and then installed Racket as his Scheme environment because it offers an SICP extension that recreates the original MIT Scheme that SICP uses. He also installed the emacs-ob-racket package for working with Racket from within Emacs.

He describes in detail how to install all these so it’s pretty easy to duplicate his setup. If you want to study SICP, and you should, Chousos’ workflow is an excellent way of doing so. And, you’ll end up with SICP installed in Emacs as an Info file. What’s not to like?

Posted in General | Tagged , | Leave a comment