Books / Setting Up Development Environment on macOS / Chapter 8
Emacs
Emacs is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as the extensible, customizable, self-documenting, real-time display editor.
Development of the first Emacs began in the mid-1970s, and work on its direct descendant, GNU Emacs, continues actively as of 2017.
Installation
There are many Emacs clients on macOS. The recommended version on macOS is Emacs Mac Port, but others are good as well.
Emacs Mac port (Recommended)
Many useful features are built with Emacs Mac Port, e.g. environment variables, full screen, visual enhancements and so on.
Link the Homebrew tap first.
brew tap railwaycat/emacsmacport
- Method 1: Install with
brew cask
.
brew install --cask emacs-mac
There are three available versions, emacs-mac
, emacs-mac-official-icon
, emacs-mac-spacemacs-icon
.
- Method 2: Install using
brew
.
brew install emacs-mac [options]
Click here to see available options: </summary>
--with-dbus
, Build with d-bus support
--with-modules
, Build with dynamic modules support
--with-xml2
, Build with libxml2 support
--with-ctags
, Don’t remove the ctags executable that emacs provides
--with-no-title-bars
, Build with a patch for no title bars on frames (–HEAD is not supported)
--with-natural-title-bar
, Build with a patch for title bar color inferred by your theme (–HEAD is not supported). More info is provided here
--with-official-icon
, Using official Emacs icon
--with-modern-icon
, Using a modern style Emacs icon by @tpanum
--with-spacemacs-icon
, Using the spacemacs Emacs icon by Nasser Alshammari
--with-icon-for-documents
, Using official icon for documents which default open with Emacs
</details>
Emacs plus
Start off by tapping the official emacs-plus cask.
brew tap d12frosted/emacs-plus
Emacs Plus contains separate formulas for different Emacs versions:
- emacs-plus - installs Emacs 26, current release version.
brew install emacs-plus [options]
- emacs-plus@27 - installs Emacs 27, next release version.
brew install emacs-plus@27 [options]
- emacs-plus@28 - installs Emacs 28, development version.
brew install emacs-plus@28 [options]
Options:
--with-24bit-color
: Experimental: build with 24 bit color support
--with-ctags
: Don’t remove the ctags executable that Emacs provides
--with-dbus
: Build with dbus support
--with-mailutils
: Build with mailutils support
--with-natural-title-bar
: Experimental: use a title bar colour inferred by your theme
--with-no-title-bars
: Experimental: build with a patch for no title bars on frames (–HEAD has this built-in via undecorated flag)
--with-x11
: Experimental: build with x11 support
--without-cocoa
: Build a non-Cocoa version of Emacs
--without-gnutls
: Build without gnutls support
--without-imagemagick@6
: Build without imagemagick@6 support
--without-librsvg
: Build without librsvg support
--without-libxml2
: Build without libxml2 support
--without-modules
: Build without dynamic modules support
--without-multicolor-fonts
: Build without a patch that enables multicolor font support
--without-spacemacs-icon
: Build without Spacemacs icon by Nasser Alshammari
--HEAD
: Install HEAD version
Note: 1) You might want to install exec-path-from-shell if you are using Emacs plus. It takes care of your environment variables.
2) To have the title bar match your theme background color, consider using instead:
brew install emacs-plus --HEAD --with-natural-title-bars
Spacemacs
Spacemacs is a new way to experience Emacs – a sophisticated and polished set-up focused on ergonomics, mnemonics and consistency.
Spacemacs can be used naturally by both Emacs and Vim users – you can even mix the two editing styles. Switching easily between input styles makes Spacemacs a great tool for pair-programming.
Installation
-
If you have an existing Emacs configuration, back it up first:
cd ~
mv .emacs.d .emacs.d.bak
mv .emacs .emacs.bak
Don’t forget to backup and remove ~/.emacs
file otherwise Spacemacs
WILL NOT load since that file prevents Emacs from loading the proper
initialization file.
-
Clone the repository:
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
master
is the stable branch and it is immutable, DO NOT make any
modification to it or you will break the update mechanism. If you want to
fork Spacemacs safely use the develop
branch where you handle the update
manually.
-
(Optional) Install the Source Code Pro font.
If you are running in terminal you’ll also need to change font settings of
your terminal.
-
Launch Emacs. Spacemacs will automatically install the packages it requires.
If you get an error regarding package downloads then you may try to disable
the HTTPS protocol by starting Emacs with
emacs --insecure
Or you can set the dotspacemacs-elpa-https
to nil
in your dotfile to
remove the need to start Emacs with --insecure
argument. You may wish to
clear out your .emacs.d/elpa
directory before doing this, so that any
corrupted packages you may have downloaded will be re-installed.
-
Restart Emacs to complete the installation.
Purcell’s Emacs configuration
This is Purcell’s emacs configuration tree, continually used and tweaked since 2000, and it may be a good starting point for other Emacs users, especially those who are web developers. These days it’s somewhat geared towards macOS, but it is known to also work on Linux and Windows.
Installation
To install, clone this repository to ~/.emacs.d
, i.e. ensure that the init.el
contained in this repository ends up at ~/.emacs.d/init.el
:
git clone https://github.com/purcell/emacs.d.git ~/.emacs.d
Upon starting up Emacs for the first time, further third-party packages will be automatically downloaded and installed. If you encounter any errors at that stage, try restarting Emacs, and possibly running M-x package-refresh-contents
before doing so.
Doom Emacs
Doom is a configuration for GNU Emacs written by a stubborn, shell-dwelling, and melodramatic ex-vimmer. It wasn’t originally intended for public use, but can be considered a hacker’s starter kit.
Installation
git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
cd ~/.emacs.d
cp init.example.el init.el # maybe edit init.el
make install
Don’t forget to run make
every time you modify init.el
!
Visit the wiki for a more detailed guide on installing, customizing and grokking Doom.
--with-dbus
, Build with d-bus support--with-modules
, Build with dynamic modules support--with-xml2
, Build with libxml2 support--with-ctags
, Don’t remove the ctags executable that emacs provides--with-no-title-bars
, Build with a patch for no title bars on frames (–HEAD is not supported)--with-natural-title-bar
, Build with a patch for title bar color inferred by your theme (–HEAD is not supported). More info is provided here--with-official-icon
, Using official Emacs icon--with-modern-icon
, Using a modern style Emacs icon by @tpanum--with-spacemacs-icon
, Using the spacemacs Emacs icon by Nasser Alshammari--with-icon-for-documents
, Using official icon for documents which default open with Emacsbrew tap d12frosted/emacs-plus
brew install emacs-plus [options]
brew install emacs-plus@27 [options]
brew install emacs-plus@28 [options]
--with-24bit-color
: Experimental: build with 24 bit color support--with-ctags
: Don’t remove the ctags executable that Emacs provides--with-dbus
: Build with dbus support--with-mailutils
: Build with mailutils support--with-natural-title-bar
: Experimental: use a title bar colour inferred by your theme--with-no-title-bars
: Experimental: build with a patch for no title bars on frames (–HEAD has this built-in via undecorated flag)--with-x11
: Experimental: build with x11 support--without-cocoa
: Build a non-Cocoa version of Emacs--without-gnutls
: Build without gnutls support--without-imagemagick@6
: Build without imagemagick@6 support--without-librsvg
: Build without librsvg support--without-libxml2
: Build without libxml2 support--without-modules
: Build without dynamic modules support--without-multicolor-fonts
: Build without a patch that enables multicolor font support--without-spacemacs-icon
: Build without Spacemacs icon by Nasser Alshammari--HEAD
: Install HEAD versionNote: 1) You might want to install exec-path-from-shell if you are using Emacs plus. It takes care of your environment variables.
2) To have the title bar match your theme background color, consider using instead:
brew install emacs-plus --HEAD --with-natural-title-bars
If you have an existing Emacs configuration, back it up first:
cd ~
mv .emacs.d .emacs.d.bak
mv .emacs .emacs.bak
Don’t forget to backup and remove ~/.emacs
file otherwise Spacemacs
WILL NOT load since that file prevents Emacs from loading the proper
initialization file.
Clone the repository:
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
master
is the stable branch and it is immutable, DO NOT make any
modification to it or you will break the update mechanism. If you want to
fork Spacemacs safely use the develop
branch where you handle the update
manually.
(Optional) Install the Source Code Pro font.
If you are running in terminal you’ll also need to change font settings of your terminal.
Launch Emacs. Spacemacs will automatically install the packages it requires. If you get an error regarding package downloads then you may try to disable the HTTPS protocol by starting Emacs with
emacs --insecure
Or you can set the dotspacemacs-elpa-https
to nil
in your dotfile to
remove the need to start Emacs with --insecure
argument. You may wish to
clear out your .emacs.d/elpa
directory before doing this, so that any
corrupted packages you may have downloaded will be re-installed.
Restart Emacs to complete the installation.
~/.emacs.d
, i.e. ensure that the init.el
contained in this repository ends up at ~/.emacs.d/init.el
:git clone https://github.com/purcell/emacs.d.git ~/.emacs.d
M-x package-refresh-contents
before doing so.git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
cd ~/.emacs.d
cp init.example.el init.el # maybe edit init.el
make install
make
every time you modify init.el
!