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