Emacs And Lisp

Joe Marsahll has been blogging up a storm lately. One of his latest posts is a sort of personal history of Emacs and its relationship to Lisp. When Marshall started as an undergraduate, he was using the line oriented editor TECO. If you think your experience with an editor is difficult, read his description of what it was like to use TECO.

Soon he was directed to Vi and a whole new world was opened to him. He no longer had to work in the blind but could actually see what he was doing. Later, when he moved to MIT he was introduced to Lisp and various early incarnations of what we now think of as “Emacs”.

Emacs, of course, began life as a set of macros for TECO so, in a sense, Marshall revisited TECO when he started working at the MIT AI lab. but the Lisp Machines that were developed in the AI lab had their own Emacs clone integrated into the system. In his career he has used a wide variety of Emacs-like editors but like all of us he’s using GNU Emacs these days.

One of the things Marshall talks about is using Sly with Emacs to recreate his experiences on the Lisp Machine. Sly, he says, pretty much recreates the interface that you had using ZWEI—an early version of Emacs—on a Lisp Machine. I’m still using Slime for my Lisp coding but, as I have written many times, I have a long standing urge to work on a Lisp Machine so I may give Sly a try if only to get closer to the Lisp Machine experience.

Posted in General | Tagged | Leave a comment

Prot On Elisp

If you follow the various Emacs forums, you’ll see a lot a whining about how hard Elisp is to learn and how things would be so much better if only the extension language were something rational like Python, Ruby, or Lua. I rail frequently against this nonsense but Prot (Protesilaos Stavrou) stands as an unassailable refutation of the silliness.

He’s a guy with a liberal arts education who has no training in programming and yet has nevertheless produced some really great Emacs software. If you look at his code, you can see that he’s obviously mastered the intricacies of Elisp.

Now, Prot has shared some of his knowledge in the form of a short Elisp tutorial. Although Emacs is exhaustively documented, there’s a dearth of Elisp documentation for beginners. There is, of course, the Elisp manual, which is comprehensive, but not really beginner friendly. It’s a reference rather than a tutorial.

There’s the builtin Elisp tutorial and Mbork’s Elisp book but not much more. I am, therefore, happy to see Prot’s contribution. I haven’t had a chance to do more than scan it but it seems like a very worthwhile addition to the Emacs corpus.

One thing for sure, it should put all the whiners to shame. If you’re claiming to be a software engineer but find Elisp too difficult to learn, you should be chagrined that a guy with no formal training in software is nevertheless able to produce first rate Elisp code that the Emacs community embraces as useful and excellent.

The irony is that Lisps in general are actually easier to learn and use than other languages. It’s just that they’re unfamiliar to n00bs so they seem unapproachable. If you just suspend your expectations from other languages, you’ll find that Elisp is actually an easy language to learn.

Update [2025-04-13 Sun 16:24]: Added link to Prot’s book.

Posted in General | Tagged , | Leave a comment

An Application Of Bloom Filters At Google

Joe Marshall, who is an old time Lisper now working at Google, has an interesting story about the use of Bloom filters at Google. The story begins when Marshall noticed an anomaly in the response time graph of one their search appliances. There was an odd blip at 300 ms across several machines that was independent of the search string.

Marshall soon narrowed the problem to the spell server that asks you “Did you mean X” when you misspell a word in your search string. Here’s how that works. When you enter a search string, each word is checked to see if it’s in the list of “known misspellings of legitimate terms”. This is done by means of a Bloom filter. The thing about Bloom filters is that if they tell you an item is not in the list then that item is definitely not in the list. But if it says the item is in the list, the item may or may not be there. If a spell server term is flagged as a misspelling, a longer running process is invoked to find the misspelling and suggest alternatives. Obviously, misflagged terms increase response time.

A good Bloom filter is designed so the probability of a false positive is minimized. Marshall gives the basic idea of Bloom filters but they’re actually a bit more complex because they use multiple hash functions. Still, his explanation tells you what you need to know: It basically hashes each word into a bit array that is false if the term is not there, and true if any term hashed to that bit location. Obviously the bigger the bit array, the less chance of a collision. You can check the linked Wikipedia article if you want the details.

Marshall’s problem turned out to be that the bit array wasn’t big enough so even correctly spelled words were being flagged. When he increased the bit array size the problem went away and the 300 ms blip disappeared.

Posted in Programming | Leave a comment

Configuring Journelly

After my post Initial Thoughts On Journelly, in which I recounted how I’m using Álvaro Ramírez’s Journelly app, Bren Smith asked me to share my configuration for sharing files between my iOS devices and my Mac. If you’re an Emacs user and want to enjoy the full power of Journelly, it’s important to be able to share the files between your iOS devices and your Macs.

The thing is, it’s so easy that it didn’t occur to me an explanation was needed. By default, Journelly keeps all its files locally on your phone or other iOS device but it’s possible to store them in the iCloud or, really, anywhere that’s reachable from your Mac and your iPhone/iPad. If you click on the three dots at the upper right of the Journelly screen and then choose Storage → iCloud Drive, Journelly will allow you to store your files in the iCloud. From there you can easily access them from your Mac.

Apple’s default location for storing the files is a long and complex file spec so you’ll probably want to set a symbolic link to it so that it’s easy to access from the Mac. Once you’ve done that, it’s easy to bring up the Journelly file in the usual way from Emacs or any other app.

It’s also possible to put the files somewhere else in the iCloud by using the Storage → Other… option. I did this so I wouldn’t have to navigate the complex file spec but in the end, it turned out to be easier to just set a symbolic link so I recommend you just use the Storage → iCloud Drive option. On the other hand, I think, but haven’t verified, that you can use Storage → Other… to store the files anywhere you like but I don’t know the details.

The other thing to keep in mind is that Journelly is still in beta so any or all of this could change. Still, I’ve been using this setup every day without any problems.

Posted in General | Tagged , | Leave a comment

Another Happy Journelly User

As you all know by now, I’ve become a huge Journelly fan. Its author, Álvaro Ramírez, thinks of it as Twitter for your private use. That’s a reasonable description given its user interface but it doesn’t begin to capture its real power.

As more and more users have started using the beta, I’ve come to realize that Journelly is a bit of a shape shifter that adapts itself to your needs. Ramírez, apparently, just wanted a simple app that he could use like a private Twitter. My use case is implementing my memo book. I want to capture entries on my phone and keep the results as a permanent record of my daily activities.

JTR over at The Art Of Not Asking Why has a different conception. He is using it as a sort of staging area for capturing notes that he then refiles to the appropriate Org files. That’s possible because one of Journelly’s strengths is that it keeps its data in Org format and can arrange to sync its files with your Mac and other iOS devices.

JTR explains all this in his latest post on Journelly in which he reveals himself as another happy Journelly user. It’s a nice post that recounts his experience with using Journelly. As I say, his use is slightly different from mine but that just speaks to the power and flexibility of Journelly. If you’re the slightest bit interested in Journelly, you should read his post.

About the only thing I don’t agree with is that JTR says that if you’re not an Emacs user, you should probably look elsewhere. Journelly is such a good fit for my memo book that I’d probably use it even if I weren’t an Emacser. But, of course, I am and the fact that its records are in Org format just expands its power for me. As Jack Baty says in a comment to JTR’s post,

I think he things of the .org thing as an implementation detail, so as to not limit his audience, but you’re right, for me it’s The Thing™.

The other thing that JTR mentions that I forgot to write about is that after tapping the big plus sign, you can enter your note orally in the usual iOS way. That’s really powerful, especially when you’re on the run.

Posted in General | Tagged , | Leave a comment

Twenty Years Of Git

Wait. What? Git is 20 years old? How can that be? I’m sure it was just yesterday that Linus announced the Git project after his arrangement with Larry McVoy’s BitKeeper imploded. That’s a sad story in itself but this post is just about how surprised I am that Git is 20 years old.

I started using Git fairly early on and soon after it became available, I moved to Magit. In the intervening years, Git has taken over the VCS mindspace. At this point, virtually everyone without very special requirements uses it.

There’s an argument to made that BitKeeper is the better solution and McVoy has made that argument in the past but BitKeeper was proprietary software in an age when developers pretty much insisted on open source tools. McVoy, to his credit, has accepted this and is devoting his time to fishing.

Whether or not Git is the best solution it has emerged as the default solution and that, I think, is a good thing. It’s definitely a good VCS and having a standardized VCS benefits us all. I have no doubt that its distributed nature is the correct answer and 20 years of Git and BitKeeper before it has proven that to be the case.

The article that I linked above has a nice history of Git and its origins. If you weren’t there to experience it, you may enjoy discovering some of that history

Posted in Programming | Tagged | Leave a comment

Emacs Startup Time

Bozhidar Batsov has a post that claims something I’ve often said: Emacs startup time doesn’t matter. No one is saying that your editor taking 30 seconds to start is acceptable but by and large the people you see worrying about startup times are obsessing over sub-second differences. That is, differences that are virtually imperceptible to a human at the keyboard.

Batsov and I say that if you’re using Emacs correctly, you hardly ever restart it. Unlike, say, Vim, you shouldn’t start a new Emacs session for each file you want to edit. When I switched from Vim to Emacs, this was one of the hardest things to get used to. Even if you do want to invoke Emacs for each file, you can simply use Emacsclient and get near instantaneous response.

Judging from the comments on reddit, you’d think Batsov had resurrected Swift’s Modest Proposal. He was accused of being arrogant and not understanding how “real” people use Emacs. If you know anything about Batsov, you’ll find that an amusing notion.

Sure, people do use Emacs in different ways and for different reasons. One commenter, for example, says he develops packages and often has to restart Emacs. John Wiegley does the same but he was a separate Emacs that starts quickly to deal with that: when you’re testing a package you probably want something approaching Emacs -Q anyway.

The TL;DR is that for almost everyone, Emacs startup time really doesn’t matter. I restart Emacs once a week when I upgrade my packages. Batsov says that he goes months without a restart. Even if Emacs did take 30 seconds to start, why would we care. One commenter complains that he has to restart Emacs every morning and, therefore, startup time really does matter. Sorry, but that’s just silly. If you have to spend 5 seconds—or even 30 seconds—starting Emacs in the morning, who cares?

And, by the way, if Emacs really is taking more than a few seconds to start, it probably means that there’s something wrong with your configuration. Mine has plenty of packages, hasn’t been refactored since I started almost 20 years ago, and it still starts within a couple of seconds. It’s hard to get a hard number because it stops to ask me for a password for my .authinfo file. I’m inclined to think of it like booting my machine: it’s not instantaneous but I don’t do it very often.

Posted in General | Tagged | Leave a comment

Setq Versus Setopt

Like most people, I use setq to set user options in my Emacs configuration. It’s the canonical way of setting a variable in just about any Lisp. But, as Bozhidar Batsov says, it’s not always the best way of setting a configuration variable in Emacs. He suggests using setopt instead.

It’s more than just a convention. The setopt macro does a bit more than setq. In particular, it can arrange to call a setter function when you set a configuration variable. This can be useful for checking the prospective value or for performing some system adjustment when a parameter changes.

I’ve known about this for a while but my problem has always been when you need to use setopt instead of setq. Batsov’s recommendation is to use setopt unless the variable is not defined in terms of defcustom. That’s all very well but how do you know which variables are which? The online documentation isn’t much help so the best policy is probably to assume that any variable in your configuration should be set with setopt unless you have reason to believe otherwise.

Batsov says that setopt will work with regular (non-defcustom variables) as well but that it won’t be as efficient as setq. Really, who cares? The setopt macro will almost certainly not be in a loop so any inefficiency won’t matter much. Plus, as I always say, if you’re using Emacs correctly, you won’t be restarting it very often in any event.

Take a look at Batsov’s post to get an idea of the difference between setq and setopt. It probably won’t help you decide which to use but at least you’ll know what each does.

Update [2025-04-07 Mon 13:42]: In the Emacs subreddit, Batsov notes that an easy way to discover which variables are customizable is to check the documentation with describe-variable. Variables that are customizable will have the notation “You can customize this variable.”

Posted in General | Tagged | Leave a comment

TestFlight

I know you will all think I’m indulging my inner Apple Fan Boyzism but I want to say a few words in praise of an Apple app. As you likely know by now, I am involved in a beta test of Journelly. You can read about my experience with that app here and here.

But now I want to write about my experience with Apple’s support of app betas. As you probably know, Apple has its App store locked down pretty tightly. All apps have to be vetted before they can appear in the store. That raises the question of what to do about betas.

Apple has a great solution. They have an app called TestFlight to make all this seamless. The prospective beta tester gets an invite from the developer, installs TestFlight, and then simply clicks on the invite. TestFlight takes care of the rest. It installs the app beta, shows you the developers notes, and allows you to open the app. After that, you can use it until that version of the app beta expires—usually 90 days.

When the developer releases a new version of the beta, TestFlight notifies you and can optionally install it automatically. In either event, you are shown the current release notes. It’s hard to imagine a more seamless procedure. Basically, TestFlight takes care of everything from the tester’s point of view. I don’t know what it looks like from the developer’s point of view but I’d be surprised if it wasn’t similarly easy.

Posted in General | Tagged | Leave a comment

New Window Commands For Emacs 31

Being a basically boring guy, I almost always have a full screen frame with two side-by-side windows for Emacs. For some functions—Magit and Elfeed are examples—I temporarily pop up a single full frame window but the previous window configuration is restored when I finish. Some of you, I know, lead less constrained lives and have more complicated window configurations.

People with these more interesting configurations sometimes want to move their windows around. When you have two side-by-side windows, that’s trivial—basically Ctrl+u Ctrl+x o is all you have to know—but if you have different sized windows stacked both vertically and horizontally, things can get more complicated.

Pranshu has a nice post that describes the problem and what he’s done to address it. The changes won’t appear until Emacs 31 but for those of you with complex window configurations they will surely be welcome.

Take a look at his post to see the sorts of transformations that are possible and the commands that implement them. To tell the truth, they make me dizzy and I’m happy to stay with my simple configuration but as always Emacs is able to adjust to everyone’s needs.

Posted in General | Tagged | Leave a comment