emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/term/x-win.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/term/x-win.el,v
Date: Wed, 29 Aug 2007 05:28:32 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     07/08/29 05:28:10

Index: lisp/term/x-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/x-win.el,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -b -r1.205 -r1.206
--- lisp/term/x-win.el  28 Aug 2007 10:16:31 -0000      1.205
+++ lisp/term/x-win.el  29 Aug 2007 05:27:59 -0000      1.206
@@ -25,10 +25,16 @@
 
 ;;; Commentary:
 
-;; X-win.el:  this file is loaded from ../lisp/startup.el when it recognizes
-;; that X windows are to be used.  Command line switches are parsed and those
-;; pertaining to X are processed and removed from the command line.  The
-;; X display is opened and hooks are set for popping up the initial window.
+;; X-win.el: this file defines functions to initialize the X window
+;; system and process X-specific command line parameters before
+;; creating the first X frame.
+
+;; Note that contrary to previous Emacs versions, the act of loading
+;; this file should not have the side effect of initializing the
+;; window system or processing command line arguments (this file is
+;; now loaded in loadup.el).  See the variables
+;; `handle-args-function-alist' and
+;; `window-system-initialization-alist' for more details.
 
 ;; startup.el will then examine startup files, and eventually call the hooks
 ;; which create the first window(s).
@@ -65,7 +71,7 @@
 ;; An alist of X options and the function which handles them.  See
 ;; ../startup.el.
 
-(if (not (eq window-system 'x))
+(if (not (fboundp 'x-create-frame))
     (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
 
 (require 'frame)
@@ -1170,27 +1176,30 @@
 
 ;;;; Function keys
 
-(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
-                          global-map)
-
-;; Map certain keypad keys into ASCII characters
-;; that people usually expect.
-(define-key function-key-map [backspace] [127])
-(define-key function-key-map [delete] [127])
-(define-key function-key-map [tab] [?\t])
-(define-key function-key-map [linefeed] [?\n])
-(define-key function-key-map [clear] [?\C-l])
-(define-key function-key-map [return] [?\C-m])
-(define-key function-key-map [escape] [?\e])
-(define-key function-key-map [M-backspace] [?\M-\d])
-(define-key function-key-map [M-delete] [?\M-\d])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [M-linefeed] [?\M-\n])
-(define-key function-key-map [M-clear] [?\M-\C-l])
-(define-key function-key-map [M-return] [?\M-\C-m])
-(define-key function-key-map [M-escape] [?\M-\e])
-(define-key function-key-map [iso-lefttab] [backtab])
-(define-key function-key-map [S-iso-lefttab] [backtab])
+(defun x-setup-function-keys (frame)
+  "Set up `function-key-map' on FRAME for the X window system."
+  ;; Don't do this twice on the same display, or it would break
+  ;; normal-erase-is-backspace-mode.
+  (unless (terminal-parameter frame 'x-setup-function-keys)
+    ;; Map certain keypad keys into ASCII characters that people usually 
expect.
+    (with-selected-frame frame
+      (define-key local-function-key-map [backspace] [127])
+      (define-key local-function-key-map [delete] [127])
+      (define-key local-function-key-map [tab] [?\t])
+      (define-key local-function-key-map [linefeed] [?\n])
+      (define-key local-function-key-map [clear] [?\C-l])
+      (define-key local-function-key-map [return] [?\C-m])
+      (define-key local-function-key-map [escape] [?\e])
+      (define-key local-function-key-map [M-backspace] [?\M-\d])
+      (define-key local-function-key-map [M-delete] [?\M-\d])
+      (define-key local-function-key-map [M-tab] [?\M-\t])
+      (define-key local-function-key-map [M-linefeed] [?\M-\n])
+      (define-key local-function-key-map [M-clear] [?\M-\C-l])
+      (define-key local-function-key-map [M-return] [?\M-\C-m])
+      (define-key local-function-key-map [M-escape] [?\M-\e])
+      (define-key local-function-key-map [iso-lefttab] [backtab])
+      (define-key local-function-key-map [S-iso-lefttab] [backtab]))
+    (set-terminal-parameter frame 'x-setup-function-keys t)))
 
 ;; These tell read-char how to convert
 ;; these special chars to ASCII.
@@ -2393,14 +2402,34 @@
     (or clip-text primary-text cut-text)
     ))
 
+(defun x-clipboard-yank ()
+  "Insert the clipboard contents, or the last stretch of killed text."
+  (interactive "*")
+  (let ((clipboard-text (x-selection-value 'CLIPBOARD))
+       (x-select-enable-clipboard t))
+    (if (and clipboard-text (> (length clipboard-text) 0))
+       (kill-new clipboard-text))
+    (yank)))
+
+(defun x-menu-bar-open (&optional frame)
+  "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
+  (interactive "i")
+  (if menu-bar-mode (accelerate-menu frame)
+    (tmm-menubar)))
+
 
-;; Do the actual X Windows setup here; the above code just defines
-;; functions and variables that we use now.
+;;; Window system initialization.
 
-(setq command-line-args (x-handle-args command-line-args))
+(defun x-win-suspend-error ()
+  (error "Suspending an Emacs running under X makes no sense"))
+
+(defvar x-initialized nil
+  "Non-nil if the X window system has been initialized.")
 
-;; Make sure we have a valid resource name.
-(or (stringp x-resource-name)
+(defun x-initialize-window-system ()
+  "Initialize Emacs for X frames and open the first connection to an X server."
+  ;; Make sure we have a valid resource name.
+  (or (stringp x-resource-name)
     (let (i)
       (setq x-resource-name (invocation-name))
 
@@ -2409,35 +2438,35 @@
       (while (setq i (string-match "[.*]" x-resource-name))
        (aset x-resource-name i ?-))))
 
-(x-open-connection (or x-display-name
-                      (setq x-display-name (getenv "DISPLAY")))
+  (x-open-connection (or x-display-name
+                        (setq x-display-name (or (getenv "DISPLAY" 
(selected-frame))
+                                                 (getenv "DISPLAY"))))
                   x-command-line-resources
-                  ;; Exit Emacs with fatal error if this fails.
-                  t)
+                    ;; Exit Emacs with fatal error if this fails and we
+                    ;; are the initial display.
+                    (eq initial-window-system 'x))
 
-(setq frame-creation-function 'x-create-frame-with-faces)
-
-(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
+  (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
                            x-cut-buffer-max))
 
-;; Setup the default fontset.
-(setup-default-fontset)
+  ;; Setup the default fontset.
+  (setup-default-fontset)
 
-;; Create the standard fontset.
-(create-fontset-from-fontset-spec standard-fontset-spec t)
+  ;; Create the standard fontset.
+  (create-fontset-from-fontset-spec standard-fontset-spec t)
 
-;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
-(create-fontset-from-x-resource)
+  ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
+  (create-fontset-from-x-resource)
 
-;; Try to create a fontset from a font specification which comes
-;; from initial-frame-alist, default-frame-alist, or X resource.
-;; A font specification in command line argument (i.e. -fn XXXX)
-;; should be already in default-frame-alist as a `font'
-;; parameter.  However, any font specifications in site-start
-;; library, user's init file (.emacs), and default.el are not
-;; yet handled here.
+  ;; Try to create a fontset from a font specification which comes
+  ;; from initial-frame-alist, default-frame-alist, or X resource.
+  ;; A font specification in command line argument (i.e. -fn XXXX)
+  ;; should be already in default-frame-alist as a `font'
+  ;; parameter.  However, any font specifications in site-start
+  ;; library, user's init file (.emacs), and default.el are not
+  ;; yet handled here.
 
-(let ((font (or (cdr (assq 'font initial-frame-alist))
+  (let ((font (or (cdr (assq 'font initial-frame-alist))
                (cdr (assq 'font default-frame-alist))
                (x-get-resource "font" "Font")))
       xlfd-fields resolved-name)
@@ -2451,10 +2480,14 @@
        ;; generated from FONT.
        (create-fontset-from-ascii-font font resolved-name "startup"))))
 
-;; Apply a geometry resource to the initial frame.  Put it at the end
-;; of the alist, so that anything specified on the command line takes
-;; precedence.
-(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
+  ;; Set scroll bar mode to right if set by X resources. Default is left.
+  (if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
+      (customize-set-variable 'scroll-bar-mode 'right))
+
+  ;; Apply a geometry resource to the initial frame.  Put it at the end
+  ;; of the alist, so that anything specified on the command line takes
+  ;; precedence.
+  (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
        parsed)
   (if res-geometry
       (progn
@@ -2479,68 +2512,55 @@
                  (cons (cons 'width (cdr (assq 'width parsed)))
                        default-frame-alist))))))
 
-;; Check the reverseVideo resource.
-(let ((case-fold-search t))
+  ;; Check the reverseVideo resource.
+  (let ((case-fold-search t))
   (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
     (if (and rv
             (string-match "^\\(true\\|yes\\|on\\)$" rv))
        (setq default-frame-alist
              (cons '(reverse . t) default-frame-alist)))))
 
-;; Set x-selection-timeout, measured in milliseconds.
-(let ((res-selection-timeout
+  ;; Set x-selection-timeout, measured in milliseconds.
+  (let ((res-selection-timeout
        (x-get-resource "selectionTimeout" "SelectionTimeout")))
   (setq x-selection-timeout 20000)
   (if res-selection-timeout
       (setq x-selection-timeout (string-to-number res-selection-timeout))))
 
-;; Set scroll bar mode to right if set by X resources. Default is left.
-(if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
-    (customize-set-variable 'scroll-bar-mode 'right))
-
-(defun x-win-suspend-error ()
-  (error "Suspending an Emacs running under X makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-
-;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
-(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
-
-;; Turn off window-splitting optimization; X is usually fast enough
-;; that this is only annoying.
-(setq split-window-keep-point t)
-
-;; Don't show the frame name; that's redundant with X.
-(setq-default mode-line-frame-identification "  ")
-
-;; Motif direct handling of f10 wasn't working right,
-;; So temporarily we've turned it off in lwlib-Xm.c
-;; and turned the Emacs f10 back on.
-;; ;; Motif normally handles f10 itself, so don't try to handle it a second 
time.
-;; (if (featurep 'motif)
-;;     (global-set-key [f10] 'ignore))
-
-;; Turn on support for mouse wheels.
-(mouse-wheel-mode 1)
+  ;; Don't let Emacs suspend under X.
+  (add-hook 'suspend-hook 'x-win-suspend-error)
 
+  ;; Turn off window-splitting optimization; X is usually fast enough
+  ;; that this is only annoying.
+  (setq split-window-keep-point t)
+
+  ;; Motif direct handling of f10 wasn't working right,
+  ;; So temporarily we've turned it off in lwlib-Xm.c
+  ;; and turned the Emacs f10 back on.
+  ;; ;; Motif normally handles f10 itself, so don't try to handle it a second 
time.
+  ;; (if (featurep 'motif)
+  ;;     (global-set-key [f10] 'ignore))
+
+  ;; Turn on support for mouse wheels.
+  (mouse-wheel-mode 1)
+
+  ;; Enable CLIPBOARD copy/paste through menu bar commands.
+  (menu-bar-enable-clipboard)
+
+  ;; Override Paste so it looks at CLIPBOARD first.
+  (define-key menu-bar-edit-menu [paste]
+    (append '(menu-item "Paste" x-clipboard-yank
+                       :enable (not buffer-read-only)
+                       :help "Paste (yank) text most recently cut/copied")
+           nil))
 
-;; Enable CLIPBOARD copy/paste through menu bar commands.
-(menu-bar-enable-clipboard)
+  (setq x-initialized t))
 
-;; Override Paste so it looks at CLIPBOARD first.
-(defun x-clipboard-yank ()
-  "Insert the clipboard contents, or the last stretch of killed text."
-  (interactive "*")
-  (let ((clipboard-text (x-selection-value 'CLIPBOARD))
-       (x-select-enable-clipboard t))
-    (if (and clipboard-text (> (length clipboard-text) 0))
-       (kill-new clipboard-text))
-    (yank)))
+(add-to-list 'handle-args-function-alist '(x . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(x . 
x-initialize-window-system))
 
-(define-key menu-bar-edit-menu [paste]
-  '(menu-item "Paste" x-clipboard-yank
-             :enable (not buffer-read-only)
-             :help "Paste (yank) text most recently cut/copied"))
+(provide 'x-win)
 
 ;; Initiate drag and drop
 (add-hook 'after-make-frame-functions 'x-dnd-init-frame)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]