Major rewrite to behave more like a minor mode.
[bpt/emacs.git] / lisp / startup.el
index a31aa73..4de390c 100644 (file)
@@ -246,13 +246,31 @@ specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
   ;;! (setq split-window-keep-point (> baud-rate 2400))
 
   ;; Read window system's init file if using a window system.
-  (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))
+  (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.
+    (error
+     (princ
+      (if (eq (car error) 'error)
+         (apply 'concat (cdr error))
+       (if (memq 'file-error (get (car error) 'error-conditions))
+           (format "%s: %s"
+                    (nth 1 error)
+                    (mapconcat '(lambda (obj) (prin1-to-string obj t))
+                               (cdr (cdr error)) ", "))
+         (format "%s: %s"
+                  (get (car error) 'error-message)
+                  (mapconcat '(lambda (obj) (prin1-to-string obj t))
+                             (cdr error) ", "))))
+      'external-debugging-output)
+     (setq window-system nil)
+     (kill-emacs)))
 
   (let ((done nil)
        (args (cdr command-line-args)))
@@ -295,6 +313,10 @@ specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
       (face-initialize))
   (if (fboundp 'frame-initialize)
       (frame-initialize))
+  ;; If frame was created with a menu bar, set menu-bar-mode on.
+  (if (and (eq window-system 'x)
+          (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
+      (menu-bar-mode t))
 
   (run-hooks 'before-init-hook)