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