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