aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/term
diff options
context:
space:
mode:
authorKaroly Lorentey2004-01-22 02:36:55 +0000
committerKaroly Lorentey2004-01-22 02:36:55 +0000
commite9cda8277618ce4e2644e852539474b7b67f09e3 (patch)
treeca87f4bef3d3f98379211ea69f1fb3c26452a540 /lisp/term
parent990e879437236fc76e827d6191899c117f01fd99 (diff)
downloademacs-e9cda8277618ce4e2644e852539474b7b67f09e3.tar.gz
emacs-e9cda8277618ce4e2644e852539474b7b67f09e3.zip
Romain Francoise's and Ami Fischman's bugfixes.
src/term.c (create_tty_output): Fix syntax error. Reported by Ami Fischman (ami at fischman dot org). lisp/loadup.el: Load term/x-win.el if X is available. lisp/startup.el (handle-args-function-alist) (window-system-initialization-alist): New variables. (command-line): Don't load term/x-win.el, use the above variables. lisp/x-win.el: (x-initialize-window-system): New function, move X initialization here. (x-initialized): New variable. lisp/frame.el (make-frame-on-display): Don't initialize X twice, and make sure to pass the correct display parameter to x-open-connection. Reported by Romain Francoise (romain at orebokech dot com). git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-58
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/x-win.el261
1 files changed, 137 insertions, 124 deletions
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 11e3c073b76..e0233d64dbd 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -24,10 +24,16 @@
24 24
25;;; Commentary: 25;;; Commentary:
26 26
27;; X-win.el: this file is loaded from ../lisp/startup.el when it recognizes 27;; X-win.el: this file defines functions to initialize the X window
28;; that X windows are to be used. Command line switches are parsed and those 28;; system and process X-specific command line parameters before
29;; pertaining to X are processed and removed from the command line. The 29;; creating the first X frame.
30;; X display is opened and hooks are set for popping up the initial window. 30
31;; Note that contrary to previous Emacs versions, the act of loading
32;; this file should not have the side effect of initializing the
33;; window system or processing command line arguments (this file is
34;; now loaded in loadup.el). See the variables
35;; `handle-args-function-alist' and
36;; `window-system-initialization-alist' for more details.
31 37
32;; startup.el will then examine startup files, and eventually call the hooks 38;; startup.el will then examine startup files, and eventually call the hooks
33;; which create the first window(s). 39;; which create the first window(s).
@@ -1159,10 +1165,6 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1159 1165
1160;;;; Function keys 1166;;;; Function keys
1161 1167
1162;;; XXX This might be wrong with multi-tty support.
1163(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1164 global-map)
1165
1166;; Map certain keypad keys into ASCII characters 1168;; Map certain keypad keys into ASCII characters
1167;; that people usually expect. 1169;; that people usually expect.
1168(define-key function-key-map [backspace] [127]) 1170(define-key function-key-map [backspace] [127])
@@ -2237,7 +2239,7 @@ order until succeed.")
2237 (if text 2239 (if text
2238 (remove-text-properties 0 (length text) '(foreign-selection nil) text)) 2240 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
2239 text)) 2241 text))
2240 2242
2241;;; Return the value of the current X selection. 2243;;; Return the value of the current X selection.
2242;;; Consult the selection, and the cut buffer. Treat empty strings 2244;;; Consult the selection, and the cut buffer. Treat empty strings
2243;;; as if they were unset. 2245;;; as if they were unset.
@@ -2329,132 +2331,143 @@ order until succeed.")
2329 )) 2331 ))
2330 2332
2331 2333
2332;;; Do the actual X Windows setup here; the above code just defines 2334;;; Window system initialization.
2333;;; functions and variables that we use now.
2334
2335(setq command-line-args (x-handle-args command-line-args))
2336 2335
2337;;; Make sure we have a valid resource name. 2336(defun x-win-suspend-error ()
2338(or (stringp x-resource-name) 2337 (error "Suspending an Emacs running under X makes no sense"))
2339 (let (i)
2340 (setq x-resource-name (invocation-name))
2341 2338
2342 ;; Change any . or * characters in x-resource-name to hyphens, 2339(defvar x-initialized nil
2343 ;; so as not to choke when we use it in X resource queries. 2340 "Non-nil if the X window system has been initialized.")
2344 (while (setq i (string-match "[.*]" x-resource-name)) 2341
2345 (aset x-resource-name i ?-)))) 2342(defun x-initialize-window-system ()
2343 "Initialize Emacs for X frames and open the first connection to an X server."
2344 ;; Make sure we have a valid resource name.
2345 (or (stringp x-resource-name)
2346 (let (i)
2347 (setq x-resource-name (invocation-name))
2348
2349 ;; Change any . or * characters in x-resource-name to hyphens,
2350 ;; so as not to choke when we use it in X resource queries.
2351 (while (setq i (string-match "[.*]" x-resource-name))
2352 (aset x-resource-name i ?-))))
2353
2354 (x-open-connection (or x-display-name
2355 (setq x-display-name (getenv "DISPLAY")))
2356 x-command-line-resources
2357 ;; Exit Emacs with fatal error if this fails and we
2358 ;; are the initial display.
2359 (eq initial-window-system 'x))
2360
2361 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
2362 x-cut-buffer-max))
2363
2364 ;; Setup the default fontset.
2365 (setup-default-fontset)
2366
2367 ;; Create the standard fontset.
2368 (create-fontset-from-fontset-spec standard-fontset-spec t)
2369
2370 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2371 (create-fontset-from-x-resource)
2372
2373 ;; Try to create a fontset from a font specification which comes
2374 ;; from initial-frame-alist, default-frame-alist, or X resource.
2375 ;; A font specification in command line argument (i.e. -fn XXXX)
2376 ;; should be already in default-frame-alist as a `font'
2377 ;; parameter. However, any font specifications in site-start
2378 ;; library, user's init file (.emacs), and default.el are not
2379 ;; yet handled here.
2380
2381 (let ((font (or (cdr (assq 'font initial-frame-alist))
2382 (cdr (assq 'font default-frame-alist))
2383 (x-get-resource "font" "Font")))
2384 xlfd-fields resolved-name)
2385 (if (and font
2386 (not (query-fontset font))
2387 (setq resolved-name (x-resolve-font-name font))
2388 (setq xlfd-fields (x-decompose-font-name font)))
2389 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2390 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2391 ;; Create a fontset from FONT. The fontset name is
2392 ;; generated from FONT.
2393 (create-fontset-from-ascii-font font resolved-name "startup"))))
2394
2395 ;; Sun expects the menu bar cut and paste commands to use the clipboard.
2396 ;; This has ,? to match both on Sunos and on Solaris.
2397 (if (string-match "Sun Microsystems,? Inc\\."
2398 (x-server-vendor))
2399 (menu-bar-enable-clipboard))
2400
2401 ;; Apply a geometry resource to the initial frame. Put it at the end
2402 ;; of the alist, so that anything specified on the command line takes
2403 ;; precedence.
2404 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2405 parsed)
2406 (if res-geometry
2407 (progn
2408 (setq parsed (x-parse-geometry res-geometry))
2409 ;; If the resource specifies a position,
2410 ;; call the position and size "user-specified".
2411 (if (or (assq 'top parsed) (assq 'left parsed))
2412 (setq parsed (cons '(user-position . t)
2413 (cons '(user-size . t) parsed))))
2414 ;; All geometry parms apply to the initial frame.
2415 (setq initial-frame-alist (append initial-frame-alist parsed))
2416 ;; The size parms apply to all frames.
2417 (if (assq 'height parsed)
2418 (setq default-frame-alist
2419 (cons (cons 'height (cdr (assq 'height parsed)))
2420 default-frame-alist)))
2421 (if (assq 'width parsed)
2422 (setq default-frame-alist
2423 (cons (cons 'width (cdr (assq 'width parsed)))
2424 default-frame-alist))))))
2425
2426 ;; Check the reverseVideo resource.
2427 (let ((case-fold-search t))
2428 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2429 (if (and rv
2430 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2431 (setq default-frame-alist
2432 (cons '(reverse . t) default-frame-alist)))))
2346 2433
2347(x-open-connection (or x-display-name 2434 ;; Set x-selection-timeout, measured in milliseconds.
2348 (setq x-display-name (getenv "DISPLAY"))) 2435 (let ((res-selection-timeout
2349 x-command-line-resources 2436 (x-get-resource "selectionTimeout" "SelectionTimeout")))
2350 ;; Exit Emacs with fatal error if this fails and we 2437 (setq x-selection-timeout 20000)
2351 ;; are the initial display. 2438 (if res-selection-timeout
2352 (eq initial-window-system 'x)) 2439 (setq x-selection-timeout (string-to-number res-selection-timeout))))
2353 2440
2354(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces)) 2441 ;; XXX This is wrong in general with multi-tty support.
2442 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
2443 global-map)
2355 2444
2356(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100) 2445 ;; XXX This is wrong in general with multi-tty support.
2357 x-cut-buffer-max)) 2446 (add-hook 'suspend-hook 'x-win-suspend-error)
2358
2359;; Setup the default fontset.
2360(setup-default-fontset)
2361
2362;; Create the standard fontset.
2363(create-fontset-from-fontset-spec standard-fontset-spec t)
2364
2365;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2366(create-fontset-from-x-resource)
2367
2368;; Try to create a fontset from a font specification which comes
2369;; from initial-frame-alist, default-frame-alist, or X resource.
2370;; A font specification in command line argument (i.e. -fn XXXX)
2371;; should be already in default-frame-alist as a `font'
2372;; parameter. However, any font specifications in site-start
2373;; library, user's init file (.emacs), and default.el are not
2374;; yet handled here.
2375
2376(let ((font (or (cdr (assq 'font initial-frame-alist))
2377 (cdr (assq 'font default-frame-alist))
2378 (x-get-resource "font" "Font")))
2379 xlfd-fields resolved-name)
2380 (if (and font
2381 (not (query-fontset font))
2382 (setq resolved-name (x-resolve-font-name font))
2383 (setq xlfd-fields (x-decompose-font-name font)))
2384 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2385 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2386 ;; Create a fontset from FONT. The fontset name is
2387 ;; generated from FONT.
2388 (create-fontset-from-ascii-font font resolved-name "startup"))))
2389
2390;; Sun expects the menu bar cut and paste commands to use the clipboard.
2391;; This has ,? to match both on Sunos and on Solaris.
2392(if (string-match "Sun Microsystems,? Inc\\."
2393 (x-server-vendor))
2394 (menu-bar-enable-clipboard))
2395
2396;; Apply a geometry resource to the initial frame. Put it at the end
2397;; of the alist, so that anything specified on the command line takes
2398;; precedence.
2399(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2400 parsed)
2401 (if res-geometry
2402 (progn
2403 (setq parsed (x-parse-geometry res-geometry))
2404 ;; If the resource specifies a position,
2405 ;; call the position and size "user-specified".
2406 (if (or (assq 'top parsed) (assq 'left parsed))
2407 (setq parsed (cons '(user-position . t)
2408 (cons '(user-size . t) parsed))))
2409 ;; All geometry parms apply to the initial frame.
2410 (setq initial-frame-alist (append initial-frame-alist parsed))
2411 ;; The size parms apply to all frames.
2412 (if (assq 'height parsed)
2413 (setq default-frame-alist
2414 (cons (cons 'height (cdr (assq 'height parsed)))
2415 default-frame-alist)))
2416 (if (assq 'width parsed)
2417 (setq default-frame-alist
2418 (cons (cons 'width (cdr (assq 'width parsed)))
2419 default-frame-alist))))))
2420
2421;; Check the reverseVideo resource.
2422(let ((case-fold-search t))
2423 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2424 (if (and rv
2425 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2426 (setq default-frame-alist
2427 (cons '(reverse . t) default-frame-alist)))))
2428 2447
2429;; Set x-selection-timeout, measured in milliseconds. 2448 ;; Arrange for the kill and yank functions to set and check the clipboard.
2430(let ((res-selection-timeout 2449 (setq interprogram-cut-function 'x-select-text)
2431 (x-get-resource "selectionTimeout" "SelectionTimeout"))) 2450 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
2432 (setq x-selection-timeout 20000)
2433 (if res-selection-timeout
2434 (setq x-selection-timeout (string-to-number res-selection-timeout))))
2435 2451
2436;; XXX This is wrong with multi-tty support. 2452 ;; Turn off window-splitting optimization; X is usually fast enough
2437(defun x-win-suspend-error () 2453 ;; that this is only annoying.
2438 (error "Suspending an Emacs running under X makes no sense")) 2454 (setq split-window-keep-point t)
2439(add-hook 'suspend-hook 'x-win-suspend-error)
2440 2455
2441;;; Arrange for the kill and yank functions to set and check the clipboard. 2456 ;; Motif direct handling of f10 wasn't working right,
2442(setq interprogram-cut-function 'x-select-text) 2457 ;; So temporarily we've turned it off in lwlib-Xm.c
2443(setq interprogram-paste-function 'x-cut-buffer-or-selection-value) 2458 ;; and turned the Emacs f10 back on.
2459 ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
2460 ;; (if (featurep 'motif)
2461 ;; (global-set-key [f10] 'ignore))
2444 2462
2445;;; Turn off window-splitting optimization; X is usually fast enough 2463 ;; Turn on support for mouse wheels.
2446;;; that this is only annoying. 2464 (mouse-wheel-mode 1)
2447(setq split-window-keep-point t)
2448 2465
2449;; Motif direct handling of f10 wasn't working right, 2466 (setq x-initialized t))
2450;; So temporarily we've turned it off in lwlib-Xm.c
2451;; and turned the Emacs f10 back on.
2452;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
2453;; (if (featurep 'motif)
2454;; (global-set-key [f10] 'ignore))
2455 2467
2456;; Turn on support for mouse wheels. 2468(add-to-list 'handle-args-function-alist '(x . x-handle-args))
2457(mouse-wheel-mode 1) 2469(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
2470(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
2458 2471
2459(provide 'x-win) 2472(provide 'x-win)
2460 2473