Random ramblings about Mac, Python, TeX, programming, and more   |     |        |     |  



Emacs on Mac

September 26, 2018  |  os-x, software, tools, programming

Until recently, I have been an Aquamacs user on the Mac. However, recently, I have been switching back to a more standard Emacs distribution for Mac. After some time of research, I ended up with the Emacs Mac Port. This distribution is easily installed and updated through Homebrew, and since I am already using Homebrew for other important software on my Mac (including bsdmake), this was an obvious choice. I use Homebrew to install the Emacs Mac Port from railwaycat with these commands:

  brew tap railwaycat/emacsmacport
  brew install emacs-mac

Later, when I want to update to the latest release, I just do this:

  brew upgrade emacs-mac

Optionally, you can also create a soft link in the Application directory to be able to access Emacs from there:

  ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications

Tips to run Emacs from the command line prompt can be found here.

Since I want to have a more Mac feel to my Emacs on the Mac (I have used Aquamacs too long, I guess), the final configuration I suggest is to add support for typical Mac key bindings. I use a modified version of this mac-port-keys.el. My remapping of modifiers is changed to the following (use the function modifier key for meta since I need option modifier key for different key modifiers, including typing the Norwegian letters æ, ø and å):

  (when (symbolp 'mac-control-modifier)
        ;; Re-map modifiers
        (setq mac-control-modifier  'control
              ;mac-option-modifier 'meta
              mac-function-modifier 'meta 
              mac-command-modifier 'super))

On my iMac keyboard, I do not have the function modifier key in a proper location, so I use Karabiner-Elements to map the unused Caps Lock key to the function modifier (the fn-key). I actually do this on all my Macs since I never use Caps Locks, and the meta key is used a lot in Emacs.

And I use Cua-Mode (but I disable the overriding of standard Emacs bindings):

  ;; Cua-mode
  (cua-mode t)
  (setq cua-enable-cua-keys nil)          ; C-v and M-v to scroll!
Last updated: June 22, 2024