Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install emacs correctly on OS X?

Tags:

emacs

macos

I tried doing:

brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls --with-rsvg --with-imagemagick 

But when I do emacs --version

emacs --version -bash: /usr/local/Cellar/emacs/24.5/Emacs.app/Contents/MacOS/Emacs: No such file or directory 

When I do

brew info emacs  emacs: stable 25.2 (bottled), HEAD 

I am an EMACS newbie. It's a bit difficult to understand. And I may have deleted the default Emacs

like image 415
maximusdooku Avatar asked May 21 '17 02:05

maximusdooku


People also ask

Is Emacs installed by default on Mac?

OS X comes with a preinstalled version of Emacs, but alas it is the outdated Emacs 22. Fortunately, obtaining a newer release is really simple. There are several popular ways to do it.

Does Mac terminal have Emacs?

Yes, you can use emacs inside the terminal.


1 Answers

This is an update for April 2019, Mac OSX mojave 10.14.4 discussion on reddit

It seems that the cocoa option is not available on hombrew also the --head. So you can:

brew cask install emacs #is the preferred from emacs wiki brew install --cask emacs #using new cask syntax 

and if you want to do the equal setup from brew without using cask, you can use this:

emacs-head

brew tap daviderestivo/emacs-head brew install emacs-head --HEAD --with-cocoa --with-librsvg --with-imagemagick@7 --with-jansson --with-multicolor-fonts --with-no-frame-refocus --with-mailutils --with-dbus --with-modules 

getting this

ls -l $(which emacs)                                                                                                                                                                                                lrwxr-xr-x  1 toni  admin  45 23 abr 19:26 /usr/local/bin/emacs -> ../Cellar/emacs-head/HEAD-259dfd2_1/bin/emacs 

Then you can make it and osascript to get in spotlight and applications:

osascript -e 'tell application "Finder" to make alias file to POSIX file "/usr/local/Cellar/emacs-head/HEAD-259dfd2_1/Emacs.app" at POSIX file "/Applications"' 

This is obsolete from now but it contains further information: This is an update for October 2017. Now the easy to install emacs is using brew cask

brew cask install emacs 

With this, it works well but I have an issue with gnutls and installing last org (9.1.6), but it worked well

for the traditional way and getting an emacs more integrated with your system or the nightly releases you can install with

brew install emacs --HEAD --with-cocoa --with-gnutls --with-librsvg --with-imagemagick@6 --with-mailutils 

the --HEAD is not necessary, and now (23-01-2018) get Emacs 27, for the latest distributed without HEAD

then you should make this to use spotlight:

brew linkapps emacs rm /Applications/Emacs.app osascript -e 'tell application "Finder" to make alias file to POSIX file "/usr/local/opt/emacs/Emacs.app" at POSIX file "/Applications"' 

and finally take a look at emacs wiki

Homebrew has Emacs 25.3 as of October 2017. Cask homebrew installation

Homebrew now recommends to use the cask version with the following message: “Please try the Cask for a better-supported Cocoa version”

To install the cask version:

brew cask install emacs

This installs a pre-built package from https://emacsformacosx.com/ Standard homebrew installation

If you prefer not to run the cask version, you can still use the old homebrew recipe.

A Cocoa-specific Emacs.app can be built using the --with-cocoa switch. A version supporting X11 can be built using the --with-x switch. Note that this version will not have all of the features of the Cocoa 

version; use only if necessary.

Other options include:

--keep-ctags Don’t remove the ctags executable that emacs provides. Use of this flag is not recommended Instead, use brew 

install ctags after installation. --srgb This option will enable sRGB colors when using Cocoa.

To install using the --with-cocoa switch, one simply uses:

brew install --with-cocoa emacs

to get some “pretty” colours add the --srgb switch:

brew install --with-cocoa --srgb emacs

and finally link it to your Applications folder:

brew linkapps emacs

This creates a symlink and not an alias. So Spotlight may not find it (tested on macOS Sierra 10.12.2). Spotlight indexes symlinks to files that are treated as system files, but it doesn’t show them in the GUI. It does show aliases though, so you could just command-option-drag /usr/local/Cellar/emacs/*/Emacs.app to /Applications/ from Finder. Or:

$ osascript -e "tell application "Finder" to make alias file to (POSIX file "/usr/local/Cellar/emacs-plus/25.3/Emacs.app") at POSIX file "$HOME/Applications""

After installation, using the emacs command in the terminal or shell will run the -nw version of Emacs. If you want to run the Cocoa version using this command, you simply add a line to your .bash_profile. Emacs-Plus version in tap

To instead use the emacs-plus version, which is like regular homebrew emacs but with some configuration options enabled,

brew tap d12frosted/emacs-plus brew install emacs-plus

Mitsaharu version in tap

To instead use the Yamamoto Mitsuharu version of Emacs 25.2 (with more mac-specific features):

brew tap railwaycat/emacsmacport brew install emacs-mac

and finally link it to your Applications folder:

brew linkapps emacs-mac

like image 92
anquegi Avatar answered Oct 09 '22 01:10

anquegi