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