comparison lisp/startup.el @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children da8ed4261e83
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details. 20 ;; General Public License for more details.
21 21
22 ;; You should have received a copy of the GNU General Public License 22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the 23 ;; along with XEmacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, 59 Temple Place - Suite 330, 24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA. 25 ;; Boston, MA 02111-1307, USA.
26 26
27 ;;; Synched up with: FSF 19.34. 27 ;;; Synched up with: FSF 19.34.
28 28
29 ;;; Commentary: 29 ;;; Commentary:
30 30
31 ;; This file is dumped with XEmacs. 31 ;; This file is dumped with XEmacs.
32 32
33 ;; -batch, -t, and -nw are processed by main() in emacs.c and are 33 ;; -batch, -t, and -nw are processed by main() in emacs.c and are
34 ;; never seen by lisp code. 34 ;; never seen by lisp code.
35 35
36 ;; -version and -help are special-cased as well: they imply -batch, 36 ;; -version and -help are special-cased as well: they imply -batch,
37 ;; but are left on the list for lisp code to process. 37 ;; but are left on the list for lisp code to process.
38 38
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 user-init-directory-base ".xemacs" 107 (defvar init-file-user nil
108 "Base of directory where user-installed init files may go.") 108 "Identity of user whose `.emacs' file is or was read.
109 109 The value is nil if no init file is being used; otherwise, it may be either
110 (defvar user-init-directory 110 the null string, meaning that the init file was taken from the user that
111 (file-name-as-directory 111 originally logged in, or it may be a string containing a user's name.
112 (paths-construct-path (list "~" user-init-directory-base))) 112
113 "Directory where user-installed init files may go.") 113 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
114 114 evaluates to the name of the directory in which the `.emacs' file was
115 (defvar user-init-file-base "init.el" 115 searched for.
116 "Default name of the user init file if uncompiled. 116
117 This should be used for migration purposes only.") 117 Setting `init-file-user' does not prevent Emacs from loading
118 118 `site-start.el'. The only way to do that is to use `--no-site-file'.")
119 (defvar user-init-file-base-list '("init.elc" "init.el")
120 "List of allowed init files in the user's init directory.
121 The first one found takes precedence.")
122
123 (defvar user-home-init-file-base-list
124 (append '(".emacs.elc" ".emacs.el" ".emacs")
125 (and (eq system-type 'windows-nt)
126 '("_emacs.elc" "_emacs.el" "_emacs")))
127 "List of allowed init files in the user's home directory.
128 The first one found takes precedence.")
129
130 (defvar load-home-init-file nil
131 "Non-nil if XEmacs should load the init file from the home directory.
132 Otherwise, XEmacs will offer migration to the init directory.")
133
134 (defvar load-user-init-file-p t
135 "Non-nil if XEmacs should load the user's init file.")
136 119
137 ;; #### called `site-run-file' in FSFmacs 120 ;; #### called `site-run-file' in FSFmacs
138 121
139 (defvar site-start-file (purecopy "site-start") 122 (defvar site-start-file (purecopy "site-start")
140 "File containing site-wide run-time initializations. 123 "File containing site-wide run-time initializations.
215 "Print the XEmacs usage message and exit." 198 "Print the XEmacs usage message and exit."
216 (let ((standard-output 'external-debugging-output)) 199 (let ((standard-output 'external-debugging-output))
217 (princ (concat "\n" (emacs-version) "\n\n")) 200 (princ (concat "\n" (emacs-version) "\n\n"))
218 (princ 201 (princ
219 (if (featurep 'x) 202 (if (featurep 'x)
220 (concat "When creating a window on an X display, " 203 (concat (emacs-name)
221 (emacs-name) 204 " accepts all standard X Toolkit command line options.\n"
222 " accepts all standard X Toolkit 205 "In addition, the")
223 command line options plus the following:
224 -iconname <title> Use title as the icon name.
225 -mc <color> Use color as the mouse color.
226 -cr <color> Use color as the text-cursor foregound color.
227 -private Install a private colormap.
228
229 In addition, the")
230 "The")) 206 "The"))
231 (princ " following options are accepted: 207 (princ " following options are accepted:
208
232 -t <device> Use TTY <device> instead of the terminal for input 209 -t <device> Use TTY <device> instead of the terminal for input
233 and output. This implies the -nw option. 210 and output. This implies the -nw option.
234 -nw Inhibit the use of any window-system-specific 211 -nw Inhibit the use of any window-system-specific
235 display code: use the current tty. 212 display code: use the current tty.
236 -batch Execute noninteractively (messages go to stderr). 213 -batch Execute noninteractively (messages go to stderr).
241 -no-early-packages Do not process early packages. 218 -no-early-packages Do not process early packages.
242 -no-autoloads Do not load global symbol files (auto-autoloads) at 219 -no-autoloads Do not load global symbol files (auto-autoloads) at
243 startup. Also implies `-vanilla'. 220 startup. Also implies `-vanilla'.
244 -vanilla Equivalent to -q -no-site-file -no-early-packages. 221 -vanilla Equivalent to -q -no-site-file -no-early-packages.
245 -q Same as -no-init-file. 222 -q Same as -no-init-file.
246 -user-init-file <file> Use <file> as init file.
247 -user-init-directory <directory> use <directory> as init directory.
248 -user <user> Load user's init file instead of your own. 223 -user <user> Load user's init file instead of your own.
249 Equivalent to -user-init-file ~<user>/.emacs
250 -user-init-directory ~<user>/.xemacs/
251 -u <user> Same as -user.\n") 224 -u <user> Same as -user.\n")
252 (let ((l command-switch-alist) 225 (let ((l command-switch-alist)
253 (insert (lambda (&rest x) 226 (insert (lambda (&rest x)
254 (princ " ") 227 (princ " ")
255 (let ((len 2)) 228 (let ((len 2))
380 (princ (format "\ndoc-directory is %S" doc-directory) stream) 353 (princ (format "\ndoc-directory is %S" doc-directory) stream)
381 (princ (format "\nload-path is %S" load-path) stream) 354 (princ (format "\nload-path is %S" load-path) stream)
382 (princ "\n\n" stream))) 355 (princ "\n\n" stream)))
383 (when (not suppress-early-error-handler-backtrace) 356 (when (not suppress-early-error-handler-backtrace)
384 (backtrace stream t))) 357 (backtrace stream t)))
385 (if (fboundp 'mswindows-message-box)
386 (mswindows-message-box "Initialization error"))
387 (kill-emacs -1)) 358 (kill-emacs -1))
359
360 (defvar lock-directory)
361 (defvar superlock-file)
388 362
389 (defun normal-top-level () 363 (defun normal-top-level ()
390 (if command-line-processed 364 (if command-line-processed
391 (message "Back to top level.") 365 (message "Back to top level.")
392 (setq command-line-processed t) 366 (setq command-line-processed t)
406 (and (getenv "EMACSDEBUGPATHS") 380 (and (getenv "EMACSDEBUGPATHS")
407 t)))) 381 t))))
408 382
409 (setq emacs-roots (paths-find-emacs-roots invocation-directory 383 (setq emacs-roots (paths-find-emacs-roots invocation-directory
410 invocation-name)) 384 invocation-name))
411 385
412 (if debug-paths 386 (if debug-paths
413 (princ (format "emacs-roots:\n%S\n" emacs-roots) 387 (princ (format "emacs-roots:\n%S\n" emacs-roots)
414 'external-debugging-output)) 388 'external-debugging-output))
415 389
416 (if (null emacs-roots) 390 (if (null emacs-roots)
417 (startup-find-roots-warning) 391 (startup-find-roots-warning)
418 (startup-setup-paths emacs-roots 392 (startup-setup-paths emacs-roots
419 user-init-directory
420 inhibit-early-packages 393 inhibit-early-packages
421 inhibit-site-lisp 394 inhibit-site-lisp
422 debug-paths)) 395 debug-paths))
423 (startup-setup-paths-warning)) 396 (startup-setup-paths-warning))
424 397
425 (if (and (not inhibit-autoloads) 398 (if (and (not inhibit-autoloads)
426 lisp-directory) 399 lisp-directory)
427 (load (expand-file-name (file-name-sans-extension autoload-file-name) 400 (load (expand-file-name (file-name-sans-extension autoload-file-name)
428 lisp-directory) nil t)) 401 lisp-directory) nil t))
429 402
430 (if (not inhibit-autoloads) 403 (if (not inhibit-autoloads)
431 (progn 404 (progn
432 (if (not inhibit-early-packages) 405 (if (not inhibit-early-packages)
433 (packages-load-package-auto-autoloads early-package-load-path)) 406 (packages-load-package-auto-autoloads early-package-load-path))
434 (packages-load-package-auto-autoloads late-package-load-path) 407 (packages-load-package-auto-autoloads late-package-load-path)
458 ;; (if (fboundp 'font-menu-add-default) 431 ;; (if (fboundp 'font-menu-add-default)
459 ;; (font-menu-add-default)) 432 ;; (font-menu-add-default))
460 (when window-setup-hook 433 (when window-setup-hook
461 (run-hooks 'window-setup-hook)) 434 (run-hooks 'window-setup-hook))
462 (setq window-setup-hook nil)) 435 (setq window-setup-hook nil))
463
464 (if load-user-init-file-p
465 (maybe-migrate-user-init-file))
466 ;;####FSFmacs junk 436 ;;####FSFmacs junk
467 ;; (or menubar-bindings-done 437 ;; (or menubar-bindings-done
468 ;; (precompute-menubar-bindings)) 438 ;; (precompute-menubar-bindings))
469 )) 439 ))
470 440
509 ;; (and (not (equal string "")) string)) 479 ;; (and (not (equal string "")) string))
510 ;; (let ((string (getenv "LANG"))) 480 ;; (let ((string (getenv "LANG")))
511 ;; (and (not (equal string "")) string))))) 481 ;; (and (not (equal string "")) string)))))
512 ;; (and ctype 482 ;; (and ctype
513 ;; (string-match iso-8859-1-locale-regexp ctype))) 483 ;; (string-match iso-8859-1-locale-regexp ctype)))
514 ;; (progn 484 ;; (progn
515 ;; (standard-display-european t) 485 ;; (standard-display-european t)
516 ;; (require 'iso-syntax))) 486 ;; (require 'iso-syntax)))
517 487
518 (setq load-user-init-file-p (not (noninteractive))) 488 ;; Figure out which user's init file to load,
489 ;; either from the environment or from the options.
490 (setq init-file-user (if (noninteractive) nil (user-login-name)))
491 ;; If user has not done su, use current $HOME to find .emacs.
492 (and init-file-user (string= init-file-user (user-real-login-name))
493 (setq init-file-user ""))
519 494
520 ;; Allow (at least) these arguments anywhere in the command line 495 ;; Allow (at least) these arguments anywhere in the command line
521 (let ((new-args nil) 496 (let ((new-args nil)
522 (arg nil)) 497 (arg nil))
523 (while args 498 (while args
524 (setq arg (pop args)) 499 (setq arg (pop args))
525 (cond 500 (cond
526 ((or (string= arg "-q") 501 ((or (string= arg "-q")
527 (string= arg "-no-init-file")) 502 (string= arg "-no-init-file"))
528 (setq load-user-init-file-p nil)) 503 (setq init-file-user nil))
529 ((string= arg "-no-site-file") 504 ((string= arg "-no-site-file")
530 (setq site-start-file nil)) 505 (setq site-start-file nil))
531 ((or (string= arg "-no-early-packages") 506 ((or (string= arg "-no-early-packages")
532 (string= arg "--no-early-packages")) 507 (string= arg "--no-early-packages"))
533 (setq inhibit-early-packages t)) 508 (setq inhibit-early-packages t))
534 ((or (string= arg "-vanilla") 509 ((or (string= arg "-vanilla")
535 (string= arg "--vanilla") 510 (string= arg "--vanilla")
536 ;; Some work on this one already done in emacs.c. 511 ;; Some work on this one already done in emacs.c.
537 (string= arg "-no-autoloads") 512 (string= arg "-no-autoloads")
538 (string= arg "--no-autoloads")) 513 (string= arg "--no-autoloads"))
539 (setq load-user-init-file-p nil 514 (setq init-file-user nil
540 site-start-file nil)) 515 site-start-file nil))
541 ((string= arg "-user-init-file")
542 (setq user-init-file (pop args)))
543 ((string= arg "-user-init-directory")
544 (setq user-init-directory (file-name-as-directory (pop args))))
545 ((or (string= arg "-u") 516 ((or (string= arg "-u")
546 (string= arg "-user")) 517 (string= arg "-user"))
547 (let* ((user (pop args)) 518 (setq init-file-user (pop args)))
548 (home-user (concat "~" user)))
549 (setq user-init-directory (file-name-as-directory
550 (paths-construct-path
551 (list home-user user-init-directory-base))))
552 (setq user-init-file
553 (find-user-init-file user-init-directory home-user))
554 (setq custom-file
555 (make-custom-file-name user-init-file))))
556 ((string= arg "-debug-init") 519 ((string= arg "-debug-init")
557 (setq init-file-debug t)) 520 (setq init-file-debug t))
558 ((string= arg "-unmapped") 521 ((string= arg "-unmapped")
559 (setq initial-frame-unmapped-p t)) 522 (setq initial-frame-unmapped-p t))
560 ((or (string= arg "-debug-paths") 523 ((or (string= arg "-debug-paths")
562 t) 525 t)
563 ((or (string= arg "--") (string= arg "-")) 526 ((or (string= arg "--") (string= arg "-"))
564 (while args 527 (while args
565 (push (pop args) new-args))) 528 (push (pop args) new-args)))
566 (t (push arg new-args)))) 529 (t (push arg new-args))))
567 530
568 (setq init-file-user (and load-user-init-file-p ""))
569
570 (nreverse new-args))) 531 (nreverse new-args)))
571 532
572 (defconst initial-scratch-message "\ 533 (defconst initial-scratch-message "\
573 ;; This buffer is for notes you don't want to save, and for Lisp evaluation. 534 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
574 ;; If you want to create a file, first visit that file with C-x C-f, 535 ;; If you want to create a file, first visit that file with C-x C-f,
605 566
606 ;; When not in batch mode, this creates the first visible frame, 567 ;; When not in batch mode, this creates the first visible frame,
607 ;; and deletes the stdio device. 568 ;; and deletes the stdio device.
608 (frame-initialize)) 569 (frame-initialize))
609 570
610 ;; Reinitialize faces if necessary. This function changes face if
611 ;; it is created during auto-autoloads loading. Otherwise, it
612 ;; does nothing.
613 (startup-initialize-custom-faces)
614
615 ;; 571 ;;
616 ;; We have normality, I repeat, we have normality. Anything you still 572 ;; We have normality, I repeat, we have normality. Anything you still
617 ;; can't cope with is therefore your own problem. (And we don't need 573 ;; can't cope with is therefore your own problem. (And we don't need
618 ;; to kill XEmacs for it.) 574 ;; to kill XEmacs for it.)
619 ;; 575 ;;
620 576
621 ;;; Load init files. 577 ;;; Load init files.
622 (load-init-file) 578 (load-init-file)
623 579
624 (with-current-buffer (get-buffer "*scratch*") 580 (with-current-buffer (get-buffer "*scratch*")
625 (erase-buffer) 581 (erase-buffer)
626 ;; (insert initial-scratch-message) 582 ;; (insert initial-scratch-message)
627 (set-buffer-modified-p nil) 583 (set-buffer-modified-p nil)
628 (when (eq major-mode 'fundamental-mode) 584 (when (eq major-mode 'fundamental-mode)
643 ;; until after the splash screen. 599 ;; until after the splash screen.
644 (setq inhibit-warning-display nil) 600 (setq inhibit-warning-display nil)
645 ;; If -batch, terminate after processing the command options. 601 ;; If -batch, terminate after processing the command options.
646 (when (noninteractive) (kill-emacs t)))) 602 (when (noninteractive) (kill-emacs t))))
647 603
648 (defun load-terminal-library () 604 (defun load-terminal-library ()
649 (when term-file-prefix 605 (when term-file-prefix
650 (let ((term (getenv "TERM")) 606 (let ((term (getenv "TERM"))
651 hyphend) 607 hyphend)
652 (while (and term 608 (while (and term
653 (not (load (concat term-file-prefix term) t t))) 609 (not (load (concat term-file-prefix term) t t)))
654 ;; Strip off last hyphen and what follows, then try again 610 ;; Strip off last hyphen and what follows, then try again
655 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) 611 (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
656 (setq term (substring term 0 hyphend)) 612 (setq term (substring term 0 hyphend))
657 (setq term nil)))))) 613 (setq term nil))))))
658 614
659 (defun find-user-init-directory-init-file (&optional init-directory) 615 (defconst user-init-directory "/.xemacs/"
660 "Determine the user's init file if in the init directory." 616 "Directory where user-installed packages may go.")
661 (let ((init-directory (or init-directory user-init-directory))) 617 (define-obsolete-variable-alias
662 (catch 'found 618 'emacs-user-extension-dir
663 (dolist (file user-init-file-base-list) 619 'user-init-directory)
664 (let ((expanded (expand-file-name file init-directory))) 620
665 (when (file-exists-p expanded) 621 (defun load-user-init-file (init-file-user)
666 (throw 'found expanded))))))) 622 "This function actually reads the init file, .emacs."
667 623 (when init-file-user
668 (defun find-user-home-directory-init-file (&optional home-directory) 624 ;; purge references to init.el and options.el
669 "Determine the user's init file if in the home directory." 625 ;; convert these to use paths-construct-path for eventual migration to init.el
670 (let ((home-directory (or home-directory "~"))) 626 ;; needs to be converted when idiom for constructing "~user" paths is created
671 (catch 'found 627 ; (setq user-init-file
672 (dolist (file user-home-init-file-base-list) 628 ; (paths-construct-path (list (concat "~" init-file-user)
673 (let ((expanded (expand-file-name file home-directory))) 629 ; user-init-directory
674 (when (file-exists-p expanded) 630 ; "init.el")))
675 (throw 'found expanded)))) 631 ; (unless (file-exists-p (expand-file-name user-init-file))
676 nil))) 632 (setq user-init-file
677 633 (paths-construct-path (list (concat "~" init-file-user)
678 (defun find-user-init-file (&optional init-directory home-directory) 634 (cond
679 "Determine the user's init file." 635 ((eq system-type 'ms-dos) "_emacs")
680 (if load-home-init-file 636 (t ".emacs")))))
681 (find-user-home-directory-init-file home-directory) 637 ; )
682 (or (find-user-init-directory-init-file init-directory) 638 (load user-init-file t t t)
683 (find-user-home-directory-init-file home-directory)))) 639 ;; This should not be loaded since custom stuff currently goes into .emacs
684 640 ; (let ((default-custom-file
685 (defun maybe-migrate-user-init-file () 641 ; (paths-construct-path (list (concat "~" init-file-user)
686 "Ask user if she wants to migrate the init file(s) to new location." 642 ; user-init-directory
687 (if (and (not load-home-init-file) 643 ; "options.el")))
688 (not (find-user-init-directory-init-file user-init-directory)) 644 ; (when (string= custom-file default-custom-file)
689 (file-exists-p user-init-file)) 645 ; (load default-custom-file t t)))
690 (if (with-output-to-temp-buffer (help-buffer-name nil) 646 (unless inhibit-default-init
691 (progn 647 (let ((inhibit-startup-message nil))
692 (princ "XEmacs recommends that the initialization code in 648 ;; Users are supposed to be told their rights.
693 ") 649 ;; (Plus how to get help and how to undo.)
694 (princ user-init-file) 650 ;; Don't you dare turn this off for anyone except yourself.
695 (princ " 651 (load "default" t t)))))
696 be migrated to the ")
697 (princ user-init-directory)
698 (princ " directory. XEmacs can
699 perform the migration automatically.
700
701 After the migration, init.el/init.elc holds user-written
702 initialization code. Moreover the customize settings will be in
703 custom.el.
704
705 If you choose not to do this now, XEmacs will not ask you this
706 question in the future. However, you can still make XEmacs
707 perform the migration at any time with M-x migrate-user-init-file.")
708 (show-temp-buffer-in-current-frame standard-output)
709 (yes-or-no-p-minibuf (concat "Migrate init file to "
710 user-init-directory
711 "? "))))
712 (migrate-user-init-file)
713 (customize-save-variable 'load-home-init-file t))))
714
715 (defun migrate-user-init-file ()
716 "Migrate the init file from the home directory."
717 (interactive)
718 (if (not (file-exists-p user-init-directory))
719 (progn
720 (message "Creating %s directory..." user-init-directory)
721 (make-directory user-init-directory)))
722 (message "Migrating custom file...")
723 (custom-migrate-custom-file (make-custom-file-name user-init-file
724 'force-new))
725 (message "Moving init file...")
726 (rename-file user-init-file
727 (expand-file-name user-init-file-base
728 user-init-directory))
729 (message "Migration done."))
730
731 (defun load-user-init-file ()
732 "This function actually reads the init file."
733 (if (or user-init-file
734 (setq user-init-file (find-user-init-file user-init-directory)))
735 (load user-init-file t t t))
736 (if (not custom-file)
737 (setq custom-file (make-custom-file-name user-init-file)))
738 (if (and (not (string= custom-file user-init-file))
739 (file-exists-p custom-file))
740 (load custom-file t t t))
741 (unless inhibit-default-init
742 (let ((inhibit-startup-message nil))
743 ;; Users are supposed to be told their rights.
744 ;; (Plus how to get help and how to undo.)
745 ;; Don't you dare turn this off for anyone except yourself.
746 (load "default" t t))))
747 652
748 ;;; Load user's init file and default ones. 653 ;;; Load user's init file and default ones.
749 (defun load-init-file () 654 (defun load-init-file ()
750 (run-hooks 'before-init-hook) 655 (run-hooks 'before-init-hook)
751 656
762 (let (debug-on-error-from-init-file 667 (let (debug-on-error-from-init-file
763 debug-on-error-should-be-set 668 debug-on-error-should-be-set
764 (debug-on-error-initial 669 (debug-on-error-initial
765 (if (eq init-file-debug t) 'startup init-file-debug))) 670 (if (eq init-file-debug t) 'startup init-file-debug)))
766 (let ((debug-on-error debug-on-error-initial)) 671 (let ((debug-on-error debug-on-error-initial))
767 (if (and load-user-init-file-p init-file-debug) 672 (if init-file-debug
768 (progn 673 ;; Do this without a condition-case if the user wants to debug.
769 ;; Do this without a condition-case if the user wants to debug. 674 (load-user-init-file init-file-user)
770 (load-user-init-file))
771 (condition-case error 675 (condition-case error
772 (progn 676 (progn
773 (if load-user-init-file-p 677 (load-user-init-file init-file-user)
774 (load-user-init-file))
775 (setq init-file-had-error nil)) 678 (setq init-file-had-error nil))
776 (error 679 (error
777 (message "Error in init file: %s" (error-message-string error)) 680 (message "Error in init file: %s" (error-message-string error))
778 (display-warning 'initialization 681 (display-warning 'initialization
779 (format "\ 682 (format "\
862 ;; Command-line-options exist 765 ;; Command-line-options exist
863 (let ((dir command-line-default-directory) 766 (let ((dir command-line-default-directory)
864 (file-count 0) 767 (file-count 0)
865 (line nil) 768 (line nil)
866 (end-of-options nil) 769 (end-of-options nil)
867 file-p arg tem) 770 first-file-buffer file-p arg tem)
868 (while command-line-args-left 771 (while command-line-args-left
869 (setq arg (pop command-line-args-left)) 772 (setq arg (pop command-line-args-left))
870 (cond 773 (cond
871 (end-of-options 774 (end-of-options
872 (setq file-p t)) 775 (setq file-p t))
883 ;; This is worthless; the `unixoid' way is "./file". -jwz 786 ;; This is worthless; the `unixoid' way is "./file". -jwz
884 ((or (string= arg "-") (string= arg "--")) 787 ((or (string= arg "-") (string= arg "--"))
885 (setq end-of-options t)) 788 (setq end-of-options t))
886 (t 789 (t
887 (setq file-p t))) 790 (setq file-p t)))
888 791
889 (when file-p 792 (when file-p
890 (setq file-p nil) 793 (setq file-p nil)
891 (incf file-count) 794 (incf file-count)
892 (setq arg (expand-file-name arg dir)) 795 (setq arg (expand-file-name arg dir))
893 (cond 796 (cond
894 ((= file-count 1) 797 ((= file-count 1) (setq first-file-buffer
895 (find-file arg)) 798 (progn (find-file arg) (current-buffer))))
896 (noninteractive (find-file arg)) 799 (noninteractive (find-file arg))
897 (t (find-file-other-window arg))) 800 (t (find-file-other-window arg)))
898 (when line 801 (when line
899 (goto-line line) 802 (goto-line line)
900 (setq line nil)))))))) 803 (setq line nil))))))))
921 (let ((map e) 824 (let ((map e)
922 (overriding-local-map (indirect-function e))) 825 (overriding-local-map (indirect-function e)))
923 (setq e (read-key-sequence 826 (setq e (read-key-sequence
924 (let ((p (keymap-prompt map t))) 827 (let ((p (keymap-prompt map t)))
925 (cond ((symbolp map) 828 (cond ((symbolp map)
926 (if p 829 (if p
927 (format "%s %s " map p) 830 (format "%s %s " map p)
928 (format "%s " map))) 831 (format "%s " map)))
929 (p) 832 (p)
930 (t 833 (t
931 (prin1-to-string map)))))) 834 (prin1-to-string map))))))
1000 (error "WTF!?")))) 903 (error "WTF!?"))))
1001 904
1002 (defun startup-center-spaces (glyph) 905 (defun startup-center-spaces (glyph)
1003 ;; Return the number of spaces to insert in order to center 906 ;; Return the number of spaces to insert in order to center
1004 ;; the given glyph (may be a string or a pixmap). 907 ;; the given glyph (may be a string or a pixmap).
1005 ;; Assume spaces are as wide as avg-pixwidth. 908 ;; Assume spaces are as wide as avg-pixwidth.
1006 ;; Won't be quite right for proportional fonts, but it's the best we can do. 909 ;; Won't be quite right for proportional fonts, but it's the best we can do.
1007 ;; Maybe the new redisplay will export something a glyph-width function. 910 ;; Maybe the new redisplay will export something a glyph-width function.
1008 ;;; #### Yes, there is a glyph-width function but it isn't quite what 911 ;;; #### Yes, there is a glyph-width function but it isn't quite what
1009 ;;; #### this was expecting. Or is it? 912 ;;; #### this was expecting. Or is it?
1010 ;; (An alternate way to get avg-pixwidth would be to use x-font-properties 913 ;; (An alternate way to get avg-pixwidth would be to use x-font-properties
1011 ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.) 914 ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.)
1012 915
1013 ;; This function is used in about.el too. 916 ;; This function is used in about.el too.
1014 (let* ((avg-pixwidth (round (/ (frame-pixel-width) (frame-width)))) 917 (let* ((avg-pixwidth (round (/ (frame-pixel-width) (frame-width))))
1015 (fill-area-width (* avg-pixwidth (- fill-column left-margin))) 918 (fill-area-width (* avg-pixwidth (- fill-column left-margin)))
1016 (glyph-pixwidth (cond ((stringp glyph) 919 (glyph-pixwidth (cond ((stringp glyph)
1017 (* avg-pixwidth (length glyph))) 920 (* avg-pixwidth (length glyph)))
1018 ;; #### the pixmap option should be removed 921 ;; #### the pixmap option should be removed
1019 ;;((pixmapp glyph) 922 ;;((pixmapp glyph)
1020 ;; (pixmap-width glyph)) 923 ;; (pixmap-width glyph))
1021 ((glyphp glyph) 924 ((glyphp glyph)
1031 "Please visit the XEmacs website at http://www.xemacs.org !\n\n" 934 "Please visit the XEmacs website at http://www.xemacs.org !\n\n"
1032 ,@(if (featurep 'sparcworks) 935 ,@(if (featurep 'sparcworks)
1033 `( "\ 936 `( "\
1034 Sun provides support for the WorkShop/XEmacs integration package only. 937 Sun provides support for the WorkShop/XEmacs integration package only.
1035 All other XEmacs packages are provided to you \"AS IS\".\n" 938 All other XEmacs packages are provided to you \"AS IS\".\n"
1036 ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") 939 ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES")
1037 (getenv "LANG")))) 940 (getenv "LANG"))))
1038 (if (and 941 (if (and
1039 (not (featurep 'mule)) ;; Already got mule? 942 (not (featurep 'mule)) ;; Already got mule?
1040 ;; No Mule support on tty's yet 943 ;; No Mule support on tty's yet
1041 (not (eq 'tty (console-type))) 944 (not (eq 'tty (console-type)))
1042 lang ;; Non-English locale? 945 lang ;; Non-English locale?
1043 (not (string= lang "C")) 946 (not (string= lang "C"))
1044 (not (string-match "^en" lang)) 947 (not (string-match "^en" lang))
1045 ;; Comes with Sun WorkShop 948 ;; Comes with Sun WorkShop
1046 (locate-file "xemacs-mule" exec-path)) 949 (locate-file "xemacs-mule" exec-path))
1048 This version of XEmacs has been built with support for Latin-1 languages only. 951 This version of XEmacs has been built with support for Latin-1 languages only.
1049 To handle other languages you need to run a Multi-lingual (`Mule') version of 952 To handle other languages you need to run a Multi-lingual (`Mule') version of
1050 XEmacs, by either running the command `xemacs-mule', or by using the X resource 953 XEmacs, by either running the command `xemacs-mule', or by using the X resource
1051 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop. 954 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop.
1052 \n"))))) 955 \n")))))
1053 ((key describe-no-warranty) 956 ((key describe-no-warranty)
1054 ": "(face (red bold) "XEmacs comes with ABSOLUTELY NO WARRANTY\n")) 957 ": "(face (red bold) "XEmacs comes with ABSOLUTELY NO WARRANTY\n"))
1055 ((key describe-copying) 958 ((key describe-copying)
1056 ": conditions to give out copies of XEmacs\n") 959 ": conditions to give out copies of XEmacs\n")
1057 ((key describe-distribution) 960 ((key describe-distribution)
1058 ": how to get the latest version\n") 961 ": how to get the latest version\n")
1061 Copyright (C) 1985-1999 Free Software Foundation, Inc. 964 Copyright (C) 1985-1999 Free Software Foundation, Inc.
1062 Copyright (C) 1990-1994 Lucid, Inc. 965 Copyright (C) 1990-1994 Lucid, Inc.
1063 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved. 966 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved.
1064 Copyright (C) 1994-1996 Board of Trustees, University of Illinois 967 Copyright (C) 1994-1996 Board of Trustees, University of Illinois
1065 Copyright (C) 1995-1996 Ben Wing\n")) 968 Copyright (C) 1995-1996 Ben Wing\n"))
1066 969
1067 ((face (blue bold underline) "\nInformation, on-line help:\n\n") 970 ((face (blue bold underline) "\nInformation, on-line help:\n\n")
1068 "XEmacs comes with plenty of documentation...\n\n" 971 "XEmacs comes with plenty of documentation...\n\n"
1069 ,@(if (string-match "beta" emacs-version) 972 ,@(if (string-match "beta" emacs-version)
1070 `((key describe-beta) 973 `((key describe-beta)
1071 ": " (face (red bold) 974 ": " (face (red bold)
1072 "This is an Experimental version of XEmacs.\n")) 975 "This is an Experimental version of XEmacs.\n"))
1073 `( "\n")) 976 `( "\n"))
1074 ((key xemacs-local-faq) 977 ((key xemacs-local-faq)
1075 ": read the XEmacs FAQ (a " (face underline "capital") " F!)\n") 978 ": read the XEmacs FAQ (a " (face underline "capital") " F!)\n")
1094 ;; I really hate global variables, oh well. 997 ;; I really hate global variables, oh well.
1095 ;(defvar xemacs-startup-logo-function nil 998 ;(defvar xemacs-startup-logo-function nil
1096 ; "If non-nil, function called to provide the startup logo. 999 ; "If non-nil, function called to provide the startup logo.
1097 ;This function should return an initialized glyph if it is used.") 1000 ;This function should return an initialized glyph if it is used.")
1098 1001
1099 ;; This will hopefully go away when gettext is functional. 1002 ;; This will hopefully go away when gettext is functionnal.
1100 (defconst splash-frame-static-body 1003 (defconst splash-frame-static-body
1101 `(,(emacs-version) "\n\n" 1004 `(,(emacs-version) "\n\n"
1102 (face italic "`C-' means the control key,`M-' means the meta key\n\n"))) 1005 (face italic "`C-' means the control key,`M-' means the meta key\n\n")))
1103 1006
1104 1007
1115 (if (= indice (- (length elements) 1)) 1018 (if (= indice (- (length elements) 1))
1116 0 1019 0
1117 (1+ indice ))) 1020 (1+ indice )))
1118 ))) 1021 )))
1119 1022
1120 ;; #### This function now returns the (possibly nil) timeout circulating the 1023 ;; ### This function now returns the (possibly nil) timeout circulating the
1121 ;; splash-frame elements 1024 ;; splash-frame elements
1122 (defun display-splash-frame () 1025 (defun display-splash-frame ()
1123 (let ((logo xemacs-logo) 1026 (let ((logo xemacs-logo)
1124 (buffer-read-only nil) 1027 (buffer-read-only nil)
1125 (cramped-p (eq 'tty (console-type)))) 1028 (cramped-p (eq 'tty (console-type))))
1164 (or invocation-directory (setq invocation-directory default-directory)) 1067 (or invocation-directory (setq invocation-directory default-directory))
1165 (setq invocation-directory 1068 (setq invocation-directory
1166 ;; don't let /tmp_mnt/... get into the load-path or exec-path. 1069 ;; don't let /tmp_mnt/... get into the load-path or exec-path.
1167 (abbreviate-file-name invocation-directory))) 1070 (abbreviate-file-name invocation-directory)))
1168 1071
1169 (defun startup-setup-paths (roots user-init-directory 1072 (defun startup-setup-paths (roots &optional
1170 &optional
1171 inhibit-early-packages inhibit-site-lisp 1073 inhibit-early-packages inhibit-site-lisp
1172 debug-paths) 1074 debug-paths)
1173 "Setup all the various paths. 1075 "Setup all the various paths.
1174 ROOTS is a list of plausible roots of the XEmacs directory hierarchy. 1076 ROOTS is a list of plausible roots of the XEmacs directory hierarchy.
1175 If INHIBIT-PACKAGES is non-NIL, don't do packages. 1077 If INHIBIT-PACKAGES is non-NIL, don't do packages.
1180 (apply #'(lambda (early late last) 1082 (apply #'(lambda (early late last)
1181 (setq early-packages (and (not inhibit-early-packages) 1083 (setq early-packages (and (not inhibit-early-packages)
1182 early)) 1084 early))
1183 (setq late-packages late) 1085 (setq late-packages late)
1184 (setq last-packages last)) 1086 (setq last-packages last))
1185 (packages-find-packages 1087 (packages-find-packages roots))
1186 roots
1187 (packages-compute-package-locations user-init-directory)))
1188 1088
1189 (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))
1190 (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))
1191 (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))
1192 1092
1226 1126
1227 (setq Info-directory-list 1127 (setq Info-directory-list
1228 (paths-construct-info-path roots 1128 (paths-construct-info-path roots
1229 early-packages late-packages last-packages)) 1129 early-packages late-packages last-packages))
1230 1130
1231 1131
1232 (if debug-paths 1132 (if debug-paths
1233 (princ (format "Info-directory-list:\n%S\n" Info-directory-list) 1133 (princ (format "Info-directory-list:\n%S\n" Info-directory-list)
1234 'external-debugging-output)) 1134 'external-debugging-output))
1235 1135
1136 (if (boundp 'lock-directory)
1137 (progn
1138 (setq lock-directory (paths-find-lock-directory roots))
1139 (setq superlock-file (paths-find-superlock-file lock-directory))
1140
1141 (if debug-paths
1142 (progn
1143 (princ (format "lock-directory:\n%S\n" lock-directory)
1144 'external-debugging-output)
1145 (princ (format "superlock-file:\n%S\n" superlock-file)
1146 'external-debugging-output)))))
1147
1236 (setq exec-directory (paths-find-exec-directory roots)) 1148 (setq exec-directory (paths-find-exec-directory roots))
1237 1149
1238 (if debug-paths 1150 (if debug-paths
1239 (princ (format "exec-directory:\n%s\n" exec-directory) 1151 (princ (format "exec-directory:\n%s\n" exec-directory)
1240 'external-debugging-output)) 1152 'external-debugging-output))
1244 early-packages late-packages last-packages)) 1156 early-packages late-packages last-packages))
1245 1157
1246 (if debug-paths 1158 (if debug-paths
1247 (princ (format "exec-path:\n%S\n" exec-path) 1159 (princ (format "exec-path:\n%S\n" exec-path)
1248 'external-debugging-output)) 1160 'external-debugging-output))
1249 1161
1250 (setq doc-directory (paths-find-doc-directory roots)) 1162 (setq doc-directory (paths-find-doc-directory roots))
1251 1163
1252 (if debug-paths 1164 (if debug-paths
1253 (princ (format "doc-directory:\n%S\n" doc-directory) 1165 (princ (format "doc-directory:\n%S\n" doc-directory)
1254 'external-debugging-output)) 1166 'external-debugging-output))
1278 1190
1279 (princ "\nWARNING:\n" 'external-debugging-output) 1191 (princ "\nWARNING:\n" 'external-debugging-output)
1280 (princ (buffer-string) 'external-debugging-output))) 1192 (princ (buffer-string) 'external-debugging-output)))
1281 1193
1282 (defun startup-setup-paths-warning () 1194 (defun startup-setup-paths-warning ()
1283 (let ((warnings '())) 1195 (let ((lock (if (boundp 'lock-directory) lock-directory 't))
1196 (warnings '()))
1197 (if (and (stringp lock) (null (file-directory-p lock)))
1198 (setq lock nil))
1284 (cond 1199 (cond
1285 ((null (and lisp-directory exec-directory data-directory doc-directory 1200 ((null (and lisp-directory exec-directory data-directory doc-directory
1286 load-path)) 1201 load-path
1202 lock))
1287 (save-excursion 1203 (save-excursion
1288 (set-buffer (get-buffer-create " *warning-tmp*")) 1204 (set-buffer (get-buffer-create " *warning-tmp*"))
1289 (erase-buffer) 1205 (erase-buffer)
1290 (buffer-disable-undo (current-buffer)) 1206 (buffer-disable-undo (current-buffer))
1291 (if (null lisp-directory) (push "lisp-directory" warnings)) 1207 (if (null lisp-directory) (push "lisp-directory" warnings))
1208 (if (null lock) (push "lock-directory" warnings))
1292 (if (null exec-directory) (push "exec-directory" warnings)) 1209 (if (null exec-directory) (push "exec-directory" warnings))
1293 (if (null data-directory) (push "data-directory" warnings)) 1210 (if (null data-directory) (push "data-directory" warnings))
1294 (if (null doc-directory) (push "doc-directory" warnings)) 1211 (if (null doc-directory) (push "doc-directory" warnings))
1295 (if (null load-path) (push "load-path" warnings)) 1212 (if (null load-path) (push "load-path" warnings))
1296 1213