Emacs on MacOS Catalina 10.15 in 2019
Speeding up your Emacs start up time
I have always been an Emacs lover for the sake of simplicity. With MacOS Catalina update, it is a headache as usual to getting Emacs to work seamlessly with the terminal or iTerm2, or the Finder. One can be a GTD-nerd, a writer of any kind, or just working with plain text files, and loads of information; everyone deserves the right to use free software, even if Emacs is not embed with the last version of MacOS Catalina.
If you haven’t installed Emacs yet, I would recommend you to do it right now thru your favorite shell.
brew cask install emacs
I won’t demonstrate why Emacs is awesome. It goes without speaking. You can download it from emacsformacosx.com as well if you are more comfortable with GUI package installers.
Emacs can be invoked from the command line (emacs) and the Finder (/Applications/Emacs.app). Do not forget to fix its permissions in the panel System Preferences > Security and Privacy > Privacy or Emacs won’t be able to access your hard drive.
Enable ruby as well located in
/usr/bin/ruby. After hitting the + button, press ⌘-G to open
/usr/bin . Ruby is hiding in there.
For a nice user experience (aka UX) on MacOS, I can’t stress enough to install Castlemacs. It is lightweight. MacOS keybindings are nicely integrated with Emacs’. I can use the ⌘ key for Command and Super. All of my mac and emacs keybindings are working together like a charm. None is missing.
Note: On the first run, dired gives me an error
ls does not support --dired; see `dired-use-ls-dired' for more details. Insert
(setq dired-use-ls-dired nil) in your custom.el file.
Buggy behavior: Emacs starts a new instance (and process) every time I am trying to open a doc either from the command line or the Finder. I don’t really care about that… I am more cringing about the time it is taking to boot on my shiny 2017 Macbook Pro, like… 5 seconds? Way too long for me. Textmate opens instantly (Finder or CLI). So I have this piece of code from the 60’s which is Emacs, flavored with a lightweight layer on top, taking a $4K Macintosh laptop five long seconds at startup? I can’t live with it, can’t sleep with it. It is pinching a painful nerve of injustice: am I going to pour my money into subscription software to manage my tasks, my calendar, my projects, my journals, my bills, my reports… my life? Not today.
I want Emacs to boot in a blitz on MacOS Catalina so do I need a daemon?
brew services start emacs is broken.
emacs --daemon command does not seem to help. Google is my friend, like Stackoverflow, though I could not find any cure for my pain.
I am mainly using the CLI on iTerm2. I don’t really need an .app file to double click on, or to spotlight. I am blessed to have a smart son able to speak bash fluently. He wrote me a beautiful piece of shell that does the job, all credits to him. The poetry has been commented for you to understand the true meaning of it. We want to start a server, if it is not already started. Then open our document in a new buffer.
To use your script everywhere on your CLI, you will need to add it to your
bin folder. I would recommend you to store your home-made or internet-from executables into a separate
bin folder, like I did. Create a
bin folder in your
Users/username/ home folder. Add it to your PATH in your .zshrc or .profile or .bash or .whatever. Here is the line from my .zshrc file as an example:
Create a new file with the code below. Save it to you
bin folder. Let’s call the file
# Note: X windows are referred as frames, since for emacs a window is a split of a frame. This script is called em.# The help part.
# If I type in help, or -h... I get something at least.
if [ “$1” == “help” ] || [ “$1” == “ — help” ] || [ “$1” == “-h” ]; then
echo “A dumb script to deal with Emacs Client Frame”
echo “Open a file in the existing frame or create a frame if none”
echo “If multiple frames are open, the file will be opened in the last focused frame”
echo “usage: em <name of file> [w]”
echo “ — \”w\” forces the creation of a frame even if there is already one”exit
fi# Now the meat part.# We use the command emacsclient. Get the state of the emacsclient, ‘nil’ if no frame is opened and ‘t’ if a is frame is opened
state=”$(emacsclient -qn -e “(if (> (length (frame-list)) 1) ‘t)”)”# If the server is off OR if there is no frame already opened OR if we explicitly ask for a frame using the suffix “w”
if [ “$state” == “” ] || [ “$state” == “nil” ] || [ “$2” == “w” ] ; then
# Create a frame and open the file within it
emacsclient -a ‘’ -cqn $1
# Open the file in the existing frame
emacsclient -qn $1
From the command line type in
em yourfile and add the
w suffix (without any dash) to open a new frame (X Window). The files you will open/create in your term from that on will show up as a new buffer in the last focused frame (X Window). Thus you have absolute control over frame opening without hassle.
Just remember that …
- C-x C-c kills the frame. The server remains active in the background.
- ⌘-Q kills the server. Useful if you need to test a config.
Hope you are enjoying blazing fast Emacs take-offs. There must be the possibility of building an .app executable from the script. I am adding it to my list. I haven’t found any clean and simple option yet. Should you have the answer, I would be glad to hear from you.