1 @c This is part of the Emacs manual.
2 @c Copyright (C) 2000-2018 Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions.
5 @appendix Emacs and macOS / GNUstep
10 This section describes the peculiarities of using Emacs built with
11 the GNUstep libraries on GNU/Linux or other operating systems, or on
12 macOS with native window system support. On macOS, Emacs can be
13 built either without window system support, with X11, or with the
14 Cocoa interface; this section only applies to the Cocoa build. This
15 does not support versions before macOS 10.6.
17 For various historical and technical reasons, Emacs uses the term
18 @samp{Nextstep} internally, instead of ``Cocoa'' or ``macOS''; for
19 instance, most of the commands and variables described in this section
20 begin with @samp{ns-}, which is short for @samp{Nextstep}. NeXTstep
21 was an application interface released by NeXT Inc.@: during the 1980s,
22 of which Cocoa is a direct descendant. Apart from Cocoa, there is
23 another NeXTstep-style system: GNUstep, which is free software. As of
24 this writing, Emacs GNUstep support is alpha status (@pxref{GNUstep
25 Support}), but we hope to improve it in the future.
28 * Mac / GNUstep Basics:: Basic Emacs usage under GNUstep or macOS.
29 * Mac / GNUstep Customization:: Customizations under GNUstep or macOS.
30 * Mac / GNUstep Events:: How window system events are handled.
31 * GNUstep Support:: Details on status of GNUstep support.
34 @node Mac / GNUstep Basics
35 @section Basic Emacs usage under macOS and GNUstep
37 By default, the @key{Alt} and @key{Option} keys are the same as
38 @key{Meta}. The Mac @key{Cmd} key is the same as @key{Super}, and
39 Emacs provides a set of key bindings using this modifier key that mimic
40 other Mac / GNUstep applications (@pxref{Mac / GNUstep Events}). You
41 can change these bindings in the usual way (@pxref{Key Bindings}).
43 @vindex ns-alternate-modifier
44 @vindex ns-right-alternate-modifier
45 The variable @code{ns-right-alternate-modifier} controls the
46 behavior of the right @key{Alt} and @key{Option} keys. These keys
47 behave like the left-hand keys if the value is @code{left} (the
48 default). A value of @code{control}, @code{meta}, @code{alt},
49 @code{super}, or @code{hyper} makes them behave like the corresponding
50 modifier keys; a value to @code{left} means be the same key as
51 @code{ns-alternate-modifier}; a value of @code{none} tells Emacs to
52 ignore them, in which case you get the default behavior of macOS
53 accentuation system from the right option key.
55 @kbd{S-mouse-1} adjusts the region to the click position,
56 just like @kbd{mouse-3} (@code{mouse-save-then-kill}); it does not pop
57 up a menu for changing the default face, as @kbd{S-mouse-1} normally
58 does (@pxref{Text Scale}). This change makes Emacs behave more like
59 other Mac / GNUstep applications.
61 When you open or save files using the menus, or using the
62 @kbd{Cmd-o} and @kbd{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 @kbd{C-x C-f}, Emacs uses the minibuffer to read
67 On GNUstep, in an X-windows environment you need to use @kbd{Cmd-c}
68 instead of one of the @kbd{C-w} or @kbd{M-w} commands to transfer text
69 to the X primary selection; otherwise, Emacs will use the
70 clipboard selection. Likewise, @kbd{Cmd-y} (instead of @kbd{C-y})
71 yanks from the X primary selection instead of the kill-ring or
75 @subsection Grabbing environment variables
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.
79 Many programs which may run under Emacs, like latex or man, depend on the
80 settings of environment variables. If Emacs is launched from the shell, it
81 will automatically inherit these environment variables and its subprocesses
82 will inherit them from it. But if Emacs is launched from the Finder it
83 is not a descendant of any shell, so its environment variables haven't been
84 set, which often causes the subprocesses it launches to behave differently than
85 they would when launched from the shell.
87 For the PATH and MANPATH variables, a system-wide method
88 of setting PATH is recommended on macOS, using the
89 @file{/etc/paths} files and the @file{/etc/paths.d} directory.
91 @node Mac / GNUstep Customization
92 @section Mac / GNUstep Customization
94 There are a few customization options that are specific to the
95 Nextstep port. For example, they affect things such as the modifier
96 keys and the fullscreen behavior. To see all such options, use
97 @kbd{M-x customize-group @key{RET} ns @key{RET}}.
99 @subsection Font and Color Panels
101 The standard Mac / GNUstep font and color panels are accessible via
102 Lisp commands. The Font Panel may be accessed with @kbd{M-x
103 ns-popup-font-panel}. It will set the default font in the frame most
104 recently used or clicked on.
106 @c To make the setting permanent, use @samp{Save Options} in the
107 @c Options menu, or run @code{menu-bar-options-save}.
109 You can bring up a color panel with @kbd{M-x ns-popup-color-panel} and
110 drag the color you want over the Emacs face you want to change. Normal
111 dragging will alter the foreground color. Shift dragging will alter the
112 background color. To discard the settings, create a new frame and
113 close the altered one.
115 @c To make the changes permanent select the "Save Options"
116 @c item in the "Options" menu, or run @code{menu-bar-options-save}.
118 Useful in this context is the listing of all faces obtained by
119 @kbd{M-x list-faces-display}.
121 @cindex Core Text, on macOS
122 In macOS, Emacs uses a Core Text based font backend
123 by default. If you prefer the older font style, enter the following
124 at the command-line before starting Emacs:
127 % defaults write org.gnu.Emacs FontBackend ns
131 @node Mac / GNUstep Events
132 @section Windowing System Events under macOS / GNUstep
134 Nextstep applications receive a number of special events which have
135 no X equivalent. These are sent as specially defined key events, which
136 do not correspond to any sequence of keystrokes. Under Emacs, these
137 key events can be bound to functions just like ordinary
138 keystrokes. Here is a list of these events.
142 @vindex ns-pop-up-frames
143 This event occurs when another Nextstep application requests that
144 Emacs open a file. A typical reason for this would be a user
145 double-clicking a file in the Finder application. By default, Emacs
146 responds to this event by opening a new frame and visiting the file in
147 that frame (@code{ns-find-file}). As an exception, if the selected
148 buffer is the @file{*scratch*} buffer, Emacs visits the file in the
151 You can change how Emacs responds to a @code{ns-open-file} event by
152 changing the variable @code{ns-pop-up-frames}. Its default value,
153 @samp{fresh}, is what we have just described. A value of @code{t}
154 means to always visit the file in a new frame. A value of @code{nil}
155 means to always visit the file in an existing frame.
157 @item ns-open-temp-file
158 This event occurs when another application requests that Emacs open a
159 temporary file. By default, this is handled by just generating a
160 @code{ns-open-file} event, the results of which are described above.
162 @item ns-open-file-line
163 Some applications, such as ProjectBuilder and gdb, request not only a
164 particular file, but also a particular line or sequence of lines in
165 the file. Emacs handles this by visiting that file and highlighting
166 the requested line (@code{ns-open-file-select-line}).
169 This event occurs when a user drags files from another application
170 into an Emacs frame. The default behavior is to insert the contents
171 of all the dragged files into the current buffer
172 (@code{ns-insert-files}). The list of dragged files is stored in the
173 variable @code{ns-input-file}.
176 This event occurs when a user drags a color from the color well (or
177 some other source) into an Emacs frame. The default behavior is to
178 alter the foreground color of the area the color was dragged onto
179 (@code{ns-set-foreground-at-mouse}). If this event is issued with a
180 @key{Shift} modifier, Emacs changes the background color instead
181 (@code{ns-set-background-at-mouse}). The name of the dragged color is
182 stored in the variable @code{ns-input-color}.
185 This event occurs when the user selects a font in a Nextstep font
186 panel (which can be opened with @kbd{Cmd-t}). The default behavior is
187 to adjust the font of the selected frame
188 (@code{ns-respond-to-changefont}). The name and size of the selected
189 font are stored in the variables @code{ns-input-font} and
190 @code{ns-input-fontsize}, respectively.
193 This event occurs when the user logs out and Emacs is still running, or when
194 ``Quit Emacs'' is chosen from the application menu.
195 The default behavior is to save all file-visiting buffers.
198 Emacs also allows users to make use of Nextstep services, via a set
199 of commands whose names begin with @samp{ns-service-} and end with the
200 name of the service. Type @kbd{M-x ns-service-@key{TAB}} to
201 see a list of these commands. These functions either operate on
202 marked text (replacing it with the result) or take a string argument
203 and return the result as a string. You can also use the Lisp function
204 @code{ns-perform-service} to pass arbitrary strings to arbitrary
205 services and receive the results back. Note that you may need to
206 restart Emacs to access newly-available services.
208 @node GNUstep Support
209 @section GNUstep Support
211 Emacs can be built and run under GNUstep, but there are still
212 issues to be addressed. Interested developers should contact
214 @email{emacs-devel@@gnu.org}.
217 @url{https://lists.gnu.org/mailman/listinfo/emacs-devel, the
218 emacs-devel mailing list}.