(Pointer Shape): Node renamed from Pointer Shapes.
[emacs.git] / man / macos.texi
bloba6c1020fbc56d868bd28a6e5e91be3abc8cec0bb
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, Microsoft Windows, Antinews, Top
6 @appendix Emacs and Mac OS
7 @cindex Mac OS
8 @cindex Macintosh
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.
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.
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
40 @node Mac Input
41 @section Keyboard and Mouse Input on Mac
42 @cindex Meta (Mac OS)
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
57 @key{META}.
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.  (Try drag-and-drop if input
71 from the Character Palette does not work.)  Selecting one of the layouts
72 from the keyboard layout pull-down menu will affect how the keys typed
73 on the keyboard are interpreted.
75 @vindex mac-pass-command-to-system
76 @vindex mac-pass-control-to-system
77   Mac OS intercepts and handles certain key combinations (e.g.,
78 @key{command}-@key{SPC} for switching input languages).  These will not
79 be passed to Emacs.  One can disable this interception by setting
80 @code{mac-pass-command-to-system} or @code{mac-pass-control-to-system}
81 to @code{nil}.
83 @vindex mac-emulate-three-button-mouse
84   Especially for one-button mice, the multiple button feature can be
85 emulated by setting @code{mac-emulate-three-button-mouse} to @code{t}
86 or @code{reverse}.  If set to @code{t} (@code{reverse}, respectively),
87 pressing the mouse button with the @key{option} key is recognized as
88 the second (third) button, and that with the @key{command} key is
89 recognized as the third (second) button.
91 @vindex mac-wheel-button-is-mouse-2
92   For multi-button mice, the wheel button and the secondary button are
93 recognized as the second and the third button, respectively.  If
94 @code{mac-wheel-button-is-mouse-2} is set to @code{nil}, their roles
95 are exchanged.
97 @node Mac International
98 @section International Character Set Support on Mac
99 @cindex Mac Roman coding system
100 @cindex clipboard support (Mac OS)
102   Mac uses non-standard encodings for the upper 128 single-byte
103 characters.  They also deviate from the ISO 2022 standard by using
104 character codes in the range 128-159.  The coding systems
105 @code{mac-roman}, @code{mac-centraleurroman}, and @code{mac-cyrillic}
106 are used to represent these Mac encodings.
108   You can use input methods provided either by LEIM (@pxref{Input
109 Methods}) or Mac OS to enter international characters.  To use the
110 former, see the International Character Set Support section of the
111 manual (@pxref{International}).
113   Emacs on Mac OS automatically changes the value of
114 @code{keyboard-coding-system} according to the current keyboard
115 layout.  So users don't need to set it manually, and even if set, it
116 will be changed when the keyboard layout change is detected next time.
118   The Mac clipboard and the Emacs kill ring (@pxref{Killing}) are
119 synchronized by default: you can yank a piece of text and paste it
120 into another Mac application, or cut or copy one in another Mac
121 application and yank it into a Emacs buffer.  This feature can be
122 disabled by setting @code{x-select-enable-clipboard} to @code{nil}.
123 One can still do copy and paste with another application from the Edit
124 menu.
126   On Mac, the role of the coding system for selection that is set by
127 @code{set-selection-coding-system} (@pxref{Communication Coding}) is
128 two-fold.  First, it is used as a preferred coding system for the
129 traditional text flavor that does not specify any particular encodings
130 and is mainly used by applications on Mac OS Classic.  Second, it
131 specifies the intermediate encoding for the UTF-16 text flavor that is
132 mainly used by applications on Mac OS X.
134   When pasting UTF-16 text data from the clipboard, it is first
135 converted to the encoding specified by the selection coding system
136 using the converter in the Mac OS system, and then decoded into the
137 Emacs internal encoding using the converter in Emacs.  If the first
138 conversion failed, then the UTF-16 data is directly converted to Emacs
139 internal encoding using the converter in Emacs.  Copying UTF-16 text
140 to the clipboard goes through the inverse path.  The reason for this
141 two-pass decoding is to avoid subtle differences in Unicode mappings
142 between the Mac OS system and Emacs such as various kinds of hyphens,
143 and to minimize users' customization.  For example, users that mainly
144 use Latin characters would prefer Greek characters to be decoded into
145 the @code{mule-unicode-0100-24ff} charset, but Japanese users would
146 prefer them to be decoded into the @code{japanese-jisx0208} charset.
147 Since the coding system for selection is automatically set according
148 to the system locale setting, users usually don't have to set it
149 manually.
151   The default language environment (@pxref{Language Environments}) is
152 set according to the locale setting at the startup time.  On Mac OS,
153 the locale setting is consulted in the following order:
155 @enumerate
156 @item
157 Environment variables @env{LC_ALL}, @env{LC_CTYPE} and @env{LANG} as
158 in other systems.
160 @item
161 Preference @code{AppleLocale} that is set by default on Mac OS X 10.3
162 and later.
164 @item
165 Preference @code{AppleLanguages} that is set by default on Mac OS X
166 10.1 and later.
168 @item
169 Variable @code{mac-system-locale} that is derived from the system
170 language and region codes.  This variable is available on all
171 supported Mac OS versions including Mac OS Classic.
172 @end enumerate
174   The default values of almost all variables about coding systems are
175 also set according to the language environment.  So usually you don't
176 have to customize these variables manually.
178 @node Mac Environment Variables
179 @section Environment Variables and Command Line Arguments.
180 @cindex environment variables (Mac OS)
182   On Mac OS X, when Emacs is run in a terminal, it inherits the values
183 of environment variables from the shell from which it is invoked.
184 However, when it is run from the Finder as a GUI application, it only
185 inherits environment variable values defined in the file
186 @file{~/.MacOSX/environment.plist} that affects all the applications
187 invoked from the Finder or the @command{open} command.
189   Command line arguments are specified like
191 @example
192 /Applications/Emacs.app/Contents/MacOS/Emacs -g 80x25 &
193 @end example
195 @noindent
196 if Emacs is installed at @file{/Applications/Emacs.app}.  If Emacs is
197 invoked like this, then it also inherits the values of environment
198 variables from the shell from which it is invoked.
200   On Mac OS Classic, environment variables and command line arguments
201 for Emacs can be set by modifying the @samp{STR#} resources 128 and
202 129, respectively.  A common environment variable that one may want to
203 set is @samp{HOME}.
205   The way to set an environment variable is by adding a string of the
206 form
208 @example
209 ENV_VAR=VALUE
210 @end example
212 @noindent
213 to resource @samp{STR#} number 128 using @code{ResEdit}. To set up the
214 program to use unibyte characters exclusively, for example, add the
215 string
217 @example
218 EMACS_UNIBYTE=1
219 @end example
221 @cindex Mac Preferences
222   Although Emacs on Mac does not support X resources (@pxref{X
223 Resources}) directly, one can use the Preferences system in place of X
224 resources.  For example, adding the line
226 @example
227 Emacs.cursorType: bar
228 @end example
230 @noindent
231 to @file{~/.Xresources} in X11 corresponds to the execution of
233 @example
234 defaults write org.gnu.Emacs Emacs.cursorType bar
235 @end example
237 @noindent
238 on Mac OS X.  One can use boolean or numeric values as well as string
239 values as follows:
241 @example
242 defaults write org.gnu.Emacs Emacs.toolBar -bool false
243 defaults write org.gnu.Emacs Emacs.lineSpacing -int 3
244 @end example
246 @noindent
247 Try @kbd{M-x man RET defaults RET} for the usage of the
248 @command{defaults} command.  Alternatively, if you have Developer
249 Tools installed on Mac OS X, you can use Property List Editor to edit
250 the file @file{~/Library/Preferences/org.gnu.Emacs.plist}.
253 @node Mac Directories
254 @section Volumes and Directories on Mac
255 @cindex file names (Mac OS)
257   This node applies to Mac OS Classic only.
259   The directory structure in Mac OS Classic is seen by Emacs as
261 @example
262 /@var{volumename}/@var{filename}
263 @end example
265 So when Emacs requests a file name, doing file name completion on
266 @file{/} will display all volumes on the system.  You can use @file{..}
267 to go up a directory level.
269   On Mac OS Classic, to access files and folders on the desktop, look
270 in the folder @file{Desktop Folder} in your boot volume (this folder
271 is usually invisible in the Mac @code{Finder}).
273   On Mac OS Classic, Emacs creates the Mac folder
274 @file{:Preferences:Emacs:} in the @file{System Folder} and uses it as
275 the temporary directory.  Emacs maps the directory name @file{/tmp/}
276 to that.  Therefore it is best to avoid naming a volume @file{tmp}.
277 If everything works correctly, the program should leave no files in it
278 when it exits.  You should be able to set the environment variable
279 @code{TMPDIR} to use another directory but this folder will still be
280 created.
283 @node Mac Font Specs
284 @section Specifying Fonts on Mac
285 @cindex font names (Mac OS)
287   It is rare that you need to specify a font name in Emacs; usually
288 you specify face attributes instead.  For example, you can use 14pt
289 Courier by customizing the default face attributes for all frames:
291 @lisp
292 (set-face-attribute 'default nil
293                     :family "courier" :height 140)
294 @end lisp
296 @noindent
297 Alternatively, an interactive one is also available
298 (@pxref{Face Customization}).
300 But when you do need to specify a font name in Emacs on Mac, use a
301 standard X font name:
303 @smallexample
304 -@var{maker}-@var{family}-@var{weight}-@var{slant}-@var{widthtype}-@var{style}@dots{}
305 @dots{}-@var{pixels}-@var{height}-@var{horiz}-@var{vert}-@var{spacing}-@var{width}-@var{charset}
306 @end smallexample
308 @noindent
309 @xref{Font X}.  Wildcards are supported as they are on X.
311   Emacs on Mac OS Classic uses QuickDraw Text routines for drawing texts
312 by default.  Emacs on Mac OS X uses @acronym{ATSUI, Apple Type Services
313 for Unicode Imaging} as well as QuickDraw Text, and most of the
314 characters other than Chinese, Japanese, and Korean ones are drawn using
315 the former by default.
317   @acronym{ATSUI}-compatible fonts have maker name @code{apple} and
318 charset @code{iso10646-1}.  For example 12-point Monaco can be specified
319 by the name
320 @samp{-apple-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1}.  Note
321 that it must be specified in a format containing 14 @samp{-}s (i.e., not
322 by @samp{-apple-monaco-medium-r-normal--12-*-iso10646-1}) because every
323 @acronym{ATSUI}-compatible font is a scalable one.
325   QuickDraw Text fonts have maker name @code{apple} and various charset
326 names other than @code{iso10646-1}.  Native Apple fonts in Mac Roman
327 encoding has charset @code{mac-roman}.  You can specify a
328 @code{mac-roman} font for @acronym{ASCII} characters like
330 @smalllisp
331 (add-to-list
332  'default-frame-alist
333  '(font . "-apple-monaco-medium-r-normal--13-*-*-*-*-*-mac-roman"))
334 @end smalllisp
336 @noindent
337 but that does not extend to ISO-8859-1: specifying a @code{mac-roman}
338 font for Latin-1 characters introduces wrong glyphs.
340   Native Apple Traditional Chinese, Simplified Chinese, Japanese,
341 Korean, Central European, Cyrillic, Symbol, and Dingbats fonts have
342 charsets @samp{big5-0}, @samp{gb2312.1980-0},
343 @samp{jisx0208.1983-sjis} and @samp{jisx0201.1976-0},
344 @samp{ksc5601.1989-0}, @samp{mac-centraleurroman},
345 @samp{mac-cyrillic}, @samp{mac-symbol}, and @samp{mac-dingbats},
346 respectively.
348   The use of @code{create-fontset-from-fontset-spec} (@pxref{Defining
349 Fontsets}) for defining fontsets often results in wrong ones especially
350 when using only OS-bundled QuickDraw Text fonts.  The recommended way to
351 use them is to create a fontset using
352 @code{create-fontset-from-mac-roman-font}:
354 @lisp
355 (create-fontset-from-mac-roman-font
356  "-apple-courier-medium-r-normal--13-*-*-*-*-*-mac-roman"
357  nil "foo")
358 @end lisp
360 @noindent
361 and then optionally specifying Chinese, Japanese, or Korean font
362 families using @code{set-fontset-font}:
364 @lisp
365 (set-fontset-font "fontset-foo"
366                   'chinese-gb2312 '("song" . "gb2312.1980-0"))
367 @end lisp
369   Single-byte fonts converted from GNU fonts in BDF format, which are not
370 in the Mac Roman encoding, have foundry, family, and character sets
371 encoded in the names of their font suitcases.  E.g., the font suitcase
372 @samp{ETL-Fixed-ISO8859-1} contains fonts which can be referred to by
373 the name @samp{-ETL-fixed-*-iso8859-1}.
375 @vindex mac-allow-anti-aliasing
376   Mac OS X 10.2 or later can use two types of text renderings: Quartz 2D
377 (aka Core Graphics) and QuickDraw.  By default, Emacs uses the former on
378 such versions.  It can be changed by setting
379 @code{mac-allow-anti-aliasing} to @code{t} (Quartz 2D) or @code{nil}
380 (QuickDraw).  Both @acronym{ATSUI} and QuickDraw Text drawings are
381 affected by the value of this variable.
384 @node Mac Functions
385 @section Mac-Specific Lisp Functions
386 @cindex Lisp functions specific to Mac OS
388 @findex do-applescript
389   The function @code{do-applescript} takes a string argument,
390 executes it as an AppleScript command, and returns the result as a
391 string.
393 @findex mac-file-name-to-posix
394 @findex posix-file-name-to-mac
395   The function @code{mac-file-name-to-posix} takes a Mac file name and
396 returns the GNU or Unix equivalent.  The function
397 @code{posix-file-name-to-mac} performs the opposite conversion.  They
398 are useful for constructing AppleScript commands to be passed to
399 @code{do-applescript}.
401 @findex mac-set-file-creator
402 @findex mac-get-file-creator
403 @findex mac-set-file-type
404 @findex mac-get-file-type
405   The functions @code{mac-set-file-creator},
406 @code{mac-get-file-creator}, @code{mac-set-file-type}, and
407 @code{mac-get-file-type} can be used to set and get creator and file
408 codes.
410 @findex mac-get-preference
411   The function @code{mac-get-preference} returns the preferences value
412 converted to a Lisp object for a specified key and application.
414 @ignore
415    arch-tag: a822c2ab-4273-4997-927e-c153bb71dcf6
416 @end ignore