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