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