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