1 @c This is part of the Emacs manual.
2 @c Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 @c 2005 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
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
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.
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.
41 @section Keyboard and Mouse Input on Mac
43 @cindex keyboard coding (Mac OS)
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
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.
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.
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}
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.
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
96 @node Mac International
97 @section International Character Set Support on Mac
98 @cindex Mac Roman coding system
99 @cindex clipboard support (Mac OS)
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.
107 The fontset @code{fontset-mac} is created automatically when Emacs
108 is run on Mac, and used by default. It displays as many kinds of
109 characters as possible using 12-point Monaco as a base font. If you
110 see some character as a hollow box with this fontset, then it's almost
111 impossible to display it only by customizing font settings (@pxref{Mac
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}).
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.
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
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.
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
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:
163 Environment variables @env{LC_ALL}, @env{LC_CTYPE} and @env{LANG} as
167 Preference @code{AppleLocale} that is set by default on Mac OS X 10.3
171 Preference @code{AppleLanguages} that is set by default on Mac OS X
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.
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.
184 @node Mac Environment Variables
185 @section Environment Variables and Command Line Arguments.
186 @cindex environment variables (Mac OS)
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.
195 Command line arguments are specified like
198 /Applications/Emacs.app/Contents/MacOS/Emacs -geometry 80x25 &
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.
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
211 The way to set an environment variable is by adding a string of the
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
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
233 Emacs.cursorType: bar
237 to @file{~/.Xresources} in X11 corresponds to the execution of
240 defaults write org.gnu.Emacs Emacs.cursorType bar
244 on Mac OS X. One can use boolean or numeric values as well as string
248 defaults write org.gnu.Emacs Emacs.toolBar -bool false
249 defaults write org.gnu.Emacs Emacs.lineSpacing -int 3
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}.
259 @node Mac Directories
260 @section Volumes and Directories on Mac
261 @cindex file names (Mac OS)
263 This node applies to Mac OS Classic only.
265 The directory structure in Mac OS Classic is seen by Emacs as
268 /@var{volumename}/@var{filename}
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.
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}).
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
290 @section Specifying Fonts on Mac
291 @cindex font names (Mac OS)
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:
298 (set-face-attribute 'default nil :family "courier" :height 140)
302 Alternatively, an interactive one is also available
303 (@pxref{Face Customization}).
305 But when you do need to specify a font name in Emacs on Mac, use a
306 standard X font name:
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}
314 @xref{Font X}. Wildcards are supported as they are on X.
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}.
323 You can specify a @code{mac-roman} font for @acronym{ASCII}
329 '(font . "-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman"))
333 but that does not extend to ISO-8859-1: specifying a @code{mac-roman}
334 font for Latin-1 characters introduces wrong glyphs.
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},
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
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}:
356 (create-fontset-from-mac-roman-font
357 "-apple-courier-medium-r-normal--13-*-*-*-*-*-mac-roman"
362 and then optionally specifying Chinese, Japanese, or Korean font
363 families using @code{set-fontset-font}:
366 (set-fontset-font "fontset-foo"
367 'chinese-gb2312 '("song" . "gb2312.1980-0"))
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}.
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.
384 @section Mac-Specific Lisp Functions
385 @cindex Lisp functions specific to Mac OS
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
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}.
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
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.
414 arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6