]> code.delx.au - gnu-emacs/blobdiff - lisp/startup.el
Disable scrollbars until fully functional.
[gnu-emacs] / lisp / startup.el
index 772d619f8893aff3530409670a0be58c38f9f481..86ded247979cb0c12eedcba927b635c2d44b5fde 100644 (file)
@@ -223,12 +223,17 @@ specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
   "*Name of this machine, for purposes of naming users.")
 
 (defvar user-mail-address nil
-  "*Full mailing address of this user.")
+  "*Full mailing address of this user.
+This is initialized based on `mail-host-address',
+after your init file is read, in case it sets `mail-host-address'.")
 
 (defvar auto-save-list-file-prefix "~/.saves-"
-  "Prefix for generating auto-save-list-file-name.
-Emacs's pid and the system name will be appended to
-this prefix to create a unique file name.")
+  "Prefix for generating `auto-save-list-file-name'.
+This is used after reading your `.emacs' file to initialize
+`auto-save-list-file-name', by appending Emacs's pid and the system name,
+if you have not already set `auto-save-list-file-name' yourself.
+Set this to nil if you want to prevent `auto-save-list-file-name'
+from being initialized.")
 
 (defvar init-file-debug nil)
 
@@ -275,22 +280,21 @@ this prefix to create a unique file name.")
                           (delete (concat "PWD=" pwd)
                                   process-environment)))))))
     (setq default-directory (abbreviate-file-name default-directory))
-    (setq user-mail-address (concat (user-login-name) "@"
-                                   (or mail-host-address
-                                       (system-name))))
-    ;; Specify the file for recording all the auto save files of this session.
-    ;; This is used by recover-session.
-    (setq auto-save-list-file-name
-         (expand-file-name
-          (format "%s%d-%s"
-                  auto-save-list-file-prefix
-                  (emacs-pid)
-                  (system-name))))
     (let ((menubar-bindings-done nil))
       (unwind-protect
          (command-line)
        ;; Do this again, in case .emacs defined more abbreviations.
        (setq default-directory (abbreviate-file-name default-directory))
+       ;; Specify the file for recording all the auto save files of this session.
+       ;; This is used by recover-session.
+       (or auto-save-list-file-name
+           (and auto-save-list-file-prefix
+                (setq auto-save-list-file-name
+                      (expand-file-name
+                       (format "%s%d-%s"
+                               auto-save-list-file-prefix
+                               (emacs-pid)
+                               (system-name))))))
        (run-hooks 'emacs-startup-hook)
        (and term-setup-hook
             (run-hooks 'term-setup-hook))
@@ -304,7 +308,7 @@ this prefix to create a unique file name.")
        (and window-setup-hook
             (run-hooks 'window-setup-hook))
        (or menubar-bindings-done
-           (if (eq window-system 'x)
+           (if (or (eq window-system 'x) (eq window-system 'win32))
                (precompute-menubar-bindings)))))))
 
 ;; Precompute the keyboard equivalents in the menu bar items.
@@ -404,7 +408,9 @@ this prefix to create a unique file name.")
                        ("--debug-init") ("--iconic") ("--icon-type")))
            (argi (car args))
            (argval nil))
-       (if (string-match "=" argi)
+       ;; Handle --OPTION=VALUE format.
+       (if (and (string-match "\\`--" argi)
+                (string-match "=" argi))
            (setq argval (substring argi (match-end 0))
                  argi (substring argi 0 (match-beginning 0))))
        (let ((completion (try-completion argi longopts)))
@@ -459,8 +465,8 @@ this prefix to create a unique file name.")
   (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))
+  (if (or (not (or (eq window-system 'x) (eq window-system 'win32)))
+         (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
       (menu-bar-mode t))
 
   (run-hooks 'before-init-hook)
@@ -525,6 +531,12 @@ this prefix to create a unique file name.")
     (if debug-on-error-should-be-set
        (setq debug-on-error debug-on-error-from-init-file)))
 
+  ;; Do this here in case the init file sets mail-host-address.
+  (or user-mail-address
+      (setq user-mail-address (concat (user-login-name) "@"
+                                     (or mail-host-address
+                                         (system-name)))))
+
   (run-hooks 'after-init-hook)
 
   ;; If *scratch* exists and init file didn't change its mode, initialize it.
@@ -603,14 +615,17 @@ this prefix to create a unique file name.")
             (setq window-setup-hook nil)
             ;; Do this now to avoid an annoying delay if the user
             ;; clicks the menu bar during the sit-for.
-            (if (eq window-system 'x)
+            (if (or (eq window-system 'x) (eq window-system 'win32))
                 (precompute-menubar-bindings))
             (setq menubar-bindings-done t)
             (unwind-protect
                 (progn
+                  ;; The convention for this piece of code is that
+                  ;; each piece of output starts with one or two newlines
+                  ;; and does not end with any newlines.
                   (insert (emacs-version)
                           "
-Copyright (C) 1995 Free Software Foundation, Inc.\n\n")
+Copyright (C) 1995 Free Software Foundation, Inc.")
                   ;; If keys have their default meanings,
                   ;; use precomputed string to save lots of time.
                   (if (and (eq (key-binding "\C-h") 'help-command)
@@ -618,13 +633,14 @@ Copyright (C) 1995 Free Software Foundation, Inc.\n\n")
                            (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
                            (eq (key-binding "\C-ht") 'help-with-tutorial)
                            (eq (key-binding "\C-hi") 'info))
-                      (insert 
-       "Type C-h for help; C-x u to undo changes.  (`C-' means use CTRL key.)
+                      (insert "\n
+Type C-h for help; C-x u to undo changes.  (`C-' means use CTRL key.)
 To kill the Emacs job, type C-x C-c.
 Type C-h t for a tutorial on using Emacs.
 Type C-h i to enter Info, which you can use to read GNU documentation.")
                     (insert (substitute-command-keys
-                             (format "Type %s for help; \\[advertised-undo] to undo changes.  (`C-' means use CTRL key.)
+                             (format "\n
+Type %s for help; \\[advertised-undo] to undo changes.  (`C-' means use CTRL key.)
 To kill the Emacs job, type \\[save-buffers-kill-emacs].
 Type \\[help-with-tutorial] for a tutorial on using Emacs.
 Type \\[info] to enter Info, which you can use to read GNU documentation."
@@ -633,33 +649,45 @@ Type \\[info] to enter Info, which you can use to read GNU documentation."
                                        (if where
                                            (key-description where)
                                          "M-x help"))))))
+                  ;; Say how to use the menu bar
+                  ;; if that is not with the mouse.
+                  (if (not (assq 'display (frame-parameters)))
+                      (if (eq (key-binding "\M-`") 'tmm-menubar)
+                          (insert "\n\nType F10, ESC ` or Meta-` to use the menu bar.")
+                        (insert (substitute-command-keys
+                                 "\n\nType \\[tmm-menubar] to use the menu bar."))))
 
                   ;; Windows and MSDOS (currently) do not count as
                   ;; window systems, but do have mouse support.
                   (if (or (memq system-type '(msdos windowsnt))
                           window-system)
-                      (insert "
+                      (insert "\n
 C-mouse-3 (third mouse button, with Control) gets a mode-specific menu."))
-                  (insert "\n")
+                  (if (directory-files (file-name-directory auto-save-list-file-prefix)
+                                       nil
+                                       (concat "\\`"
+                                               (regexp-quote
+                                                (file-name-nondirectory
+                                                 auto-save-list-file-prefix)))
+                                       t)
+                      (insert "\n\nIf an Emacs session crashed recently,\n"
+                              "type M-x recover-session RET to recover"
+                              " the files you were editing."))
+
                   (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
                            (eq (key-binding "\C-h\C-d") 'describe-distribution)
                            (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
                       (insert 
-                       "
+                       "\n
 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
 You may give out copies of Emacs; type C-h C-c to see the conditions.
 Type C-h C-d for information on getting the latest version.")
                     (insert (substitute-command-keys
-                             "
+                             "\n
 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
 You may give out copies of Emacs; type \\[describe-copying] to see the conditions.
 Type \\[describe-distribution] for information on getting the latest version.")))
 
-                  (if (directory-files "~/" nil "\\`\\.saves-" t)
-                      (insert "\n\nIf an Emacs session crashed recently,\n"
-                              "type M-x recover-session RET to recover"
-                              " the files you were editing."))
-
                   (set-buffer-modified-p nil)
                   (sit-for 120))
               (save-excursion
@@ -778,6 +806,8 @@ Type \\[describe-distribution] for information on getting the latest version."))
                   (if (not did-hook)
                       ;; Ok, presume that the argument is a file name
                       (progn
+                        (if (string-match "\\`-" argi)
+                            (error "Unknown option `%s'" argi))
                         (setq file-count (1+ file-count))
                         (cond ((= file-count 1)
                                (setq first-file-buffer