comparison lisp/startup.el @ 37688:187a17e0e802

(command-line): If parameters have been changed in the init files which influence font selection, clear the face cache so that faces get realized with the new parameters.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 11 May 2001 15:12:08 +0000
parents 43f6d0dc6354
children 0a8958170e89
comparison
equal deleted inserted replaced
37687:82789ad4a626 37688:187a17e0e802
817 (setq tool-bar-originally-present 817 (setq tool-bar-originally-present
818 (not (or (null tool-bar-lines) 818 (not (or (null tool-bar-lines)
819 (null (cdr tool-bar-lines)) 819 (null (cdr tool-bar-lines))
820 (eq 0 (cdr tool-bar-lines))))))) 820 (eq 0 (cdr tool-bar-lines)))))))
821 821
822 (run-hooks 'before-init-hook) 822 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
823 823 (old-font-list-limit font-list-limit)
824 ;; Run the site-start library if it exists. The point of this file is 824 (old-face-ignored-fonts face-ignored-fonts))
825 ;; that it is run before .emacs. There is no point in doing this after 825
826 ;; .emacs; that is useless. 826 (run-hooks 'before-init-hook)
827 (if site-run-file 827
828 (load site-run-file t t)) 828 ;; Run the site-start library if it exists. The point of this file is
829 829 ;; that it is run before .emacs. There is no point in doing this after
830 ;; Sites should not disable this. Only individuals should disable 830 ;; .emacs; that is useless.
831 ;; the startup message. 831 (if site-run-file
832 (setq inhibit-startup-message nil) 832 (load site-run-file t t))
833 833
834 ;; Load that user's init file, or the default one, or none. 834 ;; Sites should not disable this. Only individuals should disable
835 (let (debug-on-error-from-init-file 835 ;; the startup message.
836 debug-on-error-should-be-set 836 (setq inhibit-startup-message nil)
837 (debug-on-error-initial 837
838 (if (eq init-file-debug t) 'startup init-file-debug)) 838 ;; Load that user's init file, or the default one, or none.
839 (orig-enable-multibyte default-enable-multibyte-characters)) 839 (let (debug-on-error-from-init-file
840 (let ((debug-on-error debug-on-error-initial) 840 debug-on-error-should-be-set
841 ;; This function actually reads the init files. 841 (debug-on-error-initial
842 (inner 842 (if (eq init-file-debug t) 'startup init-file-debug))
843 (function 843 (orig-enable-multibyte default-enable-multibyte-characters))
844 (lambda () 844 (let ((debug-on-error debug-on-error-initial)
845 (if init-file-user 845 ;; This function actually reads the init files.
846 (let ((user-init-file-1 846 (inner
847 (cond 847 (function
848 ((eq system-type 'ms-dos) 848 (lambda ()
849 (concat "~" init-file-user "/_emacs")) 849 (if init-file-user
850 ((eq system-type 'windows-nt) 850 (let ((user-init-file-1
851 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$") 851 (cond
852 "~/.emacs" 852 ((eq system-type 'ms-dos)
853 "~/_emacs")) 853 (concat "~" init-file-user "/_emacs"))
854 ((eq system-type 'vax-vms) 854 ((eq system-type 'windows-nt)
855 "sys$login:.emacs") 855 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
856 (t 856 "~/.emacs"
857 (concat "~" init-file-user "/.emacs"))))) 857 "~/_emacs"))
858 ;; This tells `load' to store the file name found 858 ((eq system-type 'vax-vms)
859 ;; into user-init-file. 859 "sys$login:.emacs")
860 (setq user-init-file t) 860 (t
861 (load user-init-file-1 t t) 861 (concat "~" init-file-user "/.emacs")))))
862 862 ;; This tells `load' to store the file name found
863 ;; If we did not find the user's init file, 863 ;; into user-init-file.
864 ;; set user-init-file conclusively to nil; 864 (setq user-init-file t)
865 ;; don't let it be set from default.el. 865 (load user-init-file-1 t t)
866 (if (eq user-init-file t) 866
867 (setq user-init-file nil)) 867 ;; If we did not find the user's init file,
868 868 ;; set user-init-file conclusively to nil;
869 ;; If we loaded a compiled file, set 869 ;; don't let it be set from default.el.
870 ;; `user-init-file' to the source version if that 870 (if (eq user-init-file t)
871 ;; exists. 871 (setq user-init-file nil))
872 (when (and user-init-file 872
873 (equal (file-name-extension user-init-file) 873 ;; If we loaded a compiled file, set
874 "elc")) 874 ;; `user-init-file' to the source version if that
875 (let* ((source (file-name-sans-extension user-init-file)) 875 ;; exists.
876 (alt (concat source ".el"))) 876 (when (and user-init-file
877 (setq source (cond ((file-exists-p alt) alt) 877 (equal (file-name-extension user-init-file)
878 ((file-exists-p source) source) 878 "elc"))
879 (t nil))) 879 (let* ((source (file-name-sans-extension user-init-file))
880 (when source 880 (alt (concat source ".el")))
881 (when (file-newer-than-file-p source user-init-file) 881 (setq source (cond ((file-exists-p alt) alt)
882 (message "Warning: %s is newer than %s" 882 ((file-exists-p source) source)
883 source user-init-file) 883 (t nil)))
884 (sit-for 1)) 884 (when source
885 (setq user-init-file source)))) 885 (when (file-newer-than-file-p source user-init-file)
886 886 (message "Warning: %s is newer than %s"
887 (or inhibit-default-init 887 source user-init-file)
888 (let ((inhibit-startup-message nil)) 888 (sit-for 1))
889 ;; Users are supposed to be told their rights. 889 (setq user-init-file source))))
890 ;; (Plus how to get help and how to undo.) 890
891 ;; Don't you dare turn this off for anyone 891 (or inhibit-default-init
892 ;; except yourself. 892 (let ((inhibit-startup-message nil))
893 (load "default" t t))))))))) 893 ;; Users are supposed to be told their rights.
894 (if init-file-debug 894 ;; (Plus how to get help and how to undo.)
895 ;; Do this without a condition-case if the user wants to debug. 895 ;; Don't you dare turn this off for anyone
896 (funcall inner) 896 ;; except yourself.
897 (condition-case error 897 (load "default" t t)))))))))
898 (progn 898 (if init-file-debug
899 (funcall inner) 899 ;; Do this without a condition-case if the user wants to debug.
900 (setq init-file-had-error nil)) 900 (funcall inner)
901 (error 901 (condition-case error
902 (let ((message-log-max nil)) 902 (progn
903 (save-excursion 903 (funcall inner)
904 (set-buffer (get-buffer-create "*Messages*")) 904 (setq init-file-had-error nil))
905 (insert "\n\n" 905 (error
906 (format "An error has occurred while loading `%s':\n\n" 906 (let ((message-log-max nil))
907 user-init-file) 907 (save-excursion
908 (format "%s%s%s" 908 (set-buffer (get-buffer-create "*Messages*"))
909 (get (car error) 'error-message) 909 (insert "\n\n"
910 (if (cdr error) ": " "") 910 (format "An error has occurred while loading `%s':\n\n"
911 (mapconcat 'prin1-to-string (cdr error) ", ")) 911 user-init-file)
912 "\n\n" 912 (format "%s%s%s"
913 "To ensure normal operation, you should investigate the cause\n" 913 (get (car error) 'error-message)
914 "of the error in your initialization file and remove it. Start\n" 914 (if (cdr error) ": " "")
915 "Emacs with the `--debug-init' option to view a complete error\n" 915 (mapconcat 'prin1-to-string (cdr error) ", "))
916 "backtrace\n")) 916 "\n\n"
917 (message "Error in init file: %s%s%s" 917 "To ensure normal operation, you should investigate the cause\n"
918 (get (car error) 'error-message) 918 "of the error in your initialization file and remove it. Start\n"
919 (if (cdr error) ": " "") 919 "Emacs with the `--debug-init' option to view a complete error\n"
920 (mapconcat 'prin1-to-string (cdr error) ", ")) 920 "backtrace\n"))
921 (pop-to-buffer "*Messages*") 921 (message "Error in init file: %s%s%s"
922 (setq init-file-had-error t))))) 922 (get (car error) 'error-message)
923 ;; If we can tell that the init file altered debug-on-error, 923 (if (cdr error) ": " "")
924 ;; arrange to preserve the value that it set up. 924 (mapconcat 'prin1-to-string (cdr error) ", "))
925 (or (eq debug-on-error debug-on-error-initial) 925 (pop-to-buffer "*Messages*")
926 (setq debug-on-error-should-be-set t 926 (setq init-file-had-error t)))))
927 debug-on-error-from-init-file debug-on-error))) 927 ;; If we can tell that the init file altered debug-on-error,
928 (if debug-on-error-should-be-set 928 ;; arrange to preserve the value that it set up.
929 (setq debug-on-error debug-on-error-from-init-file)) 929 (or (eq debug-on-error debug-on-error-initial)
930 (unless (or default-enable-multibyte-characters 930 (setq debug-on-error-should-be-set t
931 (eq orig-enable-multibyte default-enable-multibyte-characters)) 931 debug-on-error-from-init-file debug-on-error)))
932 ;; Init file changed to unibyte. Reset existing multibyte 932 (if debug-on-error-should-be-set
933 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*). 933 (setq debug-on-error debug-on-error-from-init-file))
934 ;; Arguably this should only be done if they're free of 934 (unless (or default-enable-multibyte-characters
935 ;; multibyte characters. 935 (eq orig-enable-multibyte default-enable-multibyte-characters))
936 (mapcar (lambda (buffer) 936 ;; Init file changed to unibyte. Reset existing multibyte
937 (with-current-buffer buffer 937 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
938 (if enable-multibyte-characters 938 ;; Arguably this should only be done if they're free of
939 (set-buffer-multibyte nil)))) 939 ;; multibyte characters.
940 (buffer-list)) 940 (mapcar (lambda (buffer)
941 ;; Also re-set the language environment in case it was 941 (with-current-buffer buffer
942 ;; originally done before unibyte was set and is sensitive to 942 (if enable-multibyte-characters
943 ;; unibyte (display table, terminal coding system &c). 943 (set-buffer-multibyte nil))))
944 (set-language-environment current-language-environment))) 944 (buffer-list))
945 945 ;; Also re-set the language environment in case it was
946 ;; Do this here in case the init file sets mail-host-address. 946 ;; originally done before unibyte was set and is sensitive to
947 (or user-mail-address 947 ;; unibyte (display table, terminal coding system &c).
948 (setq user-mail-address (concat (user-login-name) "@" 948 (set-language-environment current-language-environment)))
949 (or mail-host-address 949
950 (system-name))))) 950 ;; Do this here in case the init file sets mail-host-address.
951 951 (or user-mail-address
952 (setq user-mail-address (concat (user-login-name) "@"
953 (or mail-host-address
954 (system-name)))))
955
956 ;; If parameter have been changed in the init file which influence
957 ;; face realization, clear the face cache so that new faces will
958 ;; be realized.
959 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
960 (eq font-list-limit old-font-list-limit)
961 (eq face-ignored-fonts old-face-ignored-fonts))
962 (clear-face-cache)))
963
952 (run-hooks 'after-init-hook) 964 (run-hooks 'after-init-hook)
953 965
954 ;; If *scratch* exists and init file didn't change its mode, initialize it. 966 ;; If *scratch* exists and init file didn't change its mode, initialize it.
955 (if (get-buffer "*scratch*") 967 (if (get-buffer "*scratch*")
956 (save-excursion 968 (save-excursion