1 @c This is part of the Emacs manual.
2 @c Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 @c 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Mac OS, Microsoft Windows, Antinews, Top
6 @appendix Emacs and Mac OS
10 This section briefly describes the peculiarities of using Emacs
11 under Mac OS X with native window system support. For Mac OS X, Emacs
12 can be built either without window system support, with X11, or with
13 the Cocoa interface. This section only applies to the Cocoa build.
14 Emacs 23 does not support Mac OS Classic.
16 Emacs, when built on Mac OS X, uses the Cocoa application interface.
17 For various historical and technical reasons, Emacs uses the term
18 @samp{Nextstep} internally, instead of ``Cocoa'' or ``Mac OS X''; for
19 instance, most of the commands and variables described in the
20 following sections begin with @samp{ns-}, which is short for
21 @samp{Nextstep}. NeXTstep was an application interface released by
22 NeXT Inc during the 1980s, of which Cocoa is a direct descendent.
23 Apart from Cocoa, there is another NeXTstep-style system: GNUstep,
24 which is free software. As of this writing, the GNUstep support is
25 not fully functional, but we hope to improve it in the future.
28 * Mac Basics:: Basic Emacs usage in Mac OS.
29 * Mac Events:: How window system events are handled.
30 * Mac Preferences:: Using the Preferences Panel to customize Emacs.
31 * Mac Customization:: Customizations in Mac OS
35 @section Basic Emacs usage in Mac OS
37 By default, the @key{alt} and @key{option} keys are the same as
38 @key{Meta} when running under Mac OS. The Mac @key{Cmd} key is the
39 same as @key{Super}, and Emacs provides a set of keybindings using
40 this modifier key that mimic other Mac applications (@pxref{Mac
41 Events}). You can change these bindings in the usual way (@pxref{Key
42 Bindings}), or by using the Mac preferences panel (@pxref{Mac
45 The standard Mac font and color panels are accessible via the
46 @samp{Windows} menu, or via the standard @key{Cmd-t} and @key{Cmd-C}
47 keybindings. To use the color panel, drag from it to an Emacs frame
48 to change the foreground color of the face at that position (if the
49 @key{shift} key is held down, it changes the background color
50 instead). To finalize the settings for either color or font, choose
51 @samp{Save Options} in the @samp{Options} menu. To discard the
52 settings, create a new frame and close the altered one.
54 In Mac OS, @key{S-Mouse-1} (i.e., clicking the left mouse button
55 while holding down the @key{Shift} key) adjusts the region to the
56 click position, just like @key{Mouse-3} (@code{mouse-save-then-kill});
57 it does not pop up a menu for changing the default face, as
58 @key{S-Mouse-1} normally does (@pxref{Temporary Face Changes}). This
59 change makes Emacs behave more like other Mac applications.
61 When you open or save files using the menus, or using the standard
62 @key{Cmd-o} and @key{Cmd-S} bindings, Emacs uses graphical file
63 dialogs to read file names. However, if you use the regular Emacs key
64 sequences, such as @key{C-x C-f}, Emacs uses the minibuffer to read
67 When Emacs is called by a name which ends in @file{-nw}, it will
68 always start in terminal mode. For example, if you need a
69 terminal-only Emacs, create a symbolic link from @file{emacs} to
70 @file{emacs-nw} and launch @file{emacs-nw}.
72 On GNUstep, in an X-windows environment you need to use @key{Cmd-c}
73 instead of one of the @key{C-w} or @key{M-w} commands to transfer text
74 to the X primary selection; otherwise, Emacs will use the
75 ``clipboard'' selection. Likewise, @key{Cmd-y} (instead of @key{C-y})
76 yanks from the X primary selection instead of the kill-ring or
80 @section Windowing System Events in Mac OS X
82 Nextstep applications receive a number of special events which have
83 no X equivalent. These are sent as specially defined ``keys'', which
84 do not correspond to any sequence of keystrokes. Under Emacs, these
85 ``key'' events can be bound to functions just like ordinary
86 keystrokes. Here is a list of these events.
90 @vindex ns-pop-up-frames
91 This event occurs when another Nextstep application requests that
92 Emacs open a file. A typical reason for this would be a user
93 double-clicking a file in the Finder application. By default, Emacs
94 responds to this event by opening a new frame and visiting the file in
95 that frame (@code{ns-find-file}), As an exception, if the selected
96 buffer is the @samp{*scratch*} buffer, Emacs visits the file in the
99 You can change how Emacs responds to @key{ns-open-file} by changing
100 the variable @code{ns-pop-up-frames}. Its default value,
101 @code{'fresh}, is what we have just described. A value of @code{t}
102 means to always visit the file in a new frame. A value of @code{nil}
103 means to always visit the file in an existing frame.
105 @item ns-open-temp-file
106 This event occurs when another application requests that Emacs open a
107 temporary file. By default, this is handled by just generating a
108 @code{ns-open-file} event, the results of which are described above.
110 You can bind @key{ns-pop-up-frames} and @key{ns-open-temp-file} to
111 other Lisp functions. When the event is registered, the name of the
112 file to open is stored in the variable @code{ns-input-file}.
114 @item ns-open-file-line
115 Some applications, such as ProjectBuilder and gdb, request not only a
116 particular file, but also a particular line or sequence of lines in
117 the file. Emacs handles this by visiting that file and highlighting
118 the requested line (@code{ns-open-file-select-line}).
121 This event occurs when a user drags files from another application
122 into an Emacs frame. The default behavior is to insert the contents
123 of all the dragged files into the current buffer
124 (@code{ns-insert-files}). The list of dragged files is stored in the
125 variable @code{ns-input-file}.
128 This event occurs when a user drags a color from the color well (or
129 some other source) into an Emacs frame. The default behavior is to
130 alter the foreground color of the area the color was dragged onto
131 (@code{ns-set-foreground-at-mouse}). If this event is issued with a
132 @key{Shift} modifier, Emacs changes the background color instead
133 (@code{ns-set-background-at-mouse}). The name of the dragged color is
134 stored in the variable @code{ns-input-color}.
137 This event occurs when the user selects a font in a Nextstep font
138 panel (which can be opened with @kbd{Cmd-t}). The default behavior is
139 to adjust the font of the selected frame
140 (@code{ns-respond-to-changefont}). The name and size of the selected
141 font are stored in the variables @code{ns-input-font} and
142 @code{ns-input-fontsize} respectively.
145 This event occurs when the user logs out and Emacs is still running.
146 The default behavior is to save all file-visiting buffers without
147 confirmation, and exit.
150 Emacs also allows users to make use of Nextstep services, via a set
151 of commands whose names begin with @samp{ns-service-} and end with the
152 name of the service. Type @kbd{M-x ns-service-@key{TAB}@key{TAB}} to
153 see a list of these commands. These functions either operate on
154 marked text (replacing it with the result) or take a string argument
155 and return the result as a string. You can also use the Lisp function
156 @code{ns-perform-service} to pass arbitrary strings to arbitrary
157 services and receive the results back. Note that you may need to
158 restart Emacs to access newly-available services.
160 @node Mac Preferences
161 @section Mac Preferences
163 The Preferences panel can be used to set or change some of the
164 settings for Emacs such as the text appearance, cursor settings, and
167 To save any settings changed through the Preferences panel, click on
168 @samp{OK}; this has the same effect as if you had explicitly chosen
169 @samp{Help / Save Preferences}.
171 To restore Emacs to use its default settings click @samp{Reset to
172 Defaults} from the Preferences Panel.
174 Additional preferences may be set from the command line using the
175 @command{defaults} command. @xref{Mac Customization}.
177 Font and color settings can be set using the standard NeXTstep font
182 To set the default font used by Emacs click the Default Font... button
183 to launch the Font Panel. Click on a frame before selecting the font
184 family, typeface, and size of the default font from the Font Panel.
186 Note that the default font will not be changed if a frame hasn't been
190 To set the default foreground or background color click the
191 Colors... button to launch the Color Panel. Choose the color you want
192 using any of the color models (color wheel, sliders, palette, image,
193 or crayons) available from the Colors toolbar. To apply the color
194 drag a swatch from the color bar at the top of the panel to text on
195 an Emacs frame. Holding down shift will change the background color
196 instead of the foreground.
199 To use antialiased text check the Smooth Fonts option. Lighter font
200 smoothing can be achieved by checking the Use Quickdraw (lighter)
204 To change the line height that text is displayed at drag the Expand
205 Line Spacing slider. When the slider is set to 0.0 Emacs will use the
206 same line height as other Mac OS X applications. To increase the line
207 height (and decrease the number of lines that can be displayed on the
208 screen) drag the slider towards 1.0. To decrease the line height
209 (increases the number of lines that can be displayed) drag the slider
212 After the line spacing setting has been changed Emacs must be restarted
213 to take account of the change.
217 The Display Preferences can be used to change the appearance of the
218 default cursor used by Emacs.
222 The Cursor Type radio buttons can be used to select the style used for the cursor:
226 Box - the cursor is displayed as a box
228 Underscore - the cursor is displayed as a horizontal bar
230 Bar - the cursor is displayed as a vertical bar
232 Hollow - the cursor is displayed as a box with an outline but no fill
236 Use the Cursor Blink Rate slider to set the frequency at which the cursor blinks.
239 Check the Use System Highlight Color option to use the system default
240 color for highlighted text.
244 The Modifier Preferences can be used to change the behaviour of the
245 Alt/Opt and Command keys. By default the Alt or Opt key is bound to
246 the Emacs 'Meta' key, and the Command key is bound to 'super' which
247 allows the Command key to function in a way similar to other
248 NeXTstep/OS X applications.
252 To re-bind the Alt or Opt key select a keybinding from the Alt/Opt Key
255 To re-bind the Command key select a keybinding from the Command Key
259 @node Mac Customization
260 @section Mac Customization
262 Under X, resources are used to customize the behavior of Emacs to the
263 needs of the user. Nexstep defaults fulfill a similar function. From
264 the command line, the command @samp{defaults read org.gnu.Emacs} show
265 these resources as of the last Emacs exited, and individual resources
266 can be read or written by commands like @samp{defaults read Emacs Foo}
267 and @samp{defaults write Emacs Foo barvalue}.
269 Calling the function @code{ns-save-preferences} in lisp, or
270 selecting the @samp{Option / Save Options} menu item, automatically
271 writes out the defaults corresponding to the selected window.
273 In addition, you can set many of the following customizations by
274 setting @code{default-frame-alist} in your initialization file.
276 Many of the preferences relating specifically to the Nextstep
277 windowing system (such as font rendering and the cursor type) can be
278 set using the Preferences panel (@pxref{Mac Preferences}). It is
279 important to note that when you hit @samp{OK} on this panel,
280 @emph{all} Nextstep settings are saved (including font and colors).
282 This is a listing of some of the more useful defaults (and their
283 default values). Several of these defaults accept the names of colors
284 as values. For a list of all available colors pull up the color panel
285 and look at the color list called @samp{Emacs}. Emacs also accepts
286 color specifications of the form @samp{ARGBaarrggbb} where @var{aa},
287 @var{rr}, @var{gg}, and @var{bb} are two hexadecimal digits describing
288 the alpha, red, green, and blue content of the color respectively.
289 @samp{HSBhhssbb}, @samp{CMYKccmmyykk} and @samp{GRAYgg} are the
290 equivalents in @samp{HSB}, @samp{CMYK} and gray scales. (For HSB,
291 @samp{AHSBaahhssbb} is also accepted.)
294 @item InternalBorderWidth
295 Width in pixels of the internal border of the Nextstep frame. This
296 acts to separate the text area of the window from the fringes,
297 scrollbars, and/or edges.
300 defaults write Emacs InternalBorderWidth 2
303 @item VerticalScrollBars
304 @samp{YES} or @samp{NO} to enable or disable scroll bars, @samp{left} or
305 @samp{right} to explicitly set the side.
308 defaults write Emacs VerticalScrollBars YES
312 Name of the default font to be used for new frames (which can be
313 overridden by various faces). If this font is not set, Emacs will use
314 the system wide fixed pitch font. For most users the system fixed
315 pitch font will be @samp{Monaco} which doesn't have any bold or italic
316 versions. (Italic will be synthesized.)
319 Size of the font to be used for new frames. If not set, Emacs will
320 use the default size of the system wide fixed pitch font.
323 The default foreground (text) color for new frames.
326 defaults write Emacs Foreground "Black"
330 The default background color for new frames.
333 defaults write Emacs Background "White"
337 Height in rows of the default window.
340 defaults write Emacs Height 48
344 Width in columns of the default window.
347 defaults write Emacs Width 80
351 Name of the default cursor type for Emacs. Allowed values are
352 @samp{box}, @samp{hollow}, @samp{underscore}, @samp{bar}, @samp{line} and @samp{no}.
355 defaults write Emacs CursorType box
358 @item CursorBlinkRate
359 Users who want their cursor to blink can set the rate (in seconds) with
360 this defaults write. Setting it to @samp{NO} disables cursor blinking.
363 defaults write Emacs CursorBlinkRate NO
367 Name of the default cursor color for Emacs. Of a particular use for
368 this setting is the @samp{Highlight} color. When it is the cursor
369 color, Emacs will draw the cursor using the standard Nextstep
370 highlighting operator.
373 defaults write Emacs CursorColor Highlight
377 Distance in pixels from the top of the screen of the upper left corner
378 of the default window.
381 defaults write Emacs Top 100
385 Distance in pixels from the left edge of the screen to the upper left
386 corner of the default window.
389 defaults write Emacs Left 100
392 @item HideOnAutoLaunch
393 @samp{YES} or @samp{NO} to determine whether Emacs will hide itself when
394 autolaunched from the dock.
397 defaults write Emacs HideOnAutoLaunch NO
401 This lets you expand or shrink the line height used for displaying
402 text. When this is set to 0.0, display should look like other
403 Nextstep applications. If you set it higher than 0, Emacs will spread
404 the text lines apart, less than 0, compress them together. (With
405 settings below zero parts of characters may be chopped off in certain
406 fonts.) When using the Preferences panel, this is controlled by a
407 slider. You must OK the panel and then restart Emacs for this default
410 When setting this using @code{"defaults write"}, you can either set a floating
411 point value, or @samp{YES}, which is equivalent 0.5, or @samp{NO}, which is
415 defaults write Emacs ExpandSpace -0.125
418 @item GSFontAntiAlias
419 This turns antialiasing on and off on. Note that, on OS X, even if
420 antialiasing is on, Emacs will not antialias text of a size below the system
424 defaults write Emacs GSFontAntiAlias NO
427 @item UseQuickdrawSmoothing
428 On OS X 10.3 and higher, this will render fonts using Quickdraw antialiasing,
429 which is less heavy than the Quartz antialiasing used by default. Whether
430 this is on or off, the system font size threshold for antialiasing (see above)
434 defaults write Emacs UseQuickdrawSmoothing YES
437 @item AlternateModifier
438 This allows you to set the effect of the Alt or Opt key. The default is
439 @samp{meta}, meaning to use as the Emacs 'meta' key. You can also set this to
440 @samp{command}, @samp{hyper}, @samp{alt}, or @samp{none}. The last is useful
441 for Continental users who normally use this key to enter accented and other
445 defaults write Emacs AlternateModifier "none"
448 @item CommandModifier
449 This allows you to set the effect of the Command key. The default is
450 @samp{super}, which is used in a set of keybindings such as @code{s-o} for
451 ``open file'' and @code{s-z} for ``undo'' that are similar to other NeXTstep
452 applications. On the other hand, some people who use the Alt/Opt key for
453 accent entry like to set this to @samp{meta} so they still have easy access to
454 Emacs functionality bound to meta keys. You can also set this, like Alt/Opt,
455 to @samp{hyper} or @samp{alt}, though there are no bindings to combinations
456 using these keys by default. The @samp{none} option is not available for the
460 defaults write Emacs CommandModifier "meta"
464 Position and size to use for the frame named @var{foo} when it is
465 created. The position and size have to be specified as a space
466 separated list: @samp{top}, @samp{left}, @samp{height} and
467 @samp{width}. @samp{top} and @samp{left} are expressed in pixels,
468 @samp{height} is given in rows and @samp{width} is given in columns.
469 Named frames can be created by e.g. @code{(make-frame '((name
473 defaults write Emacs TestFrame "100 200 30 70"
476 Another default previouly used by many Emacs users is this.
479 defaults write Workspace DefaultOpenApp Emacs
482 It caused the NeXTstep Workspace to open files without a registered extension
483 in Emacs instead of as usual Edit. For this default to work, Emacs needed to
484 be in the application search path of the Workspace (which usually includes
485 @file{~/Applications} and @file{~/Applications}). If anyone knows the current
486 way to do this under OS X please contact the authors.
491 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6