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.
|
114
|
609 ;; Don't do this here unless noninteractive, it is frequently wrong. -sb
|
|
610 ;; (or user-mail-address
|
|
611 (when noninteractive
|
|
612 (setq user-mail-address (concat (user-login-name) "@"
|
|
613 (or mail-host-address
|
|
614 (system-name)))))
|
0
|
615
|
|
616 (run-hooks 'after-init-hook)
|
|
617 nil)
|
|
618
|
|
619 (defun load-options-file (filename)
|
|
620 "Load the file of saved options (from the Options menu) called FILENAME.
|
|
621 Currently this does nothing but call `load', but it might be redefined
|
|
622 in the future to support automatically converting older options files to
|
|
623 a new format, when variables have changed, etc."
|
|
624 (load filename))
|
|
625
|
|
626 (defun command-line-1 ()
|
|
627 (if (null command-line-args-left)
|
70
|
628 (unless (or inhibit-startup-message
|
|
629 noninteractive
|
0
|
630 ;; Don't clobber a non-scratch buffer if init file
|
|
631 ;; has selected it.
|
70
|
632 (not (string= (buffer-name) "*scratch*"))
|
|
633 (input-pending-p))
|
0
|
634
|
70
|
635 ;; If there are no switches to process, run the term-setup-hook
|
|
636 ;; before displaying the copyright notice; there may be some need
|
|
637 ;; to do it before doing any output. If we're not going to
|
|
638 ;; display a copyright notice (because other options are present)
|
|
639 ;; then this is run after those options are processed.
|
|
640 (run-hooks 'term-setup-hook)
|
|
641 ;; Don't let the hook be run twice.
|
|
642 (setq term-setup-hook nil)
|
0
|
643
|
70
|
644 (let ((timeout nil))
|
|
645 (unwind-protect
|
|
646 ;; Guts of with-timeout
|
|
647 (catch 'timeout
|
|
648 (setq timeout (add-timeout startup-message-timeout
|
|
649 (lambda (ignore)
|
|
650 (condition-case nil
|
|
651 (throw 'timeout t)
|
|
652 (error nil)))
|
|
653 nil))
|
|
654 (startup-splash-frame)
|
|
655 (or nil;; (pos-visible-in-window-p (point-min))
|
|
656 (goto-char (point-min)))
|
|
657 (sit-for 0)
|
|
658 (setq unread-command-event (next-command-event)))
|
|
659 (when timeout (disable-timeout timeout))
|
|
660 (save-excursion
|
|
661 ;; In case the XEmacs server has already selected
|
|
662 ;; another buffer, erase the one our message is in.
|
|
663 (set-buffer (get-buffer "*scratch*"))
|
|
664 (erase-buffer)
|
|
665 (set-buffer-modified-p nil)))))
|
|
666
|
|
667 ;; Command-line-options exist
|
0
|
668 (let ((dir command-line-default-directory)
|
|
669 (file-count 0)
|
70
|
670 (line nil)
|
|
671 (end-of-options nil)
|
|
672 first-file-buffer file-p arg tem)
|
0
|
673 (while command-line-args-left
|
70
|
674 (setq arg (pop command-line-args-left))
|
|
675 (cond
|
|
676 (end-of-options
|
|
677 (setq file-p t))
|
|
678 ((setq tem (when (eq (aref arg 0) ?-)
|
|
679 (or (assoc arg command-switch-alist)
|
|
680 (assoc (substring arg 1)
|
|
681 command-switch-alist))))
|
|
682 (funcall (cdr tem) arg))
|
|
683 ((string-match "\\`\\+[0-9]+\\'" arg)
|
|
684 (setq line (string-to-int arg)))
|
|
685 ;; "- file" means don't treat "file" as a switch
|
|
686 ;; ("+0 file" has the same effect; "-" added
|
|
687 ;; for unixoidiality).
|
|
688 ;; This is worthless; the `unixoid' way is "./file". -jwz
|
|
689 ((or (string= arg "-") (string= arg "--"))
|
|
690 (setq end-of-options t))
|
|
691 (t
|
|
692 (setq file-p t)))
|
|
693
|
|
694 (when file-p
|
|
695 (setq file-p nil)
|
|
696 (incf file-count)
|
|
697 (setq arg (expand-file-name arg dir))
|
|
698 (cond
|
|
699 ((= file-count 1) (setq first-file-buffer
|
|
700 (progn (find-file arg) (current-buffer))))
|
|
701 (noninteractive (find-file arg))
|
|
702 (t (find-file-other-window arg)))
|
|
703 (when line
|
|
704 (goto-line line)
|
|
705 (setq line nil))))
|
0
|
706 ;; If 3 or more files visited, and not all visible,
|
|
707 ;; show user what they all are.
|
70
|
708 (when (and (not noninteractive)
|
|
709 (> file-count 2)
|
|
710 (not (get-buffer-window first-file-buffer)))
|
|
711 (other-window 1)
|
|
712 (buffer-menu nil)))))
|
0
|
713
|
|
714 (defvar startup-presentation-hack-keymap
|
|
715 (let ((map (make-sparse-keymap)))
|
|
716 (set-keymap-name map 'startup-presentation-hack-keymap)
|
|
717 (define-key map '[button1] 'startup-presentation-hack)
|
|
718 (define-key map '[button2] 'startup-presentation-hack)
|
|
719 map)
|
|
720 "Putting yesterday in the future tomorrow.")
|
|
721
|
|
722 (defun startup-presentation-hack ()
|
|
723 (interactive)
|
|
724 (let ((e last-command-event))
|
|
725 (and (button-press-event-p e)
|
|
726 (setq e (extent-at (event-point e)
|
|
727 (event-buffer e)
|
|
728 'startup-presentation-hack))
|
|
729 (setq e (extent-property e 'startup-presentation-hack))
|
|
730 (if (consp e)
|
|
731 (apply (car e) (cdr e))
|
70
|
732 (while (keymapp (indirect-function e))
|
|
733 (let ((map e)
|
|
734 (overriding-local-map (indirect-function e)))
|
|
735 (setq e (read-key-sequence
|
|
736 (let ((p (keymap-prompt map t)))
|
|
737 (cond ((symbolp map)
|
|
738 (if p
|
|
739 (format "%s %s " map p)
|
|
740 (format "%s " map)))
|
|
741 (p)
|
|
742 (t
|
|
743 (prin1-to-string map))))))
|
|
744 (if (and (button-release-event-p (elt e 0))
|
|
745 (null (key-binding e)))
|
|
746 (setq e map) ; try again
|
|
747 (setq e (key-binding e)))))
|
|
748 (call-interactively e)))))
|
0
|
749
|
|
750 (defun startup-presentation-hack-help (e)
|
|
751 (setq e (extent-property e 'startup-presentation-hack))
|
|
752 (if (consp e)
|
|
753 (format "Evaluate %S" e)
|
70
|
754 (symbol-name e)))
|
0
|
755
|
|
756 (defun splash-frame-present-hack (e v)
|
70
|
757 ;; (set-extent-property e 'mouse-face 'highlight)
|
|
758 ;; (set-extent-property e 'keymap
|
|
759 ;; startup-presentation-hack-keymap)
|
|
760 ;; (set-extent-property e 'startup-presentation-hack v)
|
|
761 ;; (set-extent-property e 'help-echo
|
|
762 ;; 'startup-presentation-hack-help))
|
0
|
763 )
|
|
764
|
108
|
765 (defun splash-hack-version-string ()
|
|
766 (save-excursion
|
|
767 (save-restriction
|
|
768 (goto-char (point-min))
|
|
769 (re-search-forward "^XEmacs" nil t)
|
|
770 (narrow-to-region (point-at-bol) (point-at-eol))
|
|
771 (goto-char (point-min))
|
|
772 (when (re-search-forward " \\[Lucid\\]" nil t)
|
|
773 (delete-region (match-beginning 0) (match-end 0)))
|
|
774 (when (re-search-forward "[^(].*-.*-" nil t)
|
|
775 (delete-region (1+ (match-beginning 0)) (match-end 0))
|
|
776 (insert "("))
|
|
777 (goto-char (point-max))
|
|
778 (search-backward " " nil t)
|
|
779 (when (search-forward "." nil t)
|
|
780 (delete-region (1- (point)) (point-max))))))
|
|
781
|
0
|
782 (defun splash-frame-present (l)
|
|
783 (cond ((stringp l)
|
108
|
784 (insert l)
|
|
785 (splash-hack-version-string))
|
0
|
786 ((eq (car-safe l) 'face)
|
|
787 ;; (face name string)
|
|
788 (let ((p (point)))
|
|
789 (splash-frame-present (elt l 2))
|
|
790 (if (fboundp 'set-extent-face)
|
|
791 (set-extent-face (make-extent p (point))
|
|
792 (elt l 1)))))
|
|
793 ((eq (car-safe l) 'key)
|
|
794 (let* ((c (elt l 1))
|
|
795 (p (point))
|
|
796 (k (where-is-internal c nil t)))
|
|
797 (insert (if k (key-description k)
|
70
|
798 (format "M-x %s" c)))
|
0
|
799 (if (fboundp 'set-extent-face)
|
|
800 (let ((e (make-extent p (point))))
|
|
801 (set-extent-face e 'bold)
|
|
802 (splash-frame-present-hack e c)))))
|
|
803 ((eq (car-safe l) 'funcall)
|
|
804 ;; (funcall (fun . args) string)
|
|
805 (let ((p (point)))
|
|
806 (splash-frame-present (elt l 2))
|
|
807 (if (fboundp 'set-extent-face)
|
|
808 (splash-frame-present-hack (make-extent p (point))
|
70
|
809 (elt l 1)))))
|
0
|
810 ((consp l)
|
|
811 (mapcar 'splash-frame-present l))
|
|
812 (t
|
|
813 (error "WTF!?"))))
|
|
814
|
|
815 (defun startup-center-spaces (glyph)
|
|
816 ;; Return the number of spaces to insert in order to center
|
|
817 ;; the given glyph (may be a string or a pixmap).
|
|
818 ;; Assume spaces are as wide as avg-pixwidth.
|
|
819 ;; Won't be quite right for proportional fonts, but it's the best we can do.
|
|
820 ;; Maybe the new redisplay will export something a glyph-width function.
|
|
821 ;;; #### Yes, there is a glyph-width function but it isn't quite what
|
|
822 ;;; #### this was expecting. Or is it?
|
|
823 ;; (An alternate way to get avg-pixwidth would be to use x-font-properties
|
|
824 ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.)
|
|
825
|
|
826 ;; This function is used in about.el too.
|
|
827 (let* ((avg-pixwidth (round (/ (frame-pixel-width) (frame-width))))
|
|
828 (fill-area-width (* avg-pixwidth (- fill-column left-margin)))
|
|
829 (glyph-pixwidth (cond ((stringp glyph)
|
|
830 (* avg-pixwidth (length glyph)))
|
|
831 ;; #### the pixmap option should be removed
|
|
832 ;;((pixmapp glyph)
|
|
833 ;; (pixmap-width glyph))
|
|
834 ((glyphp glyph)
|
|
835 (glyph-width glyph))
|
|
836 (t
|
|
837 (error "startup-center-spaces: bad arg")))))
|
|
838 (+ left-margin
|
|
839 (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth)))))
|
|
840
|
2
|
841 (defun startup-splash-frame-body ()
|
|
842 `("\n" ,(emacs-version) "\n"
|
108
|
843 ,@(if (string-match "beta" emacs-version)
|
|
844 `( (face (bold blue) ( "This is an Experimental version of XEmacs. "
|
|
845 " Type " (key describe-beta)
|
|
846 " to see what this means.\n")))
|
|
847 `( "\n"))
|
2
|
848 (face bold-italic "\
|
108
|
849 Copyright (C) 1985-1997 Free Software Foundation, Inc.
|
0
|
850 Copyright (C) 1990-1994 Lucid, Inc.
|
108
|
851 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved.
|
0
|
852 Copyright (C) 1994-1996 Board of Trustees, University of Illinois
|
2
|
853 Copyright (C) 1995-1996 Ben Wing\n\n")
|
|
854
|
|
855 ,@(if (featurep 'sparcworks)
|
|
856 `( "\
|
|
857 Sun provides support for the WorkShop/XEmacs integration package only.
|
|
858 All other XEmacs packages are provided to you \"AS IS\".
|
|
859 For full details, type " (key describe-no-warranty)
|
|
860 " to refer to the GPL Version 2, dated June 1991.\n\n"
|
70
|
861 ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") (getenv "LANG"))))
|
2
|
862 (if (and
|
|
863 (not (featurep 'mule)) ; Already got mule?
|
|
864 (not (eq 'tty (console-type))) ; No Mule support on tty's yet
|
|
865 lang ; Non-English locale?
|
70
|
866 (not (string= lang "C"))
|
2
|
867 (not (string-match "^en" lang))
|
|
868 (locate-file "xemacs-mule" exec-path)) ; Comes with Sun WorkShop
|
|
869 '( "\
|
|
870 This version of XEmacs has been built with support for Latin-1 languages only.
|
|
871 To handle other languages you need to run a Multi-lingual (`Mule') version of
|
|
872 XEmacs, by either running the command `xemacs-mule', or by using the X resource
|
|
873 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop.\n\n"))))
|
0
|
874
|
2
|
875 '("XEmacs comes with ABSOLUTELY NO WARRANTY; type "
|
|
876 (key describe-no-warranty) " for full details.\n"))
|
|
877
|
|
878 "You may give out copies of XEmacs; type "
|
|
879 (key describe-copying) " to see the conditions.\n"
|
|
880 "Type " (key describe-distribution)
|
|
881 " for information on getting the latest version.\n\n"
|
|
882
|
|
883 "Type " (key help-command) " or use the " (face bold "Help") " menu to get help.\n"
|
|
884 "Type " (key advertised-undo) " to undo changes (`C-' means use the Control key).\n"
|
|
885 "To get out of XEmacs, type " (key save-buffers-kill-emacs) ".\n"
|
|
886 "Type " (key help-with-tutorial) " for a tutorial on using XEmacs.\n"
|
|
887 "Type " (key info) " to enter Info, "
|
110
|
888 "which you can use to read online documentation.\n"
|
2
|
889 (face (bold red) ( "\
|
|
890 For tips and answers to frequently asked questions, see the XEmacs FAQ.
|
|
891 \(It's on the Help menu, or type " (key xemacs-local-faq) " [a capital F!].\)"))))
|
|
892
|
|
893 (defun startup-splash-frame ()
|
|
894 (let ((p (point))
|
|
895 (cramped-p (eq 'tty (console-type))))
|
|
896 (unless cramped-p (insert "\n"))
|
|
897 (indent-to (startup-center-spaces xemacs-logo))
|
|
898 (set-extent-begin-glyph (make-extent (point) (point)) xemacs-logo)
|
|
899 (insert (if cramped-p "\n" "\n\n"))
|
|
900 (splash-frame-present-hack (make-extent p (point)) 'about-xemacs))
|
|
901
|
70
|
902 (let ((after-change-functions nil)) ; no font-lock, thank you
|
2
|
903 (dolist (l (startup-splash-frame-body))
|
|
904 (splash-frame-present l)))
|
|
905 (set-buffer-modified-p nil))
|
|
906
|
70
|
907 ;; (let ((present-file
|
|
908 ;; #'(lambda (f)
|
|
909 ;; (splash-frame-present
|
|
910 ;; (list 'funcall
|
|
911 ;; (list 'find-file-other-window
|
|
912 ;; (expand-file-name f data-directory))
|
|
913 ;; f)))))
|
|
914 ;; (insert "For customization examples, see the files ")
|
|
915 ;; (funcall present-file "sample.emacs")
|
|
916 ;; (insert " and ")
|
|
917 ;; (funcall present-file "sample.Xdefaults")
|
|
918 ;; (insert (format "\nin the directory %s." data-directory)))
|
2
|
919
|
0
|
920
|
|
921 ;;;; Computing the default load-path, etc.
|
|
922 ;;;
|
|
923 ;;; This stuff is a complete mess and isn't nearly as general as it
|
|
924 ;;; thinks it is. It should be rethunk. In particular, too much logic
|
|
925 ;;; is duplicated between the code that looks around for the various
|
|
926 ;;; directories, and the code which suggests where to create the various
|
|
927 ;;; directories once it decides they are missing.
|
|
928
|
|
929 ;;; The source directory has this layout:
|
|
930 ;;;
|
|
931 ;;; BUILD_ROOT/src/xemacs* argv[0]
|
|
932 ;;; BUILD_ROOT/xemacs* argv[0], possibly
|
|
933 ;;; BUILD_ROOT/lisp/
|
|
934 ;;; BUILD_ROOT/etc/ data-directory
|
|
935 ;;; BUILD_ROOT/info/
|
|
936 ;;; BUILD_ROOT/lib-src/ exec-directory, doc-directory
|
|
937 ;;; BUILD_ROOT/lock/
|
|
938 ;;;
|
|
939 ;;; The default tree created by "make install" has this layout:
|
|
940 ;;;
|
|
941 ;;; PREFIX/bin/xemacs* argv[0]
|
|
942 ;;; PREFIX/lib/xemacs-VERSION/lisp/
|
|
943 ;;; PREFIX/lib/xemacs-VERSION/etc/ data-directory
|
|
944 ;;; PREFIX/lib/xemacs-VERSION/info/
|
|
945 ;;; PREFIX/lib/xemacs-VERSION/CONFIGURATION/ exec-directory, doc-directory
|
|
946 ;;; PREFIX/lib/xemacs/lock/
|
|
947 ;;; PREFIX/lib/xemacs/site-lisp/
|
|
948 ;;;
|
|
949 ;;; The binary packages we ship have that layout, except that argv[0] has
|
|
950 ;;; been moved one level deeper under the bin directory:
|
|
951 ;;;
|
|
952 ;;; PREFIX/bin/CONFIGURATION/xemacs*
|
|
953 ;;;
|
|
954 ;;; The following code has to deal with at least the above three situations,
|
|
955 ;;; and it should be possible for it to deal with more. Though perhaps that
|
|
956 ;;; does cover it all? The trick is, when something is missing, realizing
|
|
957 ;;; which of those three layouts is mostly in place, so that we can suggest
|
|
958 ;;; the right directories in the error message.
|
|
959
|
|
960
|
|
961 ;; extremely low-tech debugging, since this happens so early in startup.
|
70
|
962 ;;(or (fboundp 'orig-file-directory-p)
|
|
963 ;; (fset 'orig-file-directory-p (symbol-function 'file-directory-p)))
|
|
964 ;;(defun file-directory-p (path)
|
|
965 ;; (send-string-to-terminal (format "PROBING %S" path))
|
|
966 ;; (let ((v (orig-file-directory-p path)))
|
|
967 ;; (send-string-to-terminal (format " -> %S\n" v))
|
|
968 ;; v))
|
0
|
969
|
|
970 (defun startup-make-version-dir ()
|
|
971 (let ((version (and (string-match "\\`[^0-9]*\\([0-9]+\\.[0-9]+\\)"
|
|
972 emacs-version)
|
|
973 (substring emacs-version
|
|
974 (match-beginning 1) (match-end 1)))))
|
|
975 (if (string-match "(beta *\\([0-9]+\\))" emacs-version)
|
|
976 (setq version (concat version "-b"
|
|
977 (substring emacs-version (match-beginning 1)
|
|
978 (match-end 1)))))
|
|
979 (if (string-match "(alpha *\\([0-9]+\\))" emacs-version)
|
|
980 (setq version (concat version "-a"
|
|
981 (substring emacs-version (match-beginning 1)
|
|
982 (match-end 1)))))
|
|
983 (concat "lib/xemacs-" version)))
|
|
984
|
|
985 (defun find-emacs-root-internal-1 (path lisp-p)
|
|
986 (let ((dir (file-name-directory path)))
|
|
987 (or
|
|
988 ;;
|
|
989 ;; If this directory is a plausible root of the XEmacs tree, return it.
|
|
990 ;;
|
|
991 (and (or (not lisp-p)
|
|
992 (file-directory-p (expand-file-name "lisp/prim" dir)))
|
|
993 (or (file-directory-p (expand-file-name "lib-src" dir))
|
|
994 (file-directory-p (expand-file-name system-configuration dir)))
|
|
995 dir)
|
|
996 ;;
|
|
997 ;; If the parent of this directory is a plausible root, use it.
|
|
998 ;; (But don't do so recursively!)
|
|
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
|
|
1003 (format "../%s" system-configuration)
|
|
1004 dir))
|
|
1005 (file-directory-p (expand-file-name "../lib-src" dir)))
|
|
1006 (expand-file-name "../" dir))
|
|
1007
|
|
1008 ;;
|
|
1009 ;; (--run-in-place) Same thing, but from one directory level deeper.
|
|
1010 ;;
|
|
1011 (and (or (not lisp-p)
|
|
1012 (file-directory-p (expand-file-name "../../lisp/prim" dir)))
|
|
1013 (or (file-directory-p (expand-file-name
|
|
1014 (format "../%s" system-configuration)
|
|
1015 dir))
|
|
1016 (file-directory-p
|
|
1017 (expand-file-name
|
|
1018 (format "../../lib-src/%s" system-configuration) dir)))
|
|
1019 (expand-file-name "../.." dir))
|
|
1020
|
|
1021 ;; If ../lib/xemacs-<version> exists check it.
|
|
1022 ;; This is of the form "xemacs-19.10/" or "xemacs-19.10-b7/".
|
|
1023 ;;
|
|
1024 (let ((ver-dir (concat "../" (startup-make-version-dir))))
|
|
1025 (and (or (not lisp-p)
|
|
1026 (file-directory-p (expand-file-name
|
|
1027 (format "%s/lisp/prim" ver-dir)
|
|
1028 dir)))
|
|
1029 (or (file-directory-p (expand-file-name
|
|
1030 (format "%s/%s" ver-dir
|
|
1031 system-configuration)
|
|
1032 dir))
|
|
1033 (file-directory-p (expand-file-name
|
|
1034 (format "%s/lib-src" ver-dir)
|
|
1035 dir)))
|
|
1036 (expand-file-name (file-name-as-directory ver-dir) dir)))
|
|
1037 ;;
|
|
1038 ;; Same thing, but one higher: ../../lib/xemacs-<version>.
|
|
1039 ;;
|
|
1040 (let ((ver-dir (concat "../../" (startup-make-version-dir))))
|
|
1041 (and (or (not lisp-p)
|
|
1042 (file-directory-p (expand-file-name
|
|
1043 (format "%s/lisp/prim" ver-dir)
|
|
1044 dir)))
|
|
1045 (or (file-directory-p (expand-file-name
|
|
1046 (format "%s/%s" ver-dir
|
|
1047 system-configuration)
|
|
1048 dir))
|
|
1049 (file-directory-p (expand-file-name
|
|
1050 (format "%s/lib-src" ver-dir)
|
|
1051 dir)))
|
|
1052 (expand-file-name (file-name-as-directory ver-dir) dir)))
|
|
1053 ;;
|
|
1054 ;; If that doesn't work, and the XEmacs executable is a symlink, then
|
|
1055 ;; chase the link and try again there.
|
|
1056 ;;
|
|
1057 (and (setq path (file-symlink-p path))
|
|
1058 (find-emacs-root-internal-1 (expand-file-name path dir) lisp-p))
|
|
1059 ;;
|
|
1060 ;; Otherwise, this directory just doesn't cut it.
|
|
1061 ;; Some bozos think they can use the 18.59 lisp directory with 19.*.
|
|
1062 ;; This is because they're not using their brains. But it might be
|
|
1063 ;; nice to notice that that is happening and point them in the
|
|
1064 ;; general direction of a clue.
|
|
1065 ;;
|
|
1066 nil)))
|
|
1067
|
|
1068 (defun find-emacs-root-internal (path)
|
70
|
1069 ;; (send-string-to-terminal (format "FINDING ROOT FOR %S\n" path))
|
0
|
1070 ;; first look for lisp/prim and lib-src; then just look for lib-src.
|
|
1071 ;; XEmacs can run (kind of) if the lisp directory is omitted, which
|
|
1072 ;; some people might want to do for space reasons.
|
|
1073 (or (find-emacs-root-internal-1 path t)
|
|
1074 (find-emacs-root-internal-1 path nil)
|
|
1075 ;; If we don't succeed we are going to crash and burn for sure.
|
|
1076 ;; Try some paths relative to prefix-directory if it isn't nil.
|
|
1077 ;; This is definitely necessary in cases such as when we're used
|
|
1078 ;; as a login shell since we can't determine the invocation
|
|
1079 ;; directory in that case.
|
|
1080 (find-emacs-root-internal-1
|
|
1081 (format "%s/bin/%s" prefix-directory invocation-name) t)
|
|
1082 (find-emacs-root-internal-1
|
|
1083 (format "%s/bin/%s" prefix-directory invocation-name) nil)
|
|
1084 (find-emacs-root-internal-1
|
|
1085 (format "%s/lib/%s" prefix-directory invocation-name) t)
|
|
1086 (find-emacs-root-internal-1
|
|
1087 (format "%s/lib/%s" prefix-directory invocation-name) nil)
|
|
1088 ))
|
|
1089
|
|
1090 (defun set-default-load-path ()
|
|
1091 ;; XEmacs -- Steven Baur says invocation directory is nil if you
|
|
1092 ;; try to use XEmacs as a login shell.
|
|
1093 (or invocation-directory (setq invocation-directory default-directory))
|
|
1094 (setq invocation-directory
|
|
1095 ;; don't let /tmp_mnt/... get into the load-path or exec-path.
|
|
1096 (abbreviate-file-name invocation-directory))
|
|
1097
|
|
1098 ;; #### FSFmacs recognizes environment vars EMACSLOCKDIR, etc.
|
|
1099 (let* ((root (find-emacs-root-internal (concat invocation-directory
|
|
1100 invocation-name)))
|
|
1101 (lisp (and root
|
|
1102 (let ((f (expand-file-name "lisp" root)))
|
|
1103 (and (file-directory-p f) f))))
|
70
|
1104 (site-lisp
|
|
1105 (and root
|
|
1106 (or
|
|
1107 (let ((f (expand-file-name "xemacs/site-lisp" root)))
|
|
1108 (and (file-directory-p f) f))
|
|
1109 (let ((f (expand-file-name "../xemacs/site-lisp" root)))
|
|
1110 (and (file-directory-p f) f))
|
|
1111 ;; the next two are for --run-in-place
|
|
1112 (let ((f (expand-file-name "site-lisp" root)))
|
|
1113 (and (file-directory-p f) f))
|
|
1114 (let ((f (expand-file-name "lisp/site-lisp" root)))
|
|
1115 (and (file-directory-p f) f))
|
|
1116 )))
|
|
1117 (lib-src
|
|
1118 (and root
|
|
1119 (or
|
|
1120 (let ((f (expand-file-name
|
|
1121 (concat "lib-src/" system-configuration)
|
|
1122 root)))
|
|
1123 (and (file-directory-p f) f))
|
|
1124 (let ((f (expand-file-name "lib-src" root)))
|
|
1125 (and (file-directory-p f) f))
|
|
1126 (let ((f (expand-file-name system-configuration root)))
|
|
1127 (and (file-directory-p f) f)))))
|
|
1128 (etc
|
|
1129 (and root
|
|
1130 (let ((f (expand-file-name "etc" root)))
|
|
1131 (and (file-directory-p f) f))))
|
|
1132 (info
|
|
1133 (and root
|
|
1134 (let ((f (expand-file-name "info" root)))
|
|
1135 (and (file-directory-p f) (file-name-as-directory f)))))
|
|
1136 (lock
|
|
1137 (and root
|
|
1138 (boundp 'lock-directory)
|
|
1139 (if (and lock-directory (file-directory-p lock-directory))
|
|
1140 (file-name-as-directory lock-directory)
|
|
1141 (or
|
|
1142 (let ((f (expand-file-name "xemacs/lock" root)))
|
|
1143 (and (file-directory-p f)
|
|
1144 (file-name-as-directory f)))
|
|
1145 (let ((f (expand-file-name "../xemacs/lock" root)))
|
|
1146 (and (file-directory-p f)
|
|
1147 (file-name-as-directory f)))
|
|
1148 (let ((f (expand-file-name "lock" root)))
|
|
1149 (and (file-directory-p f)
|
|
1150 (file-name-as-directory f)))
|
|
1151 ;; if none of them exist, make the "guess" be
|
|
1152 ;; the one that set-default-load-path-warning
|
|
1153 ;; will suggest.
|
|
1154 (file-name-as-directory
|
|
1155 (expand-file-name "../xemacs/lock" root))
|
|
1156 )))))
|
72
|
1157
|
|
1158 ;; 1996/12/6 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
1159 ;; define `default-load-path' for file-detect.el
|
|
1160 (setq default-load-path load-path)
|
|
1161
|
0
|
1162 ;; add site-lisp dir to load-path
|
70
|
1163 (when site-lisp
|
|
1164 ;; If the site-lisp dir isn't on the load-path, add it to the end.
|
|
1165 (or (member site-lisp load-path)
|
|
1166 (setq load-path (append load-path (list site-lisp))))
|
|
1167 ;; Also add any direct subdirectories of the site-lisp directory
|
|
1168 ;; to the load-path. But don't add dirs whose names begin
|
|
1169 ;; with dot or hyphen.
|
|
1170 (let ((files (directory-files site-lisp nil "^[^-.]" nil 'dirs-only))
|
|
1171 file)
|
|
1172 (while files
|
|
1173 (setq file (car files))
|
|
1174 (if (and (not (member file '("RCS" "CVS" "SCCS")))
|
|
1175 (setq file (expand-file-name file site-lisp))
|
|
1176 (not (member file load-path)))
|
|
1177 (setq load-path
|
|
1178 (nconc load-path
|
|
1179 (list (file-name-as-directory file)))))
|
|
1180 (setq files (cdr files)))))
|
|
1181
|
0
|
1182 ;; add lisp dir to load-path
|
70
|
1183 (when lisp
|
|
1184 ;; If the lisp dir isn't on the load-path, add it to the end.
|
|
1185 (or (member lisp load-path)
|
|
1186 (setq load-path (append load-path (list lisp))))
|
|
1187 ;; Also add any direct subdirectories of the lisp directory
|
|
1188 ;; to the load-path. But don't add dirs whose names begin
|
|
1189 ;; with dot or hyphen.
|
|
1190 (let ((files (directory-files lisp nil "^[^-.]" nil 'dirs-only))
|
|
1191 file)
|
|
1192 (while files
|
|
1193 (setq file (car files))
|
|
1194 (when (and (not (member file '("RCS" "CVS" "SCCS")))
|
|
1195 (setq file (expand-file-name file lisp))
|
|
1196 (not (member file load-path)))
|
|
1197 (setq load-path
|
|
1198 (nconc load-path
|
|
1199 (list (file-name-as-directory file)))))
|
|
1200 (setq files (cdr files)))))
|
32
|
1201
|
72
|
1202 ;; 1996/12/6 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
1203 ;; define `default-load-path' for file-detect.el
|
|
1204 (setq default-load-path
|
|
1205 (append default-load-path
|
|
1206 (if site-lisp
|
|
1207 (list site-lisp))
|
|
1208 (if lisp
|
|
1209 (list lisp)
|
|
1210 )
|
|
1211 ))
|
|
1212
|
110
|
1213 ;; 1997/03/06 by Jeff Miller <jmiller@bayserve.net>
|
|
1214 ;; initialize 'site-directory'. This is the site-lisp dir used by
|
|
1215 ;; XEmacs
|
|
1216 (if site-lisp
|
|
1217 (setq site-directory (file-name-as-directory site-lisp))
|
|
1218 )
|
0
|
1219 ;; If running from the build directory, always prefer the exec-directory
|
70
|
1220 ;; that is here over to the one that came from paths.h.
|
|
1221 (when (or (and (null exec-directory) lib-src)
|
|
1222 (and (string= lib-src (expand-file-name "lib-src" root))
|
|
1223 (not (string= exec-directory lib-src))))
|
|
1224 (setq exec-directory (file-name-as-directory lib-src)))
|
|
1225 (when (or (and (null doc-directory) lib-src)
|
|
1226 (and (string= lib-src (expand-file-name "lib-src" root))
|
|
1227 (not (string= doc-directory lib-src))))
|
|
1228 (setq doc-directory (file-name-as-directory lib-src)))
|
0
|
1229
|
70
|
1230 (when exec-directory
|
|
1231 (or (member exec-directory exec-path)
|
|
1232 (setq exec-path (append exec-path (list exec-directory)))))
|
|
1233 (when (or (and (null data-directory) etc)
|
|
1234 (and (string= etc (expand-file-name "etc" root))
|
|
1235 (not (string= data-directory etc))))
|
|
1236 (setq data-directory (file-name-as-directory etc)))
|
0
|
1237
|
|
1238
|
|
1239
|
|
1240 ;; If `configure' specified an info dir, use it.
|
|
1241 (or (boundp 'Info-default-directory-list)
|
|
1242 (setq Info-default-directory-list nil))
|
|
1243 (cond (configure-info-directory
|
|
1244 (setq configure-info-directory (file-name-as-directory
|
|
1245 configure-info-directory))
|
|
1246 (or (member configure-info-directory Info-default-directory-list)
|
|
1247 (setq Info-default-directory-list
|
|
1248 (append Info-default-directory-list
|
|
1249 (list configure-info-directory))))))
|
|
1250 ;; If we've guessed the info dir, use that (too).
|
70
|
1251 (when (and info (not (member info Info-default-directory-list)))
|
|
1252 (setq Info-default-directory-list
|
|
1253 (append Info-default-directory-list (list info))))
|
0
|
1254
|
|
1255 ;; Default the lock dir to being a sibling of the data-directory.
|
|
1256 ;; If superlock isn't set, or is set to a file in a nonexistent
|
|
1257 ;; directory, derive it from the lock dir.
|
70
|
1258 (when (boundp 'lock-directory)
|
|
1259 (setq lock-directory lock)
|
|
1260 (cond ((null lock-directory)
|
|
1261 (setq superlock-file nil))
|
|
1262 ((or (null superlock-file)
|
|
1263 (not (file-directory-p
|
|
1264 (file-name-directory superlock-file))))
|
|
1265 (setq superlock-file
|
|
1266 (expand-file-name "!!!SuperLock!!!"
|
|
1267 lock-directory)))))
|
0
|
1268
|
|
1269 (set-default-load-path-warning)))
|
|
1270
|
|
1271
|
|
1272 (defun set-default-load-path-warning ()
|
|
1273 (let ((lock (if (boundp 'lock-directory) lock-directory 't))
|
|
1274 warnings message guess)
|
70
|
1275 (when (and (stringp lock) (not (file-directory-p lock)))
|
|
1276 (setq lock nil))
|
0
|
1277 (cond
|
|
1278 ((not (and exec-directory data-directory doc-directory load-path lock))
|
|
1279 (save-excursion
|
|
1280 (set-buffer (get-buffer-create " *warning-tmp*"))
|
|
1281 (erase-buffer)
|
|
1282 (buffer-disable-undo (current-buffer))
|
70
|
1283 (when (null lock) (push "lock-directory" warnings))
|
|
1284 (when (null exec-directory) (push "exec-directory" warnings))
|
|
1285 (when (null data-directory) (push "data-directory" warnings))
|
|
1286 (when (null doc-directory) (push "doc-directory" warnings))
|
|
1287 (when (null load-path) (push "load-path" warnings))
|
0
|
1288 (cond ((cdr (cdr warnings))
|
|
1289 (setq message (apply 'format "%s, %s, and %s" warnings)))
|
|
1290 ((cdr warnings)
|
|
1291 (setq message (apply 'format "%s and %s" warnings)))
|
|
1292 (t (setq message (format "variable %s" (car warnings)))))
|
|
1293 (insert "couldn't find an obvious default for " message
|
|
1294 ", and there were no defaults specified in paths.h when "
|
|
1295 "XEmacs was built. Perhaps some directories don't exist, "
|
|
1296 "or the XEmacs executable, " (concat invocation-directory
|
|
1297 invocation-name)
|
|
1298 " is in a strange place?")
|
|
1299 (setq guess (or exec-directory
|
|
1300 data-directory
|
|
1301 doc-directory
|
|
1302 (car load-path)
|
|
1303 (and (string-match "/[^/]+\\'" invocation-directory)
|
|
1304 (substring invocation-directory 0
|
|
1305 (match-beginning 0)))))
|
70
|
1306 (when (and guess
|
|
1307 (or
|
|
1308 ;; parent of a terminal bin/<configuration> pair (hack hack).
|
|
1309 (string-match (concat "/bin/"
|
|
1310 (regexp-quote system-configuration)
|
|
1311 "/?\\'")
|
|
1312 guess)
|
|
1313 ;; parent of terminal src, lib-src, etc, or lisp dir.
|
|
1314 (string-match
|
|
1315 "/\\(bin\\|src\\|lib-src\\|etc\\|lisp\\)[^/]*/?\\'"
|
|
1316 guess)))
|
|
1317 (setq guess (substring guess 0 (match-beginning 0))))
|
0
|
1318
|
|
1319 ;; If neither the exec nor lisp dirs are around, then "guess" that
|
|
1320 ;; the new configure-style lib dir should be used. Otherwise, if
|
|
1321 ;; only one of them appears to be missing, or it's just lock,
|
|
1322 ;; then guess it to be a sibling of whatever already exists.
|
70
|
1323 (when (and (null exec-directory) (null load-path))
|
|
1324 (setq guess (expand-file-name (startup-make-version-dir) guess)))
|
0
|
1325
|
70
|
1326 (when (or (null exec-directory) (null load-path))
|
|
1327 (insert
|
|
1328 "\n\nWithout both exec-directory and load-path, XEmacs will "
|
|
1329 "be very broken. "))
|
|
1330 (when (and (null exec-directory) guess)
|
|
1331 (insert
|
|
1332 "Consider making a symbolic link from "
|
|
1333 (expand-file-name system-configuration guess)
|
|
1334 " to wherever the appropriate XEmacs exec-directory "
|
|
1335 "directory is"))
|
|
1336 (when (and (null data-directory) guess)
|
|
1337 (insert
|
|
1338 (if exec-directory
|
|
1339 "\n\nConsider making a symbolic link " ", and ")
|
|
1340 "from "
|
|
1341 (expand-file-name "etc" (if load-path
|
|
1342 (file-name-directory
|
|
1343 (directory-file-name
|
|
1344 (car load-path)))
|
|
1345 guess))
|
|
1346 " to wherever the appropriate XEmacs data-directory is"))
|
|
1347 (when (and (null load-path) guess)
|
|
1348 (insert
|
|
1349 (if (and exec-directory data-directory)
|
|
1350 "Consider making a symbolic link "
|
|
1351 ", and ")
|
|
1352 "from "
|
|
1353 (expand-file-name "lisp" guess)
|
|
1354 " to wherever the appropriate XEmacs lisp library is"))
|
0
|
1355 (insert ".")
|
|
1356
|
70
|
1357 (when (null lock)
|
|
1358 (insert
|
|
1359 "\n\nWithout lock-directory set, file locking won't work. ")
|
|
1360 (when guess
|
|
1361 (insert
|
|
1362 "Consider creating "
|
|
1363 (expand-file-name "../xemacs/lock"
|
|
1364 (or (find-emacs-root-internal
|
|
1365 (concat invocation-directory
|
|
1366 invocation-name))
|
|
1367 guess))
|
|
1368 " as a directory or symbolic link for use as the lock "
|
|
1369 "directory. (This directory must be globally writable.)"
|
|
1370 )))
|
0
|
1371
|
70
|
1372 (when (fboundp 'fill-region)
|
|
1373 ;; Might not be bound in the cold load environment...
|
|
1374 (let ((fill-column 76))
|
|
1375 (fill-region (point-min) (point-max))))
|
0
|
1376 (goto-char (point-min))
|
|
1377 (princ "\nWARNING:\n" 'external-debugging-output)
|
|
1378 (princ (buffer-string) 'external-debugging-output)
|
|
1379 (erase-buffer)
|
|
1380 t)))))
|
|
1381
|
|
1382 ;;; startup.el ends here
|