XEmacs 21.2.28 "Hermes".
[chise/xemacs-chise.git.1] / 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     (if (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
418     (if (not inhibit-autoloads)
419         (progn
420           (if (not inhibit-early-packages)
421               (packages-load-package-auto-autoloads early-package-load-path))
422           (packages-load-package-auto-autoloads late-package-load-path)
423           (packages-load-package-auto-autoloads last-package-load-path)))
424
425     (unwind-protect
426         (command-line)
427       ;; Do this again, in case .emacs defined more abbreviations.
428       (setq default-directory (abbreviate-file-name default-directory))
429       ;; Specify the file for recording all the auto save files of
430       ;; this session.  This is used by recover-session.
431       (setq auto-save-list-file-name
432             (expand-file-name
433              (format "%s%d-%s"
434                      auto-save-list-file-prefix
435                      (emacs-pid)
436                      (system-name))))
437       (run-hooks 'emacs-startup-hook)
438       (and term-setup-hook
439            (run-hooks 'term-setup-hook))
440       (setq term-setup-hook nil)
441       ;;      ;; Modify the initial frame based on what .emacs puts into
442       ;;      ;; ...-frame-alist.
443       (frame-notice-user-settings)
444       ;;      ;;####FSFmacs junk
445       ;;      ;; Now we know the user's default font, so add it to the menu.
446       ;;      (if (fboundp 'font-menu-add-default)
447       ;;          (font-menu-add-default))
448       (when window-setup-hook
449         (run-hooks 'window-setup-hook))
450       (setq window-setup-hook nil))
451     ;;####FSFmacs junk
452     ;;      (or menubar-bindings-done
453     ;;    (precompute-menubar-bindings))
454     ))
455
456 ;;####FSFmacs junk
457 ;;; Precompute the keyboard equivalents in the menu bar items.
458 ;;(defun precompute-menubar-bindings ()
459 ;;  (if (eq window-system 'x)
460 ;;      (let ((submap (lookup-key global-map [menu-bar])))
461 ;;      (while submap
462 ;;        (and (consp (car submap))
463 ;;             (symbolp (car (car submap)))
464 ;;             (stringp (car-safe (cdr (car submap))))
465 ;;             (keymapp (cdr (cdr (car submap))))
466 ;;             (x-popup-menu nil (cdr (cdr (car submap)))))
467 ;;        (setq submap (cdr submap))))))
468
469 (defun command-line-early (args)
470   ;; This processes those switches which need to be processed before
471   ;; starting up the window system.
472
473   (setq command-line-default-directory default-directory)
474
475   ;; See if we should import version-control from the environment variable.
476   (let ((vc (getenv "VERSION_CONTROL")))
477     (cond ((eq vc nil))                 ;don't do anything if not set
478           ((or (string= vc "t")
479                (string= vc "numbered"))
480            (setq version-control t))
481           ((or (string= vc "nil")
482                (string= vc "existing"))
483            (setq version-control nil))
484           ((or (string= vc "never")
485                (string= vc "simple"))
486            (setq version-control 'never))))
487
488   ;;####FSFmacs
489   ;;  (if (let ((ctype
490   ;;         ;; Use the first of these three envvars that has a nonempty value.
491   ;;         (or (let ((string (getenv "LC_ALL")))
492   ;;               (and (not (equal string "")) string))
493   ;;             (let ((string (getenv "LC_CTYPE")))
494   ;;               (and (not (equal string "")) string))
495   ;;             (let ((string (getenv "LANG")))
496   ;;               (and (not (equal string "")) string)))))
497   ;;    (and ctype
498   ;;         (string-match iso-8859-1-locale-regexp ctype)))
499   ;;      (progn
500   ;;    (standard-display-european t)
501   ;;    (require 'iso-syntax)))
502
503   (setq load-user-init-file-p (not (noninteractive)))
504
505   ;; Allow (at least) these arguments anywhere in the command line
506   (let ((new-args nil)
507         (arg      nil))
508     (while args
509       (setq arg (pop args))
510       (cond
511        ((or (string= arg "-q")
512             (string= arg "-no-init-file"))
513         (setq load-user-init-file-p nil))
514        ((string= arg "-no-site-file")
515         (setq site-start-file nil))
516        ((or (string= arg "-no-early-packages")
517             (string= arg "--no-early-packages"))
518         (setq inhibit-early-packages t))
519        ((or (string= arg "-vanilla")
520             (string= arg "--vanilla")
521             ;; Some work on this one already done in emacs.c.
522             (string= arg "-no-autoloads")
523             (string= arg "--no-autoloads"))
524         (setq load-user-init-file-p nil
525               site-start-file nil))
526        ((string= arg "-user-init-file")
527         (setq user-init-file (pop args)))
528        ((string= arg "-user-init-directory")
529         (setq user-init-directory (file-name-as-directory (pop args))))
530        ((or (string= arg "-u")
531             (string= arg "-user"))
532         (let* ((user (pop args))
533                (home-user (concat "~" user)))
534           (setq user-init-file (find-user-init-file home-user)
535                 user-init-directory (file-name-as-directory
536                                      (paths-construct-path
537                                       (list home-user user-init-directory-base))))))
538        ((string= arg "-debug-init")
539         (setq init-file-debug t))
540        ((string= arg "-unmapped")
541         (setq initial-frame-unmapped-p t))
542        ((or (string= arg "-debug-paths")
543             (string= arg "--debug-paths"))
544         t)
545        ((or (string= arg "--") (string= arg "-"))
546         (while args
547           (push (pop args) new-args)))
548        (t (push arg new-args))))
549
550     (setq init-file-user (and load-user-init-file-p ""))
551
552     (nreverse new-args)))
553
554 (defconst initial-scratch-message "\
555 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
556 ;; If you want to create a file, first visit that file with C-x C-f,
557 ;; then enter the text in that file's own buffer.
558
559 "
560   "Initial message displayed in *scratch* buffer at startup.
561 If this is nil, no message will be displayed.")
562
563 (defun command-line ()
564   (let ((command-line-args-left (cdr command-line-args)))
565
566     (let ((debugger 'early-error-handler)
567           (debug-on-error t))
568
569       ;; Process magic command-line switches like -q and -u.  Do this
570       ;; before creating the first frame because some of these switches
571       ;; may affect that.  I think it's ok to do this before establishing
572       ;; the X connection, and maybe someday things like -nw can be
573       ;; handled here instead of down in C.
574       (setq command-line-args-left (command-line-early command-line-args-left))
575
576       ;; Setup the toolbar icon directory
577       (when (featurep 'toolbar)
578         (init-toolbar-location))
579
580       ;; Run the window system's init function.  tty is considered to be
581       ;; a type of window system for this purpose.  This creates the
582       ;; initial (non stdio) device.
583       (when (and initial-window-system (not noninteractive))
584         (funcall (intern (concat "init-"
585                                  (symbol-name initial-window-system)
586                                  "-win"))))
587
588       ;; When not in batch mode, this creates the first visible frame,
589       ;; and deletes the stdio device.
590       (frame-initialize))
591
592     ;; Reinitialize faces if necessary.  This function changes face if
593     ;; it is created during auto-autoloads loading.  Otherwise, it
594     ;; does nothing.
595     (startup-initialize-custom-faces)
596
597     ;;
598     ;; We have normality, I repeat, we have normality.  Anything you still
599     ;; can't cope with is therefore your own problem.  (And we don't need
600     ;; to kill XEmacs for it.)
601     ;;
602
603     ;;; Load init files.
604     (load-init-file)
605
606     (with-current-buffer (get-buffer "*scratch*")
607       (erase-buffer)
608       ;; (insert initial-scratch-message)
609       (set-buffer-modified-p nil)
610       (when (eq major-mode 'fundamental-mode)
611         (funcall initial-major-mode)))
612
613     ;; Load library for our terminal type.
614     ;; User init file can set term-file-prefix to nil to prevent this.
615     ;; Note that for any TTY's opened subsequently, the TTY init
616     ;; code will run this.
617     (when (and (eq 'tty (console-type))
618                (not (noninteractive)))
619       (load-terminal-library))
620
621     ;; Process the remaining args.
622     (command-line-1)
623
624     ;; it was turned on by default so that the warnings don't get displayed
625     ;; until after the splash screen.
626     (setq inhibit-warning-display nil)
627     ;; If -batch, terminate after processing the command options.
628     (when (noninteractive) (kill-emacs t))))
629
630 (defun load-terminal-library ()
631   (when term-file-prefix
632     (let ((term (getenv "TERM"))
633           hyphend)
634       (while (and term
635                   (not (load (concat term-file-prefix term) t t)))
636         ;; Strip off last hyphen and what follows, then try again
637         (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
638             (setq term (substring term 0 hyphend))
639           (setq term nil))))))
640
641 (defun find-user-init-file (&optional directory)
642   "Determine the user's init file."
643   (unless directory
644     (setq directory "~"))
645   (dolist (file user-init-file-base-list)
646     (let ((expanded (paths-construct-path (list directory file))))
647       (when (file-exists-p expanded)
648         (return expanded)))))
649
650 (defun load-user-init-file ()
651   "This function actually reads the init file, .emacs."
652   (if (not user-init-file)
653       (setq user-init-file (find-user-init-file)))
654   (load user-init-file t t t)
655   (unless inhibit-default-init
656     (let ((inhibit-startup-message nil))
657       ;; Users are supposed to be told their rights.
658       ;; (Plus how to get help and how to undo.)
659       ;; Don't you dare turn this off for anyone except yourself.
660       (load "default" t t))))
661
662 ;;; Load user's init file and default ones.
663 (defun load-init-file ()
664   (run-hooks 'before-init-hook)
665
666   ;; Run the site-start library if it exists.  The point of this file is
667   ;; that it is run before .emacs.  There is no point in doing this after
668   ;; .emacs; that is useless.
669   (when site-start-file
670     (load site-start-file t t))
671
672   ;; Sites should not disable this.  Only individuals should disable
673   ;; the startup message.
674   (setq inhibit-startup-message nil)
675
676   (let (debug-on-error-from-init-file
677         debug-on-error-should-be-set
678         (debug-on-error-initial
679          (if (eq init-file-debug t) 'startup init-file-debug)))
680     (let ((debug-on-error debug-on-error-initial))
681       (if (and load-user-init-file-p init-file-debug)
682           ;; Do this without a condition-case if the user wants to debug.
683           (load-user-init-file)
684         (condition-case error
685             (progn
686               (if load-user-init-file-p
687                   (load-user-init-file))
688               (setq init-file-had-error nil))
689           (error
690            (message "Error in init file: %s" (error-message-string error))
691            (display-warning 'initialization
692              (format "\
693 An error has occurred while loading %s:
694
695 %s
696
697 To ensure normal operation, you should investigate the cause of the error
698 in your initialization file and remove it.  Use the `-debug-init' option
699 to XEmacs to view a complete error backtrace."
700                      user-init-file (error-message-string error))
701              'error)
702            (setq init-file-had-error t))))
703       ;; If we can tell that the init file altered debug-on-error,
704       ;; arrange to preserve the value that it set up.
705       (or (eq debug-on-error debug-on-error-initial)
706           (setq debug-on-error-should-be-set t
707                 debug-on-error-from-init-file debug-on-error)))
708     (when debug-on-error-should-be-set
709       (setq debug-on-error debug-on-error-from-init-file)))
710
711   (setq init-file-loaded t)
712
713   ;; Do this here in case the init file sets mail-host-address.
714   ;; Don't do this here unless noninteractive, it is frequently wrong. -sb
715   ;; (or user-mail-address
716   (when noninteractive
717     (setq user-mail-address (concat (user-login-name) "@"
718                                     (or mail-host-address
719                                         (system-name)))))
720
721   (run-hooks 'after-init-hook)
722   nil)
723
724 (defun load-options-file (filename)
725   "Load the file of saved options (from the Options menu) called FILENAME.
726 Currently this does nothing but call `load', but it might be redefined
727 in the future to support automatically converting older options files to
728 a new format, when variables have changed, etc."
729   (load filename))
730
731 (defun command-line-1 ()
732   (cond
733    ((null command-line-args-left)
734     (unless noninteractive
735       ;; If there are no switches to process, run the term-setup-hook
736       ;; before displaying the copyright notice; there may be some need
737       ;; to do it before doing any output.  If we're not going to
738       ;; display a copyright notice (because other options are present)
739       ;; then this is run after those options are processed.
740       (run-hooks 'term-setup-hook)
741       ;; Don't let the hook be run twice.
742       (setq term-setup-hook nil)
743
744       ;; Don't clobber a non-scratch buffer if init file
745       ;; has selected it.
746       (when (string= (buffer-name) "*scratch*")
747         (unless (or inhibit-startup-message
748                     (input-pending-p))
749           (let (tmout circ-tmout)
750             (unwind-protect
751                 ;; Guts of with-timeout
752                 (catch 'tmout
753                   (setq tmout (add-timeout startup-message-timeout
754                                            (lambda (ignore)
755                                              (condition-case nil
756                                                  (throw 'tmout t)
757                                                (error nil)))
758                                            nil))
759                   (setq circ-tmout (display-splash-frame))
760                   (or nil;; (pos-visible-in-window-p (point-min))
761                       (goto-char (point-min)))
762                   (sit-for 0)
763                   (setq unread-command-event (next-command-event)))
764               (when tmout (disable-timeout tmout))
765               (when circ-tmout (disable-timeout circ-tmout)))))
766         (with-current-buffer (get-buffer "*scratch*")
767           ;; In case the XEmacs server has already selected
768           ;; another buffer, erase the one our message is in.
769           (erase-buffer)
770           (when (stringp initial-scratch-message)
771             (insert initial-scratch-message))
772           (set-buffer-modified-p nil)))))
773
774    (t
775     ;; Command-line-options exist
776     (let ((dir command-line-default-directory)
777           (file-count 0)
778           (line nil)
779           (end-of-options nil)
780           first-file-buffer file-p arg tem)
781       (while command-line-args-left
782         (setq arg (pop command-line-args-left))
783         (cond
784          (end-of-options
785           (setq file-p t))
786          ((setq tem (when (eq (aref arg 0) ?-)
787                       (or (assoc arg command-switch-alist)
788                           (assoc (substring arg 1)
789                                  command-switch-alist))))
790           (funcall (cdr tem) arg))
791          ((string-match "\\`\\+[0-9]+\\'" arg)
792           (setq line (string-to-int arg)))
793          ;; "- file" means don't treat "file" as a switch
794          ;;  ("+0 file" has the same effect; "-" added
795          ;;   for unixoidiality).
796          ;; This is worthless; the `unixoid' way is "./file". -jwz
797          ((or (string= arg "-") (string= arg "--"))
798           (setq end-of-options t))
799          (t
800           (setq file-p t)))
801
802         (when file-p
803           (setq file-p nil)
804           (incf file-count)
805           (setq arg (expand-file-name arg dir))
806           (cond
807            ((= file-count 1) (setq first-file-buffer
808                                    (progn (find-file arg) (current-buffer))))
809            (noninteractive (find-file arg))
810            (t (find-file-other-window arg)))
811           (when line
812             (goto-line line)
813             (setq line nil))))))))
814
815 (defvar startup-presentation-hack-keymap
816   (let ((map (make-sparse-keymap)))
817     (set-keymap-name map 'startup-presentation-hack-keymap)
818     (define-key map '[button1] 'startup-presentation-hack)
819     (define-key map '[button2] 'startup-presentation-hack)
820     map)
821   "Putting yesterday in the future tomorrow.")
822
823 (defun startup-presentation-hack ()
824   (interactive)
825   (let ((e last-command-event))
826     (and (button-press-event-p e)
827          (setq e (extent-at (event-point e)
828                             (event-buffer e)
829                             'startup-presentation-hack))
830          (setq e (extent-property e 'startup-presentation-hack))
831          (if (consp e)
832              (apply (car e) (cdr e))
833            (while (keymapp (indirect-function e))
834              (let ((map e)
835                    (overriding-local-map (indirect-function e)))
836                (setq e (read-key-sequence
837                         (let ((p (keymap-prompt map t)))
838                           (cond ((symbolp map)
839                                  (if p
840                                      (format "%s %s " map p)
841                                    (format "%s " map)))
842                                 (p)
843                                 (t
844                                  (prin1-to-string map))))))
845                (if (and (button-release-event-p (elt e 0))
846                         (null (key-binding e)))
847                    (setq e map)         ; try again
848                  (setq e (key-binding e)))))
849            (call-interactively e)))))
850
851 (defun startup-presentation-hack-help (e)
852   (setq e (extent-property e 'startup-presentation-hack))
853   (if (consp e)
854       (format "Evaluate %S" e)
855     (symbol-name e)))
856
857 (defun splash-frame-present-hack (e v)
858   ;;   (set-extent-property e 'mouse-face 'highlight)
859   ;;   (set-extent-property e 'keymap
860   ;;                           startup-presentation-hack-keymap)
861   ;;   (set-extent-property e 'startup-presentation-hack v)
862   ;;   (set-extent-property e 'help-echo
863   ;;                           'startup-presentation-hack-help)
864   )
865
866 (defun splash-hack-version-string ()
867   (save-excursion
868     (save-restriction
869       (goto-char (point-min))
870       (re-search-forward "^XEmacs" nil t)
871       (narrow-to-region (point-at-bol) (point-at-eol))
872       (goto-char (point-min))
873       (when (re-search-forward " \\[Lucid\\]" nil t)
874         (delete-region (match-beginning 0) (match-end 0)))
875       (when (re-search-forward "[^(][^)]*-[^)]*-" nil t)
876         (delete-region (1+ (match-beginning 0)) (match-end 0))
877         (insert "("))
878       (goto-char (point-max))
879       (search-backward " " nil t)
880       (when (search-forward "." nil t)
881         (delete-region (1- (point)) (point-max))))))
882
883 (defun splash-frame-present (l)
884   (cond ((stringp l)
885          (insert l))
886         ((eq (car-safe l) 'face)
887          ;; (face name string)
888          (let ((p (point)))
889            (splash-frame-present (elt l 2))
890            (if (fboundp 'set-extent-face)
891                (set-extent-face (make-extent p (point))
892                                 (elt l 1)))))
893         ((eq (car-safe l) 'key)
894          (let* ((c (elt l 1))
895                 (p (point))
896                 (k (where-is-internal c nil t)))
897            (insert (if k (key-description k)
898                      (format "M-x %s" c)))
899            (if (fboundp 'set-extent-face)
900                (let ((e (make-extent p (point))))
901                  (set-extent-face e 'bold)
902                  (splash-frame-present-hack e c)))))
903         ((eq (car-safe l) 'funcall)
904          ;; (funcall (fun . args) string)
905          (let ((p (point)))
906            (splash-frame-present (elt l 2))
907            (if (fboundp 'set-extent-face)
908                (splash-frame-present-hack (make-extent p (point))
909                                           (elt l 1)))))
910         ((consp l)
911          (mapcar 'splash-frame-present l))
912         (t
913          (error "WTF!?"))))
914
915 (defun startup-center-spaces (glyph)
916   ;; Return the number of spaces to insert in order to center
917   ;; the given glyph (may be a string or a pixmap).
918   ;; Assume spaces are as wide as avg-pixwidth.
919   ;; Won't be quite right for proportional fonts, but it's the best we can do.
920   ;; Maybe the new redisplay will export something a glyph-width function.
921   ;;; #### Yes, there is a glyph-width function but it isn't quite what
922   ;;; #### this was expecting.  Or is it?
923   ;; (An alternate way to get avg-pixwidth would be to use x-font-properties
924   ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.)
925
926   ;; This function is used in about.el too.
927   (let* ((avg-pixwidth     (round (/ (frame-pixel-width) (frame-width))))
928          (fill-area-width  (* avg-pixwidth (- fill-column left-margin)))
929          (glyph-pixwidth   (cond ((stringp glyph)
930                                   (* avg-pixwidth (length glyph)))
931                                  ;; #### the pixmap option should be removed
932                                  ;;((pixmapp glyph)
933                                  ;; (pixmap-width glyph))
934                                  ((glyphp glyph)
935                                   (glyph-width glyph))
936                                  (t
937                                   (error "startup-center-spaces: bad arg")))))
938     (+ left-margin
939        (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth)))))
940
941 (defun splash-frame-body ()
942   `[((face (blue bold underline)
943            "\nDistribution, copying license, warranty:\n\n")
944      "Please visit the XEmacs website at http://www.xemacs.org !\n\n"
945      ,@(if (featurep 'sparcworks)
946            `( "\
947 Sun provides support for the WorkShop/XEmacs integration package only.
948 All other XEmacs packages are provided to you \"AS IS\".\n"
949               ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES")
950                                 (getenv "LANG"))))
951                   (if (and
952                        (not (featurep 'mule)) ;; Already got mule?
953                        ;; No Mule support on tty's yet
954                        (not (eq 'tty (console-type)))
955                        lang ;; Non-English locale?
956                        (not (string= lang "C"))
957                        (not (string-match "^en" lang))
958                        ;; Comes with Sun WorkShop
959                        (locate-file "xemacs-mule" exec-path))
960                       '( "\
961 This version of XEmacs has been built with support for Latin-1 languages only.
962 To handle other languages you need to run a Multi-lingual (`Mule') version of
963 XEmacs, by either running the command `xemacs-mule', or by using the X resource
964 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop.
965 \n")))))
966      ((key describe-no-warranty)
967       ": "(face (red bold) "XEmacs comes with ABSOLUTELY NO WARRANTY\n"))
968      ((key describe-copying)
969       ": conditions to give out copies of XEmacs\n")
970      ((key describe-distribution)
971       ": how to get the latest version\n")
972      "\n--\n"
973      (face italic "\
974 Copyright (C) 1985-1999 Free Software Foundation, Inc.
975 Copyright (C) 1990-1994 Lucid, Inc.
976 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved.
977 Copyright (C) 1994-1996 Board of Trustees, University of Illinois
978 Copyright (C) 1995-1996 Ben Wing\n"))
979
980     ((face (blue bold underline) "\nInformation, on-line help:\n\n")
981      "XEmacs comes with plenty of documentation...\n\n"
982      ,@(if (string-match "beta" emacs-version)
983            `((key describe-beta)
984              ": " (face (red bold)
985                         "This is an Experimental version of XEmacs.\n"))
986          `( "\n"))
987      ((key xemacs-local-faq)
988       ": read the XEmacs FAQ (a " (face underline "capital") " F!)\n")
989      ((key help-with-tutorial)
990       ": read the XEmacs tutorial (also available through the "
991       (face bold "Help") " menu)\n")
992      ((key help-command)
993       ": get help on using XEmacs (also available through the "
994       (face bold "Help") " menu)\n")
995      ((key info) ": read the on-line documentation\n\n")
996      ((key describe-project) ": read about the GNU project\n")
997      ((key about-xemacs) ": see who's developing XEmacs\n"))
998
999     ((face (blue bold underline) "\nUseful stuff:\n\n")
1000      "Things that you should know rather quickly...\n\n"
1001      ((key find-file) ": visit a file\n")
1002      ((key save-buffer) ": save changes\n")
1003      ((key advertised-undo) ": undo changes\n")
1004      ((key save-buffers-kill-emacs) ": exit XEmacs\n"))
1005     ])
1006
1007 ;; I really hate global variables, oh well.
1008 ;(defvar xemacs-startup-logo-function nil
1009 ;  "If non-nil, function called to provide the startup logo.
1010 ;This function should return an initialized glyph if it is used.")
1011
1012 ;; This will hopefully go away when gettext is functional.
1013 (defconst splash-frame-static-body
1014   `(,(emacs-version) "\n\n"
1015     (face italic "`C-' means the control key,`M-' means the meta key\n\n")))
1016
1017
1018 (defun circulate-splash-frame-elements (client-data)
1019   (with-current-buffer (aref client-data 2)
1020     (let ((buffer-read-only nil)
1021           (elements (aref client-data 3))
1022           (indice (aref client-data 0)))
1023       (goto-char (aref client-data 1))
1024       (delete-region (point) (point-max))
1025       (splash-frame-present (aref elements indice))
1026       (set-buffer-modified-p nil)
1027       (aset client-data 0
1028             (if (= indice (- (length elements) 1))
1029                 0
1030               (1+ indice )))
1031       )))
1032
1033 ;; #### This function now returns the (possibly nil) timeout circulating the
1034 ;; splash-frame elements
1035 (defun display-splash-frame ()
1036   (let ((logo xemacs-logo)
1037         (buffer-read-only nil)
1038         (cramped-p (eq 'tty (console-type))))
1039     (unless cramped-p (insert "\n"))
1040     (indent-to (startup-center-spaces logo))
1041     (set-extent-begin-glyph (make-extent (point) (point)) logo)
1042     ;;(splash-frame-present-hack (make-extent p (point)) 'about-xemacs))
1043     (insert "\n\n")
1044     (splash-frame-present splash-frame-static-body)
1045     (splash-hack-version-string)
1046     (goto-char (point-max))
1047     (let* ((after-change-functions nil) ; no font-lock, thank you
1048            (elements (splash-frame-body))
1049            (client-data `[ 1 ,(point) ,(current-buffer) ,elements ])
1050            tmout)
1051       (if (listp  elements) ;; A single element to display
1052           (splash-frame-present (splash-frame-body))
1053         ;; several elements to rotate
1054         (splash-frame-present (aref elements 0))
1055         (setq tmout (add-timeout splash-frame-timeout
1056                                  'circulate-splash-frame-elements
1057                                  client-data splash-frame-timeout)))
1058       (set-buffer-modified-p nil)
1059       tmout)))
1060
1061 ;;  (let ((present-file
1062 ;;         #'(lambda (f)
1063 ;;             (splash-frame-present
1064 ;;            (list 'funcall
1065 ;;                  (list 'find-file-other-window
1066 ;;                        (expand-file-name f data-directory))
1067 ;;                  f)))))
1068 ;;    (insert "For customization examples, see the files ")
1069 ;;    (funcall present-file "sample.emacs")
1070 ;;    (insert " and ")
1071 ;;    (funcall present-file "sample.Xdefaults")
1072 ;;    (insert (format "\nin the directory %s." data-directory)))
1073
1074 (defun startup-set-invocation-environment ()
1075   ;; XEmacs -- Steven Baur says invocation directory is nil if you
1076   ;; try to use XEmacs as a login shell.
1077   (or invocation-directory (setq invocation-directory default-directory))
1078   (setq invocation-directory
1079         ;; don't let /tmp_mnt/... get into the load-path or exec-path.
1080         (abbreviate-file-name invocation-directory)))
1081
1082 (defun startup-setup-paths (roots user-init-directory
1083                                   &optional
1084                                   inhibit-early-packages inhibit-site-lisp
1085                                   debug-paths)
1086   "Setup all the various paths.
1087 ROOTS is a list of plausible roots of the XEmacs directory hierarchy.
1088 If INHIBIT-PACKAGES is non-NIL, don't do packages.
1089 If INHIBIT-SITE-LISP is non-NIL, don't do site-lisp.
1090 If DEBUG-PATHS is non-NIL, print paths as they are detected.
1091 It's idempotent, so call this as often as you like!"
1092
1093   (apply #'(lambda (early late last)
1094              (setq early-packages (and (not inhibit-early-packages)
1095                                        early))
1096              (setq late-packages late)
1097              (setq last-packages last))
1098          (packages-find-packages
1099           roots
1100           (packages-compute-package-locations user-init-directory)))
1101
1102   (setq early-package-load-path (packages-find-package-load-path early-packages))
1103   (setq late-package-load-path (packages-find-package-load-path late-packages))
1104   (setq last-package-load-path (packages-find-package-load-path last-packages))
1105
1106   (if debug-paths
1107       (progn
1108         (princ (format "configure-package-path:\n%S\n" configure-package-path)
1109                'external-debugging-output)
1110         (princ (format "early-packages and early-package-load-path:\n%S\n%S\n"
1111                        early-packages early-package-load-path)
1112                'external-debugging-output)
1113         (princ (format "late-packages and late-package-load-path:\n%S\n%S\n"
1114                        late-packages late-package-load-path)
1115                'external-debugging-output)
1116         (princ (format "last-packages and last-package-load-path:\n%S\n%S\n"
1117                        last-packages last-package-load-path)
1118                'external-debugging-output)))
1119
1120   (setq lisp-directory (paths-find-lisp-directory roots))
1121
1122   (if debug-paths
1123       (princ (format "lisp-directory:\n%S\n" lisp-directory)
1124              'external-debugging-output))
1125
1126   (setq site-directory (and (null inhibit-site-lisp)
1127                             (paths-find-site-lisp-directory roots)))
1128
1129   (if (and debug-paths (null inhibit-site-lisp))
1130       (princ (format "site-directory:\n%S\n" site-directory)
1131              'external-debugging-output))
1132
1133   (setq load-path (paths-construct-load-path roots
1134                                              early-package-load-path
1135                                              late-package-load-path
1136                                              last-package-load-path
1137                                              lisp-directory
1138                                              site-directory))
1139
1140   (setq Info-directory-list
1141         (paths-construct-info-path roots
1142                                    early-packages late-packages last-packages))
1143
1144
1145   (if debug-paths
1146       (princ (format "Info-directory-list:\n%S\n" Info-directory-list)
1147              'external-debugging-output))
1148
1149   (if (boundp 'lock-directory)
1150       (progn
1151         (setq lock-directory (paths-find-lock-directory roots))
1152         (setq superlock-file (paths-find-superlock-file lock-directory))
1153
1154         (if debug-paths
1155             (progn
1156               (princ (format "lock-directory:\n%S\n" lock-directory)
1157                      'external-debugging-output)
1158               (princ (format "superlock-file:\n%S\n" superlock-file)
1159                      'external-debugging-output)))))
1160
1161   (setq exec-directory (paths-find-exec-directory roots))
1162
1163   (if debug-paths
1164       (princ (format "exec-directory:\n%s\n" exec-directory)
1165              'external-debugging-output))
1166
1167   (setq exec-path
1168         (paths-construct-exec-path roots exec-directory
1169                                    early-packages late-packages last-packages))
1170
1171   (if debug-paths
1172       (princ (format "exec-path:\n%S\n" exec-path)
1173              'external-debugging-output))
1174
1175   (setq doc-directory (paths-find-doc-directory roots))
1176
1177   (if debug-paths
1178       (princ (format "doc-directory:\n%S\n" doc-directory)
1179              'external-debugging-output))
1180
1181   (setq data-directory (paths-find-data-directory roots))
1182
1183   (if debug-paths
1184       (princ (format "data-directory:\n%S\n" data-directory)
1185              'external-debugging-output))
1186
1187   (setq data-directory-list (paths-construct-data-directory-list data-directory
1188                                                                  early-packages
1189                                                                  late-packages
1190                                                                  last-packages))
1191   (if debug-paths
1192       (princ (format "data-directory-list:\n%S\n" data-directory-list)
1193              'external-debugging-output)))
1194
1195 (defun startup-find-roots-warning ()
1196   (save-excursion
1197     (set-buffer (get-buffer-create " *warning-tmp*"))
1198     (erase-buffer)
1199     (buffer-disable-undo (current-buffer))
1200
1201     (insert "Couldn't find an obvious default for the root of the\n"
1202             "XEmacs hierarchy.")
1203
1204     (princ "\nWARNING:\n" 'external-debugging-output)
1205     (princ (buffer-string) 'external-debugging-output)))
1206
1207 (defun startup-setup-paths-warning ()
1208   (let ((lock (if (boundp 'lock-directory) lock-directory 't))
1209         (warnings '()))
1210     (if (and (stringp lock) (null (file-directory-p lock)))
1211         (setq lock nil))
1212     (cond
1213      ((null (and lisp-directory exec-directory data-directory doc-directory
1214                  load-path
1215                  lock))
1216       (save-excursion
1217         (set-buffer (get-buffer-create " *warning-tmp*"))
1218         (erase-buffer)
1219         (buffer-disable-undo (current-buffer))
1220         (if (null lisp-directory) (push "lisp-directory" warnings))
1221         (if (null lock)           (push "lock-directory" warnings))
1222         (if (null exec-directory) (push "exec-directory" warnings))
1223         (if (null data-directory) (push "data-directory" warnings))
1224         (if (null doc-directory)  (push "doc-directory"  warnings))
1225         (if (null load-path)      (push "load-path"      warnings))
1226
1227         (insert "Couldn't find obvious defaults for:\n")
1228         (while warnings
1229           (insert (car warnings) "\n")
1230           (setq warnings (cdr warnings)))
1231         (insert "Perhaps some directories don't exist, "
1232                 "or the XEmacs executable,\n" (concat invocation-directory
1233                                                      invocation-name)
1234                 "\nis in a strange place?")
1235
1236         (princ "\nWARNING:\n" 'external-debugging-output)
1237         (princ (buffer-string) 'external-debugging-output)
1238         (erase-buffer)
1239         t)))))
1240
1241 ;;; startup.el ends here