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