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