]> code.delx.au - gnu-emacs/blob - man/macos.texi
(Mac International): Rename "fontset-mac" to "fontset-standard".
[gnu-emacs] / man / macos.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 @c 2005, 2006 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Mac OS, MS-DOS, Antinews, Top
6 @appendix Emacs and Mac OS
7 @cindex Mac OS
8 @cindex Macintosh
9
10 This section briefly describes the peculiarities of using Emacs
11 under Mac OS with native window system support. For Mac OS X, Emacs
12 can be built either without window system support, with X11, or with
13 Carbon API. This section only applies to the Carbon build. For Mac
14 OS Classic, Emacs can be built with or without Carbon API, and this
15 section applies to either of them because they run on the native
16 window system.
17
18 Emacs built on Mac OS X supports most of its major features except
19 display support of PostScript images. The following features of Emacs
20 are not supported on Mac OS Classic: unexec (@code{dump-emacs}),
21 asynchronous subprocesses (@code{start-process}), and networking
22 (@code{open-network-stream}). As a result, packages such as Gnus,
23 GUD, and Comint do not work. Synchronous subprocesses
24 (@code{call-process}) are supported on non-Carbon build, but
25 specially-crafted external programs are needed. Since external
26 programs to handle commands such as @code{print-buffer} and
27 @code{diff} are not available on Mac OS Classic, they are not
28 supported. Non-Carbon build on Mac OS Classic does not support some
29 features such as file dialogs, drag-and-drop, and Unicode menus.
30
31 @menu
32 * Input: Mac Input. Keyboard and mouse input on Mac.
33 * Intl: Mac International. International character sets on Mac.
34 * Env: Mac Environment Variables. Setting environment variables for Emacs.
35 * Directories: Mac Directories. Volumes and directories on Mac.
36 * Font: Mac Font Specs. Specifying fonts on Mac.
37 * Functions: Mac Functions. Mac-specific Lisp functions.
38 @end menu
39
40 @node Mac Input
41 @section Keyboard and Mouse Input on Mac
42 @cindex Meta (Mac OS)
43 @cindex keyboard coding (Mac OS)
44
45 @vindex mac-control-modifier
46 @vindex mac-command-modifier
47 @vindex mac-option-modifier
48 On Mac, Emacs can use @key{control}, @key{command}, and @key{option}
49 keys as any of Emacs modifier keys except @key{SHIFT} (i.e.,
50 @key{ALT}, @key{CTRL}, @key{HYPER}, @key{META}, and @key{SUPER}). The
51 assignment is controlled by the variables @code{mac-control-modifier},
52 @code{mac-command-modifier}, and @code{mac-option-modifier}. The
53 value for each of these variables can be one of the following symbols:
54 @code{alt}, @code{control}, @code{hyper}, @code{meta}, @code{super},
55 and @code{nil} (no particular assignment). By default, the
56 @key{control} key works as @key{CTRL}, and the @key{command} key as
57 @key{META}.
58
59 For the @key{option} key, if @code{mac-option-modifier} is set to
60 @code{nil}, which is the default, the key works as the normal
61 @key{option} key, i.e., dead-key processing will work. This is useful
62 for entering non-@acronym{ASCII} Latin characters directly from the
63 Mac keyboard, for example.
64
65 Emacs recognizes the setting in the Keyboard control panel (Mac OS
66 Classic) or the International system preference pane (Mac OS X) and
67 supports international and alternative keyboard layouts (e.g., Dvorak)
68 if its script is either Roman, Japanese, Traditional Chinese, Korean,
69 Cyrillic, Simplified Chinese, or Central European. Keyboard layouts
70 based on Unicode may not work properly. Selecting one of the layouts
71 from the keyboard layout pull-down menu will affect how the keys typed
72 on the keyboard are interpreted.
73
74 @vindex mac-pass-command-to-system
75 @vindex mac-pass-control-to-system
76 Mac OS intercepts and handles certain key combinations (e.g.,
77 @key{command}-@key{SPC} for switching input languages). These will not
78 be passed to Emacs. One can disable this interception by setting
79 @code{mac-pass-command-to-system} or @code{mac-pass-control-to-system}
80 to @code{nil}.
81
82 @vindex mac-emulate-three-button-mouse
83 Especially for one-button mice, the multiple button feature can be
84 emulated by setting @code{mac-emulate-three-button-mouse} to @code{t}
85 or @code{reverse}. If set to @code{t} (@code{reverse}, respectively),
86 pressing the mouse button with the @key{option} key is recognized as
87 the second (third) button, and that with the @key{command} key is
88 recognized as the third (second) button.
89
90 @vindex mac-wheel-button-is-mouse-2
91 For multi-button mice, the wheel button and the secondary button are
92 recognized as the second and the third button, respectively. If
93 @code{mac-wheel-button-is-mouse-2} is set to @code{nil}, their roles
94 are exchanged.
95
96 @node Mac International
97 @section International Character Set Support on Mac
98 @cindex Mac Roman coding system
99 @cindex clipboard support (Mac OS)
100
101 Mac uses non-standard encodings for the upper 128 single-byte
102 characters. They also deviate from the ISO 2022 standard by using
103 character codes in the range 128-159. The coding systems
104 @code{mac-roman}, @code{mac-centraleurroman}, and @code{mac-cyrillic}
105 are used to represent these Mac encodings.
106
107 The fontset @code{fontset-standard} is created automatically when
108 Emacs is run on Mac, and used by default. It displays as many kinds
109 of characters as possible using 12-point Monaco as a base font. If
110 you see some character as a hollow box with this fontset, then it's
111 almost impossible to display it only by customizing font settings
112 (@pxref{Mac Font Specs}).
113
114 You can use input methods provided either by LEIM (@pxref{Input
115 Methods}) or Mac OS to enter international characters. To use the
116 former, see the International Character Set Support section of the
117 manual (@pxref{International}).
118
119 Emacs on Mac OS automatically changes the value of
120 @code{keyboard-coding-system} according to the current keyboard
121 layout. So users don't need to set it manually, and even if set, it
122 will be changed when the keyboard layout change is detected next time.
123
124 The Mac clipboard and the Emacs kill ring (@pxref{Killing}) are
125 synchronized by default: you can yank a piece of text and paste it
126 into another Mac application, or cut or copy one in another Mac
127 application and yank it into a Emacs buffer. This feature can be
128 disabled by setting @code{x-select-enable-clipboard} to @code{nil}.
129 One can still do copy and paste with another application from the Edit
130 menu.
131
132 On Mac, the role of the coding system for selection that is set by
133 @code{set-selection-coding-system} (@pxref{Communication Coding}) is
134 two-fold. First, it is used as a preferred coding system for the
135 traditional text flavor that does not specify any particular encodings
136 and is mainly used by applications on Mac OS Classic. Second, it
137 specifies the intermediate encoding for the UTF-16 text flavor that is
138 mainly used by applications on Mac OS X.
139
140 When pasting UTF-16 text data from the clipboard, it is first
141 converted to the encoding specified by the selection coding system
142 using the converter in the Mac OS system, and then decoded into the
143 Emacs internal encoding using the converter in Emacs. If the first
144 conversion failed, then the UTF-16 data is directly converted to Emacs
145 internal encoding using the converter in Emacs. Copying UTF-16 text
146 to the clipboard goes through the inverse path. The reason for this
147 two-pass decoding is to avoid subtle differences in Unicode mappings
148 between the Mac OS system and Emacs such as various kinds of hyphens,
149 and to minimize users' customization. For example, users that mainly
150 use Latin characters would prefer Greek characters to be decoded into
151 the @code{mule-unicode-0100-24ff} charset, but Japanese users would
152 prefer them to be decoded into the @code{japanese-jisx0208} charset.
153 Since the coding system for selection is automatically set according
154 to the system locale setting, users usually don't have to set it
155 manually.
156
157 The default language environment (@pxref{Language Environments}) is
158 set according to the locale setting at the startup time. On Mac OS,
159 the locale setting is consulted in the following order:
160
161 @enumerate
162 @item
163 Environment variables @env{LC_ALL}, @env{LC_CTYPE} and @env{LANG} as
164 in other systems.
165
166 @item
167 Preference @code{AppleLocale} that is set by default on Mac OS X 10.3
168 and later.
169
170 @item
171 Preference @code{AppleLanguages} that is set by default on Mac OS X
172 10.1 and later.
173
174 @item
175 Variable @code{mac-system-locale} that is derived from the system
176 language and region codes. This variable is available on all
177 supported Mac OS versions including Mac OS Classic.
178 @end enumerate
179
180 The default values of almost all variables about coding systems are
181 also set according to the language environment. So usually you don't
182 have to customize these variables manually.
183
184 @node Mac Environment Variables
185 @section Environment Variables and Command Line Arguments.
186 @cindex environment variables (Mac OS)
187
188 On Mac OS X, when Emacs is run in a terminal, it inherits the values
189 of environment variables from the shell from which it is invoked.
190 However, when it is run from the Finder as a GUI application, it only
191 inherits environment variable values defined in the file
192 @file{~/.MacOSX/environment.plist} that affects all the applications
193 invoked from the Finder or the @command{open} command.
194
195 Command line arguments are specified like
196
197 @example
198 /Applications/Emacs.app/Contents/MacOS/Emacs -geometry 80x25 &
199 @end example
200
201 @noindent
202 if Emacs is installed at @file{/Applications/Emacs.app}. If Emacs is
203 invoked like this, then it also inherits the values of environment
204 variables from the shell from which it is invoked.
205
206 On Mac OS Classic, environment variables and command line arguments
207 for Emacs can be set by modifying the @samp{STR#} resources 128 and
208 129, respectively. A common environment variable that one may want to
209 set is @samp{HOME}.
210
211 The way to set an environment variable is by adding a string of the
212 form
213
214 @example
215 ENV_VAR=VALUE
216 @end example
217
218 @noindent
219 to resource @samp{STR#} number 128 using @code{ResEdit}. To set up the
220 program to use unibyte characters exclusively, for example, add the
221 string
222
223 @example
224 EMACS_UNIBYTE=1
225 @end example
226
227 @cindex Mac Preferences
228 Although Emacs on Mac does not support X resources (@pxref{X
229 Resources}) directly, one can use the Preferences system in place of X
230 resources. For example, adding the line
231
232 @example
233 Emacs.cursorType: bar
234 @end example
235
236 @noindent
237 to @file{~/.Xresources} in X11 corresponds to the execution of
238
239 @example
240 defaults write org.gnu.Emacs Emacs.cursorType bar
241 @end example
242
243 @noindent
244 on Mac OS X. One can use boolean or numeric values as well as string
245 values as follows:
246
247 @example
248 defaults write org.gnu.Emacs Emacs.toolBar -bool false
249 defaults write org.gnu.Emacs Emacs.lineSpacing -int 3
250 @end example
251
252 @noindent
253 Try @kbd{M-x man RET defaults RET} for the usage of the
254 @command{defaults} command. Alternatively, if you have Developer
255 Tools installed on Mac OS X, you can use Property List Editor to edit
256 the file @file{~/Library/Preferences/org.gnu.Emacs.plist}.
257
258
259 @node Mac Directories
260 @section Volumes and Directories on Mac
261 @cindex file names (Mac OS)
262
263 This node applies to Mac OS Classic only.
264
265 The directory structure in Mac OS Classic is seen by Emacs as
266
267 @example
268 /@var{volumename}/@var{filename}
269 @end example
270
271 So when Emacs requests a file name, doing file name completion on
272 @file{/} will display all volumes on the system. You can use @file{..}
273 to go up a directory level.
274
275 On Mac OS Classic, to access files and folders on the desktop, look
276 in the folder @file{Desktop Folder} in your boot volume (this folder
277 is usually invisible in the Mac @code{Finder}).
278
279 On Mac OS Classic, Emacs creates the Mac folder
280 @file{:Preferences:Emacs:} in the @file{System Folder} and uses it as
281 the temporary directory. Emacs maps the directory name @file{/tmp/}
282 to that. Therefore it is best to avoid naming a volume @file{tmp}.
283 If everything works correctly, the program should leave no files in it
284 when it exits. You should be able to set the environment variable
285 @code{TMPDIR} to use another directory but this folder will still be
286 created.
287
288
289 @node Mac Font Specs
290 @section Specifying Fonts on Mac
291 @cindex font names (Mac OS)
292
293 It is rare that you need to specify a font name in Emacs; usually
294 you specify face attributes instead. For example, you can use 14pt
295 Courier by customizing the default face attributes for all frames:
296
297 @lisp
298 (set-face-attribute 'default nil :family "courier" :height 140)
299 @end lisp
300
301 @noindent
302 Alternatively, an interactive one is also available
303 (@pxref{Face Customization}).
304
305 But when you do need to specify a font name in Emacs on Mac, use a
306 standard X font name:
307
308 @smallexample
309 -@var{maker}-@var{family}-@var{weight}-@var{slant}-@var{widthtype}-@var{style}@dots{}
310 @dots{}-@var{pixels}-@var{height}-@var{horiz}-@var{vert}-@var{spacing}-@var{width}-@var{charset}
311 @end smallexample
312
313 @noindent
314 @xref{Font X}. Wildcards are supported as they are on X.
315
316 Native Apple fonts in Mac Roman encoding has maker name @code{apple}
317 and charset @code{mac-roman}. For example 12-point Monaco can be
318 specified by the name @samp{-apple-monaco-*-12-*-mac-roman}. When
319 using a particular size of scalable fonts, it must be specified in a
320 format containing 14 @samp{-}s like
321 @samp{-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman}.
322
323 You can specify a @code{mac-roman} font for @acronym{ASCII}
324 characters like
325
326 @lisp
327 (add-to-list
328 'default-frame-alist
329 '(font . "-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman"))
330 @end lisp
331
332 @noindent
333 but that does not extend to ISO-8859-1: specifying a @code{mac-roman}
334 font for Latin-1 characters introduces wrong glyphs.
335
336 Native Apple Traditional Chinese, Simplified Chinese, Japanese,
337 Korean, Central European, Cyrillic, Symbol, and Dingbats fonts have
338 charsets @samp{big5-0}, @samp{gb2312.1980-0},
339 @samp{jisx0208.1983-sjis} and @samp{jisx0201.1976-0},
340 @samp{ksc5601.1989-0}, @samp{mac-centraleurroman},
341 @samp{mac-cyrillic}, @samp{mac-symbol}, and @samp{mac-dingbats},
342 respectively.
343
344 Since Emacs as of the current version uses QuickDraw Text routines
345 for drawing texts, only characters in the charsets listed above can be
346 displayed with the OS-bundled fonts, even if other applications that
347 use @acronym{ATSUI} or Cocoa can display variety of characters with
348 them.
349
350 The use of @code{create-fontset-from-fontset-spec} (@pxref{Defining
351 Fontsets}) for defining fontsets often results in wrong ones
352 especially when using only OS-bundled fonts. The recommended way is
353 to create a fontset using @code{create-fontset-from-mac-roman-font}:
354
355 @lisp
356 (create-fontset-from-mac-roman-font
357 "-apple-courier-medium-r-normal--13-*-*-*-*-*-mac-roman"
358 nil "foo")
359 @end lisp
360
361 @noindent
362 and then optionally specifying Chinese, Japanese, or Korean font
363 families using @code{set-fontset-font}:
364
365 @lisp
366 (set-fontset-font "fontset-foo"
367 'chinese-gb2312 '("song" . "gb2312.1980-0"))
368 @end lisp
369
370 Single-byte fonts converted from GNU fonts in BDF format, which are not
371 in the Mac Roman encoding, have foundry, family, and character sets
372 encoded in the names of their font suitcases. E.g., the font suitcase
373 @samp{ETL-Fixed-ISO8859-1} contains fonts which can be referred to by
374 the name @samp{-ETL-fixed-*-iso8859-1}.
375
376 @vindex mac-allow-anti-aliasing
377 Emacs uses the QuickDraw text rendering by default. On Mac OS X
378 10.2 and later, it can be changed so that it uses the Quartz 2D text
379 rendering (aka CG text rendering) by setting
380 @code{mac-allow-anti-aliasing} to @code{t}. However, it is reported
381 to sometimes leave some garbages.
382
383 @node Mac Functions
384 @section Mac-Specific Lisp Functions
385 @cindex Lisp functions specific to Mac OS
386
387 @findex do-applescript
388 The function @code{do-applescript} takes a string argument,
389 executes it as an AppleScript command, and returns the result as a
390 string.
391
392 @findex mac-file-name-to-posix
393 @findex posix-file-name-to-mac
394 The function @code{mac-file-name-to-posix} takes a Mac file name and
395 returns the GNU or Unix equivalent. The function
396 @code{posix-file-name-to-mac} performs the opposite conversion. They
397 are useful for constructing AppleScript commands to be passed to
398 @code{do-applescript}.
399
400 @findex mac-set-file-creator
401 @findex mac-get-file-creator
402 @findex mac-set-file-type
403 @findex mac-get-file-type
404 The functions @code{mac-set-file-creator},
405 @code{mac-get-file-creator}, @code{mac-set-file-type}, and
406 @code{mac-get-file-type} can be used to set and get creator and file
407 codes.
408
409 @findex mac-get-preference
410 The function @code{mac-get-preference} returns the preferences value
411 converted to a Lisp object for a specified key and application.
412
413 @ignore
414 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6
415 @end ignore