1 ;;; x-win.el --- parse relevant switches and set up for X -*-coding: iso-2022-7bit;-*-
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008 Free Software Foundation, Inc.
7 ;; Keywords: terminals, i18n
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; X-win.el: this file defines functions to initialize the X window
27 ;; system and process X-specific command line parameters before
28 ;; creating the first X frame.
30 ;; Note that contrary to previous Emacs versions, the act of loading
31 ;; this file should not have the side effect of initializing the
32 ;; window system or processing command line arguments (this file is
33 ;; now loaded in loadup.el). See the variables
34 ;; `handle-args-function-alist' and
35 ;; `window-system-initialization-alist' for more details.
37 ;; startup.el will then examine startup files, and eventually call the hooks
38 ;; which create the first window(s).
42 ;; These are the standard X switches from the Xt Initialize.c file of
45 ;; Command line Resource Manager string
48 ;; +synchronous *synchronous
49 ;; -background *background
52 ;; -bordercolor *borderColor
53 ;; -borderwidth .borderWidth
59 ;; -foreground *foreground
60 ;; -geometry .geometry
63 ;; -reverse *reverseVideo
65 ;; -selectionTimeout .selectionTimeout
66 ;; -synchronous *synchronous
69 ;; An alist of X options and the function which handles them. See
72 (if (not (fboundp 'x-create-frame
))
73 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
84 (defvar x-invocation-args
)
85 (defvar x-keysym-table
)
86 (defvar x-selection-timeout
)
88 (defvar x-session-previous-id
)
90 (defun x-handle-no-bitmap-icon (switch)
91 (setq default-frame-alist
(cons '(icon-type) default-frame-alist
)))
93 ;; Handle the --parent-id option.
94 (defun x-handle-parent-id (switch)
95 (or (consp x-invocation-args
)
96 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
97 (setq initial-frame-alist
(cons
99 (string-to-number (car x-invocation-args
)))
101 x-invocation-args
(cdr x-invocation-args
)))
103 ;; Handle the --smid switch. This is used by the session manager
104 ;; to give us back our session id we had on the previous run.
105 (defun x-handle-smid (switch)
106 (or (consp x-invocation-args
)
107 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
108 (setq x-session-previous-id
(car x-invocation-args
)
109 x-invocation-args
(cdr x-invocation-args
)))
111 (defvar emacs-save-session-functions nil
112 "Special hook run when a save-session event occurs.
113 The functions do not get any argument.
114 Functions can return non-nil to inform the session manager that the
115 window system shutdown should be aborted.
117 See also `emacs-session-save'.")
119 (defun emacs-session-filename (session-id)
120 "Construct a filename to save the session in based on SESSION-ID.
121 If the directory ~/.emacs.d exists, we make a filename in there, otherwise
122 a file in the home directory."
123 (let ((basename (concat "session." session-id
))
124 (emacs-dir user-emacs-directory
))
125 (expand-file-name (if (file-directory-p emacs-dir
)
126 (concat emacs-dir basename
)
127 (concat "~/.emacs-" basename
)))))
129 (defun emacs-session-save ()
130 "This function is called when the window system is shutting down.
131 If this function returns non-nil, the window system shutdown is cancelled.
133 When a session manager tells Emacs that the window system is shutting
134 down, this function is called. It calls the functions in the hook
135 `emacs-save-session-functions'. Functions are called with the current
136 buffer set to a temporary buffer. Functions should use `insert' to insert
137 lisp code to save the session state. The buffer is saved
138 in a file in the home directory of the user running Emacs. The file
139 is evaluated when Emacs is restarted by the session manager.
141 If any of the functions returns non-nil, no more functions are called
142 and this function returns non-nil. This will inform the session manager
143 that it should abort the window system shutdown."
144 (let ((filename (emacs-session-filename x-session-id
))
145 (buf (get-buffer-create (concat " *SES " x-session-id
))))
146 (when (file-exists-p filename
)
147 (delete-file filename
))
148 (with-current-buffer buf
149 (let ((cancel-shutdown (condition-case nil
150 ;; A return of t means cancel the shutdown.
151 (run-hook-with-args-until-success
152 'emacs-save-session-functions
)
154 (unless cancel-shutdown
155 (write-file filename
))
159 (defun emacs-session-restore (previous-session-id)
160 "Restore the Emacs session if started by a session manager.
161 The file saved by `emacs-session-save' is evaluated and deleted if it
163 (let ((filename (emacs-session-filename previous-session-id
)))
164 (when (file-exists-p filename
)
166 (delete-file filename
)
167 (message "Restored session data"))))
173 ;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
176 (defconst x-pointer-X-cursor
0)
177 (defconst x-pointer-arrow
2)
178 (defconst x-pointer-based-arrow-down
4)
179 (defconst x-pointer-based-arrow-up
6)
180 (defconst x-pointer-boat
8)
181 (defconst x-pointer-bogosity
10)
182 (defconst x-pointer-bottom-left-corner
12)
183 (defconst x-pointer-bottom-right-corner
14)
184 (defconst x-pointer-bottom-side
16)
185 (defconst x-pointer-bottom-tee
18)
186 (defconst x-pointer-box-spiral
20)
187 (defconst x-pointer-center-ptr
22)
188 (defconst x-pointer-circle
24)
189 (defconst x-pointer-clock
26)
190 (defconst x-pointer-coffee-mug
28)
191 (defconst x-pointer-cross
30)
192 (defconst x-pointer-cross-reverse
32)
193 (defconst x-pointer-crosshair
34)
194 (defconst x-pointer-diamond-cross
36)
195 (defconst x-pointer-dot
38)
196 (defconst x-pointer-dotbox
40)
197 (defconst x-pointer-double-arrow
42)
198 (defconst x-pointer-draft-large
44)
199 (defconst x-pointer-draft-small
46)
200 (defconst x-pointer-draped-box
48)
201 (defconst x-pointer-exchange
50)
202 (defconst x-pointer-fleur
52)
203 (defconst x-pointer-gobbler
54)
204 (defconst x-pointer-gumby
56)
205 (defconst x-pointer-hand1
58)
206 (defconst x-pointer-hand2
60)
207 (defconst x-pointer-heart
62)
208 (defconst x-pointer-icon
64)
209 (defconst x-pointer-iron-cross
66)
210 (defconst x-pointer-left-ptr
68)
211 (defconst x-pointer-left-side
70)
212 (defconst x-pointer-left-tee
72)
213 (defconst x-pointer-leftbutton
74)
214 (defconst x-pointer-ll-angle
76)
215 (defconst x-pointer-lr-angle
78)
216 (defconst x-pointer-man
80)
217 (defconst x-pointer-middlebutton
82)
218 (defconst x-pointer-mouse
84)
219 (defconst x-pointer-pencil
86)
220 (defconst x-pointer-pirate
88)
221 (defconst x-pointer-plus
90)
222 (defconst x-pointer-question-arrow
92)
223 (defconst x-pointer-right-ptr
94)
224 (defconst x-pointer-right-side
96)
225 (defconst x-pointer-right-tee
98)
226 (defconst x-pointer-rightbutton
100)
227 (defconst x-pointer-rtl-logo
102)
228 (defconst x-pointer-sailboat
104)
229 (defconst x-pointer-sb-down-arrow
106)
230 (defconst x-pointer-sb-h-double-arrow
108)
231 (defconst x-pointer-sb-left-arrow
110)
232 (defconst x-pointer-sb-right-arrow
112)
233 (defconst x-pointer-sb-up-arrow
114)
234 (defconst x-pointer-sb-v-double-arrow
116)
235 (defconst x-pointer-shuttle
118)
236 (defconst x-pointer-sizing
120)
237 (defconst x-pointer-spider
122)
238 (defconst x-pointer-spraycan
124)
239 (defconst x-pointer-star
126)
240 (defconst x-pointer-target
128)
241 (defconst x-pointer-tcross
130)
242 (defconst x-pointer-top-left-arrow
132)
243 (defconst x-pointer-top-left-corner
134)
244 (defconst x-pointer-top-right-corner
136)
245 (defconst x-pointer-top-side
138)
246 (defconst x-pointer-top-tee
140)
247 (defconst x-pointer-trek
142)
248 (defconst x-pointer-ul-angle
144)
249 (defconst x-pointer-umbrella
146)
250 (defconst x-pointer-ur-angle
148)
251 (defconst x-pointer-watch
150)
252 (defconst x-pointer-xterm
152)
253 (defconst x-pointer-invisible
255)
258 (defun xw-defined-colors (&optional frame
)
259 "Internal function called by `defined-colors', which see."
260 (or frame
(setq frame
(selected-frame)))
261 (let ((all-colors x-colors
)
263 (defined-colors nil
))
265 (setq this-color
(car all-colors
)
266 all-colors
(cdr all-colors
))
267 (and (color-supported-p this-color frame t
)
268 (setq defined-colors
(cons this-color defined-colors
))))
273 (defvar x-alternatives-map
274 (let ((map (make-sparse-keymap)))
275 ;; Map certain keypad keys into ASCII characters that people usually expect.
276 (define-key map
[backspace] [127])
277 (define-key map [delete] [127])
278 (define-key map [tab] [?\t])
279 (define-key map [linefeed] [?\n])
280 (define-key map [clear] [?\C-l])
281 (define-key map [return] [?\C-m])
282 (define-key map [escape] [?\e])
283 (define-key map [M-backspace] [?\M-\d])
284 (define-key map [M-delete] [?\M-\d])
285 (define-key map [M-tab] [?\M-\t])
286 (define-key map [M-linefeed] [?\M-\n])
287 (define-key map [M-clear] [?\M-\C-l])
288 (define-key map [M-return] [?\M-\C-m])
289 (define-key map [M-escape] [?\M-\e])
290 (define-key map [iso-lefttab] [backtab])
291 (define-key map [S-iso-lefttab] [backtab])
293 "Keymap of possible alternative meanings for some keys.")
295 (defun x-setup-function-keys (frame)
296 "Set up `function-key-map' on FRAME for the X window system."
297 ;; Don't do this twice on the same display, or it would break
298 ;; normal-erase-is-backspace-mode.
299 (unless (terminal-parameter frame 'x-setup-function-keys)
300 ;; Map certain keypad keys into ASCII characters that people usually expect.
301 (with-selected-frame frame
302 (let ((map (copy-keymap x-alternatives-map)))
303 (set-keymap-parent map (keymap-parent local-function-key-map))
304 (set-keymap-parent local-function-key-map map)))
305 (set-terminal-parameter frame 'x-setup-function-keys t)))
307 ;; These tell read-char how to convert
308 ;; these special chars to ASCII.
309 (put 'backspace 'ascii-character 127)
310 (put 'delete 'ascii-character 127)
311 (put 'tab 'ascii-character ?\t)
312 (put 'linefeed 'ascii-character ?\n)
313 (put 'clear 'ascii-character 12)
314 (put 'return 'ascii-character 13)
315 (put 'escape 'ascii-character ?\e)
320 (defun vendor-specific-keysyms (vendor)
321 "Return the appropriate value of `system-key-alist' for VENDOR.
322 VENDOR is a string containing the name of the X Server's vendor,
323 as returned by `x-server-vendor'."
324 (cond ((or (string-equal vendor "Hewlett-Packard Incorporated")
325 (string-equal vendor "Hewlett-Packard Company"))
326 '(( 168 . mute-acute)
328 ( 170 . mute-asciicircum)
329 ( 171 . mute-diaeresis)
330 ( 172 . mute-asciitilde)
344 (65397 . kp-backtab)))
345 ;; Fixme: What about non-X11/NeWS sun server?
346 ((or (string-equal vendor "X11/NeWS - Sun Microsystems Inc.")
347 (string-equal vendor "X Consortium"))
351 ;; These are for Sun under X11R6
359 ;; This is used by DEC's X server.
360 '((65280 . remove)))))
365 (puthash i i x-keysym-table)
368 ;; Table from Kuhn's proposed additions to the `KEYSYM Encoding'
369 ;; appendix to the X protocol definition.
430 (#x1ff . ?\e,B\x7f\e(B)
490 ;; Kana: Fixme: needs conversion to Japanese charset -- seems
491 ;; to require jisx0213, for which the Unicode translation
494 (#x4a1 . ?\e$A!#\e(B)
495 (#x4a2 . ?\\e$A!8\e(B)
496 (#x4a3 . ?\\e$A!9\e(B)
497 (#x4a4 . ?\e$A!"\e(B)
498 (#x4a5 . ?\e$A!$\e(B)
499 (#x4a6 . ?\e$A%r\e(B)
500 (#x4a7 . ?\e$A%!\e(B)
501 (#x4a8 . ?\e$A%#\e(B)
502 (#x4a9 . ?\e$A%%\e(B)
503 (#x4aa . ?\e$A%'\e(B)
504 (#x4ab . ?\e$A%)\e(B)
505 (#x4ac . ?\e$A%c\e(B)
506 (#x4ad . ?\e$A%e\e(B)
507 (#x4ae . ?\e$A%g\e(B)
508 (#x4af . ?\e$A%C\e(B)
509 (#x4b0 . ?\e$B!<\e(B)
510 (#x4b1 . ?\e$A%"\e(B)
511 (#x4b2 . ?\e$A%$\e(B)
512 (#x4b3 . ?\e$A%&\e(B)
513 (#x4b4 . ?\e$A%(\e(B)
514 (#x4b5 . ?\e$A%*\e(B)
515 (#x4b6 . ?\e$A%+\e(B)
516 (#x4b7 . ?\e$A%-\e(B)
517 (#x4b8 . ?\e$A%/\e(B)
518 (#x4b9 . ?\e$A%1\e(B)
519 (#x4ba . ?\e$A%3\e(B)
520 (#x4bb . ?\e$A%5\e(B)
521 (#x4bc . ?\e$A%7\e(B)
522 (#x4bd . ?\e$A%9\e(B)
523 (#x4be . ?\e$A%;\e(B)
524 (#x4bf . ?\e$A%=\e(B)
525 (#x4c0 . ?\e$A%?\e(B)
526 (#x4c1 . ?\e$A%A\e(B)
527 (#x4c2 . ?\e$A%D\e(B)
528 (#x4c3 . ?\e$A%F\e(B)
529 (#x4c4 . ?\e$A%H\e(B)
530 (#x4c5 . ?\e$A%J\e(B)
531 (#x4c6 . ?\e$A%K\e(B)
532 (#x4c7 . ?\e$A%L\e(B)
533 (#x4c8 . ?\e$A%M\e(B)
534 (#x4c9 . ?\e$A%N\e(B)
535 (#x4ca . ?\e$A%O\e(B)
536 (#x4cb . ?\e$A%R\e(B)
537 (#x4cc . ?\e$A%U\e(B)
538 (#x4cd . ?\e$A%X\e(B)
539 (#x4ce . ?\e$A%[\e(B)
540 (#x4cf . ?\e$A%^\e(B)
541 (#x4d0 . ?\e$A%_\e(B)
542 (#x4d1 . ?\e$A%`\e(B)
543 (#x4d2 . ?\e$A%a\e(B)
544 (#x4d3 . ?\e$A%b\e(B)
545 (#x4d4 . ?\e$A%d\e(B)
546 (#x4d5 . ?\e$A%f\e(B)
547 (#x4d6 . ?\e$A%h\e(B)
548 (#x4d7 . ?\e$A%i\e(B)
549 (#x4d8 . ?\e$A%j\e(B)
550 (#x4d9 . ?\e$A%k\e(B)
551 (#x4da . ?\e$A%l\e(B)
552 (#x4db . ?\e$A%m\e(B)
553 (#x4dc . ?\e$A%o\e(B)
554 (#x4dd . ?\e$A%s\e(B)
555 (#x4de . ?\e$B!+\e(B)
556 (#x4df . ?\e$B!,\e(B)
607 (#x680 . ?\e$,1)R\e(B)
608 (#x681 . ?\e$,1)V\e(B)
609 (#x682 . ?\e$,1)Z\e(B)
610 (#x683 . ?\e$,1)\\e(B)
611 (#x684 . ?\e$,1)b\e(B)
612 (#x685 . ?\e$,1)n\e(B)
613 (#x686 . ?\e$,1)p\e(B)
614 (#x687 . ?\e$,1)r\e(B)
615 (#x688 . ?\e$,1)v\e(B)
616 (#x689 . ?\e$,1)x\e(B)
617 (#x68a . ?\e$,1)z\e(B)
618 (#x68c . ?\e$,1*8\e(B)
619 (#x68d . ?\e$,1*B\e(B)
620 (#x68e . ?\e$,1*H\e(B)
621 (#x68f . ?\e$,1*N\e(B)
622 (#x690 . ?\e$,1)S\e(B)
623 (#x691 . ?\e$,1)W\e(B)
624 (#x692 . ?\e$,1)[\e(B)
625 (#x693 . ?\e$,1)]\e(B)
626 (#x694 . ?\e$,1)c\e(B)
627 (#x695 . ?\e$,1)o\e(B)
628 (#x696 . ?\e$,1)q\e(B)
629 (#x697 . ?\e$,1)s\e(B)
630 (#x698 . ?\e$,1)w\e(B)
631 (#x699 . ?\e$,1)y\e(B)
632 (#x69a . ?\e$,1){\e(B)
633 (#x69c . ?\e$,1*9\e(B)
634 (#x69d . ?\e$,1*C\e(B)
635 (#x69e . ?\e$,1*I\e(B)
636 (#x69f . ?\e$,1*O\e(B)
650 (#x6af . ?\e,L\x7f\e(B)
803 (#x8a1 . ?\e$,1|W\e(B)
804 (#x8a2 . ?\e$A)0\e(B)
805 (#x8a3 . ?\e$A)$\e(B)
806 (#x8a4 . ?\e$,1{ \e(B)
807 (#x8a5 . ?\e$,1{!\e(B)
808 (#x8a6 . ?\e$A)&\e(B)
809 (#x8a7 . ?\e$,1|A\e(B)
810 (#x8a8 . ?\e$,1|C\e(B)
811 (#x8a9 . ?\e$,1|D\e(B)
812 (#x8aa . ?\e$,1|F\e(B)
813 (#x8ab . ?\e$,1|;\e(B)
814 (#x8ac . ?\e$,1|=\e(B)
815 (#x8ad . ?\e$,1|>\e(B)
816 (#x8ae . ?\e$,1|@\e(B)
817 (#x8af . ?\e$,1|H\e(B)
818 (#x8b0 . ?\e$,1|L\e(B)
819 (#x8bc . ?\e$A!\\e(B)
820 (#x8bd . ?\e$A!Y\e(B)
821 (#x8be . ?\e$A!]\e(B)
822 (#x8bf . ?\e$A!R\e(B)
823 (#x8c0 . ?\e$A!`\e(B)
824 (#x8c1 . ?\e$A!X\e(B)
825 (#x8c2 . ?\e$A!^\e(B)
826 (#x8c5 . ?\e$B"`\e(B)
827 (#x8c8 . ?\e$(G"D\e(B)
828 (#x8c9 . ?\e$(O"l\e(B)
829 (#x8cd . ?\e$B"N\e(B)
830 (#x8ce . ?\e$B"M\e(B)
831 (#x8cf . ?\e$A!T\e(B)
832 (#x8d6 . ?\e$A!L\e(B)
833 (#x8da . ?\e$B">\e(B)
834 (#x8db . ?\e$B"?\e(B)
835 (#x8dc . ?\e$A!I\e(B)
836 (#x8dd . ?\e$A!H\e(B)
837 (#x8de . ?\e$A!D\e(B)
838 (#x8df . ?\e$A!E\e(B)
839 (#x8ef . ?\e$B"_\e(B)
840 (#x8f6 . ?\e$,1!R\e(B)
841 (#x8fb . ?\e$A!{\e(B)
842 (#x8fc . ?\e$A!|\e(B)
843 (#x8fd . ?\e$A!z\e(B)
844 (#x8fe . ?\e$A!}\e(B)
846 (#x9e0 . ?\e$A!t\e(B)
847 (#x9e1 . ?\e$(C"F\e(B)
848 (#x9e2 . ?\e$(GB*\e(B)
849 (#x9e3 . ?\e$(GB-\e(B)
850 (#x9e4 . ?\e$(GB.\e(B)
851 (#x9e5 . ?\e$(GB+\e(B)
852 (#x9e8 . ?\e$,1}d\e(B)
853 (#x9e9 . ?\e$(GB,\e(B)
854 (#x9ea . ?\e$A)<\e(B)
855 (#x9eb . ?\e$A)4\e(B)
856 (#x9ec . ?\e$A)0\e(B)
857 (#x9ed . ?\e$A)8\e(B)
858 (#x9ee . ?\e$A)`\e(B)
859 (#x9ef . ?\e$,1|Z\e(B)
860 (#x9f0 . ?\e$,1|[\e(B)
861 (#x9f1 . ?\e$A)$\e(B)
862 (#x9f2 . ?\e$,1|\\e(B)
863 (#x9f3 . ?\e$,1|]\e(B)
864 (#x9f4 . ?\e$A)@\e(B)
865 (#x9f5 . ?\e$A)H\e(B)
866 (#x9f6 . ?\e$A)X\e(B)
867 (#x9f7 . ?\e$A)P\e(B)
868 (#x9f8 . ?\e$A)&\e(B)
870 (#xaa1 . ?\e$,1rc\e(B)
871 (#xaa2 . ?\e$,1rb\e(B)
872 (#xaa3 . ?\e$,1rd\e(B)
873 (#xaa4 . ?\e$,1re\e(B)
874 (#xaa5 . ?\e$,1rg\e(B)
875 (#xaa6 . ?\e$,1rh\e(B)
876 (#xaa7 . ?\e$,1ri\e(B)
877 (#xaa8 . ?\e$,1rj\e(B)
878 (#xaa9 . ?\e$(G!7\e(B)
879 (#xaaa . ?\e$(G!9\e(B)
880 (#xaae . ?\e$A!-\e(B)
881 (#xaaf . ?\e$(G!-\e(B)
882 (#xab0 . ?\e$(O'x\e(B)
883 (#xab1 . ?\e$(O'y\e(B)
884 (#xab2 . ?\e$(O'z\e(B)
885 (#xab3 . ?\e$,1v6\e(B)
886 (#xab4 . ?\e$,1v7\e(B)
887 (#xab5 . ?\e$,1v8\e(B)
888 (#xab6 . ?\e$,1v9\e(B)
889 (#xab7 . ?\e$,1v:\e(B)
890 (#xab8 . ?\e$(G""\e(B)
891 (#xabb . ?\e$,1rr\e(B)
892 (#xabc . ?\e$,1{)\e(B)
893 (#xabe . ?\e$,1{*\e(B)
894 (#xac3 . ?\e$(C({\e(B)
895 (#xac4 . ?\e$(C(|\e(B)
896 (#xac5 . ?\e$(C(}\e(B)
897 (#xac6 . ?\e$(C(~\e(B)
898 (#xac9 . ?\e$(D"o\e(B)
899 (#xaca . ?\e$,2"s\e(B)
900 (#xacc . ?\e$(O##\e(B)
901 (#xacd . ?\e$(O#!\e(B)
902 (#xace . ?\e$A!p\e(B)
903 (#xacf . ?\e$,2!o\e(B)
908 (#xad4 . ?\e$,1u^\e(B)
909 (#xad6 . ?\e$A!d\e(B)
910 (#xad7 . ?\e$A!e\e(B)
911 (#xad9 . ?\e$,2%]\e(B)
912 (#xadb . ?\e$,2!l\e(B)
913 (#xadc . ?\e$(O#$\e(B)
914 (#xadd . ?\e$(O#"\e(B)
915 (#xade . ?\e$A!q\e(B)
916 (#xadf . ?\e$,2!n\e(B)
917 (#xae0 . ?\e$(O#?\e(B)
918 (#xae1 . ?\e$,2!k\e(B)
919 (#xae2 . ?\e$,2!m\e(B)
920 (#xae3 . ?\e$A!w\e(B)
921 (#xae4 . ?\e$(G!}\e(B)
922 (#xae5 . ?\e$A!n\e(B)
923 (#xae6 . ?\e$(O#@\e(B)
924 (#xae7 . ?\e$,2!j\e(B)
925 (#xae8 . ?\e$A!x\e(B)
926 (#xae9 . ?\e$(G!~\e(B)
927 (#xaea . ?\e$(C"P\e(B)
928 (#xaeb . ?\e$(O-~\e(B)
929 (#xaec . ?\e$(O&@\e(B)
930 (#xaed . ?\e$(O&<\e(B)
931 (#xaee . ?\e$(O&>\e(B)
932 (#xaf0 . ?\e$,2%`\e(B)
933 (#xaf1 . ?\e$B"w\e(B)
934 (#xaf2 . ?\e$B"x\e(B)
935 (#xaf3 . ?\e$(O'{\e(B)
936 (#xaf4 . ?\e$,2%W\e(B)
937 (#xaf5 . ?\e$B"t\e(B)
938 (#xaf6 . ?\e$B"u\e(B)
939 (#xaf7 . ?\e$A!a\e(B)
940 (#xaf8 . ?\e$A!b\e(B)
941 (#xaf9 . ?\e$(O&g\e(B)
942 (#xafa . ?\e$,1zu\e(B)
943 (#xafb . ?\e$,1uW\e(B)
944 (#xafc . ?\e$,1s8\e(B)
945 (#xafd . ?\e$,1rz\e(B)
950 (#xba8 . ?\e$A!E\e(B)
951 (#xba9 . ?\e$A!D\e(B)
953 (#xbc2 . ?\e$A!M\e(B)
954 (#xbc3 . ?\e$A!I\e(B)
955 (#xbc4 . ?\e$,1zj\e(B)
957 (#xbca . ?\e$,1x8\e(B)
958 (#xbcc . ?\e$,1|5\e(B)
959 (#xbce . ?\e$,1yd\e(B)
960 (#xbcf . ?\e$A!p\e(B)
961 (#xbd3 . ?\e$,1zh\e(B)
962 (#xbd6 . ?\e$A!H\e(B)
963 (#xbd8 . ?\e$B"?\e(B)
964 (#xbda . ?\e$B">\e(B)
965 (#xbdc . ?\e$,1yb\e(B)
966 (#xbfc . ?\e$,1yc\e(B)
1000 (#xda4 . ?\e,T$\e(B)
1001 (#xda5 . ?\e,T%\e(B)
1002 (#xda6 . ?\e,T&\e(B)
1003 (#xda7 . ?\e,T'\e(B)
1004 (#xda8 . ?\e,T(\e(B)
1005 (#xda9 . ?\e,T)\e(B)
1006 (#xdaa . ?\e,T*\e(B)
1007 (#xdab . ?\e,T+\e(B)
1008 (#xdac . ?\e,T,\e(B)
1009 (#xdad . ?\e,T-\e(B)
1010 (#xdae . ?\e,T.\e(B)
1011 (#xdaf . ?\e,T/\e(B)
1012 (#xdb0 . ?\e,T0\e(B)
1013 (#xdb1 . ?\e,T1\e(B)
1014 (#xdb2 . ?\e,T2\e(B)
1015 (#xdb3 . ?\e,T3\e(B)
1016 (#xdb4 . ?\e,T4\e(B)
1017 (#xdb5 . ?\e,T5\e(B)
1018 (#xdb6 . ?\e,T6\e(B)
1019 (#xdb7 . ?\e,T7\e(B)
1020 (#xdb8 . ?\e,T8\e(B)
1021 (#xdb9 . ?\e,T9\e(B)
1022 (#xdba . ?\e,T:\e(B)
1023 (#xdbb . ?\e,T;\e(B)
1024 (#xdbc . ?\e,T<\e(B)
1025 (#xdbd . ?\e,T=\e(B)
1026 (#xdbe . ?\e,T>\e(B)
1027 (#xdbf . ?\e,T?\e(B)
1028 (#xdc0 . ?\e,T@\e(B)
1029 (#xdc1 . ?\e,TA\e(B)
1030 (#xdc2 . ?\e,TB\e(B)
1031 (#xdc3 . ?\e,TC\e(B)
1032 (#xdc4 . ?\e,TD\e(B)
1033 (#xdc5 . ?\e,TE\e(B)
1034 (#xdc6 . ?\e,TF\e(B)
1035 (#xdc7 . ?\e,TG\e(B)
1036 (#xdc8 . ?\e,TH\e(B)
1037 (#xdc9 . ?\e,TI\e(B)
1038 (#xdca . ?\e,TJ\e(B)
1039 (#xdcb . ?\e,TK\e(B)
1040 (#xdcc . ?\e,TL\e(B)
1041 (#xdcd . ?\e,TM\e(B)
1042 (#xdce . ?\e,TN\e(B)
1043 (#xdcf . ?\e,TO\e(B)
1044 (#xdd0 . ?\e,TP\e(B)
1045 (#xdd1 . ?\e,TQ\e(B)
1046 (#xdd2 . ?\e,TR\e(B)
1047 (#xdd3 . ?\e,TS\e(B)
1048 (#xdd4 . ?\e,TT\e(B)
1049 (#xdd5 . ?\e,TU\e(B)
1050 (#xdd6 . ?\e,TV\e(B)
1051 (#xdd7 . ?\e,TW\e(B)
1052 (#xdd8 . ?\e,TX\e(B)
1053 (#xdd9 . ?\e,TY\e(B)
1054 (#xdda . ?\e,TZ\e(B)
1055 (#xddf . ?\e,T_\e(B)
1056 (#xde0 . ?\e,T`\e(B)
1057 (#xde1 . ?\e,Ta\e(B)
1058 (#xde2 . ?\e,Tb\e(B)
1059 (#xde3 . ?\e,Tc\e(B)
1060 (#xde4 . ?\e,Td\e(B)
1061 (#xde5 . ?\e,Te\e(B)
1062 (#xde6 . ?\e,Tf\e(B)
1063 (#xde7 . ?\e,Tg\e(B)
1064 (#xde8 . ?\e,Th\e(B)
1065 (#xde9 . ?\e,Ti\e(B)
1066 (#xdea . ?\e,Tj\e(B)
1067 (#xdeb . ?\e,Tk\e(B)
1068 (#xdec . ?\e,Tl\e(B)
1069 (#xded . ?\e,Tm\e(B)
1070 (#xdf0 . ?\e,Tp\e(B)
1071 (#xdf1 . ?\e,Tq\e(B)
1072 (#xdf2 . ?\e,Tr\e(B)
1073 (#xdf3 . ?\e,Ts\e(B)
1074 (#xdf4 . ?\e,Tt\e(B)
1075 (#xdf5 . ?\e,Tu\e(B)
1076 (#xdf6 . ?\e,Tv\e(B)
1077 (#xdf7 . ?\e,Tw\e(B)
1078 (#xdf8 . ?\e,Tx\e(B)
1079 (#xdf9 . ?\e,Ty\e(B)
1081 (#xea1 . ?\e$(C$!\e(B)
1082 (#xea2 . ?\e$(C$"\e(B)
1083 (#xea3 . ?\e$(C$#\e(B)
1084 (#xea4 . ?\e$(C$$\e(B)
1085 (#xea5 . ?\e$(C$%\e(B)
1086 (#xea6 . ?\e$(C$&\e(B)
1087 (#xea7 . ?\e$(C$'\e(B)
1088 (#xea8 . ?\e$(C$(\e(B)
1089 (#xea9 . ?\e$(C$)\e(B)
1090 (#xeaa . ?\e$(C$*\e(B)
1091 (#xeab . ?\e$(C$+\e(B)
1092 (#xeac . ?\e$(C$,\e(B)
1093 (#xead . ?\e$(C$-\e(B)
1094 (#xeae . ?\e$(C$.\e(B)
1095 (#xeaf . ?\e$(C$/\e(B)
1096 (#xeb0 . ?\e$(C$0\e(B)
1097 (#xeb1 . ?\e$(C$1\e(B)
1098 (#xeb2 . ?\e$(C$2\e(B)
1099 (#xeb3 . ?\e$(C$3\e(B)
1100 (#xeb4 . ?\e$(C$4\e(B)
1101 (#xeb5 . ?\e$(C$5\e(B)
1102 (#xeb6 . ?\e$(C$6\e(B)
1103 (#xeb7 . ?\e$(C$7\e(B)
1104 (#xeb8 . ?\e$(C$8\e(B)
1105 (#xeb9 . ?\e$(C$9\e(B)
1106 (#xeba . ?\e$(C$:\e(B)
1107 (#xebb . ?\e$(C$;\e(B)
1108 (#xebc . ?\e$(C$<\e(B)
1109 (#xebd . ?\e$(C$=\e(B)
1110 (#xebe . ?\e$(C$>\e(B)
1111 (#xebf . ?\e$(C$?\e(B)
1112 (#xec0 . ?\e$(C$@\e(B)
1113 (#xec1 . ?\e$(C$A\e(B)
1114 (#xec2 . ?\e$(C$B\e(B)
1115 (#xec3 . ?\e$(C$C\e(B)
1116 (#xec4 . ?\e$(C$D\e(B)
1117 (#xec5 . ?\e$(C$E\e(B)
1118 (#xec6 . ?\e$(C$F\e(B)
1119 (#xec7 . ?\e$(C$G\e(B)
1120 (#xec8 . ?\e$(C$H\e(B)
1121 (#xec9 . ?\e$(C$I\e(B)
1122 (#xeca . ?\e$(C$J\e(B)
1123 (#xecb . ?\e$(C$K\e(B)
1124 (#xecc . ?\e$(C$L\e(B)
1125 (#xecd . ?\e$(C$M\e(B)
1126 (#xece . ?\e$(C$N\e(B)
1127 (#xecf . ?\e$(C$O\e(B)
1128 (#xed0 . ?\e$(C$P\e(B)
1129 (#xed1 . ?\e$(C$Q\e(B)
1130 (#xed2 . ?\e$(C$R\e(B)
1131 (#xed3 . ?\e$(C$S\e(B)
1132 (#xed4 . ?\e$,1LH\e(B)
1133 (#xed5 . ?\e$,1LI\e(B)
1134 (#xed6 . ?\e$,1LJ\e(B)
1135 (#xed7 . ?\e$,1LK\e(B)
1136 (#xed8 . ?\e$,1LL\e(B)
1137 (#xed9 . ?\e$,1LM\e(B)
1138 (#xeda . ?\e$,1LN\e(B)
1139 (#xedb . ?\e$,1LO\e(B)
1140 (#xedc . ?\e$,1LP\e(B)
1141 (#xedd . ?\e$,1LQ\e(B)
1142 (#xede . ?\e$,1LR\e(B)
1143 (#xedf . ?\e$,1LS\e(B)
1144 (#xee0 . ?\e$,1LT\e(B)
1145 (#xee1 . ?\e$,1LU\e(B)
1146 (#xee2 . ?\e$,1LV\e(B)
1147 (#xee3 . ?\e$,1LW\e(B)
1148 (#xee4 . ?\e$,1LX\e(B)
1149 (#xee5 . ?\e$,1LY\e(B)
1150 (#xee6 . ?\e$,1LZ\e(B)
1151 (#xee7 . ?\e$,1L[\e(B)
1152 (#xee8 . ?\e$,1L\\e(B)
1153 (#xee9 . ?\e$,1L]\e(B)
1154 (#xeea . ?\e$,1L^\e(B)
1155 (#xeeb . ?\e$,1L_\e(B)
1156 (#xeec . ?\e$,1L`\e(B)
1157 (#xeed . ?\e$,1La\e(B)
1158 (#xeee . ?\e$,1Lb\e(B)
1159 (#xeef . ?\e$(C$]\e(B)
1160 (#xef0 . ?\e$(C$a\e(B)
1161 (#xef1 . ?\e$(C$h\e(B)
1162 (#xef2 . ?\e$(C$o\e(B)
1163 (#xef3 . ?\e$(C$q\e(B)
1164 (#xef4 . ?\e$(C$t\e(B)
1165 (#xef5 . ?\e$(C$v\e(B)
1166 (#xef6 . ?\e$(C$}\e(B)
1167 (#xef7 . ?\e$(C$~\e(B)
1168 (#xef8 . ?\e$,1M+\e(B)
1169 (#xef9 . ?\e$,1M0\e(B)
1170 (#xefa . ?\e$,1M9\e(B)
1171 (#xeff . ?\e$,1tI\e(B)
1177 (#x13bc . ?\e,b<\e(B)
1178 (#x13bd . ?\e,b=\e(B)
1179 (#x13be . ?\e,_/\e(B)
1181 (#x20a0 . ?\e$,1t@\e(B)
1182 (#x20a1 . ?\e$,1tA\e(B)
1183 (#x20a2 . ?\e$,1tB\e(B)
1184 (#x20a3 . ?\e$,1tC\e(B)
1185 (#x20a4 . ?\e$,1tD\e(B)
1186 (#x20a5 . ?\e$,1tE\e(B)
1187 (#x20a6 . ?\e$,1tF\e(B)
1188 (#x20a7 . ?\e$,1tG\e(B)
1189 (#x20a8 . ?\e$,1tH\e(B)
1190 (#x20aa . ?\e$,1tJ\e(B)
1191 (#x20ab . ?\e$,1tK\e(B)
1192 (#x20ac . ?\e,b$\e(B)))
1193 (puthash (car pair) (cdr pair) x-keysym-table))
1195 ;; The following keysym codes for graphics are listed in the document
1196 ;; as not having unicodes available:
1198 ;; #x08b1 TOP LEFT SUMMATION Technical
1199 ;; #x08b2 BOTTOM LEFT SUMMATION Technical
1200 ;; #x08b3 TOP VERTICAL SUMMATION CONNECTOR Technical
1201 ;; #x08b4 BOTTOM VERTICAL SUMMATION CONNECTOR Technical
1202 ;; #x08b5 TOP RIGHT SUMMATION Technical
1203 ;; #x08b6 BOTTOM RIGHT SUMMATION Technical
1204 ;; #x08b7 RIGHT MIDDLE SUMMATION Technical
1205 ;; #x0aac SIGNIFICANT BLANK SYMBOL Publish
1206 ;; #x0abd DECIMAL POINT Publish
1207 ;; #x0abf MARKER Publish
1208 ;; #x0acb TRADEMARK SIGN IN CIRCLE Publish
1209 ;; #x0ada HEXAGRAM Publish
1210 ;; #x0aff CURSOR Publish
1211 ;; #x0dde THAI MAIHANAKAT Thai
1214 ;;;; Selections and cut buffers
1216 ;; We keep track of the last text selected here, so we can check the
1217 ;; current selection against it, and avoid passing back our own text
1218 ;; from x-cut-buffer-or-selection-value. We track all three
1219 ;; seperately in case another X application only sets one of them
1220 ;; (say the cut buffer) we aren't fooled by the PRIMARY or
1221 ;; CLIPBOARD selection staying the same.
1222 (defvar x-last-selected-text-clipboard nil
1223 "The value of the CLIPBOARD X selection last time we selected or
1225 (defvar x-last-selected-text-primary nil
1226 "The value of the PRIMARY X selection last time we selected or
1228 (defvar x-last-selected-text-cut nil
1229 "The value of the X cut buffer last time we selected or pasted text.
1230 The actual text stored in the X cut buffer is what encoded from this value.")
1231 (defvar x-last-selected-text-cut-encoded nil
1232 "The value of the X cut buffer last time we selected or pasted text.
1233 This is the actual text stored in the X cut buffer.")
1234 (defvar x-last-cut-buffer-coding 'iso-latin-1
1235 "The coding we last used to encode/decode the text from the X cut buffer")
1237 (defvar x-cut-buffer-max 20000 ; Note this value is overridden below.
1238 "Max number of characters to put in the cut buffer.
1239 It is said that overlarge strings are slow to put into the cut buffer.")
1241 (defcustom x-select-enable-clipboard nil
1242 "Non-nil means cutting and pasting uses the clipboard.
1243 This is in addition to, but in preference to, the primary selection."
1247 (defcustom x-select-enable-primary t
1248 "Non-nil means cutting and pasting uses the primary selection."
1252 (defun x-select-text (text &optional push)
1253 "Make TEXT, a string, the primary X selection.
1254 Also, set the value of X cut buffer 0, for backward compatibility
1255 with older X applications.
1256 gildea@stop.mail-abuse.org says it's not desirable to put kills
1258 ;; With multi-tty, this function may be called from a tty frame.
1259 (when (eq (framep (selected-frame)) 'x)
1260 ;; Don't send the cut buffer too much text.
1261 ;; It becomes slow, and if really big it causes errors.
1262 (cond ((>= (length text) x-cut-buffer-max)
1263 (x-set-cut-buffer "" push)
1264 (setq x-last-selected-text-cut ""
1265 x-last-selected-text-cut-encoded ""))
1267 (setq x-last-selected-text-cut text
1268 x-last-cut-buffer-coding 'iso-latin-1
1269 x-last-selected-text-cut-encoded
1270 ;; ICCCM says cut buffer always contain ISO-Latin-1
1271 (encode-coding-string text 'iso-latin-1))
1272 (x-set-cut-buffer x-last-selected-text-cut-encoded push)))
1273 (when x-select-enable-primary
1274 (x-set-selection 'PRIMARY text)
1275 (setq x-last-selected-text-primary text))
1276 (when x-select-enable-clipboard
1277 (x-set-selection 'CLIPBOARD text)
1278 (setq x-last-selected-text-clipboard text))))
1280 (defvar x-select-request-type nil
1281 "*Data type request for X selection.
1282 The value is one of the following data types, a list of them, or nil:
1283 `COMPOUND_TEXT', `UTF8_STRING', `STRING', `TEXT'
1285 If the value is one of the above symbols, try only the specified
1288 If the value is a list of them, try each of them in the specified
1289 order until succeed.
1291 The value nil is the same as this list:
1292 \(UTF8_STRING COMPOUND_TEXT STRING)
1295 ;; Get a selection value of type TYPE by calling x-get-selection with
1296 ;; an appropiate DATA-TYPE argument decided by `x-select-request-type'.
1297 ;; The return value is already decoded. If x-get-selection causes an
1298 ;; error, this function return nil.
1300 (defun x-selection-value (type)
1301 (let ((request-type (or x-select-request-type
1302 '(UTF8_STRING COMPOUND_TEXT STRING)))
1304 (if (consp request-type)
1305 (while (and request-type (not text))
1307 (setq text (x-get-selection type (car request-type)))
1309 (setq request-type (cdr request-type)))
1311 (setq text (x-get-selection type request-type))
1314 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
1317 ;; Return the value of the current X selection.
1318 ;; Consult the selection, and the cut buffer. Treat empty strings
1319 ;; as if they were unset.
1320 ;; If this function is called twice and finds the same text,
1321 ;; it returns nil the second time. This is so that a single
1322 ;; selection won't be added to the kill ring over and over.
1323 (defun x-cut-buffer-or-selection-value ()
1324 ;; With multi-tty, this function may be called from a tty frame.
1325 (when (eq (framep (selected-frame)) 'x)
1326 (let (clip-text primary-text cut-text)
1327 (when x-select-enable-clipboard
1328 (setq clip-text (x-selection-value 'CLIPBOARD))
1329 (if (string= clip-text "") (setq clip-text nil))
1331 ;; Check the CLIPBOARD selection for 'newness', is it different
1332 ;; from what we remebered them to be last time we did a
1333 ;; cut/paste operation.
1335 (cond ;; check clipboard
1336 ((or (not clip-text) (string= clip-text ""))
1337 (setq x-last-selected-text-clipboard nil))
1338 ((eq clip-text x-last-selected-text-clipboard) nil)
1339 ((string= clip-text x-last-selected-text-clipboard)
1340 ;; Record the newer string,
1341 ;; so subsequent calls can use the `eq' test.
1342 (setq x-last-selected-text-clipboard clip-text)
1344 (t (setq x-last-selected-text-clipboard clip-text)))))
1346 (when x-select-enable-primary
1347 (setq primary-text (x-selection-value 'PRIMARY))
1348 ;; Check the PRIMARY selection for 'newness', is it different
1349 ;; from what we remebered them to be last time we did a
1350 ;; cut/paste operation.
1352 (cond ;; check primary selection
1353 ((or (not primary-text) (string= primary-text ""))
1354 (setq x-last-selected-text-primary nil))
1355 ((eq primary-text x-last-selected-text-primary) nil)
1356 ((string= primary-text x-last-selected-text-primary)
1357 ;; Record the newer string,
1358 ;; so subsequent calls can use the `eq' test.
1359 (setq x-last-selected-text-primary primary-text)
1362 (setq x-last-selected-text-primary primary-text)))))
1364 (setq cut-text (x-get-cut-buffer 0))
1366 ;; Check the x cut buffer for 'newness', is it different
1367 ;; from what we remebered them to be last time we did a
1368 ;; cut/paste operation.
1370 (let ((next-coding (or next-selection-coding-system 'iso-latin-1)))
1371 (cond ;; check cut buffer
1372 ((or (not cut-text) (string= cut-text ""))
1373 (setq x-last-selected-text-cut nil))
1374 ;; This short cut doesn't work because x-get-cut-buffer
1375 ;; always returns a newly created string.
1376 ;; ((eq cut-text x-last-selected-text-cut) nil)
1377 ((and (string= cut-text x-last-selected-text-cut-encoded)
1378 (eq x-last-cut-buffer-coding next-coding))
1379 ;; See the comment above. No need of this recording.
1380 ;; Record the newer string,
1381 ;; so subsequent calls can use the `eq' test.
1382 ;; (setq x-last-selected-text-cut cut-text)
1385 (setq x-last-selected-text-cut-encoded cut-text
1386 x-last-cut-buffer-coding next-coding
1387 x-last-selected-text-cut
1388 ;; ICCCM says cut buffer always contain ISO-Latin-1, but
1389 ;; use next-selection-coding-system if not nil.
1390 (decode-coding-string
1391 cut-text next-coding))))))
1393 ;; As we have done one selection, clear this now.
1394 (setq next-selection-coding-system nil)
1396 ;; At this point we have recorded the current values for the
1397 ;; selection from clipboard (if we are supposed to) primary,
1398 ;; and cut buffer. So return the first one that has changed
1399 ;; (which is the first non-null one).
1401 ;; NOTE: There will be cases where more than one of these has
1402 ;; changed and the new values differ. This indicates that
1403 ;; something like the following has happened since the last time
1404 ;; we looked at the selections: Application X set all the
1405 ;; selections, then Application Y set only one or two of them (say
1406 ;; just the cut-buffer). In this case since we don't have
1407 ;; timestamps there is no way to know what the 'correct' value to
1408 ;; return is. The nice thing to do would be to tell the user we
1409 ;; saw multiple possible selections and ask the user which was the
1411 ;; This code is still a big improvement because now the user can
1412 ;; futz with the current selection and get emacs to pay attention
1413 ;; to the cut buffer again (previously as soon as clipboard or
1414 ;; primary had been set the cut buffer would essentially never be
1416 (or clip-text primary-text cut-text)
1419 ;; Arrange for the kill and yank functions to set and check the clipboard.
1420 (setq interprogram-cut-function 'x-select-text)
1421 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1423 (defun x-clipboard-yank ()
1424 "Insert the clipboard contents, or the last stretch of killed text."
1426 (let ((clipboard-text (x-selection-value 'CLIPBOARD))
1427 (x-select-enable-clipboard t))
1428 (if (and clipboard-text (> (length clipboard-text) 0))
1429 (kill-new clipboard-text))
1432 (declare-function accelerate-menu "xmenu.c" (&optional frame) t)
1434 (defun x-menu-bar-open (&optional frame)
1435 "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
1437 (if menu-bar-mode (accelerate-menu frame)
1441 ;;; Window system initialization.
1443 (defun x-win-suspend-error ()
1444 ;; Don't allow suspending if any of the frames are X frames.
1445 (if (memq 'x (mapcar 'window-system (frame-list)))
1446 (error "Cannot suspend Emacs while running under X")))
1448 (defvar x-initialized nil
1449 "Non-nil if the X window system has been initialized.")
1451 (declare-function x-open-connection "xfns.c"
1452 (display &optional xrm-string must-succeed))
1453 (declare-function x-server-max-request-size "xfns.c" (&optional terminal))
1454 (declare-function x-get-resource "frame.c"
1455 (attribute class &optional component subclass))
1456 (declare-function x-parse-geometry "frame.c" (string))
1457 (defvar x-resource-name)
1458 (defvar x-display-name)
1459 (defvar x-command-line-resources)
1461 (defun x-initialize-window-system ()
1462 "Initialize Emacs for X frames and open the first connection to an X server."
1463 ;; Make sure we have a valid resource name.
1464 (or (stringp x-resource-name)
1466 (setq x-resource-name (invocation-name))
1468 ;; Change any . or * characters in x-resource-name to hyphens,
1469 ;; so as not to choke when we use it in X resource queries.
1470 (while (setq i (string-match "[.*]" x-resource-name))
1471 (aset x-resource-name i ?-))))
1473 (x-open-connection (or x-display-name
1474 (setq x-display-name (or (getenv "DISPLAY" (selected-frame))
1475 (getenv "DISPLAY"))))
1476 x-command-line-resources
1477 ;; Exit Emacs with fatal error if this fails and we
1478 ;; are the initial display.
1479 (eq initial-window-system 'x))
1481 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
1484 ;; Setup the default fontset.
1485 (setup-default-fontset)
1487 ;; Create the standard fontset.
1488 (create-fontset-from-fontset-spec standard-fontset-spec t)
1490 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
1491 (create-fontset-from-x-resource)
1493 ;; Set scroll bar mode to right if set by X resources. Default is left.
1494 (if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
1495 (customize-set-variable 'scroll-bar-mode 'right))
1497 ;; Apply a geometry resource to the initial frame. Put it at the end
1498 ;; of the alist, so that anything specified on the command line takes
1500 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1504 (setq parsed (x-parse-geometry res-geometry))
1505 ;; If the resource specifies a position,
1506 ;; call the position and size "user-specified".
1507 (if (or (assq 'top parsed) (assq 'left parsed))
1508 (setq parsed (cons '(user-position . t)
1509 (cons '(user-size . t) parsed))))
1510 ;; All geometry parms apply to the initial frame.
1511 (setq initial-frame-alist (append initial-frame-alist parsed))
1512 ;; The size parms apply to all frames. Don't set it if there are
1513 ;; sizes there already (from command line).
1514 (if (and (assq 'height parsed)
1515 (not (assq 'height default-frame-alist)))
1516 (setq default-frame-alist
1517 (cons (cons 'height (cdr (assq 'height parsed)))
1518 default-frame-alist)))
1519 (if (and (assq 'width parsed)
1520 (not (assq 'width default-frame-alist)))
1521 (setq default-frame-alist
1522 (cons (cons 'width (cdr (assq 'width parsed)))
1523 default-frame-alist))))))
1525 ;; Check the reverseVideo resource.
1526 (let ((case-fold-search t))
1527 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1529 (string-match "^\\(true\\|yes\\|on\\)$" rv))
1530 (setq default-frame-alist
1531 (cons '(reverse . t) default-frame-alist)))))
1533 ;; Set x-selection-timeout, measured in milliseconds.
1534 (let ((res-selection-timeout
1535 (x-get-resource "selectionTimeout" "SelectionTimeout")))
1536 (setq x-selection-timeout 20000)
1537 (if res-selection-timeout
1538 (setq x-selection-timeout (string-to-number res-selection-timeout))))
1540 ;; Don't let Emacs suspend under X.
1541 (add-hook 'suspend-hook 'x-win-suspend-error)
1543 ;; During initialization, we defer sending size hints to the window
1544 ;; manager, because that can induce a race condition:
1545 ;; http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00033.html
1546 ;; Send the size hints once initialization is done.
1547 (add-hook 'after-init-hook 'x-wm-set-size-hint)
1549 ;; Turn off window-splitting optimization; X is usually fast enough
1550 ;; that this is only annoying.
1551 (setq split-window-keep-point t)
1553 ;; Motif direct handling of f10 wasn't working right,
1554 ;; So temporarily we've turned it off in lwlib-Xm.c
1555 ;; and turned the Emacs f10 back on.
1556 ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
1557 ;; (if (featurep 'motif)
1558 ;; (global-set-key [f10] 'ignore))
1560 ;; Turn on support for mouse wheels.
1561 (mouse-wheel-mode 1)
1563 ;; Enable CLIPBOARD copy/paste through menu bar commands.
1564 (menu-bar-enable-clipboard)
1566 ;; Override Paste so it looks at CLIPBOARD first.
1567 (define-key menu-bar-edit-menu [paste]
1568 (append '(menu-item "Paste" x-clipboard-yank
1569 :enable (not buffer-read-only)
1570 :help "Paste (yank) text most recently cut/copied")
1573 (setq x-initialized t))
1575 (add-to-list 'handle-args-function-alist '(x . x-handle-args))
1576 (add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
1577 (add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
1579 ;; Initiate drag and drop
1580 (add-hook 'after-make-frame-functions 'x-dnd-init-frame)
1581 (define-key special-event-map [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
1583 (defcustom x-gtk-stock-map
1585 ("etc/images/new" . "gtk-new")
1586 ("etc/images/open" . "gtk-open")
1587 ("etc/images/diropen" . "n:system-file-manager")
1588 ("etc/images/close" . "gtk-close")
1589 ("etc/images/save" . "gtk-save")
1590 ("etc/images/saveas" . "gtk-save-as")
1591 ("etc/images/undo" . "gtk-undo")
1592 ("etc/images/cut" . "gtk-cut")
1593 ("etc/images/copy" . "gtk-copy")
1594 ("etc/images/paste" . "gtk-paste")
1595 ("etc/images/search" . "gtk-find")
1596 ("etc/images/print" . "gtk-print")
1597 ("etc/images/preferences" . "gtk-preferences")
1598 ("etc/images/help" . "gtk-help")
1599 ("etc/images/left-arrow" . "gtk-go-back")
1600 ("etc/images/right-arrow" . "gtk-go-forward")
1601 ("etc/images/home" . "gtk-home")
1602 ("etc/images/jump-to" . "gtk-jump-to")
1603 ("etc/images/index" . "gtk-index")
1604 ("etc/images/search" . "gtk-find")
1605 ("etc/images/exit" . "gtk-quit")
1606 ("etc/images/cancel" . "gtk-cancel")
1607 ("etc/images/info" . "gtk-info")
1608 ("etc/images/bookmark_add" . "n:bookmark_add")
1609 ;; Used in Gnus and/or MH-E:
1610 ("etc/images/attach" . "gtk-attach")
1611 ("etc/images/connect" . "gtk-connect")
1612 ("etc/images/contact" . "gtk-contact")
1613 ("etc/images/delete" . "gtk-delete")
1614 ("etc/images/describe" . "gtk-properties")
1615 ("etc/images/disconnect" . "gtk-disconnect")
1616 ;; ("etc/images/exit" . "gtk-exit")
1617 ("etc/images/lock-broken" . "gtk-lock_broken")
1618 ("etc/images/lock-ok" . "gtk-lock_ok")
1619 ("etc/images/lock" . "gtk-lock")
1620 ("etc/images/next-page" . "gtk-next-page")
1621 ("etc/images/refresh" . "gtk-refresh")
1622 ("etc/images/sort-ascending" . "gtk-sort-ascending")
1623 ("etc/images/sort-column-ascending" . "gtk-sort-column-ascending")
1624 ("etc/images/sort-criteria" . "gtk-sort-criteria")
1625 ("etc/images/sort-descending" . "gtk-sort-descending")
1626 ("etc/images/sort-row-ascending" . "gtk-sort-row-ascending")
1627 ("images/gnus/toggle-subscription" . "gtk-task-recurring")
1628 ("images/mail/compose" . "gtk-mail-compose")
1629 ("images/mail/copy" . "gtk-mail-copy")
1630 ("images/mail/forward" . "gtk-mail-forward")
1631 ("images/mail/inbox" . "gtk-inbox")
1632 ("images/mail/move" . "gtk-mail-move")
1633 ("images/mail/not-spam" . "gtk-not-spam")
1634 ("images/mail/outbox" . "gtk-outbox")
1635 ("images/mail/reply-all" . "gtk-mail-reply-to-all")
1636 ("images/mail/reply" . "gtk-mail-reply")
1637 ("images/mail/save-draft" . "gtk-mail-handling")
1638 ("images/mail/send" . "gtk-mail-send")
1639 ("images/mail/spam" . "gtk-spam")
1640 ;; No themed versions available:
1641 ;; mail/preview (combining stock_mail and stock_zoom)
1642 ;; mail/save (combining stock_mail, stock_save and stock_convert)
1644 "How icons for tool bars are mapped to Gtk+ stock items.
1645 Emacs must be compiled with the Gtk+ toolkit for this to have any effect.
1646 A value that begins with n: denotes a named icon instead of a stock icon."
1648 :type '(choice (repeat (choice symbol
1649 (cons (string :tag "Emacs icon")
1650 (string :tag "Stock/named")))))
1653 (defcustom icon-map-list '(x-gtk-stock-map)
1654 "A list of alists that maps icon file names to stock/named icons.
1655 The alists are searched in the order they appear. The first match is used.
1656 The keys in the alists are file names without extension and with two directory
1657 components. For example, to map /usr/share/emacs/22.1.1/etc/images/open.xpm
1658 to stock item gtk-open, use:
1660 (\"etc/images/open\" . \"gtk-open\")
1662 Themes also have named icons. To map to one of those, use n: before the name:
1664 (\"etc/images/diropen\" . \"n:system-file-manager\")
1666 The list elements are either the symbol name for the alist or the
1669 If you don't want stock icons, set the variable to nil."
1671 :type '(choice (const :tag "Don't use stock icons" nil)
1672 (repeat (choice symbol
1673 (cons (string :tag "Emacs icon")
1674 (string :tag "Stock/named")))))
1677 (defconst x-gtk-stock-cache (make-hash-table :weakness t :test 'equal))
1679 (defun x-gtk-map-stock (file)
1680 "Map icon with file name FILE to a Gtk+ stock name.
1681 This uses `icon-map-list' to map icon file names to stock icon names."
1682 (when (stringp file)
1683 (or (gethash file x-gtk-stock-cache)
1687 (let* ((file-sans (file-name-sans-extension file))
1688 (key (and (string-match "/\\([^/]+/[^/]+/[^/]+$\\)"
1690 (match-string 1 file-sans)))
1691 (icon-map icon-map-list)
1693 (while (and (null value) icon-map)
1694 (setq elem (car icon-map)
1695 value (assoc-string (or key file-sans)
1699 icon-map (cdr icon-map)))
1700 (and value (cdr value))))
1701 x-gtk-stock-cache))))
1705 ;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
1706 ;;; x-win.el ends here