Create: 2022-06-13, Update: 2022-11-27
There are a lot of ways of installing Emacs onto your computer. This post would discuss about the benefits of different approaches.
There are three major operating systems, Windows, macOS and GNU/Linux. Emacs supports all three of them.
I have never tried Emacs on Windows. As far as I know, simple usage on Windows is fine, but when it comes to some integration of package, e.g. magit, due to the difference between a Windows shell and a Unix shell, user may have to make a lot of tweaks to get optimal performance. Therefore, I do not recommend using Windows on your personal computer which you can just install GNU/Linux.
I personally use Emacs on both macOS and GNU/Linux, specifically Artix Linux. The experience between those are quite similar until I use EXWM extensively on my Linux machine.
I will only be talking about installing Emacs on macOS and GNU/Linux.
The easiest way to install Emacs is through your package manager.
On Arch-based Linux.
pacman -S emacs
On macOS, via homebrew.
brew install emacs
You can download emacs from this site, nil. Although it is perfectly usable, I do not recommend it. The dependencies of this prebuilt binary may be missing on your computer leading to weird bug when launching Emacs.
Downloading binary is extremely simple. But it comes at a cost where you may not get the features you want.
I personally always compile Emacs from source regularly, which is known as living on HEAD.
Clone the source.
git clone https://git.savannah.gnu.org/git/emacs.git
Sometimes, the gnu source is quite slow, you can try the github mirror.
git clone https://github.com/emacs-mirror/emacs.git
Go the emacs directory and run autogen.
At this step, you may encounter some errors about missing dependencies. You can install the required dependencies via package manager. If failed, try google the package name with your os. Often it is because the package has a different name in the package repository.
Configure. Configuring may seem to be an alien thing to many people. But here is where we select what features we want in our own Emacs build.
We can have a look the supported switches.
Most of the time, I would compile with these flags.
./configure --with-native-compilation \
If you are on version 28 or earlier, omit the last
flag. This is a feature introduced in the latest HEAD that support
pixel perfect scrolling.
Build. This will compile Emacs with all the CPU cores of your computer.
sudo make install
On macOS, I personally prefers the emacs-mac build by Mitsuharu Yamamoto. Since it has very great integration with macOS, e.g. smooth scrolling, force touch to open dictionary at point. The only drawback is that, Mr Yamamoto only updates at stable releases. Therefore, the latest version of emacs-mac is still at 28.1.50.
I used to clone the source from him and compile. But thanks to the hard work of github user railwaycat, we can compile with homebrew easily. emacs mac port
Add a new tap.
brew tap railwaycat/emacsmacport
Configure and build. We would also like to check out the available flags.
brew info emacs-mac
Here is a list of flags I personally use.
brew install emacs-mac --with-native-compilation \
Emacs will automatically build and install.
Add emacs to application folder. This is a script suggested by homebrew after compilation.
For ARM-based mac, e.g. M1 MacBook.
osascript -e 'tell application "Finder" to make alias file to POSIX file "/opt/homebrew/opt/emacs-mac/Emacs.app" at POSIX file "/Applications"'
For Intel-based mac.
osascript -e 'tell application "Finder" to make alias file to POSIX file "/usr/local/opt/emacs-mac/Emacs.app" at POSIX file "/Applications"'
There are a lot of flags for us to configure. I would explain why I choose these compile flags.
Normally, Emacs compile the elisp file into byte code. Native compilation enable Emacs to compile elisp file into native code, which greatly enhance the performance, at the cost of higher usage of disk space to store the larger native compiled files.
This is a game changer to Emacs performance, especially on old hardwares. The user experience is like day and night. Nevertheless, on modern hardware like the M1 chip. The difference is nearly unobservable. I started a poll on Reddit a while ago, and received similar observations.
Anyway, disk space is cheap. Native compilation is reliable. I will always enable it.
This depends on
This flag enable native json support on Emacs, which in turns improve lsp performance.
This depends on
libjansson. Normally you would not have to enable
this flag manually, Emacs automatically compiles with it when it
This embeds a fully functional browser inside Emacs. On Linux, it depends on webkitgtk. On macOS, it uses Safari.
Be careful, this will crash Emacs if you are at version 28 using EXWM. Only use it at HEAD.
I use to think this is redundent on Linux, since I can use Firefox with EXWM. But xwidget renders HTML email more accurately, (I think people who send HTML email should go to hell), and have a better experience reading epub file.
Imagemagick is a great tool to convert image into different size and format. But I somehow have no idea what it does when it compiles with Emacs. I enable this flag is solely because I have imagemagick on my machine anyway.
As I said above, this flag enable `pixel-scroll-precision-mode', but only available on latest HEAD. If you are using macOS, do NOT enable this flag.
I always uses gtk3, but a while ago, gtk3 has a child frame display bug. But thank to the maintainer of Emacs, the bug was solved shortly after my bug report.
At the time gtk3 was no usable, I have switched to athena. Actually, x-toolkit does not matter that much. I even tried to build "--with-x-toolkit=none". Everything was fine.
Since I am using "--with-xwidgets", I would just use gtk3 also.
This is a special flag in the emacs-mac repo. If you are not building with railwaycat's brew tap. You are likely to encounter a bug that you can not open Emacs.
Without this, Emacs would use OpenGL instead. But metal is the new graphic api and OpenGL is being deprecated for years. Although no observable difference, I would always be the early adopter.