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