Dernière modification
Résumé : Broken and dangerous - on Snow Leopard, hard crashed multiple emacs variants.
Supprimé(e) :
< === Command to Maximize Emacs 23.1 (vanilla) ===
< Fullscreen mode doesn't work in Vanilla Emacs 23.1. This at least maximizes your session to take up as much room as possible.
< <pre>
< (defun maximize-frame ()
< (interactive)
< (set-frame-position (selected-frame) 0 0)
< (set-frame-size (selected-frame) 1000 1000))
< (global-set-key (kbd "<s-S-return>") 'maximize-frame)
< </pre>
< -- [[timcharper]]
A copy of GNU Emacs 22 without GUI support compiled in is available on all recent versions of Mac OS X via the shell. However, there are other Emacs distributions geared towards Mac OS X that include GUI support as well as other distinctions that may make it a more appropriate choice for some.
Cocoa is the Objective-C API (originally developed by NeXT) that is used for native OS X applications (included in Emacs 23.2). Aquamacs and Emacs.app (GNU Emacs/Cocoa) both run under Cocoa. Note that Emacs.app, GNU Emacs/Cocoa, and GNU Emacs/nextstep refer to the same thing.
Carbon is the C language API (developed by Apple) that lets applications written under OS 9 (or earlier) run under OS X. Carbon Emacs runs under Carbon. As of Emacs 23, Carbon Emacs has been deprecated in favor of Emacs.app.
X11 Emacs is the “original” emacs running under X11 (installed by default in recent versions of Mac OS X)
If you are a Mac user new to Emacs, many people find Aquamacs to be a good choice. Many find it to be more Mac-like than Emacs.app. If you’ve used Emacs before and already have your own emacs initialization file, then Emacs.app is likely a better choice. As compared to Aquamacs, Emacs.app is more traditional in its approach, prefers a single frame, and is more likely to work with existing emacs initialization files.
A similar page on a German blog: Die Emacssituation unter OS X (in German).
These builds are based on the BZR version of GNU Emacs and do not contain any additional packages or patches. Popular Mac keyboard shortcuts are available though (e.g. Command-O for opening a file); these are mapped to the Super modifier (i.e., the Apple/Command key functions as Super).
The site makes available Releases, Pretests & Nightlies.
Custom distributions contain startup routines and tweaks to make Emacs’ UI behavior more “Mac-like”. In addition to that, they typically include recent versions of popular packages.
‘select’ that doesn’t require periodic polling, full screen support, and smooth (pixel) scrolling. See the readme for more details.Directions for accessing the emacs BZR repository are found at http://savannah.gnu.org/projects/emacs. To download emacs, use the command:
bzr branch http://bzr.savannah.gnu.org/r/emacs/trunk
(or `bzr revert; bzr pull', if you already had checked it out)
To download emacs using git, use this command:
git clone git://git.savannah.gnu.org/emacs.git
Available from the GNU Savannah emacs page. Click on “Download Area” under “Quick Overview”.
There are many options for building emacs (such as whether to build the X11 version), which are discussed in the INSTALL file. There is also a script (emacs/mac/make-package) to create a Mac OS X package for use by the installer.
AquamacsEmacs can be built via build script or manually (step by step). The source is available from a Git repository. Then, do:
./configure make make install
When the build is complete, find Aquamacs.app in .nextstep.
Note: changes to any source files in src/ require a simple “make”. The binary will directly be installed into nextstepAquamacs.app. Changes to source files in lisp require a “make install”. Changes to any lisp files directly in the .app bundle may or may not take effect (upon restarting Aquamacs): for many such files (list lisp/site-load.el), you must call “make”.
Detailed build instructions are available on BuildingAquamacs.
Emacs 23.2 ships with Cocoa support. You can build it by running something like the following:
./configure --with-ns make install
When the build is complete, you should see Emacs.app in ./nextstep/Emacs.app. Simply copy it to your applications folder and open it to run.
For more detailed instructions, see the nextstep/INSTALL file. Additionally, you may benefit from reading the build script here: http://github.com/ieure/emacs-nightly. As of 2010-05-08 Cocoa Emacs 23.2 builds correctly on Snow Leopard (Mac OS X 10.6.x).
As of October 2011, the version of autoconf on OS X Lion is not recent enough to configure/compile Emacs from source. There is a workaround provided by using the autogen/copy_autogen script which will build emacs using pre-generated versions of the required build files. See the comments in autogen/copy_autogen for more information.
Directions to build and install may be found in the INSTALL or INSTALL.BZR files. The basic build and installation of the X11 Emacs application uses the commands:
./configure --with-x
make
sudo make install
As of 2010-05-08 X11 Emacs 23.2 builds correctly on Snow Leopard (Mac OS X 10.6.x).
Directions to build and install may be found in the file newly downloaded to emacs/mac/INSTALL. The basic build and installation of the carbon Emacs application uses the commands:
./configure --enable-carbon-app
make
sudo make install
Note: Carbon emacs has been replaced with Cocoa Emacs in Emacs 23.x. This is why the option --enable-carbon-app is no longer recognised by configure.
Package managers provide a convenient way to install and maintain/upgrade software.
As of May 8th, 2010 Fink http://fink.sourceforge.net/ includes the following packages:
— I just installed fink 0.31.0 on 10.6 using a source tarball because I wanted jdee, but unfortunately there seems to be no such package. (kosta 19/08/2011)
Homebrew has Emacs 24.2 (as of 2013-02-06).
Other options include:
To install using the --cocoa switch, one simply uses:
brew install --cocoa emacs ln -s /usr/local/Cellar/emacs/24.2/Emacs.app /Applications/Emacs.app
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.
MacPorts http://www.macports.org/ is another means of installing Emacs on OS X (and other unix-alikes for that matter).
As of December 6, 2011 it provides the following packages:
See Available Ports for the current list.
The emacs executable installs to: /opt/local/bin/emacs
The emacs-app executable installs to: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
The various emacs packages MacPorts offers (e.g., org-mode) will install to: /opt/local/share/emacs/site-lisp/
Note that Mac OS X Lion comes with GNU Emacs 22.1.1, located at: /usr/bin/emacs
Linux users, add these lines to your .profile (or .bashrc, etc.) to feel at home:
alias emacs='/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs'
alias emacsclient='/Applications/MacPorts/Emacs.app/Contents/MacOS/bin/emacsclient'
For the OS X native (Cocoa) versions, once you’ve got MacPorts installed, run
sudo port install emacs-app
or (if you prefer a – usually more recent– development version)
sudo port install emacs-app-devel
It’s also possible to build the development version of GNU Emacs with ATSUI – Apple Type Services for Unicode Imaging.
Use the shell mode. Make sure cursor is at the file, then type: ! open <RET>
For Terminal.app, starting from Snow Leopard: Go to Preferences > Settings > Keyboard > Use option as meta key.
For iTerm: Go to Manage Profiles > Keyboard profiles > (your profile) > Option Key as…
If you want to use Option key for both international characters and Meta key in Emacs, see this page for iTerm 0.10.x patch and/or binary.
Alt-b and Alt-f for navigating by word also works for your shell now.
I use Andrew Choi’s build of GNU Emacs at work every day on OS X. I keep some notes and some Lisp functions for calling AppleScript? from Emacs in my advogato.org diary:
http://advogato.org/person/wainstead/
The OS X Terminal.app uses UTF-8 by default. To get the correct behaviour from the Emacs that comes with OS X, I use the following settings in my InitFile file:
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)you also can write accents like this C-x 8 ‘ character see C-x 8 C-h
See UnicodeEncoding.
This also works with XEmacs 21.5.9 and above, at least.
In shell-mode, the [C-up] and [C-down] key-bindings do not work as expected to browse the history ring. The problem is that Terminal.app does not properly send these control sequences. To fix this behavior, open Terminal.app Preferences>>Settings>>Keyboard. Select the “+” button and you will see that you can add bindings to the “cursor down” key with the “control” modifier. Select “send string to shell”, and enter “ESCp”, i.e., emacs M-p. Similarly, define control cursor up to send “ESCn” to the shell.
The variables available for binding the modifier keys:
mac-function-modifier mac-control-modifier mac-command-modifier mac-option-modifier mac-right-command-modifier mac-right-control-modifier mac-right-option-modifier
values can be 'control, 'alt, 'meta, 'super, 'hyper, nil (setting to nil allows the OS to assign values)
Also see http://lists.gnu.org/archive/html/help-gnu-emacs/2011-02/msg00019.html
example usage:
;; key bindings (when (eq system-type 'darwin) ;; mac specific settings (setq mac-option-modifier 'alt) (setq mac-command-modifier 'meta) (global-set-key [kp-delete] 'delete-char) ;; sets fn-delete to be right-delete )
This information does not regard the actual use of emacs, but I think many people will be happy to find out that some cursor movement / text editing keybindings can be used in Cocoa Apps. If you ever happen to use any other application on your Mac … You can also set up additional keybindings as described in this document.
http://www.lorax.com/FreeStuff/TextExtras.html provides additional Emacs like features to every Cocoa application like alt-/ completion
So control-s is just beeping at me in emacs in the Mac OS X Terminal (10.4) on my home machine but works fine on 10.2 on my work machine – what gives? I’ve looked into the flow control tty issue and tried to disable it – still emacs just sits there beeping. M-x save-buffers and M-x isearch gets to be a pain. Any hints for the Mac OS X Terminal?
Say I want to run the function “forward-sexp” bound to C-M-f. I should be able to get at it with “hold ctrl, hold alt, hit f”. However, if I actually do that I get the result of the command forward-word (M-f). To actually get forward-sexp I must “hit esc, hold ctrl, hit f”. However the alt key works fine as meta for things like M-x and basically anything that doesn’t also require ctrl. Anyone know how to fix this? (This is using Terminal.app on 10.4.9 btw).
See the following blog post for swapping the cmd and meta key. Also, if you want to retain one of the Option key functions as modifier for national characters, see this page for iTerm patch and/or binary.
See the following blog post for using alt as your meta key:
http://tylerkieft.com/archives/2006/10/05/redefine-the-x11-meta-key-in-mac-os-x/
Fullscreen mode is not offered in either 23.3 or 24+. In trying to adapt the “maximize-frame” function below I inadvertently discovered that if one uses the maximize control button once the frame is maximized vertically, twice the frame is maximized both vertically and horizontally and three times results in the frame restored to its original size. Good enough for me!
-pmr
You can also use Right Zoom ( http://www.macupdate.com/app/mac/30591/right-zoom ) with
-dwd
The section is meant to collect useful hacks to the C sources (or to Lisp sources that are executed before any init files are read, such as startup.el).
This fork has patches for true fullscreen and it works wonderfully.
$ git clone git://github.com/typester/emacs.git $ cd emacs $ ./configure --with-ns $ make bootstrap $ make install $ mv nextstep/Emacs.app /Applications
(global-set-key (kbd "M-RET") 'ns-toggle-fullscreen)
The size of the “knob” in a given window’s scrollbar is proportional to how much of the buffer is displayed in the window. When the whole buffer is displayed in the window, the knob takes up the entire scrollbar. I find this distracting (not too mention aesthetically objectionable), and much prefer the behavior of applications like iTerm that show an empty scrollbar slot in such cases.
You can get that effect in Emacs by making a small change to src/nsterm.m. Look for this bit of code:
- setPosition: (int)position portion: (int)portion whole: (int)whole
{
NSTRACE (setPosition);
em_position = position;
em_portion = portion;
em_whole = whole;
if (portion >= whole)
[self setFloatValue: 0.0 knobProportion: 1.0];
else
{
float pos, por;
portion = max ((float)whole*min_portion/pixel_height, portion);
pos = (float)position / (whole - portion);
por = (float)portion/whole;
[self setFloatValue: pos knobProportion: por];
}
return self;
}
and replace it with:
- setPosition: (int)position portion: (int)portion whole: (int)whole
{
NSTRACE (setPosition);
em_position = position;
em_portion = portion;
em_whole = whole;
if (portion >= whole)
[self setEnabled:NO];
else
{
if (![self isEnabled])
{
[self setEnabled:YES];
}
float pos, por;
portion = max ((float)whole*min_portion/pixel_height, portion);
pos = (float)position / (whole - portion);
por = (float)portion/whole;
[self setFloatValue: pos knobProportion: por];
}
return self;
}
A further change is to have the knob be of constant, minimal size, so that it only indicates position in the buffer, instead of changing size according to the portion of the buffer displayed in the window (I find the variable sizes distracting). To do this, use the replacement code:
- setPosition: (int)position portion: (int)portion whole: (int)whole
{
NSTRACE (setPosition);
em_position = position;
em_portion = portion;
em_whole = whole;
if (portion >= whole)
[self setEnabled:NO];
else
{
if (![self isEnabled])
{
[self setEnabled:YES];
}
float pos;
portion = max ((float)whole*min_portion/pixel_height, portion);
pos = (float)position / (whole - portion);
[self setFloatValue: pos knobProportion: 0];
}
return self;
}