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)
256 (defun xw-defined-colors (&optional frame
)
257 "Internal function called by `defined-colors', which see."
258 (or frame
(setq frame
(selected-frame)))
259 (let ((all-colors x-colors
)
261 (defined-colors nil
))
263 (setq this-color
(car all-colors
)
264 all-colors
(cdr all-colors
))
265 (and (color-supported-p this-color frame t
)
266 (setq defined-colors
(cons this-color defined-colors
))))
271 (defvar x-alternatives-map
272 (let ((map (make-sparse-keymap)))
273 ;; Map certain keypad keys into ASCII characters that people usually expect.
274 (define-key map
[backspace] [127])
275 (define-key map [delete] [127])
276 (define-key map [tab] [?\t])
277 (define-key map [linefeed] [?\n])
278 (define-key map [clear] [?\C-l])
279 (define-key map [return] [?\C-m])
280 (define-key map [escape] [?\e])
281 (define-key map [M-backspace] [?\M-\d])
282 (define-key map [M-delete] [?\M-\d])
283 (define-key map [M-tab] [?\M-\t])
284 (define-key map [M-linefeed] [?\M-\n])
285 (define-key map [M-clear] [?\M-\C-l])
286 (define-key map [M-return] [?\M-\C-m])
287 (define-key map [M-escape] [?\M-\e])
288 (define-key map [iso-lefttab] [backtab])
289 (define-key map [S-iso-lefttab] [backtab])
291 "Keymap of possible alternative meanings for some keys.")
293 (defun x-setup-function-keys (frame)
294 "Set up `function-key-map' on FRAME for the X window system."
295 ;; Don't do this twice on the same display, or it would break
296 ;; normal-erase-is-backspace-mode.
297 (unless (terminal-parameter frame 'x-setup-function-keys)
298 ;; Map certain keypad keys into ASCII characters that people usually expect.
299 (with-selected-frame frame
300 (let ((map (copy-keymap x-alternatives-map)))
301 (set-keymap-parent map (keymap-parent local-function-key-map))
302 (set-keymap-parent local-function-key-map map)))
303 (set-terminal-parameter frame 'x-setup-function-keys t)))
305 ;; These tell read-char how to convert
306 ;; these special chars to ASCII.
307 (put 'backspace 'ascii-character 127)
308 (put 'delete 'ascii-character 127)
309 (put 'tab 'ascii-character ?\t)
310 (put 'linefeed 'ascii-character ?\n)
311 (put 'clear 'ascii-character 12)
312 (put 'return 'ascii-character 13)
313 (put 'escape 'ascii-character ?\e)
318 (defun vendor-specific-keysyms (vendor)
319 "Return the appropriate value of `system-key-alist' for VENDOR.
320 VENDOR is a string containing the name of the X Server's vendor,
321 as returned by `x-server-vendor'."
322 (cond ((or (string-equal vendor "Hewlett-Packard Incorporated")
323 (string-equal vendor "Hewlett-Packard Company"))
324 '(( 168 . mute-acute)
326 ( 170 . mute-asciicircum)
327 ( 171 . mute-diaeresis)
328 ( 172 . mute-asciitilde)
342 (65397 . kp-backtab)))
343 ;; Fixme: What about non-X11/NeWS sun server?
344 ((or (string-equal vendor "X11/NeWS - Sun Microsystems Inc.")
345 (string-equal vendor "X Consortium"))
349 ;; These are for Sun under X11R6
357 ;; This is used by DEC's X server.
358 '((65280 . remove)))))
363 (puthash i i x-keysym-table)
366 ;; Table from Kuhn's proposed additions to the `KEYSYM Encoding'
367 ;; appendix to the X protocol definition.
428 (#x1ff . ?\e,B\7f\e(B)
488 ;; Kana: Fixme: needs conversion to Japanese charset -- seems
489 ;; to require jisx0213, for which the Unicode translation
492 (#x4a1 . ?\e$A!#\e(B)
493 (#x4a2 . ?\\e$A!8\e(B)
494 (#x4a3 . ?\\e$A!9\e(B)
495 (#x4a4 . ?\e$A!"\e(B)
496 (#x4a5 . ?\e$A!$\e(B)
497 (#x4a6 . ?\e$A%r\e(B)
498 (#x4a7 . ?\e$A%!\e(B)
499 (#x4a8 . ?\e$A%#\e(B)
500 (#x4a9 . ?\e$A%%\e(B)
501 (#x4aa . ?\e$A%'\e(B)
502 (#x4ab . ?\e$A%)\e(B)
503 (#x4ac . ?\e$A%c\e(B)
504 (#x4ad . ?\e$A%e\e(B)
505 (#x4ae . ?\e$A%g\e(B)
506 (#x4af . ?\e$A%C\e(B)
507 (#x4b0 . ?\e$B!<\e(B)
508 (#x4b1 . ?\e$A%"\e(B)
509 (#x4b2 . ?\e$A%$\e(B)
510 (#x4b3 . ?\e$A%&\e(B)
511 (#x4b4 . ?\e$A%(\e(B)
512 (#x4b5 . ?\e$A%*\e(B)
513 (#x4b6 . ?\e$A%+\e(B)
514 (#x4b7 . ?\e$A%-\e(B)
515 (#x4b8 . ?\e$A%/\e(B)
516 (#x4b9 . ?\e$A%1\e(B)
517 (#x4ba . ?\e$A%3\e(B)
518 (#x4bb . ?\e$A%5\e(B)
519 (#x4bc . ?\e$A%7\e(B)
520 (#x4bd . ?\e$A%9\e(B)
521 (#x4be . ?\e$A%;\e(B)
522 (#x4bf . ?\e$A%=\e(B)
523 (#x4c0 . ?\e$A%?\e(B)
524 (#x4c1 . ?\e$A%A\e(B)
525 (#x4c2 . ?\e$A%D\e(B)
526 (#x4c3 . ?\e$A%F\e(B)
527 (#x4c4 . ?\e$A%H\e(B)
528 (#x4c5 . ?\e$A%J\e(B)
529 (#x4c6 . ?\e$A%K\e(B)
530 (#x4c7 . ?\e$A%L\e(B)
531 (#x4c8 . ?\e$A%M\e(B)
532 (#x4c9 . ?\e$A%N\e(B)
533 (#x4ca . ?\e$A%O\e(B)
534 (#x4cb . ?\e$A%R\e(B)
535 (#x4cc . ?\e$A%U\e(B)
536 (#x4cd . ?\e$A%X\e(B)
537 (#x4ce . ?\e$A%[\e(B)
538 (#x4cf . ?\e$A%^\e(B)
539 (#x4d0 . ?\e$A%_\e(B)
540 (#x4d1 . ?\e$A%`\e(B)
541 (#x4d2 . ?\e$A%a\e(B)
542 (#x4d3 . ?\e$A%b\e(B)
543 (#x4d4 . ?\e$A%d\e(B)
544 (#x4d5 . ?\e$A%f\e(B)
545 (#x4d6 . ?\e$A%h\e(B)
546 (#x4d7 . ?\e$A%i\e(B)
547 (#x4d8 . ?\e$A%j\e(B)
548 (#x4d9 . ?\e$A%k\e(B)
549 (#x4da . ?\e$A%l\e(B)
550 (#x4db . ?\e$A%m\e(B)
551 (#x4dc . ?\e$A%o\e(B)
552 (#x4dd . ?\e$A%s\e(B)
553 (#x4de . ?\e$B!+\e(B)
554 (#x4df . ?\e$B!,\e(B)
605 (#x680 . ?\e$,1)R\e(B)
606 (#x681 . ?\e$,1)V\e(B)
607 (#x682 . ?\e$,1)Z\e(B)
608 (#x683 . ?\e$,1)\\e(B)
609 (#x684 . ?\e$,1)b\e(B)
610 (#x685 . ?\e$,1)n\e(B)
611 (#x686 . ?\e$,1)p\e(B)
612 (#x687 . ?\e$,1)r\e(B)
613 (#x688 . ?\e$,1)v\e(B)
614 (#x689 . ?\e$,1)x\e(B)
615 (#x68a . ?\e$,1)z\e(B)
616 (#x68c . ?\e$,1*8\e(B)
617 (#x68d . ?\e$,1*B\e(B)
618 (#x68e . ?\e$,1*H\e(B)
619 (#x68f . ?\e$,1*N\e(B)
620 (#x690 . ?\e$,1)S\e(B)
621 (#x691 . ?\e$,1)W\e(B)
622 (#x692 . ?\e$,1)[\e(B)
623 (#x693 . ?\e$,1)]\e(B)
624 (#x694 . ?\e$,1)c\e(B)
625 (#x695 . ?\e$,1)o\e(B)
626 (#x696 . ?\e$,1)q\e(B)
627 (#x697 . ?\e$,1)s\e(B)
628 (#x698 . ?\e$,1)w\e(B)
629 (#x699 . ?\e$,1)y\e(B)
630 (#x69a . ?\e$,1){\e(B)
631 (#x69c . ?\e$,1*9\e(B)
632 (#x69d . ?\e$,1*C\e(B)
633 (#x69e . ?\e$,1*I\e(B)
634 (#x69f . ?\e$,1*O\e(B)
648 (#x6af . ?\e,L\7f\e(B)
801 (#x8a1 . ?\e$,1|W\e(B)
802 (#x8a2 . ?\e$A)0\e(B)
803 (#x8a3 . ?\e$A)$\e(B)
804 (#x8a4 . ?\e$,1{ \e(B)
805 (#x8a5 . ?\e$,1{!\e(B)
806 (#x8a6 . ?\e$A)&\e(B)
807 (#x8a7 . ?\e$,1|A\e(B)
808 (#x8a8 . ?\e$,1|C\e(B)
809 (#x8a9 . ?\e$,1|D\e(B)
810 (#x8aa . ?\e$,1|F\e(B)
811 (#x8ab . ?\e$,1|;\e(B)
812 (#x8ac . ?\e$,1|=\e(B)
813 (#x8ad . ?\e$,1|>\e(B)
814 (#x8ae . ?\e$,1|@\e(B)
815 (#x8af . ?\e$,1|H\e(B)
816 (#x8b0 . ?\e$,1|L\e(B)
817 (#x8bc . ?\e$A!\\e(B)
818 (#x8bd . ?\e$A!Y\e(B)
819 (#x8be . ?\e$A!]\e(B)
820 (#x8bf . ?\e$A!R\e(B)
821 (#x8c0 . ?\e$A!`\e(B)
822 (#x8c1 . ?\e$A!X\e(B)
823 (#x8c2 . ?\e$A!^\e(B)
824 (#x8c5 . ?\e$B"`\e(B)
825 (#x8c8 . ?\e$(G"D\e(B)
826 (#x8c9 . ?\e$(O"l\e(B)
827 (#x8cd . ?\e$B"N\e(B)
828 (#x8ce . ?\e$B"M\e(B)
829 (#x8cf . ?\e$A!T\e(B)
830 (#x8d6 . ?\e$A!L\e(B)
831 (#x8da . ?\e$B">\e(B)
832 (#x8db . ?\e$B"?\e(B)
833 (#x8dc . ?\e$A!I\e(B)
834 (#x8dd . ?\e$A!H\e(B)
835 (#x8de . ?\e$A!D\e(B)
836 (#x8df . ?\e$A!E\e(B)
837 (#x8ef . ?\e$B"_\e(B)
838 (#x8f6 . ?\e$,1!R\e(B)
839 (#x8fb . ?\e$A!{\e(B)
840 (#x8fc . ?\e$A!|\e(B)
841 (#x8fd . ?\e$A!z\e(B)
842 (#x8fe . ?\e$A!}\e(B)
844 (#x9e0 . ?\e$A!t\e(B)
845 (#x9e1 . ?\e$(C"F\e(B)
846 (#x9e2 . ?\e$(GB*\e(B)
847 (#x9e3 . ?\e$(GB-\e(B)
848 (#x9e4 . ?\e$(GB.\e(B)
849 (#x9e5 . ?\e$(GB+\e(B)
850 (#x9e8 . ?\e$,1}d\e(B)
851 (#x9e9 . ?\e$(GB,\e(B)
852 (#x9ea . ?\e$A)<\e(B)
853 (#x9eb . ?\e$A)4\e(B)
854 (#x9ec . ?\e$A)0\e(B)
855 (#x9ed . ?\e$A)8\e(B)
856 (#x9ee . ?\e$A)`\e(B)
857 (#x9ef . ?\e$,1|Z\e(B)
858 (#x9f0 . ?\e$,1|[\e(B)
859 (#x9f1 . ?\e$A)$\e(B)
860 (#x9f2 . ?\e$,1|\\e(B)
861 (#x9f3 . ?\e$,1|]\e(B)
862 (#x9f4 . ?\e$A)@\e(B)
863 (#x9f5 . ?\e$A)H\e(B)
864 (#x9f6 . ?\e$A)X\e(B)
865 (#x9f7 . ?\e$A)P\e(B)
866 (#x9f8 . ?\e$A)&\e(B)
868 (#xaa1 . ?\e$,1rc\e(B)
869 (#xaa2 . ?\e$,1rb\e(B)
870 (#xaa3 . ?\e$,1rd\e(B)
871 (#xaa4 . ?\e$,1re\e(B)
872 (#xaa5 . ?\e$,1rg\e(B)
873 (#xaa6 . ?\e$,1rh\e(B)
874 (#xaa7 . ?\e$,1ri\e(B)
875 (#xaa8 . ?\e$,1rj\e(B)
876 (#xaa9 . ?\e$(G!7\e(B)
877 (#xaaa . ?\e$(G!9\e(B)
878 (#xaae . ?\e$A!-\e(B)
879 (#xaaf . ?\e$(G!-\e(B)
880 (#xab0 . ?\e$(O'x\e(B)
881 (#xab1 . ?\e$(O'y\e(B)
882 (#xab2 . ?\e$(O'z\e(B)
883 (#xab3 . ?\e$,1v6\e(B)
884 (#xab4 . ?\e$,1v7\e(B)
885 (#xab5 . ?\e$,1v8\e(B)
886 (#xab6 . ?\e$,1v9\e(B)
887 (#xab7 . ?\e$,1v:\e(B)
888 (#xab8 . ?\e$(G""\e(B)
889 (#xabb . ?\e$,1rr\e(B)
890 (#xabc . ?\e$,1{)\e(B)
891 (#xabe . ?\e$,1{*\e(B)
892 (#xac3 . ?\e$(C({\e(B)
893 (#xac4 . ?\e$(C(|\e(B)
894 (#xac5 . ?\e$(C(}\e(B)
895 (#xac6 . ?\e$(C(~\e(B)
896 (#xac9 . ?\e$(D"o\e(B)
897 (#xaca . ?\e$,2"s\e(B)
898 (#xacc . ?\e$(O##\e(B)
899 (#xacd . ?\e$(O#!\e(B)
900 (#xace . ?\e$A!p\e(B)
901 (#xacf . ?\e$,2!o\e(B)
906 (#xad4 . ?\e$,1u^\e(B)
907 (#xad6 . ?\e$A!d\e(B)
908 (#xad7 . ?\e$A!e\e(B)
909 (#xad9 . ?\e$,2%]\e(B)
910 (#xadb . ?\e$,2!l\e(B)
911 (#xadc . ?\e$(O#$\e(B)
912 (#xadd . ?\e$(O#"\e(B)
913 (#xade . ?\e$A!q\e(B)
914 (#xadf . ?\e$,2!n\e(B)
915 (#xae0 . ?\e$(O#?\e(B)
916 (#xae1 . ?\e$,2!k\e(B)
917 (#xae2 . ?\e$,2!m\e(B)
918 (#xae3 . ?\e$A!w\e(B)
919 (#xae4 . ?\e$(G!}\e(B)
920 (#xae5 . ?\e$A!n\e(B)
921 (#xae6 . ?\e$(O#@\e(B)
922 (#xae7 . ?\e$,2!j\e(B)
923 (#xae8 . ?\e$A!x\e(B)
924 (#xae9 . ?\e$(G!~\e(B)
925 (#xaea . ?\e$(C"P\e(B)
926 (#xaeb . ?\e$(O-~\e(B)
927 (#xaec . ?\e$(O&@\e(B)
928 (#xaed . ?\e$(O&<\e(B)
929 (#xaee . ?\e$(O&>\e(B)
930 (#xaf0 . ?\e$,2%`\e(B)
931 (#xaf1 . ?\e$B"w\e(B)
932 (#xaf2 . ?\e$B"x\e(B)
933 (#xaf3 . ?\e$(O'{\e(B)
934 (#xaf4 . ?\e$,2%W\e(B)
935 (#xaf5 . ?\e$B"t\e(B)
936 (#xaf6 . ?\e$B"u\e(B)
937 (#xaf7 . ?\e$A!a\e(B)
938 (#xaf8 . ?\e$A!b\e(B)
939 (#xaf9 . ?\e$(O&g\e(B)
940 (#xafa . ?\e$,1zu\e(B)
941 (#xafb . ?\e$,1uW\e(B)
942 (#xafc . ?\e$,1s8\e(B)
943 (#xafd . ?\e$,1rz\e(B)
948 (#xba8 . ?\e$A!E\e(B)
949 (#xba9 . ?\e$A!D\e(B)
951 (#xbc2 . ?\e$A!M\e(B)
952 (#xbc3 . ?\e$A!I\e(B)
953 (#xbc4 . ?\e$,1zj\e(B)
955 (#xbca . ?\e$,1x8\e(B)
956 (#xbcc . ?\e$,1|5\e(B)
957 (#xbce . ?\e$,1yd\e(B)
958 (#xbcf . ?\e$A!p\e(B)
959 (#xbd3 . ?\e$,1zh\e(B)
960 (#xbd6 . ?\e$A!H\e(B)
961 (#xbd8 . ?\e$B"?\e(B)
962 (#xbda . ?\e$B">\e(B)
963 (#xbdc . ?\e$,1yb\e(B)
964 (#xbfc . ?\e$,1yc\e(B)
1000 (#xda6 . ?\e,T&\e(B)
1001 (#xda7 . ?\e,T'\e(B)
1002 (#xda8 . ?\e,T(\e(B)
1003 (#xda9 . ?\e,T)\e(B)
1004 (#xdaa . ?\e,T*\e(B)
1005 (#xdab . ?\e,T+\e(B)
1006 (#xdac . ?\e,T,\e(B)
1007 (#xdad . ?\e,T-\e(B)
1008 (#xdae . ?\e,T.\e(B)
1009 (#xdaf . ?\e,T/\e(B)
1010 (#xdb0 . ?\e,T0\e(B)
1011 (#xdb1 . ?\e,T1\e(B)
1012 (#xdb2 . ?\e,T2\e(B)
1013 (#xdb3 . ?\e,T3\e(B)
1014 (#xdb4 . ?\e,T4\e(B)
1015 (#xdb5 . ?\e,T5\e(B)
1016 (#xdb6 . ?\e,T6\e(B)
1017 (#xdb7 . ?\e,T7\e(B)
1018 (#xdb8 . ?\e,T8\e(B)
1019 (#xdb9 . ?\e,T9\e(B)
1020 (#xdba . ?\e,T:\e(B)
1021 (#xdbb . ?\e,T;\e(B)
1022 (#xdbc . ?\e,T<\e(B)
1023 (#xdbd . ?\e,T=\e(B)
1024 (#xdbe . ?\e,T>\e(B)
1025 (#xdbf . ?\e,T?\e(B)
1026 (#xdc0 . ?\e,T@\e(B)
1027 (#xdc1 . ?\e,TA\e(B)
1028 (#xdc2 . ?\e,TB\e(B)
1029 (#xdc3 . ?\e,TC\e(B)
1030 (#xdc4 . ?\e,TD\e(B)
1031 (#xdc5 . ?\e,TE\e(B)
1032 (#xdc6 . ?\e,TF\e(B)
1033 (#xdc7 . ?\e,TG\e(B)
1034 (#xdc8 . ?\e,TH\e(B)
1035 (#xdc9 . ?\e,TI\e(B)
1036 (#xdca . ?\e,TJ\e(B)
1037 (#xdcb . ?\e,TK\e(B)
1038 (#xdcc . ?\e,TL\e(B)
1039 (#xdcd . ?\e,TM\e(B)
1040 (#xdce . ?\e,TN\e(B)
1041 (#xdcf . ?\e,TO\e(B)
1042 (#xdd0 . ?\e,TP\e(B)
1043 (#xdd1 . ?\e,TQ\e(B)
1044 (#xdd2 . ?\e,TR\e(B)
1045 (#xdd3 . ?\e,TS\e(B)
1046 (#xdd4 . ?\e,TT\e(B)
1047 (#xdd5 . ?\e,TU\e(B)
1048 (#xdd6 . ?\e,TV\e(B)
1049 (#xdd7 . ?\e,TW\e(B)
1050 (#xdd8 . ?\e,TX\e(B)
1051 (#xdd9 . ?\e,TY\e(B)
1052 (#xdda . ?\e,TZ\e(B)
1053 (#xddf . ?\e,T_\e(B)
1054 (#xde0 . ?\e,T`\e(B)
1055 (#xde1 . ?\e,Ta\e(B)
1056 (#xde2 . ?\e,Tb\e(B)
1057 (#xde3 . ?\e,Tc\e(B)
1058 (#xde4 . ?\e,Td\e(B)
1059 (#xde5 . ?\e,Te\e(B)
1060 (#xde6 . ?\e,Tf\e(B)
1061 (#xde7 . ?\e,Tg\e(B)
1062 (#xde8 . ?\e,Th\e(B)
1063 (#xde9 . ?\e,Ti\e(B)
1064 (#xdea . ?\e,Tj\e(B)
1065 (#xdeb . ?\e,Tk\e(B)
1066 (#xdec . ?\e,Tl\e(B)
1067 (#xded . ?\e,Tm\e(B)
1068 (#xdf0 . ?\e,Tp\e(B)
1069 (#xdf1 . ?\e,Tq\e(B)
1070 (#xdf2 . ?\e,Tr\e(B)
1071 (#xdf3 . ?\e,Ts\e(B)
1072 (#xdf4 . ?\e,Tt\e(B)
1073 (#xdf5 . ?\e,Tu\e(B)
1074 (#xdf6 . ?\e,Tv\e(B)
1075 (#xdf7 . ?\e,Tw\e(B)
1076 (#xdf8 . ?\e,Tx\e(B)
1077 (#xdf9 . ?\e,Ty\e(B)
1079 (#xea1 . ?\e$(C$!\e(B)
1080 (#xea2 . ?\e$(C$"\e(B)
1081 (#xea3 . ?\e$(C$#\e(B)
1082 (#xea4 . ?\e$(C$$\e(B)
1083 (#xea5 . ?\e$(C$%\e(B)
1084 (#xea6 . ?\e$(C$&\e(B)
1085 (#xea7 . ?\e$(C$'\e(B)
1086 (#xea8 . ?\e$(C$(\e(B)
1087 (#xea9 . ?\e$(C$)\e(B)
1088 (#xeaa . ?\e$(C$*\e(B)
1089 (#xeab . ?\e$(C$+\e(B)
1090 (#xeac . ?\e$(C$,\e(B)
1091 (#xead . ?\e$(C$-\e(B)
1092 (#xeae . ?\e$(C$.\e(B)
1093 (#xeaf . ?\e$(C$/\e(B)
1094 (#xeb0 . ?\e$(C$0\e(B)
1095 (#xeb1 . ?\e$(C$1\e(B)
1096 (#xeb2 . ?\e$(C$2\e(B)
1097 (#xeb3 . ?\e$(C$3\e(B)
1098 (#xeb4 . ?\e$(C$4\e(B)
1099 (#xeb5 . ?\e$(C$5\e(B)
1100 (#xeb6 . ?\e$(C$6\e(B)
1101 (#xeb7 . ?\e$(C$7\e(B)
1102 (#xeb8 . ?\e$(C$8\e(B)
1103 (#xeb9 . ?\e$(C$9\e(B)
1104 (#xeba . ?\e$(C$:\e(B)
1105 (#xebb . ?\e$(C$;\e(B)
1106 (#xebc . ?\e$(C$<\e(B)
1107 (#xebd . ?\e$(C$=\e(B)
1108 (#xebe . ?\e$(C$>\e(B)
1109 (#xebf . ?\e$(C$?\e(B)
1110 (#xec0 . ?\e$(C$@\e(B)
1111 (#xec1 . ?\e$(C$A\e(B)
1112 (#xec2 . ?\e$(C$B\e(B)
1113 (#xec3 . ?\e$(C$C\e(B)
1114 (#xec4 . ?\e$(C$D\e(B)
1115 (#xec5 . ?\e$(C$E\e(B)
1116 (#xec6 . ?\e$(C$F\e(B)
1117 (#xec7 . ?\e$(C$G\e(B)
1118 (#xec8 . ?\e$(C$H\e(B)
1119 (#xec9 . ?\e$(C$I\e(B)
1120 (#xeca . ?\e$(C$J\e(B)
1121 (#xecb . ?\e$(C$K\e(B)
1122 (#xecc . ?\e$(C$L\e(B)
1123 (#xecd . ?\e$(C$M\e(B)
1124 (#xece . ?\e$(C$N\e(B)
1125 (#xecf . ?\e$(C$O\e(B)
1126 (#xed0 . ?\e$(C$P\e(B)
1127 (#xed1 . ?\e$(C$Q\e(B)
1128 (#xed2 . ?\e$(C$R\e(B)
1129 (#xed3 . ?\e$(C$S\e(B)
1130 (#xed4 . ?\e$,1LH\e(B)
1131 (#xed5 . ?\e$,1LI\e(B)
1132 (#xed6 . ?\e$,1LJ\e(B)
1133 (#xed7 . ?\e$,1LK\e(B)
1134 (#xed8 . ?\e$,1LL\e(B)
1135 (#xed9 . ?\e$,1LM\e(B)
1136 (#xeda . ?\e$,1LN\e(B)
1137 (#xedb . ?\e$,1LO\e(B)
1138 (#xedc . ?\e$,1LP\e(B)
1139 (#xedd . ?\e$,1LQ\e(B)
1140 (#xede . ?\e$,1LR\e(B)
1141 (#xedf . ?\e$,1LS\e(B)
1142 (#xee0 . ?\e$,1LT\e(B)
1143 (#xee1 . ?\e$,1LU\e(B)
1144 (#xee2 . ?\e$,1LV\e(B)
1145 (#xee3 . ?\e$,1LW\e(B)
1146 (#xee4 . ?\e$,1LX\e(B)
1147 (#xee5 . ?\e$,1LY\e(B)
1148 (#xee6 . ?\e$,1LZ\e(B)
1149 (#xee7 . ?\e$,1L[\e(B)
1150 (#xee8 . ?\e$,1L\\e(B)
1151 (#xee9 . ?\e$,1L]\e(B)
1152 (#xeea . ?\e$,1L^\e(B)
1153 (#xeeb . ?\e$,1L_\e(B)
1154 (#xeec . ?\e$,1L`\e(B)
1155 (#xeed . ?\e$,1La\e(B)
1156 (#xeee . ?\e$,1Lb\e(B)
1157 (#xeef . ?\e$(C$]\e(B)
1158 (#xef0 . ?\e$(C$a\e(B)
1159 (#xef1 . ?\e$(C$h\e(B)
1160 (#xef2 . ?\e$(C$o\e(B)
1161 (#xef3 . ?\e$(C$q\e(B)
1162 (#xef4 . ?\e$(C$t\e(B)
1163 (#xef5 . ?\e$(C$v\e(B)
1164 (#xef6 . ?\e$(C$}\e(B)
1165 (#xef7 . ?\e$(C$~\e(B)
1166 (#xef8 . ?\e$,1M+\e(B)
1167 (#xef9 . ?\e$,1M0\e(B)
1168 (#xefa . ?\e$,1M9\e(B)
1169 (#xeff . ?\e$,1tI\e(B)
1175 (#x13bc . ?\e,b<\e(B)
1176 (#x13bd . ?\e,b=\e(B)
1177 (#x13be . ?\e,_/\e(B)
1179 (#x20a0 . ?\e$,1t@\e(B)
1180 (#x20a1 . ?\e$,1tA\e(B)
1181 (#x20a2 . ?\e$,1tB\e(B)
1182 (#x20a3 . ?\e$,1tC\e(B)
1183 (#x20a4 . ?\e$,1tD\e(B)
1184 (#x20a5 . ?\e$,1tE\e(B)
1185 (#x20a6 . ?\e$,1tF\e(B)
1186 (#x20a7 . ?\e$,1tG\e(B)
1187 (#x20a8 . ?\e$,1tH\e(B)
1188 (#x20aa . ?\e$,1tJ\e(B)
1189 (#x20ab . ?\e$,1tK\e(B)
1190 (#x20ac . ?\e,b$\e(B)))
1191 (puthash (car pair) (cdr pair) x-keysym-table))
1193 ;; The following keysym codes for graphics are listed in the document
1194 ;; as not having unicodes available:
1196 ;; #x08b1 TOP LEFT SUMMATION Technical
1197 ;; #x08b2 BOTTOM LEFT SUMMATION Technical
1198 ;; #x08b3 TOP VERTICAL SUMMATION CONNECTOR Technical
1199 ;; #x08b4 BOTTOM VERTICAL SUMMATION CONNECTOR Technical
1200 ;; #x08b5 TOP RIGHT SUMMATION Technical
1201 ;; #x08b6 BOTTOM RIGHT SUMMATION Technical
1202 ;; #x08b7 RIGHT MIDDLE SUMMATION Technical
1203 ;; #x0aac SIGNIFICANT BLANK SYMBOL Publish
1204 ;; #x0abd DECIMAL POINT Publish
1205 ;; #x0abf MARKER Publish
1206 ;; #x0acb TRADEMARK SIGN IN CIRCLE Publish
1207 ;; #x0ada HEXAGRAM Publish
1208 ;; #x0aff CURSOR Publish
1209 ;; #x0dde THAI MAIHANAKAT Thai
1212 ;;;; Selections and cut buffers
1214 ;; We keep track of the last text selected here, so we can check the
1215 ;; current selection against it, and avoid passing back our own text
1216 ;; from x-cut-buffer-or-selection-value. We track all three
1217 ;; seperately in case another X application only sets one of them
1218 ;; (say the cut buffer) we aren't fooled by the PRIMARY or
1219 ;; CLIPBOARD selection staying the same.
1220 (defvar x-last-selected-text-clipboard nil
1221 "The value of the CLIPBOARD X selection last time we selected or
1223 (defvar x-last-selected-text-primary nil
1224 "The value of the PRIMARY X selection last time we selected or
1226 (defvar x-last-selected-text-cut nil
1227 "The value of the X cut buffer last time we selected or pasted text.
1228 The actual text stored in the X cut buffer is what encoded from this value.")
1229 (defvar x-last-selected-text-cut-encoded nil
1230 "The value of the X cut buffer last time we selected or pasted text.
1231 This is the actual text stored in the X cut buffer.")
1232 (defvar x-last-cut-buffer-coding 'iso-latin-1
1233 "The coding we last used to encode/decode the text from the X cut buffer")
1235 (defvar x-cut-buffer-max 20000 ; Note this value is overridden below.
1236 "Max number of characters to put in the cut buffer.
1237 It is said that overlarge strings are slow to put into the cut buffer.")
1239 (defcustom x-select-enable-clipboard nil
1240 "Non-nil means cutting and pasting uses the clipboard.
1241 This is in addition to, but in preference to, the primary selection."
1245 (defcustom x-select-enable-primary t
1246 "Non-nil means cutting and pasting uses the primary selection."
1250 (defun x-select-text (text &optional push)
1251 "Make TEXT, a string, the primary X selection.
1252 Also, set the value of X cut buffer 0, for backward compatibility
1253 with older X applications.
1254 gildea@stop.mail-abuse.org says it's not desirable to put kills
1256 ;; With multi-tty, this function may be called from a tty frame.
1257 (when (eq (framep (selected-frame)) 'x)
1258 ;; Don't send the cut buffer too much text.
1259 ;; It becomes slow, and if really big it causes errors.
1260 (cond ((>= (length text) x-cut-buffer-max)
1261 (x-set-cut-buffer "" push)
1262 (setq x-last-selected-text-cut ""
1263 x-last-selected-text-cut-encoded ""))
1265 (setq x-last-selected-text-cut text
1266 x-last-cut-buffer-coding 'iso-latin-1
1267 x-last-selected-text-cut-encoded
1268 ;; ICCCM says cut buffer always contain ISO-Latin-1
1269 (encode-coding-string text 'iso-latin-1))
1270 (x-set-cut-buffer x-last-selected-text-cut-encoded push)))
1271 (when x-select-enable-primary
1272 (x-set-selection 'PRIMARY text)
1273 (setq x-last-selected-text-primary text))
1274 (when x-select-enable-clipboard
1275 (x-set-selection 'CLIPBOARD text)
1276 (setq x-last-selected-text-clipboard text))))
1278 (defvar x-select-request-type nil
1279 "*Data type request for X selection.
1280 The value is one of the following data types, a list of them, or nil:
1281 `COMPOUND_TEXT', `UTF8_STRING', `STRING', `TEXT'
1283 If the value is one of the above symbols, try only the specified
1286 If the value is a list of them, try each of them in the specified
1287 order until succeed.
1289 The value nil is the same as this list:
1290 \(UTF8_STRING COMPOUND_TEXT STRING)
1293 ;; Get a selection value of type TYPE by calling x-get-selection with
1294 ;; an appropiate DATA-TYPE argument decided by `x-select-request-type'.
1295 ;; The return value is already decoded. If x-get-selection causes an
1296 ;; error, this function return nil.
1298 (defun x-selection-value (type)
1299 (let ((request-type (or x-select-request-type
1300 '(UTF8_STRING COMPOUND_TEXT STRING)))
1302 (if (consp request-type)
1303 (while (and request-type (not text))
1305 (setq text (x-get-selection type (car request-type)))
1307 (setq request-type (cdr request-type)))
1309 (setq text (x-get-selection type request-type))
1312 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
1315 ;; Return the value of the current X selection.
1316 ;; Consult the selection, and the cut buffer. Treat empty strings
1317 ;; as if they were unset.
1318 ;; If this function is called twice and finds the same text,
1319 ;; it returns nil the second time. This is so that a single
1320 ;; selection won't be added to the kill ring over and over.
1321 (defun x-cut-buffer-or-selection-value ()
1322 ;; With multi-tty, this function may be called from a tty frame.
1323 (when (eq (framep (selected-frame)) 'x)
1324 (let (clip-text primary-text cut-text)
1325 (when x-select-enable-clipboard
1326 (setq clip-text (x-selection-value 'CLIPBOARD))
1327 (if (string= clip-text "") (setq clip-text nil))
1329 ;; Check the CLIPBOARD selection for 'newness', is it different
1330 ;; from what we remebered them to be last time we did a
1331 ;; cut/paste operation.
1333 (cond ;; check clipboard
1334 ((or (not clip-text) (string= clip-text ""))
1335 (setq x-last-selected-text-clipboard nil))
1336 ((eq clip-text x-last-selected-text-clipboard) nil)
1337 ((string= clip-text x-last-selected-text-clipboard)
1338 ;; Record the newer string,
1339 ;; so subsequent calls can use the `eq' test.
1340 (setq x-last-selected-text-clipboard clip-text)
1342 (t (setq x-last-selected-text-clipboard clip-text)))))
1344 (when x-select-enable-primary
1345 (setq primary-text (x-selection-value 'PRIMARY))
1346 ;; Check the PRIMARY selection for 'newness', is it different
1347 ;; from what we remebered them to be last time we did a
1348 ;; cut/paste operation.
1350 (cond ;; check primary selection
1351 ((or (not primary-text) (string= primary-text ""))
1352 (setq x-last-selected-text-primary nil))
1353 ((eq primary-text x-last-selected-text-primary) nil)
1354 ((string= primary-text x-last-selected-text-primary)
1355 ;; Record the newer string,
1356 ;; so subsequent calls can use the `eq' test.
1357 (setq x-last-selected-text-primary primary-text)
1360 (setq x-last-selected-text-primary primary-text)))))
1362 (setq cut-text (x-get-cut-buffer 0))
1364 ;; Check the x cut buffer for 'newness', is it different
1365 ;; from what we remebered them to be last time we did a
1366 ;; cut/paste operation.
1368 (let ((next-coding (or next-selection-coding-system 'iso-latin-1)))
1369 (cond ;; check cut buffer
1370 ((or (not cut-text) (string= cut-text ""))
1371 (setq x-last-selected-text-cut nil))
1372 ;; This short cut doesn't work because x-get-cut-buffer
1373 ;; always returns a newly created string.
1374 ;; ((eq cut-text x-last-selected-text-cut) nil)
1375 ((and (string= cut-text x-last-selected-text-cut-encoded)
1376 (eq x-last-cut-buffer-coding next-coding))
1377 ;; See the comment above. No need of this recording.
1378 ;; Record the newer string,
1379 ;; so subsequent calls can use the `eq' test.
1380 ;; (setq x-last-selected-text-cut cut-text)
1383 (setq x-last-selected-text-cut-encoded cut-text
1384 x-last-cut-buffer-coding next-coding
1385 x-last-selected-text-cut
1386 ;; ICCCM says cut buffer always contain ISO-Latin-1, but
1387 ;; use next-selection-coding-system if not nil.
1388 (decode-coding-string
1389 cut-text next-coding))))))
1391 ;; As we have done one selection, clear this now.
1392 (setq next-selection-coding-system nil)
1394 ;; At this point we have recorded the current values for the
1395 ;; selection from clipboard (if we are supposed to) primary,
1396 ;; and cut buffer. So return the first one that has changed
1397 ;; (which is the first non-null one).
1399 ;; NOTE: There will be cases where more than one of these has
1400 ;; changed and the new values differ. This indicates that
1401 ;; something like the following has happened since the last time
1402 ;; we looked at the selections: Application X set all the
1403 ;; selections, then Application Y set only one or two of them (say
1404 ;; just the cut-buffer). In this case since we don't have
1405 ;; timestamps there is no way to know what the 'correct' value to
1406 ;; return is. The nice thing to do would be to tell the user we
1407 ;; saw multiple possible selections and ask the user which was the
1409 ;; This code is still a big improvement because now the user can
1410 ;; futz with the current selection and get emacs to pay attention
1411 ;; to the cut buffer again (previously as soon as clipboard or
1412 ;; primary had been set the cut buffer would essentially never be
1414 (or clip-text primary-text cut-text)
1417 ;; Arrange for the kill and yank functions to set and check the clipboard.
1418 (setq interprogram-cut-function 'x-select-text)
1419 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1421 (defun x-clipboard-yank ()
1422 "Insert the clipboard contents, or the last stretch of killed text."
1424 (let ((clipboard-text (x-selection-value 'CLIPBOARD))
1425 (x-select-enable-clipboard t))
1426 (if (and clipboard-text (> (length clipboard-text) 0))
1427 (kill-new clipboard-text))
1430 (declare-function accelerate-menu "xmenu.c" (&optional frame) t)
1432 (defun x-menu-bar-open (&optional frame)
1433 "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
1435 (if menu-bar-mode (accelerate-menu frame)
1439 ;;; Window system initialization.
1441 (defun x-win-suspend-error ()
1442 (error "Suspending an Emacs running under X makes no sense"))
1444 (defvar x-initialized nil
1445 "Non-nil if the X window system has been initialized.")
1447 (declare-function x-open-connection "xfns.c"
1448 (display &optional xrm-string must-succeed))
1449 (declare-function x-server-max-request-size "xfns.c" (&optional terminal))
1450 (declare-function x-get-resource "frame.c"
1451 (attribute class &optional component subclass))
1453 (defun x-initialize-window-system ()
1454 "Initialize Emacs for X frames and open the first connection to an X server."
1455 ;; Make sure we have a valid resource name.
1456 (or (stringp x-resource-name)
1458 (setq x-resource-name (invocation-name))
1460 ;; Change any . or * characters in x-resource-name to hyphens,
1461 ;; so as not to choke when we use it in X resource queries.
1462 (while (setq i (string-match "[.*]" x-resource-name))
1463 (aset x-resource-name i ?-))))
1465 (x-open-connection (or x-display-name
1466 (setq x-display-name (or (getenv "DISPLAY" (selected-frame))
1467 (getenv "DISPLAY"))))
1468 x-command-line-resources
1469 ;; Exit Emacs with fatal error if this fails and we
1470 ;; are the initial display.
1471 (eq initial-window-system 'x))
1473 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
1476 ;; Setup the default fontset.
1477 (setup-default-fontset)
1479 ;; Create the standard fontset.
1480 (create-fontset-from-fontset-spec standard-fontset-spec t)
1482 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
1483 (create-fontset-from-x-resource)
1485 ;; Set scroll bar mode to right if set by X resources. Default is left.
1486 (if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
1487 (customize-set-variable 'scroll-bar-mode 'right))
1489 ;; Apply a geometry resource to the initial frame. Put it at the end
1490 ;; of the alist, so that anything specified on the command line takes
1492 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1496 (setq parsed (x-parse-geometry res-geometry))
1497 ;; If the resource specifies a position,
1498 ;; call the position and size "user-specified".
1499 (if (or (assq 'top parsed) (assq 'left parsed))
1500 (setq parsed (cons '(user-position . t)
1501 (cons '(user-size . t) parsed))))
1502 ;; All geometry parms apply to the initial frame.
1503 (setq initial-frame-alist (append initial-frame-alist parsed))
1504 ;; The size parms apply to all frames. Don't set it if there are
1505 ;; sizes there already (from command line).
1506 (if (and (assq 'height parsed)
1507 (not (assq 'height default-frame-alist)))
1508 (setq default-frame-alist
1509 (cons (cons 'height (cdr (assq 'height parsed)))
1510 default-frame-alist)))
1511 (if (and (assq 'width parsed)
1512 (not (assq 'width default-frame-alist)))
1513 (setq default-frame-alist
1514 (cons (cons 'width (cdr (assq 'width parsed)))
1515 default-frame-alist))))))
1517 ;; Check the reverseVideo resource.
1518 (let ((case-fold-search t))
1519 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1521 (string-match "^\\(true\\|yes\\|on\\)$" rv))
1522 (setq default-frame-alist
1523 (cons '(reverse . t) default-frame-alist)))))
1525 ;; Set x-selection-timeout, measured in milliseconds.
1526 (let ((res-selection-timeout
1527 (x-get-resource "selectionTimeout" "SelectionTimeout")))
1528 (setq x-selection-timeout 20000)
1529 (if res-selection-timeout
1530 (setq x-selection-timeout (string-to-number res-selection-timeout))))
1532 ;; Don't let Emacs suspend under X.
1533 (add-hook 'suspend-hook 'x-win-suspend-error)
1535 ;; Turn off window-splitting optimization; X is usually fast enough
1536 ;; that this is only annoying.
1537 (setq split-window-keep-point t)
1539 ;; Motif direct handling of f10 wasn't working right,
1540 ;; So temporarily we've turned it off in lwlib-Xm.c
1541 ;; and turned the Emacs f10 back on.
1542 ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
1543 ;; (if (featurep 'motif)
1544 ;; (global-set-key [f10] 'ignore))
1546 ;; Turn on support for mouse wheels.
1547 (mouse-wheel-mode 1)
1549 ;; Enable CLIPBOARD copy/paste through menu bar commands.
1550 (menu-bar-enable-clipboard)
1552 ;; Override Paste so it looks at CLIPBOARD first.
1553 (define-key menu-bar-edit-menu [paste]
1554 (append '(menu-item "Paste" x-clipboard-yank
1555 :enable (not buffer-read-only)
1556 :help "Paste (yank) text most recently cut/copied")
1559 (setq x-initialized t))
1561 (add-to-list 'handle-args-function-alist '(x . x-handle-args))
1562 (add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
1563 (add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
1565 ;; Initiate drag and drop
1566 (add-hook 'after-make-frame-functions 'x-dnd-init-frame)
1567 (define-key special-event-map [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
1569 (defcustom x-gtk-stock-map
1571 ("etc/images/new" . "gtk-new")
1572 ("etc/images/open" . "gtk-open")
1573 ("etc/images/diropen" . "n:system-file-manager")
1574 ("etc/images/close" . "gtk-close")
1575 ("etc/images/save" . "gtk-save")
1576 ("etc/images/saveas" . "gtk-save-as")
1577 ("etc/images/undo" . "gtk-undo")
1578 ("etc/images/cut" . "gtk-cut")
1579 ("etc/images/copy" . "gtk-copy")
1580 ("etc/images/paste" . "gtk-paste")
1581 ("etc/images/search" . "gtk-find")
1582 ("etc/images/print" . "gtk-print")
1583 ("etc/images/preferences" . "gtk-preferences")
1584 ("etc/images/help" . "gtk-help")
1585 ("etc/images/left-arrow" . "gtk-go-back")
1586 ("etc/images/right-arrow" . "gtk-go-forward")
1587 ("etc/images/home" . "gtk-home")
1588 ("etc/images/jump-to" . "gtk-jump-to")
1589 ("etc/images/index" . "gtk-index")
1590 ("etc/images/search" . "gtk-find")
1591 ("etc/images/exit" . "gtk-quit")
1592 ("etc/images/cancel" . "gtk-cancel")
1593 ("etc/images/info" . "gtk-info")
1594 ("etc/images/bookmark_add" . "n:bookmark_add")
1595 ;; Used in Gnus and/or MH-E:
1596 ("etc/images/attach" . "gtk-attach")
1597 ("etc/images/connect" . "gtk-connect")
1598 ("etc/images/contact" . "gtk-contact")
1599 ("etc/images/delete" . "gtk-delete")
1600 ("etc/images/describe" . "gtk-properties")
1601 ("etc/images/disconnect" . "gtk-disconnect")
1602 ;; ("etc/images/exit" . "gtk-exit")
1603 ("etc/images/lock-broken" . "gtk-lock_broken")
1604 ("etc/images/lock-ok" . "gtk-lock_ok")
1605 ("etc/images/lock" . "gtk-lock")
1606 ("etc/images/next-page" . "gtk-next-page")
1607 ("etc/images/refresh" . "gtk-refresh")
1608 ("etc/images/sort-ascending" . "gtk-sort-ascending")
1609 ("etc/images/sort-column-ascending" . "gtk-sort-column-ascending")
1610 ("etc/images/sort-criteria" . "gtk-sort-criteria")
1611 ("etc/images/sort-descending" . "gtk-sort-descending")
1612 ("etc/images/sort-row-ascending" . "gtk-sort-row-ascending")
1613 ("images/gnus/toggle-subscription" . "gtk-task-recurring")
1614 ("images/mail/compose" . "gtk-mail-compose")
1615 ("images/mail/copy" . "gtk-mail-copy")
1616 ("images/mail/forward" . "gtk-mail-forward")
1617 ("images/mail/inbox" . "gtk-inbox")
1618 ("images/mail/move" . "gtk-mail-move")
1619 ("images/mail/not-spam" . "gtk-not-spam")
1620 ("images/mail/outbox" . "gtk-outbox")
1621 ("images/mail/reply-all" . "gtk-mail-reply-to-all")
1622 ("images/mail/reply" . "gtk-mail-reply")
1623 ("images/mail/save-draft" . "gtk-mail-handling")
1624 ("images/mail/send" . "gtk-mail-send")
1625 ("images/mail/spam" . "gtk-spam")
1626 ;; No themed versions available:
1627 ;; mail/preview (combining stock_mail and stock_zoom)
1628 ;; mail/save (combining stock_mail, stock_save and stock_convert)
1630 "How icons for tool bars are mapped to Gtk+ stock items.
1631 Emacs must be compiled with the Gtk+ toolkit for this to have any effect.
1632 A value that begins with n: denotes a named icon instead of a stock icon."
1634 :type '(choice (repeat (choice symbol
1635 (cons (string :tag "Emacs icon")
1636 (string :tag "Stock/named")))))
1639 (defcustom icon-map-list '(x-gtk-stock-map)
1640 "A list of alists that maps icon file names to stock/named icons.
1641 The alists are searched in the order they appear. The first match is used.
1642 The keys in the alists are file names without extension and with two directory
1643 components. For example, to map /usr/share/emacs/22.1.1/etc/images/open.xpm
1644 to stock item gtk-open, use:
1646 (\"etc/images/open\" . \"gtk-open\")
1648 Themes also have named icons. To map to one of those, use n: before the name:
1650 (\"etc/images/diropen\" . \"n:system-file-manager\")
1652 The list elements are either the symbol name for the alist or the
1655 If you don't want stock icons, set the variable to nil."
1657 :type '(choice (const :tag "Don't use stock icons" nil)
1658 (repeat (choice symbol
1659 (cons (string :tag "Emacs icon")
1660 (string :tag "Stock/named")))))
1663 (defun x-gtk-map-stock (file)
1664 "Map icon with file name FILE to a Gtk+ stock name, using `x-gtk-stock-map'."
1666 (let* ((file-sans (file-name-sans-extension file))
1667 (key (and (string-match "/\\([^/]+/[^/]+/[^/]+$\\)" file-sans)
1668 (match-string 1 file-sans)))
1670 (mapc (lambda (elem)
1671 (let ((assoc (if (symbolp elem) (symbol-value elem) elem)))
1672 (or value (setq value (assoc-string (or key file-sans)
1675 (and value (cdr value)))
1680 ;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
1681 ;;; x-win.el ends here