Sync with r21-2-33 and r21-2-33-utf-2000.
[chise/xemacs-chise.git-] / lisp / startup.el
1 ;;; startup.el --- process XEmacs shell arguments
2
3 ;; Copyright (C) 1985-1986, 1990, 1992-1997 Free Software Foundation, Inc.
4 ;; Copyright (c) 1993, 1994 Sun Microsystems, Inc.
5 ;; Copyright (C) 1995 Board of Trustees, University of Illinois
6
7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: internal, dumped
9
10 ;; This file is part of XEmacs.
11
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16
17 ;; XEmacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
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
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Synched up with: FSF 19.34.
28
29 ;;; Commentary:
30
31 ;; This file is dumped with XEmacs.
32
33 ;; -batch, -t, and -nw are processed by main() in emacs.c and are
34 ;; never seen by lisp code.
35
36 ;; -version and -help are special-cased as well: they imply -batch,
37 ;; but are left on the list for lisp code to process.
38
39 ;;; Code:
40 \f
41 (setq top-level '(normal-top-level))
42
43 (defvar command-line-processed nil "t once command line has been processed")
44
45 (defconst startup-message-timeout 12000) ; More or less disable the timeout
46 (defconst splash-frame-timeout 7) ; interval between splash frame elements
47
48 (defconst inhibit-startup-message nil
49   "*Non-nil inhibits the initial startup message.
50 This is for use in your personal init file, once you are familiar
51 with the contents of the startup message.")
52
53 ;; #### FSFmacs randomness
54 ;;(defconst inhibit-startup-echo-area-message nil
55 ;;  "*Non-nil inhibits the initial startup echo area message.
56 ;;Inhibition takes effect only if your `.emacs' file contains
57 ;;a line of this form:
58 ;; (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
59 ;;If your `.emacs' file is byte-compiled, use the following form instead:
60 ;; (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
61 ;;Thus, someone else using a copy of your `.emacs' file will see
62 ;;the startup message unless he personally acts to inhibit it.")
63
64 (defconst inhibit-default-init nil
65   "*Non-nil inhibits loading the `default' library.")
66
67 (defvar command-line-args-left nil
68   "List of command-line args not yet processed.") ; bound by `command-line'
69
70 (defvar command-line-default-directory nil
71   "Default directory to use for command line arguments.
72 This is normally copied from `default-directory' when XEmacs starts.")
73
74 (defvar before-init-hook nil
75   "Functions to call after handling urgent options but before init files.
76 The frame system uses this to open frames to display messages while
77 XEmacs loads the user's initialization file.")
78
79 (defvar after-init-hook nil
80   "*Functions to call after loading the init file (`.emacs').
81 The call is not protected by a condition-case, so you can set `debug-on-error'
82 in `.emacs', and put all the actual code on `after-init-hook'.")
83
84 (defvar term-setup-hook nil
85   "*Functions to be called after loading terminal-specific Lisp code.
86 See `run-hooks'.  This variable exists for users to set, so as to
87 override the definitions made by the terminal-specific file.  XEmacs
88 never sets this variable itself.")
89
90 (defvar keyboard-type nil
91   "The brand of keyboard you are using.
92 This variable is used to define the proper function and keypad keys
93 for use under X.  It is used in a fashion analogous to the environment
94 value TERM.")
95
96 (defvar window-setup-hook nil
97   "Normal hook run to initialize window system display.
98 XEmacs runs this hook after processing the command line arguments and loading
99 the user's init file.")
100
101 (defconst initial-major-mode 'lisp-interaction-mode
102   "Major mode command symbol to use for the initial *scratch* buffer.")
103
104 (defvar emacs-roots nil
105   "List of plausible roots of the XEmacs hierarchy.")
106
107 (defvar user-init-directory-base ".xemacs"
108   "Base of directory where user-installed init files may go.")
109
110 (defvar user-init-file-base-list (append
111                                   '(".emacs.elc" ".emacs.el" ".emacs")
112                                   (and (eq system-type 'windows-nt)
113                                        '("_emacs.elc" "_emacs.el" "_emacs")))
114   "List of allowed init files.  The first one found takes precedence.")
115
116 (defvar user-init-directory
117   (file-name-as-directory
118    (paths-construct-path (list "~" user-init-directory-base)))
119   "Directory where user-installed init files may go.")
120
121 (defvar load-user-init-file-p t
122   "Non-nil if XEmacs should load the user's init file.")
123
124 ;; #### called `site-run-file' in FSFmacs
125
126 (defvar site-start-file (purecopy "site-start")
127   "File containing site-wide run-time initializations.
128 This file is loaded at run-time before `.emacs'.  It
129 contains inits that need to be in place for the entire site, but
130 which, due to their higher incidence of change, don't make sense to
131 load into XEmacs' dumped image.  Thus, the run-time load order is:
132
133   1. file described in this variable, if non-nil;
134   2. `.emacs';
135   3. `/path/to/xemacs/lisp/default.el'.
136
137 Don't use the `site-start.el' file for things some users may not like.
138 Put them in `default.el' instead, so that users can more easily
139 override them.  Users can prevent loading `default.el' with the `-q'
140 option or by setting `inhibit-default-init' in their own init files,
141 but inhibiting `site-start.el' requires `--no-site-file', which
142 is less convenient.")
143
144 ;;(defconst iso-8859-1-locale-regexp "8859[-_]?1"
145 ;;  "Regexp that specifies when to enable the ISO 8859-1 character set.
146 ;;We do that if this regexp matches the locale name
147 ;;specified by the LC_ALL, LC_CTYPE and LANG environment variables.")
148
149 (defvar mail-host-address nil
150   "*Name of this machine, for purposes of naming users.")
151
152 (defvar user-mail-address nil
153   "*Full mailing address of this user.
154 This is initialized based on `mail-host-address',
155 after your init file is read, in case it sets `mail-host-address'.")
156
157 (defvar auto-save-list-file-prefix "~/.saves-"
158   "Prefix for generating auto-save-list-file-name.
159 Emacs's pid and the system name will be appended to
160 this prefix to create a unique file name.")
161
162 (defvar init-file-debug nil)
163
164 (defvar init-file-had-error nil)
165
166 (defvar init-file-loaded nil
167   "True after the user's init file has been loaded (or suppressed with -q).
168 This will be true when `after-init-hook' is run and at all times
169 after, and will not be true at any time before.")
170
171 (defvar initial-frame-unmapped-p nil)
172
173 \f
174
175 (defvar command-switch-alist
176   (purecopy
177    '(("-help"   . command-line-do-help)
178      ("-version". command-line-do-version)
179      ("-V"      . command-line-do-version)
180      ("-funcall". command-line-do-funcall)
181      ("-f"      . command-line-do-funcall)
182      ("-e"      . command-line-do-funcall-1)
183      ("-eval"   . command-line-do-eval)
184      ("-load"   . command-line-do-load)
185      ("-l"      . command-line-do-load)
186      ("-insert" . command-line-do-insert)
187      ("-i"      . command-line-do-insert)
188      ("-kill"   . command-line-do-kill)
189      ;; Options like +35 are handled specially.
190      ;; Window-system, site, or package-specific code might add to this.
191      ;; X11 handles its options by letting Xt remove args from this list.
192      ))
193   "Alist of command-line switches.
194 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
195 HANDLER-FUNCTION receives switch name as sole arg;
196 remaining command-line args are in the variable `command-line-args-left'.")
197
198 ;;; default switches
199 ;;; Note: these doc strings are semi-magical.
200
201 (defun command-line-do-help (arg)
202   "Print the XEmacs usage message and exit."
203   (let ((standard-output 'external-debugging-output))
204     (princ (concat "\n" (emacs-version) "\n\n"))
205     (princ
206      (if (featurep 'x)
207          (concat "When creating a window on an X display, "
208                  (emacs-name)
209                  " accepts all standard X Toolkit
210 command line options plus the following:
211   -iconname <title>     Use title as the icon name.
212   -mc <color>           Use color as the mouse color.
213   -cr <color>           Use color as the text-cursor foregound color.
214   -private              Install a private colormap.
215
216 In addition, the")
217        "The"))
218     (princ " following options are accepted:
219   -t <device>           Use TTY <device> instead of the terminal for input
220                         and output.  This implies the -nw option.
221   -nw                   Inhibit the use of any window-system-specific
222                         display code: use the current tty.
223   -batch                Execute noninteractively (messages go to stderr).
224   -debug-init           Enter the debugger if an error in the init file occurs.
225   -unmapped             Do not map the initial frame.
226   -no-site-file         Do not load the site-specific init file (site-start.el).
227   -no-init-file         Do not load the user-specific init file (~/.emacs).
228   -no-early-packages    Do not process early packages.
229   -no-autoloads         Do not load global symbol files (auto-autoloads) at
230                         startup.  Also implies `-vanilla'.
231   -vanilla              Equivalent to -q -no-site-file -no-early-packages.
232   -q                    Same as -no-init-file.
233   -user-init-file <file> Use <file> as init file.
234   -user-init-directory <directory> use <directory> as init directory.
235   -user <user>          Load user's init file instead of your own.
236                         Equivalent to -user-init-file ~<user>/.emacs
237                                       -user-init-directory ~<user>/.xemacs/
238   -u <user>             Same as -user.\n")
239    (let ((l command-switch-alist)
240           (insert (lambda (&rest x)
241                     (princ "  ")
242                     (let ((len 2))
243                       (while x
244                         (princ (car x))
245                         (incf len (length (car x)))
246                         (setq x (cdr x)))
247                       (when (>= len 24)
248                         (terpri) (setq len 0))
249                       (while (< len 24)
250                         (princ " ")
251                         (incf len))))))
252       (while l
253         (let ((name (car (car l)))
254               (fn (cdr (car l)))
255               doc arg cons)
256           (cond
257            ((and (symbolp fn) (get fn 'undocumented)) nil)
258            (t
259             (setq doc (documentation fn))
260             (if (member doc '(nil "")) (setq doc "(undocumented)"))
261             (cond ((string-match "\n\\(<.*>\\)\n?\\'" doc)
262                    ;; Doc of the form "The frobber switch\n<arg1> <arg2>"
263                    (setq arg (substring doc (match-beginning 1) (match-end 1))
264                          doc (substring doc 0 (match-beginning 0))))
265                   ((string-match "\n+\\'" doc)
266                    (setq doc (substring doc 0 (match-beginning 0)))))
267             (if (and (setq cons (rassq fn command-switch-alist))
268                      (not (eq cons (car l))))
269                 (setq doc (format "Same as %s." (car cons))))
270             (if arg
271                 (funcall insert name " " arg)
272               (funcall insert name))
273             (princ doc)
274             (terpri))))
275         (setq l (cdr l))))
276     (princ (concat "\
277   +N <file>             Start displaying <file> at line N.
278
279 Anything else is considered a file name, and is placed into a buffer for
280 editing.
281
282 " (emacs-name) " has an online tutorial and manuals.  Type ^Ht (Control-h t) after
283 starting XEmacs to run the tutorial.  Type ^Hi to enter the manual browser.
284 Type ^H^H^H (Control-h Control-h Control-h) to get more help options.\n")
285
286     (kill-emacs 0))))
287
288 (defun command-line-do-funcall (arg)
289   "Invoke the named lisp function with no arguments.
290 <function>"
291   (funcall (intern (pop command-line-args-left))))
292 (fset 'command-line-do-funcall-1 'command-line-do-funcall)
293 (put 'command-line-do-funcall-1 'undocumented t)
294
295 (defun command-line-do-eval (arg)
296   "Evaluate the lisp form.  Quote it carefully.
297 <form>"
298   (eval (read (pop command-line-args-left))))
299
300 (defun command-line-do-load (arg)
301   "Load the named file of Lisp code into XEmacs.
302 <file>"
303   (let ((file (pop command-line-args-left)))
304     ;; Take file from default dir if it exists there;
305     ;; otherwise let `load' search for it.
306     (if (file-exists-p (expand-file-name file))
307         (setq file (expand-file-name file)))
308     (load file nil t)))
309
310 (defun command-line-do-insert (arg)
311   "Insert file into the current buffer.
312 <file>"
313   (insert-file-contents (pop command-line-args-left)))
314
315 (defun command-line-do-kill (arg)
316   "Exit XEmacs."
317   (kill-emacs t))
318
319 (defun command-line-do-version (arg)
320   "Print version info and exit."
321   (princ (concat (emacs-version) "\n"))
322   (kill-emacs 0))
323
324 \f
325 ;;; Processing the command line and loading various init files
326
327 (defun early-error-handler (&rest debugger-args)
328   "You should probably not be using this."
329   ;; Used as the debugger during XEmacs initialization; if an error occurs,
330   ;; print some diagnostics, and kill XEmacs.
331
332   ;; output the contents of the warning buffer, since it won't be seen
333   ;; otherwise.
334   ;; #### kludge!  The call to Feval forces the pending warnings to
335   ;; get output.  There definitely needs to be a better way.
336   (let ((buffer (eval (get-buffer-create "*Warnings*"))))
337     (princ (buffer-substring (point-min buffer) (point-max buffer) buffer)
338            'external-debugging-output))
339
340   (let ((string "Initialization error")
341         (error (nth 1 debugger-args))
342         (debug-on-error nil)
343         (stream 'external-debugging-output))
344     (if (null error)
345         (princ string stream)
346       (princ (concat "\n" string ": ") stream)
347       (condition-case ()
348           (display-error error stream)
349         (error (princ "<<< error printing error message >>>" stream)))
350       (princ "\n" stream)
351       (if (memq (car-safe error) '(void-function void-variable))
352           (princ "
353         This probably means that XEmacs is picking up an old version of
354         the lisp library, or that some .elc files are not up-to-date.\n"
355                  stream)))
356     (when (not suppress-early-error-handler-backtrace)
357       (let ((print-length 1000)
358             (print-level 1000)
359             (print-escape-newlines t)
360             (print-readably nil))
361         (when (getenv "EMACSLOADPATH")
362           (princ (format "\n$EMACSLOADPATH is %s" (getenv "EMACSLOADPATH"))
363                  stream))
364         (princ (format "\nexec-directory is %S" exec-directory) stream)
365         (princ (format "\ndata-directory is %S" data-directory) stream)
366         (princ (format "\ndata-directory-list is %S" data-directory-list) stream)
367         (princ (format "\ndoc-directory is %S" doc-directory) stream)
368         (princ (format "\nload-path is %S" load-path) stream)
369         (princ "\n\n" stream)))
370     (when (not suppress-early-error-handler-backtrace)
371       (backtrace stream t)))
372   (kill-emacs -1))
373
374 (defvar lock-directory)
375 (defvar superlock-file)
376
377 (defun normal-top-level ()
378   (if command-line-processed
379       (message "Back to top level.")
380     (setq command-line-processed t)
381     ;; Canonicalize HOME (PWD is canonicalized by init_buffer in buffer.c)
382     (let ((value (user-home-directory)))
383       (if (and value
384                (< (length value) (length default-directory))
385                (equal (file-attributes default-directory)
386                       (file-attributes value)))
387           (setq default-directory (file-name-as-directory value))))
388     (setq default-directory (abbreviate-file-name default-directory))
389     (initialize-xemacs-paths)
390
391     (startup-set-invocation-environment)
392
393     (let ((debug-paths (or debug-paths
394                            (and (getenv "EMACSDEBUGPATHS")
395                                 t))))
396
397       (setq emacs-roots (paths-find-emacs-roots invocation-directory
398                                                 invocation-name))
399
400       (if debug-paths
401           (princ (format "emacs-roots:\n%S\n" emacs-roots)
402                  'external-debugging-output))
403
404       (if (null emacs-roots)
405           (startup-find-roots-warning)
406         (startup-setup-paths emacs-roots
407                              user-init-directory
408                              inhibit-early-packages
409                              inhibit-site-lisp
410                              debug-paths))
411       (startup-setup-paths-warning))
412
413     (when (and (not inhibit-autoloads)
414                lisp-directory)
415       (load (expand-file-name (file-name-sans-extension autoload-file-name)
416                               lisp-directory) nil t)
417       (if (featurep 'utf-2000)
418           (load (expand-file-name
419                  (file-name-sans-extension autoload-file-name)
420                  (expand-file-name "utf-2000" lisp-directory))
421                 nil t)))
422
423     (if (not inhibit-autoloads)
424         (progn
425           (if (not inhibit-early-packages)
426               (packages-load-package-auto-autoloads early-package-load-path))
427           (packages-load-package-auto-autoloads late-package-load-path)
428           (packages-load-package-auto-autoloads last-package-load-path)))
429
430     (unwind-protect
431         (command-line)
432       ;; Do this again, in case .emacs defined more abbreviations.
433       (setq default-directory (abbreviate-file-name default-directory))
434       ;; Specify the file for recording all the auto save files of
435       ;; this session.  This is used by recover-session.
436       (setq auto-save-list-file-name
437             (expand-file-name
438              (format "%s%d-%s"
439                      auto-save-list-file-prefix
440                      (emacs-pid)
441                      (system-name))))
442       (run-hooks 'emacs-startup-hook)
443       (and term-setup-hook
444            (run-hooks 'term-setup-hook))
445       (setq term-setup-hook nil)
446       ;;      ;; Modify the initial frame based on what .emacs puts into
447       ;;      ;; ...-frame-alist.
448       (frame-notice-user-settings)
449       ;;      ;;####FSFmacs junk
450       ;;      ;; Now we know the user's default font, so add it to the menu.
451       ;;      (if (fboundp 'font-menu-add-default)
452       ;;          (font-menu-add-default))
453       (when window-setup-hook
454         (run-hooks 'window-setup-hook))
455       (setq window-setup-hook nil))
456     ;;####FSFmacs junk
457     ;;      (or menubar-bindings-done
458     ;;    (precompute-menubar-bindings))
459     ))
460
461 ;;####FSFmacs junk
462 ;;; Precompute the keyboard equivalents in the menu bar items.
463 ;;(defun precompute-menubar-bindings ()
464 ;;  (if (eq window-system 'x)
465 ;;      (let ((submap (lookup-key global-map [menu-bar])))
466 ;;      (while submap
467 ;;        (and (consp (car submap))
468 ;;             (symbolp (car (car submap)))
469 ;;             (stringp (car-safe (cdr (car submap))))
470 ;;             (keymapp (cdr (cdr (car submap))))
471 ;;             (x-popup-menu nil (cdr (cdr (car submap)))))
472 ;;        (setq submap (cdr submap))))))
473
474 (defun command-line-early (args)
475   ;; This processes those switches which need to be processed before
476   ;; starting up the window system.
477
478   (setq command-line-default-directory default-directory)
479
480   ;; See if we should import version-control from the environment variable.
481   (let ((vc (getenv "VERSION_CONTROL")))
482     (cond ((eq vc nil))                 ;don't do anything if not set
483           ((or (string= vc "t")
484                (string= vc "numbered"))
485            (setq version-control t))
486           ((or (string= vc "nil")
487                (string= vc "existing"))
488            (setq version-control nil))
489           ((or (string= vc "never")
490                (string= vc "simple"))
491            (setq version-control 'never))))
492
493   ;;####FSFmacs
494   ;;  (if (let ((ctype
495   ;;         ;; Use the first of these three envvars that has a nonempty value.
496   ;;         (or (let ((string (getenv "LC_ALL")))
497   ;;               (and (not (equal string "")) string))
498   ;;             (let ((string (getenv "LC_CTYPE")))
499   ;;               (and (not (equal string "")) string))
500   ;;             (let ((string (getenv "LANG")))
501   ;;               (and (not (equal string "")) string)))))
502   ;;    (and ctype
503   ;;         (string-match iso-8859-1-locale-regexp ctype)))
504   ;;      (progn
505   ;;    (standard-display-european t)
506   ;;    (require 'iso-syntax)))
507
508   (setq load-user-init-file-p (not (noninteractive)))
509
510   ;; Allow (at least) these arguments anywhere in the command line
511   (let ((new-args nil)
512         (arg      nil))
513     (while args
514       (setq arg (pop args))
515       (cond
516        ((or (string= arg "-q")
517             (string= arg "-no-init-file"))
518         (setq load-user-init-file-p nil))
519        ((string= arg "-no-site-file")
520         (setq site-start-file nil))
521        ((or (string= arg "-no-early-packages")
522             (string= arg "--no-early-packages"))
523         (setq inhibit-early-packages t))
524        ((or (string= arg "-vanilla")
525             (string= arg "--vanilla")
526             ;; Some work on this one already done in emacs.c.
527             (string= arg "-no-autoloads")
528             (string= arg "--no-autoloads"))
529         (setq load-user-init-file-p nil
530               site-start-file nil))
531        ((string= arg "-user-init-file")
532         (setq user-init-file (pop args)))
533        ((string= arg "-user-init-directory")
534         (setq user-init-directory (file-name-as-directory (pop args))))
535        ((or (string= arg "-u")
536             (string= arg "-user"))
537         (let* ((user (pop args))
538                (home-user (concat "~" user)))
539           (setq user-init-file (find-user-init-file home-user)
540                 user-init-directory (file-name-as-directory
541                                      (paths-construct-path
542                                       (list home-user user-init-directory-base))))))
543        ((string= arg "-debug-init")
544         (setq init-file-debug t))
545        ((string= arg "-unmapped")
546         (setq initial-frame-unmapped-p t))
547        ((or (string= arg "-debug-paths")
548             (string= arg "--debug-paths"))
549         t)
550        ((or (string= arg "--") (string= arg "-"))
551         (while args
552           (push (pop args) new-args)))
553        (t (push arg new-args))))
554
555     (setq init-file-user (and load-user-init-file-p ""))
556
557     (nreverse new-args)))
558
559 (defconst initial-scratch-message "\
560 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
561 ;; If you want to create a file, first visit that file with C-x C-f,
562 ;; then enter the text in that file's own buffer.
563
564 "
565   "Initial message displayed in *scratch* buffer at startup.
566 If this is nil, no message will be displayed.")
567
568 (defun command-line ()
569   (let ((command-line-args-left (cdr command-line-args)))
570
571     (let ((debugger 'early-error-handler)
572           (debug-on-error t))
573
574       ;; Process magic command-line switches like -q and -u.  Do this
575       ;; before creating the first frame because some of these switches
576       ;; may affect that.  I think it's ok to do this before establishing
577       ;; the X connection, and maybe someday things like -nw can be
578       ;; handled here instead of down in C.
579       (setq command-line-args-left (command-line-early command-line-args-left))
580
581       ;; Setup the toolbar icon directory
582       (when (featurep 'toolbar)
583         (init-toolbar-location))
584
585       ;; Run the window system's init function.  tty is considered to be
586       ;; a type of window system for this purpose.  This creates the
587       ;; initial (non stdio) device.
588       (when (and initial-window-system (not noninteractive))
589         (funcall (intern (concat "init-"
590                                  (symbol-name initial-window-system)
591                                  "-win"))))
592
593       ;; When not in batch mode, this creates the first visible frame,
594       ;; and deletes the stdio device.
595       (frame-initialize))
596
597     ;; Reinitialize faces if necessary.  This function changes face if
598     ;; it is created during auto-autoloads loading.  Otherwise, it
599     ;; does nothing.
600     (startup-initialize-custom-faces)
601
602     ;;
603     ;; We have normality, I repeat, we have normality.  Anything you still
604     ;; can't cope with is therefore your own problem.  (And we don't need
605     ;; to kill XEmacs for it.)
606     ;;
607
608     ;;; Load init files.
609     (load-init-file)
610
611     (with-current-buffer (get-buffer "*scratch*")
612       (erase-buffer)
613       ;; (insert initial-scratch-message)
614       (set-buffer-modified-p nil)
615       (when (eq major-mode 'fundamental-mode)
616         (funcall initial-major-mode)))
617
618     ;; Load library for our terminal type.
619     ;; User init file can set term-file-prefix to nil to prevent this.
620     ;; Note that for any TTY's opened subsequently, the TTY init
621     ;; code will run this.
622     (when (and (eq 'tty (console-type))
623                (not (noninteractive)))
624       (load-terminal-library))
625
626     ;; Process the remaining args.
627     (command-line-1)
628
629     ;; it was turned on by default so that the warnings don't get displayed
630     ;; until after the splash screen.
631     (setq inhibit-warning-display nil)
632     ;; If -batch, terminate after processing the command options.
633     (when (noninteractive) (kill-emacs t))))
634
635 (defun load-terminal-library ()
636   (when term-file-prefix
637     (let ((term (getenv "TERM"))
638           hyphend)
639       (while (and term
640                   (not (load (concat term-file-prefix term) t t)))
641         ;; Strip off last hyphen and what follows, then try again
642         (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
643             (setq term (substring term 0 hyphend))
644           (setq term nil))))))
645
646 (defun find-user-init-file (&optional directory)
647   "Determine the user's init file."
648   (unless directory
649     (setq directory "~"))
650   (dolist (file user-init-file-base-list)
651     (let ((expanded (paths-construct-path (list directory file))))
652       (when (file-exists-p expanded)
653         (return expanded)))))
654
655 (defun load-user-init-file ()
656   "This function actually reads the init file, .emacs."
657   (if (or user-init-file
658           (setq user-init-file (find-user-init-file)))
659       (load user-init-file t t t))
660   (unless inhibit-default-init
661     (let ((inhibit-startup-message nil))
662       ;; Users are supposed to be told their rights.
663       ;; (Plus how to get help and how to undo.)
664       ;; Don't you dare turn this off for anyone except yourself.
665       (load "default" t t))))
666
667 ;;; Load user's init file and default ones.
668 (defun load-init-file ()
669   (run-hooks 'before-init-hook)
670
671   ;; Run the site-start library if it exists.  The point of this file is
672   ;; that it is run before .emacs.  There is no point in doing this after
673   ;; .emacs; that is useless.
674   (when site-start-file
675     (load site-start-file t t))
676
677   ;; Sites should not disable this.  Only individuals should disable
678   ;; the startup message.
679   (setq inhibit-startup-message nil)
680
681   (let (debug-on-error-from-init-file
682         debug-on-error-should-be-set
683         (debug-on-error-initial
684          (if (eq init-file-debug t) 'startup init-file-debug)))
685     (let ((debug-on-error debug-on-error-initial))
686       (if (and load-user-init-file-p init-file-debug)
687           ;; Do this without a condition-case if the user wants to debug.
688           (load-user-init-file)
689         (condition-case error
690             (progn
691               (if load-user-init-file-p
692                   (load-user-init-file))
693               (setq init-file-had-error nil))
694           (error
695            (message "Error in init file: %s" (error-message-string error))
696            (display-warning 'initialization
697              (format "\
698 An error has occurred while loading %s:
699
700 %s
701
702 To ensure normal operation, you should investigate the cause of the error
703 in your initialization file and remove it.  Use the `-debug-init' option
704 to XEmacs to view a complete error backtrace."
705                      user-init-file (error-message-string error))
706              'error)
707            (setq init-file-had-error t))))
708       ;; If we can tell that the init file altered debug-on-error,
709       ;; arrange to preserve the value that it set up.
710       (or (eq debug-on-error debug-on-error-initial)
711           (setq debug-on-error-should-be-set t
712                 debug-on-error-from-init-file debug-on-error)))
713     (when debug-on-error-should-be-set
714       (setq debug-on-error debug-on-error-from-init-file)))
715
716   (setq init-file-loaded t)
717
718   ;; Do this here in case the init file sets mail-host-address.
719   ;; Don't do this here unless noninteractive, it is frequently wrong. -sb
720   ;; (or user-mail-address
721   (when noninteractive
722     (setq user-mail-address (concat (user-login-name) "@"
723                                     (or mail-host-address
724                                         (system-name)))))
725
726   (run-hooks 'after-init-hook)
727   nil)
728
729 (defun load-options-file (filename)
730   "Load the file of saved options (from the Options menu) called FILENAME.
731 Currently this does nothing but call `load', but it might be redefined
732 in the future to support automatically converting older options files to
733 a new format, when variables have changed, etc."
734   (load filename))
735
736 (defun command-line-1 ()
737   (cond
738    ((null command-line-args-left)
739     (unless noninteractive
740       ;; If there are no switches to process, run the term-setup-hook
741       ;; before displaying the copyright notice; there may be some need
742       ;; to do it before doing any output.  If we're not going to
743       ;; display a copyright notice (because other options are present)
744       ;; then this is run after those options are processed.
745       (run-hooks 'term-setup-hook)
746       ;; Don't let the hook be run twice.
747       (setq term-setup-hook nil)
748
749       ;; Don't clobber a non-scratch buffer if init file
750       ;; has selected it.
751       (when (string= (buffer-name) "*scratch*")
752         (unless (or inhibit-startup-message
753                     (input-pending-p))
754           (let (tmout circ-tmout)
755             (unwind-protect
756                 ;; Guts of with-timeout
757                 (catch 'tmout
758                   (setq tmout (add-timeout startup-message-timeout
759                                            (lambda (ignore)
760                                              (condition-case nil
761                                                  (throw 'tmout t)
762                                                (error nil)))
763                                            nil))
764                   (setq circ-tmout (display-splash-frame))
765                   (or nil;; (pos-visible-in-window-p (point-min))
766                       (goto-char (point-min)))
767                   (sit-for 0)
768                   (setq unread-command-event (next-command-event)))
769               (when tmout (disable-timeout tmout))
770               (when circ-tmout (disable-timeout circ-tmout)))))
771         (with-current-buffer (get-buffer "*scratch*")
772           ;; In case the XEmacs server has already selected
773           ;; another buffer, erase the one our message is in.
774           (erase-buffer)
775           (when (stringp initial-scratch-message)
776             (insert initial-scratch-message))
777           (set-buffer-modified-p nil)))))
778
779    (t
780     ;; Command-line-options exist
781     (let ((dir command-line-default-directory)
782           (file-count 0)
783           (line nil)
784           (end-of-options nil)
785           file-p arg tem)
786       (while command-line-args-left
787         (setq arg (pop command-line-args-left))
788         (cond
789          (end-of-options
790           (setq file-p t))
791          ((setq tem (when (eq (aref arg 0) ?-)
792                       (or (assoc arg command-switch-alist)
793                           (assoc (substring arg 1)
794                                  command-switch-alist))))
795           (funcall (cdr tem) arg))
796          ((string-match "\\`\\+[0-9]+\\'" arg)
797           (setq line (string-to-int arg)))
798          ;; "- file" means don't treat "file" as a switch
799          ;;  ("+0 file" has the same effect; "-" added
800          ;;   for unixoidiality).
801          ;; This is worthless; the `unixoid' way is "./file". -jwz
802          ((or (string= arg "-") (string= arg "--"))
803           (setq end-of-options t))
804          (t
805           (setq file-p t)))
806
807         (when file-p
808           (setq file-p nil)
809           (incf file-count)
810           (setq arg (expand-file-name arg dir))
811           (cond
812            ((= file-count 1)
813             (find-file arg))
814            (noninteractive (find-file arg))
815            (t (find-file-other-window arg)))
816           (when line
817             (goto-line line)
818             (setq line nil))))))))
819
820 (defvar startup-presentation-hack-keymap
821   (let ((map (make-sparse-keymap)))
822     (set-keymap-name map 'startup-presentation-hack-keymap)
823     (define-key map '[button1] 'startup-presentation-hack)
824     (define-key map '[button2] 'startup-presentation-hack)
825     map)
826   "Putting yesterday in the future tomorrow.")
827
828 (defun startup-presentation-hack ()
829   (interactive)
830   (let ((e last-command-event))
831     (and (button-press-event-p e)
832          (setq e (extent-at (event-point e)
833                             (event-buffer e)
834                             'startup-presentation-hack))
835          (setq e (extent-property e 'startup-presentation-hack))
836          (if (consp e)
837              (apply (car e) (cdr e))
838            (while (keymapp (indirect-function e))
839              (let ((map e)
840                    (overriding-local-map (indirect-function e)))
841                (setq e (read-key-sequence
842                         (let ((p (keymap-prompt map t)))
843                           (cond ((symbolp map)
844                                  (if p
845                                      (format "%s %s " map p)
846                                    (format "%s " map)))
847                                 (p)
848                                 (t
849                                  (prin1-to-string map))))))
850                (if (and (button-release-event-p (elt e 0))
851                         (null (key-binding e)))
852                    (setq e map)         ; try again
853                  (setq e (key-binding e)))))
854            (call-interactively e)))))
855
856 (defun startup-presentation-hack-help (e)
857   (setq e (extent-property e 'startup-presentation-hack))
858   (if (consp e)
859       (format "Evaluate %S" e)
860     (symbol-name e)))
861
862 (defun splash-frame-present-hack (e v)
863   ;;   (set-extent-property e 'mouse-face 'highlight)
864   ;;   (set-extent-property e 'keymap
865   ;;                           startup-presentation-hack-keymap)
866   ;;   (set-extent-property e 'startup-presentation-hack v)
867   ;;   (set-extent-property e 'help-echo
868   ;;                           'startup-presentation-hack-help)
869   )
870
871 (defun splash-hack-version-string ()
872   (save-excursion
873     (save-restriction
874       (goto-char (point-min))
875       (re-search-forward "^XEmacs" nil t)
876       (narrow-to-region (point-at-bol) (point-at-eol))
877       (goto-char (point-min))
878       (when (re-search-forward " \\[Lucid\\]" nil t)
879         (delete-region (match-beginning 0) (match-end 0)))
880       (when (re-search-forward "[^(][^)]*-[^)]*-" nil t)
881         (delete-region (1+ (match-beginning 0)) (match-end 0))
882         (insert "("))
883       (goto-char (point-max))
884       (search-backward " " nil t)
885       (when (search-forward "." nil t)
886         (delete-region (1- (point)) (point-max))))))
887
888 (defun splash-frame-present (l)
889   (cond ((stringp l)
890          (insert l))
891         ((eq (car-safe l) 'face)
892          ;; (face name string)
893          (let ((p (point)))
894            (splash-frame-present (elt l 2))
895            (if (fboundp 'set-extent-face)
896                (set-extent-face (make-extent p (point))
897                                 (elt l 1)))))
898         ((eq (car-safe l) 'key)
899          (let* ((c (elt l 1))
900                 (p (point))
901                 (k (where-is-internal c nil t)))
902            (insert (if k (key-description k)
903                      (format "M-x %s" c)))
904            (if (fboundp 'set-extent-face)
905                (let ((e (make-extent p (point))))
906                  (set-extent-face e 'bold)
907                  (splash-frame-present-hack e c)))))
908         ((eq (car-safe l) 'funcall)
909          ;; (funcall (fun . args) string)
910          (let ((p (point)))
911            (splash-frame-present (elt l 2))
912            (if (fboundp 'set-extent-face)
913                (splash-frame-present-hack (make-extent p (point))
914                                           (elt l 1)))))
915         ((consp l)
916          (mapcar 'splash-frame-present l))
917         (t
918          (error "WTF!?"))))
919
920 (defun startup-center-spaces (glyph)
921   ;; Return the number of spaces to insert in order to center
922   ;; the given glyph (may be a string or a pixmap).
923   ;; Assume spaces are as wide as avg-pixwidth.
924   ;; Won't be quite right for proportional fonts, but it's the best we can do.
925   ;; Maybe the new redisplay will export something a glyph-width function.
926   ;;; #### Yes, there is a glyph-width function but it isn't quite what
927   ;;; #### this was expecting.  Or is it?
928   ;; (An alternate way to get avg-pixwidth would be to use x-font-properties
929   ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.)
930
931   ;; This function is used in about.el too.
932   (let* ((avg-pixwidth     (round (/ (frame-pixel-width) (frame-width))))
933          (fill-area-width  (* avg-pixwidth (- fill-column left-margin)))
934          (glyph-pixwidth   (cond ((stringp glyph)
935                                   (* avg-pixwidth (length glyph)))
936                                  ;; #### the pixmap option should be removed
937                                  ;;((pixmapp glyph)
938                                  ;; (pixmap-width glyph))
939                                  ((glyphp glyph)
940                                   (glyph-width glyph))
941                                  (t
942                                   (error "startup-center-spaces: bad arg")))))
943     (+ left-margin
944        (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth)))))
945
946 (defun splash-frame-body ()
947   `[((face (blue bold underline)
948            "\nDistribution, copying license, warranty:\n\n")
949      "Please visit the XEmacs website at http://www.xemacs.org !\n\n"
950      ,@(if (featurep 'sparcworks)
951            `( "\
952 Sun provides support for the WorkShop/XEmacs integration package only.
953 All other XEmacs packages are provided to you \"AS IS\".\n"
954               ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES")
955                                 (getenv "LANG"))))
956                   (if (and
957                        (not (featurep 'mule)) ;; Already got mule?
958                        ;; No Mule support on tty's yet
959                        (not (eq 'tty (console-type)))
960                        lang ;; Non-English locale?
961                        (not (string= lang "C"))
962                        (not (string-match "^en" lang))
963                        ;; Comes with Sun WorkShop
964                        (locate-file "xemacs-mule" exec-path))
965                       '( "\
966 This version of XEmacs has been built with support for Latin-1 languages only.
967 To handle other languages you need to run a Multi-lingual (`Mule') version of
968 XEmacs, by either running the command `xemacs-mule', or by using the X resource
969 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop.
970 \n")))))
971      ((key describe-no-warranty)
972       ": "(face (red bold) "XEmacs comes with ABSOLUTELY NO WARRANTY\n"))
973      ((key describe-copying)
974       ": conditions to give out copies of XEmacs\n")
975      ((key describe-distribution)
976       ": how to get the latest version\n")
977      "\n--\n"
978      (face italic "\
979 Copyright (C) 1985-1999 Free Software Foundation, Inc.
980 Copyright (C) 1990-1994 Lucid, Inc.
981 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved.
982 Copyright (C) 1994-1996 Board of Trustees, University of Illinois
983 Copyright (C) 1995-1996 Ben Wing
984 Copyright (C) 1996-2000 MORIOKA Tomohiko
985 "))
986
987     ((face (blue bold underline) "\nInformation, on-line help:\n\n")
988      "XEmacs comes with plenty of documentation...\n\n"
989      ,@(if (string-match "beta" emacs-version)
990            `((key describe-beta)
991              ": " (face (red bold)
992                         "This is an Experimental version of XEmacs.\n"))
993          `( "\n"))
994      ((key xemacs-local-faq)
995       ": read the XEmacs FAQ (a " (face underline "capital") " F!)\n")
996      ((key help-with-tutorial)
997       ": read the XEmacs tutorial (also available through the "
998       (face bold "Help") " menu)\n")
999      ((key help-command)
1000       ": get help on using XEmacs (also available through the "
1001       (face bold "Help") " menu)\n")
1002      ((key info) ": read the on-line documentation\n\n")
1003      ((key describe-project) ": read about the GNU project\n")
1004      ((key about-xemacs) ": see who's developing XEmacs\n"))
1005
1006     ((face (blue bold underline) "\nUseful stuff:\n\n")
1007      "Things that you should know rather quickly...\n\n"
1008      ((key find-file) ": visit a file\n")
1009      ((key save-buffer) ": save changes\n")
1010      ((key advertised-undo) ": undo changes\n")
1011      ((key save-buffers-kill-emacs) ": exit XEmacs\n"))
1012     ])
1013
1014 ;; I really hate global variables, oh well.
1015 ;(defvar xemacs-startup-logo-function nil
1016 ;  "If non-nil, function called to provide the startup logo.
1017 ;This function should return an initialized glyph if it is used.")
1018
1019 ;; This will hopefully go away when gettext is functional.
1020 (defconst splash-frame-static-body
1021   `(,(emacs-version) "\n\n"
1022     (face italic "`C-' means the control key,`M-' means the meta key\n\n")))
1023
1024
1025 (defun circulate-splash-frame-elements (client-data)
1026   (with-current-buffer (aref client-data 2)
1027     (let ((buffer-read-only nil)
1028           (elements (aref client-data 3))
1029           (indice (aref client-data 0)))
1030       (goto-char (aref client-data 1))
1031       (delete-region (point) (point-max))
1032       (splash-frame-present (aref elements indice))
1033       (set-buffer-modified-p nil)
1034       (aset client-data 0
1035             (if (= indice (- (length elements) 1))
1036                 0
1037               (1+ indice )))
1038       )))
1039
1040 ;; #### This function now returns the (possibly nil) timeout circulating the
1041 ;; splash-frame elements
1042 (defun display-splash-frame ()
1043   (let ((logo xemacs-logo)
1044         (buffer-read-only nil)
1045         (cramped-p (eq 'tty (console-type))))
1046     (unless cramped-p (insert "\n"))
1047     (indent-to (startup-center-spaces logo))
1048     (set-extent-begin-glyph (make-extent (point) (point)) logo)
1049     ;;(splash-frame-present-hack (make-extent p (point)) 'about-xemacs))
1050     (insert "\n\n")
1051     (splash-frame-present splash-frame-static-body)
1052     (splash-hack-version-string)
1053     (goto-char (point-max))
1054     (let* ((after-change-functions nil) ; no font-lock, thank you
1055            (elements (splash-frame-body))
1056            (client-data `[ 1 ,(point) ,(current-buffer) ,elements ])
1057            tmout)
1058       (if (listp  elements) ;; A single element to display
1059           (splash-frame-present (splash-frame-body))
1060         ;; several elements to rotate
1061         (splash-frame-present (aref elements 0))
1062         (setq tmout (add-timeout splash-frame-timeout
1063                                  'circulate-splash-frame-elements
1064                                  client-data splash-frame-timeout)))
1065       (set-buffer-modified-p nil)
1066       tmout)))
1067
1068 ;;  (let ((present-file
1069 ;;         #'(lambda (f)
1070 ;;             (splash-frame-present
1071 ;;            (list 'funcall
1072 ;;                  (list 'find-file-other-window
1073 ;;                        (expand-file-name f data-directory))
1074 ;;                  f)))))
1075 ;;    (insert "For customization examples, see the files ")
1076 ;;    (funcall present-file "sample.emacs")
1077 ;;    (insert " and ")
1078 ;;    (funcall present-file "sample.Xdefaults")
1079 ;;    (insert (format "\nin the directory %s." data-directory)))
1080
1081 (defun startup-set-invocation-environment ()
1082   ;; XEmacs -- Steven Baur says invocation directory is nil if you
1083   ;; try to use XEmacs as a login shell.
1084   (or invocation-directory (setq invocation-directory default-directory))
1085   (setq invocation-directory
1086         ;; don't let /tmp_mnt/... get into the load-path or exec-path.
1087         (abbreviate-file-name invocation-directory)))
1088
1089 (defun startup-setup-paths (roots user-init-directory
1090                                   &optional
1091                                   inhibit-early-packages inhibit-site-lisp
1092                                   debug-paths)
1093   "Setup all the various paths.
1094 ROOTS is a list of plausible roots of the XEmacs directory hierarchy.
1095 If INHIBIT-PACKAGES is non-NIL, don't do packages.
1096 If INHIBIT-SITE-LISP is non-NIL, don't do site-lisp.
1097 If DEBUG-PATHS is non-NIL, print paths as they are detected.
1098 It's idempotent, so call this as often as you like!"
1099
1100   (apply #'(lambda (early late last)
1101              (setq early-packages (and (not inhibit-early-packages)
1102                                        early))
1103              (setq late-packages late)
1104              (setq last-packages last))
1105          (packages-find-packages
1106           roots
1107           (packages-compute-package-locations user-init-directory)))
1108
1109   (setq early-package-load-path (packages-find-package-load-path early-packages))
1110   (setq late-package-load-path (packages-find-package-load-path late-packages))
1111   (setq last-package-load-path (packages-find-package-load-path last-packages))
1112
1113   (if debug-paths
1114       (progn
1115         (princ (format "configure-package-path:\n%S\n" configure-package-path)
1116                'external-debugging-output)
1117         (princ (format "early-packages and early-package-load-path:\n%S\n%S\n"
1118                        early-packages early-package-load-path)
1119                'external-debugging-output)
1120         (princ (format "late-packages and late-package-load-path:\n%S\n%S\n"
1121                        late-packages late-package-load-path)
1122                'external-debugging-output)
1123         (princ (format "last-packages and last-package-load-path:\n%S\n%S\n"
1124                        last-packages last-package-load-path)
1125                'external-debugging-output)))
1126
1127   (setq lisp-directory (paths-find-lisp-directory roots))
1128
1129   (if debug-paths
1130       (princ (format "lisp-directory:\n%S\n" lisp-directory)
1131              'external-debugging-output))
1132
1133   (setq site-directory (and (null inhibit-site-lisp)
1134                             (paths-find-site-lisp-directory roots)))
1135
1136   (if (and debug-paths (null inhibit-site-lisp))
1137       (princ (format "site-directory:\n%S\n" site-directory)
1138              'external-debugging-output))
1139
1140   (setq load-path (paths-construct-load-path roots
1141                                              early-package-load-path
1142                                              late-package-load-path
1143                                              last-package-load-path
1144                                              lisp-directory
1145                                              site-directory))
1146
1147   (setq Info-directory-list
1148         (paths-construct-info-path roots
1149                                    early-packages late-packages last-packages))
1150
1151
1152   (if debug-paths
1153       (princ (format "Info-directory-list:\n%S\n" Info-directory-list)
1154              'external-debugging-output))
1155
1156   (if (boundp 'lock-directory)
1157       (progn
1158         (setq lock-directory (paths-find-lock-directory roots))
1159         (setq superlock-file (paths-find-superlock-file lock-directory))
1160
1161         (if debug-paths
1162             (progn
1163               (princ (format "lock-directory:\n%S\n" lock-directory)
1164                      'external-debugging-output)
1165               (princ (format "superlock-file:\n%S\n" superlock-file)
1166                      'external-debugging-output)))))
1167
1168   (setq exec-directory (paths-find-exec-directory roots))
1169
1170   (if debug-paths
1171       (princ (format "exec-directory:\n%s\n" exec-directory)
1172              'external-debugging-output))
1173
1174   (setq exec-path
1175         (paths-construct-exec-path roots exec-directory
1176                                    early-packages late-packages last-packages))
1177
1178   (if debug-paths
1179       (princ (format "exec-path:\n%S\n" exec-path)
1180              'external-debugging-output))
1181
1182   (setq doc-directory (paths-find-doc-directory roots))
1183
1184   (if debug-paths
1185       (princ (format "doc-directory:\n%S\n" doc-directory)
1186              'external-debugging-output))
1187
1188   (setq data-directory (paths-find-data-directory roots))
1189
1190   (if debug-paths
1191       (princ (format "data-directory:\n%S\n" data-directory)
1192              'external-debugging-output))
1193
1194   (setq data-directory-list (paths-construct-data-directory-list data-directory
1195                                                                  early-packages
1196                                                                  late-packages
1197                                                                  last-packages))
1198   (if debug-paths
1199       (princ (format "data-directory-list:\n%S\n" data-directory-list)
1200              'external-debugging-output)))
1201
1202 (defun startup-find-roots-warning ()
1203   (save-excursion
1204     (set-buffer (get-buffer-create " *warning-tmp*"))
1205     (erase-buffer)
1206     (buffer-disable-undo (current-buffer))
1207
1208     (insert "Couldn't find an obvious default for the root of the\n"
1209             "XEmacs hierarchy.")
1210
1211     (princ "\nWARNING:\n" 'external-debugging-output)
1212     (princ (buffer-string) 'external-debugging-output)))
1213
1214 (defun startup-setup-paths-warning ()
1215   (let ((lock (if (boundp 'lock-directory) lock-directory 't))
1216         (warnings '()))
1217     (if (and (stringp lock) (null (file-directory-p lock)))
1218         (setq lock nil))
1219     (cond
1220      ((null (and lisp-directory exec-directory data-directory doc-directory
1221                  load-path
1222                  lock))
1223       (save-excursion
1224         (set-buffer (get-buffer-create " *warning-tmp*"))
1225         (erase-buffer)
1226         (buffer-disable-undo (current-buffer))
1227         (if (null lisp-directory) (push "lisp-directory" warnings))
1228         (if (null lock)           (push "lock-directory" warnings))
1229         (if (null exec-directory) (push "exec-directory" warnings))
1230         (if (null data-directory) (push "data-directory" warnings))
1231         (if (null doc-directory)  (push "doc-directory"  warnings))
1232         (if (null load-path)      (push "load-path"      warnings))
1233
1234         (insert "Couldn't find obvious defaults for:\n")
1235         (while warnings
1236           (insert (car warnings) "\n")
1237           (setq warnings (cdr warnings)))
1238         (insert "Perhaps some directories don't exist, "
1239                 "or the XEmacs executable,\n" (concat invocation-directory
1240                                                      invocation-name)
1241                 "\nis in a strange place?")
1242
1243         (princ "\nWARNING:\n" 'external-debugging-output)
1244         (princ (buffer-string) 'external-debugging-output)
1245         (erase-buffer)
1246         t)))))
1247
1248 ;;; startup.el ends here