aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-11-14 20:40:28 +0000
committerChong Yidong2008-11-14 20:40:28 +0000
commit8be7682356b546c55724fcf4a21b6f4d4ba021a0 (patch)
tree5a181f7e67e75e09b2ca84866dc9a8dd1d79c240
parent0b4f2253e6f06f675437dbc1f744bc52f8a6d6b9 (diff)
downloademacs-8be7682356b546c55724fcf4a21b6f4d4ba021a0.tar.gz
emacs-8be7682356b546c55724fcf4a21b6f4d4ba021a0.zip
(Mac OS): Move Cocoa manual from ns-emacs.texi to here, replacing
previous contents. Numerous copyedits to adapt ns-emacs to the conventions of the main Emacs manual.
-rw-r--r--doc/emacs/macos.texi751
1 files changed, 407 insertions, 344 deletions
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index d4673794d3c..e35e9bf4168 100644
--- a/doc/emacs/macos.texi
+++ b/doc/emacs/macos.texi
@@ -8,421 +8,484 @@
8@cindex Macintosh 8@cindex Macintosh
9 9
10 This section briefly describes the peculiarities of using Emacs 10 This section briefly describes the peculiarities of using Emacs
11under Mac OS with native window system support. For Mac OS X, Emacs 11under Mac OS X with native window system support. For Mac OS X, Emacs
12can be built either without window system support, with X11, or with 12can be built either without window system support, with X11, or with
13Carbon API. This section only applies to the Carbon build. For Mac 13the Cocoa interface. This section only applies to the Cocoa build.
14OS Classic, Emacs can be built with or without Carbon API, and this 14Emacs 23 does not support Mac OS Classic.
15section applies to either of them because they run on the native 15
16window system. 16 Emacs, when built on Mac OS X, uses the Cocoa application interface.
17 17For various historical and technical reasons, Emacs uses the term
18 Emacs built on Mac OS X supports most of its major features except 18@samp{Nextstep} internally, instead of ``Cocoa'' or ``Mac OS X''; for
19display support of PostScript images. The following features of Emacs 19instance, most of the commands and variables described in the
20are not supported on Mac OS Classic: unexec (@code{dump-emacs}), 20following sections begin with @samp{ns-}, which is short for
21asynchronous subprocesses (@code{start-process}), and networking 21@samp{Nextstep}. NeXTstep was an application interface released by
22(@code{open-network-stream}). As a result, packages such as Gnus, 22NeXT Inc during the 1980s, of which Cocoa is a direct descendent.
23GUD, and Comint do not work. Synchronous subprocesses 23Apart from Cocoa, there is another NeXTstep-style system: GNUstep,
24(@code{call-process}) are supported on non-Carbon build, but 24which is free software. As of this writing, the GNUstep support is
25specially-crafted external programs are needed. Since external 25not fully functional, but we hope to improve it in the future.
26programs to handle commands such as @code{print-buffer} and
27@code{diff} are not available on Mac OS Classic, they are not
28supported. Non-Carbon build on Mac OS Classic does not support some
29features such as file dialogs, drag-and-drop, and Unicode menus.
30 26
31@menu 27@menu
32* Input: Mac Input. Keyboard and mouse input on Mac. 28* Mac Basics:: Basic Emacs usage in Mac OS.
33* Intl: Mac International. International character sets on Mac. 29* Mac Events:: How window system events are handled.
34* Env: Mac Environment Variables. Setting environment variables for Emacs. 30* Mac Preferences:: Using the Preferences Panel to customize Emacs.
35* Directories: Mac Directories. Volumes and directories on Mac. 31* Mac Customization:: Customizations in Mac OS
36* Font: Mac Font Specs. Specifying fonts on Mac.
37* Functions: Mac Functions. Mac-specific Lisp functions.
38@end menu 32@end menu
39 33
40@node Mac Input 34@node Mac Basics
41@section Keyboard and Mouse Input on Mac 35@section Basic Emacs usage in Mac OS
42@cindex Meta (Mac OS) 36
43@cindex keyboard coding (Mac OS) 37 By default, the @key{alt} and @key{option} keys are the same as
44 38@key{Meta} when running under Mac OS. The Mac @key{Cmd} key is the
45@vindex mac-control-modifier 39same as @key{Super}, and Emacs provides a set of keybindings using
46@vindex mac-command-modifier 40this modifier key that mimic other Mac applications (@pxref{Mac
47@vindex mac-option-modifier 41Events}). You can change these bindings in the usual way (@pxref{Key
48@vindex mac-function-modifier 42Bindings}), or by using the Mac preferences panel (@pxref{Mac
49 On Mac, Emacs can use @key{control}, @key{command}, @key{option}, and 43Preferences}).
50laptop @key{function} keys as any of Emacs modifier keys except 44
51@key{SHIFT} (i.e., @key{ALT}, @key{CTRL}, @key{HYPER}, @key{META}, and 45 The standard Mac font and color panels are accessible via the
52@key{SUPER}). The assignment is controlled by the variables 46@samp{Windows} menu, or via the standard @key{Cmd-t} and @key{Cmd-C}
53@code{mac-control-modifier}, @code{mac-command-modifier}, 47keybindings. To use the color panel, drag from it to an Emacs frame
54@code{mac-option-modifier}, and @code{mac-function-modifier}. The value 48to change the foreground color of the face at that position (if the
55for each of these variables can be one of the following symbols: 49@key{shift} key is held down, it changes the background color
56@code{alt}, @code{control}, @code{hyper}, @code{meta}, @code{super}, and 50instead). To finalize the settings for either color or font, choose
57@code{nil} (no particular assignment). By default, the @key{control} 51@samp{Save Options} in the @samp{Options} menu. To discard the
58key works as @key{CTRL}, and the @key{command} key as @key{META}. 52settings, create a new frame and close the altered one.
59 53
60 For the @key{option} key, if @code{mac-option-modifier} is set to 54 In Mac OS, @key{S-Mouse-1} (i.e., clicking the left mouse button
61@code{nil}, which is the default, the key works as the normal 55while holding down the @key{Shift} key) adjusts the region to the
62@key{option} key, i.e., dead-key processing will work. This is useful 56click position, just like @key{Mouse-3} (@code{mouse-save-then-kill});
63for entering non-@acronym{ASCII} Latin characters directly from the 57it does not pop up a menu for changing the default face, as
64Mac keyboard, for example. 58@key{S-Mouse-1} normally does (@pxref{Temporary Face Changes}). This
65 59change makes Emacs behave more like other Mac applications.
66 Emacs recognizes the setting in the Keyboard control panel (Mac OS 60
67Classic) or the International system preference pane (Mac OS X) and 61 When you open or save files using the menus, or using the standard
68supports international and alternative keyboard layouts (e.g., Dvorak). 62@key{Cmd-o} and @key{Cmd-S} bindings, Emacs uses graphical file
69Selecting one of the layouts from the keyboard layout pull-down menu 63dialogs to read file names. However, if you use the regular Emacs key
70will affect how the keys typed on the keyboard are interpreted. 64sequences, such as @key{C-x C-f}, Emacs uses the minibuffer to read
71 65file names.
72@vindex mac-pass-command-to-system 66
73@vindex mac-pass-control-to-system 67 When Emacs is called by a name which ends in @file{-nw}, it will
74 Mac OS intercepts and handles certain key combinations (e.g., 68always start in terminal mode. For example, if you need a
75@key{command}-@key{SPC} for switching input languages). These will not 69terminal-only Emacs, create a symbolic link from @file{emacs} to
76be passed to Emacs. One can disable this interception by setting 70@file{emacs-nw} and launch @file{emacs-nw}.
77@code{mac-pass-command-to-system} or @code{mac-pass-control-to-system} 71
78to @code{nil}. 72 On GNUstep, in an X-windows environment you need to use @key{Cmd-c}
79 73instead of one of the @key{C-w} or @key{M-w} commands to transfer text
80@vindex mac-emulate-three-button-mouse 74to the X primary selection; otherwise, Emacs will use the
81 Especially for one-button mice, the multiple button feature can be 75``clipboard'' selection. Likewise, @key{Cmd-y} (instead of @key{C-y})
82emulated by setting @code{mac-emulate-three-button-mouse} to @code{t} 76yanks from the X primary selection instead of the kill-ring or
83or @code{reverse}. If set to @code{t} (@code{reverse}, respectively), 77clipboard.
84pressing the mouse button with the @key{option} key is recognized as 78
85the second (third) button, and that with the @key{command} key is 79@node Mac Events
86recognized as the third (second) button. 80@section Windowing System Events in Mac OS X
87 81
88@vindex mac-wheel-button-is-mouse-2 82 Nextstep applications receive a number of special events which have
89 For multi-button mice, the wheel button and the secondary button are 83no X equivalent. These are sent as specially defined ``keys'', which
90recognized as the second and the third button, respectively. If 84do not correspond to any sequence of keystrokes. Under Emacs, these
91@code{mac-wheel-button-is-mouse-2} is set to @code{nil}, their roles 85``key'' events can be bound to functions just like ordinary
92are exchanged. 86keystrokes. Here is a list of these events.
93 87
94@node Mac International 88@table @key
95@section International Character Set Support on Mac 89@item ns-open-file
96@cindex Mac Roman coding system 90@vindex ns-pop-up-frames
97@cindex clipboard support (Mac OS) 91This event occurs when another Nextstep application requests that
98 92Emacs open a file. A typical reason for this would be a user
99 Mac uses non-standard encodings for the upper 128 single-byte 93double-clicking a file in the Finder application. By default, Emacs
100characters. They also deviate from the ISO 2022 standard by using 94responds to this event by opening a new frame and visiting the file in
101character codes in the range 128-159. The coding systems 95that frame (@code{ns-find-file}), As an exception, if the selected
102@code{mac-roman}, @code{mac-centraleurroman}, and @code{mac-cyrillic} 96buffer is the @samp{*scratch*} buffer, Emacs visits the file in the
103are used to represent these Mac encodings. 97the selected frame.
104 98
105 You can use input methods provided either by LEIM (@pxref{Input 99You can change how Emacs responds to @key{ns-open-file} by changing
106Methods}) or Mac OS to enter international characters. To use the 100the variable @code{ns-pop-up-frames}. Its default value,
107former, see the International Character Set Support section of the 101@code{'fresh}, is what we have just described. A value of @code{t}
108manual (@pxref{International}). 102means to always visit the file in a new frame. A value of @code{nil}
109 103means to always visit the file in an existing frame.
110 Emacs on Mac OS automatically changes the value of 104
111@code{keyboard-coding-system} according to the current keyboard 105@item ns-open-temp-file
112layout. So users don't need to set it manually, and even if set, it 106This event occurs when another application requests that Emacs open a
113will be changed when the keyboard layout change is detected next time. 107temporary file. By default, this is handled by just generating a
114 108@code{ns-open-file} event, the results of which are described above.
115 The Mac clipboard and the Emacs kill ring (@pxref{Killing}) are 109
116synchronized by default: you can yank a piece of text and paste it 110You can bind @key{ns-pop-up-frames} and @key{ns-open-temp-file} to
117into another Mac application, or cut or copy one in another Mac 111other Lisp functions. When the event is registered, the name of the
118application and yank it into a Emacs buffer. This feature can be 112file to open is stored in the variable @code{ns-input-file}.
119disabled by setting @code{x-select-enable-clipboard} to @code{nil}. 113
120One can still do copy and paste with another application from the Edit 114@item ns-open-file-line
121menu. 115Some applications, such as ProjectBuilder and gdb, request not only a
122 116particular file, but also a particular line or sequence of lines in
123 On Mac, the role of the coding system for selection that is set by 117the file. Emacs handles this by visiting that file and highlighting
124@code{set-selection-coding-system} (@pxref{Communication Coding}) is 118the requested line (@code{ns-open-file-select-line}).
125two-fold. First, it is used as a preferred coding system for the 119
126traditional text flavor that does not specify any particular encodings 120@item ns-drag-file
127and is mainly used by applications on Mac OS Classic. Second, it 121This event occurs when a user drags files from another application
128specifies the intermediate encoding for the UTF-16 text flavor that is 122into an Emacs frame. The default behavior is to insert the contents
129mainly used by applications on Mac OS X. 123of all the dragged files into the current buffer
130 124(@code{ns-insert-files}). The list of dragged files is stored in the
131 When pasting UTF-16 text data from the clipboard, it is first 125variable @code{ns-input-file}.
132converted to the encoding specified by the selection coding system 126
133using the converter in the Mac OS system, and then decoded into the 127@item ns-drag-color
134Emacs internal encoding using the converter in Emacs. If the first 128This event occurs when a user drags a color from the color well (or
135conversion failed, then the UTF-16 data is directly converted to Emacs 129some other source) into an Emacs frame. The default behavior is to
136internal encoding using the converter in Emacs. Copying UTF-16 text 130alter the foreground color of the area the color was dragged onto
137to the clipboard goes through the inverse path. The reason for this 131(@code{ns-set-foreground-at-mouse}). If this event is issued with a
138two-pass decoding is to avoid subtle differences in Unicode mappings 132@key{Shift} modifier, Emacs changes the background color instead
139between the Mac OS system and Emacs such as various kinds of hyphens, 133(@code{ns-set-background-at-mouse}). The name of the dragged color is
140and to minimize users' customization. For example, users that mainly 134stored in the variable @code{ns-input-color}.
141use Latin characters would prefer Greek characters to be decoded into 135
142the @code{mule-unicode-0100-24ff} charset, but Japanese users would 136@item ns-change-font
143prefer them to be decoded into the @code{japanese-jisx0208} charset. 137This event occurs when the user selects a font in a Nextstep font
144Since the coding system for selection is automatically set according 138panel (which can be opened with @kbd{Cmd-t}). The default behavior is
145to the system locale setting, users usually don't have to set it 139to adjust the font of the selected frame
146manually. 140(@code{ns-respond-to-changefont}). The name and size of the selected
147 141font are stored in the variables @code{ns-input-font} and
148 The default language environment (@pxref{Language Environments}) is 142@code{ns-input-fontsize} respectively.
149set according to the locale setting at the startup time. On Mac OS, 143
150the locale setting is consulted in the following order: 144@item ns-power-off
151 145This event occurs when the user logs out and Emacs is still running.
152@enumerate 146The default behavior is to save all file-visiting buffers without
147confirmation, and exit.
148@end table
149
150 Emacs also allows users to make use of Nextstep services, via a set
151of commands whose names begin with @samp{ns-service-} and end with the
152name of the service. Type @kbd{M-x ns-service-@key{TAB}@key{TAB}} to
153see a list of these commands. These functions either operate on
154marked text (replacing it with the result) or take a string argument
155and return the result as a string. You can also use the Lisp function
156@code{ns-perform-service} to pass arbitrary strings to arbitrary
157services and receive the results back. Note that you may need to
158restart Emacs to access newly-available services.
159
160@node Mac Preferences
161@section Mac Preferences
162
163The Preferences panel can be used to set or change some of the
164settings for Emacs such as the text appearance, cursor settings, and
165key bindings.
166
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}.
170
171 To restore Emacs to use its default settings click @samp{Reset to
172Defaults} from the Preferences Panel.
173
174 Additional preferences may be set from the command line using the
175@command{defaults} command. @xref{Mac Customization}.
176
177Font and color settings can be set using the standard NeXTstep font
178and color panels.
179
180@itemize @bullet
153@item 181@item
154Environment variables @env{LC_ALL}, @env{LC_CTYPE} and @env{LANG} as 182To set the default font used by Emacs click the Default Font... button
155in other systems. 183to launch the Font Panel. Click on a frame before selecting the font
184family, typeface, and size of the default font from the Font Panel.
185
186Note that the default font will not be changed if a frame hasn't been
187selected first.
156 188
157@item 189@item
158Preference @code{AppleLocale} that is set by default on Mac OS X 10.3 190To set the default foreground or background color click the
159and later. 191Colors... button to launch the Color Panel. Choose the color you want
192using any of the color models (color wheel, sliders, palette, image,
193or crayons) available from the Colors toolbar. To apply the color
194drag a swatch from the color bar at the top of the panel to text on
195an Emacs frame. Holding down shift will change the background color
196instead of the foreground.
160 197
161@item 198@item
162Preference @code{AppleLanguages} that is set by default on Mac OS X 199To use antialiased text check the Smooth Fonts option. Lighter font
16310.1 and later. 200smoothing can be achieved by checking the Use Quickdraw (lighter)
201smoothing option.
164 202
165@item 203@item
166Variable @code{mac-system-locale} that is derived from the system 204To change the line height that text is displayed at drag the Expand
167language and region codes. This variable is available on all 205Line Spacing slider. When the slider is set to 0.0 Emacs will use the
168supported Mac OS versions including Mac OS Classic. 206same line height as other Mac OS X applications. To increase the line
169@end enumerate 207height (and decrease the number of lines that can be displayed on the
208screen) drag the slider towards 1.0. To decrease the line height
209(increases the number of lines that can be displayed) drag the slider
210towards -1.0.
211
212After the line spacing setting has been changed Emacs must be restarted
213to take account of the change.
170 214
171 The default values of almost all variables about coding systems are 215@end itemize
172also set according to the language environment. So usually you don't
173have to customize these variables manually.
174 216
175@node Mac Environment Variables 217The Display Preferences can be used to change the appearance of the
176@section Environment Variables and Command Line Arguments. 218default cursor used by Emacs.
177@cindex environment variables (Mac OS)
178 219
179 On Mac OS X, when Emacs is run in a terminal, it inherits the values 220@itemize @bullet
180of environment variables from the shell from which it is invoked. 221@item
181However, when it is run from the Finder as a GUI application, it only 222The Cursor Type radio buttons can be used to select the style used for the cursor:
182inherits environment variable values defined in the file
183@file{~/.MacOSX/environment.plist} that affects all the applications
184invoked from the Finder or the @command{open} command.
185 223
186 Command line arguments are specified like 224@itemize
225@item
226Box - the cursor is displayed as a box
227@item
228Underscore - the cursor is displayed as a horizontal bar
229@item
230Bar - the cursor is displayed as a vertical bar
231@item
232Hollow - the cursor is displayed as a box with an outline but no fill
233@end itemize
234
235@item
236Use the Cursor Blink Rate slider to set the frequency at which the cursor blinks.
237
238@item
239Check the Use System Highlight Color option to use the system default
240color for highlighted text.
241
242@end itemize
243
244The Modifier Preferences can be used to change the behaviour of the
245Alt/Opt and Command keys. By default the Alt or Opt key is bound to
246the Emacs 'Meta' key, and the Command key is bound to 'super' which
247allows the Command key to function in a way similar to other
248NeXTstep/OS X applications.
249
250@itemize @bullet
251@item
252To re-bind the Alt or Opt key select a keybinding from the Alt/Opt Key
253combo box.
254@item
255To re-bind the Command key select a keybinding from the Command Key
256combo box.
257@end itemize
258
259@node Mac Customization
260@section Mac Customization
261
262Under X, resources are used to customize the behavior of Emacs to the
263needs of the user. Nexstep defaults fulfill a similar function. From
264the command line, the command @samp{defaults read org.gnu.Emacs} show
265these resources as of the last Emacs exited, and individual resources
266can be read or written by commands like @samp{defaults read Emacs Foo}
267and @samp{defaults write Emacs Foo barvalue}.
268
269 Calling the function @code{ns-save-preferences} in lisp, or
270selecting the @samp{Option / Save Options} menu item, automatically
271writes out the defaults corresponding to the selected window.
272
273 In addition, you can set many of the following customizations by
274setting @code{default-frame-alist} in your initialization file.
275
276 Many of the preferences relating specifically to the Nextstep
277windowing system (such as font rendering and the cursor type) can be
278set using the Preferences panel (@pxref{Mac Preferences}). It is
279important to note that when you hit @samp{OK} on this panel,
280@emph{all} Nextstep settings are saved (including font and colors).
281
282This is a listing of some of the more useful defaults (and their
283default values). Several of these defaults accept the names of colors
284as values. For a list of all available colors pull up the color panel
285and look at the color list called @samp{Emacs}. Emacs also accepts
286color specifications of the form @samp{ARGBaarrggbb} where @var{aa},
287@var{rr}, @var{gg}, and @var{bb} are two hexadecimal digits describing
288the alpha, red, green, and blue content of the color respectively.
289@samp{HSBhhssbb}, @samp{CMYKccmmyykk} and @samp{GRAYgg} are the
290equivalents in @samp{HSB}, @samp{CMYK} and gray scales. (For HSB,
291@samp{AHSBaahhssbb} is also accepted.)
292
293@table @samp
294@item InternalBorderWidth
295Width in pixels of the internal border of the Nextstep frame. This
296acts to separate the text area of the window from the fringes,
297scrollbars, and/or edges.
187 298
188@example 299@example
189/Applications/Emacs.app/Contents/MacOS/Emacs -g 80x25 & 300defaults write Emacs InternalBorderWidth 2
190@end example 301@end example
191 302
192@noindent 303@item VerticalScrollBars
193if Emacs is installed at @file{/Applications/Emacs.app}. If Emacs is 304@samp{YES} or @samp{NO} to enable or disable scroll bars, @samp{left} or
194invoked like this, then it also inherits the values of environment 305@samp{right} to explicitly set the side.
195variables from the shell from which it is invoked.
196 306
197 On Mac OS Classic, environment variables and command line arguments 307@example
198for Emacs can be set by modifying the @samp{STR#} resources 128 and 308defaults write Emacs VerticalScrollBars YES
199129, respectively. A common environment variable that one may want to 309@end example
200set is @samp{HOME}. 310
311@item Font
312Name of the default font to be used for new frames (which can be
313overriden by various faces). If this font is not set, Emacs will use
314the system wide fixed pitch font. For most users the system fixed
315pitch font will be @samp{Monaco} which doesn't have any bold or italic
316versions. (Italic will be synthesized.)
201 317
202 The way to set an environment variable is by adding a string of the 318@item FontSize
203form 319Size of the font to be used for new frames. If not set, Emacs will
320use the default size of the system wide fixed pitch font.
321
322@item Foreground
323The default foreground (text) color for new frames.
204 324
205@example 325@example
206ENV_VAR=VALUE 326defaults write Emacs Foreground "Black"
207@end example 327@end example
208 328
209@noindent 329@item Background
210to resource @samp{STR#} number 128 using @code{ResEdit}. To set up the 330The default background color for new frames.
211program to use unibyte characters exclusively, for example, add the
212string
213 331
214@example 332@example
215EMACS_UNIBYTE=1 333defaults write Emacs Background "White"
216@end example 334@end example
217 335
218@cindex Mac Preferences 336@item Height
219 Although Emacs on Mac does not support X resources (@pxref{X 337Height in rows of the default window.
220Resources}) directly, one can use the Preferences system in place of X
221resources. For example, adding the line
222 338
223@example 339@example
224Emacs.cursorType: bar 340defaults write Emacs Height 48
225@end example 341@end example
226 342
227@noindent 343@item Width
228to @file{~/.Xresources} in X11 corresponds to the execution of 344Width in columns of the default window.
229 345
230@example 346@example
231defaults write org.gnu.Emacs Emacs.cursorType bar 347defaults write Emacs Width 80
232@end example 348@end example
233 349
234@noindent 350@item CursorType
235on Mac OS X. One can use boolean or numeric values as well as string 351Name of the default cursor type for Emacs. Allowed values are
236values as follows: 352@samp{box}, @samp{hollow}, @samp{underscore}, @samp{bar}, @samp{line} and @samp{no}.
237 353
238@example 354@example
239defaults write org.gnu.Emacs Emacs.toolBar -bool false 355defaults write Emacs CursorType box
240defaults write org.gnu.Emacs Emacs.lineSpacing -int 3
241@end example 356@end example
242 357
243@noindent 358@item CursorBlinkRate
244Try @kbd{M-x man RET defaults RET} for the usage of the 359Users who want their cursor to blink can set the rate (in seconds) with
245@command{defaults} command. Alternatively, if you have Developer 360this defaults write. Setting it to @samp{NO} disables cursor blinking.
246Tools installed on Mac OS X, you can use Property List Editor to edit
247the file @file{~/Library/Preferences/org.gnu.Emacs.plist}.
248 361
362@example
363defaults write Emacs CursorBlinkRate NO
364@end example
365
366@item CursorColor
367Name of the default cursor color for Emacs. Of a particular use for
368this setting is the @samp{Highlight} color. When it is the cursor
369color, Emacs will draw the cursor using the standard Nextstep
370highlighting operator.
371
372@example
373defaults write Emacs CursorColor Highlight
374@end example
249 375
250@node Mac Directories 376@item Top
251@section Volumes and Directories on Mac 377Distance in pixels from the top of the screen of the upper left corner
252@cindex file names (Mac OS) 378of the default window.
253 379
254 This node applies to Mac OS Classic only. 380@example
381defaults write Emacs Top 100
382@end example
255 383
256 The directory structure in Mac OS Classic is seen by Emacs as 384@item Left
385Distance in pixels from the left edge of the screen to the upper left
386corner of the default window.
257 387
258@example 388@example
259/@var{volumename}/@var{filename} 389defaults write Emacs Left 100
260@end example 390@end example
261 391
262So when Emacs requests a file name, doing file name completion on 392@item HideOnAutoLaunch
263@file{/} will display all volumes on the system. You can use @file{..} 393@samp{YES} or @samp{NO} to determine whether Emacs will hide itself when
264to go up a directory level. 394autolaunched from the dock.
395
396@example
397defaults write Emacs HideOnAutoLaunch NO
398@end example
265 399
266 On Mac OS Classic, to access files and folders on the desktop, look 400@item ExpandSpace
267in the folder @file{Desktop Folder} in your boot volume (this folder 401This lets you expand or shrink the line height used for displaying
268is usually invisible in the Mac @code{Finder}). 402text. When this is set to 0.0, display should look like other
403Nextstep applications. If you set it higher than 0, Emacs will spread
404the text lines apart, less than 0, compress them together. (With
405settings below zero parts of characters may be chopped off in certain
406fonts.) When using the Preferences panel, this is controlled by a
407slider. You must OK the panel and then restart Emacs for this default
408to take effect.
269 409
270 On Mac OS Classic, Emacs creates the Mac folder 410When setting this using @code{"defaults write"}, you can either set a floating
271@file{:Preferences:Emacs:} in the @file{System Folder} and uses it as 411point value, or @samp{YES}, which is equivalent 0.5, or @samp{NO}, which is
272the temporary directory. Emacs maps the directory name @file{/tmp/} 412equivalent to 0.0.
273to that. Therefore it is best to avoid naming a volume @file{tmp}.
274If everything works correctly, the program should leave no files in it
275when it exits. You should be able to set the environment variable
276@code{TMPDIR} to use another directory but this folder will still be
277created.
278 413
414@example
415defaults write Emacs ExpandSpace -0.125
416@end example
279 417
280@node Mac Font Specs 418@item GSFontAntiAlias
281@section Specifying Fonts on Mac 419This turns antialiasing on and off on. Note that, on OS X, even if
282@cindex font names (Mac OS) 420antialiasing is on, Emacs will not antialias text of a size below the system
421preference setting.
283 422
284 It is rare that you need to specify a font name in Emacs; usually 423@example
285you specify face attributes instead. For example, you can use 14pt 424defaults write Emacs GSFontAntiAlias NO
286Courier by customizing the default face attributes for all frames: 425@end example
287 426
288@lisp 427@item UseQuickdrawSmoothing
289(set-face-attribute 'default nil 428On OS X 10.3 and higher, this will render fonts using Quickdraw antialiasing,
290 :family "courier" :height 140) 429which is less heavy than the Quartz antialiasing used by default. Whether
291@end lisp 430this is on or off, the system font size threshold for antialiasing (see above)
431is respected.
292 432
293@noindent 433@example
294Alternatively, an interactive one is also available 434defaults write Emacs UseQuickdrawSmoothing YES
295(@pxref{Face Customization}). 435@end example
296 436
297But when you do need to specify a font name in Emacs on Mac, use a 437@item AlternateModifier
298standard X font name: 438This 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
441for Continental users who normally use this key to enter accented and other
442special characters.
299 443
300@smallexample 444@example
301-@var{maker}-@var{family}-@var{weight}-@var{slant}-@var{widthtype}-@var{style}@dots{} 445defaults write Emacs AlternateModifier "none"
302@dots{}-@var{pixels}-@var{height}-@var{horiz}-@var{vert}-@var{spacing}-@var{width}-@var{charset} 446@end example
303@end smallexample
304 447
305@noindent 448@item CommandModifier
306@xref{Font X}. Wildcards are supported as they are on X. 449This 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
452applications. On the other hand, some people who use the Alt/Opt key for
453accent entry like to set this to @samp{meta} so they still have easy access to
454Emacs functionality bound to meta keys. You can also set this, like Alt/Opt,
455to @samp{hyper} or @samp{alt}, though there are no bindings to combinations
456using these keys by default. The @samp{none} option is not available for the
457Command key.
307 458
308 Emacs on Mac OS Classic uses QuickDraw Text routines for drawing texts 459@example
309by default. Emacs on Mac OS X uses @acronym{ATSUI, Apple Type Services 460defaults write Emacs CommandModifier "meta"
310for Unicode Imaging} as well as QuickDraw Text, and most of the 461@end example
311characters other than Chinese, Japanese, and Korean ones are drawn using
312the former by default.
313 462
314 @acronym{ATSUI}-compatible fonts have maker name @code{apple} and 463@item fooFrame
315charset @code{iso10646-1}. For example, 12-point Monaco can be specified 464Position and size to use for the frame named @var{foo} when it is
316by the name: 465created. The position and size have to be specified as a space
466separated 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.
469Named frames can be created by e.g. @code{(make-frame '((name
470. "FOO")))}.
317 471
318@example 472@example
319-apple-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1 473defaults write Emacs TestFrame "100 200 30 70"
320@end example 474@end example
321 475
322Note that these names must be specified using a format containing all 476Another default previouly used by many Emacs users is this.
32314 @samp{-}s (not by
324@samp{-apple-monaco-medium-r-normal--12-*-iso10646-1}, for instance),
325because every @acronym{ATSUI}-compatible font is a scalable one.
326
327 QuickDraw Text fonts have maker name @code{apple} and various charset
328names other than @code{iso10646-1}. Native Apple fonts in Mac Roman
329encoding has charset @code{mac-roman}. You can specify a
330@code{mac-roman} font for @acronym{ASCII} characters like
331
332@smalllisp
333(add-to-list
334 'default-frame-alist
335 '(font . "-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman"))
336@end smalllisp
337
338@noindent
339but that does not extend to ISO-8859-1: specifying a @code{mac-roman}
340font for Latin-1 characters introduces wrong glyphs.
341
342 Native Apple Traditional Chinese, Simplified Chinese, Japanese,
343Korean, Central European, Cyrillic, Symbol, and Dingbats fonts have
344the charsets @samp{big5-0}, @samp{gb2312.1980-0},
345@samp{jisx0208.1983-sjis} and @samp{jisx0201.1976-0},
346@samp{ksc5601.1989-0}, @samp{mac-centraleurroman},
347@samp{mac-cyrillic}, @samp{mac-symbol}, and @samp{mac-dingbats},
348respectively.
349
350 The use of @code{create-fontset-from-fontset-spec} (@pxref{Defining
351Fontsets}) for defining fontsets often results in wrong ones especially
352when using only OS-bundled QuickDraw Text fonts. The recommended way to
353use them is to create a fontset using
354@code{create-fontset-from-mac-roman-font}:
355
356@lisp
357(create-fontset-from-mac-roman-font
358 "-apple-courier-medium-r-normal--13-*-*-*-*-*-mac-roman"
359 nil "foo")
360@end lisp
361
362@noindent
363and then optionally specifying Chinese, Japanese, or Korean font
364families using @code{set-fontset-font}:
365
366@lisp
367(set-fontset-font "fontset-foo"
368 'chinese-gb2312 '("song" . "gb2312.1980-0"))
369@end lisp
370
371 Single-byte fonts converted from GNU fonts in BDF format, which are not
372in the Mac Roman encoding, have foundry, family, and character sets
373encoded in the names of their font suitcases. E.g., the font suitcase
374@samp{ETL-Fixed-ISO8859-1} contains fonts which can be referred to by
375the name @samp{-ETL-fixed-*-iso8859-1}.
376
377@vindex mac-allow-anti-aliasing
378 Mac OS X 10.2 or later can use two types of text renderings: Quartz 2D
379(aka Core Graphics) and QuickDraw. By default, Emacs uses the former on
380such versions. It can be changed by setting
381@code{mac-allow-anti-aliasing} to @code{t} (Quartz 2D) or @code{nil}
382(QuickDraw). Both @acronym{ATSUI} and QuickDraw Text drawings are
383affected by the value of this variable.
384
385 Appearance of text in small sizes will also be affected by the ``Turn
386off text smoothing for font sizes @var{n} and smaller'' setting in the
387General pane (Mac OS X 10.1 or 10.2) or in the Appearance pane (10.3 or
388later) of the System Preferences. This threshold can alternatively be
389set just for Emacs (i.e., not as the system-wide setting) using the
390@command{defaults} command:
391 477
392@example 478@example
393defaults write org.gnu.Emacs AppleAntiAliasingThreshold @var{n} 479defaults write Workspace DefaultOpenApp Emacs
394@end example 480@end example
395 481
482It caused the NeXTstep Workspace to open files without a registered extension
483in Emacs instead of as usual Edit. For this default to work, Emacs needed to
484be in the application search path of the Workspace (which usually includes
485@file{~/Applications} and @file{~/Applications}). If anyone knows the current
486way to do this under OS X please contact the authors.
396 487
397@node Mac Functions 488@end table
398@section Mac-Specific Lisp Functions
399@cindex Lisp functions specific to Mac OS
400
401@findex do-applescript
402 The function @code{do-applescript} takes a string argument,
403executes it as an AppleScript command, and returns the result as a
404string.
405
406@findex mac-file-name-to-posix
407@findex posix-file-name-to-mac
408 The function @code{mac-file-name-to-posix} takes a Mac file name and
409returns the GNU or Unix equivalent. The function
410@code{posix-file-name-to-mac} performs the opposite conversion. They
411are useful for constructing AppleScript commands to be passed to
412@code{do-applescript}.
413
414@findex mac-set-file-creator
415@findex mac-get-file-creator
416@findex mac-set-file-type
417@findex mac-get-file-type
418 The functions @code{mac-set-file-creator},
419@code{mac-get-file-creator}, @code{mac-set-file-type}, and
420@code{mac-get-file-type} can be used to set and get creator and file
421codes.
422
423@findex mac-get-preference
424 The function @code{mac-get-preference} returns the preferences value
425converted to a Lisp object for a specified key and application.
426 489
427@ignore 490@ignore
428 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6 491 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6