1 ;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: iso-2022-7bit;-*-
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Andrew Choi <akochoi@mac.com>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; Mac-win.el: this file is loaded from ../lisp/startup.el when it recognizes
29 ;; that Mac windows are to be used. Command line switches are parsed and those
30 ;; pertaining to Mac are processed and removed from the command line. The
31 ;; Mac display is opened and hooks are set for popping up the initial window.
33 ;; startup.el will then examine startup files, and eventually call the hooks
34 ;; which create the first window(s).
38 ;; These are the standard X switches from the Xt Initialize.c file of
41 ;; Command line Resource Manager string
44 ;; +synchronous *synchronous
45 ;; -background *background
48 ;; -bordercolor *borderColor
49 ;; -borderwidth .borderWidth
55 ;; -foreground *foreground
56 ;; -geometry .geometry
59 ;; -reverse *reverseVideo
61 ;; -selectionTimeout .selectionTimeout
62 ;; -synchronous *synchronous
65 ;; An alist of X options and the function which handles them. See
68 ;; (if (not (eq window-system 'mac))
69 ;; (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
80 (defvar mac-charset-info-alist
)
81 (defvar mac-service-selection
)
82 (defvar mac-system-script-code
)
83 (defvar mac-apple-event-map
)
84 (defvar mac-font-panel-mode
)
85 (defvar mac-ts-active-input-overlay
)
86 (defvar x-invocation-args
)
87 (declare-function mac-code-convert-string
"mac.c")
88 (declare-function mac-coerce-ae-data
"mac.c")
89 (declare-function mac-resume-apple-event
"macselect.c")
90 ;; Suppress warning when compiling on non-Mac.
91 (declare-function mac-font-panel-mode
"mac-win.el")
92 (declare-function mac-atsu-font-face-attributes
"macfns.c")
93 (declare-function mac-ae-set-reply-parameter
"macselect.c")
94 (declare-function mac-clear-font-name-table
"macfns.c")
96 (defvar x-command-line-resources nil
)
98 ;; Handler for switches of the form "-switch value" or "-switch".
99 (defun x-handle-switch (switch)
100 (let ((aelt (assoc switch command-line-x-option-alist
)))
102 (let ((param (nth 3 aelt
))
103 (value (nth 4 aelt
)))
105 (setq default-frame-alist
106 (cons (cons param value
)
107 default-frame-alist
))
108 (setq default-frame-alist
110 (car x-invocation-args
))
112 x-invocation-args
(cdr x-invocation-args
)))))))
114 ;; Handler for switches of the form "-switch n"
115 (defun x-handle-numeric-switch (switch)
116 (let ((aelt (assoc switch command-line-x-option-alist
)))
118 (let ((param (nth 3 aelt
)))
119 (setq default-frame-alist
121 (string-to-number (car x-invocation-args
)))
124 (cdr x-invocation-args
))))))
126 ;; Handle options that apply to initial frame only
127 (defun x-handle-initial-switch (switch)
128 (let ((aelt (assoc switch command-line-x-option-alist
)))
130 (let ((param (nth 3 aelt
))
131 (value (nth 4 aelt
)))
133 (setq initial-frame-alist
134 (cons (cons param value
)
135 initial-frame-alist
))
136 (setq initial-frame-alist
138 (car x-invocation-args
))
140 x-invocation-args
(cdr x-invocation-args
)))))))
142 ;; Make -iconic apply only to the initial frame!
143 (defun x-handle-iconic (switch)
144 (setq initial-frame-alist
145 (cons '(visibility . icon
) initial-frame-alist
)))
147 ;; Handle the -xrm option.
148 (defun x-handle-xrm-switch (switch)
149 (unless (consp x-invocation-args
)
150 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
151 (setq x-command-line-resources
152 (if (null x-command-line-resources
)
153 (car x-invocation-args
)
154 (concat x-command-line-resources
"\n" (car x-invocation-args
))))
155 (setq x-invocation-args
(cdr x-invocation-args
)))
157 ;; Handle the geometry option
158 (defun x-handle-geometry (switch)
159 (let* ((geo (x-parse-geometry (car x-invocation-args
)))
160 (left (assq 'left geo
))
161 (top (assq 'top geo
))
162 (height (assq 'height geo
))
163 (width (assq 'width geo
)))
164 (if (or height width
)
165 (setq default-frame-alist
166 (append default-frame-alist
168 (if height
(list height
))
169 (if width
(list width
)))
171 (append initial-frame-alist
173 (if height
(list height
))
174 (if width
(list width
)))))
176 (setq initial-frame-alist
177 (append initial-frame-alist
178 '((user-position . t
))
179 (if left
(list left
))
180 (if top
(list top
)))))
181 (setq x-invocation-args
(cdr x-invocation-args
))))
183 ;; Handle the -name option. Set the variable x-resource-name
184 ;; to the option's operand; set the name of
185 ;; the initial frame, too.
186 (defun x-handle-name-switch (switch)
187 (or (consp x-invocation-args
)
188 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
189 (setq x-resource-name
(car x-invocation-args
)
190 x-invocation-args
(cdr x-invocation-args
))
191 (setq initial-frame-alist
(cons (cons 'name x-resource-name
)
192 initial-frame-alist
)))
194 (defvar x-display-name nil
195 "The display name specifying server and frame.")
197 (defun x-handle-display (switch)
198 (setq x-display-name
(car x-invocation-args
)
199 x-invocation-args
(cdr x-invocation-args
)))
201 (defun x-handle-args (args)
202 "Process the X-related command line options in ARGS.
203 This is done before the user's startup file is loaded. They are copied to
204 `x-invocation-args', from which the X-related things are extracted, first
205 the switch (e.g., \"-fg\") in the following code, and possible values
206 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
207 This function returns ARGS minus the arguments that have been processed."
208 ;; We use ARGS to accumulate the args that we don't handle here, to return.
209 (setq x-invocation-args args
211 (while (and x-invocation-args
212 (not (equal (car x-invocation-args
) "--")))
213 (let* ((this-switch (car x-invocation-args
))
214 (orig-this-switch this-switch
)
215 completion argval aelt handler
)
216 (setq x-invocation-args
(cdr x-invocation-args
))
217 ;; Check for long options with attached arguments
218 ;; and separate out the attached option argument into argval.
219 (if (string-match "^--[^=]*=" this-switch
)
220 (setq argval
(substring this-switch
(match-end 0))
221 this-switch
(substring this-switch
0 (1- (match-end 0)))))
222 ;; Complete names of long options.
223 (if (string-match "^--" this-switch
)
225 (setq completion
(try-completion this-switch command-line-x-option-alist
))
226 (if (eq completion t
)
227 ;; Exact match for long option.
229 (if (stringp completion
)
230 (let ((elt (assoc completion command-line-x-option-alist
)))
231 ;; Check for abbreviated long option.
233 (error "Option `%s' is ambiguous" this-switch
))
234 (setq this-switch completion
))))))
235 (setq aelt
(assoc this-switch command-line-x-option-alist
))
236 (if aelt
(setq handler
(nth 2 aelt
)))
239 (let ((x-invocation-args
240 (cons argval x-invocation-args
)))
241 (funcall handler this-switch
))
242 (funcall handler this-switch
))
243 (setq args
(cons orig-this-switch args
)))))
244 (nconc (nreverse args
) x-invocation-args
))
248 ;; Standard Mac cursor shapes
251 (defconst mac-pointer-arrow
0)
252 (defconst mac-pointer-copy-arrow
1)
253 (defconst mac-pointer-alias-arrow
2)
254 (defconst mac-pointer-contextual-menu-arrow
3)
255 (defconst mac-pointer-I-beam
4)
256 (defconst mac-pointer-cross
5)
257 (defconst mac-pointer-plus
6)
258 (defconst mac-pointer-watch
7)
259 (defconst mac-pointer-closed-hand
8)
260 (defconst mac-pointer-open-hand
9)
261 (defconst mac-pointer-pointing-hand
10)
262 (defconst mac-pointer-counting-up-hand
11)
263 (defconst mac-pointer-counting-down-hand
12)
264 (defconst mac-pointer-counting-up-and-down-hand
13)
265 (defconst mac-pointer-spinning
14)
266 (defconst mac-pointer-resize-left
15)
267 (defconst mac-pointer-resize-right
16)
268 (defconst mac-pointer-resize-left-right
17)
269 ;; Mac OS X 10.2 and later
270 (defconst mac-pointer-not-allowed
18)
271 ;; Mac OS X 10.3 and later
272 (defconst mac-pointer-resize-up
19)
273 (defconst mac-pointer-resize-down
20)
274 (defconst mac-pointer-resize-up-down
21)
275 (defconst mac-pointer-poof
22)
278 ;; Standard X cursor shapes that have Mac counterparts
281 (defconst x-pointer-left-ptr mac-pointer-arrow
)
282 (defconst x-pointer-xterm mac-pointer-I-beam
)
283 (defconst x-pointer-crosshair mac-pointer-cross
)
284 (defconst x-pointer-plus mac-pointer-plus
)
285 (defconst x-pointer-watch mac-pointer-watch
)
286 (defconst x-pointer-hand2 mac-pointer-pointing-hand
)
287 (defconst x-pointer-left-side mac-pointer-resize-left
)
288 (defconst x-pointer-right-side mac-pointer-resize-right
)
289 (defconst x-pointer-sb-h-double-arrow mac-pointer-resize-left-right
)
290 (defconst x-pointer-top-side mac-pointer-resize-up
)
291 (defconst x-pointer-bottom-side mac-pointer-resize-down
)
292 (defconst x-pointer-sb-v-double-arrow mac-pointer-resize-up-down
)
299 (defvar x-colors
'("LightGreen"
898 "LightGoldenrodYellow"
899 "light goldenrod yellow"
916 "medium spring green"
1051 "The list of X colors from the `rgb.txt' file.
1052 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1054 (defun xw-defined-colors (&optional frame
)
1055 "Internal function called by `defined-colors', which see."
1056 (or frame
(setq frame
(selected-frame)))
1057 (let ((all-colors x-colors
)
1059 (defined-colors nil
))
1061 (setq this-color
(car all-colors
)
1062 all-colors
(cdr all-colors
))
1063 (and (color-supported-p this-color frame t
)
1064 (setq defined-colors
(cons this-color defined-colors
))))
1069 (defun x-setup-function-keys (frame)
1070 "Setup Function Keys for mac."
1071 ;; Don't do this twice on the same display, or it would break
1072 ;; normal-erase-is-backspace-mode.
1073 (unless (terminal-parameter frame
'x-setup-function-keys
)
1074 (with-selected-frame frame
1075 ;; Map certain keypad keys into ASCII characters
1076 ;; that people usually expect.
1077 (define-key local-function-key-map
[backspace] [?\d])
1078 (define-key local-function-key-map [delete] [?\d])
1079 (define-key local-function-key-map [tab] [?\t])
1080 (define-key local-function-key-map [linefeed] [?\n])
1081 (define-key local-function-key-map [clear] [?\C-l])
1082 (define-key local-function-key-map [return] [?\C-m])
1083 (define-key local-function-key-map [escape] [?\e])
1084 (define-key local-function-key-map [M-backspace] [?\M-\d])
1085 (define-key local-function-key-map [M-delete] [?\M-\d])
1086 (define-key local-function-key-map [M-tab] [?\M-\t])
1087 (define-key local-function-key-map [M-linefeed] [?\M-\n])
1088 (define-key local-function-key-map [M-clear] [?\M-\C-l])
1089 (define-key local-function-key-map [M-return] [?\M-\C-m])
1090 (define-key local-function-key-map [M-escape] [?\M-\e])
1091 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1092 local-function-key-map global-map))
1093 (set-terminal-parameter frame 'x-setup-function-keys t)))
1095 ;; These tell read-char how to convert
1096 ;; these special chars to ASCII.
1097 (put 'backspace 'ascii-character ?\d)
1098 (put 'delete 'ascii-character ?\d)
1099 (put 'tab 'ascii-character ?\t)
1100 (put 'linefeed 'ascii-character ?\n)
1101 (put 'clear 'ascii-character ?\C-l)
1102 (put 'return 'ascii-character ?\C-m)
1103 (put 'escape 'ascii-character ?\e)
1105 ;; Modifier name `ctrl' is an alias of `control'.
1106 (put 'ctrl 'modifier-value (get 'control 'modifier-value))
1109 ;;;; Script codes and coding systems
1110 (defconst mac-script-code-coding-systems
1111 '((0 . mac-roman) ; smRoman
1112 (1 . japanese-shift-jis) ; smJapanese
1113 (2 . chinese-big5) ; smTradChinese
1114 (3 . korean-iso-8bit) ; smKorean
1115 (7 . mac-cyrillic) ; smCyrillic
1116 (25 . chinese-iso-8bit) ; smSimpChinese
1117 (29 . mac-centraleurroman) ; smCentralEuroRoman
1119 "Alist of Mac script codes vs Emacs coding systems.")
1121 (defun mac-add-charset-info (xlfd-charset mac-text-encoding)
1122 "Add a character set to display with Mac fonts.
1123 Create an entry in `mac-charset-info-alist'.
1124 XLFD-CHARSET is a string which will appear in the XLFD font name
1125 to identify the character set. MAC-TEXT-ENCODING is the
1126 correspoinding TextEncodingBase value."
1127 (add-to-list 'mac-charset-info-alist
1128 (list xlfd-charset mac-text-encoding
1129 (cdr (assq mac-text-encoding
1130 mac-script-code-coding-systems)))))
1132 (setq mac-charset-info-alist nil)
1133 (mac-add-charset-info "mac-roman" 0)
1134 (mac-add-charset-info "jisx0208.1983-sjis" 1)
1135 (mac-add-charset-info "jisx0201.1976-0" 1)
1136 (mac-add-charset-info "big5-0" 2)
1137 (mac-add-charset-info "ksc5601.1989-0" 3)
1138 (mac-add-charset-info "mac-cyrillic" 7)
1139 (mac-add-charset-info "gb2312.1980-0" 25)
1140 (mac-add-charset-info "mac-centraleurroman" 29)
1141 (mac-add-charset-info "mac-symbol" 33)
1142 (mac-add-charset-info "adobe-fontspecific" 33) ; for X-Symbol
1143 (mac-add-charset-info "mac-dingbats" 34)
1144 (mac-add-charset-info "iso10646-1" 126) ; for ATSUI
1146 (cp-make-coding-system
1148 [?\\e,AD\e(B ?\\e$,1 \e(B ?\\e$,1 !\e(B ?\\e,AI\e(B ?\\e$,1 $\e(B ?\\e,AV\e(B ?\\e,A\\e(B ?\\e,Aa\e(B ?\\e$,1 %\e(B ?\\e$,1 ,\e(B ?\\e,Ad\e(B ?\\e$,1 -\e(B ?\\e$,1 &\e(B ?\\e$,1 '\e(B ?\\e,Ai\e(B ?\\e$,1!9\e(B
1149 ?\\e$,1!:\e(B ?\\e$,1 .\e(B ?\\e,Am\e(B ?\\e$,1 /\e(B ?\\e$,1 2\e(B ?\\e$,1 3\e(B ?\\e$,1 6\e(B ?\\e,As\e(B ?\\e$,1 7\e(B ?\\e,At\e(B ?\\e,Av\e(B ?\\e,Au\e(B ?\\e,Az\e(B ?\\e$,1 :\e(B ?\\e$,1 ;\e(B ?\\e,A|\e(B
1150 ?\\e$,1s \e(B ?\\e,A0\e(B ?\\e$,1 8\e(B ?\\e,A#\e(B ?\\e,A'\e(B ?\\e$,1s"\e(B ?\\e,A6\e(B ?\\e,A_\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1 9\e(B ?\\e,A(\e(B ?\\e$,1y \e(B ?\\e$,1 C\e(B ?\\e$,1 N\e(B
1151 ?\\e$,1 O\e(B ?\\e$,1 J\e(B ?\\e$,1y$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e$,1 a\e(B ?\\e$,1!<\e(B ?\\e$,1 B\e(B ?\\e$,1$g\e(B]
1156 "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman).")
1157 (coding-system-put 'mac-centraleurroman 'mime-charset 'x-mac-centraleurroman)
1159 (cp-make-coding-system
1161 [?\\e$,1(0\e(B ?\\e$,1(1\e(B ?\\e$,1(2\e(B ?\\e$,1(3\e(B ?\\e$,1(4\e(B ?\\e$,1(5\e(B ?\\e$,1(6\e(B ?\\e$,1(7\e(B ?\\e$,1(8\e(B ?\\e$,1(9\e(B ?\\e$,1(:\e(B ?\\e$,1(;\e(B ?\\e$,1(<\e(B ?\\e$,1(=\e(B ?\\e$,1(>\e(B ?\\e$,1(?\e(B
1162 ?\\e$,1(@\e(B ?\\e$,1(A\e(B ?\\e$,1(B\e(B ?\\e$,1(C\e(B ?\\e$,1(D\e(B ?\\e$,1(E\e(B ?\\e$,1(F\e(B ?\\e$,1(G\e(B ?\\e$,1(H\e(B ?\\e$,1(I\e(B ?\\e$,1(J\e(B ?\\e$,1(K\e(B ?\\e$,1(L\e(B ?\\e$,1(M\e(B ?\\e$,1(N\e(B ?\\e$,1(O\e(B
1163 ?\\e$,1s \e(B ?\\e,A0\e(B ?\\e$,1)P\e(B ?\\e,A#\e(B ?\\e,A'\e(B ?\\e$,1s"\e(B ?\\e,A6\e(B ?\\e$,1(&\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1("\e(B ?\\e$,1(r\e(B ?\\e$,1y \e(B ?\\e$,1(#\e(B ?\\e$,1(s\e(B
1164 ?\\e$,1x>\e(B ?\\e,A1\e(B ?\\e$,1y$\e(B ?\\e$,1y%\e(B ?\\e$,1(v\e(B ?\\e,A5\e(B ?\\e$,1)Q\e(B ?\\e$,1((\e(B ?\\e$,1($\e(B ?\\e$,1(t\e(B ?\\e$,1('\e(B ?\\e$,1(w\e(B ?\\e$,1()\e(B ?\\e$,1(y\e(B ?\\e$,1(*\e(B ?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{ ?\| ?\} ?\\e$,1x\\e(B]
1183 (make-vector (- 160 127) nil)
1184 ;; mac-symbol (160..254) -> emacs-mule mapping
1185 ;; Mapping of the following characters are changed from the
1187 ;; 0xE2 0x00AE+0xF87F -> 0x00AE # REGISTERED SIGN, alternate: sans serif
1188 ;; 0xE3 0x00A9+0xF87F -> 0x00A9 # COPYRIGHT SIGN, alternate: sans serif
1189 ;; 0xE4 0x2122+0xF87F -> 0x2122 # TRADE MARK SIGN, alternate: sans serif
1190 [?\\e$,1tL\e(B ?\\e$,1'R\e(B ?\\e$,1s2\e(B ?\\e$,1y$\e(B ?\\e$,1sD\e(B ?\\e$,1x>\e(B ?\\e$,1!R\e(B ?\\e$,2#c\e(B ?\\e$,2#f\e(B ?\\e$,2#e\e(B ?\\e$,2#`\e(B ?\\e$,1vt\e(B ?\\e$,1vp\e(B ?\\e$,1vq\e(B ?\\e$,1vr\e(B ?\\e$,1vs\e(B
1191 ?\\e,A0\e(B ?\\e,A1\e(B ?\\e$,1s3\e(B ?\\e$,1y%\e(B ?\\e,AW\e(B ?\\e$,1x=\e(B ?\\e$,1x"\e(B ?\\e$,1s"\e(B ?\\e,Aw\e(B ?\\e$,1y \e(B ?\\e$,1y!\e(B ?\\e$,1xh\e(B ?\\e$,1s&\e(B ?\\e$,1|p\e(B ?\\e$,1|O\e(B ?\\e$,1w5\e(B
1192 ?\\e$,1uu\e(B ?\\e$,1uQ\e(B ?\\e$,1u\\e(B ?\\e$,1uX\e(B ?\\e$,1yW\e(B ?\\e$,1yU\e(B ?\\e$,1x%\e(B ?\\e$,1xI\e(B ?\\e$,1xJ\e(B ?\\e$,1yC\e(B ?\\e$,1yG\e(B ?\\e$,1yD\e(B ?\\e$,1yB\e(B ?\\e$,1yF\e(B ?\\e$,1x(\e(B ?\\e$,1x)\e(B
1193 ?\\e$,1x@\e(B ?\\e$,1x'\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1x/\e(B ?\\e$,1x:\e(B ?\\e$,1z%\e(B ?\\e,A,\e(B ?\\e$,1xG\e(B ?\\e$,1xH\e(B ?\\e$,1wT\e(B ?\\e$,1wP\e(B ?\\e$,1wQ\e(B ?\\e$,1wR\e(B ?\\e$,1wS\e(B
1194 ?\\e$,2"*\e(B ?\\e$,2=H\e(B ?\\e,A.\e(B ?\\e,A)\e(B ?\\e$,1ub\e(B ?\\e$,1x1\e(B ?\\e$,1|;\e(B ?\\e$,1|<\e(B ?\\e$,1|=\e(B ?\\e$,1|A\e(B ?\\e$,1|B\e(B ?\\e$,1|C\e(B ?\\e$,1|G\e(B ?\\e$,1|H\e(B ?\\e$,1|I\e(B ?\\e$,1|J\e(B
1195 ?\\e$,3b_\e(B ?\\e$,2=I\e(B ?\\e$,1xK\e(B ?\\e$,1{ \e(B ?\\e$,1|N\e(B ?\\e$,1{!\e(B ?\\e$,1|>\e(B ?\\e$,1|?\e(B ?\\e$,1|@\e(B ?\\e$,1|D\e(B ?\\e$,1|E\e(B ?\\e$,1|F\e(B ?\\e$,1|K\e(B ?\\e$,1|L\e(B ?\\e$,1|M\e(B
1198 (setq translation-table
1199 (make-translation-table-from-vector encoding-vector))
1200 ;; (define-translation-table 'mac-symbol-decoder translation-table)
1201 (define-translation-table 'mac-symbol-encoder
1202 (char-table-extra-slot translation-table 0)))
1207 (make-vector 32 nil)
1208 ;; mac-dingbats (32..126) -> emacs-mule mapping
1209 [?\ ?\\e$,2%A\e(B ?\\e$,2%B\e(B ?\\e$,2%C\e(B ?\\e$,2%D\e(B ?\\e$,2"n\e(B ?\\e$,2%F\e(B ?\\e$,2%G\e(B ?\\e$,2%H\e(B ?\\e$,2%I\e(B ?\\e$,2"{\e(B ?\\e$,2"~\e(B ?\\e$,2%L\e(B ?\\e$,2%M\e(B ?\\e$,2%N\e(B ?\\e$,2%O\e(B
1210 ?\\e$,2%P\e(B ?\\e$,2%Q\e(B ?\\e$,2%R\e(B ?\\e$,2%S\e(B ?\\e$,2%T\e(B ?\\e$,2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\\e$,2&s\e(B ?\\e$,2&t\e(B ?\\e$,1vr\e(B ?\\e$,1vt\e(B ?\\e$,1vu\e(B ?\\e$,2&x\e(B ?\\e$,2&y\e(B ?\\e$,2&z\e(B ?\\e$,2&{\e(B ?\\e$,2&|\e(B ?\\e$,2&}\e(B ?\\e$,2&~\e(B ?\\e$,2&\7f\e(B
1224 ?\\e$,2' \e(B ?\\e$,2'!\e(B ?\\e$,2'"\e(B ?\\e$,2'#\e(B ?\\e$,2'$\e(B ?\\e$,2'%\e(B ?\\e$,2'&\e(B ?\\e$,2''\e(B ?\\e$,2'(\e(B ?\\e$,2')\e(B ?\\e$,2'*\e(B ?\\e$,2'+\e(B ?\\e$,2',\e(B ?\\e$,2'-\e(B ?\\e$,2'.\e(B ?\\e$,2'/\e(B
1226 ;; mac-dingbats (241..254) -> emacs-mule mapping
1227 ?\\e$,2'1\e(B ?\\e$,2'2\e(B ?\\e$,2'3\e(B ?\\e$,2'4\e(B ?\\e$,2'5\e(B ?\\e$,2'6\e(B ?\\e$,2'7\e(B ?\\e$,2'8\e(B ?\\e$,2'9\e(B ?\\e$,2':\e(B ?\\e$,2';\e(B ?\\e$,2'<\e(B ?\\e$,2'=\e(B ?\\e$,2'>\e(B
1230 (setq translation-table
1231 (make-translation-table-from-vector encoding-vector))
1232 ;; (define-translation-table 'mac-dingbats-decoder translation-table)
1233 (define-translation-table 'mac-dingbats-encoder
1234 (char-table-extra-slot translation-table 0)))
1236 (defconst mac-system-coding-system
1237 (let ((base (or (cdr (assq mac-system-script-code
1238 mac-script-code-coding-systems))
1240 (if (eq system-type 'darwin)
1242 (coding-system-change-eol-conversion base 'mac)))
1243 "Coding system derived from the system script code.")
1245 (set-selection-coding-system mac-system-coding-system)
1248 ;;;; Keyboard layout/language change events
1249 (defun mac-handle-language-change (event)
1250 "Set keyboard coding system to what is specified in EVENT."
1252 (let ((coding-system
1253 (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
1254 (set-keyboard-coding-system (or coding-system 'mac-roman))
1255 ;; MacJapanese maps reverse solidus to ?\x80.
1256 (if (eq coding-system 'japanese-shift-jis)
1257 (define-key key-translation-map [?\x80] "\\"))))
1259 (define-key special-event-map [language-change] 'mac-handle-language-change)
1262 ;;;; Conversion between common flavors and Lisp string.
1264 (defconst mac-text-encoding-ascii #x600
1265 "ASCII text encoding.")
1267 (defconst mac-text-encoding-mac-japanese-basic-variant #x20001
1268 "MacJapanese text encoding without Apple double-byte extensions.")
1270 (defun mac-utxt-to-string (data &optional coding-system)
1271 (or coding-system (setq coding-system mac-system-coding-system))
1273 (and (eq system-type 'darwin)
1274 (eq (coding-system-base coding-system) 'japanese-shift-jis)
1275 mac-text-encoding-mac-japanese-basic-variant))
1276 (str (and (fboundp 'mac-code-convert-string)
1277 (mac-code-convert-string data nil
1278 (or encoding coding-system)))))
1280 (setq str (decode-coding-string str coding-system))
1281 (if (eq encoding mac-text-encoding-mac-japanese-basic-variant)
1282 ;; Does it contain Apple one-byte extensions other than
1284 (if (string-match "[\xa0\xfd-\xff]" str)
1287 (unless (mac-code-convert-string data nil mac-text-encoding-ascii)
1288 (subst-char-in-string ?\x5c ?\\e(J\\e(B str t)
1289 (subst-char-in-string ?\x80 ?\\ str t)))))
1291 (decode-coding-string data
1292 (if (eq (byteorder) ?B) 'utf-16be 'utf-16le)))))
1294 (defun mac-string-to-utxt (string &optional coding-system)
1295 (or coding-system (setq coding-system mac-system-coding-system))
1296 (let (data encoding)
1297 (when (and (fboundp 'mac-code-convert-string)
1298 (memq (coding-system-base coding-system)
1299 (find-coding-systems-string string)))
1301 (coding-system-change-eol-conversion coding-system 'mac))
1303 (when (and (eq system-type 'darwin)
1304 (eq coding-system 'japanese-shift-jis-mac))
1305 (setq encoding mac-text-encoding-mac-japanese-basic-variant)
1306 (setq str (subst-char-in-string ?\\ ?\x80 str))
1307 (subst-char-in-string ?\\e(J\\e(B ?\x5c str t)
1309 (if (string-match "\\`[\x00-\x7f]*\\'" str)
1312 (setq data (mac-code-convert-string
1313 (encode-coding-string str coding-system)
1314 (or encoding coding-system) nil)))))
1315 (or data (encode-coding-string string (if (eq (byteorder) ?B)
1319 (defun mac-TEXT-to-string (data &optional coding-system)
1320 (or coding-system (setq coding-system mac-system-coding-system))
1321 (prog1 (setq data (decode-coding-string data coding-system))
1322 (when (eq (coding-system-base coding-system) 'japanese-shift-jis)
1323 ;; (subst-char-in-string ?\x5c ?\\e(J\\e(B data t)
1324 (subst-char-in-string ?\x80 ?\\ data t))))
1326 (defun mac-string-to-TEXT (string &optional coding-system)
1327 (or coding-system (setq coding-system mac-system-coding-system))
1328 (let ((encodables (find-coding-systems-string string))
1329 (rest mac-script-code-coding-systems))
1330 (unless (memq (coding-system-base coding-system) encodables)
1331 (while (and rest (not (memq (cdar rest) encodables)))
1332 (setq rest (cdr rest)))
1334 (setq coding-system (cdar rest)))))
1336 (coding-system-change-eol-conversion coding-system 'mac))
1337 (when (eq coding-system 'japanese-shift-jis-mac)
1338 ;; (setq string (subst-char-in-string ?\\ ?\x80 string))
1339 (setq string (subst-char-in-string ?\\e(J\\e(B ?\x5c string)))
1340 (encode-coding-string string coding-system))
1342 (defun mac-furl-to-string (data)
1343 ;; Remove a trailing nul character.
1344 (let ((len (length data)))
1345 (if (and (> len 0) (= (aref data (1- len)) ?\0))
1346 (substring data 0 (1- len))
1349 (defun mac-TIFF-to-string (data &optional text)
1350 (prog1 (or text (setq text (copy-sequence " ")))
1351 (put-text-property 0 (length text) 'display (create-image data 'tiff t)
1356 ;;; We keep track of the last text selected here, so we can check the
1357 ;;; current selection against it, and avoid passing back our own text
1358 ;;; from x-get-selection-value.
1359 (defvar x-last-selected-text-clipboard nil
1360 "The value of the CLIPBOARD selection last time we selected or
1362 (defvar x-last-selected-text-primary nil
1363 "The value of the PRIMARY X selection last time we selected or
1366 (defcustom x-select-enable-clipboard t
1367 "*Non-nil means cutting and pasting uses the clipboard.
1368 This is in addition to the primary selection."
1372 ;;; Make TEXT, a string, the primary X selection.
1373 (defun x-select-text (text &optional push)
1374 (x-set-selection 'PRIMARY text)
1375 (setq x-last-selected-text-primary text)
1376 (if (not x-select-enable-clipboard)
1377 (setq x-last-selected-text-clipboard nil)
1378 (x-set-selection 'CLIPBOARD text)
1379 (setq x-last-selected-text-clipboard text))
1382 (defun x-get-selection (&optional type data-type)
1383 "Return the value of a selection.
1384 The argument TYPE (default `PRIMARY') says which selection,
1385 and the argument DATA-TYPE (default `STRING') says
1386 how to convert the data.
1388 TYPE may be any symbol \(but nil stands for `PRIMARY'). However,
1389 only a few symbols are commonly used. They conventionally have
1390 all upper-case names. The most often used ones, in addition to
1391 `PRIMARY', are `SECONDARY' and `CLIPBOARD'.
1393 DATA-TYPE is usually `STRING', but can also be one of the symbols
1394 in `selection-converter-alist', which see."
1395 (let ((data (x-get-selection-internal (or type 'PRIMARY)
1396 (or data-type 'STRING)))
1397 (coding (or next-selection-coding-system
1398 selection-coding-system)))
1399 (when (and (stringp data)
1400 (setq data-type (get-text-property 0 'foreign-selection data)))
1401 (cond ((eq data-type 'public.utf16-plain-text)
1402 (setq data (mac-utxt-to-string data coding)))
1403 ((eq data-type 'com.apple.traditional-mac-plain-text)
1404 (setq data (mac-TEXT-to-string data coding)))
1405 ((eq data-type 'public.file-url)
1406 (setq data (mac-furl-to-string data))))
1407 (put-text-property 0 (length data) 'foreign-selection data-type data))
1410 (defun x-selection-value (type)
1411 (let ((data-types '(public.utf16-plain-text
1412 com.apple.traditional-mac-plain-text
1415 (while (and (null text) data-types)
1416 (setq text (condition-case nil
1417 (x-get-selection type (car data-types))
1419 (setq data-types (cdr data-types)))
1421 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
1422 (setq tiff-image (condition-case nil
1423 (x-get-selection type 'public.tiff)
1426 (remove-text-properties 0 (length tiff-image)
1427 '(foreign-selection nil) tiff-image)
1428 (setq text (mac-TIFF-to-string tiff-image text)))
1431 ;;; Return the value of the current selection.
1432 ;;; Treat empty strings as if they were unset.
1433 ;;; If this function is called twice and finds the same text,
1434 ;;; it returns nil the second time. This is so that a single
1435 ;;; selection won't be added to the kill ring over and over.
1436 (defun x-get-selection-value ()
1437 (let (clip-text primary-text)
1438 (if (not x-select-enable-clipboard)
1439 (setq x-last-selected-text-clipboard nil)
1440 (setq clip-text (x-selection-value 'CLIPBOARD))
1441 (if (string= clip-text "") (setq clip-text nil))
1443 ;; Check the CLIPBOARD selection for 'newness', is it different
1444 ;; from what we remebered them to be last time we did a
1445 ;; cut/paste operation.
1447 (cond;; check clipboard
1448 ((or (not clip-text) (string= clip-text ""))
1449 (setq x-last-selected-text-clipboard nil))
1450 ((eq clip-text x-last-selected-text-clipboard) nil)
1451 ((string= clip-text x-last-selected-text-clipboard)
1452 ;; Record the newer string,
1453 ;; so subsequent calls can use the `eq' test.
1454 (setq x-last-selected-text-clipboard clip-text)
1457 (setq x-last-selected-text-clipboard clip-text))))
1460 (setq primary-text (x-selection-value 'PRIMARY))
1461 ;; Check the PRIMARY selection for 'newness', is it different
1462 ;; from what we remebered them to be last time we did a
1463 ;; cut/paste operation.
1465 (cond;; check primary selection
1466 ((or (not primary-text) (string= primary-text ""))
1467 (setq x-last-selected-text-primary nil))
1468 ((eq primary-text x-last-selected-text-primary) nil)
1469 ((string= primary-text x-last-selected-text-primary)
1470 ;; Record the newer string,
1471 ;; so subsequent calls can use the `eq' test.
1472 (setq x-last-selected-text-primary primary-text)
1475 (setq x-last-selected-text-primary primary-text))))
1477 ;; As we have done one selection, clear this now.
1478 (setq next-selection-coding-system nil)
1480 ;; At this point we have recorded the current values for the
1481 ;; selection from clipboard (if we are supposed to) and primary,
1482 ;; So return the first one that has changed (which is the first
1484 (or clip-text primary-text)
1487 (put 'CLIPBOARD 'mac-scrap-name "com.apple.scrap.clipboard")
1488 (when (eq system-type 'darwin)
1489 (put 'FIND 'mac-scrap-name "com.apple.scrap.find")
1490 (put 'PRIMARY 'mac-scrap-name
1491 (format "org.gnu.Emacs.%d.selection.PRIMARY" (emacs-pid))))
1492 (put 'com.apple.traditional-mac-plain-text 'mac-ostype "TEXT")
1493 (put 'public.utf16-plain-text 'mac-ostype "utxt")
1494 (put 'public.tiff 'mac-ostype "TIFF")
1495 (put 'public.file-url 'mac-ostype "furl")
1497 (defun mac-select-convert-to-string (selection type value)
1498 (let ((str (cdr (xselect-convert-to-string selection nil value)))
1499 (coding (or next-selection-coding-system selection-coding-system)))
1501 ;; If TYPE is nil, this is a local request, thus return STR as
1502 ;; is. Otherwise, encode STR.
1505 (let ((inhibit-read-only t))
1506 (remove-text-properties 0 (length str) '(composition nil) str)
1508 ((eq type 'public.utf16-plain-text)
1509 (setq str (mac-string-to-utxt str coding)))
1510 ((eq type 'com.apple.traditional-mac-plain-text)
1511 (setq str (mac-string-to-TEXT str coding)))
1513 (error "Unknown selection type: %S" type))
1516 (setq next-selection-coding-system nil)
1519 (defun mac-select-convert-to-file-url (selection type value)
1520 (let ((filename (xselect-convert-to-filename selection type value))
1521 (coding (or file-name-coding-system default-file-name-coding-system)))
1522 (if (and filename coding)
1523 (setq filename (encode-coding-string filename coding)))
1525 (concat "file://localhost"
1526 (mapconcat 'url-hexify-string
1527 (split-string filename "/") "/")))))
1529 (setq selection-converter-alist
1531 '((public.utf16-plain-text . mac-select-convert-to-string)
1532 (com.apple.traditional-mac-plain-text . mac-select-convert-to-string)
1533 ;; This is not enabled by default because the `Import Image'
1534 ;; menu makes Emacs crash or hang for unknown reasons.
1535 ;; (public.tiff . nil)
1536 (public.file-url . mac-select-convert-to-file-url)
1538 selection-converter-alist))
1540 ;;;; Apple events, HICommand events, and Services menu
1543 (put 'core-event 'mac-apple-event-class "aevt") ; kCoreEventClass
1544 (put 'internet-event 'mac-apple-event-class "GURL") ; kAEInternetEventClass
1548 (put 'open-application 'mac-apple-event-id "oapp") ; kAEOpenApplication
1549 (put 'reopen-application 'mac-apple-event-id "rapp") ; kAEReopenApplication
1550 (put 'open-documents 'mac-apple-event-id "odoc") ; kAEOpenDocuments
1551 (put 'print-documents 'mac-apple-event-id "pdoc") ; kAEPrintDocuments
1552 (put 'open-contents 'mac-apple-event-id "ocon") ; kAEOpenContents
1553 (put 'quit-application 'mac-apple-event-id "quit") ; kAEQuitApplication
1554 (put 'application-died 'mac-apple-event-id "obit") ; kAEApplicationDied
1555 (put 'show-preferences 'mac-apple-event-id "pref") ; kAEShowPreferences
1556 (put 'autosave-now 'mac-apple-event-id "asav") ; kAEAutosaveNow
1557 ;; kAEInternetEventClass
1558 (put 'get-url 'mac-apple-event-id "GURL") ; kAEGetURL
1559 ;; Converted HI command events
1560 (put 'about 'mac-apple-event-id "abou") ; kHICommandAbout
1561 (put 'show-hide-font-panel 'mac-apple-event-id "shfp") ; kHICommandShowHideFontPanel
1563 (defmacro mac-event-spec (event)
1566 (defmacro mac-event-ae (event)
1569 (defun mac-ae-parameter (ae &optional keyword type)
1570 (or keyword (setq keyword "----")) ;; Direct object.
1571 (if (not (and (consp ae) (equal (car ae) "aevt")))
1572 (error "Not an Apple event: %S" ae)
1573 (let ((type-data (cdr (assoc keyword (cdr ae))))
1575 (when (and type type-data (not (equal type (car type-data))))
1576 (setq data (mac-coerce-ae-data (car type-data) (cdr type-data) type))
1577 (setq type-data (if data (cons type data) nil)))
1580 (defun mac-ae-list (ae &optional keyword type)
1581 (or keyword (setq keyword "----")) ;; Direct object.
1582 (let ((desc (mac-ae-parameter ae keyword "list")))
1585 ((not (equal (car desc) "list"))
1586 (error "Parameter for \"%s\" is not a list" keyword))
1592 (mac-coerce-ae-data (car type-data) (cdr type-data) type))
1595 (defun mac-ae-number (ae keyword)
1596 (let ((type-data (mac-ae-parameter ae keyword))
1599 (setq str (mac-coerce-ae-data (car type-data)
1600 (cdr type-data) "TEXT")))
1601 (let ((num (string-to-number str)))
1602 ;; Mac OS Classic may return "0e+0" as the coerced value for
1603 ;; the type "magn" and the data "\000\000\000\000".
1604 (if (= num 0.0) 0 num))
1607 (defun mac-bytes-to-integer (bytes &optional from to)
1608 (or from (setq from 0))
1609 (or to (setq to (length bytes)))
1610 (let* ((len (- to from))
1611 (extended-sign-len (- (1+ (ceiling (log most-positive-fixnum 2)))
1615 (setq result (logior (lsh result 8)
1616 (aref bytes (+ from (if (eq (byteorder) ?B) i
1618 (if (> extended-sign-len 0)
1619 (ash (lsh result extended-sign-len) (- extended-sign-len))
1622 (defun mac-ae-selection-range (ae)
1623 ;; #pragma options align=mac68k
1624 ;; typedef struct SelectionRange {
1625 ;; short unused1; // 0 (not used)
1626 ;; short lineNum; // line to select (<0 to specify range)
1627 ;; long startRange; // start of selection range (if line < 0)
1628 ;; long endRange; // end of selection range (if line < 0)
1629 ;; long unused2; // 0 (not used)
1630 ;; long theDate; // modification date/time
1631 ;; } SelectionRange;
1632 ;; #pragma options align=reset
1633 (let ((range-bytes (cdr (mac-ae-parameter ae "kpos" "TEXT"))))
1635 (list (mac-bytes-to-integer range-bytes 2 4)
1636 (mac-bytes-to-integer range-bytes 4 8)
1637 (mac-bytes-to-integer range-bytes 8 12)
1638 (mac-bytes-to-integer range-bytes 16 20)))))
1640 ;; On Mac OS X 10.4 and later, the `open-document' event contains an
1641 ;; optional parameter keyAESearchText from the Spotlight search.
1642 (defun mac-ae-text-for-search (ae)
1643 (let ((utf8-text (cdr (mac-ae-parameter ae "stxt" "utf8"))))
1645 (decode-coding-string utf8-text 'utf-8))))
1647 (defun mac-ae-text (ae)
1648 (or (cdr (mac-ae-parameter ae nil "TEXT"))
1649 (error "No text in Apple event.")))
1651 (defun mac-ae-frame (ae &optional keyword type)
1652 (let ((bytes (cdr (mac-ae-parameter ae keyword type))))
1653 (if (or (null bytes) (/= (length bytes) 4))
1654 (error "No window reference in Apple event.")
1655 (let ((window-id (mac-coerce-ae-data "long" bytes "TEXT"))
1658 (while (and (null frame) rest)
1659 (if (string= (frame-parameter (car rest) 'window-id) window-id)
1660 (setq frame (car rest)))
1661 (setq rest (cdr rest)))
1664 (defun mac-ae-script-language (ae keyword)
1665 ;; struct WritingCode {
1666 ;; ScriptCode theScriptCode;
1667 ;; LangCode theLangCode;
1669 (let ((bytes (cdr (mac-ae-parameter ae keyword "intl"))))
1671 (cons (mac-bytes-to-integer bytes 0 2)
1672 (mac-bytes-to-integer bytes 2 4)))))
1674 (defun mac-bytes-to-text-range (bytes &optional from to)
1675 ;; struct TextRange {
1678 ;; short fHiliteStyle;
1680 (or from (setq from 0))
1681 (or to (setq to (length bytes)))
1682 (and (= (- to from) (+ 4 4 2))
1683 (list (mac-bytes-to-integer bytes from (+ from 4))
1684 (mac-bytes-to-integer bytes (+ from 4) (+ from 8))
1685 (mac-bytes-to-integer bytes (+ from 8) to))))
1687 (defun mac-ae-text-range-array (ae keyword)
1688 ;; struct TextRangeArray {
1689 ;; short fNumOfRanges;
1690 ;; TextRange fRange[1];
1692 (let* ((bytes (cdr (mac-ae-parameter ae keyword "tray")))
1693 (len (length bytes))
1695 (when (and bytes (>= len 2)
1697 (setq nranges (mac-bytes-to-integer bytes 0 2))
1698 (= len (+ 2 (* nranges 10)))))
1699 (setq result (make-vector nranges nil))
1700 (dotimes (i nranges)
1702 (mac-bytes-to-text-range bytes (+ (* i 10) 2)
1706 (defconst mac-keyboard-modifier-mask-alist
1708 (lambda (modifier-bit)
1709 (cons (car modifier-bit) (lsh 1 (cdr modifier-bit))))
1710 '((command . 8) ; cmdKeyBit
1711 (shift . 9) ; shiftKeyBit
1712 (option . 11) ; optionKeyBit
1713 (control . 12) ; controlKeyBit
1714 (function . 17))) ; kEventKeyModifierFnBit
1715 "Alist of Mac keyboard modifier symbols vs masks.")
1717 (defun mac-ae-keyboard-modifiers (ae)
1718 (let ((modifiers-value (mac-ae-number ae "kmod"))
1721 (dolist (modifier-mask mac-keyboard-modifier-mask-alist)
1722 (if (/= (logand modifiers-value (cdr modifier-mask)) 0)
1723 (setq modifiers (cons (car modifier-mask) modifiers)))))
1726 (defun mac-ae-reopen-application (event)
1727 "Show some frame in response to the Apple event EVENT.
1728 The frame to be shown is chosen from visible or iconified frames
1729 if possible. If there's no such frame, a new frame is created."
1731 (unless (frame-visible-p (selected-frame))
1732 (let ((frame (or (car (visible-frame-list))
1733 (car (filtered-frame-list 'frame-visible-p)))))
1735 (select-frame frame)
1736 (switch-to-buffer-other-frame "*scratch*"))))
1737 (select-frame-set-input-focus (selected-frame)))
1739 (defun mac-ae-open-documents (event)
1740 "Open the documents specified by the Apple event EVENT."
1742 (let ((ae (mac-event-ae event)))
1743 (dolist (file-name (mac-ae-list ae nil 'undecoded-file-name))
1745 (dnd-open-local-file
1747 (mapconcat 'url-hexify-string
1748 (split-string file-name "/") "/")) nil)))
1749 (let ((selection-range (mac-ae-selection-range ae))
1750 (search-text (mac-ae-text-for-search ae)))
1751 (cond (selection-range
1752 (let ((line (car selection-range))
1753 (start (cadr selection-range))
1754 (end (nth 2 selection-range)))
1757 (if (and (> start 0) (> end 0))
1758 (progn (set-mark start)
1759 (goto-char end))))))
1760 ((stringp search-text)
1762 (mapconcat 'regexp-quote (split-string search-text) "\\|")
1764 (select-frame-set-input-focus (selected-frame)))
1766 (defun mac-ae-quit-application (event)
1767 "Quit the application Emacs with the Apple event EVENT."
1769 (let ((ae (mac-event-ae event)))
1771 (save-buffers-kill-emacs)
1772 ;; Reaches here if the user has canceled the quit.
1773 (mac-resume-apple-event ae -128)))) ; userCanceledErr
1775 ;; url-generic-parse-url is autoloaded from url-parse.
1776 (declare-function url-type "url-parse" t t) ; defstruct
1778 (defun mac-ae-get-url (event)
1779 "Open the URL specified by the Apple event EVENT.
1780 Currently the `mailto' scheme is supported."
1782 (let* ((ae (mac-event-ae event))
1783 (parsed-url (url-generic-parse-url (mac-ae-text ae))))
1784 (if (string= (url-type parsed-url) "mailto")
1786 (url-mailto parsed-url)
1787 (select-frame-set-input-focus (selected-frame)))
1788 (mac-resume-apple-event ae t))))
1790 (setq mac-apple-event-map (make-sparse-keymap))
1792 ;; Received when Emacs is launched without associated documents.
1793 ;; Accept it as an Apple event, but no Emacs event is generated so as
1794 ;; not to erase the splash screen.
1795 (define-key mac-apple-event-map [core-event open-application] 0)
1797 ;; Received when a dock or application icon is clicked and Emacs is
1799 (define-key mac-apple-event-map [core-event reopen-application]
1800 'mac-ae-reopen-application)
1802 (define-key mac-apple-event-map [core-event open-documents]
1803 'mac-ae-open-documents)
1804 (define-key mac-apple-event-map [core-event show-preferences] 'customize)
1805 (define-key mac-apple-event-map [core-event quit-application]
1806 'mac-ae-quit-application)
1808 (define-key mac-apple-event-map [internet-event get-url] 'mac-ae-get-url)
1810 (define-key mac-apple-event-map [hi-command about] 'about-emacs)
1812 ;;; Converted Carbon Events
1813 (defun mac-handle-toolbar-switch-mode (event)
1814 "Toggle visibility of tool-bars in response to EVENT.
1815 With no keyboard modifiers, it toggles the visibility of the
1816 frame where the tool-bar toggle button was pressed. With some
1817 modifiers, it changes the global tool-bar visibility setting."
1819 (let ((ae (mac-event-ae event)))
1820 (if (mac-ae-keyboard-modifiers ae)
1821 ;; Globally toggle tool-bar-mode if some modifier key is pressed.
1822 (tool-bar-mode 'toggle)
1823 (let ((frame (mac-ae-frame ae)))
1824 (set-frame-parameter frame 'tool-bar-lines
1825 (if (= (frame-parameter frame 'tool-bar-lines) 0)
1828 ;; kEventClassWindow/kEventWindowToolbarSwitchMode
1829 (define-key mac-apple-event-map [window toolbar-switch-mode]
1830 'mac-handle-toolbar-switch-mode)
1833 (when (fboundp 'mac-set-font-panel-visible-p)
1835 (define-minor-mode mac-font-panel-mode
1836 "Toggle use of the font panel.
1837 With numeric ARG, display the font panel if and only if ARG is positive."
1841 (mac-set-font-panel-visible-p mac-font-panel-mode))
1843 (defun mac-handle-font-panel-closed (event)
1844 "Update internal status in response to font panel closed EVENT."
1846 ;; Synchronize with the minor mode variable.
1847 (mac-font-panel-mode 0))
1849 (defun mac-handle-font-selection (event)
1850 "Change default face attributes according to font selection EVENT."
1852 (let* ((ae (mac-event-ae event))
1853 (fm-font-size (mac-ae-number ae "fmsz"))
1854 (atsu-font-id (mac-ae-number ae "auid"))
1855 (attribute-values (and atsu-font-id
1856 (mac-atsu-font-face-attributes atsu-font-id))))
1858 (setq attribute-values
1859 `(:height ,(* 10 fm-font-size) ,@attribute-values)))
1860 (apply 'set-face-attribute 'default (selected-frame) attribute-values)))
1862 ;; kEventClassFont/kEventFontPanelClosed
1863 (define-key mac-apple-event-map [font panel-closed]
1864 'mac-handle-font-panel-closed)
1865 ;; kEventClassFont/kEventFontSelection
1866 (define-key mac-apple-event-map [font selection] 'mac-handle-font-selection)
1867 (define-key mac-apple-event-map [hi-command show-hide-font-panel]
1868 'mac-font-panel-mode)
1870 (define-key-after menu-bar-showhide-menu [mac-font-panel-mode]
1871 (menu-bar-make-mm-toggle mac-font-panel-mode
1873 "Show the font panel as a floating dialog")
1876 ) ;; (fboundp 'mac-set-font-panel-visible-p)
1879 (defvar mac-ts-active-input-buf ""
1880 "Byte sequence of the current Mac TSM active input area.")
1881 (defvar mac-ts-update-active-input-area-seqno 0
1882 "Number of processed update-active-input-area events.")
1883 (setq mac-ts-active-input-overlay (make-overlay 0 0))
1885 (defface mac-ts-caret-position
1886 '((t :inverse-video t))
1887 "Face for caret position in Mac TSM active input area.
1888 This is used when the active input area is displayed either in
1889 the echo area or in a buffer where the cursor is not displayed."
1892 (defface mac-ts-raw-text
1894 "Face for raw text in Mac TSM active input area."
1897 (defface mac-ts-selected-raw-text
1899 "Face for selected raw text in Mac TSM active input area."
1902 (defface mac-ts-converted-text
1903 '((((background dark)) :underline "gray20")
1904 (t :underline "gray80"))
1905 "Face for converted text in Mac TSM active input area."
1908 (defface mac-ts-selected-converted-text
1910 "Face for selected converted text in Mac TSM active input area."
1913 (defface mac-ts-block-fill-text
1915 "Face for block fill text in Mac TSM active input area."
1918 (defface mac-ts-outline-text
1920 "Face for outline text in Mac TSM active input area."
1923 (defface mac-ts-selected-text
1925 "Face for selected text in Mac TSM active input area."
1928 (defface mac-ts-no-hilite
1929 '((t :inherit default))
1930 "Face for no hilite in Mac TSM active input area."
1933 (defconst mac-ts-hilite-style-faces
1934 '((2 . mac-ts-raw-text) ; kTSMHiliteRawText
1935 (3 . mac-ts-selected-raw-text) ; kTSMHiliteSelectedRawText
1936 (4 . mac-ts-converted-text) ; kTSMHiliteConvertedText
1937 (5 . mac-ts-selected-converted-text) ; kTSMHiliteSelectedConvertedText
1938 (6 . mac-ts-block-fill-text) ; kTSMHiliteBlockFillText
1939 (7 . mac-ts-outline-text) ; kTSMHiliteOutlineText
1940 (8 . mac-ts-selected-text) ; kTSMHiliteSelectedText
1941 (9 . mac-ts-no-hilite)) ; kTSMHiliteNoHilite
1942 "Alist of Mac TSM hilite style vs Emacs face.")
1944 (defun mac-ts-update-active-input-buf (text fix-len hilite-rng update-rng)
1945 (let ((buf-len (length mac-ts-active-input-buf))
1947 (if (or (null update-rng)
1948 (/= (% (length update-rng) 2) 0))
1949 ;; The parameter is missing (or in a bad format). The
1950 ;; existing inline input session is completely replaced with
1952 (setq mac-ts-active-input-buf text)
1953 ;; Otherwise, the current subtext specified by the (2*j)-th
1954 ;; range is replaced with the new subtext specified by the
1955 ;; (2*j+1)-th range.
1956 (let ((tail buf-len)
1957 (i (length update-rng))
1961 (setq rng (aref update-rng i))
1962 (if (and (<= 0 (cadr rng)) (< (cadr rng) tail)
1965 (cons (substring mac-ts-active-input-buf (cadr rng) tail)
1967 (setq tail (car rng))
1968 (setq rng (aref update-rng (1+ i)))
1969 (if (and (<= 0 (car rng)) (< (car rng) (cadr rng))
1970 (<= (cadr rng) (length text)))
1972 (cons (substring text (car rng) (cadr rng))
1974 (if (and (< 0 tail) (<= tail buf-len))
1976 (cons (substring mac-ts-active-input-buf 0 tail)
1978 (setq mac-ts-active-input-buf (apply 'concat segments))))
1979 (setq buf-len (length mac-ts-active-input-buf))
1980 ;; Confirm (a part of) inline input session.
1981 (cond ((< fix-len 0)
1982 ;; Entire inline session is being confirmed.
1983 (setq confirmed mac-ts-active-input-buf)
1984 (setq mac-ts-active-input-buf ""))
1986 ;; None of the text is being confirmed (yet).
1987 (setq confirmed ""))
1989 (if (> fix-len buf-len)
1990 (setq fix-len buf-len))
1991 (setq confirmed (substring mac-ts-active-input-buf 0 fix-len))
1992 (setq mac-ts-active-input-buf
1993 (substring mac-ts-active-input-buf fix-len))))
1994 (setq buf-len (length mac-ts-active-input-buf))
1995 ;; Update highlighting and the caret position in the new inline
1997 (remove-text-properties 0 buf-len '(cursor nil) mac-ts-active-input-buf)
1999 (cond ((and (= (nth 2 rng) 1) ; kTSMHiliteCaretPosition
2000 (<= 0 (car rng)) (< (car rng) buf-len))
2001 (put-text-property (car rng) buf-len
2002 'cursor t mac-ts-active-input-buf))
2003 ((and (<= 0 (car rng)) (< (car rng) (cadr rng))
2004 (<= (cadr rng) buf-len))
2005 (put-text-property (car rng) (cadr rng) 'face
2006 (cdr (assq (nth 2 rng)
2007 mac-ts-hilite-style-faces))
2008 mac-ts-active-input-buf))))
2012 (defun mac-split-string-by-property-change (string)
2013 (let ((tail (length string))
2016 (while (setq head (previous-property-change tail string)
2017 result (cons (substring string (or head 0) tail) result)
2021 (defun mac-replace-untranslated-utf-8-chars (string &optional to-string)
2022 (or to-string (setq to-string "\e$,3u=\e(B"))
2025 (if (get-text-property 0 'untranslated-utf-8 str) to-string str))
2026 (mac-split-string-by-property-change string)
2029 (defun mac-keyboard-translate-char (ch)
2030 (if (and (char-valid-p ch)
2031 (or (char-table-p keyboard-translate-table)
2032 (and (or (stringp keyboard-translate-table)
2033 (vectorp keyboard-translate-table))
2034 (> (length keyboard-translate-table) ch))))
2035 (or (aref keyboard-translate-table ch) ch)
2038 (defun mac-unread-string (string)
2039 ;; Unread characters and insert them in a keyboard macro being
2041 (apply 'isearch-unread
2042 (mapcar 'mac-keyboard-translate-char
2043 (mac-replace-untranslated-utf-8-chars string))))
2045 (defun mac-ts-update-active-input-area (event)
2046 "Update Mac TSM active input area according to EVENT.
2047 The confirmed text is converted to Emacs input events and pushed
2048 into `unread-command-events'. The unconfirmed text is displayed
2049 either in the current buffer or in the echo area."
2051 (let* ((ae (mac-event-ae event))
2052 (type-text (mac-ae-parameter ae "tstx"))
2053 (text (or (cdr type-text) ""))
2054 (decode-fun (if (equal (car type-text) "TEXT")
2055 'mac-TEXT-to-string 'mac-utxt-to-string))
2056 (script-language (mac-ae-script-language ae "tssl"))
2057 (coding (or (cdr (assq (car script-language)
2058 mac-script-code-coding-systems))
2060 (fix-len (mac-ae-number ae "tsfx"))
2061 ;; Optional parameters
2062 (hilite-rng (mac-ae-text-range-array ae "tshi"))
2063 (update-rng (mac-ae-text-range-array ae "tsup"))
2064 ;;(pin-rng (mac-bytes-to-text-range (cdr (mac-ae-parameter ae "tspn" "txrn"))))
2065 ;;(clause-offsets (cdr (mac-ae-parameter ae "tscl" "ofay")))
2066 (seqno (mac-ae-number ae "tsSn"))
2068 (unless (= seqno mac-ts-update-active-input-area-seqno)
2069 ;; Reset internal states if sequence number is out of sync.
2070 (setq mac-ts-active-input-buf ""))
2072 (mac-ts-update-active-input-buf text fix-len hilite-rng update-rng))
2073 (let ((use-echo-area
2075 (and cursor-in-echo-area (current-message))
2076 ;; Overlay strings are not shown in some cases.
2077 (get-char-property (point) 'invisible)
2079 (or (and (get-char-property (point) 'display)
2080 (eq (get-char-property (1- (point)) 'display)
2081 (get-char-property (point) 'display)))
2082 (and (get-char-property (point) 'composition)
2083 (eq (get-char-property (1- (point)) 'composition)
2084 (get-char-property (point) 'composition)))))))
2085 active-input-string caret-seen)
2086 ;; Decode the active input area text with inheriting faces and
2087 ;; the caret position.
2088 (setq active-input-string
2091 (let ((decoded (funcall decode-fun str coding)))
2092 (put-text-property 0 (length decoded) 'face
2093 (get-text-property 0 'face str) decoded)
2094 (when (and (not caret-seen)
2095 (get-text-property 0 'cursor str))
2097 (if (or use-echo-area (null cursor-type))
2098 (put-text-property 0 1 'face 'mac-ts-caret-position
2100 (put-text-property 0 1 'cursor t decoded)))
2102 (mac-split-string-by-property-change mac-ts-active-input-buf)
2104 (put-text-property 0 (length active-input-string)
2105 'mac-ts-active-input-string t active-input-string)
2107 (let ((msg (current-message))
2110 ;; Don't get confused by previously displayed
2111 ;; `active-input-string'.
2112 (null (get-text-property 0 'mac-ts-active-input-string
2114 (setq msg (propertize msg 'display
2115 (concat msg active-input-string)))
2116 (setq msg active-input-string))
2118 (overlay-put mac-ts-active-input-overlay 'before-string nil))
2119 (move-overlay mac-ts-active-input-overlay
2120 (point) (point) (current-buffer))
2121 (overlay-put mac-ts-active-input-overlay 'before-string
2122 active-input-string))
2123 (mac-unread-string (funcall decode-fun confirmed coding)))
2124 ;; The event is successfully processed. Sync the sequence number.
2125 (setq mac-ts-update-active-input-area-seqno (1+ seqno))))
2127 (defun mac-ts-unicode-for-key-event (event)
2128 "Convert Unicode key EVENT to Emacs key events and unread them."
2130 (let* ((ae (mac-event-ae event))
2131 (text (cdr (mac-ae-parameter ae "tstx" "utxt")))
2132 (script-language (mac-ae-script-language ae "tssl"))
2133 (coding (or (cdr (assq (car script-language)
2134 mac-script-code-coding-systems))
2137 (mac-unread-string (mac-utxt-to-string text coding)))))
2139 ;; kEventClassTextInput/kEventTextInputUpdateActiveInputArea
2140 (define-key mac-apple-event-map [text-input update-active-input-area]
2141 'mac-ts-update-active-input-area)
2142 ;; kEventClassTextInput/kEventTextInputUnicodeForKeyEvent
2143 (define-key mac-apple-event-map [text-input unicode-for-key-event]
2144 'mac-ts-unicode-for-key-event)
2147 (defun mac-service-open-file ()
2148 "Open the file specified by the selection value for Services."
2150 (find-file-existing (x-selection-value mac-service-selection)))
2152 (defun mac-service-open-selection ()
2153 "Create a new buffer containing the selection value for Services."
2155 (switch-to-buffer (generate-new-buffer "*untitled*"))
2156 (insert (x-selection-value mac-service-selection))
2158 (save-buffer) ; It pops up the save dialog.
2161 (defun mac-service-mail-selection ()
2162 "Prepare a mail buffer containing the selection value for Services."
2167 (insert (x-selection-value mac-service-selection) "\n"))
2169 (defun mac-service-mail-to ()
2170 "Prepare a mail buffer to be sent to the selection value for Services."
2172 (compose-mail (x-selection-value mac-service-selection)))
2174 (defun mac-service-insert-text ()
2175 "Insert the selection value for Services."
2177 (let ((text (x-selection-value mac-service-selection)))
2178 (if (not buffer-read-only)
2182 (substitute-command-keys
2183 "The text from the Services menu can be accessed with \\[yank]")))))
2185 ;; kEventClassService/kEventServicePaste
2186 (define-key mac-apple-event-map [service paste] 'mac-service-insert-text)
2187 ;; kEventClassService/kEventServicePerform
2188 (define-key mac-apple-event-map [service perform open-file]
2189 'mac-service-open-file)
2190 (define-key mac-apple-event-map [service perform open-selection]
2191 'mac-service-open-selection)
2192 (define-key mac-apple-event-map [service perform mail-selection]
2193 'mac-service-mail-selection)
2194 (define-key mac-apple-event-map [service perform mail-to]
2195 'mac-service-mail-to)
2197 (defun mac-dispatch-apple-event (event)
2198 "Dispatch EVENT according to the keymap `mac-apple-event-map'."
2200 (let* ((binding (lookup-key mac-apple-event-map (mac-event-spec event)))
2201 (ae (mac-event-ae event))
2202 (service-message (and (keymapp binding)
2203 (cdr (mac-ae-parameter ae "svmg")))))
2204 (when service-message
2205 (setq service-message
2206 (intern (decode-coding-string service-message 'utf-8)))
2207 (setq binding (lookup-key binding (vector service-message))))
2208 ;; Replace (cadr event) with a dummy position so that event-start
2210 (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0))
2211 (if (null (mac-ae-parameter ae 'emacs-suspension-id))
2212 (command-execute binding nil (vector event) t)
2215 (command-execute binding nil (vector event) t)
2216 (mac-resume-apple-event ae))
2218 (mac-ae-set-reply-parameter ae "errs"
2219 (cons "TEXT" (error-message-string err)))
2220 (mac-resume-apple-event ae -10000)))))) ; errAEEventFailed
2222 (define-key special-event-map [mac-apple-event] 'mac-dispatch-apple-event)
2224 ;; Processing of Apple events are deferred at the startup time. For
2225 ;; example, files dropped onto the Emacs application icon can only be
2226 ;; processed when the initial frame has been created: this is where
2227 ;; the files should be opened.
2228 (add-hook 'after-init-hook 'mac-process-deferred-apple-events)
2230 (run-with-idle-timer 5 t 'mac-cleanup-expired-apple-events)
2235 (defcustom mac-dnd-types-alist
2236 '(("furl" . mac-dnd-handle-furl)
2237 ("hfs " . mac-dnd-handle-hfs)
2238 ("utxt" . mac-dnd-insert-utxt)
2239 ("TEXT" . mac-dnd-insert-TEXT)
2240 ("TIFF" . mac-dnd-insert-TIFF))
2241 "Which function to call to handle a drop of that type.
2242 The function takes three arguments, WINDOW, ACTION and DATA.
2243 WINDOW is where the drop occurred, ACTION is always `private' on
2244 Mac. DATA is the drop data. Unlike the x-dnd counterpart, the
2245 return value of the function is not significant.
2247 See also `mac-dnd-known-types'."
2252 (defun mac-dnd-handle-furl (window action data)
2253 (dnd-handle-one-url window action (mac-furl-to-string data)))
2255 (defun mac-dnd-handle-hfs (window action data)
2256 ;; struct HFSFlavor {
2258 ;; OSType fileCreator;
2262 (let* ((file-name (mac-coerce-ae-data "fss " (substring data 10)
2263 'undecoded-file-name))
2264 (url (concat "file://"
2265 (mapconcat 'url-hexify-string
2266 (split-string file-name "/") "/"))))
2267 (dnd-handle-one-url window action url)))
2269 (defun mac-dnd-insert-utxt (window action data)
2270 (dnd-insert-text window action (mac-utxt-to-string data)))
2272 (defun mac-dnd-insert-TEXT (window action data)
2273 (dnd-insert-text window action (mac-TEXT-to-string data)))
2275 (defun mac-dnd-insert-TIFF (window action data)
2276 (dnd-insert-text window action (mac-TIFF-to-string data)))
2278 (defun mac-dnd-drop-data (event frame window data type &optional action)
2279 (or action (setq action 'private))
2280 (let* ((type-info (assoc type mac-dnd-types-alist))
2281 (handler (cdr type-info))
2282 (w (posn-window (event-start event))))
2284 (if (and (window-live-p w)
2285 (not (window-minibuffer-p w))
2286 (not (window-dedicated-p w)))
2287 ;; If dropping in an ordinary window which we could use,
2288 ;; let dnd-open-file-other-window specify what to do.
2290 (when (not mouse-yank-at-point)
2291 (goto-char (posn-point (event-start event))))
2292 (funcall handler window action data))
2293 ;; If we can't display the file here,
2294 ;; make a new window for it.
2295 (let ((dnd-open-file-other-window t))
2296 (select-frame frame)
2297 (funcall handler window action data))))))
2299 (defun mac-dnd-handle-drag-n-drop-event (event)
2300 "Receive drag and drop events."
2302 (let ((window (posn-window (event-start event)))
2303 (ae (mac-event-ae event))
2305 (when (windowp window) (select-window window))
2306 (if (memq 'option (mac-ae-keyboard-modifiers ae))
2307 (setq action 'copy))
2308 (dolist (item (mac-ae-list ae))
2309 (if (not (equal (car item) "null"))
2310 (mac-dnd-drop-data event (selected-frame) window
2311 (cdr item) (car item) action)))))
2313 (defvar mac-font-encoder-list
2314 '(("mac-roman" mac-roman-encoder
2315 ccl-encode-mac-roman-font "%s")
2316 ("mac-centraleurroman" encode-mac-centraleurroman
2317 ccl-encode-mac-centraleurroman-font "%s ce")
2318 ("mac-cyrillic" encode-mac-cyrillic
2319 ccl-encode-mac-cyrillic-font "%s cy")
2320 ("mac-symbol" mac-symbol-encoder
2321 ccl-encode-mac-symbol-font "symbol")
2322 ("mac-dingbats" mac-dingbats-encoder
2323 ccl-encode-mac-dingbats-font "zapf dingbats")))
2326 (mapcar (lambda (lst) (nth 1 lst)) mac-font-encoder-list))
2329 latin-iso8859-3 latin-iso8859-4
2330 cyrillic-iso8859-5 greek-iso8859-7 hebrew-iso8859-8
2331 latin-iso8859-9 latin-iso8859-14 latin-iso8859-15)))
2332 (dolist (encoder encoder-list)
2333 (let ((table (get encoder 'translation-table)))
2334 (dolist (charset charset-list)
2336 (let* ((c (make-char charset (+ i 32)))
2337 (mu (aref ucs-mule-to-mule-unicode c))
2338 (mac-encoded (and mu (aref table mu))))
2340 (aset table c mac-encoded))))))))
2342 ;; We assume none of official dim2 charsets (0x90..0x99) are encoded
2345 (define-ccl-program ccl-encode-mac-roman-font
2348 (translate-character mac-roman-encoder r0 r1)
2351 (translate-character mac-roman-encoder r0 r1))))
2352 "CCL program for Mac Roman font")
2354 (define-ccl-program ccl-encode-mac-centraleurroman-font
2357 (translate-character encode-mac-centraleurroman r0 r1)
2360 (translate-character encode-mac-centraleurroman r0 r1))))
2361 "CCL program for Mac Central European Roman font")
2363 (define-ccl-program ccl-encode-mac-cyrillic-font
2366 (translate-character encode-mac-cyrillic r0 r1)
2369 (translate-character encode-mac-cyrillic r0 r1))))
2370 "CCL program for Mac Cyrillic font")
2372 (define-ccl-program ccl-encode-mac-symbol-font
2375 (translate-character mac-symbol-encoder r0 r1)
2378 (translate-character mac-symbol-encoder r0 r1))))
2379 "CCL program for Mac Symbol font")
2381 (define-ccl-program ccl-encode-mac-dingbats-font
2384 (translate-character mac-dingbats-encoder r0 r1)
2387 (translate-character mac-dingbats-encoder r0 r1))))
2388 "CCL program for Mac Dingbats font")
2391 (setq font-ccl-encoder-alist
2393 (mapcar (lambda (lst) (cons (nth 0 lst) (nth 2 lst)))
2394 mac-font-encoder-list)
2395 font-ccl-encoder-alist))
2397 (defconst mac-char-fontspec-list
2398 ;; Directly operate on a char-table instead of a fontset so that it
2399 ;; may not create a dummy fontset.
2400 (let ((template (make-char-table 'fontset)))
2404 (mapcar (lambda (lst)
2405 (cons (cons (nth 3 lst) (nth 0 lst)) (nth 1 lst)))
2406 mac-font-encoder-list)))
2407 (let ((font (car font-encoder))
2408 (encoder (cdr font-encoder)))
2412 (generic-char-p key)
2413 (memq (char-charset key)
2414 '(ascii eight-bit-control eight-bit-graphic))
2415 (aset template key font)))
2416 (get encoder 'translation-table))))
2418 ;; Like fontset-info, but extend a range only if its "to" part is
2419 ;; the predecessor of the current char.
2420 (let* ((last '((0 nil)))
2422 last-char-or-range last-char last-elt)
2426 (setq last-char-or-range (car (car last))
2427 last-char (if (consp last-char-or-range)
2428 (cdr last-char-or-range)
2430 last-elt (cdr (car last)))
2431 (if (and (eq elt last-elt)
2432 (= char (1+ last-char))
2433 (eq (char-charset char) (char-charset last-char)))
2434 (if (consp last-char-or-range)
2435 (setcdr last-char-or-range char)
2436 (setcar (car last) (cons last-char char)))
2437 (setcdr last (list (cons char elt)))
2438 (setq last (cdr last)))))
2440 (cdr accumulator))))
2442 (defun fontset-add-mac-fonts (fontset &optional base-family)
2443 "Add font-specs for Mac fonts to FONTSET.
2444 The added font-specs are determined by BASE-FAMILY and the value
2445 of `mac-char-fontspec-list', which is a list
2446 of (CHARACTER-OR-RANGE . (FAMILY-FORMAT . REGISTRY)). If
2447 BASE-FAMILY is nil, the font family in the added font-specs is
2448 also nil. If BASE-FAMILY is a string, `%s' in FAMILY-FORMAT is
2449 replaced with the string. Otherwise, `%s' in FAMILY-FORMAT is
2450 replaced with the ASCII font family name in FONTSET."
2452 (if (stringp base-family)
2453 (setq base-family (downcase base-family))
2454 (let ((ascii-font (fontset-font fontset (charset-id 'ascii))))
2457 (aref (x-decompose-font-name
2458 (downcase (x-resolve-font-name ascii-font)))
2459 xlfd-regexp-family-subnum))))))
2460 (let (fontspec-cache fontspec)
2461 (dolist (char-fontspec mac-char-fontspec-list)
2462 (setq fontspec (cdr (assq (cdr char-fontspec) fontspec-cache)))
2463 (when (null fontspec)
2465 (cons (and base-family
2466 (format (car (cdr char-fontspec)) base-family))
2467 (cdr (cdr char-fontspec))))
2468 (setq fontspec-cache (cons (cons (cdr char-fontspec) fontspec)
2470 (set-fontset-font fontset (car char-fontspec) fontspec))))
2472 (defun create-fontset-from-mac-roman-font (font &optional resolved-font
2474 "Create a fontset from a Mac roman font FONT.
2476 Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If
2477 omitted, `x-resolve-font-name' is called to get the resolved name. At
2478 this time, if FONT is not available, error is signaled.
2480 Optional 2nd arg FONTSET-NAME is a string to be used in
2481 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
2482 an appropriate name is generated automatically.
2484 It returns a name of the created fontset."
2486 (create-fontset-from-ascii-font font resolved-font fontset-name)))
2487 (fontset-add-mac-fonts fontset t)
2490 (defun x-win-suspend-error ()
2491 (error "Suspending an Emacs running under Mac makes no sense"))
2493 (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
2495 (defvar mac-initialized nil
2496 "Non-nil if the w32 window system has been initialized.")
2498 (defun mac-initialize-window-system ()
2499 "Initialize Emacs for Mac GUI frames."
2501 ;;; Do the actual Windows setup here; the above code just defines
2502 ;;; functions and variables that we use now.
2504 (setq command-line-args (x-handle-args command-line-args))
2506 ;;; Make sure we have a valid resource name.
2507 (or (stringp x-resource-name)
2509 (setq x-resource-name (invocation-name))
2511 ;; Change any . or * characters in x-resource-name to hyphens,
2512 ;; so as not to choke when we use it in X resource queries.
2513 (while (setq i (string-match "[.*]" x-resource-name))
2514 (aset x-resource-name i ?-))))
2516 (if (x-display-list)
2517 ;; On Mac OS 8/9, Most coding systems used in code conversion for
2518 ;; font names are not ready at the time when the terminal frame is
2519 ;; created. So we reconstruct font name table for the initial
2521 (mac-clear-font-name-table)
2522 (x-open-connection "Mac"
2523 x-command-line-resources
2524 ;; Exit Emacs with fatal error if this fails.
2527 (add-hook 'suspend-hook 'x-win-suspend-error)
2529 ;;; Arrange for the kill and yank functions to set and check the clipboard.
2530 (setq interprogram-cut-function 'x-select-text)
2531 (setq interprogram-paste-function 'x-get-selection-value)
2536 ;;; Turn off window-splitting optimization; Mac is usually fast enough
2537 ;;; that this is only annoying.
2538 (setq split-window-keep-point t)
2540 ;; Don't show the frame name; that's redundant.
2541 (setq-default mode-line-frame-identification " ")
2543 ;; Turn on support for mouse wheels.
2544 (mouse-wheel-mode 1)
2547 ;; Enable CLIPBOARD copy/paste through menu bar commands.
2548 (menu-bar-enable-clipboard)
2551 ;; Initiate drag and drop
2553 (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2556 ;;;; Non-toolkit Scroll bars
2558 (unless x-toolkit-scroll-bars
2561 ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
2563 ;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
2566 [vertical-scroll-bar down-mouse-1]
2567 'mac-handle-scroll-bar-event)
2569 (global-unset-key [vertical-scroll-bar drag-mouse-1])
2570 (global-unset-key [vertical-scroll-bar mouse-1])
2572 ;; Adjust Courier font specifications in x-fixed-font-alist.
2573 (let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
2575 (dolist (label-fonts (cdr courier-fonts))
2579 (if (string-match "\\`-adobe-courier-\\([^-]*\\)-\\(.\\)-\\(.*\\)-iso8859-1\\'" font)
2581 (if (string= (match-string 2 font) "o")
2582 "-*-courier-\\1-i-\\3-*-*"
2583 "-*-courier-\\1-\\2-\\3-*-*")
2586 (cdr label-fonts))))))
2588 ;; Setup the default fontset.
2589 (setup-default-fontset)
2590 (cond ((x-list-fonts "*-iso10646-1" nil nil 1)
2591 ;; Use ATSUI (if available) for the following charsets.
2593 (charset '(latin-iso8859-1
2594 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
2595 thai-tis620 greek-iso8859-7 arabic-iso8859-6
2596 hebrew-iso8859-8 cyrillic-iso8859-5
2597 latin-iso8859-9 latin-iso8859-15 latin-iso8859-14
2598 japanese-jisx0212 chinese-sisheng ipa
2599 vietnamese-viscii-lower vietnamese-viscii-upper
2600 lao ethiopic tibetan))
2601 (set-fontset-font nil charset '(nil . "iso10646-1"))))
2602 ((null (x-list-fonts "*-iso8859-1" nil nil 1))
2603 ;; Add Mac-encoding fonts unless ETL fonts are installed.
2604 (fontset-add-mac-fonts "fontset-default")))
2606 ;; Create a fontset that uses mac-roman font. With this fontset,
2607 ;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
2608 ;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
2609 (create-fontset-from-fontset-spec
2610 "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
2611 ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
2612 (fontset-add-mac-fonts "fontset-standard" t)
2614 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2615 (create-fontset-from-x-resource)
2617 ;; Try to create a fontset from a font specification which comes
2618 ;; from initial-frame-alist, default-frame-alist, or X resource.
2619 ;; A font specification in command line argument (i.e. -fn XXXX)
2620 ;; should be already in default-frame-alist as a `font'
2621 ;; parameter. However, any font specifications in site-start
2622 ;; library, user's init file (.emacs), and default.el are not
2623 ;; yet handled here.
2625 (let ((font (or (cdr (assq 'font initial-frame-alist))
2626 (cdr (assq 'font default-frame-alist))
2627 (x-get-resource "font" "Font")))
2628 xlfd-fields resolved-name)
2630 (not (query-fontset font))
2631 (setq resolved-name (x-resolve-font-name font))
2632 (setq xlfd-fields (x-decompose-font-name font)))
2633 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2634 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2635 ;; Create a fontset from FONT. The fontset name is
2636 ;; generated from FONT.
2637 (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum))
2638 (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum)))
2639 (create-fontset-from-mac-roman-font font resolved-name "startup")
2640 (create-fontset-from-ascii-font font resolved-name "startup")))))
2642 ;; Apply a geometry resource to the initial frame. Put it at the end
2643 ;; of the alist, so that anything specified on the command line takes
2645 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2649 (setq parsed (x-parse-geometry res-geometry))
2650 ;; If the resource specifies a position,
2651 ;; call the position and size "user-specified".
2652 (if (or (assq 'top parsed) (assq 'left parsed))
2653 (setq parsed (cons '(user-position . t)
2654 (cons '(user-size . t) parsed))))
2655 ;; All geometry parms apply to the initial frame.
2656 (setq initial-frame-alist (append initial-frame-alist parsed))
2657 ;; The size parms apply to all frames. Don't set it if there are
2658 ;; sizes there already (from command line).
2659 (if (and (assq 'height parsed)
2660 (not (assq 'height default-frame-alist)))
2661 (setq default-frame-alist
2662 (cons (cons 'height (cdr (assq 'height parsed)))
2663 default-frame-alist)))
2664 (if (and (assq 'width parsed)
2665 (not (assq 'width default-frame-alist)))
2666 (setq default-frame-alist
2667 (cons (cons 'width (cdr (assq 'width parsed)))
2668 default-frame-alist))))))
2670 ;; Check the reverseVideo resource.
2671 (let ((case-fold-search t))
2672 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2674 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2675 (setq default-frame-alist
2676 (cons '(reverse . t) default-frame-alist)))))
2678 (setq mac-initialized t)))
2680 (defun mac-handle-scroll-bar-event (event)
2681 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
2683 (let* ((position (event-start event))
2684 (window (nth 0 position))
2685 (bar-part (nth 4 position)))
2686 (select-window window)
2689 (goto-char (window-start window))
2690 (mac-scroll-down-line))
2691 ((eq bar-part 'above-handle)
2693 ((eq bar-part 'handle)
2694 (scroll-bar-drag event))
2695 ((eq bar-part 'below-handle)
2697 ((eq bar-part 'down)
2698 (goto-char (window-start window))
2699 (mac-scroll-up-line)))))
2701 (defun mac-scroll-ignore-events ()
2702 ;; Ignore confusing non-mouse events
2703 (while (not (memq (car-safe (read-event))
2704 '(mouse-1 double-mouse-1 triple-mouse-1))) nil))
2706 (defun mac-scroll-down ()
2708 (mac-scroll-ignore-events)
2711 (defun mac-scroll-down-line ()
2713 (mac-scroll-ignore-events)
2716 (defun mac-scroll-up ()
2718 (mac-scroll-ignore-events)
2721 (defun mac-scroll-up-line ()
2723 (mac-scroll-ignore-events)
2730 (unless (eq system-type 'darwin)
2731 ;; This variable specifies the Unix program to call (as a process) to
2732 ;; determine the amount of free space on a file system (defaults to
2733 ;; df). If it is not set to nil, ls-lisp will not work correctly
2734 ;; unless an external application df is implemented on the Mac.
2735 (setq directory-free-space-program nil)
2737 ;; Set this so that Emacs calls subprocesses with "sh" as shell to
2738 ;; expand filenames Note no subprocess for the shell is actually
2739 ;; started (see run_mac_command in sysdep.c).
2740 (setq shell-file-name "sh")
2742 ;; Some system variables are encoded with the system script code.
2743 (dolist (v '(system-name
2744 emacs-build-system ; Mac OS 9 version cannot dump
2745 user-login-name user-real-login-name user-full-name))
2746 (set v (decode-coding-string (symbol-value v) mac-system-coding-system))))
2748 ;; Now the default directory is changed to the user's home directory
2749 ;; in emacs.c if invoked from the WindowServer (with -psn_* option).
2750 ;; (if (string= default-directory "/")
2753 ;; Darwin 6- pty breakage is now controlled from the C code so that
2754 ;; it applies to all builds on darwin. See s/darwin.h PTY_ITERATION.
2755 ;; (setq process-connection-type t)
2757 ;; Assume that fonts are always scalable on the Mac. This sometimes
2758 ;; results in characters with jagged edges. However, without it,
2759 ;; fonts with both truetype and bitmap representations but no italic
2760 ;; or bold bitmap versions will not display these variants correctly.
2761 (setq scalable-fonts-allowed t)
2763 (add-to-list 'handle-args-function-alist '(mac . x-handle-args))
2764 (add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
2765 (add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
2769 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
2770 ;;; mac-win.el ends here