]> code.delx.au - gnu-emacs/blobdiff - lisp/term/mac-win.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / term / mac-win.el
index c9c13c7814e5b7c217b796b68e6c4476f6206adf..60f27052892edf6a259b3743a64cb207275145df 100644 (file)
@@ -1,4 +1,4 @@
-;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: iso-2022-7bit;-*-
+;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: utf-8-*-
 
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -65,8 +65,8 @@
 ;; An alist of X options and the function which handles them.  See
 ;; ../startup.el.
 
-(if (not (eq window-system 'mac))
-    (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
+;; (if (not (eq window-system 'mac))
+;;     (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
 
 (require 'frame)
 (require 'mouse)
 (defvar mac-font-panel-mode)
 (defvar mac-ts-active-input-overlay)
 (defvar x-invocation-args)
+(declare-function mac-code-convert-string "mac.c")
+(declare-function mac-coerce-ae-data "mac.c")
+(declare-function mac-resume-apple-event "macselect.c")
+;; Suppress warning when compiling on non-Mac.
+(declare-function mac-font-panel-mode "mac-win.el")
+(declare-function mac-atsu-font-face-attributes "macfns.c")
+(declare-function mac-ae-set-reply-parameter "macselect.c")
+(declare-function mac-clear-font-name-table "macfns.c")
 
 (defvar x-command-line-resources nil)
 
@@ -1058,25 +1066,31 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
 \f
 ;;;; Function keys
 
-(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
-                          global-map)
-
-;; Map certain keypad keys into ASCII characters
-;; that people usually expect.
-(define-key function-key-map [backspace] [?\d])
-(define-key function-key-map [delete] [?\d])
-(define-key function-key-map [tab] [?\t])
-(define-key function-key-map [linefeed] [?\n])
-(define-key function-key-map [clear] [?\C-l])
-(define-key function-key-map [return] [?\C-m])
-(define-key function-key-map [escape] [?\e])
-(define-key function-key-map [M-backspace] [?\M-\d])
-(define-key function-key-map [M-delete] [?\M-\d])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [M-linefeed] [?\M-\n])
-(define-key function-key-map [M-clear] [?\M-\C-l])
-(define-key function-key-map [M-return] [?\M-\C-m])
-(define-key function-key-map [M-escape] [?\M-\e])
+(defun x-setup-function-keys (frame)
+  "Setup Function Keys for mac."
+  ;; Don't do this twice on the same display, or it would break
+  ;; normal-erase-is-backspace-mode.
+  (unless (terminal-parameter frame 'x-setup-function-keys)
+    (with-selected-frame frame
+      ;; Map certain keypad keys into ASCII characters
+      ;; that people usually expect.
+      (define-key local-function-key-map [backspace] [?\d])
+      (define-key local-function-key-map [delete] [?\d])
+      (define-key local-function-key-map [tab] [?\t])
+      (define-key local-function-key-map [linefeed] [?\n])
+      (define-key local-function-key-map [clear] [?\C-l])
+      (define-key local-function-key-map [return] [?\C-m])
+      (define-key local-function-key-map [escape] [?\e])
+      (define-key local-function-key-map [M-backspace] [?\M-\d])
+      (define-key local-function-key-map [M-delete] [?\M-\d])
+      (define-key local-function-key-map [M-tab] [?\M-\t])
+      (define-key local-function-key-map [M-linefeed] [?\M-\n])
+      (define-key local-function-key-map [M-clear] [?\M-\C-l])
+      (define-key local-function-key-map [M-return] [?\M-\C-m])
+      (define-key local-function-key-map [M-escape] [?\M-\e])
+      (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
+                                local-function-key-map global-map))
+    (set-terminal-parameter frame 'x-setup-function-keys t)))
 
 ;; These tell read-char how to convert
 ;; these special chars to ASCII.
@@ -1129,95 +1143,145 @@ correspoinding TextEncodingBase value."
 (mac-add-charset-info "mac-dingbats" 34)
 (mac-add-charset-info "iso10646-1" 126) ; for ATSUI
 
-(cp-make-coding-system
- mac-centraleurroman
- [?\\e,AD\e(B ?\\e$,1  \e(B ?\\e$,1 !\e(B ?\\e,AI\e(B ?\\e$,1 $\e(B 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\e$,1(!\e(B ?\\e$,1(q\e(B ?\\e$,1(o\e(B
-  ?\\e$,1(P\e(B ?\\e$,1(Q\e(B ?\\e$,1(R\e(B ?\\e$,1(S\e(B ?\\e$,1(T\e(B ?\\e$,1(U\e(B ?\\e$,1(V\e(B ?\\e$,1(W\e(B ?\\e$,1(X\e(B ?\\e$,1(Y\e(B ?\\e$,1(Z\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 ?\\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$,1tL\e(B]
- "Mac Cyrillic Encoding (MIME:x-mac-cyrillic).")
-(coding-system-put 'mac-cyrillic 'mime-charset 'x-mac-cyrillic)
-
-(let
-    ((encoding-vector
-      (vconcat
-       (make-vector 32 nil)
-       ;; mac-symbol (32..126) -> emacs-mule mapping
-       [?\  ?\! ?\\e$,1x \e(B ?\# ?\\e$,1x#\e(B ?\% ?\& ?\\e$,1x-\e(B ?\( ?\) ?\\e$,1x7\e(B ?\+ ?\, ?\\e$,1x2\e(B ?\. ?\/
-       ?\0 ?\1 ?\2 ?\3 ?\4 ?\5 ?\6 ?\7 ?\8 ?\9 ?\: ?\; ?\< ?\= ?\> ?\?
-       ?\\e$,1xe\e(B ?\\e$,1&q\e(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&\7f\e(B
-       ?\\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 ?\_
-       ?\\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
-       ?\\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]
-       (make-vector (- 160 127) nil)
-       ;; mac-symbol (160..254) -> emacs-mule mapping
-       ;; Mapping of the following characters are changed from the
-       ;; original one:
-       ;; 0xE2 0x00AE+0xF87F -> 0x00AE # REGISTERED SIGN, alternate: sans serif
-       ;; 0xE3 0x00A9+0xF87F -> 0x00A9 # COPYRIGHT SIGN, alternate: sans serif
-       ;; 0xE4 0x2122+0xF87F -> 0x2122 # TRADE MARK SIGN, alternate: sans serif
-       [?\\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#`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(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
-       nil]))
-     translation-table)
-  (setq translation-table
-       (make-translation-table-from-vector encoding-vector))
-;;  (define-translation-table 'mac-symbol-decoder translation-table)
-  (define-translation-table 'mac-symbol-encoder
-    (char-table-extra-slot translation-table 0)))
-
-(let
-    ((encoding-vector
-      (vconcat
-       (make-vector 32 nil)
-       ;; mac-dingbats (32..126) -> emacs-mule mapping
-       [?\  ?\\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
-       ?\\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
-       ?\\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 ?\\e$,2%f\e(B ?\\e$,2%g\e(B ?\\e$,2"e\e(B ?\\e$,2%i\e(B ?\\e$,2%j\e(B ?\\e$,2%k\e(B ?\\e$,2%l\e(B ?\\e$,2%m\e(B ?\\e$,2%n\e(B ?\\e$,2%o\e(B
-       ?\\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%\7f\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 ?\\e$,2&/\e(B
-       ?\\e$,2&0\e(B ?\\e$,2&1\e(B ?\\e$,2&2\e(B ?\\e$,2!r\e(B ?\\e$,2!|\e(B ?\\e$,2"&\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
-       nil
-       ;; mac-dingbats (128..141) -> emacs-mule mapping
-       ?\\e$,2&H\e(B ?\\e$,2&I\e(B ?\\e$,2&J\e(B ?\\e$,2&K\e(B ?\\e$,2&L\e(B ?\\e$,2&M\e(B ?\\e$,2&N\e(B ?\\e$,2&O\e(B ?\\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]
-       (make-vector (- 161 142) nil)
-       ;; mac-dingbats (161..239) -> emacs-mule mapping
-       [?\\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 ?\\e$,2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(B ?\\e$,2'/\e(B
-       nil
-       ;; mac-dingbats (241..254) -> emacs-mule mapping
-       ?\\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
-       nil]))
-     translation-table)
-  (setq translation-table
-       (make-translation-table-from-vector encoding-vector))
-;;  (define-translation-table 'mac-dingbats-decoder translation-table)
-  (define-translation-table 'mac-dingbats-encoder
-    (char-table-extra-slot translation-table 0)))
+(define-charset 'mac-centraleurroman
+  "Mac Central European Roman"
+  :short-name "Mac CE"
+  :ascii-compatible-p t
+  :code-space [0 255]
+  :map
+  (let ((tbl
+        [?\Ä ?\Ā ?\ā ?\É ?\Ą ?\Ö ?\Ü ?\á ?\ą ?\Č ?\ä ?\č ?\Ć ?\ć ?\é ?\Ź
+         ?\ź ?\Ď ?\í ?\ď ?\Ē ?\ē ?\Ė ?\ó ?\ė ?\ô ?\ö ?\õ ?\ú ?\Ě ?\ě ?\ü
+         ?\† ?\° ?\Ę ?\£ ?\§ ?\• ?\¶ ?\ß ?\® ?\© ?\™ ?\ę ?\¨ ?\≠ ?\ģ ?\Į
+         ?\į ?\Ī ?\≤ ?\≥ ?\ī ?\Ķ ?\∂ ?\∑ ?\ł ?\Ļ ?\ļ ?\Ľ ?\ľ ?\Ĺ ?\ĺ ?\Ņ
+         ?\ņ ?\Ń ?\¬ ?\√ ?\ń ?\Ň ?\∆ ?\« ?\» ?\… ?\  ?\ň ?\Ő ?\Õ ?\ő ?\Ō
+         ?\– ?\— ?\“ ?\” ?\‘ ?\’ ?\÷ ?\◊ ?\ō ?\Ŕ ?\ŕ ?\Ř ?\‹ ?\› ?\ř ?\Ŗ
+         ?\ŗ ?\Š ?\‚ ?\„ ?\š ?\Ś ?\ś ?\Á ?\Ť ?\ť ?\Í ?\Ž ?\ž ?\Ū ?\Ó ?\Ô
+         ?\ū ?\Ů ?\Ú ?\ů ?\Ű ?\ű ?\Ų ?\ų ?\Ý ?\ý ?\ķ ?\Ż ?\Ł ?\ż ?\Ģ ?\ˇ])
+       (map (make-vector 512 nil)))
+    (or (= (length tbl) 128)
+       (error "Invalid vector length: %d" (length tbl)))
+    (dotimes (i 128)
+      (aset map (* i 2) i)
+      (aset map (1+ (* i 2)) i))
+    (dotimes (i 128)
+      (aset map (+ 256 (* i 2)) (+ 128 i))
+      (aset map (+ 256 (1+ (* i 2))) (aref tbl i)))
+    map))
+
+(define-coding-system 'mac-centraleurroman
+  "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman)."
+  :coding-type 'charset
+  :mnemonic ?*
+  :charset-list '(mac-centraleurroman)
+  :mime-charset 'x-mac-centraleurroman)
+
+(define-charset 'mac-cyrillic
+  "Mac Cyrillic"
+  :short-name "Mac CYRILLIC"
+  :ascii-compatible-p t
+  :code-space [0 255]
+  :map
+  (let ((tbl
+        [?\А ?\Б ?\В ?\Г ?\Д ?\Е ?\Ж ?\З ?\И ?\Й ?\К ?\Л ?\М ?\Н ?\О ?\П
+         ?\Р ?\С ?\Т ?\У ?\Ф ?\Х ?\Ц ?\Ч ?\Ш ?\Щ ?\Ъ ?\Ы ?\Ь ?\Э ?\Ю ?\Я
+         ?\† ?\° ?\Ґ ?\£ ?\§ ?\• ?\¶ ?\І ?\® ?\© ?\™ ?\Ђ ?\ђ ?\≠ ?\Ѓ ?\ѓ
+         ?\∞ ?\± ?\≤ ?\≥ ?\і ?\µ ?\ґ ?\Ј ?\Є ?\є ?\Ї ?\ї ?\Љ ?\љ ?\Њ ?\њ
+         ?\ј ?\Ѕ ?\¬ ?\√ ?\ƒ ?\≈ ?\∆ ?\« ?\» ?\… ?\  ?\Ћ ?\ћ ?\Ќ ?\ќ ?\ѕ
+         ?\– ?\— ?\“ ?\” ?\‘ ?\’ ?\÷ ?\„ ?\Ў ?\ў ?\Џ ?\џ ?\№ ?\Ё ?\ё ?\я
+         ?\а ?\б ?\в ?\г ?\д ?\е ?\ж ?\з ?\и ?\й ?\к ?\л ?\м ?\н ?\о ?\п
+         ?\р ?\с ?\т ?\у ?\ф ?\х ?\ц ?\ч ?\ш ?\щ ?\ъ ?\ы ?\ь ?\э ?\ю ?\€])
+       (map (make-vector 512 nil)))
+    (or (= (length tbl) 128)
+       (error "Invalid vector length: %d" (length tbl)))
+    (dotimes (i 128)
+      (aset map (* i 2) i)
+      (aset map (1+ (* i 2)) i))
+    (dotimes (i 128)
+      (aset map (+ 256 (* i 2)) (+ 128 i))
+      (aset map (+ 256 (1+ (* i 2))) (aref tbl i)))
+    map))
+
+(define-coding-system 'mac-cyrillic
+  "Mac Cyrillic Encoding (MIME:x-mac-cyrillic)."
+  :coding-type 'charset
+  :mnemonic ?*
+  :charset-list '(mac-cyrillic)
+  :mime-charset 'x-mac-cyrillic)
+
+(define-charset 'mac-symbol
+  "Mac Symbol"
+  :short-name "Mac SYMBOL"
+  :code-space [32 254]
+  :map
+  (let ((tbl-32-126
+        [?\  ?\! ?\∀ ?\# ?\∃ ?\% ?\& ?\∍ ?\( ?\) ?\∗ ?\+ ?\, ?\− ?\. ?\/
+         ?\0 ?\1 ?\2 ?\3 ?\4 ?\5 ?\6 ?\7 ?\8 ?\9 ?\: ?\; ?\< ?\= ?\> ?\?
+         ?\≅ ?\Α ?\Β ?\Χ ?\Δ ?\Ε ?\Φ ?\Γ ?\Η ?\Ι ?\ϑ ?\Κ ?\Λ ?\Μ ?\Ν ?\Ο
+         ?\Π ?\Θ ?\Ρ ?\Σ ?\Τ ?\Υ ?\ς ?\Ω ?\Ξ ?\Ψ ?\Ζ ?\[ ?\∴ ?\] ?\⊥ ?\_
+         ?\ ?\α ?\β ?\χ ?\δ ?\ε ?\φ ?\γ ?\η ?\ι ?\ϕ ?\κ ?\λ ?\μ ?\ν ?\ο
+         ?\π ?\θ ?\ρ ?\σ ?\τ ?\υ ?\ϖ ?\ω ?\ξ ?\ψ ?\ζ ?\{ ?\| ?\} ?\∼])
+       (map-32-126 (make-vector (* (1+ (- 126 32)) 2) nil))
+       (tbl-160-254
+        ;; Mapping of the following characters are changed from the
+        ;; original one:
+        ;; 0xE2 0x00AE+0xF87F->0x00AE # REGISTERED SIGN, alternate: sans serif
+        ;; 0xE3 0x00A9+0xF87F->0x00A9 # COPYRIGHT SIGN, alternate: sans serif
+        ;; 0xE4 0x2122+0xF87F->0x2122 # TRADE MARK SIGN, alternate: sans serif
+        [?\€ ?\ϒ ?\′ ?\≤ ?\⁄ ?\∞ ?\ƒ ?\♣ ?\♦ ?\♥ ?\♠ ?\↔ ?\← ?\↑ ?\→ ?\↓
+         ?\° ?\± ?\″ ?\≥ ?\× ?\∝ ?\∂ ?\• ?\÷ ?\≠ ?\≡ ?\≈ ?\… ?\⏐ ?\⎯ ?\↵
+         ?\ℵ ?\ℑ ?\ℜ ?\℘ ?\⊗ ?\⊕ ?\∅ ?\∩ ?\∪ ?\⊃ ?\⊇ ?\⊄ ?\⊂ ?\⊆ ?\∈ ?\∉
+         ?\∠ ?\∇ ?\® ?\© ?\™ ?\∏ ?\√ ?\⋅ ?\¬ ?\∧ ?\∨ ?\⇔ ?\⇐ ?\⇑ ?\⇒ ?\⇓
+         ?\◊ ?\〈 ?\® ?\© ?\™ ?\∑ ?\⎛ ?\⎜ ?\⎝ ?\⎡ ?\⎢ ?\⎣ ?\⎧ ?\⎨ ?\⎩ ?\⎪
+         ?\ ?\〉 ?\∫ ?\⌠ ?\⎮ ?\⌡ ?\⎞ ?\⎟ ?\⎠ ?\⎤ ?\⎥ ?\⎦ ?\⎫ ?\⎬ ?\⎭])
+       (map-160-254 (make-vector (* (1+ (- 254 160)) 2) nil)))
+    (dotimes (i (1+ (- 126 32)))
+      (aset map-32-126 (* i 2) (+ 32 i))
+      (aset map-32-126 (1+ (* i 2)) (aref tbl-32-126 i)))
+    (dotimes (i (1+ (- 254 160)))
+      (aset map-160-254 (* i 2) (+ 160 i))
+      (aset map-160-254 (1+ (* i 2)) (aref tbl-160-254 i)))
+    (vconcat map-32-126 map-160-254)))
+
+(define-charset 'mac-dingbats
+  "Mac Dingbats"
+  :short-name "Mac Dingbats"
+  :code-space [32 254]
+  :map
+  (let ((tbl-32-126
+        [?\  ?\✁ ?\✂ ?\✃ ?\✄ ?\☎ ?\✆ ?\✇ ?\✈ ?\✉ ?\☛ ?\☞ ?\✌ ?\✍ ?\✎ ?\✏
+         ?\✐ ?\✑ ?\✒ ?\✓ ?\✔ ?\✕ ?\✖ ?\✗ ?\✘ ?\✙ ?\✚ ?\✛ ?\✜ ?\✝ ?\✞ ?\✟
+         ?\✠ ?\✡ ?\✢ ?\✣ ?\✤ ?\✥ ?\✦ ?\✧ ?\★ ?\✩ ?\✪ ?\✫ ?\✬ ?\✭ ?\✮ ?\✯
+         ?\✰ ?\✱ ?\✲ ?\✳ ?\✴ ?\✵ ?\✶ ?\✷ ?\✸ ?\✹ ?\✺ ?\✻ ?\✼ ?\✽ ?\✾ ?\✿
+         ?\❀ ?\❁ ?\❂ ?\❃ ?\❄ ?\❅ ?\❆ ?\❇ ?\❈ ?\❉ ?\❊ ?\❋ ?\● ?\❍ ?\■ ?\❏
+         ?\❐ ?\❑ ?\❒ ?\▲ ?\▼ ?\◆ ?\❖ ?\◗ ?\❘ ?\❙ ?\❚ ?\❛ ?\❜ ?\❝ ?\❞])
+       (map-32-126 (make-vector (* (1+ (- 126 32)) 2) nil))
+       (tbl-128-141
+        [?\❨ ?\❩ ?\❪ ?\❫ ?\❬ ?\❭ ?\❮ ?\❯ ?\❰ ?\❱ ?\❲ ?\❳ ?\❴ ?\❵])
+       (map-128-141 (make-vector (* (1+ (- 141 128)) 2) nil))
+       (tbl-161-239
+        [?\❡ ?\❢ ?\❣ ?\❤ ?\❥ ?\❦ ?\❧ ?\♣ ?\♦ ?\♥ ?\♠ ?\① ?\② ?\③ ?\④
+         ?\⑤ ?\⑥ ?\⑦ ?\⑧ ?\⑨ ?\⑩ ?\❶ ?\❷ ?\❸ ?\❹ ?\❺ ?\❻ ?\❼ ?\❽ ?\❾ ?\❿
+         ?\➀ ?\➁ ?\➂ ?\➃ ?\➄ ?\➅ ?\➆ ?\➇ ?\➈ ?\➉ ?\➊ ?\➋ ?\➌ ?\➍ ?\➎ ?\➏
+         ?\➐ ?\➑ ?\➒ ?\➓ ?\➔ ?\→ ?\↔ ?\↕ ?\➘ ?\➙ ?\➚ ?\➛ ?\➜ ?\➝ ?\➞ ?\➟
+         ?\➠ ?\➡ ?\➢ ?\➣ ?\➤ ?\➥ ?\➦ ?\➧ ?\➨ ?\➩ ?\➪ ?\➫ ?\➬ ?\➭ ?\➮ ?\➯])
+       (map-161-239 (make-vector (* (1+ (- 239 161)) 2) nil))
+       (tbl-241-254
+        [?\➱ ?\➲ ?\➳ ?\➴ ?\➵ ?\➶ ?\➷ ?\➸ ?\➹ ?\➺ ?\➻ ?\➼ ?\➽ ?\➾])
+       (map-241-254 (make-vector (* (1+ (- 254 241)) 2) nil)))
+    (dotimes (i (1+ (- 126 32)))
+      (aset map-32-126 (* i 2) (+ 32 i))
+      (aset map-32-126 (1+ (* i 2)) (aref tbl-32-126 i)))
+    (dotimes (i (1+ (- 141 128)))
+      (aset map-128-141 (* i 2) (+ 128 i))
+      (aset map-128-141 (1+ (* i 2)) (aref tbl-128-141 i)))
+    (dotimes (i (1+ (- 239 161)))
+      (aset map-161-239 (* i 2) (+ 161 i))
+      (aset map-161-239 (1+ (* i 2)) (aref tbl-161-239 i)))
+    (dotimes (i (1+ (- 254 241)))
+      (aset map-241-254 (* i 2) (+ 241 i))
+      (aset map-241-254 (1+ (* i 2)) (aref tbl-241-254 i)))
+    (vconcat map-32-126 map-128-141 map-161-239 map-241-254)))
 
 (defconst mac-system-coding-system
   (let ((base (or (cdr (assq mac-system-script-code
@@ -1271,7 +1335,7 @@ correspoinding TextEncodingBase value."
              (setq str nil)
            ;; ASCII-only?
            (unless (mac-code-convert-string data nil mac-text-encoding-ascii)
-             (subst-char-in-string ?\x5c ?\\e(J\\e(B str t)
+             (subst-char-in-string ?\x5c ?\¥ str t)
              (subst-char-in-string ?\x80 ?\\ str t)))))
     (or str
        (decode-coding-string data
@@ -1290,7 +1354,7 @@ correspoinding TextEncodingBase value."
                   (eq coding-system 'japanese-shift-jis-mac))
          (setq encoding mac-text-encoding-mac-japanese-basic-variant)
          (setq str (subst-char-in-string ?\\ ?\x80 str))
-         (subst-char-in-string ?\\e(J\\e(B ?\x5c str t)
+         (subst-char-in-string ?\¥ ?\x5c str t)
          ;; ASCII-only?
          (if (string-match "\\`[\x00-\x7f]*\\'" str)
              (setq str nil)))
@@ -1306,7 +1370,7 @@ correspoinding TextEncodingBase value."
   (or coding-system (setq coding-system mac-system-coding-system))
   (prog1 (setq data (decode-coding-string data coding-system))
     (when (eq (coding-system-base coding-system) 'japanese-shift-jis)
-      ;; (subst-char-in-string ?\x5c ?\\e(J\\e(B data t)
+      ;; (subst-char-in-string ?\x5c ?\¥ data t)
       (subst-char-in-string ?\x80 ?\\ data t))))
 
 (defun mac-string-to-TEXT (string &optional coding-system)
@@ -1322,7 +1386,7 @@ correspoinding TextEncodingBase value."
        (coding-system-change-eol-conversion coding-system 'mac))
   (when (eq coding-system 'japanese-shift-jis-mac)
     ;; (setq string (subst-char-in-string ?\\ ?\x80 string))
-    (setq string (subst-char-in-string ?\\e(J\\e(B ?\x5c string)))
+    (setq string (subst-char-in-string ?\¥ ?\x5c string)))
   (encode-coding-string string coding-system))
 
 (defun mac-furl-to-string (data)
@@ -1758,6 +1822,9 @@ if possible.  If there's no such frame, a new frame is created."
       ;; Reaches here if the user has canceled the quit.
       (mac-resume-apple-event ae -128)))) ; userCanceledErr
 
+;; url-generic-parse-url is autoloaded from url-parse.
+(declare-function url-type "url-parse" t t) ; defstruct
+
 (defun mac-ae-get-url (event)
   "Open the URL specified by the Apple event EVENT.
 Currently the `mailto' scheme is supported."
@@ -2010,7 +2077,7 @@ the echo area or in a buffer where the cursor is not displayed."
    ""))
 
 (defun mac-keyboard-translate-char (ch)
-  (if (and (char-valid-p ch)
+  (if (and (characterp ch)
           (or (char-table-p keyboard-translate-table)
               (and (or (stringp keyboard-translate-table)
                        (vectorp keyboard-translate-table))
@@ -2163,7 +2230,7 @@ either in the current buffer or in the echo area."
     (if (not buffer-read-only)
        (insert text)
       (kill-new text)
-      (message
+      (message "%s"
        (substitute-command-keys
        "The text from the Services menu can be accessed with \\[yank]")))))
 
@@ -2295,6 +2362,57 @@ See also `mac-dnd-known-types'."
          (mac-dnd-drop-data event (selected-frame) window
                             (cdr item) (car item) action)))))
 \f
+(setq font-encoding-alist
+      (append
+       '(("mac-roman" . mac-roman)
+        ("mac-centraleurroman" . mac-centraleurroman)
+        ("mac-cyrillic" . mac-cyrillic)
+        ("mac-symbol" . mac-symbol)
+        ("mac-dingbats" . mac-dingbats))
+       font-encoding-alist))
+
+(defun fontset-add-mac-fonts (fontset &optional base-family)
+  (dolist (elt `((latin . (,(or base-family "Monaco") . "mac-roman"))
+                (mac-roman . (,base-family . "mac-roman"))
+                (mac-centraleurroman . (,base-family . "mac-centraleurroman"))
+                (mac-cyrillic . (,base-family . "mac-cyrillic"))
+                (mac-symbol . (,base-family . "mac-symbol"))
+                (mac-dingbats . (,base-family . "mac-dingbats"))))
+    (set-fontset-font fontset (car elt) (cdr elt))))
+
+(defun create-fontset-from-mac-roman-font (font &optional resolved-font
+                                               fontset-name)
+  "Create a fontset from a Mac roman font FONT.
+
+Optional 1st arg RESOLVED-FONT is a resolved name of FONT.  If
+omitted, `x-resolve-font-name' is called to get the resolved name.  At
+this time, if FONT is not available, error is signaled.
+
+Optional 2nd arg FONTSET-NAME is a string to be used in
+`<CHARSET_ENCODING>' fields of a new fontset name.  If it is omitted,
+an appropriate name is generated automatically.
+
+It returns a name of the created fontset."
+  (or resolved-font
+      (setq resolved-font (x-resolve-font-name font)))
+  (let ((base-family (aref (x-decompose-font-name resolved-font)
+                          xlfd-regexp-family-subnum)))
+    (if (string= base-family "*")
+       (setq base-family nil))
+    (new-fontset fontset-name (list (cons 'ascii resolved-font)))
+    (fontset-add-mac-fonts fontset-name base-family)))
+
+(defun x-win-suspend-error ()
+  (error "Suspending an Emacs running under Mac makes no sense"))
+
+(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
+
+(defvar mac-initialized nil
+  "Non-nil if the w32 window system has been initialized.")
+
+(defun mac-initialize-window-system ()
+  "Initialize Emacs for Mac GUI frames."
+
 ;;; Do the actual Windows setup here; the above code just defines
 ;;; functions and variables that we use now.
 
@@ -2321,184 +2439,50 @@ See also `mac-dnd-known-types'."
                     ;; Exit Emacs with fatal error if this fails.
                     t))
 
-(setq frame-creation-function 'x-create-frame-with-faces)
-
-(defvar mac-font-encoder-list
-  '(("mac-roman" mac-roman-encoder
-     ccl-encode-mac-roman-font "%s")
-    ("mac-centraleurroman" encode-mac-centraleurroman
-     ccl-encode-mac-centraleurroman-font "%s ce")
-    ("mac-cyrillic" encode-mac-cyrillic
-     ccl-encode-mac-cyrillic-font "%s cy")
-    ("mac-symbol" mac-symbol-encoder
-     ccl-encode-mac-symbol-font "symbol")
-    ("mac-dingbats" mac-dingbats-encoder
-     ccl-encode-mac-dingbats-font "zapf dingbats")))
-
-(let ((encoder-list
-       (mapcar (lambda (lst) (nth 1 lst)) mac-font-encoder-list))
-      (charset-list
-       '(latin-iso8859-2
-        latin-iso8859-3 latin-iso8859-4
-        cyrillic-iso8859-5 greek-iso8859-7 hebrew-iso8859-8
-        latin-iso8859-9 latin-iso8859-14 latin-iso8859-15)))
-  (dolist (encoder encoder-list)
-    (let ((table (get encoder 'translation-table)))
-      (dolist (charset charset-list)
-       (dotimes (i 96)
-         (let* ((c (make-char charset (+ i 32)))
-                (mu (aref ucs-mule-to-mule-unicode c))
-                (mac-encoded (and mu (aref table mu))))
-           (if mac-encoded
-               (aset table c mac-encoded))))))))
-
-;; We assume none of official dim2 charsets (0x90..0x99) are encoded
-;; to these fonts.
-
-(define-ccl-program ccl-encode-mac-roman-font
-  `(0
-    (if (r0 <= ?\xef)
-       (translate-character mac-roman-encoder r0 r1)
-      ((r1 <<= 7)
-       (r1 |= r2)
-       (translate-character mac-roman-encoder r0 r1))))
-  "CCL program for Mac Roman font")
-
-(define-ccl-program ccl-encode-mac-centraleurroman-font
-  `(0
-    (if (r0 <= ?\xef)
-       (translate-character encode-mac-centraleurroman r0 r1)
-      ((r1 <<= 7)
-       (r1 |= r2)
-       (translate-character encode-mac-centraleurroman r0 r1))))
-  "CCL program for Mac Central European Roman font")
-
-(define-ccl-program ccl-encode-mac-cyrillic-font
-  `(0
-    (if (r0 <= ?\xef)
-       (translate-character encode-mac-cyrillic r0 r1)
-      ((r1 <<= 7)
-       (r1 |= r2)
-       (translate-character encode-mac-cyrillic r0 r1))))
-  "CCL program for Mac Cyrillic font")
-
-(define-ccl-program ccl-encode-mac-symbol-font
-  `(0
-    (if (r0 <= ?\xef)
-       (translate-character mac-symbol-encoder r0 r1)
-      ((r1 <<= 7)
-       (r1 |= r2)
-       (translate-character mac-symbol-encoder r0 r1))))
-  "CCL program for Mac Symbol font")
-
-(define-ccl-program ccl-encode-mac-dingbats-font
-  `(0
-    (if (r0 <= ?\xef)
-       (translate-character mac-dingbats-encoder r0 r1)
-      ((r1 <<= 7)
-       (r1 |= r2)
-       (translate-character mac-dingbats-encoder r0 r1))))
-  "CCL program for Mac Dingbats font")
-
-
-(setq font-ccl-encoder-alist
-      (nconc
-       (mapcar (lambda (lst) (cons (nth 0 lst) (nth 2 lst)))
-              mac-font-encoder-list)
-       font-ccl-encoder-alist))
-
-(defconst mac-char-fontspec-list
-  ;; Directly operate on a char-table instead of a fontset so that it
-  ;; may not create a dummy fontset.
-  (let ((template (make-char-table 'fontset)))
-    (dolist
-       (font-encoder
-        (nreverse
-         (mapcar (lambda (lst)
-                   (cons (cons (nth 3 lst) (nth 0 lst)) (nth 1 lst)))
-                 mac-font-encoder-list)))
-      (let ((font (car font-encoder))
-           (encoder (cdr font-encoder)))
-       (map-char-table
-        (lambda (key val)
-          (or (null val)
-              (generic-char-p key)
-              (memq (char-charset key)
-                    '(ascii eight-bit-control eight-bit-graphic))
-              (aset template key font)))
-        (get encoder 'translation-table))))
-
-    ;; Like fontset-info, but extend a range only if its "to" part is
-    ;; the predecessor of the current char.
-    (let* ((last '((0 nil)))
-          (accumulator last)
-          last-char-or-range last-char last-elt)
-      (map-char-table
-       (lambda (char elt)
-        (when elt
-          (setq last-char-or-range (car (car last))
-                last-char (if (consp last-char-or-range)
-                              (cdr last-char-or-range)
-                            last-char-or-range)
-                last-elt (cdr (car last)))
-          (if (and (eq elt last-elt)
-                   (= char (1+ last-char))
-                   (eq (char-charset char) (char-charset last-char)))
-              (if (consp last-char-or-range)
-                  (setcdr last-char-or-range char)
-                (setcar (car last) (cons last-char char)))
-            (setcdr last (list (cons char elt)))
-            (setq last (cdr last)))))
-       template)
-      (cdr accumulator))))
+(add-hook 'suspend-hook 'x-win-suspend-error)
 
-(defun fontset-add-mac-fonts (fontset &optional base-family)
-  "Add font-specs for Mac fonts to FONTSET.
-The added font-specs are determined by BASE-FAMILY and the value
-of `mac-char-fontspec-list', which is a list
-of (CHARACTER-OR-RANGE . (FAMILY-FORMAT . REGISTRY)).  If
-BASE-FAMILY is nil, the font family in the added font-specs is
-also nil.  If BASE-FAMILY is a string, `%s' in FAMILY-FORMAT is
-replaced with the string.  Otherwise, `%s' in FAMILY-FORMAT is
-replaced with the ASCII font family name in FONTSET."
-  (if base-family
-      (if (stringp base-family)
-         (setq base-family (downcase base-family))
-       (let ((ascii-font (fontset-font fontset (charset-id 'ascii))))
-         (if ascii-font
-             (setq base-family
-                   (aref (x-decompose-font-name
-                          (downcase (x-resolve-font-name ascii-font)))
-                         xlfd-regexp-family-subnum))))))
-  (let (fontspec-cache fontspec)
-    (dolist (char-fontspec mac-char-fontspec-list)
-      (setq fontspec (cdr (assq (cdr char-fontspec) fontspec-cache)))
-      (when (null fontspec)
-       (setq fontspec
-             (cons (and base-family
-                        (format (car (cdr char-fontspec)) base-family))
-                   (cdr (cdr char-fontspec))))
-       (setq fontspec-cache (cons (cons (cdr char-fontspec) fontspec)
-                                  fontspec-cache)))
-      (set-fontset-font fontset (car char-fontspec) fontspec))))
+;;; Arrange for the kill and yank functions to set and check the clipboard.
+(setq interprogram-cut-function 'x-select-text)
+(setq interprogram-paste-function 'x-get-selection-value)
 
-(defun create-fontset-from-mac-roman-font (font &optional resolved-font
-                                               fontset-name)
-  "Create a fontset from a Mac roman font FONT.
 
-Optional 1st arg RESOLVED-FONT is a resolved name of FONT.  If
-omitted, `x-resolve-font-name' is called to get the resolved name.  At
-this time, if FONT is not available, error is signaled.
 
-Optional 2nd arg FONTSET-NAME is a string to be used in
-`<CHARSET_ENCODING>' fields of a new fontset name.  If it is omitted,
-an appropriate name is generated automatically.
 
-It returns a name of the created fontset."
-  (let ((fontset
-        (create-fontset-from-ascii-font font resolved-font fontset-name)))
-    (fontset-add-mac-fonts fontset t)
-    fontset))
+;;; Turn off window-splitting optimization; Mac is usually fast enough
+;;; that this is only annoying.
+(setq split-window-keep-point t)
+
+;; Don't show the frame name; that's redundant.
+(setq-default mode-line-frame-identification "  ")
+
+;; Turn on support for mouse wheels.
+(mouse-wheel-mode 1)
+
+
+;; Enable CLIPBOARD copy/paste through menu bar commands.
+(menu-bar-enable-clipboard)
+
+
+;; Initiate drag and drop
+
+(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
+
+\f
+;;;; Non-toolkit Scroll bars
+
+(unless x-toolkit-scroll-bars
+
+;; for debugging
+;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
+
+;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
+
+(global-set-key
+ [vertical-scroll-bar down-mouse-1]
+ 'mac-handle-scroll-bar-event)
+
+(global-unset-key [vertical-scroll-bar drag-mouse-1])
+(global-unset-key [vertical-scroll-bar mouse-1])
 
 ;; Adjust Courier font specifications in x-fixed-font-alist.
 (let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
@@ -2518,58 +2502,17 @@ It returns a name of the created fontset."
 
 ;; Setup the default fontset.
 (setup-default-fontset)
-(cond ((x-list-fonts "*-iso10646-1" nil nil 1)
-       ;; Use ATSUI (if available) for the following charsets.
-       (dolist
-          (charset '(latin-iso8859-1
-                     latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
-                     thai-tis620 greek-iso8859-7 arabic-iso8859-6
-                     hebrew-iso8859-8 cyrillic-iso8859-5
-                     latin-iso8859-9 latin-iso8859-15 latin-iso8859-14
-                     japanese-jisx0212 chinese-sisheng ipa
-                     vietnamese-viscii-lower vietnamese-viscii-upper
-                     lao ethiopic tibetan))
-        (set-fontset-font nil charset '(nil . "iso10646-1"))))
-      ((null (x-list-fonts "*-iso8859-1" nil nil 1))
-       ;; Add Mac-encoding fonts unless ETL fonts are installed.
-       (fontset-add-mac-fonts "fontset-default")))
 
 ;; Create a fontset that uses mac-roman font.  With this fontset,
-;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
-;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
-(create-fontset-from-fontset-spec
- "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard,
-ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
-(fontset-add-mac-fonts "fontset-standard" t)
+;; characters belonging to mac-roman charset (that contains ASCII and
+;; more Latin characters) are displayed by a mac-roman font.
+(create-fontset-from-mac-roman-font
+ "-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman" nil
+ "-apple-Monaco-normal-r-*-*-12-*-*-*-*-*-fontset-standard")
 
 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
 (create-fontset-from-x-resource)
 
-;; Try to create a fontset from a font specification which comes
-;; from initial-frame-alist, default-frame-alist, or X resource.
-;; A font specification in command line argument (i.e. -fn XXXX)
-;; should be already in default-frame-alist as a `font'
-;; parameter.  However, any font specifications in site-start
-;; library, user's init file (.emacs), and default.el are not
-;; yet handled here.
-
-(let ((font (or (cdr (assq 'font initial-frame-alist))
-               (cdr (assq 'font default-frame-alist))
-               (x-get-resource "font" "Font")))
-      xlfd-fields resolved-name)
-  (if (and font
-          (not (query-fontset font))
-          (setq resolved-name (x-resolve-font-name font))
-          (setq xlfd-fields (x-decompose-font-name font)))
-      (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
-         (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
-       ;; Create a fontset from FONT.  The fontset name is
-       ;; generated from FONT.
-       (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum))
-                (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum)))
-           (create-fontset-from-mac-roman-font font resolved-name "startup")
-         (create-fontset-from-ascii-font font resolved-name "startup")))))
-
 ;; Apply a geometry resource to the initial frame.  Put it at the end
 ;; of the alist, so that anything specified on the command line takes
 ;; precedence.
@@ -2606,50 +2549,7 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
        (setq default-frame-alist
              (cons '(reverse . t) default-frame-alist)))))
 
-(defun x-win-suspend-error ()
-  (error "Suspending an Emacs running under Mac makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-
-;;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
-(setq interprogram-paste-function 'x-get-selection-value)
-
-(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
-
-;;; Turn off window-splitting optimization; Mac is usually fast enough
-;;; that this is only annoying.
-(setq split-window-keep-point t)
-
-;; Don't show the frame name; that's redundant.
-(setq-default mode-line-frame-identification "  ")
-
-;; Turn on support for mouse wheels.
-(mouse-wheel-mode 1)
-
-
-;; Enable CLIPBOARD copy/paste through menu bar commands.
-(menu-bar-enable-clipboard)
-
-;; Initiate drag and drop
-
-(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
-
-\f
-;;;; Non-toolkit Scroll bars
-
-(unless x-toolkit-scroll-bars
-
-;; for debugging
-;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
-
-;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
-
-(global-set-key
- [vertical-scroll-bar down-mouse-1]
- 'mac-handle-scroll-bar-event)
-
-(global-unset-key [vertical-scroll-bar drag-mouse-1])
-(global-unset-key [vertical-scroll-bar mouse-1])
+(setq mac-initialized t)))
 
 (defun mac-handle-scroll-bar-event (event)
   "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
@@ -2697,7 +2597,6 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
     (mac-scroll-ignore-events)
     (scroll-up 1)))
 
-)
 
 \f
 ;;;; Others
@@ -2735,5 +2634,11 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
 ;; or bold bitmap versions will not display these variants correctly.
 (setq scalable-fonts-allowed t)
 
+(add-to-list 'handle-args-function-alist '(mac . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
+
+(provide 'mac-win)
+
 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
 ;;; mac-win.el ends here