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
)
88 (defvar x-command-line-resources nil
)
90 ;; Handler for switches of the form "-switch value" or "-switch".
91 (defun x-handle-switch (switch)
92 (let ((aelt (assoc switch command-line-x-option-alist
)))
94 (let ((param (nth 3 aelt
))
97 (setq default-frame-alist
98 (cons (cons param value
)
100 (setq default-frame-alist
102 (car x-invocation-args
))
104 x-invocation-args
(cdr x-invocation-args
)))))))
106 ;; Handler for switches of the form "-switch n"
107 (defun x-handle-numeric-switch (switch)
108 (let ((aelt (assoc switch command-line-x-option-alist
)))
110 (let ((param (nth 3 aelt
)))
111 (setq default-frame-alist
113 (string-to-number (car x-invocation-args
)))
116 (cdr x-invocation-args
))))))
118 ;; Handle options that apply to initial frame only
119 (defun x-handle-initial-switch (switch)
120 (let ((aelt (assoc switch command-line-x-option-alist
)))
122 (let ((param (nth 3 aelt
))
123 (value (nth 4 aelt
)))
125 (setq initial-frame-alist
126 (cons (cons param value
)
127 initial-frame-alist
))
128 (setq initial-frame-alist
130 (car x-invocation-args
))
132 x-invocation-args
(cdr x-invocation-args
)))))))
134 ;; Make -iconic apply only to the initial frame!
135 (defun x-handle-iconic (switch)
136 (setq initial-frame-alist
137 (cons '(visibility . icon
) initial-frame-alist
)))
139 ;; Handle the -xrm option.
140 (defun x-handle-xrm-switch (switch)
141 (unless (consp x-invocation-args
)
142 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
143 (setq x-command-line-resources
144 (if (null x-command-line-resources
)
145 (car x-invocation-args
)
146 (concat x-command-line-resources
"\n" (car x-invocation-args
))))
147 (setq x-invocation-args
(cdr x-invocation-args
)))
149 ;; Handle the geometry option
150 (defun x-handle-geometry (switch)
151 (let* ((geo (x-parse-geometry (car x-invocation-args
)))
152 (left (assq 'left geo
))
153 (top (assq 'top geo
))
154 (height (assq 'height geo
))
155 (width (assq 'width geo
)))
156 (if (or height width
)
157 (setq default-frame-alist
158 (append default-frame-alist
160 (if height
(list height
))
161 (if width
(list width
)))
163 (append initial-frame-alist
165 (if height
(list height
))
166 (if width
(list width
)))))
168 (setq initial-frame-alist
169 (append initial-frame-alist
170 '((user-position . t
))
171 (if left
(list left
))
172 (if top
(list top
)))))
173 (setq x-invocation-args
(cdr x-invocation-args
))))
175 ;; Handle the -name option. Set the variable x-resource-name
176 ;; to the option's operand; set the name of
177 ;; the initial frame, too.
178 (defun x-handle-name-switch (switch)
179 (or (consp x-invocation-args
)
180 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
181 (setq x-resource-name
(car x-invocation-args
)
182 x-invocation-args
(cdr x-invocation-args
))
183 (setq initial-frame-alist
(cons (cons 'name x-resource-name
)
184 initial-frame-alist
)))
186 (defvar x-display-name nil
187 "The display name specifying server and frame.")
189 (defun x-handle-display (switch)
190 (setq x-display-name
(car x-invocation-args
)
191 x-invocation-args
(cdr x-invocation-args
)))
193 (defun x-handle-args (args)
194 "Process the X-related command line options in ARGS.
195 This is done before the user's startup file is loaded. They are copied to
196 `x-invocation-args', from which the X-related things are extracted, first
197 the switch (e.g., \"-fg\") in the following code, and possible values
198 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
199 This function returns ARGS minus the arguments that have been processed."
200 ;; We use ARGS to accumulate the args that we don't handle here, to return.
201 (setq x-invocation-args args
203 (while (and x-invocation-args
204 (not (equal (car x-invocation-args
) "--")))
205 (let* ((this-switch (car x-invocation-args
))
206 (orig-this-switch this-switch
)
207 completion argval aelt handler
)
208 (setq x-invocation-args
(cdr x-invocation-args
))
209 ;; Check for long options with attached arguments
210 ;; and separate out the attached option argument into argval.
211 (if (string-match "^--[^=]*=" this-switch
)
212 (setq argval
(substring this-switch
(match-end 0))
213 this-switch
(substring this-switch
0 (1- (match-end 0)))))
214 ;; Complete names of long options.
215 (if (string-match "^--" this-switch
)
217 (setq completion
(try-completion this-switch command-line-x-option-alist
))
218 (if (eq completion t
)
219 ;; Exact match for long option.
221 (if (stringp completion
)
222 (let ((elt (assoc completion command-line-x-option-alist
)))
223 ;; Check for abbreviated long option.
225 (error "Option `%s' is ambiguous" this-switch
))
226 (setq this-switch completion
))))))
227 (setq aelt
(assoc this-switch command-line-x-option-alist
))
228 (if aelt
(setq handler
(nth 2 aelt
)))
231 (let ((x-invocation-args
232 (cons argval x-invocation-args
)))
233 (funcall handler this-switch
))
234 (funcall handler this-switch
))
235 (setq args
(cons orig-this-switch args
)))))
236 (nconc (nreverse args
) x-invocation-args
))
240 ;; Standard Mac cursor shapes
243 (defconst mac-pointer-arrow
0)
244 (defconst mac-pointer-copy-arrow
1)
245 (defconst mac-pointer-alias-arrow
2)
246 (defconst mac-pointer-contextual-menu-arrow
3)
247 (defconst mac-pointer-I-beam
4)
248 (defconst mac-pointer-cross
5)
249 (defconst mac-pointer-plus
6)
250 (defconst mac-pointer-watch
7)
251 (defconst mac-pointer-closed-hand
8)
252 (defconst mac-pointer-open-hand
9)
253 (defconst mac-pointer-pointing-hand
10)
254 (defconst mac-pointer-counting-up-hand
11)
255 (defconst mac-pointer-counting-down-hand
12)
256 (defconst mac-pointer-counting-up-and-down-hand
13)
257 (defconst mac-pointer-spinning
14)
258 (defconst mac-pointer-resize-left
15)
259 (defconst mac-pointer-resize-right
16)
260 (defconst mac-pointer-resize-left-right
17)
261 ;; Mac OS X 10.2 and later
262 (defconst mac-pointer-not-allowed
18)
263 ;; Mac OS X 10.3 and later
264 (defconst mac-pointer-resize-up
19)
265 (defconst mac-pointer-resize-down
20)
266 (defconst mac-pointer-resize-up-down
21)
267 (defconst mac-pointer-poof
22)
270 ;; Standard X cursor shapes that have Mac counterparts
273 (defconst x-pointer-left-ptr mac-pointer-arrow
)
274 (defconst x-pointer-xterm mac-pointer-I-beam
)
275 (defconst x-pointer-crosshair mac-pointer-cross
)
276 (defconst x-pointer-plus mac-pointer-plus
)
277 (defconst x-pointer-watch mac-pointer-watch
)
278 (defconst x-pointer-hand2 mac-pointer-pointing-hand
)
279 (defconst x-pointer-left-side mac-pointer-resize-left
)
280 (defconst x-pointer-right-side mac-pointer-resize-right
)
281 (defconst x-pointer-sb-h-double-arrow mac-pointer-resize-left-right
)
282 (defconst x-pointer-top-side mac-pointer-resize-up
)
283 (defconst x-pointer-bottom-side mac-pointer-resize-down
)
284 (defconst x-pointer-sb-v-double-arrow mac-pointer-resize-up-down
)
291 (defvar x-colors
'("LightGreen"
890 "LightGoldenrodYellow"
891 "light goldenrod yellow"
908 "medium spring green"
1043 "The list of X colors from the `rgb.txt' file.
1044 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1046 (defun xw-defined-colors (&optional frame
)
1047 "Internal function called by `defined-colors', which see."
1048 (or frame
(setq frame
(selected-frame)))
1049 (let ((all-colors x-colors
)
1051 (defined-colors nil
))
1053 (setq this-color
(car all-colors
)
1054 all-colors
(cdr all-colors
))
1055 (and (color-supported-p this-color frame t
)
1056 (setq defined-colors
(cons this-color defined-colors
))))
1061 (defun x-setup-function-keys (frame)
1062 "Setup Function Keys for mac."
1063 ;; Don't do this twice on the same display, or it would break
1064 ;; normal-erase-is-backspace-mode.
1065 (unless (terminal-parameter frame
'x-setup-function-keys
)
1066 (with-selected-frame frame
1067 ;; Map certain keypad keys into ASCII characters
1068 ;; that people usually expect.
1069 (define-key local-function-key-map
[backspace] [?\d])
1070 (define-key local-function-key-map [delete] [?\d])
1071 (define-key local-function-key-map [tab] [?\t])
1072 (define-key local-function-key-map [linefeed] [?\n])
1073 (define-key local-function-key-map [clear] [?\C-l])
1074 (define-key local-function-key-map [return] [?\C-m])
1075 (define-key local-function-key-map [escape] [?\e])
1076 (define-key local-function-key-map [M-backspace] [?\M-\d])
1077 (define-key local-function-key-map [M-delete] [?\M-\d])
1078 (define-key local-function-key-map [M-tab] [?\M-\t])
1079 (define-key local-function-key-map [M-linefeed] [?\M-\n])
1080 (define-key local-function-key-map [M-clear] [?\M-\C-l])
1081 (define-key local-function-key-map [M-return] [?\M-\C-m])
1082 (define-key local-function-key-map [M-escape] [?\M-\e])
1083 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1084 local-function-key-map global-map))
1085 (set-terminal-parameter frame 'x-setup-function-keys t)))
1087 ;; These tell read-char how to convert
1088 ;; these special chars to ASCII.
1089 (put 'backspace 'ascii-character ?\d)
1090 (put 'delete 'ascii-character ?\d)
1091 (put 'tab 'ascii-character ?\t)
1092 (put 'linefeed 'ascii-character ?\n)
1093 (put 'clear 'ascii-character ?\C-l)
1094 (put 'return 'ascii-character ?\C-m)
1095 (put 'escape 'ascii-character ?\e)
1097 ;; Modifier name `ctrl' is an alias of `control'.
1098 (put 'ctrl 'modifier-value (get 'control 'modifier-value))
1101 ;;;; Script codes and coding systems
1102 (defconst mac-script-code-coding-systems
1103 '((0 . mac-roman) ; smRoman
1104 (1 . japanese-shift-jis) ; smJapanese
1105 (2 . chinese-big5) ; smTradChinese
1106 (3 . korean-iso-8bit) ; smKorean
1107 (7 . mac-cyrillic) ; smCyrillic
1108 (25 . chinese-iso-8bit) ; smSimpChinese
1109 (29 . mac-centraleurroman) ; smCentralEuroRoman
1111 "Alist of Mac script codes vs Emacs coding systems.")
1113 (defun mac-add-charset-info (xlfd-charset mac-text-encoding)
1114 "Add a character set to display with Mac fonts.
1115 Create an entry in `mac-charset-info-alist'.
1116 XLFD-CHARSET is a string which will appear in the XLFD font name
1117 to identify the character set. MAC-TEXT-ENCODING is the
1118 correspoinding TextEncodingBase value."
1119 (add-to-list 'mac-charset-info-alist
1120 (list xlfd-charset mac-text-encoding
1121 (cdr (assq mac-text-encoding
1122 mac-script-code-coding-systems)))))
1124 (setq mac-charset-info-alist nil)
1125 (mac-add-charset-info "mac-roman" 0)
1126 (mac-add-charset-info "jisx0208.1983-sjis" 1)
1127 (mac-add-charset-info "jisx0201.1976-0" 1)
1128 (mac-add-charset-info "big5-0" 2)
1129 (mac-add-charset-info "ksc5601.1989-0" 3)
1130 (mac-add-charset-info "mac-cyrillic" 7)
1131 (mac-add-charset-info "gb2312.1980-0" 25)
1132 (mac-add-charset-info "mac-centraleurroman" 29)
1133 (mac-add-charset-info "mac-symbol" 33)
1134 (mac-add-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B ?\\e$,1&r\e(B ?\\e$,1''\e(B ?\\e$,1&t\e(B ?\\e$,1&u\e(B ?\\e$,1'&\e(B ?\\e$,1&s\e(B ?\\e$,1&w\e(B ?\\e$,1&y\e(B ?\\e$,1'Q\e(B ?\\e$,1&z\e(B ?\\e$,1&{\e(B ?\\e$,1&|\e(B ?\\e$,1&}\e(B ?\\e$,1&\x7f\e(B
1172 ?\\e$,1' \e(B ?\\e$,1&x\e(B ?\\e$,1'!\e(B ?\\e$,1'#\e(B ?\\e$,1'$\e(B ?\\e$,1'%\e(B ?\\e$,1'B\e(B ?\\e$,1')\e(B ?\\e$,1&~\e(B ?\\e$,1'(\e(B ?\\e$,1&v\e(B ?\[ ?\\e$,1xT\e(B ?\] ?\\e$,1ye\e(B ?\_
1173 ?\\e$,3bE\e(B ?\\e$,1'1\e(B ?\\e$,1'2\e(B ?\\e$,1'G\e(B ?\\e$,1'4\e(B ?\\e$,1'5\e(B ?\\e$,1'F\e(B ?\\e$,1'3\e(B ?\\e$,1'7\e(B ?\\e$,1'9\e(B ?\\e$,1'U\e(B ?\\e$,1':\e(B ?\\e$,1';\e(B ?\\e$,1'<\e(B ?\\e$,1'=\e(B ?\\e$,1'?\e(B
1174 ?\\e$,1'@\e(B ?\\e$,1'8\e(B ?\\e$,1'A\e(B ?\\e$,1'C\e(B ?\\e$,1'D\e(B ?\\e$,1'E\e(B ?\\e$,1'V\e(B ?\\e$,1'I\e(B ?\\e$,1'>\e(B ?\\e$,1'H\e(B ?\\e$,1'6\e(B ?\{ ?\| ?\} ?\\e$,1x\\e(B]
1175 (make-vector (- 160 127) nil)
1176 ;; mac-symbol (160..254) -> emacs-mule mapping
1177 ;; Mapping of the following characters are changed from the
1179 ;; 0xE2 0x00AE+0xF87F -> 0x00AE # REGISTERED SIGN, alternate: sans serif
1180 ;; 0xE3 0x00A9+0xF87F -> 0x00A9 # COPYRIGHT SIGN, alternate: sans serif
1181 ;; 0xE4 0x2122+0xF87F -> 0x2122 # TRADE MARK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(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
1187 ?\\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
1190 (setq translation-table
1191 (make-translation-table-from-vector encoding-vector))
1192 ;; (define-translation-table 'mac-symbol-decoder translation-table)
1193 (define-translation-table 'mac-symbol-encoder
1194 (char-table-extra-slot translation-table 0)))
1199 (make-vector 32 nil)
1200 ;; mac-dingbats (32..126) -> emacs-mule mapping
1201 [?\ ?\\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
1202 ?\\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%U\e(B ?\\e$,2%V\e(B ?\\e$,2%W\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%_\e(B
1203 ?\\e$,2%`\e(B ?\\e$,2%a\e(B ?\\e$,2%b\e(B ?\\e$,2%c\e(B ?\\e$,2%d\e(B ?\\e$,2%e\e(B ?\\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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
1218 ;; mac-dingbats (241..254) -> emacs-mule mapping
1219 ?\\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
1222 (setq translation-table
1223 (make-translation-table-from-vector encoding-vector))
1224 ;; (define-translation-table 'mac-dingbats-decoder translation-table)
1225 (define-translation-table 'mac-dingbats-encoder
1226 (char-table-extra-slot translation-table 0)))
1228 (defconst mac-system-coding-system
1229 (let ((base (or (cdr (assq mac-system-script-code
1230 mac-script-code-coding-systems))
1232 (if (eq system-type 'darwin)
1234 (coding-system-change-eol-conversion base 'mac)))
1235 "Coding system derived from the system script code.")
1237 (set-selection-coding-system mac-system-coding-system)
1240 ;;;; Keyboard layout/language change events
1241 (defun mac-handle-language-change (event)
1242 "Set keyboard coding system to what is specified in EVENT."
1244 (let ((coding-system
1245 (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
1246 (set-keyboard-coding-system (or coding-system 'mac-roman))
1247 ;; MacJapanese maps reverse solidus to ?\x80.
1248 (if (eq coding-system 'japanese-shift-jis)
1249 (define-key key-translation-map [?\x80] "\\"))))
1251 (define-key special-event-map [language-change] 'mac-handle-language-change)
1254 ;;;; Conversion between common flavors and Lisp string.
1256 (defconst mac-text-encoding-ascii #x600
1257 "ASCII text encoding.")
1259 (defconst mac-text-encoding-mac-japanese-basic-variant #x20001
1260 "MacJapanese text encoding without Apple double-byte extensions.")
1262 (defun mac-utxt-to-string (data &optional coding-system)
1263 (or coding-system (setq coding-system mac-system-coding-system))
1265 (and (eq system-type 'darwin)
1266 (eq (coding-system-base coding-system) 'japanese-shift-jis)
1267 mac-text-encoding-mac-japanese-basic-variant))
1268 (str (and (fboundp 'mac-code-convert-string)
1269 (mac-code-convert-string data nil
1270 (or encoding coding-system)))))
1272 (setq str (decode-coding-string str coding-system))
1273 (if (eq encoding mac-text-encoding-mac-japanese-basic-variant)
1274 ;; Does it contain Apple one-byte extensions other than
1276 (if (string-match "[\xa0\xfd-\xff]" str)
1279 (unless (mac-code-convert-string data nil mac-text-encoding-ascii)
1280 (subst-char-in-string ?\x5c ?\\e(J\\e(B str t)
1281 (subst-char-in-string ?\x80 ?\\ str t)))))
1283 (decode-coding-string data
1284 (if (eq (byteorder) ?B) 'utf-16be 'utf-16le)))))
1286 (defun mac-string-to-utxt (string &optional coding-system)
1287 (or coding-system (setq coding-system mac-system-coding-system))
1288 (let (data encoding)
1289 (when (and (fboundp 'mac-code-convert-string)
1290 (memq (coding-system-base coding-system)
1291 (find-coding-systems-string string)))
1293 (coding-system-change-eol-conversion coding-system 'mac))
1295 (when (and (eq system-type 'darwin)
1296 (eq coding-system 'japanese-shift-jis-mac))
1297 (setq encoding mac-text-encoding-mac-japanese-basic-variant)
1298 (setq str (subst-char-in-string ?\\ ?\x80 str))
1299 (subst-char-in-string ?\\e(J\\e(B ?\x5c str t)
1301 (if (string-match "\\`[\x00-\x7f]*\\'" str)
1304 (setq data (mac-code-convert-string
1305 (encode-coding-string str coding-system)
1306 (or encoding coding-system) nil)))))
1307 (or data (encode-coding-string string (if (eq (byteorder) ?B)
1311 (defun mac-TEXT-to-string (data &optional coding-system)
1312 (or coding-system (setq coding-system mac-system-coding-system))
1313 (prog1 (setq data (decode-coding-string data coding-system))
1314 (when (eq (coding-system-base coding-system) 'japanese-shift-jis)
1315 ;; (subst-char-in-string ?\x5c ?\\e(J\\e(B data t)
1316 (subst-char-in-string ?\x80 ?\\ data t))))
1318 (defun mac-string-to-TEXT (string &optional coding-system)
1319 (or coding-system (setq coding-system mac-system-coding-system))
1320 (let ((encodables (find-coding-systems-string string))
1321 (rest mac-script-code-coding-systems))
1322 (unless (memq (coding-system-base coding-system) encodables)
1323 (while (and rest (not (memq (cdar rest) encodables)))
1324 (setq rest (cdr rest)))
1326 (setq coding-system (cdar rest)))))
1328 (coding-system-change-eol-conversion coding-system 'mac))
1329 (when (eq coding-system 'japanese-shift-jis-mac)
1330 ;; (setq string (subst-char-in-string ?\\ ?\x80 string))
1331 (setq string (subst-char-in-string ?\\e(J\\e(B ?\x5c string)))
1332 (encode-coding-string string coding-system))
1334 (defun mac-furl-to-string (data)
1335 ;; Remove a trailing nul character.
1336 (let ((len (length data)))
1337 (if (and (> len 0) (= (aref data (1- len)) ?\0))
1338 (substring data 0 (1- len))
1341 (defun mac-TIFF-to-string (data &optional text)
1342 (prog1 (or text (setq text (copy-sequence " ")))
1343 (put-text-property 0 (length text) 'display (create-image data 'tiff t)
1348 ;;; We keep track of the last text selected here, so we can check the
1349 ;;; current selection against it, and avoid passing back our own text
1350 ;;; from x-get-selection-value.
1351 (defvar x-last-selected-text-clipboard nil
1352 "The value of the CLIPBOARD selection last time we selected or
1354 (defvar x-last-selected-text-primary nil
1355 "The value of the PRIMARY X selection last time we selected or
1358 (defcustom x-select-enable-clipboard t
1359 "*Non-nil means cutting and pasting uses the clipboard.
1360 This is in addition to the primary selection."
1364 ;;; Make TEXT, a string, the primary X selection.
1365 (defun x-select-text (text &optional push)
1366 (x-set-selection 'PRIMARY text)
1367 (setq x-last-selected-text-primary text)
1368 (if (not x-select-enable-clipboard)
1369 (setq x-last-selected-text-clipboard nil)
1370 (x-set-selection 'CLIPBOARD text)
1371 (setq x-last-selected-text-clipboard text))
1374 (defun x-get-selection (&optional type data-type)
1375 "Return the value of a selection.
1376 The argument TYPE (default `PRIMARY') says which selection,
1377 and the argument DATA-TYPE (default `STRING') says
1378 how to convert the data.
1380 TYPE may be any symbol \(but nil stands for `PRIMARY'). However,
1381 only a few symbols are commonly used. They conventionally have
1382 all upper-case names. The most often used ones, in addition to
1383 `PRIMARY', are `SECONDARY' and `CLIPBOARD'.
1385 DATA-TYPE is usually `STRING', but can also be one of the symbols
1386 in `selection-converter-alist', which see."
1387 (let ((data (x-get-selection-internal (or type 'PRIMARY)
1388 (or data-type 'STRING)))
1389 (coding (or next-selection-coding-system
1390 selection-coding-system)))
1391 (when (and (stringp data)
1392 (setq data-type (get-text-property 0 'foreign-selection data)))
1393 (cond ((eq data-type 'public.utf16-plain-text)
1394 (setq data (mac-utxt-to-string data coding)))
1395 ((eq data-type 'com.apple.traditional-mac-plain-text)
1396 (setq data (mac-TEXT-to-string data coding)))
1397 ((eq data-type 'public.file-url)
1398 (setq data (mac-furl-to-string data))))
1399 (put-text-property 0 (length data) 'foreign-selection data-type data))
1402 (defun x-selection-value (type)
1403 (let ((data-types '(public.utf16-plain-text
1404 com.apple.traditional-mac-plain-text
1407 (while (and (null text) data-types)
1408 (setq text (condition-case nil
1409 (x-get-selection type (car data-types))
1411 (setq data-types (cdr data-types)))
1413 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
1414 (setq tiff-image (condition-case nil
1415 (x-get-selection type 'public.tiff)
1418 (remove-text-properties 0 (length tiff-image)
1419 '(foreign-selection nil) tiff-image)
1420 (setq text (mac-TIFF-to-string tiff-image text)))
1423 ;;; Return the value of the current selection.
1424 ;;; Treat empty strings as if they were unset.
1425 ;;; If this function is called twice and finds the same text,
1426 ;;; it returns nil the second time. This is so that a single
1427 ;;; selection won't be added to the kill ring over and over.
1428 (defun x-get-selection-value ()
1429 (let (clip-text primary-text)
1430 (if (not x-select-enable-clipboard)
1431 (setq x-last-selected-text-clipboard nil)
1432 (setq clip-text (x-selection-value 'CLIPBOARD))
1433 (if (string= clip-text "") (setq clip-text nil))
1435 ;; Check the CLIPBOARD selection for 'newness', is it different
1436 ;; from what we remebered them to be last time we did a
1437 ;; cut/paste operation.
1439 (cond;; check clipboard
1440 ((or (not clip-text) (string= clip-text ""))
1441 (setq x-last-selected-text-clipboard nil))
1442 ((eq clip-text x-last-selected-text-clipboard) nil)
1443 ((string= clip-text x-last-selected-text-clipboard)
1444 ;; Record the newer string,
1445 ;; so subsequent calls can use the `eq' test.
1446 (setq x-last-selected-text-clipboard clip-text)
1449 (setq x-last-selected-text-clipboard clip-text))))
1452 (setq primary-text (x-selection-value 'PRIMARY))
1453 ;; Check the PRIMARY selection for 'newness', is it different
1454 ;; from what we remebered them to be last time we did a
1455 ;; cut/paste operation.
1457 (cond;; check primary selection
1458 ((or (not primary-text) (string= primary-text ""))
1459 (setq x-last-selected-text-primary nil))
1460 ((eq primary-text x-last-selected-text-primary) nil)
1461 ((string= primary-text x-last-selected-text-primary)
1462 ;; Record the newer string,
1463 ;; so subsequent calls can use the `eq' test.
1464 (setq x-last-selected-text-primary primary-text)
1467 (setq x-last-selected-text-primary primary-text))))
1469 ;; As we have done one selection, clear this now.
1470 (setq next-selection-coding-system nil)
1472 ;; At this point we have recorded the current values for the
1473 ;; selection from clipboard (if we are supposed to) and primary,
1474 ;; So return the first one that has changed (which is the first
1476 (or clip-text primary-text)
1479 (put 'CLIPBOARD 'mac-scrap-name "com.apple.scrap.clipboard")
1480 (when (eq system-type 'darwin)
1481 (put 'FIND 'mac-scrap-name "com.apple.scrap.find")
1482 (put 'PRIMARY 'mac-scrap-name
1483 (format "org.gnu.Emacs.%d.selection.PRIMARY" (emacs-pid))))
1484 (put 'com.apple.traditional-mac-plain-text 'mac-ostype "TEXT")
1485 (put 'public.utf16-plain-text 'mac-ostype "utxt")
1486 (put 'public.tiff 'mac-ostype "TIFF")
1487 (put 'public.file-url 'mac-ostype "furl")
1489 (defun mac-select-convert-to-string (selection type value)
1490 (let ((str (cdr (xselect-convert-to-string selection nil value)))
1491 (coding (or next-selection-coding-system selection-coding-system)))
1493 ;; If TYPE is nil, this is a local request, thus return STR as
1494 ;; is. Otherwise, encode STR.
1497 (let ((inhibit-read-only t))
1498 (remove-text-properties 0 (length str) '(composition nil) str)
1500 ((eq type 'public.utf16-plain-text)
1501 (setq str (mac-string-to-utxt str coding)))
1502 ((eq type 'com.apple.traditional-mac-plain-text)
1503 (setq str (mac-string-to-TEXT str coding)))
1505 (error "Unknown selection type: %S" type))
1508 (setq next-selection-coding-system nil)
1511 (defun mac-select-convert-to-file-url (selection type value)
1512 (let ((filename (xselect-convert-to-filename selection type value))
1513 (coding (or file-name-coding-system default-file-name-coding-system)))
1514 (if (and filename coding)
1515 (setq filename (encode-coding-string filename coding)))
1517 (concat "file://localhost"
1518 (mapconcat 'url-hexify-string
1519 (split-string filename "/") "/")))))
1521 (setq selection-converter-alist
1523 '((public.utf16-plain-text . mac-select-convert-to-string)
1524 (com.apple.traditional-mac-plain-text . mac-select-convert-to-string)
1525 ;; This is not enabled by default because the `Import Image'
1526 ;; menu makes Emacs crash or hang for unknown reasons.
1527 ;; (public.tiff . nil)
1528 (public.file-url . mac-select-convert-to-file-url)
1530 selection-converter-alist))
1532 ;;;; Apple events, HICommand events, and Services menu
1535 (put 'core-event 'mac-apple-event-class "aevt") ; kCoreEventClass
1536 (put 'internet-event 'mac-apple-event-class "GURL") ; kAEInternetEventClass
1540 (put 'open-application 'mac-apple-event-id "oapp") ; kAEOpenApplication
1541 (put 'reopen-application 'mac-apple-event-id "rapp") ; kAEReopenApplication
1542 (put 'open-documents 'mac-apple-event-id "odoc") ; kAEOpenDocuments
1543 (put 'print-documents 'mac-apple-event-id "pdoc") ; kAEPrintDocuments
1544 (put 'open-contents 'mac-apple-event-id "ocon") ; kAEOpenContents
1545 (put 'quit-application 'mac-apple-event-id "quit") ; kAEQuitApplication
1546 (put 'application-died 'mac-apple-event-id "obit") ; kAEApplicationDied
1547 (put 'show-preferences 'mac-apple-event-id "pref") ; kAEShowPreferences
1548 (put 'autosave-now 'mac-apple-event-id "asav") ; kAEAutosaveNow
1549 ;; kAEInternetEventClass
1550 (put 'get-url 'mac-apple-event-id "GURL") ; kAEGetURL
1551 ;; Converted HI command events
1552 (put 'about 'mac-apple-event-id "abou") ; kHICommandAbout
1553 (put 'show-hide-font-panel 'mac-apple-event-id "shfp") ; kHICommandShowHideFontPanel
1555 (defmacro mac-event-spec (event)
1558 (defmacro mac-event-ae (event)
1561 (defun mac-ae-parameter (ae &optional keyword type)
1562 (or keyword (setq keyword "----")) ;; Direct object.
1563 (if (not (and (consp ae) (equal (car ae) "aevt")))
1564 (error "Not an Apple event: %S" ae)
1565 (let ((type-data (cdr (assoc keyword (cdr ae))))
1567 (when (and type type-data (not (equal type (car type-data))))
1568 (setq data (mac-coerce-ae-data (car type-data) (cdr type-data) type))
1569 (setq type-data (if data (cons type data) nil)))
1572 (defun mac-ae-list (ae &optional keyword type)
1573 (or keyword (setq keyword "----")) ;; Direct object.
1574 (let ((desc (mac-ae-parameter ae keyword "list")))
1577 ((not (equal (car desc) "list"))
1578 (error "Parameter for \"%s\" is not a list" keyword))
1584 (mac-coerce-ae-data (car type-data) (cdr type-data) type))
1587 (defun mac-ae-number (ae keyword)
1588 (let ((type-data (mac-ae-parameter ae keyword))
1591 (setq str (mac-coerce-ae-data (car type-data)
1592 (cdr type-data) "TEXT")))
1593 (let ((num (string-to-number str)))
1594 ;; Mac OS Classic may return "0e+0" as the coerced value for
1595 ;; the type "magn" and the data "\000\000\000\000".
1596 (if (= num 0.0) 0 num))
1599 (defun mac-bytes-to-integer (bytes &optional from to)
1600 (or from (setq from 0))
1601 (or to (setq to (length bytes)))
1602 (let* ((len (- to from))
1603 (extended-sign-len (- (1+ (ceiling (log most-positive-fixnum 2)))
1607 (setq result (logior (lsh result 8)
1608 (aref bytes (+ from (if (eq (byteorder) ?B) i
1610 (if (> extended-sign-len 0)
1611 (ash (lsh result extended-sign-len) (- extended-sign-len))
1614 (defun mac-ae-selection-range (ae)
1615 ;; #pragma options align=mac68k
1616 ;; typedef struct SelectionRange {
1617 ;; short unused1; // 0 (not used)
1618 ;; short lineNum; // line to select (<0 to specify range)
1619 ;; long startRange; // start of selection range (if line < 0)
1620 ;; long endRange; // end of selection range (if line < 0)
1621 ;; long unused2; // 0 (not used)
1622 ;; long theDate; // modification date/time
1623 ;; } SelectionRange;
1624 ;; #pragma options align=reset
1625 (let ((range-bytes (cdr (mac-ae-parameter ae "kpos" "TEXT"))))
1627 (list (mac-bytes-to-integer range-bytes 2 4)
1628 (mac-bytes-to-integer range-bytes 4 8)
1629 (mac-bytes-to-integer range-bytes 8 12)
1630 (mac-bytes-to-integer range-bytes 16 20)))))
1632 ;; On Mac OS X 10.4 and later, the `open-document' event contains an
1633 ;; optional parameter keyAESearchText from the Spotlight search.
1634 (defun mac-ae-text-for-search (ae)
1635 (let ((utf8-text (cdr (mac-ae-parameter ae "stxt" "utf8"))))
1637 (decode-coding-string utf8-text 'utf-8))))
1639 (defun mac-ae-text (ae)
1640 (or (cdr (mac-ae-parameter ae nil "TEXT"))
1641 (error "No text in Apple event.")))
1643 (defun mac-ae-frame (ae &optional keyword type)
1644 (let ((bytes (cdr (mac-ae-parameter ae keyword type))))
1645 (if (or (null bytes) (/= (length bytes) 4))
1646 (error "No window reference in Apple event.")
1647 (let ((window-id (mac-coerce-ae-data "long" bytes "TEXT"))
1650 (while (and (null frame) rest)
1651 (if (string= (frame-parameter (car rest) 'window-id) window-id)
1652 (setq frame (car rest)))
1653 (setq rest (cdr rest)))
1656 (defun mac-ae-script-language (ae keyword)
1657 ;; struct WritingCode {
1658 ;; ScriptCode theScriptCode;
1659 ;; LangCode theLangCode;
1661 (let ((bytes (cdr (mac-ae-parameter ae keyword "intl"))))
1663 (cons (mac-bytes-to-integer bytes 0 2)
1664 (mac-bytes-to-integer bytes 2 4)))))
1666 (defun mac-bytes-to-text-range (bytes &optional from to)
1667 ;; struct TextRange {
1670 ;; short fHiliteStyle;
1672 (or from (setq from 0))
1673 (or to (setq to (length bytes)))
1674 (and (= (- to from) (+ 4 4 2))
1675 (list (mac-bytes-to-integer bytes from (+ from 4))
1676 (mac-bytes-to-integer bytes (+ from 4) (+ from 8))
1677 (mac-bytes-to-integer bytes (+ from 8) to))))
1679 (defun mac-ae-text-range-array (ae keyword)
1680 ;; struct TextRangeArray {
1681 ;; short fNumOfRanges;
1682 ;; TextRange fRange[1];
1684 (let* ((bytes (cdr (mac-ae-parameter ae keyword "tray")))
1685 (len (length bytes))
1687 (when (and bytes (>= len 2)
1689 (setq nranges (mac-bytes-to-integer bytes 0 2))
1690 (= len (+ 2 (* nranges 10)))))
1691 (setq result (make-vector nranges nil))
1692 (dotimes (i nranges)
1694 (mac-bytes-to-text-range bytes (+ (* i 10) 2)
1698 (defconst mac-keyboard-modifier-mask-alist
1700 (lambda (modifier-bit)
1701 (cons (car modifier-bit) (lsh 1 (cdr modifier-bit))))
1702 '((command . 8) ; cmdKeyBit
1703 (shift . 9) ; shiftKeyBit
1704 (option . 11) ; optionKeyBit
1705 (control . 12) ; controlKeyBit
1706 (function . 17))) ; kEventKeyModifierFnBit
1707 "Alist of Mac keyboard modifier symbols vs masks.")
1709 (defun mac-ae-keyboard-modifiers (ae)
1710 (let ((modifiers-value (mac-ae-number ae "kmod"))
1713 (dolist (modifier-mask mac-keyboard-modifier-mask-alist)
1714 (if (/= (logand modifiers-value (cdr modifier-mask)) 0)
1715 (setq modifiers (cons (car modifier-mask) modifiers)))))
1718 (defun mac-ae-reopen-application (event)
1719 "Show some frame in response to the Apple event EVENT.
1720 The frame to be shown is chosen from visible or iconified frames
1721 if possible. If there's no such frame, a new frame is created."
1723 (unless (frame-visible-p (selected-frame))
1724 (let ((frame (or (car (visible-frame-list))
1725 (car (filtered-frame-list 'frame-visible-p)))))
1727 (select-frame frame)
1728 (switch-to-buffer-other-frame "*scratch*"))))
1729 (select-frame-set-input-focus (selected-frame)))
1731 (defun mac-ae-open-documents (event)
1732 "Open the documents specified by the Apple event EVENT."
1734 (let ((ae (mac-event-ae event)))
1735 (dolist (file-name (mac-ae-list ae nil 'undecoded-file-name))
1737 (dnd-open-local-file
1739 (mapconcat 'url-hexify-string
1740 (split-string file-name "/") "/")) nil)))
1741 (let ((selection-range (mac-ae-selection-range ae))
1742 (search-text (mac-ae-text-for-search ae)))
1743 (cond (selection-range
1744 (let ((line (car selection-range))
1745 (start (cadr selection-range))
1746 (end (nth 2 selection-range)))
1749 (if (and (> start 0) (> end 0))
1750 (progn (set-mark start)
1751 (goto-char end))))))
1752 ((stringp search-text)
1754 (mapconcat 'regexp-quote (split-string search-text) "\\|")
1756 (select-frame-set-input-focus (selected-frame)))
1758 (defun mac-ae-quit-application (event)
1759 "Quit the application Emacs with the Apple event EVENT."
1761 (let ((ae (mac-event-ae event)))
1763 (save-buffers-kill-emacs)
1764 ;; Reaches here if the user has canceled the quit.
1765 (mac-resume-apple-event ae -128)))) ; userCanceledErr
1767 (defun mac-ae-get-url (event)
1768 "Open the URL specified by the Apple event EVENT.
1769 Currently the `mailto' scheme is supported."
1771 (let* ((ae (mac-event-ae event))
1772 (parsed-url (url-generic-parse-url (mac-ae-text ae))))
1773 (if (string= (url-type parsed-url) "mailto")
1775 (url-mailto parsed-url)
1776 (select-frame-set-input-focus (selected-frame)))
1777 (mac-resume-apple-event ae t))))
1779 (setq mac-apple-event-map (make-sparse-keymap))
1781 ;; Received when Emacs is launched without associated documents.
1782 ;; Accept it as an Apple event, but no Emacs event is generated so as
1783 ;; not to erase the splash screen.
1784 (define-key mac-apple-event-map [core-event open-application] 0)
1786 ;; Received when a dock or application icon is clicked and Emacs is
1788 (define-key mac-apple-event-map [core-event reopen-application]
1789 'mac-ae-reopen-application)
1791 (define-key mac-apple-event-map [core-event open-documents]
1792 'mac-ae-open-documents)
1793 (define-key mac-apple-event-map [core-event show-preferences] 'customize)
1794 (define-key mac-apple-event-map [core-event quit-application]
1795 'mac-ae-quit-application)
1797 (define-key mac-apple-event-map [internet-event get-url] 'mac-ae-get-url)
1799 (define-key mac-apple-event-map [hi-command about] 'about-emacs)
1801 ;;; Converted Carbon Events
1802 (defun mac-handle-toolbar-switch-mode (event)
1803 "Toggle visibility of tool-bars in response to EVENT.
1804 With no keyboard modifiers, it toggles the visibility of the
1805 frame where the tool-bar toggle button was pressed. With some
1806 modifiers, it changes the global tool-bar visibility setting."
1808 (let ((ae (mac-event-ae event)))
1809 (if (mac-ae-keyboard-modifiers ae)
1810 ;; Globally toggle tool-bar-mode if some modifier key is pressed.
1811 (tool-bar-mode 'toggle)
1812 (let ((frame (mac-ae-frame ae)))
1813 (set-frame-parameter frame 'tool-bar-lines
1814 (if (= (frame-parameter frame 'tool-bar-lines) 0)
1817 ;; kEventClassWindow/kEventWindowToolbarSwitchMode
1818 (define-key mac-apple-event-map [window toolbar-switch-mode]
1819 'mac-handle-toolbar-switch-mode)
1822 (when (fboundp 'mac-set-font-panel-visible-p)
1824 (define-minor-mode mac-font-panel-mode
1825 "Toggle use of the font panel.
1826 With numeric ARG, display the font panel if and only if ARG is positive."
1830 (mac-set-font-panel-visible-p mac-font-panel-mode))
1832 (defun mac-handle-font-panel-closed (event)
1833 "Update internal status in response to font panel closed EVENT."
1835 ;; Synchronize with the minor mode variable.
1836 (mac-font-panel-mode 0))
1838 (defun mac-handle-font-selection (event)
1839 "Change default face attributes according to font selection EVENT."
1841 (let* ((ae (mac-event-ae event))
1842 (fm-font-size (mac-ae-number ae "fmsz"))
1843 (atsu-font-id (mac-ae-number ae "auid"))
1844 (attribute-values (and atsu-font-id
1845 (mac-atsu-font-face-attributes atsu-font-id))))
1847 (setq attribute-values
1848 `(:height ,(* 10 fm-font-size) ,@attribute-values)))
1849 (apply 'set-face-attribute 'default (selected-frame) attribute-values)))
1851 ;; kEventClassFont/kEventFontPanelClosed
1852 (define-key mac-apple-event-map [font panel-closed]
1853 'mac-handle-font-panel-closed)
1854 ;; kEventClassFont/kEventFontSelection
1855 (define-key mac-apple-event-map [font selection] 'mac-handle-font-selection)
1856 (define-key mac-apple-event-map [hi-command show-hide-font-panel]
1857 'mac-font-panel-mode)
1859 (define-key-after menu-bar-showhide-menu [mac-font-panel-mode]
1860 (menu-bar-make-mm-toggle mac-font-panel-mode
1862 "Show the font panel as a floating dialog")
1865 ) ;; (fboundp 'mac-set-font-panel-visible-p)
1868 (defvar mac-ts-active-input-buf ""
1869 "Byte sequence of the current Mac TSM active input area.")
1870 (defvar mac-ts-update-active-input-area-seqno 0
1871 "Number of processed update-active-input-area events.")
1872 (setq mac-ts-active-input-overlay (make-overlay 0 0))
1874 (defface mac-ts-caret-position
1875 '((t :inverse-video t))
1876 "Face for caret position in Mac TSM active input area.
1877 This is used when the active input area is displayed either in
1878 the echo area or in a buffer where the cursor is not displayed."
1881 (defface mac-ts-raw-text
1883 "Face for raw text in Mac TSM active input area."
1886 (defface mac-ts-selected-raw-text
1888 "Face for selected raw text in Mac TSM active input area."
1891 (defface mac-ts-converted-text
1892 '((((background dark)) :underline "gray20")
1893 (t :underline "gray80"))
1894 "Face for converted text in Mac TSM active input area."
1897 (defface mac-ts-selected-converted-text
1899 "Face for selected converted text in Mac TSM active input area."
1902 (defface mac-ts-block-fill-text
1904 "Face for block fill text in Mac TSM active input area."
1907 (defface mac-ts-outline-text
1909 "Face for outline text in Mac TSM active input area."
1912 (defface mac-ts-selected-text
1914 "Face for selected text in Mac TSM active input area."
1917 (defface mac-ts-no-hilite
1918 '((t :inherit default))
1919 "Face for no hilite in Mac TSM active input area."
1922 (defconst mac-ts-hilite-style-faces
1923 '((2 . mac-ts-raw-text) ; kTSMHiliteRawText
1924 (3 . mac-ts-selected-raw-text) ; kTSMHiliteSelectedRawText
1925 (4 . mac-ts-converted-text) ; kTSMHiliteConvertedText
1926 (5 . mac-ts-selected-converted-text) ; kTSMHiliteSelectedConvertedText
1927 (6 . mac-ts-block-fill-text) ; kTSMHiliteBlockFillText
1928 (7 . mac-ts-outline-text) ; kTSMHiliteOutlineText
1929 (8 . mac-ts-selected-text) ; kTSMHiliteSelectedText
1930 (9 . mac-ts-no-hilite)) ; kTSMHiliteNoHilite
1931 "Alist of Mac TSM hilite style vs Emacs face.")
1933 (defun mac-ts-update-active-input-buf (text fix-len hilite-rng update-rng)
1934 (let ((buf-len (length mac-ts-active-input-buf))
1936 (if (or (null update-rng)
1937 (/= (% (length update-rng) 2) 0))
1938 ;; The parameter is missing (or in a bad format). The
1939 ;; existing inline input session is completely replaced with
1941 (setq mac-ts-active-input-buf text)
1942 ;; Otherwise, the current subtext specified by the (2*j)-th
1943 ;; range is replaced with the new subtext specified by the
1944 ;; (2*j+1)-th range.
1945 (let ((tail buf-len)
1946 (i (length update-rng))
1950 (setq rng (aref update-rng i))
1951 (if (and (<= 0 (cadr rng)) (< (cadr rng) tail)
1954 (cons (substring mac-ts-active-input-buf (cadr rng) tail)
1956 (setq tail (car rng))
1957 (setq rng (aref update-rng (1+ i)))
1958 (if (and (<= 0 (car rng)) (< (car rng) (cadr rng))
1959 (<= (cadr rng) (length text)))
1961 (cons (substring text (car rng) (cadr rng))
1963 (if (and (< 0 tail) (<= tail buf-len))
1965 (cons (substring mac-ts-active-input-buf 0 tail)
1967 (setq mac-ts-active-input-buf (apply 'concat segments))))
1968 (setq buf-len (length mac-ts-active-input-buf))
1969 ;; Confirm (a part of) inline input session.
1970 (cond ((< fix-len 0)
1971 ;; Entire inline session is being confirmed.
1972 (setq confirmed mac-ts-active-input-buf)
1973 (setq mac-ts-active-input-buf ""))
1975 ;; None of the text is being confirmed (yet).
1976 (setq confirmed ""))
1978 (if (> fix-len buf-len)
1979 (setq fix-len buf-len))
1980 (setq confirmed (substring mac-ts-active-input-buf 0 fix-len))
1981 (setq mac-ts-active-input-buf
1982 (substring mac-ts-active-input-buf fix-len))))
1983 (setq buf-len (length mac-ts-active-input-buf))
1984 ;; Update highlighting and the caret position in the new inline
1986 (remove-text-properties 0 buf-len '(cursor nil) mac-ts-active-input-buf)
1988 (cond ((and (= (nth 2 rng) 1) ; kTSMHiliteCaretPosition
1989 (<= 0 (car rng)) (< (car rng) buf-len))
1990 (put-text-property (car rng) buf-len
1991 'cursor t mac-ts-active-input-buf))
1992 ((and (<= 0 (car rng)) (< (car rng) (cadr rng))
1993 (<= (cadr rng) buf-len))
1994 (put-text-property (car rng) (cadr rng) 'face
1995 (cdr (assq (nth 2 rng)
1996 mac-ts-hilite-style-faces))
1997 mac-ts-active-input-buf))))
2001 (defun mac-split-string-by-property-change (string)
2002 (let ((tail (length string))
2005 (while (setq head (previous-property-change tail string)
2006 result (cons (substring string (or head 0) tail) result)
2010 (defun mac-replace-untranslated-utf-8-chars (string &optional to-string)
2011 (or to-string (setq to-string "\e$,3u=\e(B"))
2014 (if (get-text-property 0 'untranslated-utf-8 str) to-string str))
2015 (mac-split-string-by-property-change string)
2018 (defun mac-keyboard-translate-char (ch)
2019 (if (and (char-valid-p ch)
2020 (or (char-table-p keyboard-translate-table)
2021 (and (or (stringp keyboard-translate-table)
2022 (vectorp keyboard-translate-table))
2023 (> (length keyboard-translate-table) ch))))
2024 (or (aref keyboard-translate-table ch) ch)
2027 (defun mac-unread-string (string)
2028 ;; Unread characters and insert them in a keyboard macro being
2030 (apply 'isearch-unread
2031 (mapcar 'mac-keyboard-translate-char
2032 (mac-replace-untranslated-utf-8-chars string))))
2034 (defun mac-ts-update-active-input-area (event)
2035 "Update Mac TSM active input area according to EVENT.
2036 The confirmed text is converted to Emacs input events and pushed
2037 into `unread-command-events'. The unconfirmed text is displayed
2038 either in the current buffer or in the echo area."
2040 (let* ((ae (mac-event-ae event))
2041 (type-text (mac-ae-parameter ae "tstx"))
2042 (text (or (cdr type-text) ""))
2043 (decode-fun (if (equal (car type-text) "TEXT")
2044 'mac-TEXT-to-string 'mac-utxt-to-string))
2045 (script-language (mac-ae-script-language ae "tssl"))
2046 (coding (or (cdr (assq (car script-language)
2047 mac-script-code-coding-systems))
2049 (fix-len (mac-ae-number ae "tsfx"))
2050 ;; Optional parameters
2051 (hilite-rng (mac-ae-text-range-array ae "tshi"))
2052 (update-rng (mac-ae-text-range-array ae "tsup"))
2053 ;;(pin-rng (mac-bytes-to-text-range (cdr (mac-ae-parameter ae "tspn" "txrn"))))
2054 ;;(clause-offsets (cdr (mac-ae-parameter ae "tscl" "ofay")))
2055 (seqno (mac-ae-number ae "tsSn"))
2057 (unless (= seqno mac-ts-update-active-input-area-seqno)
2058 ;; Reset internal states if sequence number is out of sync.
2059 (setq mac-ts-active-input-buf ""))
2061 (mac-ts-update-active-input-buf text fix-len hilite-rng update-rng))
2062 (let ((use-echo-area
2064 (and cursor-in-echo-area (current-message))
2065 ;; Overlay strings are not shown in some cases.
2066 (get-char-property (point) 'invisible)
2068 (or (and (get-char-property (point) 'display)
2069 (eq (get-char-property (1- (point)) 'display)
2070 (get-char-property (point) 'display)))
2071 (and (get-char-property (point) 'composition)
2072 (eq (get-char-property (1- (point)) 'composition)
2073 (get-char-property (point) 'composition)))))))
2074 active-input-string caret-seen)
2075 ;; Decode the active input area text with inheriting faces and
2076 ;; the caret position.
2077 (setq active-input-string
2080 (let ((decoded (funcall decode-fun str coding)))
2081 (put-text-property 0 (length decoded) 'face
2082 (get-text-property 0 'face str) decoded)
2083 (when (and (not caret-seen)
2084 (get-text-property 0 'cursor str))
2086 (if (or use-echo-area (null cursor-type))
2087 (put-text-property 0 1 'face 'mac-ts-caret-position
2089 (put-text-property 0 1 'cursor t decoded)))
2091 (mac-split-string-by-property-change mac-ts-active-input-buf)
2093 (put-text-property 0 (length active-input-string)
2094 'mac-ts-active-input-string t active-input-string)
2096 (let ((msg (current-message))
2099 ;; Don't get confused by previously displayed
2100 ;; `active-input-string'.
2101 (null (get-text-property 0 'mac-ts-active-input-string
2103 (setq msg (propertize msg 'display
2104 (concat msg active-input-string)))
2105 (setq msg active-input-string))
2107 (overlay-put mac-ts-active-input-overlay 'before-string nil))
2108 (move-overlay mac-ts-active-input-overlay
2109 (point) (point) (current-buffer))
2110 (overlay-put mac-ts-active-input-overlay 'before-string
2111 active-input-string))
2112 (mac-unread-string (funcall decode-fun confirmed coding)))
2113 ;; The event is successfully processed. Sync the sequence number.
2114 (setq mac-ts-update-active-input-area-seqno (1+ seqno))))
2116 (defun mac-ts-unicode-for-key-event (event)
2117 "Convert Unicode key EVENT to Emacs key events and unread them."
2119 (let* ((ae (mac-event-ae event))
2120 (text (cdr (mac-ae-parameter ae "tstx" "utxt")))
2121 (script-language (mac-ae-script-language ae "tssl"))
2122 (coding (or (cdr (assq (car script-language)
2123 mac-script-code-coding-systems))
2126 (mac-unread-string (mac-utxt-to-string text coding)))))
2128 ;; kEventClassTextInput/kEventTextInputUpdateActiveInputArea
2129 (define-key mac-apple-event-map [text-input update-active-input-area]
2130 'mac-ts-update-active-input-area)
2131 ;; kEventClassTextInput/kEventTextInputUnicodeForKeyEvent
2132 (define-key mac-apple-event-map [text-input unicode-for-key-event]
2133 'mac-ts-unicode-for-key-event)
2136 (defun mac-service-open-file ()
2137 "Open the file specified by the selection value for Services."
2139 (find-file-existing (x-selection-value mac-service-selection)))
2141 (defun mac-service-open-selection ()
2142 "Create a new buffer containing the selection value for Services."
2144 (switch-to-buffer (generate-new-buffer "*untitled*"))
2145 (insert (x-selection-value mac-service-selection))
2147 (save-buffer) ; It pops up the save dialog.
2150 (defun mac-service-mail-selection ()
2151 "Prepare a mail buffer containing the selection value for Services."
2156 (insert (x-selection-value mac-service-selection) "\n"))
2158 (defun mac-service-mail-to ()
2159 "Prepare a mail buffer to be sent to the selection value for Services."
2161 (compose-mail (x-selection-value mac-service-selection)))
2163 (defun mac-service-insert-text ()
2164 "Insert the selection value for Services."
2166 (let ((text (x-selection-value mac-service-selection)))
2167 (if (not buffer-read-only)
2171 (substitute-command-keys
2172 "The text from the Services menu can be accessed with \\[yank]")))))
2174 ;; kEventClassService/kEventServicePaste
2175 (define-key mac-apple-event-map [service paste] 'mac-service-insert-text)
2176 ;; kEventClassService/kEventServicePerform
2177 (define-key mac-apple-event-map [service perform open-file]
2178 'mac-service-open-file)
2179 (define-key mac-apple-event-map [service perform open-selection]
2180 'mac-service-open-selection)
2181 (define-key mac-apple-event-map [service perform mail-selection]
2182 'mac-service-mail-selection)
2183 (define-key mac-apple-event-map [service perform mail-to]
2184 'mac-service-mail-to)
2186 (defun mac-dispatch-apple-event (event)
2187 "Dispatch EVENT according to the keymap `mac-apple-event-map'."
2189 (let* ((binding (lookup-key mac-apple-event-map (mac-event-spec event)))
2190 (ae (mac-event-ae event))
2191 (service-message (and (keymapp binding)
2192 (cdr (mac-ae-parameter ae "svmg")))))
2193 (when service-message
2194 (setq service-message
2195 (intern (decode-coding-string service-message 'utf-8)))
2196 (setq binding (lookup-key binding (vector service-message))))
2197 ;; Replace (cadr event) with a dummy position so that event-start
2199 (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0))
2200 (if (null (mac-ae-parameter ae 'emacs-suspension-id))
2201 (command-execute binding nil (vector event) t)
2204 (command-execute binding nil (vector event) t)
2205 (mac-resume-apple-event ae))
2207 (mac-ae-set-reply-parameter ae "errs"
2208 (cons "TEXT" (error-message-string err)))
2209 (mac-resume-apple-event ae -10000)))))) ; errAEEventFailed
2211 (define-key special-event-map [mac-apple-event] 'mac-dispatch-apple-event)
2213 ;; Processing of Apple events are deferred at the startup time. For
2214 ;; example, files dropped onto the Emacs application icon can only be
2215 ;; processed when the initial frame has been created: this is where
2216 ;; the files should be opened.
2217 (add-hook 'after-init-hook 'mac-process-deferred-apple-events)
2219 (run-with-idle-timer 5 t 'mac-cleanup-expired-apple-events)
2224 (defcustom mac-dnd-types-alist
2225 '(("furl" . mac-dnd-handle-furl)
2226 ("hfs " . mac-dnd-handle-hfs)
2227 ("utxt" . mac-dnd-insert-utxt)
2228 ("TEXT" . mac-dnd-insert-TEXT)
2229 ("TIFF" . mac-dnd-insert-TIFF))
2230 "Which function to call to handle a drop of that type.
2231 The function takes three arguments, WINDOW, ACTION and DATA.
2232 WINDOW is where the drop occurred, ACTION is always `private' on
2233 Mac. DATA is the drop data. Unlike the x-dnd counterpart, the
2234 return value of the function is not significant.
2236 See also `mac-dnd-known-types'."
2241 (defun mac-dnd-handle-furl (window action data)
2242 (dnd-handle-one-url window action (mac-furl-to-string data)))
2244 (defun mac-dnd-handle-hfs (window action data)
2245 ;; struct HFSFlavor {
2247 ;; OSType fileCreator;
2251 (let* ((file-name (mac-coerce-ae-data "fss " (substring data 10)
2252 'undecoded-file-name))
2253 (url (concat "file://"
2254 (mapconcat 'url-hexify-string
2255 (split-string file-name "/") "/"))))
2256 (dnd-handle-one-url window action url)))
2258 (defun mac-dnd-insert-utxt (window action data)
2259 (dnd-insert-text window action (mac-utxt-to-string data)))
2261 (defun mac-dnd-insert-TEXT (window action data)
2262 (dnd-insert-text window action (mac-TEXT-to-string data)))
2264 (defun mac-dnd-insert-TIFF (window action data)
2265 (dnd-insert-text window action (mac-TIFF-to-string data)))
2267 (defun mac-dnd-drop-data (event frame window data type &optional action)
2268 (or action (setq action 'private))
2269 (let* ((type-info (assoc type mac-dnd-types-alist))
2270 (handler (cdr type-info))
2271 (w (posn-window (event-start event))))
2273 (if (and (window-live-p w)
2274 (not (window-minibuffer-p w))
2275 (not (window-dedicated-p w)))
2276 ;; If dropping in an ordinary window which we could use,
2277 ;; let dnd-open-file-other-window specify what to do.
2279 (when (not mouse-yank-at-point)
2280 (goto-char (posn-point (event-start event))))
2281 (funcall handler window action data))
2282 ;; If we can't display the file here,
2283 ;; make a new window for it.
2284 (let ((dnd-open-file-other-window t))
2285 (select-frame frame)
2286 (funcall handler window action data))))))
2288 (defun mac-dnd-handle-drag-n-drop-event (event)
2289 "Receive drag and drop events."
2291 (let ((window (posn-window (event-start event)))
2292 (ae (mac-event-ae event))
2294 (when (windowp window) (select-window window))
2295 (if (memq 'option (mac-ae-keyboard-modifiers ae))
2296 (setq action 'copy))
2297 (dolist (item (mac-ae-list ae))
2298 (if (not (equal (car item) "null"))
2299 (mac-dnd-drop-data event (selected-frame) window
2300 (cdr item) (car item) action)))))
2302 (defvar mac-font-encoder-list
2303 '(("mac-roman" mac-roman-encoder
2304 ccl-encode-mac-roman-font "%s")
2305 ("mac-centraleurroman" encode-mac-centraleurroman
2306 ccl-encode-mac-centraleurroman-font "%s ce")
2307 ("mac-cyrillic" encode-mac-cyrillic
2308 ccl-encode-mac-cyrillic-font "%s cy")
2309 ("mac-symbol" mac-symbol-encoder
2310 ccl-encode-mac-symbol-font "symbol")
2311 ("mac-dingbats" mac-dingbats-encoder
2312 ccl-encode-mac-dingbats-font "zapf dingbats")))
2315 (mapcar (lambda (lst) (nth 1 lst)) mac-font-encoder-list))
2318 latin-iso8859-3 latin-iso8859-4
2319 cyrillic-iso8859-5 greek-iso8859-7 hebrew-iso8859-8
2320 latin-iso8859-9 latin-iso8859-14 latin-iso8859-15)))
2321 (dolist (encoder encoder-list)
2322 (let ((table (get encoder 'translation-table)))
2323 (dolist (charset charset-list)
2325 (let* ((c (make-char charset (+ i 32)))
2326 (mu (aref ucs-mule-to-mule-unicode c))
2327 (mac-encoded (and mu (aref table mu))))
2329 (aset table c mac-encoded))))))))
2331 ;; We assume none of official dim2 charsets (0x90..0x99) are encoded
2334 (define-ccl-program ccl-encode-mac-roman-font
2337 (translate-character mac-roman-encoder r0 r1)
2340 (translate-character mac-roman-encoder r0 r1))))
2341 "CCL program for Mac Roman font")
2343 (define-ccl-program ccl-encode-mac-centraleurroman-font
2346 (translate-character encode-mac-centraleurroman r0 r1)
2349 (translate-character encode-mac-centraleurroman r0 r1))))
2350 "CCL program for Mac Central European Roman font")
2352 (define-ccl-program ccl-encode-mac-cyrillic-font
2355 (translate-character encode-mac-cyrillic r0 r1)
2358 (translate-character encode-mac-cyrillic r0 r1))))
2359 "CCL program for Mac Cyrillic font")
2361 (define-ccl-program ccl-encode-mac-symbol-font
2364 (translate-character mac-symbol-encoder r0 r1)
2367 (translate-character mac-symbol-encoder r0 r1))))
2368 "CCL program for Mac Symbol font")
2370 (define-ccl-program ccl-encode-mac-dingbats-font
2373 (translate-character mac-dingbats-encoder r0 r1)
2376 (translate-character mac-dingbats-encoder r0 r1))))
2377 "CCL program for Mac Dingbats font")
2380 (setq font-ccl-encoder-alist
2382 (mapcar (lambda (lst) (cons (nth 0 lst) (nth 2 lst)))
2383 mac-font-encoder-list)
2384 font-ccl-encoder-alist))
2386 (defconst mac-char-fontspec-list
2387 ;; Directly operate on a char-table instead of a fontset so that it
2388 ;; may not create a dummy fontset.
2389 (let ((template (make-char-table 'fontset)))
2393 (mapcar (lambda (lst)
2394 (cons (cons (nth 3 lst) (nth 0 lst)) (nth 1 lst)))
2395 mac-font-encoder-list)))
2396 (let ((font (car font-encoder))
2397 (encoder (cdr font-encoder)))
2401 (generic-char-p key)
2402 (memq (char-charset key)
2403 '(ascii eight-bit-control eight-bit-graphic))
2404 (aset template key font)))
2405 (get encoder 'translation-table))))
2407 ;; Like fontset-info, but extend a range only if its "to" part is
2408 ;; the predecessor of the current char.
2409 (let* ((last '((0 nil)))
2411 last-char-or-range last-char last-elt)
2415 (setq last-char-or-range (car (car last))
2416 last-char (if (consp last-char-or-range)
2417 (cdr last-char-or-range)
2419 last-elt (cdr (car last)))
2420 (if (and (eq elt last-elt)
2421 (= char (1+ last-char))
2422 (eq (char-charset char) (char-charset last-char)))
2423 (if (consp last-char-or-range)
2424 (setcdr last-char-or-range char)
2425 (setcar (car last) (cons last-char char)))
2426 (setcdr last (list (cons char elt)))
2427 (setq last (cdr last)))))
2429 (cdr accumulator))))
2431 (defun fontset-add-mac-fonts (fontset &optional base-family)
2432 "Add font-specs for Mac fonts to FONTSET.
2433 The added font-specs are determined by BASE-FAMILY and the value
2434 of `mac-char-fontspec-list', which is a list
2435 of (CHARACTER-OR-RANGE . (FAMILY-FORMAT . REGISTRY)). If
2436 BASE-FAMILY is nil, the font family in the added font-specs is
2437 also nil. If BASE-FAMILY is a string, `%s' in FAMILY-FORMAT is
2438 replaced with the string. Otherwise, `%s' in FAMILY-FORMAT is
2439 replaced with the ASCII font family name in FONTSET."
2441 (if (stringp base-family)
2442 (setq base-family (downcase base-family))
2443 (let ((ascii-font (fontset-font fontset (charset-id 'ascii))))
2446 (aref (x-decompose-font-name
2447 (downcase (x-resolve-font-name ascii-font)))
2448 xlfd-regexp-family-subnum))))))
2449 (let (fontspec-cache fontspec)
2450 (dolist (char-fontspec mac-char-fontspec-list)
2451 (setq fontspec (cdr (assq (cdr char-fontspec) fontspec-cache)))
2452 (when (null fontspec)
2454 (cons (and base-family
2455 (format (car (cdr char-fontspec)) base-family))
2456 (cdr (cdr char-fontspec))))
2457 (setq fontspec-cache (cons (cons (cdr char-fontspec) fontspec)
2459 (set-fontset-font fontset (car char-fontspec) fontspec))))
2461 (defun create-fontset-from-mac-roman-font (font &optional resolved-font
2463 "Create a fontset from a Mac roman font FONT.
2465 Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If
2466 omitted, `x-resolve-font-name' is called to get the resolved name. At
2467 this time, if FONT is not available, error is signaled.
2469 Optional 2nd arg FONTSET-NAME is a string to be used in
2470 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
2471 an appropriate name is generated automatically.
2473 It returns a name of the created fontset."
2475 (create-fontset-from-ascii-font font resolved-font fontset-name)))
2476 (fontset-add-mac-fonts fontset t)
2479 (defun x-win-suspend-error ()
2480 (error "Suspending an Emacs running under Mac makes no sense"))
2482 (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
2484 (defvar mac-initialized nil
2485 "Non-nil if the w32 window system has been initialized.")
2487 (defun mac-initialize-window-system ()
2488 "Initialize Emacs for Mac GUI frames."
2490 ;;; Do the actual Windows setup here; the above code just defines
2491 ;;; functions and variables that we use now.
2493 (setq command-line-args (x-handle-args command-line-args))
2495 ;;; Make sure we have a valid resource name.
2496 (or (stringp x-resource-name)
2498 (setq x-resource-name (invocation-name))
2500 ;; Change any . or * characters in x-resource-name to hyphens,
2501 ;; so as not to choke when we use it in X resource queries.
2502 (while (setq i (string-match "[.*]" x-resource-name))
2503 (aset x-resource-name i ?-))))
2505 (if (x-display-list)
2506 ;; On Mac OS 8/9, Most coding systems used in code conversion for
2507 ;; font names are not ready at the time when the terminal frame is
2508 ;; created. So we reconstruct font name table for the initial
2510 (mac-clear-font-name-table)
2511 (x-open-connection "Mac"
2512 x-command-line-resources
2513 ;; Exit Emacs with fatal error if this fails.
2516 (add-hook 'suspend-hook 'x-win-suspend-error)
2518 ;;; Arrange for the kill and yank functions to set and check the clipboard.
2519 (setq interprogram-cut-function 'x-select-text)
2520 (setq interprogram-paste-function 'x-get-selection-value)
2525 ;;; Turn off window-splitting optimization; Mac is usually fast enough
2526 ;;; that this is only annoying.
2527 (setq split-window-keep-point t)
2529 ;; Don't show the frame name; that's redundant.
2530 (setq-default mode-line-frame-identification " ")
2532 ;; Turn on support for mouse wheels.
2533 (mouse-wheel-mode 1)
2536 ;; Enable CLIPBOARD copy/paste through menu bar commands.
2537 (menu-bar-enable-clipboard)
2540 ;; Initiate drag and drop
2542 (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2545 ;;;; Non-toolkit Scroll bars
2547 (unless x-toolkit-scroll-bars
2550 ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
2552 ;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
2555 [vertical-scroll-bar down-mouse-1]
2556 'mac-handle-scroll-bar-event)
2558 (global-unset-key [vertical-scroll-bar drag-mouse-1])
2559 (global-unset-key [vertical-scroll-bar mouse-1])
2561 ;; Adjust Courier font specifications in x-fixed-font-alist.
2562 (let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
2564 (dolist (label-fonts (cdr courier-fonts))
2568 (if (string-match "\\`-adobe-courier-\\([^-]*\\)-\\(.\\)-\\(.*\\)-iso8859-1\\'" font)
2570 (if (string= (match-string 2 font) "o")
2571 "-*-courier-\\1-i-\\3-*-*"
2572 "-*-courier-\\1-\\2-\\3-*-*")
2575 (cdr label-fonts))))))
2577 ;; Setup the default fontset.
2578 (setup-default-fontset)
2579 (cond ((x-list-fonts "*-iso10646-1" nil nil 1)
2580 ;; Use ATSUI (if available) for the following charsets.
2582 (charset '(latin-iso8859-1
2583 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
2584 thai-tis620 greek-iso8859-7 arabic-iso8859-6
2585 hebrew-iso8859-8 cyrillic-iso8859-5
2586 latin-iso8859-9 latin-iso8859-15 latin-iso8859-14
2587 japanese-jisx0212 chinese-sisheng ipa
2588 vietnamese-viscii-lower vietnamese-viscii-upper
2589 lao ethiopic tibetan))
2590 (set-fontset-font nil charset '(nil . "iso10646-1"))))
2591 ((null (x-list-fonts "*-iso8859-1" nil nil 1))
2592 ;; Add Mac-encoding fonts unless ETL fonts are installed.
2593 (fontset-add-mac-fonts "fontset-default")))
2595 ;; Create a fontset that uses mac-roman font. With this fontset,
2596 ;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
2597 ;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
2598 (create-fontset-from-fontset-spec
2599 "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
2600 ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
2601 (fontset-add-mac-fonts "fontset-standard" t)
2603 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2604 (create-fontset-from-x-resource)
2606 ;; Try to create a fontset from a font specification which comes
2607 ;; from initial-frame-alist, default-frame-alist, or X resource.
2608 ;; A font specification in command line argument (i.e. -fn XXXX)
2609 ;; should be already in default-frame-alist as a `font'
2610 ;; parameter. However, any font specifications in site-start
2611 ;; library, user's init file (.emacs), and default.el are not
2612 ;; yet handled here.
2614 (let ((font (or (cdr (assq 'font initial-frame-alist))
2615 (cdr (assq 'font default-frame-alist))
2616 (x-get-resource "font" "Font")))
2617 xlfd-fields resolved-name)
2619 (not (query-fontset font))
2620 (setq resolved-name (x-resolve-font-name font))
2621 (setq xlfd-fields (x-decompose-font-name font)))
2622 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2623 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2624 ;; Create a fontset from FONT. The fontset name is
2625 ;; generated from FONT.
2626 (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum))
2627 (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum)))
2628 (create-fontset-from-mac-roman-font font resolved-name "startup")
2629 (create-fontset-from-ascii-font font resolved-name "startup")))))
2631 ;; Apply a geometry resource to the initial frame. Put it at the end
2632 ;; of the alist, so that anything specified on the command line takes
2634 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2638 (setq parsed (x-parse-geometry res-geometry))
2639 ;; If the resource specifies a position,
2640 ;; call the position and size "user-specified".
2641 (if (or (assq 'top parsed) (assq 'left parsed))
2642 (setq parsed (cons '(user-position . t)
2643 (cons '(user-size . t) parsed))))
2644 ;; All geometry parms apply to the initial frame.
2645 (setq initial-frame-alist (append initial-frame-alist parsed))
2646 ;; The size parms apply to all frames. Don't set it if there are
2647 ;; sizes there already (from command line).
2648 (if (and (assq 'height parsed)
2649 (not (assq 'height default-frame-alist)))
2650 (setq default-frame-alist
2651 (cons (cons 'height (cdr (assq 'height parsed)))
2652 default-frame-alist)))
2653 (if (and (assq 'width parsed)
2654 (not (assq 'width default-frame-alist)))
2655 (setq default-frame-alist
2656 (cons (cons 'width (cdr (assq 'width parsed)))
2657 default-frame-alist))))))
2659 ;; Check the reverseVideo resource.
2660 (let ((case-fold-search t))
2661 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2663 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2664 (setq default-frame-alist
2665 (cons '(reverse . t) default-frame-alist)))))
2667 (setq mac-initialized t)))
2669 (defun mac-handle-scroll-bar-event (event)
2670 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
2672 (let* ((position (event-start event))
2673 (window (nth 0 position))
2674 (bar-part (nth 4 position)))
2675 (select-window window)
2678 (goto-char (window-start window))
2679 (mac-scroll-down-line))
2680 ((eq bar-part 'above-handle)
2682 ((eq bar-part 'handle)
2683 (scroll-bar-drag event))
2684 ((eq bar-part 'below-handle)
2686 ((eq bar-part 'down)
2687 (goto-char (window-start window))
2688 (mac-scroll-up-line)))))
2690 (defun mac-scroll-ignore-events ()
2691 ;; Ignore confusing non-mouse events
2692 (while (not (memq (car-safe (read-event))
2693 '(mouse-1 double-mouse-1 triple-mouse-1))) nil))
2695 (defun mac-scroll-down ()
2697 (mac-scroll-ignore-events)
2700 (defun mac-scroll-down-line ()
2702 (mac-scroll-ignore-events)
2705 (defun mac-scroll-up ()
2707 (mac-scroll-ignore-events)
2710 (defun mac-scroll-up-line ()
2712 (mac-scroll-ignore-events)
2719 (unless (eq system-type 'darwin)
2720 ;; This variable specifies the Unix program to call (as a process) to
2721 ;; determine the amount of free space on a file system (defaults to
2722 ;; df). If it is not set to nil, ls-lisp will not work correctly
2723 ;; unless an external application df is implemented on the Mac.
2724 (setq directory-free-space-program nil)
2726 ;; Set this so that Emacs calls subprocesses with "sh" as shell to
2727 ;; expand filenames Note no subprocess for the shell is actually
2728 ;; started (see run_mac_command in sysdep.c).
2729 (setq shell-file-name "sh")
2731 ;; Some system variables are encoded with the system script code.
2732 (dolist (v '(system-name
2733 emacs-build-system ; Mac OS 9 version cannot dump
2734 user-login-name user-real-login-name user-full-name))
2735 (set v (decode-coding-string (symbol-value v) mac-system-coding-system))))
2737 ;; Now the default directory is changed to the user's home directory
2738 ;; in emacs.c if invoked from the WindowServer (with -psn_* option).
2739 ;; (if (string= default-directory "/")
2742 ;; Darwin 6- pty breakage is now controlled from the C code so that
2743 ;; it applies to all builds on darwin. See s/darwin.h PTY_ITERATION.
2744 ;; (setq process-connection-type t)
2746 ;; Assume that fonts are always scalable on the Mac. This sometimes
2747 ;; results in characters with jagged edges. However, without it,
2748 ;; fonts with both truetype and bitmap representations but no italic
2749 ;; or bold bitmap versions will not display these variants correctly.
2750 (setq scalable-fonts-allowed t)
2752 (add-to-list 'handle-args-function-alist '(mac . x-handle-args))
2753 (add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
2754 (add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
2758 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
2759 ;;; mac-win.el ends here