(dired-get-filename)<declare-function>:
[bpt/emacs.git] / lisp / startup.el
index 5d5f23e..1efab62 100644 (file)
@@ -305,7 +305,7 @@ looked for.
 Setting `init-file-user' does not prevent Emacs from loading
 `site-start.el'.  The only way to do that is to use `--no-site-file'.")
 
-(defcustom site-run-file "site-start"
+(defcustom site-run-file (purecopy "site-start")
   "File containing site-wide run-time initializations.
 This file is loaded at run-time before `~/.emacs'.  It contains inits
 that need to be in place for the entire site, but which, due to their
@@ -327,7 +327,7 @@ this variable usefully is to set it while building and dumping Emacs."
   :type '(choice (const :tag "none" nil) string)
   :group 'initialization
   :initialize 'custom-initialize-default
-  :set '(lambda (variable value)
+  :set (lambda (variable value)
          (error "Customizing `site-run-file' does not work")))
 
 (defcustom mail-host-address nil
@@ -366,8 +366,6 @@ from being initialized."
                 string)
   :group 'auto-save)
 
-(defvar emacs-quick-startup nil)
-
 (defvar emacs-basic-display nil)
 
 (defvar init-file-debug nil)
@@ -384,9 +382,9 @@ from being initialized."
 (defvar pure-space-overflow nil
   "Non-nil if building Emacs overflowed pure space.")
 
-(defvar pure-space-overflow-message "\
+(defvar pure-space-overflow-message (purecopy "\
 Warning Warning!!!  Pure space overflow    !!!Warning Warning
-\(See the node Pure Storage in the Lisp manual for details.)\n")
+\(See the node Pure Storage in the Lisp manual for details.)\n"))
 
 (defcustom tutorial-directory
   (file-name-as-directory (expand-file-name "tutorials" data-directory))
@@ -698,10 +696,6 @@ opening the first frame (e.g. open a connection to an X server).")
        after-init-time nil
         command-line-default-directory default-directory)
 
-  ;; Choose a reasonable location for temporary files.
-  (custom-reevaluate-setting 'temporary-file-directory)
-  (custom-reevaluate-setting 'small-temporary-file-directory)
-  (custom-reevaluate-setting 'auto-save-file-name-transforms)
   ;; Force recomputation, in case it was computed during the dump.
   (setq abbreviated-home-dir nil)
 
@@ -731,44 +725,6 @@ opening the first frame (e.g. open a connection to an X server).")
     (setq eol-mnemonic-dos  "(DOS)"
           eol-mnemonic-mac  "(Mac)")))
 
-  ;; Make sure window system's init file was loaded in loadup.el if
-  ;; using a window system.
-  (condition-case error
-    (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)
-         (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)
-     (terpri 'external-debugging-output)
-     (setq initial-window-system nil)
-     (kill-emacs)))
-
   (set-locale-environment nil)
 
   ;; Convert preloaded file names in load-history to absolute.
@@ -841,7 +797,7 @@ opening the first frame (e.g. open a connection to an X server).")
         ((member argi '("-Q" "-quick"))
          (setq init-file-user nil
                site-run-file nil
-               emacs-quick-startup t))
+               inhibit-x-resources t))
         ((member argi '("-D" "-basic-display"))
          (setq no-blinking-cursor t
                emacs-basic-display t)
@@ -873,6 +829,46 @@ opening the first frame (e.g. open a connection to an X server).")
     (and command-line-args
          (setcdr command-line-args args)))
 
+  ;; Make sure window system's init file was loaded in loadup.el if
+  ;; using a window system.
+  ;; Initialize the window-system only after processing the command-line
+  ;; args so that -Q can influence this initialization.
+  (condition-case error
+    (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)
+         (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)
+     (terpri 'external-debugging-output)
+     (setq initial-window-system nil)
+     (kill-emacs)))
+
   (run-hooks 'before-init-hook)
 
   ;; Under X Window, this creates the X frame and deletes the terminal frame.
@@ -914,20 +910,6 @@ opening the first frame (e.g. open a connection to an X server).")
         ;; are dependencies between them.
         (prog1 (nreverse custom-delayed-init-variables)
           (setq custom-delayed-init-variables nil)))
-  
-  ;; Can't do this init in defcustom because the relevant variables
-  ;; are not set.
-  (custom-reevaluate-setting 'blink-cursor-mode)
-  (custom-reevaluate-setting 'tooltip-mode)
-  (custom-reevaluate-setting 'global-font-lock-mode)
-  (custom-reevaluate-setting 'mouse-wheel-down-event)
-  (custom-reevaluate-setting 'mouse-wheel-up-event)
-  (custom-reevaluate-setting 'file-name-shadow-mode)
-  (custom-reevaluate-setting 'send-mail-function)
-  (custom-reevaluate-setting 'focus-follows-mouse)
-  (custom-reevaluate-setting 'global-auto-composition-mode)
-  (custom-reevaluate-setting 'transient-mark-mode)
-  (custom-reevaluate-setting 'auto-encryption-mode)
 
   (normal-erase-is-backspace-setup-frame)
 
@@ -1258,7 +1240,7 @@ If this is nil, no message will be displayed."
 ;;; Fancy splash screen
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defvar fancy-startup-text
+(defconst fancy-startup-text
   '((:face (variable-pitch (:foreground "red"))
      "Welcome to "
      :link ("GNU Emacs"
@@ -1314,7 +1296,7 @@ If this is nil, no message will be displayed."
 Each element in the list should be a list of strings or pairs
 `:face FACE', like `fancy-splash-insert' accepts them.")
 
-(defvar fancy-about-text
+(defconst fancy-about-text
   '((:face (variable-pitch (:foreground "red"))
      "This is "
      :link ("GNU Emacs"
@@ -2058,8 +2040,11 @@ A fancy display is used on graphic displays, normal otherwise."
        first-file-buffer)
     (when command-line-args-left
       ;; We have command args; process them.
-      (let ((dir command-line-default-directory)
-           tem
+      ;; Note that any local variables in this function affect the
+      ;; ability of -f batch-byte-compile to detect free variables.
+      ;; So we give some of them with common names a cl1- prefix.
+      (let ((cl1-dir command-line-default-directory)
+           cl1-tem
            ;; This approach loses for "-batch -L DIR --eval "(require foo)",
            ;; if foo is intended to be found in DIR.
            ;;
@@ -2082,8 +2067,8 @@ A fancy display is used on graphic displays, normal otherwise."
                      "--find-file" "--visit" "--file" "--no-desktop")
                    (mapcar (lambda (elt) (concat "-" (car elt)))
                             command-switch-alist)))
-           (line 0)
-           (column 0))
+           (cl1-line 0)
+           (cl1-column 0))
 
        ;; Add the long X options to longopts.
        (dolist (tem command-line-x-option-alist)
@@ -2124,12 +2109,12 @@ A fancy display is used on graphic displays, normal otherwise."
                          argi orig-argi)))))
 
            ;; Execute the option.
-           (cond ((setq tem (assoc argi command-switch-alist))
+           (cond ((setq cl1-tem (assoc argi command-switch-alist))
                   (if argval
                       (let ((command-line-args-left
                              (cons argval command-line-args-left)))
-                        (funcall (cdr tem) argi))
-                    (funcall (cdr tem) argi)))
+                        (funcall (cdr cl1-tem) argi))
+                    (funcall (cdr cl1-tem) argi)))
 
                  ((equal argi "-no-splash")
                   (setq inhibit-startup-screen t))
@@ -2138,22 +2123,22 @@ A fancy display is used on graphic displays, normal otherwise."
                                  "-funcall"
                                  "-e"))  ; what the source used to say
                   (setq inhibit-startup-screen t)
-                  (setq tem (intern (or argval (pop command-line-args-left))))
-                  (if (commandp tem)
-                      (command-execute tem)
-                    (funcall tem)))
+                  (setq cl1-tem (intern (or argval (pop command-line-args-left))))
+                  (if (commandp cl1-tem)
+                      (command-execute cl1-tem)
+                    (funcall cl1-tem)))
 
                  ((member argi '("-eval" "-execute"))
                   (setq inhibit-startup-screen t)
                   (eval (read (or argval (pop command-line-args-left)))))
 
                  ((member argi '("-L" "-directory"))
-                  (setq tem (expand-file-name
+                  (setq cl1-tem (expand-file-name
                              (command-line-normalize-file-name
                               (or argval (pop command-line-args-left)))))
-                  (cond (splice (setcdr splice (cons tem (cdr splice)))
+                  (cond (splice (setcdr splice (cons cl1-tem (cdr splice)))
                                 (setq splice (cdr splice)))
-                        (t (setq load-path (cons tem load-path)
+                        (t (setq load-path (cons cl1-tem load-path)
                                  splice load-path))))
 
                  ((member argi '("-l" "-load"))
@@ -2177,10 +2162,10 @@ A fancy display is used on graphic displays, normal otherwise."
 
                  ((equal argi "-insert")
                   (setq inhibit-startup-screen t)
-                  (setq tem (or argval (pop command-line-args-left)))
-                  (or (stringp tem)
+                  (setq cl1-tem (or argval (pop command-line-args-left)))
+                  (or (stringp cl1-tem)
                       (error "File name omitted from `-insert' option"))
-                  (insert-file-contents (command-line-normalize-file-name tem)))
+                  (insert-file-contents (command-line-normalize-file-name cl1-tem)))
 
                  ((equal argi "-kill")
                   (kill-emacs t))
@@ -2193,41 +2178,42 @@ A fancy display is used on graphic displays, normal otherwise."
                   (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
 
                  ((string-match "^\\+[0-9]+\\'" argi)
-                  (setq line (string-to-number argi)))
+                  (setq cl1-line (string-to-number argi)))
 
                  ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
-                  (setq line (string-to-number (match-string 1 argi))
-                        column (string-to-number (match-string 2 argi))))
+                  (setq cl1-line (string-to-number (match-string 1 argi))
+                        cl1-column (string-to-number (match-string 2 argi))))
 
-                 ((setq tem (assoc argi command-line-x-option-alist))
+                 ((setq cl1-tem (assoc argi command-line-x-option-alist))
                   ;; Ignore X-windows options and their args if not using X.
                   (setq command-line-args-left
-                        (nthcdr (nth 1 tem) command-line-args-left)))
+                        (nthcdr (nth 1 cl1-tem) command-line-args-left)))
 
-                 ((setq tem (assoc argi command-line-ns-option-alist))
+                 ((setq cl1-tem (assoc argi command-line-ns-option-alist))
                   ;; Ignore NS-windows options and their args if not using NS.
                   (setq command-line-args-left
-                        (nthcdr (nth 1 tem) command-line-args-left)))
+                        (nthcdr (nth 1 cl1-tem) command-line-args-left)))
 
                  ((member argi '("-find-file" "-file" "-visit"))
                   (setq inhibit-startup-screen t)
                   ;; An explicit option to specify visiting a file.
-                  (setq tem (or argval (pop command-line-args-left)))
-                  (unless (stringp tem)
+                  (setq cl1-tem (or argval (pop command-line-args-left)))
+                  (unless (stringp cl1-tem)
                     (error "File name omitted from `%s' option" argi))
                   (setq file-count (1+ file-count))
                   (let ((file (expand-file-name
-                               (command-line-normalize-file-name tem) dir)))
+                               (command-line-normalize-file-name cl1-tem)
+                               cl1-dir)))
                     (if (= file-count 1)
                         (setq first-file-buffer (find-file file))
                       (find-file-other-window file)))
-                  (unless (zerop line)
+                  (unless (zerop cl1-line)
                     (goto-char (point-min))
-                    (forward-line (1- line)))
-                  (setq line 0)
-                  (unless (< column 1)
-                    (move-to-column (1- column)))
-                  (setq column 0))
+                    (forward-line (1- cl1-line)))
+                  (setq cl1-line 0)
+                  (unless (< cl1-column 1)
+                    (move-to-column (1- cl1-column)))
+                  (setq cl1-column 0))
 
                  ((equal argi "--")
                   (setq just-files t))
@@ -2250,19 +2236,19 @@ A fancy display is used on graphic displays, normal otherwise."
                           (let ((file
                                  (expand-file-name
                                   (command-line-normalize-file-name orig-argi)
-                                  dir)))
+                                  cl1-dir)))
                             (cond ((= file-count 1)
                                    (setq first-file-buffer (find-file file)))
                                   (inhibit-startup-screen
                                    (find-file-other-window file))
                                   (t (find-file file))))
-                          (unless (zerop line)
+                          (unless (zerop cl1-line)
                             (goto-char (point-min))
-                            (forward-line (1- line)))
-                          (setq line 0)
-                          (unless (< column 1)
-                            (move-to-column (1- column)))
-                          (setq column 0))))))
+                            (forward-line (1- cl1-line)))
+                          (setq cl1-line 0)
+                          (unless (< cl1-column 1)
+                            (move-to-column (1- cl1-column)))
+                          (setq cl1-column 0))))))
            ;; In unusual circumstances, the execution of Lisp code due
            ;; to command-line options can cause the last visible frame
            ;; to be deleted.  In this case, kill emacs to avoid an
@@ -2286,7 +2272,7 @@ A fancy display is used on graphic displays, normal otherwise."
     (if (or inhibit-startup-screen
            initial-buffer-choice
            noninteractive
-           emacs-quick-startup)
+           inhibit-x-resources)
 
        ;; Not displaying a startup screen.  If 3 or more files
        ;; visited, and not all visible, show user what they all are.