Commit | Line | Data |
---|---|---|
ee78dc32 | 1 | ;;; win32-win.el --- parse switches controlling interface with win32 |
2fe590dc | 2 | |
ee78dc32 GV |
3 | ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
4 | ||
5 | ;; Author: Kevin Gallo | |
6 | ;; Keywords: terminals | |
7 | ||
2fe590dc EN |
8 | ;; This file is part of GNU Emacs. |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
ee78dc32 GV |
24 | |
25 | ;;; Commentary: | |
26 | ||
27 | ;; win32-win.el: this file is loaded from ../lisp/startup.el when it recognizes | |
28 | ;; that win32 windows are to be used. Command line switches are parsed and those | |
29 | ;; pertaining to win32 are processed and removed from the command line. The | |
30 | ;; win32 display is opened and hooks are set for popping up the initial window. | |
31 | ||
32 | ;; startup.el will then examine startup files, and eventually call the hooks | |
33 | ;; which create the first window (s). | |
34 | ||
35 | ;;; Code: | |
36 | \f | |
37 | ||
38 | ;; These are the standard X switches from the Xt Initialize.c file of | |
39 | ;; Release 4. | |
40 | ||
41 | ;; Command line Resource Manager string | |
42 | ||
43 | ;; +rv *reverseVideo | |
44 | ;; +synchronous *synchronous | |
45 | ;; -background *background | |
46 | ;; -bd *borderColor | |
47 | ;; -bg *background | |
48 | ;; -bordercolor *borderColor | |
49 | ;; -borderwidth .borderWidth | |
50 | ;; -bw .borderWidth | |
51 | ;; -display .display | |
52 | ;; -fg *foreground | |
53 | ;; -fn *font | |
54 | ;; -font *font | |
55 | ;; -foreground *foreground | |
56 | ;; -geometry .geometry | |
57 | ;; -i .iconType | |
58 | ;; -itype .iconType | |
59 | ;; -iconic .iconic | |
60 | ;; -name .name | |
61 | ;; -reverse *reverseVideo | |
62 | ;; -rv *reverseVideo | |
63 | ;; -selectionTimeout .selectionTimeout | |
64 | ;; -synchronous *synchronous | |
65 | ;; -xrm | |
66 | ||
67 | ;; An alist of X options and the function which handles them. See | |
68 | ;; ../startup.el. | |
69 | ||
70 | (if (not (eq window-system 'win32)) | |
71 | (error "%s: Loading win32-win.el but not compiled for win32" (invocation-name))) | |
72 | ||
73 | (require 'frame) | |
74 | (require 'mouse) | |
75 | (require 'scroll-bar) | |
76 | (require 'faces) | |
77 | (require 'select) | |
78 | (require 'menu-bar) | |
79 | ||
fe07d75e GV |
80 | ;; Disable until scrollbars are fully functional |
81 | (scroll-bar-mode nil) | |
82 | ||
ee78dc32 GV |
83 | (defvar x-invocation-args) |
84 | ||
85 | (defvar x-command-line-resources nil) | |
86 | ||
87 | (defconst x-option-alist | |
88 | '(("-bw" . x-handle-numeric-switch) | |
89 | ("-d" . x-handle-display) | |
90 | ("-display" . x-handle-display) | |
91 | ("-name" . x-handle-name-rn-switch) | |
92 | ("-rn" . x-handle-name-rn-switch) | |
93 | ("-T" . x-handle-switch) | |
94 | ("-r" . x-handle-switch) | |
95 | ("-rv" . x-handle-switch) | |
96 | ("-reverse" . x-handle-switch) | |
97 | ("-fn" . x-handle-switch) | |
98 | ("-font" . x-handle-switch) | |
99 | ("-ib" . x-handle-numeric-switch) | |
100 | ("-g" . x-handle-geometry) | |
101 | ("-geometry" . x-handle-geometry) | |
102 | ("-fg" . x-handle-switch) | |
103 | ("-foreground". x-handle-switch) | |
104 | ("-bg" . x-handle-switch) | |
105 | ("-background". x-handle-switch) | |
106 | ("-ms" . x-handle-switch) | |
107 | ("-itype" . x-handle-switch) | |
108 | ("-i" . x-handle-switch) | |
109 | ("-iconic" . x-handle-iconic) | |
110 | ("-xrm" . x-handle-xrm-switch) | |
111 | ("-cr" . x-handle-switch) | |
112 | ("-vb" . x-handle-switch) | |
113 | ("-hb" . x-handle-switch) | |
114 | ("-bd" . x-handle-switch))) | |
115 | ||
116 | (defconst x-long-option-alist | |
117 | '(("--border-width" . "-bw") | |
118 | ("--display" . "-d") | |
119 | ("--name" . "-name") | |
120 | ("--title" . "-T") | |
121 | ("--reverse-video" . "-reverse") | |
122 | ("--font" . "-font") | |
123 | ("--internal-border" . "-ib") | |
124 | ("--geometry" . "-geometry") | |
125 | ("--foreground-color" . "-fg") | |
126 | ("--background-color" . "-bg") | |
127 | ("--mouse-color" . "-ms") | |
128 | ("--icon-type" . "-itype") | |
129 | ("--iconic" . "-iconic") | |
130 | ("--xrm" . "-xrm") | |
131 | ("--cursor-color" . "-cr") | |
132 | ("--vertical-scroll-bars" . "-vb") | |
133 | ("--border-color" . "-bd"))) | |
134 | ||
135 | (defconst x-switch-definitions | |
136 | '(("-name" name) | |
137 | ("-T" name) | |
138 | ("-r" reverse t) | |
139 | ("-rv" reverse t) | |
140 | ("-reverse" reverse t) | |
141 | ("-fn" font) | |
142 | ("-font" font) | |
143 | ("-ib" internal-border-width) | |
144 | ("-fg" foreground-color) | |
145 | ("-foreground" foreground-color) | |
146 | ("-bg" background-color) | |
147 | ("-background" background-color) | |
148 | ("-ms" mouse-color) | |
149 | ("-cr" cursor-color) | |
150 | ("-itype" icon-type t) | |
151 | ("-i" icon-type t) | |
152 | ("-vb" vertical-scroll-bars t) | |
153 | ("-hb" horizontal-scroll-bars t) | |
154 | ("-bd" border-color) | |
155 | ("-bw" border-width))) | |
156 | ||
157 | ;; Handler for switches of the form "-switch value" or "-switch". | |
158 | (defun x-handle-switch (switch) | |
159 | (let ((aelt (assoc switch x-switch-definitions))) | |
160 | (if aelt | |
161 | (if (nth 2 aelt) | |
162 | (setq default-frame-alist | |
163 | (cons (cons (nth 1 aelt) (nth 2 aelt)) | |
164 | default-frame-alist)) | |
165 | (setq default-frame-alist | |
166 | (cons (cons (nth 1 aelt) | |
167 | (car x-invocation-args)) | |
168 | default-frame-alist) | |
169 | x-invocation-args (cdr x-invocation-args)))))) | |
170 | ||
171 | ;; Make -iconic apply only to the initial frame! | |
172 | (defun x-handle-iconic (switch) | |
173 | (setq initial-frame-alist | |
174 | (cons '(visibility . icon) initial-frame-alist))) | |
175 | ||
176 | ;; Handler for switches of the form "-switch n" | |
177 | (defun x-handle-numeric-switch (switch) | |
178 | (let ((aelt (assoc switch x-switch-definitions))) | |
179 | (if aelt | |
180 | (setq default-frame-alist | |
181 | (cons (cons (nth 1 aelt) | |
182 | (string-to-int (car x-invocation-args))) | |
183 | default-frame-alist) | |
184 | x-invocation-args | |
185 | (cdr x-invocation-args))))) | |
186 | ||
187 | ;; Handle the -xrm option. | |
188 | (defun x-handle-xrm-switch (switch) | |
189 | (or (consp x-invocation-args) | |
190 | (error "%s: missing argument to `%s' option" (invocation-name) switch)) | |
191 | (setq x-command-line-resources (car x-invocation-args)) | |
192 | (setq x-invocation-args (cdr x-invocation-args))) | |
193 | ||
194 | ;; Handle the geometry option | |
195 | (defun x-handle-geometry (switch) | |
196 | (let ((geo (x-parse-geometry (car x-invocation-args)))) | |
197 | (setq initial-frame-alist | |
198 | (append initial-frame-alist | |
199 | (if (or (assq 'left geo) (assq 'top geo)) | |
200 | '((user-position . t))) | |
201 | (if (or (assq 'height geo) (assq 'width geo)) | |
202 | '((user-size . t))) | |
203 | geo) | |
204 | x-invocation-args (cdr x-invocation-args)))) | |
205 | ||
206 | ;; Handle the -name and -rn options. Set the variable x-resource-name | |
207 | ;; to the option's operand; if the switch was `-name', set the name of | |
208 | ;; the initial frame, too. | |
209 | (defun x-handle-name-rn-switch (switch) | |
210 | (or (consp x-invocation-args) | |
211 | (error "%s: missing argument to `%s' option" (invocation-name) switch)) | |
212 | (setq x-resource-name (car x-invocation-args) | |
213 | x-invocation-args (cdr x-invocation-args)) | |
214 | (if (string= switch "-name") | |
215 | (setq initial-frame-alist (cons (cons 'name x-resource-name) | |
216 | initial-frame-alist)))) | |
217 | ||
218 | (defvar x-display-name nil | |
219 | "The display name specifying server and frame.") | |
220 | ||
221 | (defun x-handle-display (switch) | |
222 | (setq x-display-name (car x-invocation-args) | |
223 | x-invocation-args (cdr x-invocation-args))) | |
224 | ||
225 | (defvar x-invocation-args nil) | |
226 | ||
227 | (defun x-handle-args (args) | |
228 | "Process the X-related command line options in ARGS. | |
229 | This is done before the user's startup file is loaded. They are copied to | |
230 | x-invocation args from which the X-related things are extracted, first | |
231 | the switch (e.g., \"-fg\") in the following code, and possible values | |
232 | \(e.g., \"black\") in the option handler code (e.g., x-handle-switch). | |
233 | This returns ARGS with the arguments that have been processed removed." | |
234 | (message "%s" args) | |
235 | (setq x-invocation-args args | |
236 | args nil) | |
237 | (while x-invocation-args | |
238 | (let* ((this-switch (car x-invocation-args)) | |
239 | (orig-this-switch this-switch) | |
240 | completion argval aelt) | |
241 | (setq x-invocation-args (cdr x-invocation-args)) | |
242 | ;; Check for long options with attached arguments | |
243 | ;; and separate out the attached option argument into argval. | |
244 | (if (string-match "^--[^=]*=" this-switch) | |
245 | (setq argval (substring this-switch (match-end 0)) | |
246 | this-switch (substring this-switch 0 (1- (match-end 0))))) | |
247 | (setq completion (try-completion this-switch x-long-option-alist)) | |
248 | (if (eq completion t) | |
249 | ;; Exact match for long option. | |
250 | (setq this-switch (cdr (assoc this-switch x-long-option-alist))) | |
251 | (if (stringp completion) | |
252 | (let ((elt (assoc completion x-long-option-alist))) | |
253 | ;; Check for abbreviated long option. | |
254 | (or elt | |
255 | (error "Option `%s' is ambiguous" this-switch)) | |
256 | (setq this-switch (cdr elt))) | |
257 | ;; Check for a short option. | |
258 | (setq argval nil this-switch orig-this-switch))) | |
259 | (setq aelt (assoc this-switch x-option-alist)) | |
260 | (if aelt | |
261 | (if argval | |
262 | (let ((x-invocation-args | |
263 | (cons argval x-invocation-args))) | |
264 | (funcall (cdr aelt) this-switch)) | |
265 | (funcall (cdr aelt) this-switch)) | |
266 | (setq args (cons this-switch args))))) | |
267 | (setq args (nreverse args))) | |
268 | ||
269 | ||
270 | \f | |
271 | ;; | |
272 | ;; Available colors | |
273 | ;; | |
274 | ||
275 | (defvar x-colors '("aquamarine" | |
276 | "Aquamarine" | |
277 | "medium aquamarine" | |
278 | "MediumAquamarine" | |
279 | "black" | |
280 | "Black" | |
281 | "blue" | |
282 | "Blue" | |
283 | "cadet blue" | |
284 | "CadetBlue" | |
285 | "cornflower blue" | |
286 | "CornflowerBlue" | |
287 | "dark slate blue" | |
288 | "DarkSlateBlue" | |
289 | "light blue" | |
290 | "LightBlue" | |
291 | "light steel blue" | |
292 | "LightSteelBlue" | |
293 | "medium blue" | |
294 | "MediumBlue" | |
295 | "medium slate blue" | |
296 | "MediumSlateBlue" | |
297 | "midnight blue" | |
298 | "MidnightBlue" | |
299 | "navy blue" | |
300 | "NavyBlue" | |
301 | "navy" | |
302 | "Navy" | |
303 | "sky blue" | |
304 | "SkyBlue" | |
305 | "slate blue" | |
306 | "SlateBlue" | |
307 | "steel blue" | |
308 | "SteelBlue" | |
309 | "coral" | |
310 | "Coral" | |
311 | "cyan" | |
312 | "Cyan" | |
313 | "firebrick" | |
314 | "Firebrick" | |
315 | "brown" | |
316 | "Brown" | |
317 | "gold" | |
318 | "Gold" | |
319 | "goldenrod" | |
320 | "Goldenrod" | |
321 | "green" | |
322 | "Green" | |
323 | "dark green" | |
324 | "DarkGreen" | |
325 | "dark olive green" | |
326 | "DarkOliveGreen" | |
327 | "forest green" | |
328 | "ForestGreen" | |
329 | "lime green" | |
330 | "LimeGreen" | |
331 | "medium sea green" | |
332 | "MediumSeaGreen" | |
333 | "medium spring green" | |
334 | "MediumSpringGreen" | |
335 | "pale green" | |
336 | "PaleGreen" | |
337 | "sea green" | |
338 | "SeaGreen" | |
339 | "spring green" | |
340 | "SpringGreen" | |
341 | "yellow green" | |
342 | "YellowGreen" | |
343 | "dark slate grey" | |
344 | "DarkSlateGrey" | |
345 | "dark slate gray" | |
346 | "DarkSlateGray" | |
347 | "dim grey" | |
348 | "DimGrey" | |
349 | "dim gray" | |
350 | "DimGray" | |
351 | "light grey" | |
352 | "LightGrey" | |
353 | "light gray" | |
354 | "LightGray" | |
355 | "gray" | |
356 | "grey" | |
357 | "Gray" | |
358 | "Grey" | |
359 | "khaki" | |
360 | "Khaki" | |
361 | "magenta" | |
362 | "Magenta" | |
363 | "maroon" | |
364 | "Maroon" | |
365 | "orange" | |
366 | "Orange" | |
367 | "orchid" | |
368 | "Orchid" | |
369 | "dark orchid" | |
370 | "DarkOrchid" | |
371 | "medium orchid" | |
372 | "MediumOrchid" | |
373 | "pink" | |
374 | "Pink" | |
375 | "plum" | |
376 | "Plum" | |
377 | "red" | |
378 | "Red" | |
379 | "indian red" | |
380 | "IndianRed" | |
381 | "medium violet red" | |
382 | "MediumVioletRed" | |
383 | "orange red" | |
384 | "OrangeRed" | |
385 | "violet red" | |
386 | "VioletRed" | |
387 | "salmon" | |
388 | "Salmon" | |
389 | "sienna" | |
390 | "Sienna" | |
391 | "tan" | |
392 | "Tan" | |
393 | "thistle" | |
394 | "Thistle" | |
395 | "turquoise" | |
396 | "Turquoise" | |
397 | "dark turquoise" | |
398 | "DarkTurquoise" | |
399 | "medium turquoise" | |
400 | "MediumTurquoise" | |
401 | "violet" | |
402 | "Violet" | |
403 | "blue violet" | |
404 | "BlueViolet" | |
405 | "wheat" | |
406 | "Wheat" | |
407 | "white" | |
408 | "White" | |
409 | "yellow" | |
410 | "Yellow" | |
411 | "green yellow" | |
412 | "GreenYellow") | |
413 | "The full list of X colors from the `rgb.text' file.") | |
414 | ||
415 | (defun x-defined-colors (&optional frame) | |
416 | "Return a list of colors supported for a particular frame. | |
417 | The argument FRAME specifies which frame to try. | |
418 | The value may be different for frames on different X displays." | |
419 | (or frame (setq frame (selected-frame))) | |
420 | (let ((all-colors x-colors) | |
421 | (this-color nil) | |
422 | (defined-colors nil)) | |
423 | (while all-colors | |
424 | (setq this-color (car all-colors) | |
425 | all-colors (cdr all-colors)) | |
426 | (and (face-color-supported-p frame this-color t) | |
427 | (setq defined-colors (cons this-color defined-colors)))) | |
428 | defined-colors)) | |
429 | \f | |
430 | ;;;; Function keys | |
431 | ||
432 | (defun iconify-or-deiconify-frame () | |
433 | "Iconify the selected frame, or deiconify if it's currently an icon." | |
434 | (interactive) | |
435 | (if (eq (cdr (assq 'visibility (frame-parameters))) t) | |
436 | (iconify-frame) | |
437 | (make-frame-visible))) | |
438 | ||
439 | (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame | |
440 | global-map) | |
441 | ||
442 | ;; Map certain keypad keys into ASCII characters | |
443 | ;; that people usually expect. | |
ee78dc32 GV |
444 | (define-key function-key-map [tab] [?\t]) |
445 | (define-key function-key-map [linefeed] [?\n]) | |
446 | (define-key function-key-map [clear] [11]) | |
447 | (define-key function-key-map [return] [13]) | |
448 | (define-key function-key-map [escape] [?\e]) | |
ee78dc32 GV |
449 | (define-key function-key-map [M-tab] [?\M-\t]) |
450 | (define-key function-key-map [M-linefeed] [?\M-\n]) | |
451 | (define-key function-key-map [M-clear] [?\M-\013]) | |
452 | (define-key function-key-map [M-return] [?\M-\015]) | |
453 | (define-key function-key-map [M-escape] [?\M-\e]) | |
454 | ||
6d511e9f GV |
455 | ;; These don't do the right thing (voelker) |
456 | ;(define-key function-key-map [backspace] [127]) | |
457 | ;(define-key function-key-map [delete] [127]) | |
458 | ;(define-key function-key-map [M-backspace] [?\M-\d]) | |
459 | ;(define-key function-key-map [M-delete] [?\M-\d]) | |
460 | ||
ee78dc32 GV |
461 | ;; These tell read-char how to convert |
462 | ;; these special chars to ASCII. | |
ee78dc32 GV |
463 | (put 'tab 'ascii-character ?\t) |
464 | (put 'linefeed 'ascii-character ?\n) | |
465 | (put 'clear 'ascii-character 12) | |
466 | (put 'return 'ascii-character 13) | |
467 | (put 'escape 'ascii-character ?\e) | |
6d511e9f GV |
468 | ;; These don't seem to be necessary (voelker) |
469 | ;(put 'backspace 'ascii-character 127) | |
470 | ;(put 'delete 'ascii-character 127) | |
ee78dc32 GV |
471 | |
472 | \f | |
473 | ;;;; Selections and cut buffers | |
474 | ||
475 | ;;; We keep track of the last text selected here, so we can check the | |
476 | ;;; current selection against it, and avoid passing back our own text | |
477 | ;;; from x-cut-buffer-or-selection-value. | |
478 | (defvar x-last-selected-text nil) | |
479 | ||
480 | ;;; It is said that overlarge strings are slow to put into the cut buffer. | |
481 | ;;; Note this value is overridden below. | |
482 | (defvar x-cut-buffer-max 20000 | |
483 | "Max number of characters to put in the cut buffer.") | |
484 | ||
485 | (defvar x-select-enable-clipboard t | |
486 | "Non-nil means cutting and pasting uses the clipboard. | |
487 | This is in addition to the primary selection.") | |
488 | ||
489 | (defun x-select-text (text &optional push) | |
490 | (if x-select-enable-clipboard | |
491 | (win32-set-clipboard-data text))) | |
492 | ||
493 | ;;; Return the value of the current selection. | |
494 | ;;; Consult the selection, then the cut buffer. Treat empty strings | |
495 | ;;; as if they were unset. | |
496 | (defun x-get-selection-value () | |
497 | (if x-select-enable-clipboard | |
498 | (let (text) | |
499 | ;; Don't die if x-get-selection signals an error. | |
500 | (condition-case c | |
501 | (setq text (win32-get-clipboard-data)) | |
502 | (error (message "win32-get-clipboard-data:%s" c))) | |
503 | (if (string= text "") (setq text nil)) | |
504 | text))) | |
505 | \f | |
506 | ;;; Do the actual Windows setup here; the above code just defines | |
507 | ;;; functions and variables that we use now. | |
508 | ||
509 | (setq command-line-args (x-handle-args command-line-args)) | |
510 | ||
511 | ;;; Make sure we have a valid resource name. | |
512 | (or (stringp x-resource-name) | |
513 | (let (i) | |
514 | (setq x-resource-name (invocation-name)) | |
515 | ||
516 | ;; Change any . or * characters in x-resource-name to hyphens, | |
517 | ;; so as not to choke when we use it in X resource queries. | |
518 | (while (setq i (string-match "[.*]" x-resource-name)) | |
519 | (aset x-resource-name i ?-)))) | |
520 | ||
521 | ;; For the benefit of older Emacses (19.27 and earlier) that are sharing | |
522 | ;; the same lisp directory, don't pass the third argument unless we seem | |
523 | ;; to have the multi-display support. | |
524 | (if (fboundp 'x-close-connection) | |
525 | (x-open-connection "" | |
526 | x-command-line-resources | |
527 | ;; Exit Emacs with fatal error if this fails. | |
528 | t) | |
529 | (x-open-connection "" | |
530 | x-command-line-resources)) | |
531 | ||
532 | (setq frame-creation-function 'x-create-frame-with-faces) | |
533 | ||
534 | (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100) | |
535 | x-cut-buffer-max)) | |
536 | ||
537 | ;; Win32 expects the menu bar cut and paste commands to use the clipboard. | |
538 | ;; This has ,? to match both on Sunos and on Solaris. | |
539 | (menu-bar-enable-clipboard) | |
540 | ||
541 | ;; Apply a geometry resource to the initial frame. Put it at the end | |
542 | ;; of the alist, so that anything specified on the command line takes | |
543 | ;; precedence. | |
544 | (let* ((res-geometry (x-get-resource "geometry" "Geometry")) | |
545 | parsed) | |
546 | (if res-geometry | |
547 | (progn | |
548 | (setq parsed (x-parse-geometry res-geometry)) | |
549 | ;; If the resource specifies a position, | |
550 | ;; call the position and size "user-specified". | |
551 | (if (or (assq 'top parsed) (assq 'left parsed)) | |
552 | (setq parsed (cons '(user-position . t) | |
553 | (cons '(user-size . t) parsed)))) | |
554 | ;; All geometry parms apply to the initial frame. | |
555 | (setq initial-frame-alist (append initial-frame-alist parsed)) | |
556 | ;; The size parms apply to all frames. | |
557 | (if (assq 'height parsed) | |
558 | (setq default-frame-alist | |
559 | (cons (cons 'height (cdr (assq 'height parsed))) | |
560 | default-frame-alist))) | |
561 | (if (assq 'width parsed) | |
562 | (setq default-frame-alist | |
563 | (cons (cons 'width (cdr (assq 'width parsed))) | |
564 | default-frame-alist)))))) | |
565 | ||
566 | ;; Check the reverseVideo resource. | |
567 | (let ((case-fold-search t)) | |
568 | (let ((rv (x-get-resource "reverseVideo" "ReverseVideo"))) | |
569 | (if (and rv | |
570 | (string-match "^\\(true\\|yes\\|on\\)$" rv)) | |
571 | (setq default-frame-alist | |
572 | (cons '(reverse . t) default-frame-alist))))) | |
573 | ||
574 | ;; Set x-selection-timeout, measured in milliseconds. | |
575 | (let ((res-selection-timeout | |
576 | (x-get-resource "selectionTimeout" "SelectionTimeout"))) | |
577 | (setq x-selection-timeout 20000) | |
578 | (if res-selection-timeout | |
579 | (setq x-selection-timeout (string-to-number res-selection-timeout)))) | |
580 | ||
581 | (defun x-win-suspend-error () | |
582 | (error "Suspending an emacs running under Win32 makes no sense")) | |
583 | (add-hook 'suspend-hook 'x-win-suspend-error) | |
584 | ||
585 | ;;; Arrange for the kill and yank functions to set and check the clipboard. | |
586 | (setq interprogram-cut-function 'x-select-text) | |
587 | (setq interprogram-paste-function 'x-get-selection-value) | |
588 | ||
589 | ;;; Turn off window-splitting optimization; win32 is usually fast enough | |
590 | ;;; that this is only annoying. | |
591 | (setq split-window-keep-point t) | |
592 | ||
593 | ;; Don't show the frame name; that's redundant. | |
594 | (setq-default mode-line-buffer-identification '("Emacs: %12b")) | |
595 | ||
596 | ;;; Set to a system sound if you want a fancy bell. | |
597 | (set-message-beep 'ok) | |
598 | ||
599 | ;; Remap some functions to call win32 common dialogs | |
600 | ||
601 | (defun internal-face-interactive (what &optional bool) | |
602 | (let* ((fn (intern (concat "face-" what))) | |
603 | (prompt (concat "Set " what " of face")) | |
604 | (face (read-face-name (concat prompt ": "))) | |
605 | (default (if (fboundp fn) | |
606 | (or (funcall fn face (selected-frame)) | |
607 | (funcall fn 'default (selected-frame))))) | |
608 | (fn-win (intern (concat (symbol-name window-system) "-select-" what))) | |
609 | (value | |
610 | (if (fboundp fn-win) | |
611 | (funcall fn-win) | |
612 | (if bool | |
613 | (y-or-n-p (concat "Should face " (symbol-name face) | |
614 | " be " bool "? ")) | |
615 | (read-string (concat prompt " " (symbol-name face) " to: ") | |
616 | default))))) | |
617 | (list face (if (equal value "") nil value)))) | |
618 | ||
619 | ;; Redefine the font selection to use the Win32 dialog | |
620 | ||
621 | (defun mouse-set-font (&rest fonts) | |
622 | (interactive) | |
623 | (set-default-font (win32-select-font))) | |
624 | ||
625 | ;;; win32-win.el ends here |