]> code.delx.au - gnu-emacs/blob - lisp/term/x-win.el
(x-colors): Delete "medium goldenrod" in both forms.
[gnu-emacs] / lisp / term / x-win.el
1 ;;; x-win.el --- parse switches controlling interface with X window system
2 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3
4 ;; Author: FSF
5 ;; Keywords: terminals
6
7 ;;; This file is part of GNU Emacs.
8 ;;;
9 ;;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;;; it under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 2, or (at your option)
12 ;;; any later version.
13 ;;;
14 ;;; GNU Emacs is distributed in the hope that it will be useful,
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Emacs; see the file COPYING. If not, write to
21 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 ;;; Commentary:
24
25 ;; X-win.el: this file is loaded from ../lisp/startup.el when it recognizes
26 ;; that X windows are to be used. Command line switches are parsed and those
27 ;; pertaining to X are processed and removed from the command line. The
28 ;; X display is opened and hooks are set for popping up the initial window.
29
30 ;; startup.el will then examine startup files, and eventually call the hooks
31 ;; which create the first window (s).
32
33 ;;; Code:
34 \f
35 ;; These are the standard X switches from the Xt Initialize.c file of
36 ;; Release 4.
37
38 ;; Command line Resource Manager string
39
40 ;; +rv *reverseVideo
41 ;; +synchronous *synchronous
42 ;; -background *background
43 ;; -bd *borderColor
44 ;; -bg *background
45 ;; -bordercolor *borderColor
46 ;; -borderwidth .borderWidth
47 ;; -bw .borderWidth
48 ;; -display .display
49 ;; -fg *foreground
50 ;; -fn *font
51 ;; -font *font
52 ;; -foreground *foreground
53 ;; -geometry .geometry
54 ;; -i .iconType
55 ;; -itype .iconType
56 ;; -iconic .iconic
57 ;; -name .name
58 ;; -reverse *reverseVideo
59 ;; -rv *reverseVideo
60 ;; -selectionTimeout .selectionTimeout
61 ;; -synchronous *synchronous
62 ;; -xrm
63
64 ;; An alist of X options and the function which handles them. See
65 ;; ../startup.el.
66
67 (if (not (eq window-system 'x))
68 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
69
70 (require 'frame)
71 (require 'mouse)
72 (require 'scroll-bar)
73 (require 'faces)
74 (require 'select)
75 (require 'menu-bar)
76
77 (defvar x-invocation-args)
78
79 (defvar x-command-line-resources nil)
80
81 (defconst x-option-alist
82 '(("-bw" . x-handle-numeric-switch)
83 ("-d" . x-handle-display)
84 ("-display" . x-handle-display)
85 ("-name" . x-handle-name-rn-switch)
86 ("-rn" . x-handle-name-rn-switch)
87 ("-T" . x-handle-switch)
88 ("-r" . x-handle-switch)
89 ("-rv" . x-handle-switch)
90 ("-reverse" . x-handle-switch)
91 ("-fn" . x-handle-switch)
92 ("-font" . x-handle-switch)
93 ("-ib" . x-handle-numeric-switch)
94 ("-g" . x-handle-geometry)
95 ("-geometry" . x-handle-geometry)
96 ("-fg" . x-handle-switch)
97 ("-foreground". x-handle-switch)
98 ("-bg" . x-handle-switch)
99 ("-background". x-handle-switch)
100 ("-ms" . x-handle-switch)
101 ("-itype" . x-handle-switch)
102 ("-i" . x-handle-switch)
103 ("-iconic" . x-handle-iconic)
104 ("-xrm" . x-handle-xrm-switch)
105 ("-cr" . x-handle-switch)
106 ("-vb" . x-handle-switch)
107 ("-hb" . x-handle-switch)
108 ("-bd" . x-handle-switch)))
109
110 (defconst x-long-option-alist
111 '(("--border-width" . "-bw")
112 ("--display" . "-d")
113 ("--name" . "-name")
114 ("--title" . "-T")
115 ("--reverse-video" . "-reverse")
116 ("--font" . "-font")
117 ("--internal-border" . "-ib")
118 ("--geometry" . "-geometry")
119 ("--foreground-color" . "-fg")
120 ("--background-color" . "-bg")
121 ("--mouse-color" . "-ms")
122 ("--icon-type" . "-itype")
123 ("--iconic" . "-iconic")
124 ("--xrm" . "-xrm")
125 ("--cursor-color" . "-cr")
126 ("--vertical-scroll-bars" . "-vb")
127 ("--border-color" . "-bd")))
128
129 (defconst x-switch-definitions
130 '(("-name" name)
131 ("-T" name)
132 ("-r" reverse t)
133 ("-rv" reverse t)
134 ("-reverse" reverse t)
135 ("-fn" font)
136 ("-font" font)
137 ("-ib" internal-border-width)
138 ("-fg" foreground-color)
139 ("-foreground" foreground-color)
140 ("-bg" background-color)
141 ("-background" background-color)
142 ("-ms" mouse-color)
143 ("-cr" cursor-color)
144 ("-itype" icon-type t)
145 ("-i" icon-type t)
146 ("-vb" vertical-scroll-bars t)
147 ("-hb" horizontal-scroll-bars t)
148 ("-bd" border-color)
149 ("-bw" border-width)))
150
151 ;; Handler for switches of the form "-switch value" or "-switch".
152 (defun x-handle-switch (switch)
153 (let ((aelt (assoc switch x-switch-definitions)))
154 (if aelt
155 (if (nth 2 aelt)
156 (setq default-frame-alist
157 (cons (cons (nth 1 aelt) (nth 2 aelt))
158 default-frame-alist))
159 (setq default-frame-alist
160 (cons (cons (nth 1 aelt)
161 (car x-invocation-args))
162 default-frame-alist)
163 x-invocation-args (cdr x-invocation-args))))))
164
165 ;; Make -iconic apply only to the initial frame!
166 (defun x-handle-iconic (switch)
167 (setq initial-frame-alist
168 (cons '(visibility . icon) initial-frame-alist)))
169
170 ;; Handler for switches of the form "-switch n"
171 (defun x-handle-numeric-switch (switch)
172 (let ((aelt (assoc switch x-switch-definitions)))
173 (if aelt
174 (setq default-frame-alist
175 (cons (cons (nth 1 aelt)
176 (string-to-int (car x-invocation-args)))
177 default-frame-alist)
178 x-invocation-args
179 (cdr x-invocation-args)))))
180
181 ;; Handle the -xrm option.
182 (defun x-handle-xrm-switch (switch)
183 (or (consp x-invocation-args)
184 (error "%s: missing argument to `%s' option" (invocation-name) switch))
185 (setq x-command-line-resources (car x-invocation-args))
186 (setq x-invocation-args (cdr x-invocation-args)))
187
188 ;; Handle the geometry option
189 (defun x-handle-geometry (switch)
190 (let ((geo (x-parse-geometry (car x-invocation-args))))
191 (setq initial-frame-alist
192 (append initial-frame-alist
193 (if (or (assq 'left geo) (assq 'top geo))
194 '((user-position . t)))
195 (if (or (assq 'height geo) (assq 'width geo))
196 '((user-size . t)))
197 geo)
198 x-invocation-args (cdr x-invocation-args))))
199
200 ;; Handle the -name and -rn options. Set the variable x-resource-name
201 ;; to the option's operand; if the switch was `-name', set the name of
202 ;; the initial frame, too.
203 (defun x-handle-name-rn-switch (switch)
204 (or (consp x-invocation-args)
205 (error "%s: missing argument to `%s' option" (invocation-name) switch))
206 (setq x-resource-name (car x-invocation-args)
207 x-invocation-args (cdr x-invocation-args))
208 (if (string= switch "-name")
209 (setq initial-frame-alist (cons (cons 'name x-resource-name)
210 initial-frame-alist))))
211
212 (defvar x-display-name nil
213 "The X display name specifying server and X frame.")
214
215 (defun x-handle-display (switch)
216 (setq x-display-name (car x-invocation-args)
217 x-invocation-args (cdr x-invocation-args)))
218
219 (defvar x-invocation-args nil)
220
221 (defun x-handle-args (args)
222 "Process the X-related command line options in ARGS.
223 This is done before the user's startup file is loaded. They are copied to
224 x-invocation args from which the X-related things are extracted, first
225 the switch (e.g., \"-fg\") in the following code, and possible values
226 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
227 This returns ARGS with the arguments that have been processed removed."
228 (message "%s" args)
229 (setq x-invocation-args args
230 args nil)
231 (while x-invocation-args
232 (let* ((this-switch (car x-invocation-args))
233 (orig-this-switch this-switch)
234 completion argval aelt)
235 (setq x-invocation-args (cdr x-invocation-args))
236 ;; Check for long options with attached arguments
237 ;; and separate out the attached option argument into argval.
238 (if (string-match "^--[^=]*=" this-switch)
239 (setq argval (substring this-switch (match-end 0))
240 this-switch (substring this-switch 0 (1- (match-end 0)))))
241 (setq completion (try-completion this-switch x-long-option-alist))
242 (if (eq completion t)
243 ;; Exact match for long option.
244 (setq this-switch (cdr (assoc this-switch x-long-option-alist)))
245 (if (stringp completion)
246 (let ((elt (assoc completion x-long-option-alist)))
247 ;; Check for abbreviated long option.
248 (or elt
249 (error "Option `%s' is ambiguous" this-switch))
250 (setq this-switch (cdr elt)))
251 ;; Check for a short option.
252 (setq argval nil this-switch orig-this-switch)))
253 (setq aelt (assoc this-switch x-option-alist))
254 (if aelt
255 (if argval
256 (let ((x-invocation-args
257 (cons argval x-invocation-args)))
258 (funcall (cdr aelt) this-switch))
259 (funcall (cdr aelt) this-switch))
260 (setq args (cons this-switch args)))))
261 (setq args (nreverse args)))
262
263
264 \f
265 ;;
266 ;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
267 ;;
268
269 (defconst x-pointer-X-cursor 0)
270 (defconst x-pointer-arrow 2)
271 (defconst x-pointer-based-arrow-down 4)
272 (defconst x-pointer-based-arrow-up 6)
273 (defconst x-pointer-boat 8)
274 (defconst x-pointer-bogosity 10)
275 (defconst x-pointer-bottom-left-corner 12)
276 (defconst x-pointer-bottom-right-corner 14)
277 (defconst x-pointer-bottom-side 16)
278 (defconst x-pointer-bottom-tee 18)
279 (defconst x-pointer-box-spiral 20)
280 (defconst x-pointer-center-ptr 22)
281 (defconst x-pointer-circle 24)
282 (defconst x-pointer-clock 26)
283 (defconst x-pointer-coffee-mug 28)
284 (defconst x-pointer-cross 30)
285 (defconst x-pointer-cross-reverse 32)
286 (defconst x-pointer-crosshair 34)
287 (defconst x-pointer-diamond-cross 36)
288 (defconst x-pointer-dot 38)
289 (defconst x-pointer-dotbox 40)
290 (defconst x-pointer-double-arrow 42)
291 (defconst x-pointer-draft-large 44)
292 (defconst x-pointer-draft-small 46)
293 (defconst x-pointer-draped-box 48)
294 (defconst x-pointer-exchange 50)
295 (defconst x-pointer-fleur 52)
296 (defconst x-pointer-gobbler 54)
297 (defconst x-pointer-gumby 56)
298 (defconst x-pointer-hand1 58)
299 (defconst x-pointer-hand2 60)
300 (defconst x-pointer-heart 62)
301 (defconst x-pointer-icon 64)
302 (defconst x-pointer-iron-cross 66)
303 (defconst x-pointer-left-ptr 68)
304 (defconst x-pointer-left-side 70)
305 (defconst x-pointer-left-tee 72)
306 (defconst x-pointer-leftbutton 74)
307 (defconst x-pointer-ll-angle 76)
308 (defconst x-pointer-lr-angle 78)
309 (defconst x-pointer-man 80)
310 (defconst x-pointer-middlebutton 82)
311 (defconst x-pointer-mouse 84)
312 (defconst x-pointer-pencil 86)
313 (defconst x-pointer-pirate 88)
314 (defconst x-pointer-plus 90)
315 (defconst x-pointer-question-arrow 92)
316 (defconst x-pointer-right-ptr 94)
317 (defconst x-pointer-right-side 96)
318 (defconst x-pointer-right-tee 98)
319 (defconst x-pointer-rightbutton 100)
320 (defconst x-pointer-rtl-logo 102)
321 (defconst x-pointer-sailboat 104)
322 (defconst x-pointer-sb-down-arrow 106)
323 (defconst x-pointer-sb-h-double-arrow 108)
324 (defconst x-pointer-sb-left-arrow 110)
325 (defconst x-pointer-sb-right-arrow 112)
326 (defconst x-pointer-sb-up-arrow 114)
327 (defconst x-pointer-sb-v-double-arrow 116)
328 (defconst x-pointer-shuttle 118)
329 (defconst x-pointer-sizing 120)
330 (defconst x-pointer-spider 122)
331 (defconst x-pointer-spraycan 124)
332 (defconst x-pointer-star 126)
333 (defconst x-pointer-target 128)
334 (defconst x-pointer-tcross 130)
335 (defconst x-pointer-top-left-arrow 132)
336 (defconst x-pointer-top-left-corner 134)
337 (defconst x-pointer-top-right-corner 136)
338 (defconst x-pointer-top-side 138)
339 (defconst x-pointer-top-tee 140)
340 (defconst x-pointer-trek 142)
341 (defconst x-pointer-ul-angle 144)
342 (defconst x-pointer-umbrella 146)
343 (defconst x-pointer-ur-angle 148)
344 (defconst x-pointer-watch 150)
345 (defconst x-pointer-xterm 152)
346 \f
347 ;;
348 ;; Available colors
349 ;;
350
351 (defvar x-colors '("aquamarine"
352 "Aquamarine"
353 "medium aquamarine"
354 "MediumAquamarine"
355 "black"
356 "Black"
357 "blue"
358 "Blue"
359 "cadet blue"
360 "CadetBlue"
361 "cornflower blue"
362 "CornflowerBlue"
363 "dark slate blue"
364 "DarkSlateBlue"
365 "light blue"
366 "LightBlue"
367 "light steel blue"
368 "LightSteelBlue"
369 "medium blue"
370 "MediumBlue"
371 "medium slate blue"
372 "MediumSlateBlue"
373 "midnight blue"
374 "MidnightBlue"
375 "navy blue"
376 "NavyBlue"
377 "navy"
378 "Navy"
379 "sky blue"
380 "SkyBlue"
381 "slate blue"
382 "SlateBlue"
383 "steel blue"
384 "SteelBlue"
385 "coral"
386 "Coral"
387 "cyan"
388 "Cyan"
389 "firebrick"
390 "Firebrick"
391 "brown"
392 "Brown"
393 "gold"
394 "Gold"
395 "goldenrod"
396 "Goldenrod"
397 "green"
398 "Green"
399 "dark green"
400 "DarkGreen"
401 "dark olive green"
402 "DarkOliveGreen"
403 "forest green"
404 "ForestGreen"
405 "lime green"
406 "LimeGreen"
407 "medium forest green"
408 "MediumForestGreen"
409 "medium sea green"
410 "MediumSeaGreen"
411 "medium spring green"
412 "MediumSpringGreen"
413 "pale green"
414 "PaleGreen"
415 "sea green"
416 "SeaGreen"
417 "spring green"
418 "SpringGreen"
419 "yellow green"
420 "YellowGreen"
421 "dark slate grey"
422 "DarkSlateGrey"
423 "dark slate gray"
424 "DarkSlateGray"
425 "dim grey"
426 "DimGrey"
427 "dim gray"
428 "DimGray"
429 "light grey"
430 "LightGrey"
431 "light gray"
432 "LightGray"
433 "gray"
434 "grey"
435 "Gray"
436 "Grey"
437 "khaki"
438 "Khaki"
439 "magenta"
440 "Magenta"
441 "maroon"
442 "Maroon"
443 "orange"
444 "Orange"
445 "orchid"
446 "Orchid"
447 "dark orchid"
448 "DarkOrchid"
449 "medium orchid"
450 "MediumOrchid"
451 "pink"
452 "Pink"
453 "plum"
454 "Plum"
455 "red"
456 "Red"
457 "indian red"
458 "IndianRed"
459 "medium violet red"
460 "MediumVioletRed"
461 "orange red"
462 "OrangeRed"
463 "violet red"
464 "VioletRed"
465 "salmon"
466 "Salmon"
467 "sienna"
468 "Sienna"
469 "tan"
470 "Tan"
471 "thistle"
472 "Thistle"
473 "turquoise"
474 "Turquoise"
475 "dark turquoise"
476 "DarkTurquoise"
477 "medium turquoise"
478 "MediumTurquoise"
479 "violet"
480 "Violet"
481 "blue violet"
482 "BlueViolet"
483 "wheat"
484 "Wheat"
485 "white"
486 "White"
487 "yellow"
488 "Yellow"
489 "green yellow"
490 "GreenYellow")
491 "The full list of X colors from the `rgb.text' file.")
492
493 (defun x-defined-colors (&optional frame)
494 "Return a list of colors supported for a particular frame.
495 The argument FRAME specifies which frame to try.
496 The value may be different for frames on different X displays."
497 (or frame (setq frame (selected-frame)))
498 (let ((all-colors x-colors)
499 (this-color nil)
500 (defined-colors nil))
501 (while all-colors
502 (setq this-color (car all-colors)
503 all-colors (cdr all-colors))
504 (and (face-color-supported-p frame this-color t)
505 (setq defined-colors (cons this-color defined-colors))))
506 defined-colors))
507 \f
508 ;;;; Function keys
509
510 (defun iconify-or-deiconify-frame ()
511 "Iconify the selected frame, or deiconify if it's currently an icon."
512 (interactive)
513 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
514 (iconify-frame)
515 (make-frame-visible)))
516
517 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
518 global-map)
519
520 ;; Map certain keypad keys into ASCII characters
521 ;; that people usually expect.
522 (define-key function-key-map [backspace] [127])
523 (define-key function-key-map [delete] [127])
524 (define-key function-key-map [tab] [?\t])
525 (define-key function-key-map [linefeed] [?\n])
526 (define-key function-key-map [clear] [11])
527 (define-key function-key-map [return] [13])
528 (define-key function-key-map [escape] [?\e])
529 (define-key function-key-map [M-backspace] [?\M-\d])
530 (define-key function-key-map [M-delete] [?\M-\d])
531 (define-key function-key-map [M-tab] [?\M-\t])
532 (define-key function-key-map [M-linefeed] [?\M-\n])
533 (define-key function-key-map [M-clear] [?\M-\013])
534 (define-key function-key-map [M-return] [?\M-\015])
535 (define-key function-key-map [M-escape] [?\M-\e])
536
537 ;; These tell read-char how to convert
538 ;; these special chars to ASCII.
539 (put 'backspace 'ascii-character 127)
540 (put 'delete 'ascii-character 127)
541 (put 'tab 'ascii-character ?\t)
542 (put 'linefeed 'ascii-character ?\n)
543 (put 'clear 'ascii-character 12)
544 (put 'return 'ascii-character 13)
545 (put 'escape 'ascii-character ?\e)
546
547 ;; Set up to recognize vendor-specific keysyms.
548 ;; Unless/until there is a real conflict,
549 ;; we need not try to make this list depend on
550 ;; the type of X server in use.
551 (setq system-key-alist
552 '(
553 ;; These are some HP keys.
554 ( 168 . mute-acute)
555 ( 169 . mute-grave)
556 ( 170 . mute-asciicircum)
557 ( 171 . mute-diaeresis)
558 ( 172 . mute-asciitilde)
559 ( 175 . lira)
560 ( 190 . guilder)
561 ( 252 . block)
562 ( 256 . longminus)
563 (65388 . reset)
564 (65389 . system)
565 (65390 . user)
566 (65391 . clearline)
567 (65392 . insertline)
568 (65393 . deleteline)
569 (65394 . insertchar)
570 (65395 . deletechar)
571 (65396 . backtab)
572 (65397 . kp-backtab)
573 ;; This is used by DEC's X server.
574 (65280 . remove)
575 ;; These are for Sun.
576 (392963 . mute-acute)
577 (392960 . mute-grave)
578 (392964 . mute-diaeresis)
579 (392961 . mute-asciicircum)
580 (392976 . f36)
581 (392977 . f37)
582 (393056 . req)
583 ;; These are for Sun under X11R6
584 (393072 . props)
585 (393073 . front)
586 (393074 . copy)
587 (393075 . open)
588 (393076 . paste)
589 (393077 . cut)
590 ))
591 \f
592 ;;;; Selections and cut buffers
593
594 ;;; We keep track of the last text selected here, so we can check the
595 ;;; current selection against it, and avoid passing back our own text
596 ;;; from x-cut-buffer-or-selection-value.
597 (defvar x-last-selected-text nil)
598
599 ;;; It is said that overlarge strings are slow to put into the cut buffer.
600 ;;; Note this value is overridden below.
601 (defvar x-cut-buffer-max 20000
602 "Max number of characters to put in the cut buffer.")
603
604 (defvar x-select-enable-clipboard nil
605 "Non-nil means cutting and pasting uses the clipboard.
606 This is in addition to the primary selection.")
607
608 ;;; Make TEXT, a string, the primary X selection.
609 ;;; Also, set the value of X cut buffer 0, for backward compatibility
610 ;;; with older X applications.
611 ;;; gildea@lcs.mit.edu says it's not desirable to put kills
612 ;;; in the clipboard.
613 (defun x-select-text (text &optional push)
614 ;; Don't send the cut buffer too much text.
615 ;; It becomes slow, and if really big it causes errors.
616 (if (< (length text) x-cut-buffer-max)
617 (x-set-cut-buffer text push)
618 (x-set-cut-buffer "" push))
619 (x-set-selection 'PRIMARY text)
620 (if x-select-enable-clipboard
621 (x-set-selection 'CLIPBOARD text))
622 (setq x-last-selected-text text))
623
624 ;;; Return the value of the current X selection.
625 ;;; Consult the selection, then the cut buffer. Treat empty strings
626 ;;; as if they were unset.
627 (defun x-cut-buffer-or-selection-value ()
628 (let (text)
629
630 ;; Don't die if x-get-selection signals an error.
631 (condition-case c
632 (setq text (x-get-selection 'PRIMARY))
633 (error (message "%s" c)))
634 (if (string= text "") (setq text nil))
635
636 (if x-select-enable-clipboard
637 (condition-case c
638 (setq text (x-get-selection 'CLIPBOARD))
639 (error (message "%s" c))))
640 (if (string= text "") (setq text nil))
641 (or text (setq text (x-get-cut-buffer 0)))
642 (if (string= text "") (setq text nil))
643
644 (cond
645 ((not text) nil)
646 ((eq text x-last-selected-text) nil)
647 ((string= text x-last-selected-text)
648 ;; Record the newer string, so subsequent calls can use the `eq' test.
649 (setq x-last-selected-text text)
650 nil)
651 (t
652 (setq x-last-selected-text text)))))
653
654 \f
655 ;;; Do the actual X Windows setup here; the above code just defines
656 ;;; functions and variables that we use now.
657
658 (setq command-line-args (x-handle-args command-line-args))
659
660 ;;; Make sure we have a valid resource name.
661 (or (stringp x-resource-name)
662 (let (i)
663 (setq x-resource-name (invocation-name))
664
665 ;; Change any . or * characters in x-resource-name to hyphens,
666 ;; so as not to choke when we use it in X resource queries.
667 (while (setq i (string-match "[.*]" x-resource-name))
668 (aset x-resource-name i ?-))))
669
670 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing
671 ;; the same lisp directory, don't pass the third argument unless we seem
672 ;; to have the multi-display support.
673 (if (fboundp 'x-close-connection)
674 (x-open-connection (or x-display-name
675 (setq x-display-name (getenv "DISPLAY")))
676 x-command-line-resources
677 ;; Exit Emacs with fatal error if this fails.
678 t)
679 (x-open-connection (or x-display-name
680 (setq x-display-name (getenv "DISPLAY")))
681 x-command-line-resources))
682
683 (setq frame-creation-function 'x-create-frame-with-faces)
684
685 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
686 x-cut-buffer-max))
687
688 ;; Sun expects the menu bar cut and paste commands to use the clipboard.
689 ;; This has ,? to match both on Sunos and on Solaris.
690 (if (string-match " Sun Microsystems,? Inc\\."
691 (x-server-vendor))
692 (menu-bar-enable-clipboard))
693
694 ;; Apply a geometry resource to the initial frame. Put it at the end
695 ;; of the alist, so that anything specified on the command line takes
696 ;; precedence.
697 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
698 parsed)
699 (if res-geometry
700 (progn
701 (setq parsed (x-parse-geometry res-geometry))
702 ;; All geometry parms apply to the initial frame.
703 (setq initial-frame-alist (append initial-frame-alist parsed))
704 ;; The size parms apply to all frames.
705 (if (assq 'height parsed)
706 (setq default-frame-alist
707 (cons (cons 'height (cdr (assq 'height parsed)))
708 default-frame-alist)))
709 (if (assq 'width parsed)
710 (setq default-frame-alist
711 (cons (cons 'width (cdr (assq 'width parsed)))
712 default-frame-alist))))))
713
714 ;; Check the reverseVideo resource.
715 (let ((case-fold-search t))
716 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
717 (if (and rv
718 (string-match "^\\(true\\|yes\\|on\\)$" rv))
719 (setq default-frame-alist
720 (cons '(reverse . t) default-frame-alist)))))
721
722 ;; Set x-selection-timeout, measured in milliseconds.
723 (let ((res-selection-timeout
724 (x-get-resource "selectionTimeout" "SelectionTimeout")))
725 (setq x-selection-timeout 20000)
726 (if res-selection-timeout
727 (setq x-selection-timeout (string-to-number res-selection-timeout))))
728
729 (defun x-win-suspend-error ()
730 (error "Suspending an emacs running under X makes no sense"))
731 (add-hook 'suspend-hook 'x-win-suspend-error)
732
733 ;;; Arrange for the kill and yank functions to set and check the clipboard.
734 (setq interprogram-cut-function 'x-select-text)
735 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
736
737 ;;; Turn off window-splitting optimization; X is usually fast enough
738 ;;; that this is only annoying.
739 (setq split-window-keep-point t)
740
741 ;; Don't show the frame name; that's redundant with X.
742 (setq-default mode-line-buffer-identification '("Emacs: %12b"))
743
744 ;;; x-win.el ends here