Mercurial > hg > xemacs-beta
comparison lisp/startup.el @ 424:11054d720c21 r21-2-20
Import from CVS: tag r21-2-20
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:26:11 +0200 |
parents | da8ed4261e83 |
children |
comparison
equal
deleted
inserted
replaced
423:28d9c139be4c | 424:11054d720c21 |
---|---|
102 "Major mode command symbol to use for the initial *scratch* buffer.") | 102 "Major mode command symbol to use for the initial *scratch* buffer.") |
103 | 103 |
104 (defvar emacs-roots nil | 104 (defvar emacs-roots nil |
105 "List of plausible roots of the XEmacs hierarchy.") | 105 "List of plausible roots of the XEmacs hierarchy.") |
106 | 106 |
107 (defvar init-file-user nil | 107 (defvar user-init-directory-base ".xemacs" |
108 "Identity of user whose `.emacs' file is or was read. | 108 "Base of directory where user-installed init files may go.") |
109 The value is nil if no init file is being used; otherwise, it may be either | 109 |
110 the null string, meaning that the init file was taken from the user that | 110 (defvar user-init-file-base (cond |
111 originally logged in, or it may be a string containing a user's name. | 111 ((eq system-type 'ms-dos) "_emacs") |
112 | 112 (t ".emacs")) |
113 In either of the latter cases, `(concat \"~\" init-file-user \"/\")' | 113 "Base of init file.") |
114 evaluates to the name of the directory in which the `.emacs' file was | 114 |
115 searched for. | 115 (defvar user-init-directory |
116 | 116 (file-name-as-directory |
117 Setting `init-file-user' does not prevent Emacs from loading | 117 (paths-construct-path (list "~" user-init-directory-base))) |
118 `site-start.el'. The only way to do that is to use `--no-site-file'.") | 118 "Directory where user-installed init files may go.") |
119 | |
120 (defvar load-user-init-file-p t | |
121 "Non-nil if XEmacs should load the user's init file.") | |
119 | 122 |
120 ;; #### called `site-run-file' in FSFmacs | 123 ;; #### called `site-run-file' in FSFmacs |
121 | 124 |
122 (defvar site-start-file (purecopy "site-start") | 125 (defvar site-start-file (purecopy "site-start") |
123 "File containing site-wide run-time initializations. | 126 "File containing site-wide run-time initializations. |
224 -no-early-packages Do not process early packages. | 227 -no-early-packages Do not process early packages. |
225 -no-autoloads Do not load global symbol files (auto-autoloads) at | 228 -no-autoloads Do not load global symbol files (auto-autoloads) at |
226 startup. Also implies `-vanilla'. | 229 startup. Also implies `-vanilla'. |
227 -vanilla Equivalent to -q -no-site-file -no-early-packages. | 230 -vanilla Equivalent to -q -no-site-file -no-early-packages. |
228 -q Same as -no-init-file. | 231 -q Same as -no-init-file. |
232 -user-init-file <file> Use <file> as init file. | |
233 -user-init-directory <directory> use <directory> as init directory. | |
229 -user <user> Load user's init file instead of your own. | 234 -user <user> Load user's init file instead of your own. |
235 Equivalent to -user-init-file ~<user>/.emacs | |
236 -user-init-directory ~<user>/.xemacs/ | |
230 -u <user> Same as -user.\n") | 237 -u <user> Same as -user.\n") |
231 (let ((l command-switch-alist) | 238 (let ((l command-switch-alist) |
232 (insert (lambda (&rest x) | 239 (insert (lambda (&rest x) |
233 (princ " ") | 240 (princ " ") |
234 (let ((len 2)) | 241 (let ((len 2)) |
394 'external-debugging-output)) | 401 'external-debugging-output)) |
395 | 402 |
396 (if (null emacs-roots) | 403 (if (null emacs-roots) |
397 (startup-find-roots-warning) | 404 (startup-find-roots-warning) |
398 (startup-setup-paths emacs-roots | 405 (startup-setup-paths emacs-roots |
406 user-init-directory | |
399 inhibit-early-packages | 407 inhibit-early-packages |
400 inhibit-site-lisp | 408 inhibit-site-lisp |
401 debug-paths)) | 409 debug-paths)) |
402 (startup-setup-paths-warning)) | 410 (startup-setup-paths-warning)) |
403 | 411 |
489 ;; (string-match iso-8859-1-locale-regexp ctype))) | 497 ;; (string-match iso-8859-1-locale-regexp ctype))) |
490 ;; (progn | 498 ;; (progn |
491 ;; (standard-display-european t) | 499 ;; (standard-display-european t) |
492 ;; (require 'iso-syntax))) | 500 ;; (require 'iso-syntax))) |
493 | 501 |
494 ;; Figure out which user's init file to load, | 502 (setq load-user-init-file-p (not (noninteractive))) |
495 ;; either from the environment or from the options. | |
496 (setq init-file-user (if (noninteractive) nil (user-login-name))) | |
497 ;; If user has not done su, use current $HOME to find .emacs. | |
498 (and init-file-user (string= init-file-user (user-real-login-name)) | |
499 (setq init-file-user "")) | |
500 | 503 |
501 ;; Allow (at least) these arguments anywhere in the command line | 504 ;; Allow (at least) these arguments anywhere in the command line |
502 (let ((new-args nil) | 505 (let ((new-args nil) |
503 (arg nil)) | 506 (arg nil)) |
504 (while args | 507 (while args |
505 (setq arg (pop args)) | 508 (setq arg (pop args)) |
506 (cond | 509 (cond |
507 ((or (string= arg "-q") | 510 ((or (string= arg "-q") |
508 (string= arg "-no-init-file")) | 511 (string= arg "-no-init-file")) |
509 (setq init-file-user nil)) | 512 (setq load-user-init-file-p nil)) |
510 ((string= arg "-no-site-file") | 513 ((string= arg "-no-site-file") |
511 (setq site-start-file nil)) | 514 (setq site-start-file nil)) |
512 ((or (string= arg "-no-early-packages") | 515 ((or (string= arg "-no-early-packages") |
513 (string= arg "--no-early-packages")) | 516 (string= arg "--no-early-packages")) |
514 (setq inhibit-early-packages t)) | 517 (setq inhibit-early-packages t)) |
515 ((or (string= arg "-vanilla") | 518 ((or (string= arg "-vanilla") |
516 (string= arg "--vanilla") | 519 (string= arg "--vanilla") |
517 ;; Some work on this one already done in emacs.c. | 520 ;; Some work on this one already done in emacs.c. |
518 (string= arg "-no-autoloads") | 521 (string= arg "-no-autoloads") |
519 (string= arg "--no-autoloads")) | 522 (string= arg "--no-autoloads")) |
520 (setq init-file-user nil | 523 (setq load-user-init-file-p nil |
521 site-start-file nil)) | 524 site-start-file nil)) |
525 ((string= arg "-user-init-file") | |
526 (setq user-init-file (pop args))) | |
527 ((string= arg "-user-init-directory") | |
528 (setq user-init-directory (file-name-as-directory (pop args)))) | |
522 ((or (string= arg "-u") | 529 ((or (string= arg "-u") |
523 (string= arg "-user")) | 530 (string= arg "-user")) |
524 (setq init-file-user (pop args))) | 531 (let* ((user (pop args)) |
532 (home-user (concat "~" user))) | |
533 (setq user-init-file | |
534 (paths-construct-path (list home-user user-init-file-base))) | |
535 (setq user-init-directory | |
536 (file-name-as-directory | |
537 (paths-construct-path (list home-user user-init-directory-base)))))) | |
525 ((string= arg "-debug-init") | 538 ((string= arg "-debug-init") |
526 (setq init-file-debug t)) | 539 (setq init-file-debug t)) |
527 ((string= arg "-unmapped") | 540 ((string= arg "-unmapped") |
528 (setq initial-frame-unmapped-p t)) | 541 (setq initial-frame-unmapped-p t)) |
529 ((or (string= arg "-debug-paths") | 542 ((or (string= arg "-debug-paths") |
531 t) | 544 t) |
532 ((or (string= arg "--") (string= arg "-")) | 545 ((or (string= arg "--") (string= arg "-")) |
533 (while args | 546 (while args |
534 (push (pop args) new-args))) | 547 (push (pop args) new-args))) |
535 (t (push arg new-args)))) | 548 (t (push arg new-args)))) |
536 | 549 |
550 (setq init-file-user (and load-user-init-file-p "")) | |
551 | |
537 (nreverse new-args))) | 552 (nreverse new-args))) |
538 | 553 |
539 (defconst initial-scratch-message "\ | 554 (defconst initial-scratch-message "\ |
540 ;; This buffer is for notes you don't want to save, and for Lisp evaluation. | 555 ;; This buffer is for notes you don't want to save, and for Lisp evaluation. |
541 ;; If you want to create a file, first visit that file with C-x C-f, | 556 ;; If you want to create a file, first visit that file with C-x C-f, |
616 ;; Strip off last hyphen and what follows, then try again | 631 ;; Strip off last hyphen and what follows, then try again |
617 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) | 632 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) |
618 (setq term (substring term 0 hyphend)) | 633 (setq term (substring term 0 hyphend)) |
619 (setq term nil)))))) | 634 (setq term nil)))))) |
620 | 635 |
621 (defconst user-init-directory "/.xemacs/" | 636 (defun load-user-init-file () |
622 "Directory where user-installed packages may go.") | |
623 (define-obsolete-variable-alias | |
624 'emacs-user-extension-dir | |
625 'user-init-directory) | |
626 | |
627 (defun load-user-init-file (init-file-user) | |
628 "This function actually reads the init file, .emacs." | 637 "This function actually reads the init file, .emacs." |
629 (when init-file-user | 638 (if (not user-init-file) |
630 ;; purge references to init.el and options.el | 639 (setq user-init-file |
631 ;; convert these to use paths-construct-path for eventual migration to init.el | 640 (paths-construct-path (list "~" user-init-file-base)))) |
632 ;; needs to be converted when idiom for constructing "~user" paths is created | 641 (load user-init-file t t t) |
633 ; (setq user-init-file | 642 (unless inhibit-default-init |
634 ; (paths-construct-path (list (concat "~" init-file-user) | 643 (let ((inhibit-startup-message nil)) |
635 ; user-init-directory | 644 ;; Users are supposed to be told their rights. |
636 ; "init.el"))) | 645 ;; (Plus how to get help and how to undo.) |
637 ; (unless (file-exists-p (expand-file-name user-init-file)) | 646 ;; Don't you dare turn this off for anyone except yourself. |
638 (setq user-init-file | 647 (load "default" t t)))) |
639 (paths-construct-path (list (concat "~" init-file-user) | |
640 (cond | |
641 ((eq system-type 'ms-dos) "_emacs") | |
642 (t ".emacs"))))) | |
643 ; ) | |
644 (load user-init-file t t t) | |
645 ;; This should not be loaded since custom stuff currently goes into .emacs | |
646 ; (let ((default-custom-file | |
647 ; (paths-construct-path (list (concat "~" init-file-user) | |
648 ; user-init-directory | |
649 ; "options.el"))) | |
650 ; (when (string= custom-file default-custom-file) | |
651 ; (load default-custom-file t t))) | |
652 (unless inhibit-default-init | |
653 (let ((inhibit-startup-message nil)) | |
654 ;; Users are supposed to be told their rights. | |
655 ;; (Plus how to get help and how to undo.) | |
656 ;; Don't you dare turn this off for anyone except yourself. | |
657 (load "default" t t))))) | |
658 | 648 |
659 ;;; Load user's init file and default ones. | 649 ;;; Load user's init file and default ones. |
660 (defun load-init-file () | 650 (defun load-init-file () |
661 (run-hooks 'before-init-hook) | 651 (run-hooks 'before-init-hook) |
662 | 652 |
673 (let (debug-on-error-from-init-file | 663 (let (debug-on-error-from-init-file |
674 debug-on-error-should-be-set | 664 debug-on-error-should-be-set |
675 (debug-on-error-initial | 665 (debug-on-error-initial |
676 (if (eq init-file-debug t) 'startup init-file-debug))) | 666 (if (eq init-file-debug t) 'startup init-file-debug))) |
677 (let ((debug-on-error debug-on-error-initial)) | 667 (let ((debug-on-error debug-on-error-initial)) |
678 (if init-file-debug | 668 (if (and load-user-init-file-p init-file-debug) |
679 ;; Do this without a condition-case if the user wants to debug. | 669 ;; Do this without a condition-case if the user wants to debug. |
680 (load-user-init-file init-file-user) | 670 (load-user-init-file) |
681 (condition-case error | 671 (condition-case error |
682 (progn | 672 (progn |
683 (load-user-init-file init-file-user) | 673 (if load-user-init-file-p |
674 (load-user-init-file)) | |
684 (setq init-file-had-error nil)) | 675 (setq init-file-had-error nil)) |
685 (error | 676 (error |
686 (message "Error in init file: %s" (error-message-string error)) | 677 (message "Error in init file: %s" (error-message-string error)) |
687 (display-warning 'initialization | 678 (display-warning 'initialization |
688 (format "\ | 679 (format "\ |
1073 (or invocation-directory (setq invocation-directory default-directory)) | 1064 (or invocation-directory (setq invocation-directory default-directory)) |
1074 (setq invocation-directory | 1065 (setq invocation-directory |
1075 ;; don't let /tmp_mnt/... get into the load-path or exec-path. | 1066 ;; don't let /tmp_mnt/... get into the load-path or exec-path. |
1076 (abbreviate-file-name invocation-directory))) | 1067 (abbreviate-file-name invocation-directory))) |
1077 | 1068 |
1078 (defun startup-setup-paths (roots &optional | 1069 (defun startup-setup-paths (roots user-init-directory |
1070 &optional | |
1079 inhibit-early-packages inhibit-site-lisp | 1071 inhibit-early-packages inhibit-site-lisp |
1080 debug-paths) | 1072 debug-paths) |
1081 "Setup all the various paths. | 1073 "Setup all the various paths. |
1082 ROOTS is a list of plausible roots of the XEmacs directory hierarchy. | 1074 ROOTS is a list of plausible roots of the XEmacs directory hierarchy. |
1083 If INHIBIT-PACKAGES is non-NIL, don't do packages. | 1075 If INHIBIT-PACKAGES is non-NIL, don't do packages. |
1088 (apply #'(lambda (early late last) | 1080 (apply #'(lambda (early late last) |
1089 (setq early-packages (and (not inhibit-early-packages) | 1081 (setq early-packages (and (not inhibit-early-packages) |
1090 early)) | 1082 early)) |
1091 (setq late-packages late) | 1083 (setq late-packages late) |
1092 (setq last-packages last)) | 1084 (setq last-packages last)) |
1093 (packages-find-packages roots)) | 1085 (packages-find-packages |
1086 roots | |
1087 (packages-compute-package-locations user-init-directory))) | |
1094 | 1088 |
1095 (setq early-package-load-path (packages-find-package-load-path early-packages)) | 1089 (setq early-package-load-path (packages-find-package-load-path early-packages)) |
1096 (setq late-package-load-path (packages-find-package-load-path late-packages)) | 1090 (setq late-package-load-path (packages-find-package-load-path late-packages)) |
1097 (setq last-package-load-path (packages-find-package-load-path last-packages)) | 1091 (setq last-package-load-path (packages-find-package-load-path last-packages)) |
1098 | 1092 |