Emacs on OSX

I have a bit of a problem… It can be a little awkward to bring up in some circles… I’m an a massive fan of Emacs. 😂

If you’ve never heard of it before then all you need to know if that Emacs is an open source, highly extensible text editor. Emacs is still in active development despite wikipedia saying the initial release was in 1976 and that amount of continuous support should give you a clue that there is some value hidden in Emacs’s murky, lisp configured depths.

The absolute best description I’ve heard for Emacs is, ‘The tinkerer’s editor’. This is tongue in cheek because Emacs is really naff until you put some effort into configuring it. It is very, very easy to spend more time configuring an Emacs setup than actually doing the work you’re supposed to be doing.

Anyway. I have an OSX box provided by my employer and getting Emacs to run properly can be a frustrating experience on a mac. There are many different blog posts documenting equally as many different approaches to how one can install and run Emacs on a mac and I’m aware that I’m currently adding another entry to that pile but… This is how I got Emacs 28.2 running with a Emacs client / daemon setup on OSX.

Emacs is not a well-behaved citizen of macOS. —yabai wiki

What do I want?

I’ve already said there are several different ways to go about getting Emacs running but here is what I wanted from my Emacs installation.

Ability to run an Emacs server / daemon at launch

Emacs is designed to be run as a client / server. You don’t have to but it feels a lot better as a user when you do. Opening multiple windows quickly as they don’t need to take a few seconds loading configuration.

An Emacsclient to talk to that server

Since I want to run an Emacs server in the background I also want an emacsclient! Preferably one that is bundled with the Emacs installation which doesn’t always seem to be the case… Many articles have you opening up apple script to get this working properly which I’d like to avoid.

As little UI chrome as possible

I’ve been playing around with tiling window managers recently and I don’t want a title bar for an Emacs window. If this wasn’t OSX I’d probably be trying to configure this via the winow manager directly but Emacs can let you disable the chrome.

Picking the right installation

I tried several different approaches to install Emacs so you don’t have to… Eventually I settled on using homebrew-emacs-plus.

The homebrew-emacs-plus package is pretty neat. It bundles a few extras into vanilla Emacs and provides a selection of major versions to install all via homebrew. There are also many different flags you can pass to brew to further refine any extras you want Emacs to be installed with.

The package installs an executable for Emacs and also one for emacsclient too. Even better, the package provides a brew service so you can configure Emacs to launch at start up without needing to touch launchctl or write a plist file directly, all of that is hidden away. This makes installation and setup of the Emacs daemon super simple.

brew tap d12frosted/emacs-plus
brew install emacs-plus --with-no-titlebar-and-round-corners --with-native-comp

# using a brew service will get emacs to start at launch
brew services start d12frosted/emacs-plus/emacs-plus@28
# under the hood this runs emacs --fg-daemon

# start an emacs client creating a new frame
emacsclient -c

And I’ve got an emacsclient starting almost instantly. 🎉

Figure 1: A new Emacs Client

Figure 1: A new Emacs Client

The, ’loaded in 11+ seconds’, is the time the Emacs daemon took to load my configuration and download any packages etc. The client itself opens practically instantly which is great.

Thanks for reading! :-)

[Tom Heyes]


640 Words

2023-09-02 09:13 +0000