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