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 / GNUstep, Microsoft Windows, Antinews, Top
6 @appendix Emacs and Mac OS / GNUstep
11 This section briefly describes the peculiarities of using Emacs built with
12 the GNUstep libraries on GNU/Linux or other operating systems, or on Mac OS X
13 with native window system support. For Mac OS X, Emacs can be built either
14 without window system support, with X11, or with the Cocoa interface. This
15 section only applies to the Cocoa build. Emacs 23 does not support Mac OS
18 Emacs, when built on Mac OS X, uses the Cocoa application interface. For
19 various historical and technical reasons, Emacs uses the term @samp{Nextstep}
20 internally, instead of ``Cocoa'' or ``Mac OS X''; for instance, most of the
21 commands and variables described in the following sections begin with
22 @samp{ns-}, which is short for @samp{Nextstep}. NeXTstep was an application
23 interface released by NeXT Inc during the 1980s, of which Cocoa is a direct
24 descendent. Apart from Cocoa, there is another NeXTstep-style system:
25 GNUstep, which is free software. As of this writing, the GNUstep support is
26 alpha status (see @pxref{GNUstep Support}), but we hope to improve it in the
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
37 @node Mac / GNUstep Basics, Mac / GNUstep Customization, , Mac OS / GNUstep
38 @section Basic Emacs usage under Mac OS and GNUstep
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
42 same as @key{Super}, and Emacs provides a set of keybindings using
43 this modifier key that mimic other Mac / GNUstep applications (@pxref{Mac /
44 GNUstep Events}). You can change these bindings in the usual way (@pxref{Key
45 Bindings}), or by using the Preferences panel (@pxref{Mac / GNUstep
48 The standard Mac / GNUstep font and color panels are accessible via the
49 @samp{Windows} menu, or via the standard @key{Cmd-t} and @key{Cmd-C}
50 keybindings. To use the color panel, drag from it to an Emacs frame
51 to change the foreground color of the face at that position (if the
52 @key{shift} key is held down, it changes the background color
53 instead). To finalize the settings for either color or font, choose
54 @samp{Save Options} in the @samp{Options} menu. To discard the
55 settings, create a new frame and close the altered one.
57 @key{S-Mouse-1} (i.e., clicking the left mouse button
58 while holding down the @key{Shift} key) adjusts the region to the
59 click position, just like @key{Mouse-3} (@code{mouse-save-then-kill});
60 it does not pop up a menu for changing the default face, as
61 @key{S-Mouse-1} normally does (@pxref{Temporary Face Changes}). This
62 change makes Emacs behave more like other Mac / GNUstep applications.
64 When you open or save files using the menus, or using the standard
65 @key{Cmd-o} and @key{Cmd-S} bindings, Emacs uses graphical file
66 dialogs to read file names. However, if you use the regular Emacs key
67 sequences, such as @key{C-x C-f}, Emacs uses the minibuffer to read
70 On GNUstep, in an X-windows environment you need to use @key{Cmd-c}
71 instead of one of the @key{C-w} or @key{M-w} commands to transfer text
72 to the X primary selection; otherwise, Emacs will use the
73 ``clipboard'' selection. Likewise, @key{Cmd-y} (instead of @key{C-y})
74 yanks from the X primary selection instead of the kill-ring or
78 @subsection Grabbing environment variables
80 Many programs which may run under Emacs like latex or man depend on the
81 settings of environment variables. If Emacs is launched from the shell, it
82 will automatically inherit these environment variables and its subprocesses
83 will inherit them from it. But if Emacs is launched from the Finder it
84 is not a descendant of any shell, so its environment variables haven't been
85 set which often causes the subprocesses it launches to behave differently than
86 they would when launched from the shell.
88 To solve this problem for Emacs, there are two solutions. First is to
89 run, from the command line:
92 .../Emacs.app/Contents/MacOS/bin/mac-fix-env
95 This will pick up your environment settings and save them into a special file
96 @file{~/.MacOSX/environment.plist}, which the desktop environment will use to
97 set the environment for all launched applications. The drawback of this
98 method is it needs to be run again whenever something changes.
100 The other approach is to use the @code{ns-grabenv} command inside Emacs. This
101 function will run a subshell and copy its environment variables into Emacs.
103 Adding this line to your @file{~/.emacs} will grab the csh environment
104 whenever emacs runs under a window system.
107 (if window-system (ns-grabenv))
110 If you have a different shell you will have to give @code{ns-grabenv} some
111 arguments. For zsh you would do this.
114 (if window-system (ns-grabenv "/usr/bin/zsh"
119 The reason that @code{ns-grabenv} is not done by default is that it adds up
120 to a second or two to the Emacs startup time.
123 @node Mac / GNUstep Customization, Mac / GNUstep Events, Mac / GNUstep Basics, Mac OS / GNUstep
124 @section Mac / GNUstep Customization
126 Emacs can be customized in several ways in addition to the standard
127 customization buffers and the Options menu.
130 @subsection Preferences Panel
132 The Preferences panel, much like the Options menu, is designed to allow quick
133 and convenient setting of commonly used options.
135 The Preferences panel is available for setting commonly used GUI-related
136 options for Emacs. Access it under the Emacs menu (Mac) or Info menu
137 (GNUstep), or using @kbd{Cmd-,}.
139 Settings made here are saved when @samp{OK} is hit, or @samp{Save Options} is
140 selected from the Options menu. These settings are stored into the NeXTstep
141 ``defaults'' system under keys described below.
145 To set the default font used by Emacs click the @samp{Default Font...} button
146 to being up the Font Panel, then click on a frame. The font of this frame
147 will then be changed when you make a selection in the Font Panel, and this
148 will be used as the default for future frames. If you do not select a frame
149 first, the Font Panel will not work.
152 The Color panel, brought up by the @samp{Colors...} button, allows setting of
153 foreground or background of any face. Drag from the color bar to over the
154 emacs face you want to change. This will change the foreground of that face,
155 or holding shift when dragging will change the background.
158 @samp{Smooth Fonts} and @samp{Use Quickdraw} control text antialiasing.
159 Quickdraw is an older Mac technology still supported under OS X.
162 The @samp{Expand Line Spacing} slider controls vertical spacing of text. The
163 0.0 setting corresponds to the same height as other applications. Settings
164 less than 0 compress the spacing, and greater than 0 expand it. Emacs must be
165 restarted for the new setting to take effect.
168 The @samp{Cursor Type} radio buttons select the cursor shape:
173 Filled Box - the cursor is displayed as a box (default)
175 Vertical Bar - the cursor is displayed as a vertical line
177 Underscore - the cursor is displayed as a horizontal line
179 Hollow - the cursor is displayed as a box with an outline but no fill
183 The @samp{Cursor Blink Rate} slider to sets the frequency at which the cursor
184 blinks (CURRENTLY INOPERATIVE -- use @samp{customize group cursor} instead.)
187 The @samp{Use System Highlight Color} option controls whether selected text is
188 highlighted with the system default or the local emacs setting.
192 The behavior of Modifier keys inside emacs can be controlled by the drop-down
193 menus in the @samp{Modifiers} section. By default the Alt or Opt key is bound
194 to the Emacs 'Meta' key, and the Command key is bound to 'super' which allows
195 the Command key to function in a way similar to other NeXTstep/OS X
199 @subsection Font and Color Panels
201 The Font Panel may be accessed from the Windows menu or by @kbd{Cmd-t}. It
202 will set the default font in the frame most recently used or clicked on. To
203 make the setting permanent, use @samp{Save Options} in the Options menu, or
204 run @code{ns-save-preferences}.
206 You can bring up a color panel (with @key{Cmd-C} or from the Windows menu) and
207 drag the color you want over the emacs face you want to change. Normal
208 dragging will alter the foreground color. Shift dragging will alter the
209 background color. To make the changes permanent select the "Save Options"
210 item in the "Options" menu, or run @code{ns-save-preferences}. Useful in this
211 context is the listing of all faces obtained by @key{M-x}
212 @code{list-faces-display}.
217 Under X, resources are used to customize the behavior of Emacs to the
218 needs of the user. Nextstep defaults fulfill a similar function. From
219 the command line, the command @samp{defaults read org.gnu.Emacs} shows
220 these resources as of the last Emacs exited, and individual resources
221 can be read or written by commands like @samp{defaults read Emacs Foo}
222 and @samp{defaults write Emacs Foo barvalue}.
224 Calling the function @code{ns-save-preferences} in lisp, or
225 selecting the @samp{Option / Save Options} menu item, automatically
226 writes out the defaults corresponding to the selected window.
228 In addition, you can set many of the following customizations by
229 setting @code{default-frame-alist} in your initialization file.
231 Many of the preferences relating specifically to the Nextstep windowing
232 system (such as font rendering and the cursor type) can be set using the
233 Preferences panel. It is important to note that when you hit @samp{OK} on
234 this panel, @emph{all} Nextstep settings are saved (including font and
237 This is a listing of some of the more useful defaults (and their
238 default values). Several of these defaults accept the names of colors
239 as values. For a list of all available colors pull up the color panel
240 and look at the color list called @samp{Emacs}. Emacs also accepts
241 color specifications of the form @samp{ARGBaarrggbb} where @var{aa},
242 @var{rr}, @var{gg}, and @var{bb} are two hexadecimal digits describing
243 the alpha, red, green, and blue content of the color respectively.
244 @samp{HSBhhssbb}, @samp{CMYKccmmyykk} and @samp{GRAYgg} are the
245 equivalents in @samp{HSB}, @samp{CMYK} and gray scales. (For HSB,
246 @samp{AHSBaahhssbb} is also accepted.)
249 @item InternalBorderWidth
250 Width in pixels of the internal border of the Nextstep frame. This
251 acts to separate the text area of the window from the fringes,
252 scrollbars, and/or edges.
255 defaults write Emacs InternalBorderWidth 2
258 @item VerticalScrollBars
259 @samp{YES} or @samp{NO} to enable or disable scroll bars, @samp{left} or
260 @samp{right} to explicitly set the side.
263 defaults write Emacs VerticalScrollBars YES
267 Name of the default font to be used for new frames (which can be
268 overridden by various faces). If this font is not set, Emacs will use
269 the system wide fixed pitch font. For most users the system fixed
270 pitch font will be @samp{Monaco} which doesn't have any bold or italic
271 versions. (Italic will be synthesized.)
274 Size of the font to be used for new frames. If not set, Emacs will
275 use the default size of the system wide fixed pitch font.
278 The default foreground (text) color for new frames.
281 defaults write Emacs Foreground "Black"
285 The default background color for new frames.
288 defaults write Emacs Background "White"
292 Height in rows of the default window.
295 defaults write Emacs Height 48
299 Width in columns of the default window.
302 defaults write Emacs Width 80
306 Name of the default cursor type for Emacs. Allowed values are
307 @samp{box}, @samp{hollow}, @samp{underscore}, @samp{bar}, @samp{line} and @samp{no}.
310 defaults write Emacs CursorType box
314 Name of the default cursor color for Emacs. Of a particular use for
315 this setting is the @samp{Highlight} color. When it is the cursor
316 color, Emacs will draw the cursor using the standard Nextstep
317 highlighting operator.
320 defaults write Emacs CursorColor blue
324 Distance in pixels from the top of the screen of the upper left corner
325 of the default window.
328 defaults write Emacs Top 100
332 Distance in pixels from the left edge of the screen to the upper left
333 corner of the default window.
336 defaults write Emacs Left 100
339 @item HideOnAutoLaunch
340 @samp{YES} or @samp{NO} to determine whether Emacs will hide itself when
341 autolaunched from the dock.
344 defaults write Emacs HideOnAutoLaunch NO
348 This lets you expand or shrink the line height used for displaying
349 text. When this is set to 0.0, display should look like other
350 Nextstep applications. If you set it higher than 0, Emacs will spread
351 the text lines apart, less than 0, compress them together. (With
352 settings below zero parts of characters may be chopped off in certain
353 fonts.) When using the Preferences panel, this is controlled by a
354 slider. You must OK the panel and then restart Emacs for this default
357 When setting this using @code{"defaults write"}, you can either set a floating
358 point value, or @samp{YES}, which is equivalent 0.5, or @samp{NO}, which is
362 defaults write Emacs ExpandSpace -0.125
365 @item GSFontAntiAlias
366 This turns antialiasing on and off on. Note that, on OS X, even if
367 antialiasing is on, Emacs will not antialias text of a size below the system
371 defaults write Emacs GSFontAntiAlias NO
374 @item UseQuickdrawSmoothing
375 On OS X 10.3 and higher, this will render fonts using Quickdraw antialiasing,
376 which is less heavy than the Quartz antialiasing used by default. Whether
377 this is on or off, the system font size threshold for antialiasing (see above)
381 defaults write Emacs UseQuickdrawSmoothing YES
384 @item AlternateModifier
385 This allows you to set the effect of the Alt or Opt key. The default is
386 @samp{meta}, meaning to use as the Emacs 'meta' key. You can also set this to
387 @samp{command}, @samp{hyper}, @samp{alt}, or @samp{none}. The last is useful
388 for Continental users who normally use this key to enter accented and other
392 defaults write Emacs AlternateModifier "none"
395 @item CommandModifier
396 This allows you to set the effect of the Command key. The default is
397 @samp{super}, which is used in a set of keybindings such as @code{s-o} for
398 ``open file'' and @code{s-z} for ``undo'' that are similar to other NeXTstep
399 applications. On the other hand, some people who use the Alt/Opt key for
400 accent entry like to set this to @samp{meta} so they still have easy access to
401 Emacs functionality bound to meta keys. You can also set this, like Alt/Opt,
402 to @samp{hyper} or @samp{alt}, though there are no bindings to combinations
403 using these keys by default. The @samp{none} option is not available for the
407 defaults write Emacs CommandModifier "meta"
411 Position and size to use for the frame named @var{foo} when it is
412 created. The position and size have to be specified as a space
413 separated list: @samp{top}, @samp{left}, @samp{height} and
414 @samp{width}. @samp{top} and @samp{left} are expressed in pixels,
415 @samp{height} is given in rows and @samp{width} is given in columns.
416 Named frames can be created by e.g. @code{(make-frame '((name
420 defaults write Emacs TestFrame "100 200 30 70"
423 Another default previouly used by many Emacs users is this.
426 defaults write Workspace DefaultOpenApp Emacs
429 It caused the NeXTstep Workspace to open files without a registered extension
430 in Emacs instead of as usual Edit. For this default to work, Emacs needed to
431 be in the application search path of the Workspace (which usually includes
432 @file{~/Applications} and @file{~/Applications}). If anyone knows the current
433 way to do this under OS X please contact the authors.
437 @subsection Open files by dragging to an Emacs window
439 The default behaviour when a user drags files from another application
440 into an Emacs frame is to insert the contents of all the dragged files
441 into the current buffer. To remap the @code{ns-drag-file} event to
442 open the dragged files in the current frame use the following line:
445 (define-key global-map [ns-drag-file] 'ns-find-file)
449 @node Mac / GNUstep Events, GNUstep Support, Mac / GNUstep Customization, Mac OS / GNUstep
450 @section Windowing System Events under Mac OS / GNUstep
452 Nextstep applications receive a number of special events which have
453 no X equivalent. These are sent as specially defined ``keys'', which
454 do not correspond to any sequence of keystrokes. Under Emacs, these
455 ``key'' events can be bound to functions just like ordinary
456 keystrokes. Here is a list of these events.
460 @vindex ns-pop-up-frames
461 This event occurs when another Nextstep application requests that
462 Emacs open a file. A typical reason for this would be a user
463 double-clicking a file in the Finder application. By default, Emacs
464 responds to this event by opening a new frame and visiting the file in
465 that frame (@code{ns-find-file}), As an exception, if the selected
466 buffer is the @samp{*scratch*} buffer, Emacs visits the file in the
469 You can change how Emacs responds to @key{ns-open-file} by changing
470 the variable @code{ns-pop-up-frames}. Its default value,
471 @code{'fresh}, is what we have just described. A value of @code{t}
472 means to always visit the file in a new frame. A value of @code{nil}
473 means to always visit the file in an existing frame.
475 @item ns-open-temp-file
476 This event occurs when another application requests that Emacs open a
477 temporary file. By default, this is handled by just generating a
478 @code{ns-open-file} event, the results of which are described above.
480 You can bind @key{ns-pop-up-frames} and @key{ns-open-temp-file} to
481 other Lisp functions. When the event is registered, the name of the
482 file to open is stored in the variable @code{ns-input-file}.
484 @item ns-open-file-line
485 Some applications, such as ProjectBuilder and gdb, request not only a
486 particular file, but also a particular line or sequence of lines in
487 the file. Emacs handles this by visiting that file and highlighting
488 the requested line (@code{ns-open-file-select-line}).
491 This event occurs when a user drags files from another application
492 into an Emacs frame. The default behavior is to insert the contents
493 of all the dragged files into the current buffer
494 (@code{ns-insert-files}). The list of dragged files is stored in the
495 variable @code{ns-input-file}.
498 This event occurs when a user drags a color from the color well (or
499 some other source) into an Emacs frame. The default behavior is to
500 alter the foreground color of the area the color was dragged onto
501 (@code{ns-set-foreground-at-mouse}). If this event is issued with a
502 @key{Shift} modifier, Emacs changes the background color instead
503 (@code{ns-set-background-at-mouse}). The name of the dragged color is
504 stored in the variable @code{ns-input-color}.
507 This event occurs when the user selects a font in a Nextstep font
508 panel (which can be opened with @kbd{Cmd-t}). The default behavior is
509 to adjust the font of the selected frame
510 (@code{ns-respond-to-changefont}). The name and size of the selected
511 font are stored in the variables @code{ns-input-font} and
512 @code{ns-input-fontsize} respectively.
515 This event occurs when the user logs out and Emacs is still running.
516 The default behavior is to save all file-visiting buffers without
517 confirmation, and exit.
520 Emacs also allows users to make use of Nextstep services, via a set
521 of commands whose names begin with @samp{ns-service-} and end with the
522 name of the service. Type @kbd{M-x ns-service-@key{TAB}@key{TAB}} to
523 see a list of these commands. These functions either operate on
524 marked text (replacing it with the result) or take a string argument
525 and return the result as a string. You can also use the Lisp function
526 @code{ns-perform-service} to pass arbitrary strings to arbitrary
527 services and receive the results back. Note that you may need to
528 restart Emacs to access newly-available services.
531 @node GNUstep Support, , Mac / GNUstep Events, Mac OS / GNUstep
532 @section GNUstep Support
534 Emacs can be built and run under GNUstep however building is difficult and
535 there are some limitations to functionality. In particular, it may be
536 necessary to run @samp{make bootstrap} with a plain X configuration, then
537 @samp{make clean} and @samp{./configure --with-ns} followed by @samp{make
540 Currently CANNOT_DUMP is automatically enabled in GNUstep configurations,
541 because the unex file(s) for GNUstep, mainly @samp{unexelf.c}, have not been
542 updated yet with the ``zone'' code in and related to @samp{unexmacosx.c}.
545 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6