emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/startup.el,v


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

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

Index: lisp/startup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/startup.el,v
retrieving revision 1.450
retrieving revision 1.451
diff -u -b -r1.450 -r1.451
--- lisp/startup.el     24 Aug 2007 02:57:42 -0000      1.450
+++ lisp/startup.el     29 Aug 2007 05:28:06 -0000      1.451
@@ -36,6 +36,13 @@
 (defvar command-line-processed nil
   "Non-nil once command line has been processed.")
 
+(defvar window-system initial-window-system
+  "Name of window system the selected frame is displaying through.
+The value is a symbol--for instance, `x' for X windows.
+The value is nil if the selected frame is on a text-only-terminal.")
+
+(make-variable-frame-local 'window-system)
+
 (defgroup initialization nil
   "Emacs start-up procedure."
   :group 'environment)
@@ -458,36 +465,19 @@
        ;; for instance due to a dense colormap.
        (when (or frame-initial-frame
                  ;; If frame-initial-frame has no meaning, do this anyway.
-                 (not (and window-system
+                 (not (and initial-window-system
                            (not noninteractive)
-                           (not (eq window-system 'pc)))))
+                           (not (eq initial-window-system 'pc)))))
          ;; Modify the initial frame based on what .emacs puts into
          ;; ...-frame-alist.
          (if (fboundp 'frame-notice-user-settings)
              (frame-notice-user-settings))
-         (if (fboundp 'frame-set-background-mode)
              ;; Set the faces for the initial background mode even if
              ;; frame-notice-user-settings didn't (such as on a tty).
              ;; frame-set-background-mode is idempotent, so it won't
              ;; cause any harm if it's already been done.
-             (let ((frame (selected-frame))
-                   term)
-               (when (and (null window-system)
-                          ;; Don't override default set by files in lisp/term.
-                          (null default-frame-background-mode)
-                          (let ((bg (frame-parameter frame 'background-color)))
-                            (or (null bg)
-                                (member bg '(unspecified "unspecified-bg"
-                                                         "unspecified-fg")))))
-
-                 (setq term (getenv "TERM"))
-                 ;; Some files in lisp/term do a better job with the
-                 ;; background mode, but we leave this here anyway, in
-                 ;; case they remove those files.
-                 (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
-                                   term)
-                     (setq default-frame-background-mode 'light)))
-               (frame-set-background-mode (selected-frame)))))
+         (if (fboundp 'frame-set-background-mode)
+             (frame-set-background-mode (selected-frame))))
 
        ;; Now we know the user's default font, so add it to the menu.
        (if (fboundp 'font-menu-add-default)
@@ -528,6 +518,20 @@
 (defvar tool-bar-originally-present nil
   "Non-nil if tool-bars are present before user and site init files are read.")
 
+(defvar handle-args-function-alist '((nil . tty-handle-args))
+  "Functions for processing window-system dependent command-line arguments.
+Window system startup files should add their own function to this
+alist, which should parse the command line arguments.  Those
+pertaining to the window system should be processed and removed
+from the returned command line.")
+
+(defvar window-system-initialization-alist '((nil . ignore))
+  "Alist of window-system initialization functions.
+Window-system startup files should add their own initialization
+function to this list.  The function should take no arguments,
+and initialize the window system environment to prepare for
+opening the first frame (e.g. open a connection to an X server).")
+
 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
 (defun tty-handle-args (args)
   (let (rest)
@@ -632,16 +636,22 @@
     (setq eol-mnemonic-dos  "(DOS)"
           eol-mnemonic-mac  "(Mac)")))
 
-  ;; Read window system's init file if using a window system.
+  ;; Make sure window system's init file was loaded in loadup.el if using a 
window system.
   (condition-case error
-      (if (and window-system (not noninteractive))
-         (load (concat term-file-prefix
-                       (symbol-name window-system)
-                       "-win")
-               ;; Every window system should have a startup file;
-               ;; barf if we can't find it.
-               nil t))
-    ;; If we can't read it, print the error message and exit.
+    (unless noninteractive
+      (if (and initial-window-system
+              (not (featurep
+                    (intern (concat (symbol-name initial-window-system) 
"-win")))))
+         (error "Unsupported window system `%s'" initial-window-system))
+      ;; Process window-system specific command line parameters.
+      (setq command-line-args
+           (funcall (or (cdr (assq initial-window-system 
handle-args-function-alist))
+                        (error "Unsupported window system `%s'" 
initial-window-system))
+                    command-line-args))
+      ;; Initialize the window system. (Open connection, etc.)
+      (funcall (or (cdr (assq initial-window-system 
window-system-initialization-alist))
+                  (error "Unsupported window system `%s'" 
initial-window-system))))
+    ;; If there was an error, print the error message and exit.
     (error
      (princ
       (if (eq (car error) 'error)
@@ -657,13 +667,9 @@
                              (cdr error) ", "))))
       'external-debugging-output)
      (terpri 'external-debugging-output)
-     (setq window-system nil)
+     (setq initial-window-system nil)
      (kill-emacs)))
 
-  ;; Windowed displays do this inside their *-win.el.
-  (unless (or (display-graphic-p) noninteractive)
-    (setq command-line-args (tty-handle-args command-line-args)))
-
   (set-locale-environment nil)
 
   ;; Convert preloaded file names in load-history to absolute.
@@ -786,7 +792,7 @@
   ;; If frame was created with a menu bar, set menu-bar-mode on.
   (unless (or noninteractive
              emacs-basic-display
-              (and (memq window-system '(x w32))
+              (and (memq initial-window-system '(x w32))
                    (<= (frame-parameter nil 'menu-bar-lines) 0)))
     (menu-bar-mode 1))
 
@@ -800,7 +806,6 @@
   ;; Can't do this init in defcustom because the relevant variables
   ;; are not set.
   (custom-reevaluate-setting 'blink-cursor-mode)
-  (custom-reevaluate-setting 'normal-erase-is-backspace)
   (custom-reevaluate-setting 'tooltip-mode)
   (custom-reevaluate-setting 'global-font-lock-mode)
   (custom-reevaluate-setting 'mouse-wheel-down-event)
@@ -809,13 +814,15 @@
   (custom-reevaluate-setting 'send-mail-function)
   (custom-reevaluate-setting 'focus-follows-mouse)
 
+  (normal-erase-is-backspace-setup-frame)
+
   ;; Register default TTY colors for the case the terminal hasn't a
-  ;; terminal init file.
-  (unless (memq window-system '(x w32 mac))
-    ;; We do this regardles of whether the terminal supports colors
-    ;; or not, since they can switch that support on or off in
-    ;; mid-session by setting the tty-color-mode frame parameter.
-    (tty-register-default-colors))
+  ;; terminal init file.  We do this regardles of whether the terminal
+  ;; supports colors or not and regardless the current display type,
+  ;; since users can connect to color-capable terminals and also
+  ;; switch color support on or off in mid-session by setting the
+  ;; tty-color-mode frame parameter.
+  (tty-register-default-colors)
 
   ;; Record whether the tool-bar is present before the user and site
   ;; init files are processed.  frame-notice-user-settings uses this
@@ -1081,31 +1088,8 @@
   ;; Load library for our terminal type.
   ;; User init file can set term-file-prefix to nil to prevent this.
   (unless (or noninteractive
-              window-system
-              (null term-file-prefix))
-    (let* ((TERM (getenv "TERM"))
-           (term TERM)
-          hyphend)
-      (while (and term
-                  (not (load (concat term-file-prefix term) t t)))
-        ;; Strip off last hyphen and what follows, then try again
-        (setq term
-              (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
-                  (substring term 0 hyphend)
-                nil)))
-      (setq term TERM)
-      ;; The terminal file has been loaded, now call the terminal specific
-      ;; initialization function.
-      (while term
-       (let ((term-init-func (intern-soft (concat "terminal-init-" term))))
-         (if (not (fboundp term-init-func))
-              ;; Strip off last hyphen and what follows, then try again
-              (setq term
-                    (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
-                        (substring term 0 hyphend)
-                      nil))
-            (setq term nil)
-           (funcall term-init-func))))))
+              initial-window-system)
+    (tty-run-terminal-initialization (selected-frame)))
 
   ;; Update the out-of-memory error message based on user's key bindings
   ;; for save-some-buffers.
@@ -1398,7 +1382,7 @@
   "Stop displaying the splash screen buffer."
   (interactive)
   (if fancy-splash-outer-buffer
-      (throw 'exit nil)
+      (throw 'stop-splashing nil)
     (quit-window t)))
 
 (defun fancy-splash-screens (&optional static)
@@ -1433,7 +1417,10 @@
                  (recursive-edit))
              (cancel-timer timer)
              (setq display-hourglass old-hourglass)
-             (kill-buffer splash-buffer)))))
+             (kill-buffer splash-buffer)
+             (when (frame-live-p frame)
+               (select-frame frame)
+               (switch-to-buffer fancy-splash-outer-buffer))))))
     ;; If static is non-nil, don't show fancy splash screen.
     (if (or (window-minibuffer-p)
            (window-dedicated-p (selected-window)))
@@ -1591,7 +1578,7 @@
             ;; use precomputed string to save lots of time.
             (if (and (eq (key-binding "\C-h") 'help-command)
                      (eq (key-binding "\C-xu") 'advertised-undo)
-                     (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
+                    (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
                      (eq (key-binding "\C-ht") 'help-with-tutorial)
                      (eq (key-binding "\C-hi") 'info)
                      (eq (key-binding "\C-hr") 'info-emacs-manual)
@@ -1646,7 +1633,7 @@
                             'action (lambda (button) (view-order-manuals))
                             'follow-link t)
              (insert (substitute-command-keys
-                      "\t   \\[view-order-manuals]\tExit Emacs\t   
\\[save-buffers-kill-emacs]")))
+                      "\t   \\[view-order-manuals]\tExit Emacs\t   
\\[save-buffers-kill-terminal]")))
 
             ;; Say how to use the menu bar with the keyboard.
            (insert "\n")
@@ -1767,11 +1754,9 @@
                   nil ;; (pop-to-buffer (current-buffer))
                (save-window-excursion
                   (switch-to-buffer (current-buffer))
-                 (sit-for 120)))
+                 (sit-for 120))
           (condition-case nil
-              (switch-to-buffer (current-buffer))
-            ;; In case the window is dedicated or something.
-            (error (pop-to-buffer (current-buffer))))))
+                   (switch-to-buffer (current-buffer))))))
       ;; Unwind ... ensure splash buffer is killed
       (if (not static)
          (kill-buffer "*About GNU Emacs*")
@@ -1789,23 +1774,7 @@
 
 (defun display-startup-echo-area-message ()
   (let ((resize-mini-windows t))
-    (message "%s" (startup-echo-area-message))))
-
-
-(defun display-splash-screen (&optional static)
-  "Display splash screen according to display.
-Fancy splash screens are used on graphic displays,
-normal otherwise.
-With a prefix argument, any user input hides the splash screen."
-  (interactive "P")
-  (if (use-fancy-splash-screens-p)
-      (fancy-splash-screens static)
-    (normal-splash-screen static)))
-
-(defalias 'about-emacs 'display-splash-screen)
-
-(defun command-line-1 (command-line-args-left)
-  (or noninteractive (input-pending-p) init-file-had-error
+    (or noninteractive ;(input-pending-p) init-file-had-error
       ;; t if the init file says to inhibit the echo area startup message.
       (and inhibit-startup-echo-area-message
           user-init-file
@@ -1843,7 +1812,25 @@
       ;; display-startup-echo-area-message runs.
       (progn
         (use-fancy-splash-screens-p)
-        (display-startup-echo-area-message)))
+         (message "%s" (startup-echo-area-message))))))
+
+
+(defun display-splash-screen (&optional static)
+  "Display splash screen according to display.
+Fancy splash screens are used on graphic displays,
+normal otherwise.
+With a prefix argument, any user input hides the splash screen."
+  (interactive "P")
+  ;; Prevent recursive calls from server-process-filter.
+  (if (not (get-buffer "*About GNU Emacs*"))
+      (if (use-fancy-splash-screens-p)
+         (fancy-splash-screens static)
+       (normal-splash-screen static))))
+
+(defalias 'about-emacs 'display-splash-screen)
+
+(defun command-line-1 (command-line-args-left)
+  (display-startup-echo-area-message)
 
   ;; Delay 2 seconds after an init file error message
   ;; was displayed, so user can read it.




reply via email to

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