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