]> code.delx.au - gnu-emacs/blob - lisp/term/ns-win.el
rename do-applescript,do_applescript in keeping with NS code conventions
[gnu-emacs] / lisp / term / ns-win.el
1 ;;; ns-win.el --- lisp side of interface with NeXT/Open/GNUstep/MacOS X window system
2
3 ;; Copyright (C) 1993, 1994, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
5
6 ;; Authors: Carl Edman, Christian Limpach, Scott Bender,
7 ;; Christophe de Dinechin, Adrian Robert
8 ;; Keywords: terminals
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; ns-win.el: this file is loaded from ../lisp/startup.el when it
28 ;; recognizes that Nextstep windows are to be used. Command line
29 ;; switches are parsed and those pertaining to Nextstep are processed
30 ;; and removed from the command line. The Nextstep display is opened
31 ;; and hooks are set for popping up the initial window.
32
33 ;; startup.el will then examine startup files, and eventually call the hooks
34 ;; which create the first window (s).
35
36 ;; A number of other Nextstep convenience functions are defined in
37 ;; this file, which works in close coordination with src/nsfns.m.
38
39 ;;; Code:
40
41
42 (if (not (featurep 'ns))
43 (error "%s: Loading ns-win.el but not compiled for GNUStep/MacOS"
44 (invocation-name)))
45
46 (eval-when-compile (require 'cl))
47
48 ;; Documentation-purposes only: actually loaded in loadup.el
49 (require 'frame)
50 (require 'mouse)
51 (require 'faces)
52 (require 'easymenu)
53 (require 'menu-bar)
54 (require 'fontset)
55
56 ;; Not needed?
57 ;;(require 'ispell)
58
59 ;; nsterm.m
60 (defvar ns-version-string)
61 (defvar ns-expand-space)
62 (defvar ns-cursor-blink-rate)
63 (defvar ns-alternate-modifier)
64
65 ;;;; Command line argument handling.
66
67 (defvar ns-invocation-args nil)
68 (defvar ns-command-line-resources nil)
69
70 ;; Handler for switches of the form "-switch value" or "-switch".
71 (defun ns-handle-switch (switch &optional numeric)
72 (let ((aelt (assoc switch command-line-ns-option-alist)))
73 (if aelt
74 (setq default-frame-alist
75 (cons (cons (nth 3 aelt)
76 (if numeric
77 (string-to-number (pop ns-invocation-args))
78 (or (nth 4 aelt) (pop ns-invocation-args))))
79 default-frame-alist)))))
80
81 ;; Handler for switches of the form "-switch n"
82 (defun ns-handle-numeric-switch (switch)
83 (ns-handle-switch switch t))
84
85 ;; Make -iconic apply only to the initial frame!
86 (defun ns-handle-iconic (switch)
87 (setq initial-frame-alist
88 (cons '(visibility . icon) initial-frame-alist)))
89
90 ;; Handle the -name option, set the name of the initial frame.
91 (defun ns-handle-name-switch (switch)
92 (or (consp ns-invocation-args)
93 (error "%s: missing argument to `%s' option" (invocation-name) switch))
94 (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args))
95 initial-frame-alist)))
96
97 ;; Set (but not used?) in frame.el.
98 (defvar x-display-name nil
99 "The name of the Nextstep display on which Emacs was started.")
100
101 ;; nsterm.m.
102 (defvar ns-input-file)
103
104 (defun ns-handle-nxopen (switch)
105 (setq unread-command-events (append unread-command-events '(ns-open-file))
106 ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
107
108 (defun ns-handle-nxopentemp (switch)
109 (setq unread-command-events (append unread-command-events
110 '(ns-open-temp-file))
111 ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
112
113 (defun ns-ignore-0-arg (switch))
114 (defun ns-ignore-1-arg (switch)
115 (setq ns-invocation-args (cdr ns-invocation-args)))
116 (defun ns-ignore-2-arg (switch)
117 (setq ns-invocation-args (cddr ns-invocation-args)))
118
119 (defun ns-handle-args (args)
120 "Process Nextstep-related command line options.
121 This is run before the user's startup file is loaded.
122 The options in ARGS are copied to `ns-invocation-args'.
123 The Nextstep-related settings are then applied using the handlers
124 defined in `command-line-ns-option-alist'.
125 The return value is ARGS minus the number of arguments processed."
126 ;; We use ARGS to accumulate the args that we don't handle here, to return.
127 (setq ns-invocation-args args
128 args nil)
129 (while ns-invocation-args
130 (let* ((this-switch (pop ns-invocation-args))
131 (orig-this-switch this-switch)
132 completion argval aelt handler)
133 ;; Check for long options with attached arguments
134 ;; and separate out the attached option argument into argval.
135 (if (string-match "^--[^=]*=" this-switch)
136 (setq argval (substring this-switch (match-end 0))
137 this-switch (substring this-switch 0 (1- (match-end 0)))))
138 ;; Complete names of long options.
139 (if (string-match "^--" this-switch)
140 (progn
141 (setq completion (try-completion this-switch
142 command-line-ns-option-alist))
143 (if (eq completion t)
144 ;; Exact match for long option.
145 nil
146 (if (stringp completion)
147 (let ((elt (assoc completion command-line-ns-option-alist)))
148 ;; Check for abbreviated long option.
149 (or elt
150 (error "Option `%s' is ambiguous" this-switch))
151 (setq this-switch completion))))))
152 (setq aelt (assoc this-switch command-line-ns-option-alist))
153 (if aelt (setq handler (nth 2 aelt)))
154 (if handler
155 (if argval
156 (let ((ns-invocation-args
157 (cons argval ns-invocation-args)))
158 (funcall handler this-switch))
159 (funcall handler this-switch))
160 (setq args (cons orig-this-switch args)))))
161 (nreverse args))
162
163 (defun x-parse-geometry (geom)
164 "Parse a Nextstep-style geometry string STRING.
165 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
166 The properties returned may include `top', `left', `height', and `width'."
167 (when (string-match "\\([0-9]+\\)\\( \\([0-9]+\\)\\( \\([0-9]+\\)\
168 \\( \\([0-9]+\\) ?\\)?\\)?\\)?"
169 geom)
170 (apply
171 'append
172 (list
173 (list (cons 'top (string-to-number (match-string 1 geom))))
174 (if (match-string 3 geom)
175 (list (cons 'left (string-to-number (match-string 3 geom)))))
176 (if (match-string 5 geom)
177 (list (cons 'height (string-to-number (match-string 5 geom)))))
178 (if (match-string 7 geom)
179 (list (cons 'width (string-to-number (match-string 7 geom)))))))))
180
181 ;;;; Keyboard mapping.
182
183 ;; These tell read-char how to convert
184 ;; these special chars to ASCII.
185 (put 'backspace 'ascii-character 127)
186 (put 'delete 'ascii-character 127)
187 (put 'tab 'ascii-character ?\t)
188 (put 'S-tab 'ascii-character (logior 16 ?\t))
189 (put 'linefeed 'ascii-character ?\n)
190 (put 'clear 'ascii-character 12)
191 (put 'return 'ascii-character 13)
192 (put 'escape 'ascii-character ?\e)
193
194 ;; Map certain keypad keys into ASCII characters
195 ;; that people usually expect.
196 (define-key function-key-map [backspace] [127])
197 (define-key function-key-map [delete] [127])
198 (define-key function-key-map [tab] [?\t])
199 (define-key function-key-map [S-tab] [25])
200 (define-key function-key-map [linefeed] [?\n])
201 (define-key function-key-map [clear] [11])
202 (define-key function-key-map [return] [13])
203 (define-key function-key-map [escape] [?\e])
204 (define-key function-key-map [M-backspace] [?\M-\d])
205 (define-key function-key-map [M-delete] [?\M-\d])
206 (define-key function-key-map [M-tab] [?\M-\t])
207 (define-key function-key-map [M-linefeed] [?\M-\n])
208 (define-key function-key-map [M-clear] [?\M-\013])
209 (define-key function-key-map [M-return] [?\M-\015])
210 (define-key function-key-map [M-escape] [?\M-\e])
211
212
213 ;; Here are some Nextstep-like bindings for command key sequences.
214 (define-key global-map [?\s-,] 'ns-popup-prefs-panel)
215 (define-key global-map [?\s-'] 'next-multiframe-window)
216 (define-key global-map [?\s-`] 'other-frame)
217 (define-key global-map [?\s--] 'center-line)
218 (define-key global-map [?\s-:] 'ispell)
219 (define-key global-map [?\s-\;] 'ispell-next)
220 (define-key global-map [?\s-?] 'info)
221 (define-key global-map [?\s-^] 'kill-some-buffers)
222 (define-key global-map [?\s-&] 'kill-this-buffer)
223 (define-key global-map [?\s-C] 'ns-popup-color-panel)
224 (define-key global-map [?\s-D] 'dired)
225 (define-key global-map [?\s-E] 'edit-abbrevs)
226 (define-key global-map [?\s-L] 'shell-command)
227 (define-key global-map [?\s-M] 'manual-entry)
228 (define-key global-map [?\s-S] 'ns-write-file-using-panel)
229 (define-key global-map [?\s-a] 'mark-whole-buffer)
230 (define-key global-map [?\s-c] 'ns-copy-including-secondary)
231 (define-key global-map [?\s-d] 'isearch-repeat-backward)
232 (define-key global-map [?\s-e] 'isearch-yank-kill)
233 (define-key global-map [?\s-f] 'isearch-forward)
234 (define-key global-map [?\s-g] 'isearch-repeat-forward)
235 (define-key global-map [?\s-h] 'ns-do-hide-emacs)
236 (define-key global-map [?\s-H] 'ns-do-hide-others)
237 (define-key global-map [?\s-j] 'exchange-point-and-mark)
238 (define-key global-map [?\s-k] 'kill-this-buffer)
239 (define-key global-map [?\s-l] 'goto-line)
240 (define-key global-map [?\s-m] 'iconify-frame)
241 (define-key global-map [?\s-n] 'make-frame)
242 (define-key global-map [?\s-o] 'ns-open-file-using-panel)
243 (define-key global-map [?\s-p] 'ns-print-buffer)
244 (define-key global-map [?\s-q] 'save-buffers-kill-emacs)
245 (define-key global-map [?\s-s] 'save-buffer)
246 (define-key global-map [?\s-t] 'ns-popup-font-panel)
247 (define-key global-map [?\s-u] 'revert-buffer)
248 (define-key global-map [?\s-v] 'yank)
249 (define-key global-map [?\s-w] 'delete-frame)
250 (define-key global-map [?\s-x] 'kill-region)
251 (define-key global-map [?\s-y] 'ns-paste-secondary)
252 (define-key global-map [?\s-z] 'undo)
253 (define-key global-map [?\s-|] 'shell-command-on-region)
254 (define-key global-map [s-kp-bar] 'shell-command-on-region)
255 ;; (as in Terminal.app)
256 (define-key global-map [s-right] 'ns-next-frame)
257 (define-key global-map [s-left] 'ns-prev-frame)
258
259 (define-key global-map [home] 'beginning-of-buffer)
260 (define-key global-map [end] 'end-of-buffer)
261 (define-key global-map [kp-home] 'beginning-of-buffer)
262 (define-key global-map [kp-end] 'end-of-buffer)
263 (define-key global-map [kp-prior] 'scroll-down)
264 (define-key global-map [kp-next] 'scroll-up)
265
266
267 ;; Special Nextstep-generated events are converted to function keys. Here
268 ;; are the bindings for them.
269 (define-key global-map [ns-power-off]
270 (lambda () (interactive) (save-buffers-kill-emacs t)))
271 (define-key global-map [ns-open-file] 'ns-find-file)
272 (define-key global-map [ns-open-temp-file] [ns-open-file])
273 (define-key global-map [ns-drag-file] 'ns-insert-file)
274 (define-key global-map [ns-drag-color] 'ns-set-foreground-at-mouse)
275 (define-key global-map [S-ns-drag-color] 'ns-set-background-at-mouse)
276 (define-key global-map [ns-drag-text] 'ns-insert-text)
277 (define-key global-map [ns-change-font] 'ns-respond-to-change-font)
278 (define-key global-map [ns-open-file-line] 'ns-open-file-select-line)
279 (define-key global-map [ns-insert-working-text] 'ns-insert-working-text)
280 (define-key global-map [ns-delete-working-text] 'ns-delete-working-text)
281 (define-key global-map [ns-spi-service-call] 'ns-spi-service-call)
282
283
284
285 ;; Functions to set environment variables by running a subshell.
286 ;;; Idea based on Nextstep 4.2 distribution, this version of code
287 ;;; based on mac-read-environment-vars-from-shell () by David Reitter.
288 ;;; Mostly used only under ns-extended-platform-support-mode.
289
290 (defun ns-make-command-string (cmdlist)
291 (mapconcat 'identity cmdlist " ; "))
292
293 ;;;###autoload
294 (defun ns-grabenv (&optional shell-path startup)
295 "Set the Emacs environment using the output of a shell command.
296 This runs a shell subprocess, and interpret its output as a
297 series of environment variables to insert into the emacs
298 environment.
299 SHELL-PATH gives the path to the shell; if nil, this defaults to
300 the current setting of `shell-file-name'.
301 STARTUP is a list of commands for the shell to execute; if nil,
302 this defaults to \"printenv\"."
303 (interactive)
304 (with-temp-buffer
305 (let ((shell-file-name (if shell-path shell-path shell-file-name))
306 (cmd (ns-make-command-string (if startup startup '("printenv")))))
307 (shell-command cmd t)
308 (while (search-forward-regexp "^\\([A-Za-z_0-9]+\\)=\\(.*\\)$" nil t)
309 (setenv (match-string 1)
310 (if (equal (match-string 1) "PATH")
311 (concat (getenv "PATH") ":" (match-string 2))
312 (match-string 2)))))))
313
314 ;; Set up a number of aliases and other layers to pretend we're using
315 ;; the Choi/Mitsuharu Carbon port.
316
317 (defvaralias 'mac-allow-anti-aliasing 'ns-antialias-text)
318 (defvaralias 'mac-command-modifier 'ns-command-modifier)
319 (defvaralias 'mac-control-modifier 'ns-control-modifier)
320 (defvaralias 'mac-option-modifier 'ns-option-modifier)
321 (defvaralias 'mac-function-modifier 'ns-function-modifier)
322 (defalias 'do-applescript 'ns-do-applescript)
323
324
325 (defvar menu-bar-ns-file-menu) ; below
326
327 ;; Toggle some additional Nextstep-like features that may interfere
328 ;; with users' expectations coming from emacs on other platforms.
329 (define-minor-mode ns-extended-platform-support-mode
330 "Toggle Nextstep extended platform support features.
331 When this mode is active (no modeline indicator):
332 - File menu is altered slightly in keeping with conventions.
333 - Screen position is preserved in scrolling.
334 - Transient mark mode is activated"
335 :init-value nil
336 :global t
337 :group 'ns
338 (if ns-extended-platform-support-mode
339 (progn
340 (defun ns-show-manual () "Show Emacs.app manual" (interactive) (info "ns-emacs"))
341 (setq where-is-preferred-modifier 'super)
342 (setq scroll-preserve-screen-position t)
343 (transient-mark-mode 1)
344
345 ;; Change file menu to simplify and add a couple of
346 ;; Nextstep-specific items
347 (easy-menu-remove-item global-map '("menu-bar") 'file)
348 (easy-menu-add-item global-map '(menu-bar)
349 (cons "File" menu-bar-ns-file-menu) 'edit)
350 (define-key menu-bar-help-menu [ns-manual]
351 '(menu-item "Emacs.app Manual" ns-show-manual)))
352 (progn
353 ;; Undo everything above.
354 (fmakunbound 'ns-show-manual)
355 (setq where-is-preferred-modifier 'nil)
356 (setq scroll-preserve-screen-position nil)
357 (transient-mark-mode 0)
358 (easy-menu-remove-item global-map '("menu-bar") 'file)
359 (easy-menu-add-item global-map '(menu-bar)
360 (cons "File" menu-bar-file-menu) 'edit)
361 (easy-menu-remove-item global-map '("menu-bar" "help-menu") 'ns-manual)
362 )))
363
364
365 (defun x-setup-function-keys (frame)
366 "Set up function Keys for Nextstep for frame FRAME."
367 (unless (terminal-parameter frame 'x-setup-function-keys)
368 (with-selected-frame frame
369 (setq interprogram-cut-function 'x-select-text
370 interprogram-paste-function 'x-cut-buffer-or-selection-value)
371 ;; (let ((map (copy-keymap x-alternatives-map)))
372 ;; (set-keymap-parent map (keymap-parent local-function-key-map))
373 ;; (set-keymap-parent local-function-key-map map))
374 (setq system-key-alist
375 (list
376 (cons (logior (lsh 0 16) 1) 'ns-power-off)
377 (cons (logior (lsh 0 16) 2) 'ns-open-file)
378 (cons (logior (lsh 0 16) 3) 'ns-open-temp-file)
379 (cons (logior (lsh 0 16) 4) 'ns-drag-file)
380 (cons (logior (lsh 0 16) 5) 'ns-drag-color)
381 (cons (logior (lsh 0 16) 6) 'ns-drag-text)
382 (cons (logior (lsh 0 16) 7) 'ns-change-font)
383 (cons (logior (lsh 0 16) 8) 'ns-open-file-line)
384 (cons (logior (lsh 0 16) 9) 'ns-insert-working-text)
385 (cons (logior (lsh 0 16) 10) 'ns-delete-working-text)
386 (cons (logior (lsh 0 16) 11) 'ns-spi-service-call)
387 (cons (logior (lsh 1 16) 32) 'f1)
388 (cons (logior (lsh 1 16) 33) 'f2)
389 (cons (logior (lsh 1 16) 34) 'f3)
390 (cons (logior (lsh 1 16) 35) 'f4)
391 (cons (logior (lsh 1 16) 36) 'f5)
392 (cons (logior (lsh 1 16) 37) 'f6)
393 (cons (logior (lsh 1 16) 38) 'f7)
394 (cons (logior (lsh 1 16) 39) 'f8)
395 (cons (logior (lsh 1 16) 40) 'f9)
396 (cons (logior (lsh 1 16) 41) 'f10)
397 (cons (logior (lsh 1 16) 42) 'f11)
398 (cons (logior (lsh 1 16) 43) 'f12)
399 (cons (logior (lsh 1 16) 44) 'kp-insert)
400 (cons (logior (lsh 1 16) 45) 'kp-delete)
401 (cons (logior (lsh 1 16) 46) 'kp-home)
402 (cons (logior (lsh 1 16) 47) 'kp-end)
403 (cons (logior (lsh 1 16) 48) 'kp-prior)
404 (cons (logior (lsh 1 16) 49) 'kp-next)
405 (cons (logior (lsh 1 16) 50) 'print-screen)
406 (cons (logior (lsh 1 16) 51) 'scroll-lock)
407 (cons (logior (lsh 1 16) 52) 'pause)
408 (cons (logior (lsh 1 16) 53) 'system)
409 (cons (logior (lsh 1 16) 54) 'break)
410 (cons (logior (lsh 1 16) 56) 'please-tell-carl-what-this-key-is-called-56)
411 (cons (logior (lsh 1 16) 61) 'please-tell-carl-what-this-key-is-called-61)
412 (cons (logior (lsh 1 16) 62) 'please-tell-carl-what-this-key-is-called-62)
413 (cons (logior (lsh 1 16) 63) 'please-tell-carl-what-this-key-is-called-63)
414 (cons (logior (lsh 1 16) 64) 'please-tell-carl-what-this-key-is-called-64)
415 (cons (logior (lsh 1 16) 69) 'please-tell-carl-what-this-key-is-called-69)
416 (cons (logior (lsh 1 16) 70) 'please-tell-carl-what-this-key-is-called-70)
417 (cons (logior (lsh 1 16) 71) 'please-tell-carl-what-this-key-is-called-71)
418 (cons (logior (lsh 1 16) 72) 'please-tell-carl-what-this-key-is-called-72)
419 (cons (logior (lsh 1 16) 73) 'please-tell-carl-what-this-key-is-called-73)
420 (cons (logior (lsh 2 16) 3) 'kp-enter)
421 (cons (logior (lsh 2 16) 9) 'kp-tab)
422 (cons (logior (lsh 2 16) 28) 'kp-quit)
423 (cons (logior (lsh 2 16) 35) 'kp-hash)
424 (cons (logior (lsh 2 16) 42) 'kp-multiply)
425 (cons (logior (lsh 2 16) 43) 'kp-add)
426 (cons (logior (lsh 2 16) 44) 'kp-separator)
427 (cons (logior (lsh 2 16) 45) 'kp-subtract)
428 (cons (logior (lsh 2 16) 46) 'kp-decimal)
429 (cons (logior (lsh 2 16) 47) 'kp-divide)
430 (cons (logior (lsh 2 16) 48) 'kp-0)
431 (cons (logior (lsh 2 16) 49) 'kp-1)
432 (cons (logior (lsh 2 16) 50) 'kp-2)
433 (cons (logior (lsh 2 16) 51) 'kp-3)
434 (cons (logior (lsh 2 16) 52) 'kp-4)
435 (cons (logior (lsh 2 16) 53) 'kp-5)
436 (cons (logior (lsh 2 16) 54) 'kp-6)
437 (cons (logior (lsh 2 16) 55) 'kp-7)
438 (cons (logior (lsh 2 16) 56) 'kp-8)
439 (cons (logior (lsh 2 16) 57) 'kp-9)
440 (cons (logior (lsh 2 16) 60) 'kp-less)
441 (cons (logior (lsh 2 16) 61) 'kp-equal)
442 (cons (logior (lsh 2 16) 62) 'kp-more)
443 (cons (logior (lsh 2 16) 64) 'kp-at)
444 (cons (logior (lsh 2 16) 92) 'kp-backslash)
445 (cons (logior (lsh 2 16) 96) 'kp-backtick)
446 (cons (logior (lsh 2 16) 124) 'kp-bar)
447 (cons (logior (lsh 2 16) 126) 'kp-tilde)
448 (cons (logior (lsh 2 16) 157) 'kp-mu)
449 (cons (logior (lsh 2 16) 165) 'kp-yen)
450 (cons (logior (lsh 2 16) 167) 'kp-paragraph)
451 (cons (logior (lsh 2 16) 172) 'left)
452 (cons (logior (lsh 2 16) 173) 'up)
453 (cons (logior (lsh 2 16) 174) 'right)
454 (cons (logior (lsh 2 16) 175) 'down)
455 (cons (logior (lsh 2 16) 176) 'kp-ring)
456 (cons (logior (lsh 2 16) 201) 'kp-square)
457 (cons (logior (lsh 2 16) 204) 'kp-cube)
458 (cons (logior (lsh 3 16) 8) 'backspace)
459 (cons (logior (lsh 3 16) 9) 'tab)
460 (cons (logior (lsh 3 16) 10) 'linefeed)
461 (cons (logior (lsh 3 16) 11) 'clear)
462 (cons (logior (lsh 3 16) 13) 'return)
463 (cons (logior (lsh 3 16) 18) 'pause)
464 (cons (logior (lsh 3 16) 25) 'S-tab)
465 (cons (logior (lsh 3 16) 27) 'escape)
466 (cons (logior (lsh 3 16) 127) 'delete)
467 ))
468 (set-terminal-parameter frame 'x-setup-function-keys t))))
469
470
471
472 ;;;; Miscellaneous mouse bindings.
473
474 ;;; Allow shift-clicks to work just like under Nextstep
475 (defun mouse-extend-region (event)
476 "Move point or mark so as to extend region.
477 This should be bound to a mouse click event type."
478 (interactive "e")
479 (mouse-minibuffer-check event)
480 (let ((posn (event-end event)))
481 (if (not (windowp (posn-window posn)))
482 (error "Cursor not in text area of window"))
483 (select-window (posn-window posn))
484 (cond
485 ((not (numberp (posn-point posn))))
486 ((or (not mark-active) (> (abs (- (posn-point posn) (point)))
487 (abs (- (posn-point posn) (mark)))))
488 (let ((point-save (point)))
489 (unwind-protect
490 (progn
491 (goto-char (posn-point posn))
492 (push-mark nil t t)
493 (or transient-mark-mode
494 (sit-for 1)))
495 (goto-char point-save))))
496 (t
497 (goto-char (posn-point posn))))))
498
499 (define-key global-map [S-mouse-1] 'mouse-extend-region)
500 (global-unset-key [S-down-mouse-1])
501
502
503
504 ;; Must come after keybindings.
505
506 (fmakunbound 'clipboard-yank)
507 (fmakunbound 'clipboard-kill-ring-save)
508 (fmakunbound 'clipboard-kill-region)
509 (fmakunbound 'menu-bar-enable-clipboard)
510
511 ;; Add a couple of menus and rearrange some others; easiest just to redo toplvl
512 ;; Note keymap defns must be given last-to-first
513 (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar"))
514
515 (setq menu-bar-final-items
516 (cond ((eq system-type 'darwin)
517 '(buffer windows services help-menu))
518 ;; Otherwise, GNUstep.
519 (t
520 '(buffer windows services hide-app quit))))
521
522 ;; Add standard top-level items to GNUstep menu.
523 (unless (eq system-type 'darwin)
524 (define-key global-map [menu-bar quit] '("Quit" . save-buffers-kill-emacs))
525 (define-key global-map [menu-bar hide-app] '("Hide" . ns-do-hide-emacs)))
526
527 (define-key global-map [menu-bar services]
528 (cons "Services" (make-sparse-keymap "Services")))
529 (define-key global-map [menu-bar windows] (make-sparse-keymap "Windows"))
530 (define-key global-map [menu-bar buffer]
531 (cons "Buffers" global-buffers-menu-map))
532 ;; (cons "Buffers" (make-sparse-keymap "Buffers")))
533 (define-key global-map [menu-bar tools] (cons "Tools" menu-bar-tools-menu))
534 (define-key global-map [menu-bar options] (cons "Options" menu-bar-options-menu))
535 (define-key global-map [menu-bar edit] (cons "Edit" menu-bar-edit-menu))
536 (define-key global-map [menu-bar file] (cons "File" menu-bar-file-menu))
537
538 ;; If running under GNUstep, rename "Help" to "Info"
539 (cond ((eq system-type 'darwin)
540 (define-key global-map [menu-bar help-menu]
541 (cons "Help" menu-bar-help-menu)))
542 (t
543 (let ((contents (reverse (cdr menu-bar-help-menu))))
544 (setq menu-bar-help-menu
545 (append (list 'keymap) (cdr contents) (list "Info"))))
546 (define-key global-map [menu-bar help-menu]
547 (cons "Info" menu-bar-help-menu))))
548
549 (if (not (eq system-type 'darwin))
550 ;; in OS X it's in the app menu already
551 (define-key menu-bar-help-menu [info-panel]
552 '("About Emacs..." . ns-do-emacs-info-panel)))
553
554
555 ;;;; File menu, replaces standard under ns-extended-platform-support
556 (defvar menu-bar-ns-file-menu (make-sparse-keymap "File"))
557 (define-key menu-bar-ns-file-menu [one-window]
558 '("Remove Splits" . delete-other-windows))
559 (define-key menu-bar-ns-file-menu [split-window]
560 '("Split Window" . split-window-vertically))
561
562 (define-key menu-bar-ns-file-menu [separator-print] '("--"))
563
564 (defvar ns-ps-print-menu-map (make-sparse-keymap "Postscript Print"))
565 (define-key ns-ps-print-menu-map [ps-print-region]
566 '("Region (B+W)" . ps-print-region))
567 (define-key ns-ps-print-menu-map [ps-print-buffer]
568 '("Buffer (B+W)" . ps-print-buffer))
569 (define-key ns-ps-print-menu-map [ps-print-region-faces]
570 '("Region" . ps-print-region-with-faces))
571 (define-key ns-ps-print-menu-map [ps-print-buffer-faces]
572 '("Buffer" . ps-print-buffer-with-faces))
573 (define-key menu-bar-ns-file-menu [postscript-print]
574 (cons "Postscript Print" ns-ps-print-menu-map))
575
576 (define-key menu-bar-ns-file-menu [print-region]
577 '("Print Region" . print-region))
578 (define-key menu-bar-ns-file-menu [print-buffer]
579 '("Print Buffer" . ns-print-buffer))
580
581 (define-key menu-bar-ns-file-menu [separator-save] '("--"))
582
583 (define-key menu-bar-ns-file-menu [recover-session]
584 '("Recover Crashed Session" . recover-session))
585 (define-key menu-bar-ns-file-menu [revert-buffer]
586 '("Revert Buffer" . revert-buffer))
587 (define-key menu-bar-ns-file-menu [write-file]
588 '("Save Buffer As..." . ns-write-file-using-panel))
589 (define-key menu-bar-ns-file-menu [save-buffer] '("Save Buffer" . save-buffer))
590
591 (define-key menu-bar-ns-file-menu [kill-buffer]
592 '("Kill Current Buffer" . kill-this-buffer))
593 (define-key menu-bar-ns-file-menu [delete-this-frame]
594 '("Close Frame" . delete-frame))
595
596 (define-key menu-bar-ns-file-menu [separator-open] '("--"))
597
598 (define-key menu-bar-ns-file-menu [insert-file]
599 '("Insert File..." . insert-file))
600 (define-key menu-bar-ns-file-menu [dired]
601 '("Open Directory..." . ns-open-file-using-panel))
602 (define-key menu-bar-ns-file-menu [open-file]
603 '("Open File..." . ns-open-file-using-panel))
604 (define-key menu-bar-ns-file-menu [make-frame]
605 '("New Frame" . make-frame))
606
607
608 ;;;; Edit menu: Modify slightly
609
610 ;; Substitute a Copy function that works better under X (for GNUstep).
611 (easy-menu-remove-item global-map '("menu-bar" "edit") 'copy)
612 (define-key-after menu-bar-edit-menu [copy]
613 '(menu-item "Copy" ns-copy-including-secondary
614 :enable mark-active
615 :help "Copy text in region between mark and current position")
616 'cut)
617
618 ;; Change to same precondition as select-and-paste, as we don't have
619 ;; `x-selection-exists-p'.
620 (easy-menu-remove-item global-map '("menu-bar" "edit") 'paste)
621 (define-key-after menu-bar-edit-menu [paste]
622 '(menu-item "Paste" yank
623 :enable (and (cdr yank-menu) (not buffer-read-only))
624 :help "Paste (yank) text most recently cut/copied")
625 'copy)
626
627 ;; Change text to be more consistent with surrounding menu items `paste', etc.
628 (easy-menu-remove-item global-map '("menu-bar" "edit") 'paste-from-menu)
629 (define-key-after menu-bar-edit-menu [select-paste]
630 '(menu-item "Select and Paste" yank-menu
631 :enable (and (cdr yank-menu) (not buffer-read-only))
632 :help "Choose a string from the kill ring and paste it")
633 'paste)
634
635 ;; Separate undo from cut/paste section, add spell for platform consistency.
636 (define-key-after menu-bar-edit-menu [separator-undo] '("--") 'undo)
637 (define-key-after menu-bar-edit-menu [spell] '("Spell" . ispell-menu-map) 'fill)
638
639
640 ;;;; Windows menu
641 (defun menu-bar-select-frame (&optional frame)
642 (interactive)
643 (make-frame-visible last-command-event)
644 (raise-frame last-command-event)
645 (select-frame last-command-event))
646
647 (defun menu-bar-update-frames ()
648 ;; If user discards the Windows item, play along.
649 (when (lookup-key (current-global-map) [menu-bar windows])
650 (let ((frames (frame-list))
651 (frames-menu (make-sparse-keymap "Select Frame")))
652 (setcdr frames-menu
653 (nconc
654 (mapcar (lambda (frame)
655 (list* frame
656 (cdr (assq 'name (frame-parameters frame)))
657 'menu-bar-select-frame))
658 frames)
659 (cdr frames-menu)))
660 (define-key frames-menu [separator-frames] '("--"))
661 (define-key frames-menu [popup-color-panel]
662 '("Colors..." . ns-popup-color-panel))
663 (define-key frames-menu [popup-font-panel]
664 '("Font Panel..." . ns-popup-font-panel))
665 (define-key frames-menu [separator-arrange] '("--"))
666 (define-key frames-menu [arrange-all-frames]
667 '("Arrange All Frames" . ns-arrange-all-frames))
668 (define-key frames-menu [arrange-visible-frames]
669 '("Arrange Visible Frames" . ns-arrange-visible-frames))
670 ;; Don't use delete-frame as event name
671 ;; because that is a special event.
672 (define-key (current-global-map) [menu-bar windows]
673 (cons "Windows" frames-menu)))))
674
675 (defun force-menu-bar-update-buffers ()
676 ;; This is a hack to get around fact that we already checked
677 ;; frame-or-buffer-changed-p and reset it, so menu-bar-update-buffers
678 ;; does not pick up any change.
679 (menu-bar-update-buffers t))
680
681 (add-hook 'menu-bar-update-fab-hook 'menu-bar-update-frames)
682 (add-hook 'menu-bar-update-fab-hook 'force-menu-bar-update-buffers)
683
684 (defun menu-bar-update-frames-and-buffers ()
685 (if (frame-or-buffer-changed-p)
686 (run-hooks 'menu-bar-update-fab-hook)))
687
688 (setq menu-bar-update-hook
689 (delq 'menu-bar-update-buffers menu-bar-update-hook))
690 (add-hook 'menu-bar-update-hook 'menu-bar-update-frames-and-buffers)
691
692 (menu-bar-update-frames-and-buffers)
693
694
695 ;; ns-arrange functions contributed
696 ;; by Eberhard Mandler <mandler@dbag.ulm.DaimlerBenz.COM>
697 (defun ns-arrange-all-frames ()
698 "Arranges all frames according to topline"
699 (interactive)
700 (ns-arrange-frames t))
701
702 (defun ns-arrange-visible-frames ()
703 "Arranges all visible frames according to topline"
704 (interactive)
705 (ns-arrange-frames nil))
706
707 (defun ns-arrange-frames ( vis)
708 (let ((frame (next-frame))
709 (end-frame (selected-frame))
710 (inc-x 20) ;relative position of frames
711 (inc-y 22)
712 (x-pos 100) ;start position
713 (y-pos 40)
714 (done nil))
715 (while (not done) ;cycle through all frames
716 (if (not (or vis (eq (frame-visible-p frame) t)))
717 (setq x-pos x-pos); do nothing; true case
718 (set-frame-position frame x-pos y-pos)
719 (setq x-pos (+ x-pos inc-x))
720 (setq y-pos (+ y-pos inc-y))
721 (raise-frame frame))
722 (select-frame frame)
723 (setq frame (next-frame))
724 (setq done (equal frame end-frame)))
725 (set-frame-position end-frame x-pos y-pos)
726 (raise-frame frame)
727 (select-frame frame)))
728
729
730 ;;;; Services
731 (declare-function ns-perform-service "nsfns.m" (service send))
732
733 (defun ns-define-service (path)
734 (let ((mapping [menu-bar services])
735 (service (mapconcat 'identity path "/"))
736 (name (intern
737 (subst-char-in-string
738 ?\s ?-
739 (mapconcat 'identity (cons "ns-service" path) "-")))))
740 ;; This defines the function.
741 (defalias name
742 (lexical-let ((service service))
743 (lambda (arg)
744 (interactive "p")
745 (let* ((in-string
746 (cond ((stringp arg) arg)
747 (mark-active
748 (buffer-substring (region-beginning) (region-end)))))
749 (out-string (ns-perform-service service in-string)))
750 (cond
751 ((stringp arg) out-string)
752 ((and out-string (or (not in-string)
753 (not (string= in-string out-string))))
754 (if mark-active (delete-region (region-beginning) (region-end)))
755 (insert out-string)
756 (setq deactivate-mark nil)))))))
757 (cond
758 ((lookup-key global-map mapping)
759 (while (cdr path)
760 (setq mapping (vconcat mapping (list (intern (car path)))))
761 (if (not (keymapp (lookup-key global-map mapping)))
762 (define-key global-map mapping
763 (cons (car path) (make-sparse-keymap (car path)))))
764 (setq path (cdr path)))
765 (setq mapping (vconcat mapping (list (intern (car path)))))
766 (define-key global-map mapping (cons (car path) name))))
767 name))
768
769 (precompute-menubar-bindings)
770
771 ;; nsterm.m
772 (defvar ns-input-spi-name)
773 (defvar ns-input-spi-arg)
774
775 (defun ns-spi-service-call ()
776 "Respond to a service request."
777 (interactive)
778 (cond ((string-equal ns-input-spi-name "open-selection")
779 (switch-to-buffer (generate-new-buffer "*untitled*"))
780 (insert ns-input-spi-arg))
781 ((string-equal ns-input-spi-name "open-file")
782 (dnd-open-file ns-input-spi-arg nil))
783 ((string-equal ns-input-spi-name "mail-selection")
784 (compose-mail)
785 (rfc822-goto-eoh)
786 (forward-line 1)
787 (insert ns-input-spi-arg))
788 ((string-equal ns-input-spi-name "mail-to")
789 (compose-mail ns-input-spi-arg))
790 (t (error (concat "Service " ns-input-spi-name " not recognized")))))
791
792
793 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
794
795
796
797 ;;;; Composed key sequence handling for Nextstep system input methods.
798 ;;;; (On Nextstep systems, input methods are provided for CJK
799 ;;;; characters, etc. which require multiple keystrokes, and during
800 ;;;; entry a partial ("working") result is typically shown in the
801 ;;;; editing window.)
802
803 (defface ns-working-text-face
804 '((t :underline t))
805 "Face used to highlight working text during compose sequence insert."
806 :group 'ns)
807
808 (defvar ns-working-overlay nil
809 "Overlay used to highlight working text during compose sequence insert.")
810 (make-variable-buffer-local 'ns-working-overlay)
811 (defvar ns-working-overlay-len 0
812 "Length of working text during compose sequence insert.")
813 (make-variable-buffer-local 'ns-working-overlay-len)
814
815 ;; Based on mac-win.el 2007/08/26 unicode-2. This will fail if called
816 ;; from an "interactive" function.
817 (defun ns-in-echo-area ()
818 "Whether, for purposes of inserting working composition text, the minibuffer
819 is currently being used."
820 (or isearch-mode
821 (and cursor-in-echo-area (current-message))
822 ;; Overlay strings are not shown in some cases.
823 (get-char-property (point) 'invisible)
824 (and (not (bobp))
825 (or (and (get-char-property (point) 'display)
826 (eq (get-char-property (1- (point)) 'display)
827 (get-char-property (point) 'display)))
828 (and (get-char-property (point) 'composition)
829 (eq (get-char-property (1- (point)) 'composition)
830 (get-char-property (point) 'composition)))))))
831
832 ;; Currently not used, doesn't work because the 'interactive' here stays
833 ;; for subinvocations.
834 (defun ns-insert-working-text ()
835 (interactive)
836 (if (ns-in-echo-area) (ns-echo-working-text) (ns-put-working-text)))
837
838 (defvar ns-working-text) ; nsterm.m
839
840 (defun ns-put-working-text ()
841 "Insert contents of ns-working-text as UTF8 string and mark with
842 ns-working-overlay. Any previously existing working text is cleared first.
843 The overlay is assigned the face ns-working-text-face."
844 (interactive)
845 (if ns-working-overlay (ns-delete-working-text))
846 (let ((start (point)))
847 (insert ns-working-text)
848 (overlay-put (setq ns-working-overlay (make-overlay start (point)
849 (current-buffer) nil t))
850 'face 'ns-working-text-face)
851 (setq ns-working-overlay-len (+ ns-working-overlay-len (- (point) start)))))
852
853 (defun ns-echo-working-text ()
854 "Echo contents of ns-working-text in message display area.
855 See ns-insert-working-text."
856 (if ns-working-overlay (ns-unecho-working-text))
857 (let* ((msg (current-message))
858 (msglen (length msg))
859 message-log-max)
860 (setq ns-working-overlay-len (length ns-working-text))
861 (setq msg (concat msg ns-working-text))
862 (put-text-property msglen (+ msglen ns-working-overlay-len) 'face 'ns-working-text-face msg)
863 (message "%s" msg)
864 (setq ns-working-overlay t)))
865
866 (defun ns-delete-working-text()
867 "Delete working text and clear ns-working-overlay."
868 (interactive)
869 (delete-backward-char ns-working-overlay-len)
870 (setq ns-working-overlay-len 0)
871 (delete-overlay ns-working-overlay))
872
873 (defun ns-unecho-working-text()
874 "Delete working text from echo area and clear ns-working-overlay."
875 (let ((msg (current-message))
876 message-log-max)
877 (setq msg (substring msg 0 (- (length msg) ns-working-overlay-len)))
878 (setq ns-working-overlay-len 0)
879 (setq ns-working-overlay nil)))
880
881
882 (declare-function ns-convert-utf8-nfd-to-nfc "nsfns.m" (str))
883
884 ;;;; OS X file system Unicode UTF-8 NFD (decomposed form) support
885 ;; Lisp code based on utf-8m.el, by Seiji Zenitani, Eiji Honjoh, and
886 ;; Carsten Bormann.
887 (if (eq system-type 'darwin)
888 (progn
889
890 (defun ns-utf8-nfd-post-read-conversion (length)
891 "Calls ns-convert-utf8-nfd-to-nfc to compose char sequences."
892 (save-excursion
893 (save-restriction
894 (narrow-to-region (point) (+ (point) length))
895 (let ((str (buffer-string)))
896 (delete-region (point-min) (point-max))
897 (insert (ns-convert-utf8-nfd-to-nfc str))
898 (- (point-max) (point-min))
899 ))))
900
901 (define-coding-system 'utf-8-nfd
902 "UTF-8 NFD (decomposed) encoding."
903 :coding-type 'utf-8
904 :mnemonic ?U
905 :charset-list '(unicode)
906 :post-read-conversion 'ns-utf8-nfd-post-read-conversion)
907 (set-file-name-coding-system 'utf-8-nfd)))
908
909 ;; PENDING: disable composition-based display for Indic scripts as it
910 ;; is not working well under Nextstep for some reason
911 (set-char-table-range composition-function-table
912 '(#x0900 . #x0DFF) nil)
913
914
915 ;;;; Inter-app communications support.
916
917 (defvar ns-input-text) ; nsterm.m
918
919 (defun ns-insert-text ()
920 "Insert contents of ns-input-text at point."
921 (interactive)
922 (insert ns-input-text)
923 (setq ns-input-text nil))
924
925 (defun ns-insert-file ()
926 "Insert contents of file ns-input-file like insert-file but with less
927 prompting. If file is a directory perform a find-file on it."
928 (interactive)
929 (let ((f))
930 (setq f (car ns-input-file))
931 (setq ns-input-file (cdr ns-input-file))
932 (if (file-directory-p f)
933 (find-file f)
934 (push-mark (+ (point) (car (cdr (insert-file-contents f))))))))
935
936 (defvar ns-select-overlay nil
937 "Overlay used to highlight areas in files requested by Nextstep apps.")
938 (make-variable-buffer-local 'ns-select-overlay)
939
940 (defvar ns-input-line) ; nsterm.m
941
942 (defun ns-open-file-select-line ()
943 "Open a buffer containing the file `ns-input-file'.
944 Lines are highlighted according to `ns-input-line'."
945 (interactive)
946 (ns-find-file)
947 (cond
948 ((and ns-input-line (buffer-modified-p))
949 (if ns-select-overlay
950 (setq ns-select-overlay (delete-overlay ns-select-overlay)))
951 (deactivate-mark)
952 (goto-line (if (consp ns-input-line)
953 (min (car ns-input-line) (cdr ns-input-line))
954 ns-input-line)))
955 (ns-input-line
956 (if (not ns-select-overlay)
957 (overlay-put (setq ns-select-overlay (make-overlay (point-min) (point-min)))
958 'face 'highlight))
959 (let ((beg (save-excursion
960 (goto-line (if (consp ns-input-line)
961 (min (car ns-input-line) (cdr ns-input-line))
962 ns-input-line))
963 (point)))
964 (end (save-excursion
965 (goto-line (+ 1 (if (consp ns-input-line)
966 (max (car ns-input-line) (cdr ns-input-line))
967 ns-input-line)))
968 (point))))
969 (move-overlay ns-select-overlay beg end)
970 (deactivate-mark)
971 (goto-char beg)))
972 (t
973 (if ns-select-overlay
974 (setq ns-select-overlay (delete-overlay ns-select-overlay))))))
975
976 (defun ns-unselect-line ()
977 "Removes any Nextstep highlight a buffer may contain."
978 (if ns-select-overlay
979 (setq ns-select-overlay (delete-overlay ns-select-overlay))))
980
981 (add-hook 'first-change-hook 'ns-unselect-line)
982
983
984
985 ;;;; Preferences handling.
986 (declare-function ns-get-resource "nsfns.m" (owner name))
987
988 (defun get-lisp-resource (arg1 arg2)
989 (let ((res (ns-get-resource arg1 arg2)))
990 (cond
991 ((not res) 'unbound)
992 ((string-equal (upcase res) "YES") t)
993 ((string-equal (upcase res) "NO") nil)
994 (t (read res)))))
995
996 ;; nsterm.m
997 (defvar ns-command-modifier)
998 (defvar ns-control-modifier)
999 (defvar ns-function-modifier)
1000 (defvar ns-antialias-text)
1001 (defvar ns-use-qd-smoothing)
1002 (defvar ns-use-system-highlight-color)
1003
1004 (declare-function ns-set-resource "nsfns.m" (owner name value))
1005 (declare-function ns-font-name "nsfns.m" (name))
1006 (declare-function ns-read-file-name "nsfns.m"
1007 (prompt &optional dir isLoad init))
1008
1009 (defun ns-save-preferences ()
1010 "Set all the defaults."
1011 (interactive)
1012 ;; Global preferences
1013 (ns-set-resource nil "AlternateModifier" (symbol-name ns-alternate-modifier))
1014 (ns-set-resource nil "CommandModifier" (symbol-name ns-command-modifier))
1015 (ns-set-resource nil "ControlModifier" (symbol-name ns-control-modifier))
1016 (ns-set-resource nil "FunctionModifier" (symbol-name ns-function-modifier))
1017 (ns-set-resource nil "CursorBlinkRate"
1018 (if ns-cursor-blink-rate
1019 (number-to-string ns-cursor-blink-rate)
1020 "NO"))
1021 (ns-set-resource nil "ExpandSpace"
1022 (if ns-expand-space
1023 (number-to-string ns-expand-space)
1024 "NO"))
1025 (ns-set-resource nil "GSFontAntiAlias" (if ns-antialias-text "YES" "NO"))
1026 (ns-set-resource nil "UseQuickdrawSmoothing"
1027 (if ns-use-qd-smoothing "YES" "NO"))
1028 (ns-set-resource nil "UseSystemHighlightColor"
1029 (if ns-use-system-highlight-color "YES" "NO"))
1030 ;; Default frame parameters
1031 (let ((p (frame-parameters))
1032 v)
1033 (if (setq v (assq 'font p))
1034 (ns-set-resource nil "Font" (ns-font-name (cdr v))))
1035 (if (setq v (assq 'fontsize p))
1036 (ns-set-resource nil "FontSize" (number-to-string (cdr v))))
1037 (if (setq v (assq 'foreground-color p))
1038 (ns-set-resource nil "Foreground" (cdr v)))
1039 (if (setq v (assq 'background-color p))
1040 (ns-set-resource nil "Background" (cdr v)))
1041 (if (setq v (assq 'cursor-color p))
1042 (ns-set-resource nil "CursorColor" (cdr v)))
1043 (if (setq v (assq 'cursor-type p))
1044 (ns-set-resource nil "CursorType" (if (symbolp (cdr v))
1045 (symbol-name (cdr v))
1046 (cdr v))))
1047 (if (setq v (assq 'underline p))
1048 (ns-set-resource nil "Underline"
1049 (case (cdr v)
1050 ((t) "YES")
1051 ((nil) "NO")
1052 (t (cdr v)))))
1053 (if (setq v (assq 'internal-border-width p))
1054 (ns-set-resource nil "InternalBorderWidth"
1055 (number-to-string (cdr v))))
1056 (if (setq v (assq 'vertical-scroll-bars p))
1057 (ns-set-resource nil "VerticalScrollBars"
1058 (case (cdr v)
1059 ((t) "YES")
1060 ((nil) "NO")
1061 ((left) "left")
1062 ((right) "right")
1063 (t nil))))
1064 (if (setq v (assq 'height p))
1065 (ns-set-resource nil "Height" (number-to-string (cdr v))))
1066 (if (setq v (assq 'width p))
1067 (ns-set-resource nil "Width" (number-to-string (cdr v))))
1068 (if (setq v (assq 'top p))
1069 (ns-set-resource nil "Top" (number-to-string (cdr v))))
1070 (if (setq v (assq 'left p))
1071 (ns-set-resource nil "Left" (number-to-string (cdr v))))
1072 ;; These not fully supported
1073 (if (setq v (assq 'auto-raise p))
1074 (ns-set-resource nil "AutoRaise" (if (cdr v) "YES" "NO")))
1075 (if (setq v (assq 'auto-lower p))
1076 (ns-set-resource nil "AutoLower" (if (cdr v) "YES" "NO")))
1077 (if (setq v (assq 'menu-bar-lines p))
1078 (ns-set-resource nil "Menus" (if (cdr v) "YES" "NO")))
1079 )
1080 (let ((fl (face-list)))
1081 (while (consp fl)
1082 (or (eq 'default (car fl))
1083 ;; dont save Default* since it causes all created faces to
1084 ;; inherit its values. The properties of the default face
1085 ;; have already been saved from the frame-parameters anyway.
1086 (let* ((name (symbol-name (car fl)))
1087 (font (face-font (car fl)))
1088 ;; (fontsize (face-fontsize (car fl)))
1089 (foreground (face-foreground (car fl)))
1090 (background (face-background (car fl)))
1091 (underline (face-underline-p (car fl)))
1092 (italic (face-italic-p (car fl)))
1093 (bold (face-bold-p (car fl)))
1094 (stipple (face-stipple (car fl))))
1095 ;; (ns-set-resource nil (concat name ".attributeFont")
1096 ;; (if font font nil))
1097 ;; (ns-set-resource nil (concat name ".attributeFontSize")
1098 ;; (if fontsize (number-to-string fontsize) nil))
1099 (ns-set-resource nil (concat name ".attributeForeground")
1100 (if foreground foreground nil))
1101 (ns-set-resource nil (concat name ".attributeBackground")
1102 (if background background nil))
1103 (ns-set-resource nil (concat name ".attributeUnderline")
1104 (if underline "YES" nil))
1105 (ns-set-resource nil (concat name ".attributeItalic")
1106 (if italic "YES" nil))
1107 (ns-set-resource nil (concat name ".attributeBold")
1108 (if bold "YES" nil))
1109 (and stipple
1110 (or (stringp stipple)
1111 (setq stipple (prin1-to-string stipple))))
1112 (ns-set-resource nil (concat name ".attributeStipple")
1113 (if stipple stipple nil))))
1114 (setq fl (cdr fl)))))
1115
1116 (declare-function menu-bar-options-save-orig "ns-win" () t)
1117
1118 ;; call ns-save-preferences when menu-bar-options-save is called
1119 (fset 'menu-bar-options-save-orig (symbol-function 'menu-bar-options-save))
1120 (defun ns-save-options ()
1121 (interactive)
1122 (menu-bar-options-save-orig)
1123 (ns-save-preferences))
1124 (fset 'menu-bar-options-save (symbol-function 'ns-save-options))
1125
1126
1127 ;;;; File handling.
1128
1129 (defun ns-open-file-using-panel ()
1130 "Pop up open-file panel, and load the result in a buffer."
1131 (interactive)
1132 ;; Prompt dir defaultName isLoad initial.
1133 (setq ns-input-file (ns-read-file-name "Select File to Load" nil t nil))
1134 (if ns-input-file
1135 (and (setq ns-input-file (list ns-input-file)) (ns-find-file))))
1136
1137 (defun ns-write-file-using-panel ()
1138 "Pop up save-file panel, and save buffer in resulting name."
1139 (interactive)
1140 (let (ns-output-file)
1141 ;; Prompt dir defaultName isLoad initial.
1142 (setq ns-output-file (ns-read-file-name "Save As" nil nil nil))
1143 (message ns-output-file)
1144 (if ns-output-file (write-file ns-output-file))))
1145
1146 (defvar ns-pop-up-frames 'fresh
1147 "*Non-nil means open files upon request from the Workspace in a new frame.
1148 If t, always do so. Any other non-nil value means open a new frame
1149 unless the current buffer is a scratch buffer.")
1150
1151 (declare-function ns-hide-emacs "nsfns.m" (on))
1152
1153 (defun ns-find-file ()
1154 "Do a find-file with the ns-input-file as argument."
1155 (interactive)
1156 (let ((f) (file) (bufwin1) (bufwin2))
1157 (setq f (file-truename (car ns-input-file)))
1158 (setq ns-input-file (cdr ns-input-file))
1159 (setq file (find-file-noselect f))
1160 (setq bufwin1 (get-buffer-window file 'visible))
1161 (setq bufwin2 (get-buffer-window "*scratch*" 'visibile))
1162 (cond
1163 (bufwin1
1164 (select-frame (window-frame bufwin1))
1165 (raise-frame (window-frame bufwin1))
1166 (select-window bufwin1))
1167 ((and (eq ns-pop-up-frames 'fresh) bufwin2)
1168 (ns-hide-emacs 'activate)
1169 (select-frame (window-frame bufwin2))
1170 (raise-frame (window-frame bufwin2))
1171 (select-window bufwin2)
1172 (find-file f))
1173 (ns-pop-up-frames
1174 (ns-hide-emacs 'activate)
1175 (let ((pop-up-frames t)) (pop-to-buffer file nil)))
1176 (t
1177 (ns-hide-emacs 'activate)
1178 (find-file f)))))
1179
1180
1181
1182 ;;;; Frame-related functions.
1183
1184 ;; Don't show the frame name; that's redundant with Nextstep.
1185 (setq-default mode-line-frame-identification '(" "))
1186
1187 ;; You say tomAYto, I say tomAHto..
1188 (defvaralias 'ns-option-modifier 'ns-alternate-modifier)
1189
1190 (defun ns-do-hide-emacs ()
1191 (interactive)
1192 (ns-hide-emacs t))
1193
1194 (declare-function ns-hide-others "nsfns.m" ())
1195
1196 (defun ns-do-hide-others ()
1197 (interactive)
1198 (ns-hide-others))
1199
1200 (declare-function ns-emacs-info-panel "nsfns.m" ())
1201
1202 (defun ns-do-emacs-info-panel ()
1203 (interactive)
1204 (ns-emacs-info-panel))
1205
1206 (defun ns-next-frame ()
1207 "Switch to next visible frame."
1208 (interactive)
1209 (other-frame 1))
1210 (defun ns-prev-frame ()
1211 "Switch to previous visible frame."
1212 (interactive)
1213 (other-frame -1))
1214
1215 ;; If no position specified, make new frame offset by 25 from current.
1216 (defvar parameters) ; dynamically bound in make-frame
1217
1218 (add-hook 'before-make-frame-hook
1219 (lambda ()
1220 (let ((left (cdr (assq 'left (frame-parameters))))
1221 (top (cdr (assq 'top (frame-parameters)))))
1222 (if (consp left) (setq left (cadr left)))
1223 (if (consp top) (setq top (cadr top)))
1224 (cond
1225 ((or (assq 'top parameters) (assq 'left parameters)))
1226 ((or (not left) (not top)))
1227 (t
1228 (setq parameters (cons (cons 'left (+ left 25))
1229 (cons (cons 'top (+ top 25))
1230 parameters))))))))
1231
1232 ;; frame will be focused anyway, so select it
1233 (add-hook 'after-make-frame-functions 'select-frame)
1234
1235 ;; (defun ns-win-suspend-error ()
1236 ;; (error "Suspending an emacs running under *Step/OS X makes no sense"))
1237 ;; (add-hook 'suspend-hook 'ns-win-suspend-error)
1238 ;; (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1239 ;; global-map)
1240
1241 ;; Based on a function by David Reitter <dreitter@inf.ed.ac.uk> ;
1242 ;; see http://lists.gnu.org/archive/html/emacs-devel/2005-09/msg00681.html .
1243 (defun ns-toggle-toolbar (&optional frame)
1244 "Switches the tool bar on and off in frame FRAME.
1245 If FRAME is nil, the change applies to the selected frame."
1246 (interactive)
1247 (modify-frame-parameters
1248 frame (list (cons 'tool-bar-lines
1249 (if (> (or (frame-parameter frame 'tool-bar-lines) 0) 0)
1250 0 1)) ))
1251 (if (not tool-bar-mode) (tool-bar-mode t)))
1252
1253 (defvar ns-cursor-blink-mode) ; nsterm.m
1254
1255 ;; Redefine from frame.el.
1256 (define-minor-mode blink-cursor-mode
1257 "Toggle blinking cursor mode.
1258 With a numeric argument, turn blinking cursor mode on if ARG is positive,
1259 otherwise turn it off. When blinking cursor mode is enabled, the
1260 cursor of the selected window blinks.
1261
1262 Note that this command is effective only when Emacs
1263 displays through a window system, because then Emacs does its own
1264 cursor display. On a text-only terminal, this is not implemented."
1265 :init-value (not (or noninteractive
1266 no-blinking-cursor
1267 (eq ns-cursor-blink-rate nil)))
1268 :initialize 'custom-initialize-safe-default
1269 :group 'cursor
1270 :global t
1271 (if blink-cursor-mode
1272 (setq ns-cursor-blink-mode t)
1273 (setq ns-cursor-blink-mode nil)))
1274
1275
1276
1277 ;;;; Dialog-related functions.
1278
1279 ;; Ask user for confirm before printing. Due to Kevin Rodgers.
1280 (defun ns-print-buffer ()
1281 "Interactive front-end to `print-buffer': asks for user confirmation first."
1282 (interactive)
1283 (if (and (interactive-p)
1284 (or (listp last-nonmenu-event)
1285 (and (char-or-string-p (event-basic-type last-command-event))
1286 (memq 'super (event-modifiers last-command-event)))))
1287 (let ((last-nonmenu-event (if (listp last-nonmenu-event)
1288 last-nonmenu-event
1289 ;; Fake it:
1290 `(mouse-1 POSITION 1))))
1291 (if (y-or-n-p (format "Print buffer %s? " (buffer-name)))
1292 (print-buffer)
1293 (error "Cancelled")))
1294 (print-buffer)))
1295
1296 (defun ns-yes-or-no-p (prompt)
1297 "Ask user a \"yes or no\" question using a Nextstep graphical panel.
1298 PROMPT is the prompt string."
1299 (interactive)
1300 (setq last-nonmenu-event nil)
1301 (yes-or-no-p prompt))
1302
1303
1304 ;;;; Font support.
1305
1306 ;; Needed for font listing functions under both backend and normal
1307 (setq scalable-fonts-allowed t)
1308
1309 ;; Set to use font panel instead
1310 (defalias 'generate-fontset-menu 'ns-popup-font-panel)
1311 (defalias 'mouse-set-font 'ns-popup-font-panel)
1312
1313 ;; nsterm.m
1314 (defvar ns-input-font)
1315 (defvar ns-input-fontsize)
1316
1317 (defun ns-respond-to-change-font ()
1318 "Respond to changeFont: event, expecting ns-input-font and\n\
1319 ns-input-fontsize of new font."
1320 (interactive)
1321 (modify-frame-parameters (selected-frame)
1322 (list (cons 'font ns-input-font)
1323 (cons 'fontsize ns-input-fontsize)))
1324 (set-frame-font ns-input-font))
1325
1326
1327 ;; Default fontset for Mac OS X. This is mainly here to show how a fontset
1328 ;; can be set up manually. Ordinarily, fontsets are auto-created whenever
1329 ;; a font is chosen by
1330 (defvar ns-standard-fontset-spec
1331 ;; Only some code supports this so far, so use uglier XLFD version
1332 ;; "-ns-*-*-*-*-*-10-*-*-*-*-*-fontset-standard,latin:Courier,han:Kai"
1333 (mapconcat 'identity
1334 '("-ns-*-*-*-*-*-10-*-*-*-*-*-fontset-standard"
1335 "latin:-*-Courier-*-*-*-*-10-*-*-*-*-*-iso10646-1"
1336 "han:-*-Kai-*-*-*-*-10-*-*-*-*-*-iso10646-1"
1337 "cyrillic:-*-Trebuchet$MS-*-*-*-*-10-*-*-*-*-*-iso10646-1")
1338 ",")
1339 "String of fontset spec of the standard fontset.
1340 This defines a fontset consisting of the Courier and other fonts that
1341 come with OS X\".
1342 See the documentation of `create-fontset-from-fontset-spec for the format.")
1343
1344 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles.
1345 (if (fboundp 'new-fontset)
1346 (progn
1347 ;; Setup the default fontset.
1348 (setup-default-fontset)
1349 ;; Create the standard fontset.
1350 (create-fontset-from-fontset-spec ns-standard-fontset-spec t)))
1351
1352 ;;(push (cons 'font "-ns-*-*-*-*-*-10-*-*-*-*-*-fontset-standard")
1353 ;; default-frame-alist)
1354
1355 ;; Add some additional scripts to var we use for fontset generation.
1356 (setq script-representative-chars
1357 (cons '(kana #xff8a)
1358 (cons '(symbol #x2295 #x2287 #x25a1)
1359 script-representative-chars)))
1360
1361
1362 ;;;; Pasteboard support.
1363
1364 (declare-function ns-get-cut-buffer-internal "nsselect.m" (buffer))
1365
1366 (defun ns-get-pasteboard ()
1367 "Returns the value of the pasteboard."
1368 (ns-get-cut-buffer-internal 'PRIMARY))
1369
1370 (declare-function ns-store-cut-buffer-internal "nsselect.m" (buffer string))
1371
1372 (defun ns-set-pasteboard (string)
1373 "Store STRING into the pasteboard of the Nextstep display server."
1374 ;; Check the data type of STRING.
1375 (if (not (stringp string)) (error "Nonstring given to pasteboard"))
1376 (ns-store-cut-buffer-internal 'PRIMARY string))
1377
1378 ;; We keep track of the last text selected here, so we can check the
1379 ;; current selection against it, and avoid passing back our own text
1380 ;; from x-cut-buffer-or-selection-value.
1381 (defvar ns-last-selected-text nil)
1382
1383 (defun x-select-text (text &optional push)
1384 "Put TEXT, a string, on the pasteboard."
1385 ;; Don't send the pasteboard too much text.
1386 ;; It becomes slow, and if really big it causes errors.
1387 (ns-set-pasteboard text)
1388 (setq ns-last-selected-text text))
1389
1390 ;; Return the value of the current Nextstep selection. For
1391 ;; compatibility with older Nextstep applications, this checks cut
1392 ;; buffer 0 before retrieving the value of the primary selection.
1393 (defun x-cut-buffer-or-selection-value ()
1394 (let (text)
1395
1396 ;; Consult the selection, then the cut buffer. Treat empty strings
1397 ;; as if they were unset.
1398 (or text (setq text (ns-get-pasteboard)))
1399 (if (string= text "") (setq text nil))
1400
1401 (cond
1402 ((not text) nil)
1403 ((eq text ns-last-selected-text) nil)
1404 ((string= text ns-last-selected-text)
1405 ;; Record the newer string, so subsequent calls can use the `eq' test.
1406 (setq ns-last-selected-text text)
1407 nil)
1408 (t
1409 (setq ns-last-selected-text text)))))
1410
1411 (defun ns-copy-including-secondary ()
1412 (interactive)
1413 (call-interactively 'kill-ring-save)
1414 (ns-store-cut-buffer-internal 'SECONDARY
1415 (buffer-substring (point) (mark t))))
1416 (defun ns-paste-secondary ()
1417 (interactive)
1418 (insert (ns-get-cut-buffer-internal 'SECONDARY)))
1419
1420 ;; PENDING: not sure what to do here.. for now interprog- are set in
1421 ;; init-fn-keys, and unsure whether these x- settings have an effect.
1422 ;;(setq interprogram-cut-function 'x-select-text
1423 ;; interprogram-paste-function 'x-cut-buffer-or-selection-value)
1424 ;; These only needed if above not working.
1425
1426 (set-face-background 'region "ns_selection_color")
1427
1428
1429
1430 ;;;; Scrollbar handling.
1431
1432 (global-set-key [vertical-scroll-bar down-mouse-1] 'ns-handle-scroll-bar-event)
1433 (global-unset-key [vertical-scroll-bar mouse-1])
1434 (global-unset-key [vertical-scroll-bar drag-mouse-1])
1435
1436 (defun ns-scroll-bar-move (event)
1437 "Scroll the frame according to an Nextstep scroller event."
1438 (interactive "e")
1439 (let* ((pos (event-end event))
1440 (window (nth 0 pos))
1441 (scale (nth 2 pos)))
1442 (save-excursion
1443 (set-buffer (window-buffer window))
1444 (cond
1445 ((eq (car scale) (cdr scale))
1446 (goto-char (point-max)))
1447 ((= (car scale) 0)
1448 (goto-char (point-min)))
1449 (t
1450 (goto-char (+ (point-min) 1
1451 (scroll-bar-scale scale (- (point-max) (point-min)))))))
1452 (beginning-of-line)
1453 (set-window-start window (point))
1454 (vertical-motion (/ (window-height window) 2) window))))
1455
1456 (defun ns-handle-scroll-bar-event (event)
1457 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
1458 (interactive "e")
1459 (let* ((position (event-start event))
1460 (bar-part (nth 4 position))
1461 (window (nth 0 position))
1462 (old-window (selected-window)))
1463 (cond
1464 ((eq bar-part 'ratio)
1465 (ns-scroll-bar-move event))
1466 ((eq bar-part 'handle)
1467 (if (eq window (selected-window))
1468 (track-mouse (ns-scroll-bar-move event))
1469 ;; track-mouse faster for selected window, slower for unselected.
1470 (ns-scroll-bar-move event)))
1471 (t
1472 (select-window window)
1473 (cond
1474 ((eq bar-part 'up)
1475 (goto-char (window-start window))
1476 (scroll-down 1))
1477 ((eq bar-part 'above-handle)
1478 (scroll-down))
1479 ((eq bar-part 'below-handle)
1480 (scroll-up))
1481 ((eq bar-part 'down)
1482 (goto-char (window-start window))
1483 (scroll-up 1)))
1484 (select-window old-window)))))
1485
1486
1487 ;;;; Color support.
1488
1489 (declare-function ns-list-colors "nsfns.m" (&optional frame))
1490
1491 (defvar x-colors (ns-list-colors)
1492 "The list of colors defined in non-PANTONE color files.")
1493 (defvar colors x-colors
1494 "The list of colors defined in non-PANTONE color files.")
1495
1496 (defun xw-defined-colors (&optional frame)
1497 "Return a list of colors supported for a particular frame.
1498 The argument FRAME specifies which frame to try.
1499 The value may be different for frames on different Nextstep displays."
1500 (or frame (setq frame (selected-frame)))
1501 (let ((all-colors x-colors)
1502 (this-color nil)
1503 (defined-colors nil))
1504 (while all-colors
1505 (setq this-color (car all-colors)
1506 all-colors (cdr all-colors))
1507 ;; (and (face-color-supported-p frame this-color t)
1508 (setq defined-colors (cons this-color defined-colors))) ;;)
1509 defined-colors))
1510
1511 (declare-function ns-set-alpha "nsfns.m" (color alpha))
1512
1513 ;; Convenience and work-around for fact that set color fns now require named.
1514 (defun ns-set-background-alpha (alpha)
1515 "Sets alpha (opacity) of background.
1516 Set from 0.0 (fully transparent) to 1.0 (fully opaque; default).
1517 Note, tranparency works better on Tiger (10.4) and higher."
1518 (interactive "nSet background alpha to: ")
1519 (let ((bgcolor (cdr (assq 'background-color (frame-parameters)))))
1520 (set-frame-parameter (selected-frame)
1521 'background-color (ns-set-alpha bgcolor alpha))))
1522
1523 ;; Functions for color panel + drag
1524 (defun ns-face-at-pos (pos)
1525 (let* ((frame (car pos))
1526 (frame-pos (cons (cadr pos) (cddr pos)))
1527 (window (window-at (car frame-pos) (cdr frame-pos) frame))
1528 (window-pos (coordinates-in-window-p frame-pos window))
1529 (buffer (window-buffer window))
1530 (edges (window-edges window)))
1531 (cond
1532 ((not window-pos)
1533 nil)
1534 ((eq window-pos 'mode-line)
1535 'modeline)
1536 ((eq window-pos 'vertical-line)
1537 'default)
1538 ((consp window-pos)
1539 (save-excursion
1540 (set-buffer buffer)
1541 (let ((p (car (compute-motion (window-start window)
1542 (cons (nth 0 edges) (nth 1 edges))
1543 (window-end window)
1544 frame-pos
1545 (- (window-width window) 1)
1546 nil
1547 window))))
1548 (cond
1549 ((eq p (window-point window))
1550 'cursor)
1551 ((and mark-active (< (region-beginning) p) (< p (region-end)))
1552 'region)
1553 (t
1554 (let ((faces (get-char-property p 'face window)))
1555 (if (consp faces) (car faces) faces)))))))
1556 (t
1557 nil))))
1558
1559 (defvar ns-input-color) ; nsterm.m
1560
1561 (defun ns-set-foreground-at-mouse ()
1562 "Set the foreground color at the mouse location to ns-input-color."
1563 (interactive)
1564 (let* ((pos (mouse-position))
1565 (frame (car pos))
1566 (face (ns-face-at-pos pos)))
1567 (cond
1568 ((eq face 'cursor)
1569 (modify-frame-parameters frame (list (cons 'cursor-color
1570 ns-input-color))))
1571 ((not face)
1572 (modify-frame-parameters frame (list (cons 'foreground-color
1573 ns-input-color))))
1574 (t
1575 (set-face-foreground face ns-input-color frame)))))
1576
1577 (defun ns-set-background-at-mouse ()
1578 "Set the background color at the mouse location to ns-input-color."
1579 (interactive)
1580 (let* ((pos (mouse-position))
1581 (frame (car pos))
1582 (face (ns-face-at-pos pos)))
1583 (cond
1584 ((eq face 'cursor)
1585 (modify-frame-parameters frame (list (cons 'cursor-color
1586 ns-input-color))))
1587 ((not face)
1588 (modify-frame-parameters frame (list (cons 'background-color
1589 ns-input-color))))
1590 (t
1591 (set-face-background face ns-input-color frame)))))
1592
1593 ;; Set some options to be as Nextstep-like as possible.
1594 (setq frame-title-format t
1595 icon-title-format t)
1596
1597 ;; Set up browser connectivity.
1598 (defvar browse-url-generic-program)
1599
1600 (setq browse-url-browser-function 'browse-url-generic)
1601 (setq browse-url-generic-program
1602 (cond ((eq system-type 'darwin) "open")
1603 ;; Otherwise, GNUstep.
1604 (t "gopen")))
1605
1606
1607 (defvar ns-initialized nil
1608 "Non-nil if Nextstep windowing has been initialized.")
1609
1610 (declare-function ns-list-services "nsfns.m" ())
1611
1612 ;; Do the actual Nextstep Windows setup here; the above code just
1613 ;; defines functions and variables that we use now.
1614 (defun ns-initialize-window-system ()
1615 "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
1616
1617 ;; PENDING: not needed?
1618 (setq command-line-args (ns-handle-args command-line-args))
1619
1620 (x-open-connection (system-name) nil t)
1621
1622 (dolist (service (ns-list-services))
1623 (if (eq (car service) 'undefined)
1624 (ns-define-service (cdr service))
1625 (define-key global-map (vector (car service))
1626 (ns-define-service (cdr service)))))
1627
1628 (if (and (eq (get-lisp-resource nil "NXAutoLaunch") t)
1629 (eq (get-lisp-resource nil "HideOnAutoLaunch") t))
1630 (add-hook 'after-init-hook 'ns-do-hide-emacs))
1631
1632 ;; FIXME: This will surely lead to "MODIFIED OUTSIDE CUSTOM" warnings.
1633 (menu-bar-mode (if (get-lisp-resource nil "Menus") 1 -1))
1634 (mouse-wheel-mode 1)
1635
1636 (setq ns-initialized t))
1637
1638 (add-to-list 'handle-args-function-alist '(ns . ns-handle-args))
1639 (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
1640 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
1641
1642
1643 (provide 'ns-win)
1644
1645 ;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644
1646 ;;; ns-win.el ends here