aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Swift2003-02-26 10:59:58 +0000
committerMatthew Swift2003-02-26 10:59:58 +0000
commitbca8c7be06fe0f6143a8e17d589760715386e4cc (patch)
tree81e77bb40cf1d9aa1a650c0fa4cf2a6ed0787b5a
parentf9d56d59976d420ff924f52f557e03ee32570785 (diff)
downloademacs-bca8c7be06fe0f6143a8e17d589760715386e4cc.tar.gz
emacs-bca8c7be06fe0f6143a8e17d589760715386e4cc.zip
* startup.el: Streamline code in several functions and use a more
consistent idiom within the file, for ease of reading and maintenance. Rephrase booleans to avoid `(not noninteractive)'. Clarify several booleans expressions using De Morgan's laws. (command-line): Fix barf when first command-line option handled by `command-line-1' is in the form --OPT=VAL. (command-line-1): Restore intended behavior of the --directory/-L command-line option: "-L a -L b -L c" on the command-line now puts '(a b c) at the front of `load-path'.
-rw-r--r--lisp/startup.el665
1 files changed, 323 insertions, 342 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 51ec459175c..e4310533647 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -580,81 +580,71 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
580(defvar tool-bar-originally-present nil 580(defvar tool-bar-originally-present nil
581 "Non-nil if tool-bars are present before user and site init files are read.") 581 "Non-nil if tool-bars are present before user and site init files are read.")
582 582
583;; Handle the X-like command line parameters "-fg", "-bg", "-name", etc. 583;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
584(defun tty-handle-args (args) 584(defun tty-handle-args (args)
585 (let ((rest nil)) 585 (let (rest)
586 (message "%s" args) 586 (message "%s" args)
587 (while (and args 587 (while (and args
588 (not (equal (car args) "--"))) 588 (not (equal (car args) "--")))
589 (let* ((this (car args)) 589 (let* ((argi (pop args))
590 (orig-this this) 590 (orig-argi argi)
591 completion argval) 591 argval completion)
592 (setq args (cdr args))
593 ;; Check for long options with attached arguments 592 ;; Check for long options with attached arguments
594 ;; and separate out the attached option argument into argval. 593 ;; and separate out the attached option argument into argval.
595 (if (string-match "^--[^=]*=" this) 594 (when (string-match "^\\(--[^=]*\\)=" argi)
596 (setq argval (substring this (match-end 0)) 595 (setq argval (substring argi (match-end 0))
597 this (substring this 0 (1- (match-end 0))))) 596 argi (match-string 1 argi)))
598 (when (string-match "^--" this) 597 (when (string-match "^--" argi)
599 (setq completion (try-completion this tty-long-option-alist)) 598 (setq completion (try-completion argi tty-long-option-alist))
600 (if (eq completion t) 599 (if (eq completion t)
601 ;; Exact match for long option. 600 ;; Exact match for long option.
602 (setq this (cdr (assoc this tty-long-option-alist))) 601 (setq argi (cdr (assoc argi tty-long-option-alist)))
603 (if (stringp completion) 602 (if (stringp completion)
604 (let ((elt (assoc completion tty-long-option-alist))) 603 (let ((elt (assoc completion tty-long-option-alist)))
605 ;; Check for abbreviated long option. 604 ;; Check for abbreviated long option.
606 (or elt 605 (or elt
607 (error "Option `%s' is ambiguous" this)) 606 (error "Option `%s' is ambiguous" argi))
608 (setq this (cdr elt))) 607 (setq argi (cdr elt)))
609 ;; Check for a short option. 608 ;; Check for a short option.
610 (setq argval nil this orig-this)))) 609 (setq argval nil
611 (cond ((or (string= this "-fg") (string= this "-foreground")) 610 argi orig-argi))))
612 (or argval (setq argval (car args) args (cdr args))) 611 (cond ((member argi '("-fg" "-foreground"))
613 (setq default-frame-alist 612 (push (cons 'foreground-color (or argval (pop args)))
614 (cons (cons 'foreground-color argval) 613 default-frame-alist))
615 default-frame-alist))) 614 ((member argi '("-bg" "-background"))
616 ((or (string= this "-bg") (string= this "-background")) 615 (push (cons 'background-color (or argval (pop args)))
617 (or argval (setq argval (car args) args (cdr args))) 616 default-frame-alist))
618 (setq default-frame-alist 617 ((member argi '("-T" "-name"))
619 (cons (cons 'background-color argval) 618 (unless argval (setq argval (pop args)))
620 default-frame-alist))) 619 (push (cons 'title
621 ((or (string= this "-T") (string= this "-name")) 620 (if (stringp argval)
622 (or argval (setq argval (car args) args (cdr args))) 621 argval
623 (setq default-frame-alist 622 (let ((case-fold-search t)
624 (cons 623 i)
625 (cons 'title 624 (setq argval (invocation-name))
626 (if (stringp argval) 625
627 argval 626 ;; Change any . or * characters in name to
628 (let ((case-fold-search t) 627 ;; hyphens, so as to emulate behavior on X.
629 i) 628 (while
630 (setq argval (invocation-name)) 629 (setq i (string-match "[.*]" argval))
631 630 (aset argval i ?-))
632 ;; Change any . or * characters in name to 631 argval)))
633 ;; hyphens, so as to emulate behavior on X. 632 default-frame-alist))
634 (while 633 ((member argi '("-r" "-rv" "-reverse"))
635 (setq i (string-match "[.*]" argval)) 634 (push '(reverse . t)
636 (aset argval i ?-)) 635 default-frame-alist))
637 argval))) 636 ((equal argi "-color")
638 default-frame-alist))) 637 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
639 ((or (string= this "-r") 638 (push (cons 'tty-color-mode
640 (string= this "-rv") 639 (cond
641 (string= this "-reverse")) 640 ((numberp argval) argval)
642 (setq default-frame-alist 641 ((string-match "-?[0-9]+" argval)
643 (cons '(reverse . t) 642 (string-to-number argval))
644 default-frame-alist))) 643 (t (intern argval))))
645 ((string= this "-color") 644 default-frame-alist))
646 (if (null argval) 645 (t
647 (setq argval 8)) ; default --color means 8 ANSI colors 646 (push argi rest)))))
648 (setq default-frame-alist 647 (nreverse rest)))
649 (cons (cons 'tty-color-mode
650 (cond
651 ((numberp argval) argval)
652 ((string-match "-?[0-9]+" argval)
653 (string-to-number argval))
654 (t (intern argval))))
655 default-frame-alist)))
656 (t (setq rest (cons this rest))))))
657 (nreverse rest)))
658 648
659(defun command-line () 649(defun command-line ()
660 (setq command-line-default-directory default-directory) 650 (setq command-line-default-directory default-directory)
@@ -680,14 +670,11 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
680 ;; See if we should import version-control from the environment variable. 670 ;; See if we should import version-control from the environment variable.
681 (let ((vc (getenv "VERSION_CONTROL"))) 671 (let ((vc (getenv "VERSION_CONTROL")))
682 (cond ((eq vc nil)) ;don't do anything if not set 672 (cond ((eq vc nil)) ;don't do anything if not set
683 ((or (string= vc "t") 673 ((member vc '("t" "numbered"))
684 (string= vc "numbered"))
685 (setq version-control t)) 674 (setq version-control t))
686 ((or (string= vc "nil") 675 ((member vc '("nil" "existing"))
687 (string= vc "existing"))
688 (setq version-control nil)) 676 (setq version-control nil))
689 ((or (string= vc "never") 677 ((member vc '("never" "simple"))
690 (string= vc "simple"))
691 (setq version-control 'never)))) 678 (setq version-control 'never))))
692 679
693 ;;! This has been commented out; I currently find the behavior when 680 ;;! This has been commented out; I currently find the behavior when
@@ -700,15 +687,15 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
700 ;; end-of-line formats that aren't native to this platform. 687 ;; end-of-line formats that aren't native to this platform.
701 (cond 688 (cond
702 ((memq system-type '(ms-dos windows-nt emx)) 689 ((memq system-type '(ms-dos windows-nt emx))
703 (setq eol-mnemonic-unix "(Unix)") 690 (setq eol-mnemonic-unix "(Unix)"
704 (setq eol-mnemonic-mac "(Mac)")) 691 eol-mnemonic-mac "(Mac)"))
705 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the 692 ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
706 ;; abbreviated strings `/' and `:' set in coding.c for them. 693 ;; abbreviated strings `/' and `:' set in coding.c for them.
707 ((eq system-type 'macos) 694 ((eq system-type 'macos)
708 (setq eol-mnemonic-dos "(DOS)")) 695 (setq eol-mnemonic-dos "(DOS)"))
709 (t ; this is for Unix/GNU/Linux systems 696 (t ; this is for Unix/GNU/Linux systems
710 (setq eol-mnemonic-dos "(DOS)") 697 (setq eol-mnemonic-dos "(DOS)"
711 (setq eol-mnemonic-mac "(Mac)"))) 698 eol-mnemonic-mac "(Mac)")))
712 699
713 ;; Read window system's init file if using a window system. 700 ;; Read window system's init file if using a window system.
714 (condition-case error 701 (condition-case error
@@ -726,21 +713,20 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
726 (apply 'concat (cdr error)) 713 (apply 'concat (cdr error))
727 (if (memq 'file-error (get (car error) 'error-conditions)) 714 (if (memq 'file-error (get (car error) 'error-conditions))
728 (format "%s: %s" 715 (format "%s: %s"
729 (nth 1 error) 716 (nth 1 error)
730 (mapconcat (lambda (obj) (prin1-to-string obj t)) 717 (mapconcat (lambda (obj) (prin1-to-string obj t))
731 (cdr (cdr error)) ", ")) 718 (cdr (cdr error)) ", "))
732 (format "%s: %s" 719 (format "%s: %s"
733 (get (car error) 'error-message) 720 (get (car error) 'error-message)
734 (mapconcat (lambda (obj) (prin1-to-string obj t)) 721 (mapconcat (lambda (obj) (prin1-to-string obj t))
735 (cdr error) ", ")))) 722 (cdr error) ", "))))
736 'external-debugging-output) 723 'external-debugging-output)
737 (terpri 'external-debugging-output) 724 (terpri 'external-debugging-output)
738 (setq window-system nil) 725 (setq window-system nil)
739 (kill-emacs))) 726 (kill-emacs)))
740 727
741 ;; Windowed displays do this inside their *-win.el. 728 ;; Windowed displays do this inside their *-win.el.
742 (when (and (not (display-graphic-p)) 729 (unless (or (display-graphic-p) noninteractive)
743 (not noninteractive))
744 (setq command-line-args (tty-handle-args command-line-args))) 730 (setq command-line-args (tty-handle-args command-line-args)))
745 731
746 (set-locale-environment nil) 732 (set-locale-environment nil)
@@ -750,7 +736,7 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
750 (while args 736 (while args
751 (setcar args 737 (setcar args
752 (decode-coding-string (car args) locale-coding-system t)) 738 (decode-coding-string (car args) locale-coding-system t))
753 (setq args (cdr args)))) 739 (pop args)))
754 740
755 (let ((done nil) 741 (let ((done nil)
756 (args (cdr command-line-args))) 742 (args (cdr command-line-args)))
@@ -759,22 +745,23 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
759 ;; either from the environment or from the options. 745 ;; either from the environment or from the options.
760 (setq init-file-user (if noninteractive nil (user-login-name))) 746 (setq init-file-user (if noninteractive nil (user-login-name)))
761 ;; If user has not done su, use current $HOME to find .emacs. 747 ;; If user has not done su, use current $HOME to find .emacs.
762 (and init-file-user (string= init-file-user (user-real-login-name)) 748 (and init-file-user
749 (equal init-file-user (user-real-login-name))
763 (setq init-file-user "")) 750 (setq init-file-user ""))
764 751
765 ;; Process the command-line args, and delete the arguments 752 ;; Process the command-line args, and delete the arguments
766 ;; processed. This is consistent with the way main in emacs.c 753 ;; processed. This is consistent with the way main in emacs.c
767 ;; does things. 754 ;; does things.
768 (while (and (not done) args) 755 (while (and (not done) args)
769 (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user") 756 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
770 ("--debug-init") ("--iconic") ("--icon-type"))) 757 ("--debug-init") ("--iconic") ("--icon-type")))
771 (argi (pop args)) 758 (argi (pop args))
772 (argval nil)) 759 (orig-argi argi)
760 argval)
773 ;; Handle --OPTION=VALUE format. 761 ;; Handle --OPTION=VALUE format.
774 (when (and (string-match "\\`--" argi) 762 (when (string-match "^\\(--[^=]*\\)=" argi)
775 (string-match "=" argi))
776 (setq argval (substring argi (match-end 0)) 763 (setq argval (substring argi (match-end 0))
777 argi (substring argi 0 (match-beginning 0)))) 764 argi (match-string 1 argi)))
778 (unless (equal argi "--") 765 (unless (equal argi "--")
779 (let ((completion (try-completion argi longopts))) 766 (let ((completion (try-completion argi longopts)))
780 (if (eq completion t) 767 (if (eq completion t)
@@ -784,54 +771,54 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
784 (or elt 771 (or elt
785 (error "Option `%s' is ambiguous" argi)) 772 (error "Option `%s' is ambiguous" argi))
786 (setq argi (substring (car elt) 1))) 773 (setq argi (substring (car elt) 1)))
787 (setq argval nil))))) 774 (setq argval nil
775 argi orig-argi)))))
788 (cond 776 (cond
789 ((member argi '("-q" "-no-init-file")) 777 ((member argi '("-q" "-no-init-file"))
790 (setq init-file-user nil)) 778 (setq init-file-user nil))
791 ((member argi '("-u" "-user")) 779 ((member argi '("-u" "-user"))
792 (or argval 780 (setq init-file-user (or argval (pop args))
793 (setq argval (pop args)))
794 (setq init-file-user argval
795 argval nil)) 781 argval nil))
796 ((string-equal argi "-no-site-file") 782 ((equal argi "-no-site-file")
797 (setq site-run-file nil)) 783 (setq site-run-file nil))
798 ((string-equal argi "-debug-init") 784 ((equal argi "-debug-init")
799 (setq init-file-debug t)) 785 (setq init-file-debug t))
800 ((string-equal argi "-iconic") 786 ((equal argi "-iconic")
801 (push '(visibility . icon) initial-frame-alist)) 787 (push '(visibility . icon) initial-frame-alist))
802 ((or (string-equal argi "-icon-type") 788 ((member argi '("-icon-type" "-i" "-itype"))
803 (string-equal argi "-i")
804 (string-equal argi "-itype"))
805 (push '(icon-type . t) default-frame-alist)) 789 (push '(icon-type . t) default-frame-alist))
806 ;; Push the popped arg back on the list of arguments. 790 ;; Push the popped arg back on the list of arguments.
807 (t (push argi args) (setq done t))) 791 (t
792 (push argi args)
793 (setq done t)))
808 ;; Was argval set but not used? 794 ;; Was argval set but not used?
809 (and argval 795 (and argval
810 (error "Option `%s' doesn't allow an argument" argi)))) 796 (error "Option `%s' doesn't allow an argument" argi))))
811 797
812 ;; Re-attach the program name to the front of the arg list. 798 ;; Re-attach the program name to the front of the arg list.
813 (and command-line-args (setcdr command-line-args args))) 799 (and command-line-args
800 (setcdr command-line-args args)))
814 801
815 ;; Under X Windows, this creates the X frame and deletes the terminal frame. 802 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
816 (when (fboundp 'frame-initialize) 803 (when (fboundp 'frame-initialize)
817 (frame-initialize)) 804 (frame-initialize))
818 805
819 ;; If frame was created with a menu bar, set menu-bar-mode on. 806 ;; If frame was created with a menu bar, set menu-bar-mode on.
820 (if (and (not noninteractive) 807 (unless (or noninteractive
821 (or (not (memq window-system '(x w32))) 808 (and (memq window-system '(x w32))
822 (> (frame-parameter nil 'menu-bar-lines) 0))) 809 (<= (frame-parameter nil 'menu-bar-lines) 0)))
823 (menu-bar-mode t)) 810 (menu-bar-mode t))
824 811
825 ;; If frame was created with a tool bar, switch tool-bar-mode on. 812 ;; If frame was created with a tool bar, switch tool-bar-mode on.
826 (when (and (not noninteractive) 813 (unless (or noninteractive
827 (display-graphic-p) 814 (not (display-graphic-p))
828 (> (frame-parameter nil 'tool-bar-lines) 0)) 815 (<= (frame-parameter nil 'tool-bar-lines) 0))
829 (tool-bar-mode 1)) 816 (tool-bar-mode 1))
830 817
831 ;; Can't do this init in defcustom because window-system isn't set. 818 ;; Can't do this init in defcustom because window-system isn't set.
832 (when (and (not noninteractive) 819 (unless (or noninteractive
833 (not (eq system-type 'ms-dos)) 820 (eq system-type 'ms-dos)
834 (memq window-system '(x w32))) 821 (not (memq window-system '(x w32))))
835 (setq-default blink-cursor t) 822 (setq-default blink-cursor t)
836 (blink-cursor-mode 1)) 823 (blink-cursor-mode 1))
837 824
@@ -850,19 +837,19 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
850 (setq-default normal-erase-is-backspace t) 837 (setq-default normal-erase-is-backspace t)
851 (normal-erase-is-backspace-mode 1))) 838 (normal-erase-is-backspace-mode 1)))
852 839
853 (when (and (not noninteractive) 840 (unless (or noninteractive
854 (display-graphic-p) 841 (not (display-graphic-p))
855 (fboundp 'x-show-tip)) 842 (not (fboundp 'x-show-tip)))
856 (setq-default tooltip-mode t) 843 (setq-default tooltip-mode t)
857 (tooltip-mode 1)) 844 (tooltip-mode 1))
858 845
859 ;; Register default TTY colors for the case the terminal hasn't a 846 ;; Register default TTY colors for the case the terminal hasn't a
860 ;; terminal init file. 847 ;; terminal init file.
861 (or (memq window-system '(x w32)) 848 (unless (memq window-system '(x w32))
862 ;; We do this regardles of whether the terminal supports colors 849 ;; We do this regardles of whether the terminal supports colors
863 ;; or not, since they can switch that support on or off in 850 ;; or not, since they can switch that support on or off in
864 ;; mid-session by setting the tty-color-mode frame parameter. 851 ;; mid-session by setting the tty-color-mode frame parameter.
865 (tty-register-default-colors)) 852 (tty-register-default-colors))
866 853
867 ;; Record whether the tool-bar is present before the user and site 854 ;; Record whether the tool-bar is present before the user and site
868 ;; init files are processed. frame-notice-user-settings uses this 855 ;; init files are processed. frame-notice-user-settings uses this
@@ -872,9 +859,9 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
872 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist) 859 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
873 (assq 'tool-bar-lines default-frame-alist)))) 860 (assq 'tool-bar-lines default-frame-alist))))
874 (setq tool-bar-originally-present 861 (setq tool-bar-originally-present
875 (not (or (null tool-bar-lines) 862 (and tool-bar-lines
876 (null (cdr tool-bar-lines)) 863 (cdr tool-bar-lines)
877 (eq 0 (cdr tool-bar-lines))))))) 864 (not (eq 0 (cdr tool-bar-lines)))))))
878 865
879 (let ((old-scalable-fonts-allowed scalable-fonts-allowed) 866 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
880 (old-font-list-limit font-list-limit) 867 (old-font-list-limit font-list-limit)
@@ -957,19 +944,19 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
957 (sit-for 1)) 944 (sit-for 1))
958 (setq user-init-file source)))) 945 (setq user-init-file source))))
959 946
960 (when (and (stringp custom-file) 947 (when (stringp custom-file)
961 (not (assoc custom-file load-history))) 948 (unless (assoc custom-file load-history)
962 ;; If the .emacs file has set `custom-file' but hasn't 949 ;; If the .emacs file has set `custom-file' but hasn't
963 ;; loaded the file yet, let's load it. 950 ;; loaded the file yet, let's load it.
964 (load custom-file t t)) 951 (load custom-file t t)))
965 952
966 (or inhibit-default-init 953 (unless inhibit-default-init
967 (let ((inhibit-startup-message nil)) 954 (let ((inhibit-startup-message nil))
968 ;; Users are supposed to be told their rights. 955 ;; Users are supposed to be told their rights.
969 ;; (Plus how to get help and how to undo.) 956 ;; (Plus how to get help and how to undo.)
970 ;; Don't you dare turn this off for anyone 957 ;; Don't you dare turn this off for anyone
971 ;; except yourself. 958 ;; except yourself.
972 (load "default" t t))))))))) 959 (load "default" t t)))))))))
973 (if init-file-debug 960 (if init-file-debug
974 ;; Do this without a condition-case if the user wants to debug. 961 ;; Do this without a condition-case if the user wants to debug.
975 (funcall inner) 962 (funcall inner)
@@ -1055,15 +1042,18 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
1055 1042
1056 ;; Load library for our terminal type. 1043 ;; Load library for our terminal type.
1057 ;; User init file can set term-file-prefix to nil to prevent this. 1044 ;; User init file can set term-file-prefix to nil to prevent this.
1058 (and term-file-prefix (not noninteractive) (not window-system) 1045 (unless (or noninteractive
1059 (let ((term (getenv "TERM")) 1046 window-system
1060 hyphend) 1047 (null term-file-prefix))
1061 (while (and term 1048 (let ((term (getenv "TERM"))
1062 (not (load (concat term-file-prefix term) t t))) 1049 hyphend)
1063 ;; Strip off last hyphen and what follows, then try again 1050 (while (and term
1064 (if (setq hyphend (string-match "[-_][^-_]+$" term)) 1051 (not (load (concat term-file-prefix term) t t)))
1065 (setq term (substring term 0 hyphend)) 1052 ;; Strip off last hyphen and what follows, then try again
1066 (setq term nil))))) 1053 (setq term
1054 (if (setq hyphend (string-match "[-_][^-_]+$" term))
1055 (substring term 0 hyphend)
1056 nil)))))
1067 1057
1068 ;; Update the out-of-memory error message based on user's key bindings 1058 ;; Update the out-of-memory error message based on user's key bindings
1069 ;; for save-some-buffers. 1059 ;; for save-some-buffers.
@@ -1079,7 +1069,8 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
1079 1069
1080 ;; Run emacs-session-restore (session management) if started by 1070 ;; Run emacs-session-restore (session management) if started by
1081 ;; the session manager and we have a session manager connection. 1071 ;; the session manager and we have a session manager connection.
1082 (if (and (boundp 'x-session-previous-id) (stringp x-session-previous-id)) 1072 (if (and (boundp 'x-session-previous-id)
1073 (stringp x-session-previous-id))
1083 (emacs-session-restore x-session-previous-id))) 1074 (emacs-session-restore x-session-previous-id)))
1084 1075
1085(defcustom initial-scratch-message (purecopy "\ 1076(defcustom initial-scratch-message (purecopy "\
@@ -1528,7 +1519,7 @@ normal otherwise."
1528 user-init-file 1519 user-init-file
1529 (or (and (get 'inhibit-startup-echo-area-message 'saved-value) 1520 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1530 (equal inhibit-startup-echo-area-message 1521 (equal inhibit-startup-echo-area-message
1531 (if (string= init-file-user "") 1522 (if (equal init-file-user "")
1532 (user-login-name) 1523 (user-login-name)
1533 init-file-user))) 1524 init-file-user)))
1534 ;; Wasn't set with custom; see if .emacs has a setq. 1525 ;; Wasn't set with custom; see if .emacs has a setq.
@@ -1544,7 +1535,7 @@ normal otherwise."
1544 "inhibit-startup-echo-area-message[ \t\n]+" 1535 "inhibit-startup-echo-area-message[ \t\n]+"
1545 (regexp-quote 1536 (regexp-quote
1546 (prin1-to-string 1537 (prin1-to-string
1547 (if (string= init-file-user "") 1538 (if (equal init-file-user "")
1548 (user-login-name) 1539 (user-login-name)
1549 init-file-user))) 1540 init-file-user)))
1550 "[ \t\n]*)") 1541 "[ \t\n]*)")
@@ -1555,199 +1546,189 @@ normal otherwise."
1555 1546
1556 ;; Delay 2 seconds after an init file error message 1547 ;; Delay 2 seconds after an init file error message
1557 ;; was displayed, so user can read it. 1548 ;; was displayed, so user can read it.
1558 (if init-file-had-error 1549 (when init-file-had-error
1559 (sit-for 2)) 1550 (sit-for 2))
1560 1551
1561 (if command-line-args-left 1552 (when command-line-args-left
1562 ;; We have command args; process them. 1553 ;; We have command args; process them.
1563 (let ((dir command-line-default-directory) 1554 (let ((dir command-line-default-directory)
1564 (file-count 0) 1555 (file-count 0)
1565 first-file-buffer 1556 first-file-buffer
1566 tem 1557 tem
1567 just-files ;; t if this follows the magic -- option. 1558 ;; The directories listed in --directory/-L options will *appear*
1568 ;; This includes our standard options' long versions 1559 ;; at the front of `load-path' in the order they appear on the
1569 ;; and long versions of what's on command-switch-alist. 1560 ;; command-line. We cannot do this by *placing* them at the front
1570 (longopts 1561 ;; in the order they appear, so we need this variable to hold them,
1571 (append '(("--funcall") ("--load") ("--insert") ("--kill") 1562 ;; temporarily.
1572 ("--directory") ("--eval") ("--execute") ("--no-splash") 1563 extra-load-path
1573 ("--find-file") ("--visit") ("--file")) 1564 just-files ;; t if this follows the magic -- option.
1574 (mapcar (lambda (elt) 1565 ;; This includes our standard options' long versions
1575 (list (concat "-" (car elt)))) 1566 ;; and long versions of what's on command-switch-alist.
1576 command-switch-alist))) 1567 (longopts
1577 (line 0) 1568 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1578 (column 0)) 1569 ("--directory") ("--eval") ("--execute") ("--no-splash")
1579 1570 ("--find-file") ("--visit") ("--file"))
1580 ;; Add the long X options to longopts. 1571 (mapcar (lambda (elt)
1581 (dolist (tem command-line-x-option-alist) 1572 (list (concat "-" (car elt))))
1582 (if (string-match "^--" (car tem)) 1573 command-switch-alist)))
1583 (push (list (car tem)) longopts))) 1574 (line 0)
1584 1575 (column 0))
1585 ;; Loop, processing options. 1576
1586 (while (and command-line-args-left) 1577 ;; Add the long X options to longopts.
1587 (let* ((argi (car command-line-args-left)) 1578 (dolist (tem command-line-x-option-alist)
1588 (orig-argi argi) 1579 (if (string-match "^--" (car tem))
1589 argval completion 1580 (push (list (car tem)) longopts)))
1590 ;; List of directories specified in -L/--directory, 1581
1591 ;; in reverse of the order specified. 1582 ;; Loop, processing options.
1592 extra-load-path 1583 (while command-line-args-left
1593 (initial-load-path load-path)) 1584 (let* ((argi (car command-line-args-left))
1594 (setq command-line-args-left (cdr command-line-args-left)) 1585 (orig-argi argi)
1595 1586 argval completion)
1596 ;; Do preliminary decoding of the option. 1587 (setq command-line-args-left (cdr command-line-args-left))
1597 (if just-files 1588
1598 ;; After --, don't look for options; treat all args as files. 1589 ;; Do preliminary decoding of the option.
1599 (setq argi "") 1590 (if just-files
1600 ;; Convert long options to ordinary options 1591 ;; After --, don't look for options; treat all args as files.
1601 ;; and separate out an attached option argument into argval. 1592 (setq argi "")
1602 (if (string-match "^--[^=]*=" argi) 1593 ;; Convert long options to ordinary options
1603 (setq argval (substring argi (match-end 0)) 1594 ;; and separate out an attached option argument into argval.
1604 argi (substring argi 0 (1- (match-end 0))))) 1595 (when (string-match "^\\(--[^=]*\\)=" argi)
1605 (if (equal argi "--") 1596 (setq argval (substring argi (match-end 0))
1606 (setq completion nil) 1597 argi (match-string 1 argi)))
1607 (setq completion (try-completion argi longopts))) 1598 (if (equal argi "--")
1608 (if (eq completion t) 1599 (setq completion nil)
1609 (setq argi (substring argi 1)) 1600 (setq completion (try-completion argi longopts)))
1610 (if (stringp completion) 1601 (if (eq completion t)
1611 (let ((elt (assoc completion longopts))) 1602 (setq argi (substring argi 1))
1612 (or elt 1603 (if (stringp completion)
1613 (error "Option `%s' is ambiguous" argi)) 1604 (let ((elt (assoc completion longopts)))
1614 (setq argi (substring (car elt) 1))) 1605 (or elt
1615 (setq argval nil argi orig-argi)))) 1606 (error "Option `%s' is ambiguous" argi))
1616 1607 (setq argi (substring (car elt) 1)))
1617 ;; Execute the option. 1608 (setq argval nil
1618 (cond ((setq tem (assoc argi command-switch-alist)) 1609 argi orig-argi))))
1619 (if argval 1610
1620 (let ((command-line-args-left 1611 ;; Execute the option.
1621 (cons argval command-line-args-left))) 1612 (cond ((setq tem (assoc argi command-switch-alist))
1622 (funcall (cdr tem) argi)) 1613 (if argval
1623 (funcall (cdr tem) argi))) 1614 (let ((command-line-args-left
1624 1615 (cons argval command-line-args-left)))
1625 ((string-equal argi "-no-splash") 1616 (funcall (cdr tem) argi))
1626 (setq inhibit-startup-message t)) 1617 (funcall (cdr tem) argi)))
1627 1618
1628 ((member argi '("-f" ;what the manual claims 1619 ((equal argi "-no-splash")
1629 "-funcall" 1620 (setq inhibit-startup-message t))
1630 "-e")) ; what the source used to say 1621
1631 (if argval 1622 ((member argi '("-f" ; what the manual claims
1632 (setq tem (intern argval)) 1623 "-funcall"
1633 (setq tem (intern (car command-line-args-left))) 1624 "-e")) ; what the source used to say
1634 (setq command-line-args-left (cdr command-line-args-left))) 1625 (setq tem (intern (or argval (pop command-line-args-left))))
1635 (if (arrayp (symbol-function tem)) 1626 (if (arrayp (symbol-function tem))
1636 (command-execute tem) 1627 (command-execute tem)
1637 (funcall tem))) 1628 (funcall tem)))
1638 1629
1639 ((member argi '("-eval" "-execute")) 1630 ((member argi '("-eval" "-execute"))
1640 (if argval 1631 (eval (read (or argval (pop command-line-args-left)))))
1641 (setq tem argval) 1632 ;; Set the default directory as specified in -L.
1642 (setq tem (car command-line-args-left)) 1633
1643 (setq command-line-args-left (cdr command-line-args-left))) 1634 ((member argi '("-L" "-directory"))
1644 (eval (read tem))) 1635 (setq tem (or argval (pop command-line-args-left)))
1645 ;; Set the default directory as specified in -L. 1636 ;; We will reverse `extra-load-path' and prepend it to
1646 1637 ;; `load-path' after all the arguments have been processed.
1647 ((member argi '("-L" "-directory")) 1638 (push
1648 (if argval 1639 (expand-file-name (command-line-normalize-file-name tem))
1649 (setq tem argval) 1640 extra-load-path))
1650 (setq tem (car command-line-args-left) 1641
1651 command-line-args-left (cdr command-line-args-left))) 1642 ((member argi '("-l" "-load"))
1652 (setq tem (command-line-normalize-file-name tem)) 1643 (let* ((file (command-line-normalize-file-name
1653 (setq extra-load-path 1644 (or argval (pop command-line-args-left))))
1654 (cons (expand-file-name tem) extra-load-path)) 1645 ;; Take file from default dir if it exists there;
1655 (setq load-path (append (nreverse extra-load-path) 1646 ;; otherwise let `load' search for it.
1656 initial-load-path))) 1647 (file-ex (expand-file-name file)))
1657 1648 (when (file-exists-p file-ex)
1658 ((member argi '("-l" "-load")) 1649 (setq file file-ex))
1659 (if argval 1650 (load file nil t)))
1660 (setq tem argval) 1651
1661 (setq tem (car command-line-args-left) 1652 ((equal argi "-insert")
1662 command-line-args-left (cdr command-line-args-left))) 1653 (setq tem (or argval (pop command-line-args-left)))
1663 (let ((file (command-line-normalize-file-name tem))) 1654 (or (stringp tem)
1664 ;; Take file from default dir if it exists there; 1655 (error "File name omitted from `-insert' option"))
1665 ;; otherwise let `load' search for it. 1656 (insert-file-contents (command-line-normalize-file-name tem)))
1666 (if (file-exists-p (expand-file-name file)) 1657
1667 (setq file (expand-file-name file))) 1658 ((equal argi "-kill")
1668 (load file nil t))) 1659 (kill-emacs t))
1669 1660
1670 ((string-equal argi "-insert") 1661 ((string-match "^\\+[0-9]+\\'" argi)
1671 (if argval 1662 (setq line (string-to-int argi)))
1672 (setq tem argval) 1663
1673 (setq tem (car command-line-args-left) 1664 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
1674 command-line-args-left (cdr command-line-args-left))) 1665 (setq line (string-to-int (match-string 1 argi))
1675 (or (stringp tem) 1666 column (string-to-int (match-string 2 argi))))
1676 (error "File name omitted from `-insert' option")) 1667
1677 (insert-file-contents (command-line-normalize-file-name tem))) 1668 ((setq tem (assoc argi command-line-x-option-alist))
1678 1669 ;; Ignore X-windows options and their args if not using X.
1679 ((string-equal argi "-kill") 1670 (setq command-line-args-left
1680 (kill-emacs t)) 1671 (nthcdr (nth 1 tem) command-line-args-left)))
1681 1672
1682 ((string-match "^\\+[0-9]+\\'" argi) 1673 ((member argi '("-find-file" "-file" "-visit"))
1683 (setq line (string-to-int argi))) 1674 ;; An explicit option to specify visiting a file.
1684 1675 (setq tem (or argval (pop command-line-args-left)))
1685 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi) 1676 (unless (stringp tem)
1686 (setq line (string-to-int (match-string 1 argi)) 1677 (error "File name omitted from `%s' option" argi))
1687 column (string-to-int (match-string 2 argi)))) 1678 (setq file-count (1+ file-count))
1688 1679 (let ((file (expand-file-name
1689 ((setq tem (assoc argi command-line-x-option-alist)) 1680 (command-line-normalize-file-name tem) dir)))
1690 ;; Ignore X-windows options and their args if not using X. 1681 (if (= file-count 1)
1691 (setq command-line-args-left 1682 (setq first-file-buffer (find-file file))
1692 (nthcdr (nth 1 tem) command-line-args-left))) 1683 (find-file-other-window file)))
1693 1684 (or (zerop line)
1694 ((member argi '("-find-file" "-file" "-visit")) 1685 (goto-line line))
1695 ;; An explicit option to specify visiting a file. 1686 (setq line 0)
1696 (if argval 1687 (unless (< column 1)
1697 (setq tem argval) 1688 (move-to-column (1- column)))
1698 (setq tem (car command-line-args-left) 1689 (setq column 0))
1699 command-line-args-left (cdr command-line-args-left))) 1690
1700 (unless (stringp tem) 1691 ((equal argi "--")
1701 (error "File name omitted from `%s' option" argi)) 1692 (setq just-files t))
1702 (setq file-count (1+ file-count)) 1693 (t
1703 (let ((file (expand-file-name 1694 ;; We have almost exhausted our options. See if the
1704 (command-line-normalize-file-name tem) dir))) 1695 ;; user has made any other command-line options available
1705 (if (= file-count 1) 1696 (let ((hooks command-line-functions) ;; lrs 7/31/89
1706 (setq first-file-buffer (find-file file)) 1697 (did-hook nil))
1707 (find-file-other-window file))) 1698 (while (and hooks
1708 (or (zerop line) 1699 (not (setq did-hook (funcall (car hooks)))))
1709 (goto-line line)) 1700 (setq hooks (cdr hooks)))
1710 (setq line 0) 1701 (if (not did-hook)
1711 (unless (< column 1) 1702 ;; Presume that the argument is a file name.
1712 (move-to-column (1- column))) 1703 (progn
1713 (setq column 0)) 1704 (if (string-match "\\`-" argi)
1714 1705 (error "Unknown option `%s'" argi))
1715 ((equal argi "--") 1706 (setq file-count (1+ file-count))
1716 (setq just-files t)) 1707 (let ((file
1717 (t 1708 (expand-file-name
1718 ;; We have almost exhausted our options. See if the 1709 (command-line-normalize-file-name orig-argi)
1719 ;; user has made any other command-line options available 1710 dir)))
1720 (let ((hooks command-line-functions) ;; lrs 7/31/89 1711 (if (= file-count 1)
1721 (did-hook nil)) 1712 (setq first-file-buffer (find-file file))
1722 (while (and hooks 1713 (find-file-other-window file)))
1723 (not (setq did-hook (funcall (car hooks))))) 1714 (or (zerop line)
1724 (setq hooks (cdr hooks))) 1715 (goto-line line))
1725 (if (not did-hook) 1716 (setq line 0)
1726 ;; Ok, presume that the argument is a file name 1717 (unless (< column 1)
1727 (progn 1718 (move-to-column (1- column)))
1728 (if (string-match "\\`-" argi) 1719 (setq column 0))))))))
1729 (error "Unknown option `%s'" argi)) 1720
1730 (setq file-count (1+ file-count)) 1721 ;; See --directory/-L option above.
1731 (let ((file 1722 (when extra-load-path
1732 (expand-file-name 1723 (setq load-path (append (nreverse extra-load-path) load-path)))
1733 (command-line-normalize-file-name orig-argi) 1724
1734 dir))) 1725 ;; If 3 or more files visited, and not all visible,
1735 (if (= file-count 1) 1726 ;; show user what they all are. But leave the last one current.
1736 (setq first-file-buffer (find-file file)) 1727 (and (> file-count 2)
1737 (find-file-other-window file))) 1728 (not noninteractive)
1738 (or (zerop line) 1729 (not inhibit-startup-buffer-menu)
1739 (goto-line line)) 1730 (or (get-buffer-window first-file-buffer)
1740 (setq line 0) 1731 (list-buffers)))))
1741 (unless (< column 1)
1742 (move-to-column (1- column)))
1743 (setq column 0))))))))
1744 ;; If 3 or more files visited, and not all visible,
1745 ;; show user what they all are. But leave the last one current.
1746 (and (> file-count 2)
1747 (not noninteractive)
1748 (not inhibit-startup-buffer-menu)
1749 (or (get-buffer-window first-file-buffer)
1750 (list-buffers)))))
1751 1732
1752 ;; Maybe display a startup screen. 1733 ;; Maybe display a startup screen.
1753 (when (and (not inhibit-startup-message) (not noninteractive) 1734 (when (and (not inhibit-startup-message) (not noninteractive)
@@ -1789,7 +1770,7 @@ normal otherwise."
1789 ;; If *scratch* is selected and it is empty, insert an 1770 ;; If *scratch* is selected and it is empty, insert an
1790 ;; initial message saying not to create a file there. 1771 ;; initial message saying not to create a file there.
1791 (when (and initial-scratch-message 1772 (when (and initial-scratch-message
1792 (string= (buffer-name) "*scratch*") 1773 (equal (buffer-name) "*scratch*")
1793 (= 0 (buffer-size))) 1774 (= 0 (buffer-size)))
1794 (insert initial-scratch-message) 1775 (insert initial-scratch-message)
1795 (set-buffer-modified-p nil)) 1776 (set-buffer-modified-p nil))