1 |
;;; mac-win.el --- support for "Macintosh windows" |
;;; mac-win.el --- support for "Macintosh windows" |
2 |
|
|
3 |
;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
;; Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Andrew Choi <akochoi@mac.com> |
;; Author: Andrew Choi <akochoi@mac.com> |
6 |
|
|
104 |
;; Don't have this yet. |
;; Don't have this yet. |
105 |
(fset 'x-get-resource 'ignore) |
(fset 'x-get-resource 'ignore) |
106 |
|
|
107 |
;; This variable specifies the Unix program to call (as a process) to |
(unless (eq system-type 'darwin) |
108 |
;; deteremine the amount of free space on a file system (defaults to |
;; This variable specifies the Unix program to call (as a process) to |
109 |
;; df). If it is not set to nil, ls-lisp will not work correctly |
;; deteremine the amount of free space on a file system (defaults to |
110 |
;; unless an external application df is implemented on the Mac. |
;; df). If it is not set to nil, ls-lisp will not work correctly |
111 |
(require 'dired) |
;; unless an external application df is implemented on the Mac. |
112 |
|
(setq directory-free-space-program nil) |
113 |
(setq dired-free-space-program nil) |
|
114 |
|
;; Set this so that Emacs calls subprocesses with "sh" as shell to |
115 |
;; Set this so that Emacs calls subprocesses with "sh" as shell to |
;; expand filenames Note no subprocess for the shell is actually |
116 |
;; expand filenames Note no subprocess for the shell is actually |
;; started (see run_mac_command in sysdep.c). |
117 |
;; started (see run_mac_command in sysdep.c). |
(setq shell-file-name "sh")) |
|
(setq shell-file-name "sh") |
|
118 |
|
|
119 |
;; X Window emulation in macterm.c is not complete enough to start a |
;; X Window emulation in macterm.c is not complete enough to start a |
120 |
;; frame without a minibuffer properly. Call this to tell ediff |
;; frame without a minibuffer properly. Call this to tell ediff |
125 |
;; mac-paste-function are defined in mac.c. |
;; mac-paste-function are defined in mac.c. |
126 |
(set-selection-coding-system 'compound-text-mac) |
(set-selection-coding-system 'compound-text-mac) |
127 |
|
|
128 |
(setq interprogram-cut-function |
(setq interprogram-cut-function |
129 |
'(lambda (str push) |
'(lambda (str push) |
130 |
(mac-cut-function |
(mac-cut-function |
131 |
(encode-coding-string str selection-coding-system t) push))) |
(encode-coding-string str selection-coding-system t) push))) |
132 |
|
|
133 |
(setq interprogram-paste-function |
(setq interprogram-paste-function |
134 |
'(lambda () |
'(lambda () |
135 |
(decode-coding-string |
(let ((clipboard (mac-paste-function))) |
136 |
(mac-paste-function) selection-coding-system t))) |
(if clipboard |
137 |
|
(decode-coding-string clipboard selection-coding-system t))))) |
138 |
|
|
139 |
(defun mac-drag-n-drop (event) |
(defun mac-drag-n-drop (event) |
140 |
"Edit the files listed in the drag-n-drop event.\n\ |
"Edit the files listed in the drag-n-drop event.\n\ |
172 |
'(lambda () |
'(lambda () |
173 |
(defvar mac-ready-for-drag-n-drop t))) |
(defvar mac-ready-for-drag-n-drop t))) |
174 |
|
|
175 |
|
(defun iconify-or-deiconify-frame () |
176 |
|
"Iconify the selected frame, or deiconify if it's currently an icon." |
177 |
|
(interactive) |
178 |
|
(if (eq (cdr (assq 'visibility (frame-parameters))) t) |
179 |
|
(iconify-frame) |
180 |
|
(make-frame-visible))) |
181 |
|
|
182 |
; Define constant values to be set to mac-keyboard-text-encoding |
; Define constant values to be set to mac-keyboard-text-encoding |
183 |
(defconst kTextEncodingMacRoman 0) |
(defconst kTextEncodingMacRoman 0) |
184 |
(defconst kTextEncodingISOLatin1 513 "0x201") |
(defconst kTextEncodingISOLatin1 513 "0x201") |
205 |
|
|
206 |
(if (fboundp 'new-fontset) |
(if (fboundp 'new-fontset) |
207 |
(progn |
(progn |
208 |
|
(require 'fontset) |
209 |
|
(setup-default-fontset) |
210 |
(create-fontset-from-fontset-spec |
(create-fontset-from-fontset-spec |
211 |
"-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac, |
"-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac, |
212 |
ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman") |
ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman") |
215 |
(function |
(function |
216 |
(lambda (key val) |
(lambda (key val) |
217 |
(or (generic-char-p key) |
(or (generic-char-p key) |
218 |
(memq (char-charset key) |
(memq (char-charset val) |
219 |
'(ascii eight-bit-control eight-bit-graphic)) |
'(ascii eight-bit-control eight-bit-graphic)) |
220 |
(set-fontset-font "fontset-mac" key monaco-font)))) |
(set-fontset-font "fontset-mac" val monaco-font)))) |
221 |
(get 'mac-roman-encoder 'translation-table))))) |
(get 'mac-roman-decoder 'translation-table))))) |
222 |
|
|
223 |
;; To display filenames in Chinese or Japanese, replace mac-roman with |
(if (eq system-type 'darwin) |
224 |
;; big5 or sjis |
;; On Darwin filenames are encoded in UTF-8 |
225 |
(setq file-name-coding-system 'mac-roman) |
(setq file-name-coding-system 'utf-8) |
226 |
|
;; To display filenames in Chinese or Japanese, replace mac-roman with |
227 |
|
;; big5 or sjis |
228 |
|
(setq file-name-coding-system 'mac-roman)) |
229 |
|
|
230 |
;; If Emacs is started from the Finder, change the default directory |
;; If Emacs is started from the Finder, change the default directory |
231 |
;; to the user's home directory. |
;; to the user's home directory. |
232 |
(if (string= default-directory "/") |
(if (string= default-directory "/") |
233 |
(cd "~")) |
(cd "~")) |
234 |
|
|
235 |
;; Tell Emacs to use pipes instead of pty's for processes because the |
(unless (eq system-type 'darwin) |
236 |
;; latter sometimes lose characters. Pty support is compiled in since |
;; Tell Emacs to use pipes instead of pty's for processes because the |
237 |
;; ange-ftp will not work without it. |
;; latter sometimes lose characters. Pty support is compiled in since |
238 |
(setq process-connection-type nil) |
;; ange-ftp will not work without it. |
239 |
|
(setq process-connection-type nil)) |
240 |
|
|
241 |
|
;; Assume that fonts are always scalable on the Mac. This sometimes |
242 |
|
;; results in characters with jagged edges. However, without it, |
243 |
|
;; fonts with both truetype and bitmap representations but no italic |
244 |
|
;; or bold bitmap versions will not display these variants correctly. |
245 |
|
(setq scalable-fonts-allowed t) |
246 |
|
|
247 |
|
;; Make suspend-emacs [C-z] collapse the current frame |
248 |
|
(substitute-key-definition 'suspend-emacs 'iconify-frame |
249 |
|
global-map) |
250 |
|
|
251 |
|
;; Support mouse-wheel scrolling |
252 |
|
(autoload 'mwheel-scroll "mwheel") |
253 |
|
(global-set-key [mouse-wheel] 'mwheel-scroll) |
254 |
|
(global-set-key [C-mouse-wheel] 'mwheel-scroll) |
255 |
|
(global-set-key [S-mouse-wheel] 'mwheel-scroll) |
256 |
|
|
257 |
;; (prefer-coding-system 'mac-roman) |
;; (prefer-coding-system 'mac-roman) |
258 |
|
|
259 |
|
;; Map certain keypad keys into ASCII characters that people usually expect |
260 |
|
(define-key function-key-map [return] [?\C-m]) |
261 |
|
(define-key function-key-map [M-return] [?\M-\C-m]) |
262 |
|
(define-key function-key-map [tab] [?\t]) |
263 |
|
(define-key function-key-map [M-tab] [?\M-\t]) |
264 |
|
(define-key function-key-map [backspace] [127]) |
265 |
|
(define-key function-key-map [M-backspace] [?\M-\d]) |
266 |
|
(define-key function-key-map [escape] [?\e]) |
267 |
|
(define-key function-key-map [M-escape] [?\M-\e]) |
268 |
|
|
269 |
|
;; Tell read-char how to convert special chars to ASCII |
270 |
|
(put 'return 'ascii-character 13) |
271 |
|
|
272 |
;; |
;; |
273 |
;; Available colors |
;; Available colors |
274 |
;; |
;; |