* bitmaps/README:
[bpt/emacs.git] / lisp / startup.el
index 5013da4..dd38767 100644 (file)
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -184,6 +182,72 @@ FRAME-PARAM (optional) is the frame parameter this option specifies,
 and VALUE is the value which is given to that frame parameter
 \(most options use the argument for this, so VALUE is not present).")
 
+(defconst command-line-ns-option-alist
+  '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
+    ("-NXAutoLaunch" 1 ns-ignore-1-arg)
+    ("-macosx" 0 ns-ignore-0-arg)
+    ("-NSHost" 1 ns-ignore-1-arg)
+    ("-_NSMachLaunch" 1 ns-ignore-1-arg)
+    ("-MachLaunch" 1 ns-ignore-1-arg)
+    ("-NXOpen" 1 ns-ignore-1-arg)
+    ("-NSOpen" 1 ns-handle-nxopen)
+    ("-NXOpenTemp" 1 ns-ignore-1-arg)
+    ("-NSOpenTemp" 1 ns-handle-nxopentemp)
+    ("-GSFilePath" 1 ns-handle-nxopen)
+    ;;("-bw" .              x-handle-numeric-switch)
+    ;;("-d" .               x-handle-display)
+    ;;("-display" .         x-handle-display)
+    ("-name" 1 ns-handle-name-switch)
+    ("-title" 1 ns-handle-switch title)
+    ("-T" 1 ns-handle-switch title)
+    ("-r" 0 ns-handle-switch reverse t)
+    ("-rv" 0 ns-handle-switch reverse t)
+    ("-reverse" 0 ns-handle-switch reverse t)
+    ("-fn" 1 ns-handle-switch font)
+    ("-font" 1 ns-handle-switch font)
+    ("-ib" 1 ns-handle-numeric-switch internal-border-width)
+    ;;("-g" .               x-handle-geometry)
+    ;;("-geometry" .        x-handle-geometry)
+    ("-fg" 1 ns-handle-switch foreground-color)
+    ("-foreground" 1 ns-handle-switch foreground-color)
+    ("-bg" 1 ns-handle-switch background-color)
+    ("-background" 1 ns-handle-switch background-color)
+;    ("-ms" 1 ns-handle-switch mouse-color)
+    ("-itype" 0 ns-handle-switch icon-type t)
+    ("-i" 0 ns-handle-switch icon-type t)
+    ("-iconic" 0 ns-handle-iconic icon-type t)
+    ;;("-xrm" .             x-handle-xrm-switch)
+    ("-cr" 1 ns-handle-switch cursor-color)
+    ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
+    ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
+    ("-bd" 1 ns-handle-switch) 
+    ;; ("--border-width" 1 ns-handle-numeric-switch border-width) 
+    ;; ("--display" 1 ns-handle-display)
+    ("--name" 1 ns-handle-name-switch)
+    ("--title" 1 ns-handle-switch title)
+    ("--reverse-video" 0 ns-handle-switch reverse t)
+    ("--font" 1 ns-handle-switch font)
+    ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
+    ;; ("--geometry" 1 ns-handle-geometry)
+    ("--foreground-color" 1 ns-handle-switch foreground-color)
+    ("--background-color" 1 ns-handle-switch background-color)
+    ("--mouse-color" 1 ns-handle-switch mouse-color)
+    ("--icon-type" 0 ns-handle-switch icon-type t)
+    ("--iconic" 0 ns-handle-iconic)
+    ;; ("--xrm" 1 ns-handle-xrm-switch)
+    ("--cursor-color" 1 ns-handle-switch cursor-color)
+    ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
+    ("--border-color" 1 ns-handle-switch border-width))
+  "Alist of NS options.
+Each element has the form
+  (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
+where NAME is the option name string, NUMARGS is the number of arguments
+that the option accepts, HANDLER is a function to call to handle the option.
+FRAME-PARAM (optional) is the frame parameter this option specifies,
+and VALUE is the value which is given to that frame parameter
+\(most options use the argument for this, so VALUE is not present).")
+
+
 (defvar before-init-hook nil
   "Normal hook run after handling urgent options but before loading init files.")
 
@@ -398,10 +462,12 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
   (if command-line-processed
       (message "Back to top level.")
     (setq command-line-processed t)
-    ;; Give *Messages* the same default-directory as *scratch*,
-    ;; just to keep things predictable.
     (let ((dir default-directory))
       (with-current-buffer "*Messages*"
+        ;; Make it easy to do like "tail -f".
+        (set (make-local-variable 'window-point-insertion-type) t)
+        ;; Give *Messages* the same default-directory as *scratch*,
+        ;; just to keep things predictable.
        (setq default-directory dir)))
     ;; `user-full-name' is now known; reset its standard-value here.
     (put 'user-full-name 'standard-value
@@ -425,20 +491,19 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
         ;; the end, because the subdirs.el files may add elements to the end
         ;; of load-path and we want to take it into account.
         (setq tail (cdr tail))))
-    (unless (eq system-type 'vax-vms)
-      ;; If the PWD environment variable isn't accurate, delete it.
-      (let ((pwd (getenv "PWD")))
-       (and (stringp pwd)
-            ;; Use FOO/., so that if FOO is a symlink, file-attributes
-            ;; describes the directory linked to, not FOO itself.
-            (or (equal (file-attributes
-                        (concat (file-name-as-directory pwd) "."))
-                       (file-attributes
-                        (concat (file-name-as-directory default-directory)
-                                ".")))
-                (setq process-environment
-                      (delete (concat "PWD=" pwd)
-                              process-environment))))))
+    ;; If the PWD environment variable isn't accurate, delete it.
+    (let ((pwd (getenv "PWD")))
+      (and (stringp pwd)
+          ;; Use FOO/., so that if FOO is a symlink, file-attributes
+          ;; describes the directory linked to, not FOO itself.
+          (or (equal (file-attributes
+                      (concat (file-name-as-directory pwd) "."))
+                     (file-attributes
+                      (concat (file-name-as-directory default-directory)
+                              ".")))
+              (setq process-environment
+                    (delete (concat "PWD=" pwd)
+                            process-environment)))))
     (setq default-directory (abbreviate-file-name default-directory))
     (let ((menubar-bindings-done nil))
       (unwind-protect
@@ -629,6 +694,10 @@ opening the first frame (e.g. open a connection to an X server).")
                (push argi rest)))))
     (nreverse rest)))
 
+(declare-function x-get-resource "frame.c"
+                 (attribute class &optional component subclass))
+(declare-function tool-bar-mode "tool-bar" (&optional arg))
+
 (defun command-line ()
   (setq before-init-time (current-time)
         command-line-default-directory default-directory)
@@ -816,7 +885,7 @@ opening the first frame (e.g. open a connection to an X server).")
   ;; only because all other settings of no-blinking-cursor are here.
   (unless (or noninteractive
              emacs-basic-display
-             (and (memq window-system '(x w32 mac))
+             (and (memq window-system '(x w32 ns))
                   (not (member (x-get-resource "cursorBlink" "CursorBlink")
                                '("off" "false")))))
     (setq no-blinking-cursor t))
@@ -847,6 +916,7 @@ opening the first frame (e.g. open a connection to an X server).")
   (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)
 
@@ -936,8 +1006,6 @@ opening the first frame (e.g. open a connection to an X server).")
                                   "~/_emacs"
                                 ;; But default to .emacs if _emacs does not exist.
                                 "~/.emacs")))
-                           ((eq system-type 'vax-vms)
-                            "sys$login:.emacs")
                            (t
                             (concat "~" init-file-user "/.emacs")))))
                      ;; This tells `load' to store the file name found
@@ -995,8 +1063,7 @@ opening the first frame (e.g. open a connection to an X server).")
                (setq init-file-had-error nil))
            (error
             (let ((message-log-max nil))
-              (save-excursion
-                (set-buffer (get-buffer-create "*Messages*"))
+              (with-current-buffer (get-buffer-create "*Messages*")
                 (insert "\n\n"
                         (format "An error has occurred while loading `%s':\n\n"
                                 user-init-file)
@@ -1179,10 +1246,7 @@ If this is nil, no message will be displayed."
             "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
         '("GNU" (lambda (button) (describe-gnu-project))
           "Display info on the GNU project")))
-     " operating system.\n"
-     :face variable-pitch "To quit a partially entered command, type "
-     :face default "Control-g"
-     :face variable-pitch ".\n\n"
+     " operating system.\n\n"
      :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
      "\tLearn basic keystroke commands"
      (lambda ()
@@ -1206,7 +1270,7 @@ If this is nil, no message will be displayed."
      :link ("Emacs Guided Tour"
            (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
            "Browse http://www.gnu.org/software/emacs/tour/")
-     "\tOverview of Emacs features\n"
+     "\tOverview of Emacs features at gnu.org\n"
      :link ("View Emacs Manual" (lambda (button) (info-emacs-manual)))
      "\tView the Emacs manual using Info\n"
      :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
@@ -1247,7 +1311,7 @@ Each element in the list should be a list of strings or pairs
      "\n"
      (lambda () (emacs-version))
      "\n"
-     :face (variable-pitch (:height 0.5))
+     :face (variable-pitch (:height 0.8))
      (lambda () emacs-copyright)
      "\n\n"
      :face variable-pitch
@@ -1365,18 +1429,25 @@ a face or button specification."
                                   'help-echo (startup-echo-area-message)))))
       (setq args (cdr args)))))
 
+(declare-function image-size "image.c" (spec &optional pixels frame))
 
 (defun fancy-splash-head ()
   "Insert the head part of the splash screen into the current buffer."
   (let* ((image-file (cond ((stringp fancy-splash-image)
                            fancy-splash-image)
-                          ((and (display-color-p)
-                                (image-type-available-p 'xpm))
-                            (if (and (fboundp 'x-display-planes)
-                                     (= (funcall 'x-display-planes) 8))
-                                "splash8.xpm"
-                              "splash.xpm"))
-                            (t "splash.pbm")))
+                          ((display-color-p)
+                           (cond ((<= (display-planes) 8)
+                                  (if (image-type-available-p 'xpm)
+                                      "splash.xpm"
+                                    "splash.pbm"))
+                                 ((image-type-available-p 'svg)
+                                  "splash.svg")
+                                 ((image-type-available-p 'png)
+                                  "splash.png")
+                                 ((image-type-available-p 'xpm)
+                                  "splash.xpm")
+                                 (t "splash.pbm")))
+                          (t "splash.pbm")))
         (img (create-image image-file))
         (image-width (and img (car (image-size img))))
         (window-width (window-width (selected-window))))
@@ -1420,11 +1491,15 @@ a face or button specification."
               (lambda (button) (customize-group 'initialization))
               "Change initialization settings including this screen")
        "\n"))
+    (fancy-splash-insert
+     :face 'variable-pitch "To quit a partially entered command, type "
+     :face 'default "Control-g"
+     :face 'variable-pitch ".\n")
     (fancy-splash-insert :face `(variable-pitch (:foreground ,fg))
                         "\nThis is "
                         (emacs-version)
                         "\n"
-                        :face '(variable-pitch (:height 0.5))
+                        :face '(variable-pitch (:height 0.8))
                         emacs-copyright
                         "\n")
     (and auto-save-list-file-prefix
@@ -2012,6 +2087,11 @@ A fancy display is used on graphic displays, normal otherwise."
          (if (string-match "^--" (car tem))
              (push (list (car tem)) longopts)))
 
+       ;; Add the long NS options to longopts.
+       (dolist (tem command-line-ns-option-alist)
+         (if (string-match "^--" (car tem))
+             (push (list (car tem)) longopts)))
+
        ;; Loop, processing options.
        (while command-line-args-left
          (let* ((argi (car command-line-args-left))
@@ -2086,7 +2166,7 @@ A fancy display is used on graphic displays, normal otherwise."
 
                  ;; This is used to handle -script.  It's not clear
                  ;; we need to document it (it is totally internal).
-                 ((member argi '("-internal-script"))
+                 ((member argi '("-scriptload"))
                   (let* ((file (command-line-normalize-file-name
                                 (or argval (pop command-line-args-left))))
                          ;; Take file from default dir.
@@ -2122,6 +2202,11 @@ A fancy display is used on graphic displays, normal otherwise."
                   (setq command-line-args-left
                         (nthcdr (nth 1 tem) command-line-args-left)))
 
+                 ((setq 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)))
+
                  ((member argi '("-find-file" "-file" "-visit"))
                   (setq inhibit-startup-screen t)
                   ;; An explicit option to specify visiting a file.