Skip to content

jdtsmith/emacs-mac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emacs-mac

This is an experimental build of the emacs-mac (aka Carbon1 Emacs) port of emacs, updated for Emacs v30.1.

Warning

This is an experimental build of emacs-mac; there will certainly be bugs. We are looking for feedback and testing from experienced users. If you are familiar with or willing to learn about running new builds of Emacs under a debugger, perfect. If you are a Mac developer familiar with ObjC or Mac Window frameworks, even better! Other users should stick to the official NS build or recent v29.4 emacs-mac release for now.

Status

Known working systems:

  • MacOS 15 (Sequoia) on ARM64 (M1, M2, M3, M4), X86_64 (Intel)
  • MacOS 14 (Sonoma) on ARM64 (M1, M3)
  • MacOS 12 (Monterey) on X86_64 (Intel)

Please see the issues for advice on build configurations for your system.

Important

Please open an issue to report your experiences, even if you encounter no problems. Mention your OS version, CPU, and any other relevant details, including the build/configure flags you used.

This build is kept current with the emacs-30 release branch.

Install

See the emacs-mac-30_1_exp branch and the file README-mac for additional compile instructions. Briefly:

Note

On MacOS, gcc is actually aliased to the clang compiler, which is required to build emacs-mac. Recent gcc versions either cannot build for the architecture (e.g. Apple Silicon) and/or do not support blocks, which this build uses heavily.

Install (optional) libraries

If you'd like to build with tree-sitter support, native-compilation, and RSVG (all recommended), first install the necessary libraries:

brew install tree-sitter libgccjit librsvg

Configure

You can configure the app either as self-contained (all resources live within the app), or non-self-contained (the default). A self-contained app is recommended. The recommended configuration options are given below; see the file README-mac for others.

Self-contained

A self-contained app by default will go into /Applications/Emacs.app.

./autogen.sh
CFLAGS="-O3 -mcpu=native" ./configure --with-native-compilation --with-tree-sitter --enable-mac-app=yes --enable-mac-self-contained

You can specify another build directory for the self-contained app using --enable-mac-app=/path/to/dir.

Note

Note the yes argument to --enable-mac-app=yes, which is required to build a self-contained app under /Applications.

Non self-contained

./autogen.sh
CFLAGS="-O3 -mcpu=native" ./configure --with-native-compilation --with-tree-sitter  

Build

make -j6 # or however many CPUs you want to use

You'll find the staging build of the app under mac/.

Install

This step compresses EL files and fully populates the app.

Self-contained

make install # Installs all resources under /Applications/Emacs.app (or wherever your self-contained build is going)

Non self-contained

sudo make install  # installs resources in, e.g., /usr/local/share/emacs/30.1.50

No install, e.g. for debug

If you choose not to make install, but instead want to run the application directly from the mac/ sub-directory, you may need to:

% cd mac/
% ln -s ../native-lisp Emacs.app/Contents/

to associate the native lisp files. This is useful for debugging, to quickly rebuild and test, for example (saving the install step). But a self-contained app build is easier.

Additions

Several additional features and fixes have been added on top of emacs-mac and Emacs proper.

Features

  • A New Frame Dock Menu Item
  • New variable mac-underwave-thickness to customize the thickness of squiggly underlines (e.g. with linters or spell-checkers)

Bug fixes

  • Take care to avoid crashes when selecting certain fonts from the system font panel.
  • Prevent zombie "Emacs Web Content" processes on SVG load, restoring normal WebView SVG rendering for MacOS v14+. Update: WebView is deprecated, so this has been reverted and another workaround installed. It's recommended to build with RSVG (it is enabled by default if the librsvg2 library is found during build).

Debugging

If you get crashes or just want to help with debugging, it would be very useful to run emacs-mac under lldb, the clang debugger. Here's how:

  1. Build emacs-mac with debug flags:
     CFLAGS="-O0 -g3" ./configure --with-native-compilation --with-tree-sitter --enable-mac-app=yes
    
  2. Link in the native-lisp directory.
  3. In an ~/.lldbinit file, add settings set target.load-cwd-lldbinit true, so Emacs can read the custom lldb commands it has defined.
  4. Start the emacs binary from the src/ directory, like:
    %lldb ../mac/Emacs.app
    Then run (or better, run -Q).
  5. Now cause your crash to occur, go up to the frame of interest, and use xprint, p, etc. on the potentially problematic variables.
  6. You can also try gui which is a little curses-based terminal GUI inside lldb (slow for me though), or realgud-lldb which isn't very complete but can do some things.

Notes

You can read about the issues encountered during the merge of Emacs v30 in the debugging notes.

Footnotes

  1. Calling this the "Carbon" port is a vestigial nod to its origins back in the pre-OSX days. It is also what M-x emacs-version says. But Carbon is a misnomer now. The ancient Carbon API never supported 64bit applications, and was deprecated and removed by Apple in 2019. A few convenience functions do remain (e.g. Carbon.h), and these are used by the NS build as well. Both NS and emacs-mac are Cocoa applications.

About

Experimental build of emacs-mac for v>=30.1

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 1,162