0
|
1 ;;; x-init.el --- initialization code for X windows
|
|
2 ;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc.
|
|
3 ;; Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
4 ;; Copyright (C) 1995, 1996 Ben Wing.
|
|
5
|
|
6 ;; Author: various
|
|
7 ;; Keywords: terminals
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
|
15
|
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24
|
|
25 ;;; Commentary:
|
|
26
|
|
27 ;;; Code:
|
|
28
|
|
29 ;;; If you want to change this variable, this is the place you must do it.
|
|
30 ;;; Do not set it to a string containing periods. X doesn't like that.
|
|
31 ;(setq x-emacs-application-class "Emacs")
|
|
32
|
|
33 ;;; selections and active regions
|
|
34
|
|
35 ;;; If and only if zmacs-regions is true:
|
|
36 ;;;
|
|
37 ;;; When a mark is pushed and the region goes into the "active" state, we
|
|
38 ;;; assert it as the Primary selection. This causes it to be hilighted.
|
|
39 ;;; When the region goes into the "inactive" state, we disown the Primary
|
|
40 ;;; selection, causing the region to be dehilighted.
|
|
41 ;;;
|
|
42 ;;; Note that it is possible for the region to be in the "active" state
|
|
43 ;;; and not be hilighted, if it is in the active state and then some other
|
|
44 ;;; application asserts the selection. This is probably not a big deal.
|
|
45
|
|
46 (defun x-activate-region-as-selection ()
|
|
47 (if (marker-buffer (mark-marker t))
|
|
48 (x-own-selection (cons (point-marker t) (mark-marker t)))))
|
|
49
|
|
50 ;;; OpenWindows-like "find" processing. These functions are really Sunisms,
|
|
51 ;;; but we put them here instead of in x-win-sun.el in case someone wants
|
2
|
52 ;;; to use them when not running on a Sun console (presumably after binding
|
|
53 ;;; them to different keys, or putting them on menus.)
|
0
|
54
|
|
55 (defvar ow-find-last-string nil)
|
|
56 (defvar ow-find-last-clipboard nil)
|
|
57
|
|
58 (defun ow-find (&optional backward-p)
|
|
59 "Search forward the next occurrence of the text of the selection."
|
|
60 (interactive)
|
|
61 (let ((sel (condition-case () (x-get-selection) (error nil)))
|
|
62 (clip (condition-case () (x-get-clipboard) (error nil)))
|
|
63 text)
|
|
64 (setq text (cond
|
|
65 (sel)
|
|
66 ((not (equal clip ow-find-last-clipboard))
|
|
67 (setq ow-find-last-clipboard clip))
|
|
68 (ow-find-last-string)
|
|
69 (t (error "No selection available"))))
|
|
70 (setq ow-find-last-string text)
|
|
71 (cond (backward-p
|
|
72 (search-backward text)
|
|
73 (set-mark (+ (point) (length text))))
|
|
74 (t
|
|
75 (search-forward text)
|
|
76 (set-mark (- (point) (length text)))))
|
|
77 (zmacs-activate-region)))
|
|
78
|
|
79 (defun ow-find-backward ()
|
2
|
80 "Search backward the previous occurrence of the text of the selection."
|
0
|
81 (interactive)
|
|
82 (ow-find t))
|
|
83
|
48
|
84 (defun x-initialize-compose ()
|
|
85 "Enable compose processing"
|
|
86 (require 'x-compose))
|
|
87
|
0
|
88 ;;; Load X-server specific code.
|
|
89 ;;; Specifically, load some code to repair the grievous damage that MIT and
|
|
90 ;;; Sun have done to the default keymap for the Sun keyboards.
|
|
91
|
|
92 (defun x-initialize-keyboard ()
|
2
|
93 "Perform X-Server-specific initializations. Don't call this."
|
|
94 ;; This is some heuristic junk that tries to guess whether this is
|
|
95 ;; a Sun keyboard.
|
|
96 ;;
|
|
97 ;; One way of implementing this (which would require C support) would
|
|
98 ;; be to examine the X keymap itself and see if the layout looks even
|
|
99 ;; remotely like a Sun - check for the Find key on a particular
|
|
100 ;; keycode, for example. It'd be nice to have a table of this to
|
|
101 ;; recognize various keyboards; see also xkeycaps.
|
|
102 (let ((vendor (x-server-vendor)))
|
|
103 (cond ((or (string-match "Sun Microsystems" vendor)
|
0
|
104 ;; MIT losingly fails to tell us what hardware the X server
|
|
105 ;; is managing, so assume all MIT displays are Suns... HA HA!
|
|
106 (string-equal "MIT X Consortium" vendor)
|
2
|
107 (string-equal "X Consortium" vendor))
|
|
108 ;; Ok, we think this could be a Sun keyboard. Load the Sun code.
|
|
109 (or (load "x-win-sun" t t)
|
|
110 (warn "Unable to load term file x-win-sun")))
|
|
111 ((string-match "XFree86" vendor)
|
|
112 ;; Those XFree86 people do some weird keysym stuff, too.
|
|
113 (or (load "x-win-xfree86" t t)
|
|
114 (warn "Unable to load term file x-win-xfree86")))
|
|
115 )))
|
0
|
116
|
|
117
|
|
118 (defvar pre-x-win-initted nil)
|
|
119
|
|
120 (defun init-pre-x-win ()
|
|
121 "Initialize X Windows at startup (pre). Don't call this."
|
2
|
122 (when (not pre-x-win-initted)
|
|
123 (require 'x-iso8859-1)
|
|
124 (setq character-set-property 'x-iso8859/1) ; see x-iso8859-1.el
|
0
|
125
|
2
|
126 (setq initial-frame-plist (if initial-frame-unmapped-p
|
|
127 '(initially-unmapped t)
|
|
128 nil))
|
|
129 (setq pre-x-win-initted t)))
|
0
|
130
|
|
131 (defvar x-win-initted nil)
|
|
132
|
|
133 (defun init-x-win ()
|
|
134 "Initialize X Windows at startup. Don't call this."
|
2
|
135 (when (not x-win-initted)
|
|
136 (init-pre-x-win)
|
0
|
137
|
2
|
138 ;; Open the X display when this file is loaded
|
|
139 ;; (Note that the first frame is created later.)
|
|
140 (setq x-initial-argv-list (cons (car command-line-args)
|
|
141 command-line-args-left))
|
|
142 (make-x-device nil)
|
|
143 (setq command-line-args-left (cdr x-initial-argv-list))
|
|
144 (setq x-win-initted t)))
|
0
|
145
|
|
146 (defvar post-x-win-initted nil)
|
|
147
|
|
148 (defun init-post-x-win ()
|
|
149 "Initialize X Windows at startup (post). Don't call this."
|
2
|
150 (when (not post-x-win-initted)
|
|
151 ;; We can't load this until after the initial X device is created
|
|
152 ;; because the icon initialization needs to access the display to get
|
|
153 ;; any toolbar-related color resources.
|
|
154 (if (featurep 'toolbar)
|
|
155 (init-x-toolbar))
|
|
156 ;; these are only ever called if zmacs-regions is true.
|
4
|
157 (add-hook 'zmacs-deactivate-region-hook
|
|
158 (lambda ()
|
|
159 (if (console-on-window-system-p)
|
|
160 (x-disown-selection))))
|
|
161 (add-hook 'zmacs-activate-region-hook
|
|
162 (lambda ()
|
|
163 (if (console-on-window-system-p)
|
|
164 (x-activate-region-as-selection))))
|
|
165 (add-hook 'zmacs-update-region-hook
|
|
166 (lambda ()
|
|
167 (if (console-on-window-system-p)
|
|
168 (x-activate-region-as-selection))))
|
2
|
169 ;; Motif-ish bindings
|
|
170 ;; The following two were generally unliked.
|
|
171 ;;(define-key global-map '(shift delete) 'x-kill-primary-selection)
|
|
172 ;;(define-key global-map '(control delete) 'x-delete-primary-selection)
|
|
173 (define-key global-map '(shift insert) 'x-yank-clipboard-selection)
|
|
174 (define-key global-map '(control insert) 'x-copy-primary-selection)
|
|
175 ;; These are Sun-isms.
|
|
176 (define-key global-map 'copy 'x-copy-primary-selection)
|
|
177 (define-key global-map 'paste 'x-yank-clipboard-selection)
|
|
178 (define-key global-map 'cut 'x-kill-primary-selection)
|
0
|
179
|
2
|
180 (define-key global-map 'menu 'popup-mode-menu)
|
|
181 ;;(define-key global-map '(shift menu) 'x-goto-menubar) ;NYI
|
0
|
182
|
2
|
183 ;; This runs after the first frame has been created (we can't
|
|
184 ;; talk to the X server before that) but before the
|
|
185 ;; site-start-file or .emacs file, so sites and users have a
|
|
186 ;; chance to override it.
|
|
187 (add-hook 'before-init-hook 'x-initialize-keyboard)
|
48
|
188 (add-hook 'before-init-hook 'x-initialize-compose)
|
0
|
189
|
2
|
190 (setq post-x-win-initted t)))
|
0
|
191
|
|
192 (defun make-frame-on-display (display &optional parms)
|
|
193 "Create a frame on the X display named DISPLAY.
|
|
194 DISPLAY should be a standard display string such as \"unix:0\",
|
|
195 or nil for the display specified on the command line or in the
|
|
196 DISPLAY environment variable.
|
|
197
|
|
198 PROPS should be an plist of properties, as in the call to `make-frame'.
|
|
199
|
|
200 This function opens a connection to the display or reuses an existing
|
|
201 connection.
|
|
202
|
|
203 This function is a trivial wrapper around `make-frame-on-device'."
|
|
204 (interactive "sMake frame on display: ")
|
|
205 (if (equal display "") (setq display nil))
|
|
206 (make-frame-on-device 'x display parms))
|
|
207
|
|
208 ;;; x-init.el ends here
|