Clarify last change.
[bpt/emacs.git] / doc / emacs / macos.texi
CommitLineData
ebc956ca 1@c This is part of the Emacs manual.
b65d8176 2@c Copyright (C) 2000, 2001, 2002, 2003, 2004,
6ed161e1 3@c 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
ebc956ca 4@c See file emacs.texi for copying conditions.
e93bc142
AR
5@node Mac OS / GNUstep, Microsoft Windows, Antinews, Top
6@appendix Emacs and Mac OS / GNUstep
7@cindex Mac OS X
ebc956ca 8@cindex Macintosh
e93bc142
AR
9@cindex GNUstep
10
11 This section briefly describes the peculiarities of using Emacs built with
12the GNUstep libraries on GNU/Linux or other operating systems, or on Mac OS X
13with native window system support. For Mac OS X, Emacs can be built either
14without window system support, with X11, or with the Cocoa interface. This
15section only applies to the Cocoa build. Emacs 23 does not support Mac OS
16Classic.
17
18 Emacs, when built on Mac OS X, uses the Cocoa application interface. For
19various historical and technical reasons, Emacs uses the term @samp{Nextstep}
20internally, instead of ``Cocoa'' or ``Mac OS X''; for instance, most of the
21commands and variables described in the following sections begin with
22@samp{ns-}, which is short for @samp{Nextstep}. NeXTstep was an application
23interface released by NeXT Inc during the 1980s, of which Cocoa is a direct
24descendent. Apart from Cocoa, there is another NeXTstep-style system:
25GNUstep, which is free software. As of this writing, the GNUstep support is
26alpha status (see @pxref{GNUstep Support}), but we hope to improve it in the
27future.
ebc956ca
EZ
28
29@menu
e93bc142
AR
30* Mac / GNUstep Basics:: Basic Emacs usage under GNUstep or Mac OS.
31* Mac / GNUstep Customization:: Customizations under GNUstep or Mac OS.
32* Mac / GNUstep Events:: How window system events are handled.
33* GNUstep Support:: Details on status of GNUstep support
34*
ebc956ca
EZ
35@end menu
36
e93bc142
AR
37@node Mac / GNUstep Basics, Mac / GNUstep Customization, , Mac OS / GNUstep
38@section Basic Emacs usage under Mac OS and GNUstep
8be76823
CY
39
40 By default, the @key{alt} and @key{option} keys are the same as
41@key{Meta} when running under Mac OS. The Mac @key{Cmd} key is the
42same as @key{Super}, and Emacs provides a set of keybindings using
e93bc142
AR
43this modifier key that mimic other Mac / GNUstep applications (@pxref{Mac /
44GNUstep Events}). You can change these bindings in the usual way (@pxref{Key
959d68bd 45Bindings}).
8be76823 46
271736fc
DR
47 The standard Mac / GNUstep font and color panels are accessible via Lisp commands.
48 To use the color panel, drag from it to an Emacs frame
8be76823
CY
49to change the foreground color of the face at that position (if the
50@key{shift} key is held down, it changes the background color
51instead). To finalize the settings for either color or font, choose
52@samp{Save Options} in the @samp{Options} menu. To discard the
53settings, create a new frame and close the altered one.
54
e93bc142 55 @key{S-Mouse-1} (i.e., clicking the left mouse button
8be76823
CY
56while holding down the @key{Shift} key) adjusts the region to the
57click position, just like @key{Mouse-3} (@code{mouse-save-then-kill});
58it does not pop up a menu for changing the default face, as
59@key{S-Mouse-1} normally does (@pxref{Temporary Face Changes}). This
e93bc142 60change makes Emacs behave more like other Mac / GNUstep applications.
8be76823
CY
61
62 When you open or save files using the menus, or using the standard
63@key{Cmd-o} and @key{Cmd-S} bindings, Emacs uses graphical file
64dialogs to read file names. However, if you use the regular Emacs key
65sequences, such as @key{C-x C-f}, Emacs uses the minibuffer to read
66file names.
67
8be76823
CY
68 On GNUstep, in an X-windows environment you need to use @key{Cmd-c}
69instead of one of the @key{C-w} or @key{M-w} commands to transfer text
70to the X primary selection; otherwise, Emacs will use the
71``clipboard'' selection. Likewise, @key{Cmd-y} (instead of @key{C-y})
72yanks from the X primary selection instead of the kill-ring or
73clipboard.
74
8be76823 75
a71703d3 76@subsection Grabbing environment variables
8be76823 77
a71703d3
AR
78Many programs which may run under Emacs like latex or man depend on the
79settings of environment variables. If Emacs is launched from the shell, it
80will automatically inherit these environment variables and its subprocesses
e93bc142 81will inherit them from it. But if Emacs is launched from the Finder it
a71703d3
AR
82is not a descendant of any shell, so its environment variables haven't been
83set which often causes the subprocesses it launches to behave differently than
84they would when launched from the shell.
8be76823 85
e93bc142 86To solve this problem for Emacs, there are two solutions. First is to
a71703d3 87run, from the command line:
8be76823 88
a71703d3
AR
89@example
90.../Emacs.app/Contents/MacOS/bin/mac-fix-env
91@end example
8be76823 92
a71703d3
AR
93This will pick up your environment settings and save them into a special file
94@file{~/.MacOSX/environment.plist}, which the desktop environment will use to
95set the environment for all launched applications. The drawback of this
96method is it needs to be run again whenever something changes.
8be76823 97
271736fc
DR
98As for the PATH and MANPATH variables, a simpler, system-wide method
99of setting PATH is recommended on Mac OS X 10.5 and later, using the
100@file{/etc/paths} files and the @file{/etc/paths.d} directory.
8be76823 101
8be76823 102
e93bc142
AR
103@node Mac / GNUstep Customization, Mac / GNUstep Events, Mac / GNUstep Basics, Mac OS / GNUstep
104@section Mac / GNUstep Customization
8be76823 105
e93bc142 106Emacs can be customized in several ways in addition to the standard
a71703d3 107customization buffers and the Options menu.
8be76823 108
8be76823 109
a71703d3
AR
110@subsection Font and Color Panels
111
271736fc 112The Font Panel may be accessed with M-x ns-popup-font-panel. It
a71703d3
AR
113will set the default font in the frame most recently used or clicked on. To
114make the setting permanent, use @samp{Save Options} in the Options menu, or
959d68bd 115run @code{menu-bar-options-save}.
a71703d3 116
271736fc 117You can bring up a color panel with M-x ns-popup-color-panel. and
a71703d3
AR
118drag the color you want over the emacs face you want to change. Normal
119dragging will alter the foreground color. Shift dragging will alter the
120background color. To make the changes permanent select the "Save Options"
959d68bd 121item in the "Options" menu, or run @code{menu-bar-options-save}. Useful in this
a71703d3
AR
122context is the listing of all faces obtained by @key{M-x}
123@code{list-faces-display}.
124
a71703d3
AR
125@subsection Open files by dragging to an Emacs window
126
127The default behaviour when a user drags files from another application
128into an Emacs frame is to insert the contents of all the dragged files
129into the current buffer. To remap the @code{ns-drag-file} event to
130open the dragged files in the current frame use the following line:
131
132@lisp
133(define-key global-map [ns-drag-file] 'ns-find-file)
134@end lisp
135
136
e93bc142
AR
137@node Mac / GNUstep Events, GNUstep Support, Mac / GNUstep Customization, Mac OS / GNUstep
138@section Windowing System Events under Mac OS / GNUstep
a71703d3
AR
139
140 Nextstep applications receive a number of special events which have
141no X equivalent. These are sent as specially defined ``keys'', which
142do not correspond to any sequence of keystrokes. Under Emacs, these
143``key'' events can be bound to functions just like ordinary
144keystrokes. Here is a list of these events.
145
146@table @key
147@item ns-open-file
148@vindex ns-pop-up-frames
149This event occurs when another Nextstep application requests that
150Emacs open a file. A typical reason for this would be a user
151double-clicking a file in the Finder application. By default, Emacs
152responds to this event by opening a new frame and visiting the file in
153that frame (@code{ns-find-file}), As an exception, if the selected
154buffer is the @samp{*scratch*} buffer, Emacs visits the file in the
6be93a16 155selected frame.
a71703d3
AR
156
157You can change how Emacs responds to @key{ns-open-file} by changing
158the variable @code{ns-pop-up-frames}. Its default value,
159@code{'fresh}, is what we have just described. A value of @code{t}
160means to always visit the file in a new frame. A value of @code{nil}
161means to always visit the file in an existing frame.
162
163@item ns-open-temp-file
164This event occurs when another application requests that Emacs open a
165temporary file. By default, this is handled by just generating a
166@code{ns-open-file} event, the results of which are described above.
167
168You can bind @key{ns-pop-up-frames} and @key{ns-open-temp-file} to
169other Lisp functions. When the event is registered, the name of the
170file to open is stored in the variable @code{ns-input-file}.
171
172@item ns-open-file-line
173Some applications, such as ProjectBuilder and gdb, request not only a
174particular file, but also a particular line or sequence of lines in
175the file. Emacs handles this by visiting that file and highlighting
176the requested line (@code{ns-open-file-select-line}).
177
178@item ns-drag-file
179This event occurs when a user drags files from another application
180into an Emacs frame. The default behavior is to insert the contents
181of all the dragged files into the current buffer
182(@code{ns-insert-files}). The list of dragged files is stored in the
183variable @code{ns-input-file}.
184
185@item ns-drag-color
186This event occurs when a user drags a color from the color well (or
187some other source) into an Emacs frame. The default behavior is to
188alter the foreground color of the area the color was dragged onto
189(@code{ns-set-foreground-at-mouse}). If this event is issued with a
190@key{Shift} modifier, Emacs changes the background color instead
191(@code{ns-set-background-at-mouse}). The name of the dragged color is
192stored in the variable @code{ns-input-color}.
193
194@item ns-change-font
195This event occurs when the user selects a font in a Nextstep font
196panel (which can be opened with @kbd{Cmd-t}). The default behavior is
197to adjust the font of the selected frame
198(@code{ns-respond-to-changefont}). The name and size of the selected
199font are stored in the variables @code{ns-input-font} and
200@code{ns-input-fontsize} respectively.
201
202@item ns-power-off
959d68bd
DR
203This event occurs when the user logs out and Emacs is still running, or when
204`Quit Emacs' is chosen from the application menu.
205The default behavior is to save all file-visiting buffers.
a71703d3
AR
206@end table
207
208 Emacs also allows users to make use of Nextstep services, via a set
209of commands whose names begin with @samp{ns-service-} and end with the
210name of the service. Type @kbd{M-x ns-service-@key{TAB}@key{TAB}} to
211see a list of these commands. These functions either operate on
212marked text (replacing it with the result) or take a string argument
213and return the result as a string. You can also use the Lisp function
214@code{ns-perform-service} to pass arbitrary strings to arbitrary
215services and receive the results back. Note that you may need to
216restart Emacs to access newly-available services.
217
e93bc142
AR
218
219@node GNUstep Support, , Mac / GNUstep Events, Mac OS / GNUstep
220@section GNUstep Support
221
222Emacs can be built and run under GNUstep however building is difficult and
223there are some limitations to functionality. In particular, it may be
224necessary to run @samp{make bootstrap} with a plain X configuration, then
225@samp{make clean} and @samp{./configure --with-ns} followed by @samp{make
226install}.
227
228Currently CANNOT_DUMP is automatically enabled in GNUstep configurations,
229because the unex file(s) for GNUstep, mainly @samp{unexelf.c}, have not been
230updated yet with the ``zone'' code in and related to @samp{unexmacosx.c}.
231
ab5796a9
MB
232@ignore
233 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6
234@end ignore