(news-fkey-prefix): Use kp-decimal, not kp-period.
[bpt/emacs.git] / lisp / term / x-win.el
CommitLineData
5cdb3f1e 1;;; x-win.el --- parse switches controlling interface with X window system
d733c5ec 2;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
5cdb3f1e
ER
3
4;; Author: FSF
5;; Keywords: terminals
6
cbc336a2
RS
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.
63f77899 22
5cdb3f1e 23;;; Commentary:
63f77899
JB
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).
5cdb3f1e
ER
32
33;;; Code:
63f77899
JB
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
db176f55
JB
54;; -i .iconType
55;; -itype .iconType
63f77899
JB
56;; -iconic .iconic
57;; -name .name
58;; -reverse *reverseVideo
59;; -rv *reverseVideo
60;; -selectionTimeout .selectionTimeout
61;; -synchronous *synchronous
63f77899
JB
62;; -xrm
63
63f77899
JB
64;; An alist of X options and the function which handles them. See
65;; ../startup.el.
66
63c86e17 67(if (not (eq window-system 'x))
800642d2 68 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
63c86e17 69
0cc89026 70(require 'frame)
3eb43f71 71(require 'mouse)
b16795eb 72(require 'scroll-bar)
ffe1dd7a
JB
73(require 'faces)
74(require 'select)
290cb602 75(require 'menu-bar)
63c86e17 76
19b08de9
RS
77(defvar x-invocation-args)
78
f6f6d98c
RS
79(defvar x-command-line-resources nil)
80
63f77899 81(setq command-switch-alist
708c60f8 82 (append '(("-bw" . x-handle-numeric-switch)
63c86e17
JB
83 ("-d" . x-handle-display)
84 ("-display" . x-handle-display)
800642d2
JB
85 ("-name" . x-handle-name-rn-switch)
86 ("-rn" . x-handle-name-rn-switch)
63c86e17
JB
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)
878a0827 93 ("-ib" . x-handle-numeric-switch)
63c86e17
JB
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)
7b937caf 101 ("-itype" . x-handle-switch)
db176f55 102 ("-i" . x-handle-switch)
ef599142 103 ("-iconic" . x-handle-iconic)
800642d2 104 ("-xrm" . x-handle-xrm-switch)
63c86e17
JB
105 ("-cr" . x-handle-switch)
106 ("-vb" . x-handle-switch)
107 ("-hb" . x-handle-switch)
108 ("-bd" . x-handle-switch))
63f77899
JB
109 command-switch-alist))
110
63f77899
JB
111(defconst x-switch-definitions
112 '(("-name" name)
113 ("-T" name)
e6299e30
JB
114 ("-r" reverse t)
115 ("-rv" reverse t)
116 ("-reverse" reverse t)
63f77899
JB
117 ("-fn" font)
118 ("-font" font)
119 ("-ib" internal-border-width)
120 ("-fg" foreground-color)
121 ("-foreground" foreground-color)
122 ("-bg" background-color)
123 ("-background" background-color)
124 ("-ms" mouse-color)
125 ("-cr" cursor-color)
7b937caf 126 ("-itype" icon-type t)
db176f55 127 ("-i" icon-type t)
0a68e87b
JB
128 ("-vb" vertical-scroll-bars t)
129 ("-hb" horizontal-scroll-bars t)
63f77899
JB
130 ("-bd" border-color)
131 ("-bw" border-width)))
132
133;; Handler for switches of the form "-switch value" or "-switch".
134(defun x-handle-switch (switch)
135 (let ((aelt (assoc switch x-switch-definitions)))
136 (if aelt
137 (if (nth 2 aelt)
0cc89026 138 (setq default-frame-alist
63f77899 139 (cons (cons (nth 1 aelt) (nth 2 aelt))
0cc89026
JB
140 default-frame-alist))
141 (setq default-frame-alist
63f77899
JB
142 (cons (cons (nth 1 aelt)
143 (car x-invocation-args))
0cc89026 144 default-frame-alist)
63f77899
JB
145 x-invocation-args (cdr x-invocation-args))))))
146
ef599142
RS
147;; Make -iconic apply only to the initial frame!
148(defun x-handle-iconic (switch)
149 (setq initial-frame-alist
150 (cons '(visibility . icon) initial-frame-alist)))
151
63f77899
JB
152;; Handler for switches of the form "-switch n"
153(defun x-handle-numeric-switch (switch)
154 (let ((aelt (assoc switch x-switch-definitions)))
155 (if aelt
0cc89026 156 (setq default-frame-alist
63f77899
JB
157 (cons (cons (nth 1 aelt)
158 (string-to-int (car x-invocation-args)))
0cc89026 159 default-frame-alist)
63f77899
JB
160 x-invocation-args
161 (cdr x-invocation-args)))))
162
800642d2
JB
163;; Handle the -xrm option.
164(defun x-handle-xrm-switch (switch)
165 (or (consp x-invocation-args)
166 (error "%s: missing argument to `%s' option" (invocation-name) switch))
f6f6d98c
RS
167 (setq x-command-line-resources (car x-invocation-args))
168 (setq x-invocation-args (cdr x-invocation-args)))
169
63f77899
JB
170;; Handle the geometry option
171(defun x-handle-geometry (switch)
6e42f5f8
RS
172 (let ((geo (x-parse-geometry (car x-invocation-args))))
173 (setq initial-frame-alist
174 (append initial-frame-alist
175 (if (or (assq 'left geo) (assq 'top geo))
176 '((user-position . t)))
177 (if (or (assq 'height geo) (assq 'width geo))
178 '((user-size . t)))
179 geo)
180 x-invocation-args (cdr x-invocation-args))))
63f77899 181
800642d2
JB
182;; Handle the -name and -rn options. Set the variable x-resource-name
183;; to the option's operand; if the switch was `-name', set the name of
184;; the initial frame, too.
185(defun x-handle-name-rn-switch (switch)
186 (or (consp x-invocation-args)
187 (error "%s: missing argument to `%s' option" (invocation-name) switch))
188 (setq x-resource-name (car x-invocation-args)
189 x-invocation-args (cdr x-invocation-args))
190 (if (string= switch "-name")
191 (setq initial-frame-alist (cons (cons 'name x-resource-name)
192 initial-frame-alist))))
193
63f77899 194(defvar x-display-name nil
0cc89026 195 "The X display name specifying server and X frame.")
63f77899
JB
196
197(defun x-handle-display (switch)
198 (setq x-display-name (car x-invocation-args)
199 x-invocation-args (cdr x-invocation-args)))
200
63f77899
JB
201(defvar x-invocation-args nil)
202
8769d648 203(defun x-handle-args (args)
dc20df95
RS
204 "Process the X-related command line options in ARGS.
205This is done before the user's startup file is loaded. They are copied to
8769d648
JB
206x-invocation args from which the X-related things are extracted, first
207the switch (e.g., \"-fg\") in the following code, and possible values
a4e104bf 208\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
8769d648 209This returns ARGS with the arguments that have been processed removed."
63c86e17
JB
210 (setq x-invocation-args args
211 args nil)
212 (while x-invocation-args
213 (let* ((this-switch (car x-invocation-args))
214 (aelt (assoc this-switch command-switch-alist)))
215 (setq x-invocation-args (cdr x-invocation-args))
216 (if aelt
217 (funcall (cdr aelt) this-switch)
218 (setq args (cons this-switch args)))))
219 (setq args (nreverse args)))
220
b54621ea 221
63f77899
JB
222\f
223;;
224;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
225;;
226
227(defconst x-pointer-X-cursor 0)
228(defconst x-pointer-arrow 2)
229(defconst x-pointer-based-arrow-down 4)
230(defconst x-pointer-based-arrow-up 6)
231(defconst x-pointer-boat 8)
232(defconst x-pointer-bogosity 10)
233(defconst x-pointer-bottom-left-corner 12)
234(defconst x-pointer-bottom-right-corner 14)
235(defconst x-pointer-bottom-side 16)
236(defconst x-pointer-bottom-tee 18)
237(defconst x-pointer-box-spiral 20)
238(defconst x-pointer-center-ptr 22)
239(defconst x-pointer-circle 24)
240(defconst x-pointer-clock 26)
241(defconst x-pointer-coffee-mug 28)
242(defconst x-pointer-cross 30)
243(defconst x-pointer-cross-reverse 32)
244(defconst x-pointer-crosshair 34)
245(defconst x-pointer-diamond-cross 36)
246(defconst x-pointer-dot 38)
247(defconst x-pointer-dotbox 40)
248(defconst x-pointer-double-arrow 42)
249(defconst x-pointer-draft-large 44)
250(defconst x-pointer-draft-small 46)
251(defconst x-pointer-draped-box 48)
252(defconst x-pointer-exchange 50)
253(defconst x-pointer-fleur 52)
254(defconst x-pointer-gobbler 54)
255(defconst x-pointer-gumby 56)
256(defconst x-pointer-hand1 58)
257(defconst x-pointer-hand2 60)
258(defconst x-pointer-heart 62)
259(defconst x-pointer-icon 64)
260(defconst x-pointer-iron-cross 66)
261(defconst x-pointer-left-ptr 68)
262(defconst x-pointer-left-side 70)
263(defconst x-pointer-left-tee 72)
264(defconst x-pointer-leftbutton 74)
265(defconst x-pointer-ll-angle 76)
266(defconst x-pointer-lr-angle 78)
267(defconst x-pointer-man 80)
268(defconst x-pointer-middlebutton 82)
269(defconst x-pointer-mouse 84)
270(defconst x-pointer-pencil 86)
271(defconst x-pointer-pirate 88)
272(defconst x-pointer-plus 90)
273(defconst x-pointer-question-arrow 92)
274(defconst x-pointer-right-ptr 94)
275(defconst x-pointer-right-side 96)
276(defconst x-pointer-right-tee 98)
277(defconst x-pointer-rightbutton 100)
278(defconst x-pointer-rtl-logo 102)
279(defconst x-pointer-sailboat 104)
280(defconst x-pointer-sb-down-arrow 106)
281(defconst x-pointer-sb-h-double-arrow 108)
282(defconst x-pointer-sb-left-arrow 110)
283(defconst x-pointer-sb-right-arrow 112)
284(defconst x-pointer-sb-up-arrow 114)
285(defconst x-pointer-sb-v-double-arrow 116)
286(defconst x-pointer-shuttle 118)
287(defconst x-pointer-sizing 120)
288(defconst x-pointer-spider 122)
289(defconst x-pointer-spraycan 124)
290(defconst x-pointer-star 126)
291(defconst x-pointer-target 128)
292(defconst x-pointer-tcross 130)
293(defconst x-pointer-top-left-arrow 132)
294(defconst x-pointer-top-left-corner 134)
295(defconst x-pointer-top-right-corner 136)
296(defconst x-pointer-top-side 138)
297(defconst x-pointer-top-tee 140)
298(defconst x-pointer-trek 142)
299(defconst x-pointer-ul-angle 144)
300(defconst x-pointer-umbrella 146)
301(defconst x-pointer-ur-angle 148)
302(defconst x-pointer-watch 150)
303(defconst x-pointer-xterm 152)
304\f
305;;
306;; Available colors
307;;
308
309(defvar x-colors '("aquamarine"
310 "Aquamarine"
311 "medium aquamarine"
312 "MediumAquamarine"
313 "black"
314 "Black"
315 "blue"
316 "Blue"
317 "cadet blue"
318 "CadetBlue"
319 "cornflower blue"
320 "CornflowerBlue"
321 "dark slate blue"
322 "DarkSlateBlue"
323 "light blue"
324 "LightBlue"
325 "light steel blue"
326 "LightSteelBlue"
327 "medium blue"
328 "MediumBlue"
329 "medium slate blue"
330 "MediumSlateBlue"
331 "midnight blue"
332 "MidnightBlue"
333 "navy blue"
334 "NavyBlue"
335 "navy"
336 "Navy"
337 "sky blue"
338 "SkyBlue"
339 "slate blue"
340 "SlateBlue"
341 "steel blue"
342 "SteelBlue"
343 "coral"
344 "Coral"
345 "cyan"
346 "Cyan"
347 "firebrick"
348 "Firebrick"
349 "brown"
350 "Brown"
351 "gold"
352 "Gold"
353 "goldenrod"
354 "Goldenrod"
355 "medium goldenrod"
356 "MediumGoldenrod"
357 "green"
358 "Green"
359 "dark green"
360 "DarkGreen"
361 "dark olive green"
362 "DarkOliveGreen"
363 "forest green"
364 "ForestGreen"
365 "lime green"
366 "LimeGreen"
367 "medium forest green"
368 "MediumForestGreen"
369 "medium sea green"
370 "MediumSeaGreen"
371 "medium spring green"
372 "MediumSpringGreen"
373 "pale green"
374 "PaleGreen"
375 "sea green"
376 "SeaGreen"
377 "spring green"
378 "SpringGreen"
379 "yellow green"
380 "YellowGreen"
381 "dark slate grey"
382 "DarkSlateGrey"
383 "dark slate gray"
384 "DarkSlateGray"
385 "dim grey"
386 "DimGrey"
387 "dim gray"
388 "DimGray"
389 "light grey"
390 "LightGrey"
391 "light gray"
392 "LightGray"
393 "gray"
394 "grey"
395 "Gray"
396 "Grey"
397 "khaki"
398 "Khaki"
399 "magenta"
400 "Magenta"
401 "maroon"
402 "Maroon"
403 "orange"
404 "Orange"
405 "orchid"
406 "Orchid"
407 "dark orchid"
408 "DarkOrchid"
409 "medium orchid"
410 "MediumOrchid"
411 "pink"
412 "Pink"
413 "plum"
414 "Plum"
415 "red"
416 "Red"
417 "indian red"
418 "IndianRed"
419 "medium violet red"
420 "MediumVioletRed"
421 "orange red"
422 "OrangeRed"
423 "violet red"
424 "VioletRed"
425 "salmon"
426 "Salmon"
427 "sienna"
428 "Sienna"
429 "tan"
430 "Tan"
431 "thistle"
432 "Thistle"
433 "turquoise"
434 "Turquoise"
435 "dark turquoise"
436 "DarkTurquoise"
437 "medium turquoise"
438 "MediumTurquoise"
439 "violet"
440 "Violet"
441 "blue violet"
442 "BlueViolet"
443 "wheat"
444 "Wheat"
445 "white"
446 "White"
447 "yellow"
448 "Yellow"
449 "green yellow"
450 "GreenYellow")
451 "The full list of X colors from the rgb.text file.")
452
453(defun x-defined-colors ()
454 "Return a list of colors supported by the current X-Display."
455 (let ((all-colors x-colors)
456 (this-color nil)
457 (defined-colors nil))
458 (while all-colors
459 (setq this-color (car all-colors)
460 all-colors (cdr all-colors))
847f5dab 461 (and (x-color-defined-p this-color)
63f77899
JB
462 (setq defined-colors (cons this-color defined-colors))))
463 defined-colors))
63f77899 464\f
98bf0c8d
JB
465;;;; Function keys
466
2d7bfcc3
RS
467(defun iconify-or-deiconify-frame ()
468 "Iconify the selected frame, or deiconify if it's currently an icon."
469 (interactive)
470 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
471 (iconify-frame)
19479ae2 472 (make-frame-visible)))
2d7bfcc3
RS
473
474(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
475 global-map)
e9de784c 476
3d80ef3f
RS
477;; Map certain keypad keys into ASCII characters
478;; that people usually expect.
479(define-key function-key-map [backspace] [127])
480(define-key function-key-map [delete] [127])
481(define-key function-key-map [tab] [?\t])
482(define-key function-key-map [linefeed] [?\n])
483(define-key function-key-map [clear] [11])
484(define-key function-key-map [return] [13])
485(define-key function-key-map [escape] [?\e])
486(define-key function-key-map [M-backspace] [?\M-\d])
487(define-key function-key-map [M-delete] [?\M-\d])
488(define-key function-key-map [M-tab] [?\M-\t])
489(define-key function-key-map [M-linefeed] [?\M-\n])
490(define-key function-key-map [M-clear] [?\M-\013])
491(define-key function-key-map [M-return] [?\M-\015])
492(define-key function-key-map [M-escape] [?\M-\e])
493
494;; These tell read-char how to convert
495;; these special chars to ASCII.
496(put 'backspace 'ascii-character 127)
497(put 'delete 'ascii-character 127)
498(put 'tab 'ascii-character ?\t)
499(put 'linefeed 'ascii-character ?\n)
500(put 'clear 'ascii-character 12)
501(put 'return 'ascii-character 13)
502(put 'escape 'ascii-character ?\e)
afa43349 503
96d63b2c
RS
504;; Set up to recognize vendor-specific keysyms.
505;; Unless/until there is a real conflict,
506;; we need not try to make this list depend on
507;; the type of X server in use.
52f04d46 508(setq system-key-alist
afa43349
RS
509 '(
510 ;; These are some HP keys.
96d63b2c
RS
511 ( 168 . mute-acute)
512 ( 169 . mute-grave)
513 ( 170 . mute-asciicircum)
514 ( 171 . mute-diaeresis)
515 ( 172 . mute-asciitilde)
516 ( 175 . lira)
517 ( 190 . guilder)
518 ( 252 . block)
519 ( 256 . longminus)
afa43349
RS
520 (65388 . reset)
521 (65389 . system)
522 (65390 . user)
523 (65391 . clearline)
524 (65392 . insertline)
525 (65393 . deleteline)
526 (65394 . insertchar)
527 (65395 . deletechar)
528 (65396 . backtab)
529 (65397 . kp-backtab)
acc8cdd2
RS
530 ;; This is used by DEC's X server.
531 (65280 . remove)
96d63b2c
RS
532 ;; These are for Sun.
533 (392976 . f35)
534 (392977 . f36)
b03f6d38 535 (393056 . req)
0a6ef8a7
RS
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)
afa43349 543 ))
2fb263f6
JB
544\f
545;;;; Selections and cut buffers
67c86cfc 546
daa37602
JB
547;;; We keep track of the last text selected here, so we can check the
548;;; current selection against it, and avoid passing back our own text
549;;; from x-cut-buffer-or-selection-value.
550(defvar x-last-selected-text nil)
551
2666a6a5 552;;; It is said that overlarge strings are slow to put into the cut buffer.
ef599142
RS
553;;; Note this value is overridden below.
554(defvar x-cut-buffer-max 20000
2666a6a5
RS
555 "Max number of characters to put in the cut buffer.")
556
dc20df95
RS
557(defvar x-select-enable-clipboard nil
558 "Non-nil means cutting and pasting uses the clipboard.
559This is in addition to the primary selection.")
560
2666a6a5 561;;; Make TEXT, a string, the primary X selection.
492878e4 562;;; Also, set the value of X cut buffer 0, for backward compatibility
d81fd0bf 563;;; with older X applications.
2666a6a5
RS
564;;; gildea@lcs.mit.edu says it's not desirable to put kills
565;;; in the clipboard.
0e2f4e59 566(defun x-select-text (text &optional push)
785080c5
RS
567 ;; Don't send the cut buffer too much text.
568 ;; It becomes slow, and if really big it causes errors.
569 (if (< (length text) x-cut-buffer-max)
2666a6a5 570 (x-set-cut-buffer text push)
14324c4d 571 (x-set-cut-buffer "" push))
c8c72d6b 572 (x-set-selection 'PRIMARY text)
dc20df95
RS
573 (if x-select-enable-clipboard
574 (x-set-selection 'CLIPBOARD text))
daa37602 575 (setq x-last-selected-text text))
492878e4 576
4390cc9c
KH
577;;; Return the value of the current X selection.
578;;; Consult the selection, then the cut buffer. Treat empty strings
579;;; as if they were unset.
492878e4 580(defun x-cut-buffer-or-selection-value ()
f6c7b4e7
JB
581 (let (text)
582
4390cc9c
KH
583 ;; Don't die if x-get-selection signals an error.
584 (condition-case c
585 (setq text (x-get-selection 'PRIMARY))
586 (error (message "%s" c)))
f6c7b4e7 587 (if (string= text "") (setq text nil))
dc20df95
RS
588
589 (if x-select-enable-clipboard
590 (condition-case c
591 (setq text (x-get-selection 'CLIPBOARD))
592 (error (message "%s" c))))
593 (if (string= text "") (setq text nil))
ef599142 594 (or text (setq text (x-get-cut-buffer 0)))
2666a6a5 595 (if (string= text "") (setq text nil))
f6c7b4e7
JB
596
597 (cond
598 ((not text) nil)
599 ((eq text x-last-selected-text) nil)
600 ((string= text x-last-selected-text)
601 ;; Record the newer string, so subsequent calls can use the `eq' test.
602 (setq x-last-selected-text text)
603 nil)
604 (t
605 (setq x-last-selected-text text)))))
492878e4 606
2fb263f6
JB
607\f
608;;; Do the actual X Windows setup here; the above code just defines
609;;; functions and variables that we use now.
610
611(setq command-line-args (x-handle-args command-line-args))
800642d2
JB
612
613;;; Make sure we have a valid resource name.
614(or (stringp x-resource-name)
615 (let (i)
616 (setq x-resource-name (invocation-name))
617
618 ;; Change any . or * characters in x-resource-name to hyphens,
619 ;; so as not to choke when we use it in X resource queries.
620 (while (setq i (string-match "[.*]" x-resource-name))
621 (aset x-resource-name i ?-))))
622
2490f7d5
RS
623(menu-bar-mode t)
624
2fb263f6 625(x-open-connection (or x-display-name
f6f6d98c
RS
626 (setq x-display-name (getenv "DISPLAY")))
627 x-command-line-resources)
2fb263f6 628
ffe1dd7a 629(setq frame-creation-function 'x-create-frame-with-faces)
3d80ef3f 630
ef599142
RS
631(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
632 x-cut-buffer-max))
633
5b0b2316
RS
634;; Sun expects the menu bar cut and paste commands to use the clipboard.
635(if (string-match "X11/NeWS - Sun Microsystems Inc\\."
636 (x-server-vendor))
637 (menu-bar-enable-clipboard))
638
5d20eba6
JB
639;; Apply a geometry resource to the initial frame. Put it at the end
640;; of the alist, so that anything specified on the command line takes
641;; precedence.
642(let ((res-geometry (x-get-resource "geometry" "Geometry")))
643 (if res-geometry
644 (setq initial-frame-alist (append initial-frame-alist
645 (x-parse-geometry res-geometry)))))
646
88046be2 647;; Check the reverseVideo resource.
800642d2
JB
648(let ((case-fold-search t))
649 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
650 (if (and rv
651 (string-match "^\\(true\\|yes\\|on\\)$" rv))
652 (setq default-frame-alist
653 (cons '(reverse . t) default-frame-alist)))))
88046be2 654
553624bf
RS
655;; Set x-selection-timeout, measured in milliseconds.
656(let ((res-selection-timeout
657 (x-get-resource "selectionTimeout" "SelectionTimeout")))
5c2867e0 658 (setq x-selection-timeout 20000)
553624bf
RS
659 (if res-selection-timeout
660 (setq x-selection-timeout (string-to-number res-selection-timeout))))
661
3d80ef3f
RS
662(defun x-win-suspend-error ()
663 (error "Suspending an emacs running under X makes no sense"))
c8c72d6b
JB
664(add-hook 'suspend-hook 'x-win-suspend-error)
665
492878e4
JB
666;;; Arrange for the kill and yank functions to set and check the clipboard.
667(setq interprogram-cut-function 'x-select-text)
668(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
63c86e17 669
0cc6db57
JB
670;;; Turn off window-splitting optimization; X is usually fast enough
671;;; that this is only annoying.
672(setq split-window-keep-point t)
5cdb3f1e
ER
673
674;;; x-win.el ends here