Mercurial > hg > xemacs-beta
annotate lisp/startup.el @ 4447:15dd5229cea5
Support windows-1250 on Unix as well as Windows.
2008-05-07 Aidan Kehoe <kehoea@parhasard.net>
* mule/latin.el (windows-1250): Add the Central European Windows
coding system.
* mule/mule-win32-init.el: Don't use the Windows-specific CP1250
implementation, rely on that in latin.el instead.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 07 May 2008 21:06:45 +0200 |
parents | 6b571dc4ba3f |
children | fd8a9a4d81d9 |
rev | line source |
---|---|
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 | |
2505 | 6 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Ben Wing. |
428 | 7 |
8 ;; Maintainer: XEmacs Development Team | |
9 ;; Keywords: internal, dumped | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
13 ;; XEmacs is free software; you can redistribute it and/or modify it | |
14 ;; under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; XEmacs is distributed in the hope that it will be useful, but | |
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 ;; General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
442 | 24 ;; along with XEmacs; see the file COPYING. If not, write to the |
428 | 25 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Synched up with: FSF 19.34. | |
29 | |
30 ;;; Commentary: | |
31 | |
32 ;; This file is dumped with XEmacs. | |
33 | |
502 | 34 ;; It handles the all aspects of startup once the C code has finished |
35 ;; initializing itself. Entry from C is through the function set in | |
36 ;; the `top-level' variable, which is normally `normal-top-level'. At | |
37 ;; the point that `normal-top-level' has been invoked: | |
38 ;; | |
39 ;; (1) the dumped Elisp files are available. Either they were loaded | |
40 ;; during this invocation of temacs and it was then converted to | |
41 ;; XEmacs using the run-temacs mechanism, or (more likely) the | |
42 ;; loadup and dumping occurred at some point in the past and we | |
43 ;; just read in the dumped data. | |
44 ;; | |
45 ;; (2) All C subsystems have been initialized. | |
46 ;; | |
47 ;; (3) A "stream" device has been created, which does I/O over stdin | |
48 ;; and stdout. This is the only device we have available and our | |
49 ;; only means of communication, other than disk files. | |
50 ;; | |
51 ;; (4) The command-line arguments have been sorted according to | |
52 ;; priority specs (this implies that the names of all arguments | |
53 ;; must be hard-coded into emacs.c), and certain low-level | |
54 ;; arguments such as -sd, -t, -nd, -nw, -batch, etc. have been | |
55 ;; processed by main_1() and removed. (NOTE: main_1() is the name | |
56 ;; in the source code, but in the object file it has some other | |
57 ;; name, such as xemacs_21_2_34_mips_sgi_irix6().) Certain other | |
58 ;; arguments such as -version and -help are partially-processed, | |
59 ;; triggering some special behavior but being left on the list for | |
60 ;; further processing by the Lisp code. | |
61 ;; | |
62 ;; The job of the code here is to process the remaining command-line | |
63 ;; args, set up the various paths, locate where all the packages are | |
64 ;; and set things up for them (initialize the load path, read in the | |
65 ;; autoloads, etc.), read in the init files, display the splash | |
66 ;; screen, and set up any remaining environment-dependent variables. | |
428 | 67 |
68 ;;; Code: | |
69 | |
70 (setq top-level '(normal-top-level)) | |
71 | |
72 (defvar command-line-processed nil "t once command line has been processed") | |
73 | |
74 (defconst startup-message-timeout 12000) ; More or less disable the timeout | |
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.") | |
2456 | 131 |
132 ;;; Path-related variables. | |
133 ;;; NOTE: Many of them (`lisp-directory', `data-directory', etc.) are | |
134 ;;; built-in. | |
428 | 135 |
2456 | 136 (defvar emacs-roots nil |
137 "List of plausible roots of the XEmacs hierarchy. | |
138 This is a list of plausible directories in which to search for the important | |
139 directories used by XEmacs at run-time, for example `exec-directory', | |
140 `data-directory' and `lisp-directory'. | |
141 | |
142 Normally set at startup by calling `paths-find-emacs-roots'.") | |
143 | |
144 (defvar emacs-data-roots nil | |
145 "List of plausible data roots of the XEmacs hierarchy.") | |
146 | |
147 (defvar user-init-directory-base ".xemacs" | |
148 "Base of directory where user-installed init files may go.") | |
149 | |
150 (defvar user-init-directory | |
151 (file-name-as-directory | |
152 (paths-construct-path (list "~" user-init-directory-base))) | |
153 "Directory where user-installed init files may go.") | |
154 | |
155 (defvar user-init-file-base "init.el" | |
156 "Default name of the user init file if uncompiled. | |
157 This should be used for migration purposes only.") | |
158 | |
159 (defvar user-init-file-base-list '("init.el") | |
160 "List of allowed init files in the user's init directory. | |
161 The first one found takes precedence. .elc files do not need to be listed.") | |
162 | |
163 (defvar user-home-init-file-base-list | |
164 (append '(".emacs.el" ".emacs") | |
165 (and (eq system-type 'windows-nt) | |
166 '("_emacs.el" "_emacs"))) | |
167 "List of allowed init files in the user's home directory. | |
168 The first one found takes precedence. .elc files do not need to be listed.") | |
169 | |
170 (defvar load-home-init-file nil | |
171 "Non-nil if XEmacs should load the init file from the home directory. | |
172 Otherwise, XEmacs will offer migration to the init directory.") | |
173 | |
174 (defvar load-user-init-file-p t | |
175 "Non-nil if XEmacs should load the user's init file.") | |
176 | |
3360 | 177 ;; #### called `site-run-file' in GNU Emacs |
428 | 178 |
444 | 179 (defvar site-start-file "site-start" |
428 | 180 "File containing site-wide run-time initializations. |
2030 | 181 It is loaded at run-time before the user's init file (see `user-init-file'). |
182 It contains inits that need to be in place for the entire site, but | |
428 | 183 which, due to their higher incidence of change, don't make sense to |
2030 | 184 load into XEmacs's dumped image. Thus, the run-time load order is: |
428 | 185 |
186 1. file described in this variable, if non-nil; | |
2030 | 187 2. the file computed by `find-user-init-file'; |
428 | 188 3. `/path/to/xemacs/lisp/default.el'. |
189 | |
190 Don't use the `site-start.el' file for things some users may not like. | |
191 Put them in `default.el' instead, so that users can more easily | |
192 override them. Users can prevent loading `default.el' with the `-q' | |
193 option or by setting `inhibit-default-init' in their own init files, | |
194 but inhibiting `site-start.el' requires `--no-site-file', which | |
195 is less convenient.") | |
196 | |
197 ;;(defconst iso-8859-1-locale-regexp "8859[-_]?1" | |
198 ;; "Regexp that specifies when to enable the ISO 8859-1 character set. | |
199 ;;We do that if this regexp matches the locale name | |
200 ;;specified by the LC_ALL, LC_CTYPE and LANG environment variables.") | |
201 | |
442 | 202 (defcustom mail-host-address nil |
203 "*Name of this machine, for purposes of naming users." | |
204 :type 'string | |
205 :group 'mail) | |
428 | 206 |
442 | 207 (defcustom user-mail-address nil |
428 | 208 "*Full mailing address of this user. |
209 This is initialized based on `mail-host-address', | |
442 | 210 after your init file is read, in case it sets `mail-host-address'." |
211 :type 'string | |
212 :group 'mail) | |
428 | 213 |
214 (defvar init-file-debug nil) | |
215 | |
216 (defvar init-file-had-error nil) | |
217 | |
218 (defvar init-file-loaded nil | |
219 "True after the user's init file has been loaded (or suppressed with -q). | |
220 This will be true when `after-init-hook' is run and at all times | |
221 after, and will not be true at any time before.") | |
222 | |
223 (defvar initial-frame-unmapped-p nil) | |
224 | |
225 | |
226 | |
227 (defvar command-switch-alist | |
444 | 228 '(("-help" . command-line-do-help) |
771 | 229 ("-version" . command-line-do-version) |
444 | 230 ("-V" . command-line-do-version) |
771 | 231 ("-funcall" . command-line-do-funcall) |
444 | 232 ("-f" . command-line-do-funcall) |
233 ("-e" . command-line-do-funcall-1) | |
234 ("-eval" . command-line-do-eval) | |
235 ("-load" . command-line-do-load) | |
236 ("-l" . command-line-do-load) | |
237 ("-insert" . command-line-do-insert) | |
238 ("-i" . command-line-do-insert) | |
239 ("-kill" . command-line-do-kill) | |
771 | 240 ("-eol" . command-line-do-enable-eol-detection) |
776 | 241 ("-enable-eol-detection" . command-line-do-enable-eol-detection) |
444 | 242 ;; Options like +35 are handled specially. |
243 ;; Window-system, site, or package-specific code might add to this. | |
244 ;; X11 handles its options by letting Xt remove args from this list. | |
245 ) | |
428 | 246 "Alist of command-line switches. |
247 Elements look like (SWITCH-STRING . HANDLER-FUNCTION). | |
248 HANDLER-FUNCTION receives switch name as sole arg; | |
249 remaining command-line args are in the variable `command-line-args-left'.") | |
250 | |
251 ;;; default switches | |
252 ;;; Note: these doc strings are semi-magical. | |
253 | |
254 (defun command-line-do-help (arg) | |
255 "Print the XEmacs usage message and exit." | |
256 (let ((standard-output 'external-debugging-output)) | |
257 (princ (concat "\n" (emacs-version) "\n\n")) | |
258 (princ | |
259 (if (featurep 'x) | |
260 (concat "When creating a window on an X display, " | |
261 (emacs-name) | |
262 " accepts all standard X Toolkit | |
263 command line options plus the following: | |
264 -iconname <title> Use title as the icon name. | |
265 -mc <color> Use color as the mouse color. | |
266 -cr <color> Use color as the text-cursor foregound color. | |
267 -private Install a private colormap. | |
268 | |
269 In addition, the") | |
270 "The")) | |
771 | 271 (let ((l command-switch-alist) |
272 (options " following options are accepted: | |
273 | |
274 Display options: | |
275 | |
276 -nw Open the initial frame on the current TTY, instead of | |
277 a window system. | |
278 -t <device> Use TTY <device> instead of the current TTY for input | |
279 and output. This implies the -nw option. | |
280 -display <display> Standard X option, to specify the display connection. | |
281 If this option is given, or if the environment | |
282 variable DISPLAY is set, an initial X frame will be | |
283 created. Otherwise, an initial Windows frame will be | |
284 created if Windows support exists and neither -nw nor | |
285 -t is given. Otherwise, a TTY frame is created. | |
286 -unmapped Do not display the initial frame. Useful to create | |
287 a \"server\" that can accept `gnuclient' connections. | |
3360 | 288 -tty Create the initial frame on the given window system. |
289 -x (Requesting an unsupported window system, or giving | |
290 -gtk conflicting window systems, is a fatal error.) | |
291 -gnome | |
292 -msw | |
771 | 293 |
294 Noninteractive options: | |
295 | |
296 {-help} | |
297 {-version} | |
298 {-V} | |
299 -batch Execute noninteractively (messages go to stderr, no | |
300 initial frame created). | |
301 {-funcall} | |
302 (The function may parse the rest of the command line | |
303 for its arguments.) | |
304 {-f} | |
305 {-eval} | |
306 {-load} | |
307 {-l} | |
308 {-insert} | |
309 {-i} | |
310 {-kill} | |
446 | 311 -sd Show dump ID. Ignored when configured without --pdump. |
312 -nd Don't load the dump file. Roughly like old temacs. | |
313 Ignored when configured without --pdump. | |
771 | 314 |
315 Initialization files: | |
316 | |
317 -no-init-file Do not load the user-specific init file. | |
318 -q Same as -no-init-file. | |
428 | 319 -debug-init Enter the debugger if an error in the init file occurs. |
771 | 320 -user-init-file <file> |
321 Use <file> as init file. | |
322 -user-init-directory <directory> | |
323 Use <directory> as init directory. | |
324 -user <user> Load user's init file instead of your own. | |
325 -u <user> Same as -user. | |
326 -no-site-file Do not load the site-specific init file | |
327 (site-start.el). | |
328 | |
329 Package/module options: | |
330 | |
331 -vanilla Equivalent to -q -no-site-file -no-early-packages. | |
776 | 332 Useful if you think some user-init or site-init code |
333 is messing things up, or when running XEmacs in | |
334 batch mode. | |
428 | 335 -no-autoloads Do not load global symbol files (auto-autoloads) at |
336 startup. Also implies `-vanilla'. | |
776 | 337 -no-packages Pretend like the packages don't exist. Don't put |
338 any packages in the load path or set up any package | |
969 | 339 autoloads. Also implies `-vanilla'. Use this when |
776 | 340 running XEmacs in batch mode when you aren't using |
341 any functionality in packages and want to make sure | |
342 that you get no interference from packages | |
343 (e.g. Lisp files that shadow core Lisp files). | |
344 -no-early-packages Do not process early packages. | |
771 | 345 -debug-paths Display info about the runtime values of various |
346 directory variables (e.g. for loading packages). | |
347 -no-site-modules Do not search site-modules directories for modules | |
348 at startup. Only applies when modules support is | |
349 compiled into XEmacs. | |
350 | |
351 Encoding options: | |
352 | |
353 -eol Turn on EOL detection (only applies to Unix, no | |
354 international support; otherwise EOL detection is | |
355 already on). | |
356 -nuni Under MS Windows, disable use of the Unicode versions | |
357 of API calls. Not for Windows 95/98/ME. This is | |
358 mostly only useful for debugging purposes. | |
359 | |
360 Misc: | |
361 | |
362 +N <file> Start displaying <file> at line N. | |
363 ") | |
428 | 364 (insert (lambda (&rest x) |
365 (let ((len 2)) | |
366 (while x | |
367 (princ (car x)) | |
368 (incf len (length (car x))) | |
369 (setq x (cdr x))) | |
370 (when (>= len 24) | |
371 (terpri) (setq len 0)) | |
372 (while (< len 24) | |
373 (princ " ") | |
374 (incf len)))))) | |
771 | 375 (princ |
376 (with-temp-buffer | |
377 (insert options) | |
378 (while l | |
379 (let ((name (car (car l))) | |
380 (fn (cdr (car l))) | |
381 doc arg cons) | |
382 (cond | |
383 ((and (symbolp fn) (get fn 'undocumented)) nil) | |
384 (t | |
385 (setq doc (documentation fn)) | |
386 (if (member doc '(nil "")) (setq doc "(undocumented)")) | |
387 (cond ((string-match "\n\\(<.*>\\)\n?\\'" doc) | |
388 ;; Doc of the form "The frobber switch\n<arg1> <arg2>" | |
389 (setq arg (substring doc (match-beginning 1) (match-end 1)) | |
390 doc (substring doc 0 (match-beginning 0)))) | |
391 ((string-match "\n+\\'" doc) | |
392 (setq doc (substring doc 0 (match-beginning 0))))) | |
393 (if (and (setq cons (rassq fn command-switch-alist)) | |
394 (not (eq cons (car l)))) | |
395 (setq doc (format "Same as %s." (car cons)))) | |
396 (goto-char (point-min)) | |
397 (when (search-forward (format "{%s}" name) nil t) | |
398 (delete-region (match-beginning 0) (match-end 0)) | |
399 (let ((standard-output (current-buffer))) | |
400 (if arg | |
401 (funcall insert name " " arg) | |
402 (funcall insert name)) | |
403 (princ doc)))))) | |
404 (setq l (cdr l))) | |
405 (buffer-string)))) | |
428 | 406 (princ (concat "\ |
407 | |
408 Anything else is considered a file name, and is placed into a buffer for | |
409 editing. | |
410 | |
411 " (emacs-name) " has an online tutorial and manuals. Type ^Ht (Control-h t) after | |
412 starting XEmacs to run the tutorial. Type ^Hi to enter the manual browser. | |
771 | 413 Type ^H^H^H (Control-h Control-h Control-h) to get more help options.\n")) |
428 | 414 |
771 | 415 (kill-emacs 0) |
416 )) | |
428 | 417 |
418 (defun command-line-do-funcall (arg) | |
419 "Invoke the named lisp function with no arguments. | |
420 <function>" | |
421 (funcall (intern (pop command-line-args-left)))) | |
422 (fset 'command-line-do-funcall-1 'command-line-do-funcall) | |
423 (put 'command-line-do-funcall-1 'undocumented t) | |
424 | |
425 (defun command-line-do-eval (arg) | |
426 "Evaluate the lisp form. Quote it carefully. | |
427 <form>" | |
428 (eval (read (pop command-line-args-left)))) | |
429 | |
430 (defun command-line-do-load (arg) | |
431 "Load the named file of Lisp code into XEmacs. | |
432 <file>" | |
433 (let ((file (pop command-line-args-left))) | |
434 ;; Take file from default dir if it exists there; | |
435 ;; otherwise let `load' search for it. | |
436 (if (file-exists-p (expand-file-name file)) | |
437 (setq file (expand-file-name file))) | |
438 (load file nil t))) | |
439 | |
440 (defun command-line-do-insert (arg) | |
441 "Insert file into the current buffer. | |
442 <file>" | |
443 (insert-file-contents (pop command-line-args-left))) | |
444 | |
445 (defun command-line-do-kill (arg) | |
446 "Exit XEmacs." | |
447 (kill-emacs t)) | |
448 | |
449 (defun command-line-do-version (arg) | |
450 "Print version info and exit." | |
451 (princ (concat (emacs-version) "\n")) | |
452 (kill-emacs 0)) | |
453 | |
771 | 454 (defun command-line-do-enable-eol-detection (arg) |
455 "Turn on EOL detection (only applies to Unix)." | |
456 (set-eol-detection t)) | |
457 | |
428 | 458 |
459 ;;; Processing the command line and loading various init files | |
460 | |
461 (defun early-error-handler (&rest debugger-args) | |
462 "You should probably not be using this." | |
463 ;; Used as the debugger during XEmacs initialization; if an error occurs, | |
464 ;; print some diagnostics, and kill XEmacs. | |
465 | |
466 ;; output the contents of the warning buffer, since it won't be seen | |
467 ;; otherwise. | |
468 ;; #### kludge! The call to Feval forces the pending warnings to | |
469 ;; get output. There definitely needs to be a better way. | |
470 (let ((buffer (eval (get-buffer-create "*Warnings*")))) | |
471 (princ (buffer-substring (point-min buffer) (point-max buffer) buffer) | |
472 'external-debugging-output)) | |
473 | |
474 (let ((string "Initialization error") | |
475 (error (nth 1 debugger-args)) | |
476 (debug-on-error nil) | |
477 (stream 'external-debugging-output)) | |
478 (if (null error) | |
479 (princ string stream) | |
480 (princ (concat "\n" string ": ") stream) | |
481 (condition-case () | |
482 (display-error error stream) | |
483 (error (princ "<<< error printing error message >>>" stream))) | |
484 (princ "\n" stream) | |
485 (if (memq (car-safe error) '(void-function void-variable)) | |
486 (princ " | |
487 This probably means that XEmacs is picking up an old version of | |
488 the lisp library, or that some .elc files are not up-to-date.\n" | |
489 stream))) | |
490 (when (not suppress-early-error-handler-backtrace) | |
491 (let ((print-length 1000) | |
492 (print-level 1000) | |
493 (print-escape-newlines t) | |
494 (print-readably nil)) | |
495 (when (getenv "EMACSLOADPATH") | |
496 (princ (format "\n$EMACSLOADPATH is %s" (getenv "EMACSLOADPATH")) | |
497 stream)) | |
498 (princ (format "\nexec-directory is %S" exec-directory) stream) | |
499 (princ (format "\ndata-directory is %S" data-directory) stream) | |
500 (princ (format "\ndata-directory-list is %S" data-directory-list) stream) | |
501 (princ (format "\ndoc-directory is %S" doc-directory) stream) | |
502 (princ (format "\nload-path is %S" load-path) stream) | |
503 (princ "\n\n" stream))) | |
504 (when (not suppress-early-error-handler-backtrace) | |
505 (backtrace stream t))) | |
778 | 506 (if-fboundp 'mswindows-message-box |
442 | 507 (mswindows-message-box "Initialization error")) |
428 | 508 (kill-emacs -1)) |
509 | |
510 (defun normal-top-level () | |
511 (if command-line-processed | |
512 (message "Back to top level.") | |
513 (setq command-line-processed t) | |
771 | 514 ;; Do this first for maximum likelihood of catching errors. The main |
515 ;; purpose of this is so that debug-on-error can be set to catch errors | |
516 ;; during normal noninteractive running. | |
517 (when (getenv "XEMACSDEBUG") | |
518 (eval (read (getenv "XEMACSDEBUG")))) | |
428 | 519 ;; Canonicalize HOME (PWD is canonicalized by init_buffer in buffer.c) |
520 (let ((value (user-home-directory))) | |
521 (if (and value | |
522 (< (length value) (length default-directory)) | |
523 (equal (file-attributes default-directory) | |
524 (file-attributes value))) | |
525 (setq default-directory (file-name-as-directory value)))) | |
526 (setq default-directory (abbreviate-file-name default-directory)) | |
527 (initialize-xemacs-paths) | |
528 | |
529 (startup-set-invocation-environment) | |
1330 | 530 (startup-setup-paths (cond (inhibit-all-packages t) |
531 (inhibit-early-packages '(early)) | |
532 (t nil)) | |
533 nil) | |
534 (startup-setup-paths-warning) | |
428 | 535 |
1232 | 536 ;; Either we need to inhibit messages from do_autoloads, or this |
537 ;; should go into (command-line) after the initialization of the | |
538 ;; frame? | |
528 | 539 (startup-load-autoloads) |
428 | 540 |
866 | 541 (let (error-data) |
1123 | 542 ;; if noninteractive, an error will kill us. by catching and |
543 ;; resignalling, we don't accomplish much, but do make it difficult | |
544 ;; to determine where the error really occurred. when interactive, | |
545 ;; however, an error processing the command line does NOT kill us; | |
546 ;; instead, the error handler tries to display an error on the frame. | |
547 ;; In that case, we must make sure that all the remaining initialization | |
548 ;; gets done!!! | |
549 ;; | |
550 ;; #### A better solution in the interactive case is to use | |
551 ;; call-with-condition-handler, which would let us do the rest of | |
552 ;; the initialization AND allow the user to get an accurate backtrace. | |
553 (if (noninteractive) | |
866 | 554 (command-line) |
1123 | 555 (condition-case data |
556 (command-line) | |
557 ;; catch non-error signals, especially quit | |
558 (t (setq error-data data)))) | |
452 | 559 ;; Do this again, in case the init file defined more abbreviations. |
428 | 560 (setq default-directory (abbreviate-file-name default-directory)) |
561 ;; Specify the file for recording all the auto save files of | |
562 ;; this session. This is used by recover-session. | |
444 | 563 (if auto-save-list-file-prefix |
564 (setq auto-save-list-file-name | |
565 (expand-file-name | |
566 (format "%s%d-%s" | |
567 auto-save-list-file-prefix | |
568 (emacs-pid) | |
569 (system-name))))) | |
428 | 570 (run-hooks 'emacs-startup-hook) |
571 (and term-setup-hook | |
572 (run-hooks 'term-setup-hook)) | |
573 (setq term-setup-hook nil) | |
452 | 574 ;; ;; Modify the initial frame based on what the init file puts into |
428 | 575 ;; ;; ...-frame-alist. |
576 (frame-notice-user-settings) | |
3360 | 577 ;; ;;#### GNU Emacs junk |
428 | 578 ;; ;; Now we know the user's default font, so add it to the menu. |
579 ;; (if (fboundp 'font-menu-add-default) | |
580 ;; (font-menu-add-default)) | |
581 (when window-setup-hook | |
582 (run-hooks 'window-setup-hook)) | |
863 | 583 (setq window-setup-hook nil) |
584 (if error-data | |
585 ;; re-signal, and don't allow continuation as that will probably | |
586 ;; wipe out the user's .emacs if she hasn't migrated yet! | |
587 (signal-error (car error-data) (cdr error-data)))) | |
442 | 588 |
589 (if load-user-init-file-p | |
590 (maybe-migrate-user-init-file)) | |
3360 | 591 ;; GNU calls precompute-menubar-bindings. We don't mix menubars |
611 | 592 ;; and keymaps. |
428 | 593 )) |
594 | |
595 (defun command-line-early (args) | |
596 ;; This processes those switches which need to be processed before | |
597 ;; starting up the window system. | |
598 | |
599 (setq command-line-default-directory default-directory) | |
600 | |
601 ;; See if we should import version-control from the environment variable. | |
602 (let ((vc (getenv "VERSION_CONTROL"))) | |
603 (cond ((eq vc nil)) ;don't do anything if not set | |
604 ((or (string= vc "t") | |
605 (string= vc "numbered")) | |
606 (setq version-control t)) | |
607 ((or (string= vc "nil") | |
608 (string= vc "existing")) | |
609 (setq version-control nil)) | |
610 ((or (string= vc "never") | |
611 (string= vc "simple")) | |
612 (setq version-control 'never)))) | |
613 | |
3360 | 614 ;;#### GNU Emacs |
428 | 615 ;; (if (let ((ctype |
616 ;; ;; Use the first of these three envvars that has a nonempty value. | |
617 ;; (or (let ((string (getenv "LC_ALL"))) | |
618 ;; (and (not (equal string "")) string)) | |
619 ;; (let ((string (getenv "LC_CTYPE"))) | |
620 ;; (and (not (equal string "")) string)) | |
621 ;; (let ((string (getenv "LANG"))) | |
622 ;; (and (not (equal string "")) string))))) | |
623 ;; (and ctype | |
624 ;; (string-match iso-8859-1-locale-regexp ctype))) | |
438 | 625 ;; (progn |
428 | 626 ;; (standard-display-european t) |
627 ;; (require 'iso-syntax))) | |
776 | 628 |
629 (if vanilla-inhibiting ;; set in main_1() | |
630 (setq load-user-init-file-p nil | |
631 site-start-file nil) | |
632 (setq load-user-init-file-p (not (noninteractive)))) | |
633 | |
428 | 634 ;; Allow (at least) these arguments anywhere in the command line |
776 | 635 (macrolet ((long-argmatch (match) |
636 ;; use a macro to avoid lots of concatting at runtime | |
637 `(or (string= arg ,match) | |
638 (string= arg ,(concat "-" match))))) | |
639 (let ((new-args nil) | |
640 (arg nil)) | |
641 (while args | |
642 (setq arg (pop args)) | |
428 | 643 (cond |
644 ((or (string= arg "-q") | |
776 | 645 (long-argmatch "-no-init-file")) |
428 | 646 (setq load-user-init-file-p nil)) |
776 | 647 ((long-argmatch "-no-site-file") |
428 | 648 (setq site-start-file nil)) |
776 | 649 ((long-argmatch "-user-init-file") |
428 | 650 (setq user-init-file (pop args))) |
776 | 651 ((long-argmatch "-user-init-directory") |
428 | 652 (setq user-init-directory (file-name-as-directory (pop args)))) |
653 ((or (string= arg "-u") | |
776 | 654 (long-argmatch "-user")) |
428 | 655 (let* ((user (pop args)) |
656 (home-user (concat "~" user))) | |
442 | 657 (setq user-init-directory (file-name-as-directory |
440 | 658 (paths-construct-path |
442 | 659 (list home-user user-init-directory-base)))) |
660 (setq user-init-file | |
661 (find-user-init-file user-init-directory home-user)) | |
662 (setq custom-file | |
663 (make-custom-file-name user-init-file)))) | |
776 | 664 ((long-argmatch "-debug-init") |
428 | 665 (setq init-file-debug t)) |
776 | 666 ((long-argmatch "-unmapped") |
428 | 667 (setq initial-frame-unmapped-p t)) |
668 ((or (string= arg "--") (string= arg "-")) | |
669 (while args | |
670 (push (pop args) new-args))) | |
671 (t (push arg new-args)))) | |
672 | |
502 | 673 (with-obsolete-variable 'init-file-user |
674 (setq init-file-user (and load-user-init-file-p ""))) | |
428 | 675 |
776 | 676 (nreverse new-args)))) |
428 | 677 |
678 (defconst initial-scratch-message "\ | |
679 ;; This buffer is for notes you don't want to save, and for Lisp evaluation. | |
680 ;; If you want to create a file, first visit that file with C-x C-f, | |
502 | 681 ;; then enter the text in that file's own buffer. (C-x is the standard |
684 | 682 ;; XEmacs abbreviation for `Control+x', i.e. hold down the Control key |
683 ;; while hitting the x key.) | |
502 | 684 ;; |
685 ;; For Lisp evaluation, type an expression, move to the end and hit C-j. | |
428 | 686 |
687 " | |
688 "Initial message displayed in *scratch* buffer at startup. | |
689 If this is nil, no message will be displayed.") | |
690 | |
691 (defun command-line () | |
692 (let ((command-line-args-left (cdr command-line-args))) | |
693 | |
694 (let ((debugger 'early-error-handler) | |
695 (debug-on-error t)) | |
696 | |
697 ;; Process magic command-line switches like -q and -u. Do this | |
698 ;; before creating the first frame because some of these switches | |
699 ;; may affect that. I think it's ok to do this before establishing | |
700 ;; the X connection, and maybe someday things like -nw can be | |
701 ;; handled here instead of down in C. | |
702 (setq command-line-args-left (command-line-early command-line-args-left)) | |
703 | |
611 | 704 (when (eq system-type 'windows-nt) |
776 | 705 (declare-fboundp (init-mswindows-at-startup))) |
611 | 706 |
428 | 707 ;; Setup the toolbar icon directory |
708 (when (featurep 'toolbar) | |
709 (init-toolbar-location)) | |
710 | |
2699 | 711 ;; Setup coding systems and Unicode support--needs to be before X11 |
712 ;; initialisation in case of keysyms of the form UABCD. | |
713 (when (featurep 'mule) | |
714 (declare-fboundp (init-mule-at-startup))) | |
715 | |
487 | 716 (if (featurep 'toolbar) |
717 (if (featurep 'infodock) | |
718 (require 'id-x-toolbar) | |
719 (init-toolbar))) | |
720 | |
428 | 721 ;; Run the window system's init function. tty is considered to be |
722 ;; a type of window system for this purpose. This creates the | |
723 ;; initial (non stdio) device. | |
724 (when (and initial-window-system (not noninteractive)) | |
725 (funcall (intern (concat "init-" | |
726 (symbol-name initial-window-system) | |
727 "-win")))) | |
728 | |
729 ;; When not in batch mode, this creates the first visible frame, | |
730 ;; and deletes the stdio device. | |
731 (frame-initialize)) | |
732 | |
440 | 733 ;; Reinitialize faces if necessary. This function changes face if |
734 ;; it is created during auto-autoloads loading. Otherwise, it | |
735 ;; does nothing. | |
736 (startup-initialize-custom-faces) | |
737 | |
771 | 738 ;; A couple of other things need to be initted. |
739 ;; (RMS writes about internally using hooks for this, in reference | |
740 ;; to frame-initialize and frame-notice-user-settings: | |
741 ;; | |
742 ;; These are now called explicitly at the proper times, | |
743 ;; since that is easier to understand. | |
744 ;; Actually using hooks within Emacs is bad for future maintenance. --rms. | |
745 ;; | |
746 ;; In this case, I completely agree. --ben | |
811 | 747 (if (featurep 'menubar) |
748 (init-menubar-at-startup)) | |
428 | 749 ;; |
750 ;; We have normality, I repeat, we have normality. Anything you still | |
751 ;; can't cope with is therefore your own problem. (And we don't need | |
752 ;; to kill XEmacs for it.) | |
753 ;; | |
754 | |
755 ;;; Load init files. | |
756 (load-init-file) | |
438 | 757 |
428 | 758 (with-current-buffer (get-buffer "*scratch*") |
759 (erase-buffer) | |
760 ;; (insert initial-scratch-message) | |
761 (set-buffer-modified-p nil) | |
762 (when (eq major-mode 'fundamental-mode) | |
2756 | 763 (funcall initial-major-mode)) |
764 ;; The docstring for font-lock-set-defaults says that major modes that | |
765 ;; have any font-lock defaults specified should call the function | |
766 ;; after initialising the `major-mode' variable. None of them do, | |
767 ;; however, and any font locking that is ever put in place is done as | |
768 ;; a result of `font-lock-set-defaults' being in find-file-hook and | |
769 ;; various other places. We could make *scratch* honour the user's | |
770 ;; choice of whether font-locking is in place by adding a call to | |
771 ;; font-lock-set-defaults in `lisp-interaction-mode'; but that'll | |
772 ;; break if `intial-major-mode' is anything else. | |
773 ;; | |
774 ;; So, despite what `font-lock-set-defaults'' docstring says, this | |
775 ;; *is* where we should call it to have the user's choice of font-lock | |
776 ;; level take effect in *scratch*. If the modes are rewritten to do | |
777 ;; the right then, we're okay too, the function is idempotent. | |
778 (font-lock-set-defaults)) | |
428 | 779 |
780 ;; Load library for our terminal type. | |
781 ;; User init file can set term-file-prefix to nil to prevent this. | |
782 ;; Note that for any TTY's opened subsequently, the TTY init | |
783 ;; code will run this. | |
784 (when (and (eq 'tty (console-type)) | |
785 (not (noninteractive))) | |
786 (load-terminal-library)) | |
787 | |
788 ;; Process the remaining args. | |
789 (command-line-1) | |
790 | |
791 ;; it was turned on by default so that the warnings don't get displayed | |
792 ;; until after the splash screen. | |
793 (setq inhibit-warning-display nil) | |
794 ;; If -batch, terminate after processing the command options. | |
795 (when (noninteractive) (kill-emacs t)))) | |
796 | |
438 | 797 (defun load-terminal-library () |
428 | 798 (when term-file-prefix |
799 (let ((term (getenv "TERM")) | |
800 hyphend) | |
801 (while (and term | |
802 (not (load (concat term-file-prefix term) t t))) | |
803 ;; Strip off last hyphen and what follows, then try again | |
804 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) | |
805 (setq term (substring term 0 hyphend)) | |
806 (setq term nil)))))) | |
807 | |
1330 | 808 (defun find-init-file-1 (dir base-list) |
809 (catch 'found | |
810 (dolist (file base-list) | |
811 (let ((expanded (expand-file-name file dir))) | |
812 (if (string-match "el$" expanded) | |
813 (let* ((elc (concat expanded "c")) | |
814 (el-ok (file-readable-p expanded)) | |
815 (elc-ok (file-readable-p elc))) | |
816 (cond | |
817 ((and el-ok elc-ok (file-newer-than-file-p expanded elc)) | |
818 (lwarn 'initialization 'warning | |
819 "\ | |
820 The compiled initialization file `%s' exists | |
821 but is out-of-date with respect to the uncompiled initialization | |
822 file `%s'. XEmacs will load the uncompiled | |
823 version. You should correct the problem as soon as possible by | |
824 loading the uncompiled version and compiling it using | |
825 `M-x byte-compile-file' (or `Lisp->Byte-Compile This File' on | |
826 the menubar)." | |
827 elc expanded) | |
828 (throw 'found expanded)) | |
829 (elc-ok (throw 'found elc)) | |
830 (el-ok (throw 'found expanded)))) | |
831 (when (file-readable-p | |
832 (when (file-readable-p expanded) | |
833 (throw 'found expanded))))))))) | |
834 | |
442 | 835 (defun find-user-init-directory-init-file (&optional init-directory) |
836 "Determine the user's init file if in the init directory." | |
1330 | 837 (find-init-file-1 (or init-directory user-init-directory) |
838 user-init-file-base-list)) | |
442 | 839 |
840 (defun find-user-home-directory-init-file (&optional home-directory) | |
841 "Determine the user's init file if in the home directory." | |
1330 | 842 (find-init-file-1 (or home-directory "~") |
843 user-home-init-file-base-list)) | |
442 | 844 |
845 (defun find-user-init-file (&optional init-directory home-directory) | |
440 | 846 "Determine the user's init file." |
442 | 847 (if load-home-init-file |
848 (find-user-home-directory-init-file home-directory) | |
849 (or (find-user-init-directory-init-file init-directory) | |
850 (find-user-home-directory-init-file home-directory)))) | |
851 | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
852 (defun ask-about-user-init-file-migration-p () |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
853 "Check whether we want to ask the user if she wants to migrate the init file." |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
854 (and (not load-home-init-file) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
855 (not (find-user-init-directory-init-file user-init-directory)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
856 (stringp user-init-file) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
857 (file-readable-p user-init-file))) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
858 |
442 | 859 (defun maybe-migrate-user-init-file () |
860 "Ask user if she wants to migrate the init file(s) to new location." | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
861 (if (ask-about-user-init-file-migration-p) |
442 | 862 (if (with-output-to-temp-buffer (help-buffer-name nil) |
863 (progn | |
864 (princ "XEmacs recommends that the initialization code in | |
865 ") | |
866 (princ user-init-file) | |
867 (princ " | |
868 be migrated to the ") | |
869 (princ user-init-directory) | |
870 (princ " directory. XEmacs can | |
871 perform the migration automatically. | |
872 | |
873 After the migration, init.el/init.elc holds user-written | |
874 initialization code. Moreover the customize settings will be in | |
875 custom.el. | |
876 | |
452 | 877 You can undo the migration at any time with |
878 M-x maybe-unmigrate-user-init-file. | |
879 | |
442 | 880 If you choose not to do this now, XEmacs will not ask you this |
881 question in the future. However, you can still make XEmacs | |
882 perform the migration at any time with M-x migrate-user-init-file.") | |
883 (show-temp-buffer-in-current-frame standard-output) | |
884 (yes-or-no-p-minibuf (concat "Migrate init file to " | |
885 user-init-directory | |
886 "? ")))) | |
4111 | 887 |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
888 (progn |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
889 (migrate-user-init-file) |
4111 | 890 (with-output-to-temp-buffer (help-buffer-name nil) |
891 (progn | |
892 (princ "The initialization code has now been migrated to the ") | |
893 (princ user-init-directory) | |
894 (princ "directory. | |
895 | |
896 For backwards compatibility with, for example, older versions of XEmacs, | |
897 XEmacs can create a special old-style .emacs file in your home | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
898 directory which will load the relocated initialization code. |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
899 |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
900 NOTE THAT THIS WILL OVERWRITE YOUR EXISTING .emacs FILE!") |
4111 | 901 (show-temp-buffer-in-current-frame standard-output) |
902 (maybe-create-compatibility-dot-emacs)))) | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
903 (set-load-home-init-file user-init-file t)))) |
442 | 904 |
452 | 905 (defun maybe-create-compatibility-dot-emacs () |
906 "Ask user if she wants to create a .emacs compatibility file." | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
907 (if (yes-or-no-p-minibuf "Create compatibility .emacs?") |
452 | 908 (create-compatibility-dot-emacs))) |
909 | |
442 | 910 (defun migrate-user-init-file () |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
911 "Migrate the init file from the home directory." |
442 | 912 (interactive) |
913 (if (not (file-exists-p user-init-directory)) | |
914 (progn | |
915 (message "Creating %s directory..." user-init-directory) | |
916 (make-directory user-init-directory))) | |
917 (message "Migrating custom file...") | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
918 (set-load-home-init-file user-init-file nil) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
919 (setq custom-file (make-custom-file-name user-init-file 'force-new)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
920 (custom-save-all) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
921 (message "Copying init file...") |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
922 (let ((new-user-init-file (expand-file-name user-init-file-base |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
923 user-init-directory))) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
924 (copy-file user-init-file new-user-init-file) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
925 (setq user-init-file new-user-init-file)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
926 (message "Migration done.")) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
927 |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
928 (defun set-load-home-init-file (filename val) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
929 "Put code in `filename' to set `load-home-init-file' to `val'. |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
930 More precisely, remove the first `setq' form for `load-home-init-file', |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
931 and replace it by (setq load-home-init-file t) if `val' is non-nil." |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
932 (save-excursion |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
933 (set-buffer (find-file-noselect filename)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
934 (goto-char (point-min)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
935 (condition-case nil |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
936 (block find-existing |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
937 (while (not (eobp)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
938 (forward-sexp 1) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
939 (backward-sexp 1) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
940 (let* ((beginning (point)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
941 (sexp (read (current-buffer)))) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
942 (if (and (consp sexp) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
943 (consp (cdr sexp)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
944 (eq 'setq (car sexp)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
945 (eq 'load-home-init-file (cadr sexp))) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
946 (progn |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
947 (forward-line 1) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
948 (delete-region beginning (point)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
949 (return-from find-existing nil)) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
950 (forward-sexp 1))))) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
951 (error nil)) ; ignore if there are no sexprs in the file |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
952 (if val |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
953 (insert "(setq load-home-init-file t) ; don't load init file from ~/.xemacs/init.el\n")) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
954 (save-buffer))) |
440 | 955 |
452 | 956 (defun create-compatibility-dot-emacs () |
957 "Create .emacs compatibility file for migrated setup." | |
958 (message "Creating .emacs compatibility file.") | |
959 (with-temp-file (expand-file-name ".emacs" "~") | |
960 (insert ";;; XEmacs backwards compatibility file\n") | |
961 (insert "(setq user-init-file\n") | |
962 (insert " (expand-file-name \"init.el\"\n") | |
963 (insert " (expand-file-name \".xemacs\" \"~\")))\n") | |
964 (insert "(setq custom-file\n") | |
965 (insert " (expand-file-name \"custom.el\"\n") | |
966 (insert " (expand-file-name \".xemacs\" \"~\")))\n") | |
967 (insert "\n") | |
968 (insert "(load-file user-init-file)\n") | |
969 (insert "(load-file custom-file)")) | |
970 (message "Created .emacs compatibility file.")) | |
971 | |
972 (defun maybe-unmigrate-user-init-file () | |
973 "Possibly unmigrate the user's init and custom files." | |
974 (interactive) | |
975 (let ((dot-emacs-file-name (expand-file-name ".emacs" "~"))) | |
976 (if (and (not load-home-init-file) | |
977 (or (not (file-exists-p dot-emacs-file-name)) | |
978 (yes-or-no-p-minibuf (concat "Overwrite " dot-emacs-file-name | |
979 "? ")))) | |
980 (unmigrate-user-init-file dot-emacs-file-name)))) | |
981 | |
982 (defun unmigrate-user-init-file (&optional target-file-name) | |
983 "Unmigrate the user's init and custom files." | |
984 (interactive) | |
985 (let ((target-file-name | |
986 (or target-file-name (expand-file-name ".emacs" "~")))) | |
987 (rename-file user-init-file target-file-name 'ok-if-already-exists) | |
988 (setq user-init-file target-file-name) | |
989 (let ((old-custom-file custom-file)) | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
990 (setq custom-file target-file-name) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
991 (custom-save-all) |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
992 (set-load-home-init-file user-init-file t) |
452 | 993 (delete-file old-custom-file)))) |
994 | |
428 | 995 (defun load-user-init-file () |
442 | 996 "This function actually reads the init file." |
428 | 997 (if (not user-init-file) |
442 | 998 (setq user-init-file |
999 (find-user-init-file user-init-directory))) | |
470 | 1000 (if (not custom-file) |
1001 (setq custom-file (make-custom-file-name user-init-file))) | |
442 | 1002 (if (and user-init-file |
1003 (file-readable-p user-init-file)) | |
1004 (load user-init-file t t t)) | |
1005 (if (and custom-file | |
1006 (or (not user-init-file) | |
1007 (not (string= custom-file user-init-file))) | |
1008 (file-readable-p custom-file)) | |
1009 (load custom-file t t t)) | |
428 | 1010 (unless inhibit-default-init |
1011 (let ((inhibit-startup-message nil)) | |
1012 ;; Users are supposed to be told their rights. | |
1013 ;; (Plus how to get help and how to undo.) | |
1014 ;; Don't you dare turn this off for anyone except yourself. | |
1015 (load "default" t t)))) | |
1016 | |
2030 | 1017 ;;; #### move this comment into a docstring. See site-init-file for some |
1018 ;;; description of what it does. Substitute a pointer to this function in | |
1019 ;;; site-init-file's docstring. | |
428 | 1020 ;;; Load user's init file and default ones. |
1021 (defun load-init-file () | |
1022 (run-hooks 'before-init-hook) | |
1023 | |
1024 ;; Run the site-start library if it exists. The point of this file is | |
2030 | 1025 ;; that it is run before the user's init file. There is no point in |
1026 ;; doing this after the user's init file; that is useless. | |
428 | 1027 (when site-start-file |
1028 (load site-start-file t t)) | |
1029 | |
1030 ;; Sites should not disable this. Only individuals should disable | |
1031 ;; the startup message. | |
1032 (setq inhibit-startup-message nil) | |
1033 | |
1034 (let (debug-on-error-from-init-file | |
1035 debug-on-error-should-be-set | |
1036 (debug-on-error-initial | |
1037 (if (eq init-file-debug t) 'startup init-file-debug))) | |
1038 (let ((debug-on-error debug-on-error-initial)) | |
1039 (if (and load-user-init-file-p init-file-debug) | |
442 | 1040 (progn |
1041 ;; Do this without a condition-case if the user wants to debug. | |
1042 (load-user-init-file)) | |
793 | 1043 (condition-case nil |
1044 (call-with-condition-handler | |
1045 #'(lambda (__load_init_file_arg__) | |
1046 (let ((errstr (error-message-string | |
1047 __load_init_file_arg__))) | |
1048 (message "Error in init file: %s" errstr) | |
1049 (lwarn 'initialization 'error | |
1050 "\ | |
428 | 1051 An error has occurred while loading %s: |
1052 | |
1053 %s | |
1054 | |
793 | 1055 Backtrace follows: |
1056 | |
1057 %s | |
1058 | |
428 | 1059 To ensure normal operation, you should investigate the cause of the error |
1060 in your initialization file and remove it. Use the `-debug-init' option | |
793 | 1061 to XEmacs to enter the debugger when the error occurs and investigate the |
1062 exact problem." | |
1063 user-init-file errstr | |
1064 (backtrace-in-condition-handler-eliminating-handler | |
1065 '__load_init_file_arg__))) | |
1066 (setq init-file-had-error t)) | |
1067 #'(lambda () | |
1068 (if load-user-init-file-p | |
1069 (load-user-init-file)) | |
1070 (setq init-file-had-error nil))) | |
1071 (error nil))) | |
428 | 1072 ;; If we can tell that the init file altered debug-on-error, |
1073 ;; arrange to preserve the value that it set up. | |
1074 (or (eq debug-on-error debug-on-error-initial) | |
1075 (setq debug-on-error-should-be-set t | |
1076 debug-on-error-from-init-file debug-on-error))) | |
1077 (when debug-on-error-should-be-set | |
1078 (setq debug-on-error debug-on-error-from-init-file))) | |
1079 | |
1080 (setq init-file-loaded t) | |
1081 | |
1082 ;; Do this here in case the init file sets mail-host-address. | |
1083 ;; Don't do this here unless noninteractive, it is frequently wrong. -sb | |
1084 ;; (or user-mail-address | |
1085 (when noninteractive | |
1086 (setq user-mail-address (concat (user-login-name) "@" | |
1087 (or mail-host-address | |
1088 (system-name))))) | |
1089 | |
1090 (run-hooks 'after-init-hook) | |
1091 nil) | |
1092 | |
1093 (defun load-options-file (filename) | |
1094 "Load the file of saved options (from the Options menu) called FILENAME. | |
1095 Currently this does nothing but call `load', but it might be redefined | |
1096 in the future to support automatically converting older options files to | |
1097 a new format, when variables have changed, etc." | |
1098 (load filename)) | |
1099 | |
1100 (defun command-line-1 () | |
1101 (cond | |
1102 ((null command-line-args-left) | |
1103 (unless noninteractive | |
1104 ;; If there are no switches to process, run the term-setup-hook | |
1105 ;; before displaying the copyright notice; there may be some need | |
1106 ;; to do it before doing any output. If we're not going to | |
1107 ;; display a copyright notice (because other options are present) | |
1108 ;; then this is run after those options are processed. | |
1109 (run-hooks 'term-setup-hook) | |
1110 ;; Don't let the hook be run twice. | |
1111 (setq term-setup-hook nil) | |
1112 | |
1113 ;; Don't clobber a non-scratch buffer if init file | |
1114 ;; has selected it. | |
4347
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
1115 (when (and (string= (buffer-name) "*scratch*") |
6b571dc4ba3f
Rework init-file migration.
Mike Sperber <sperber@deinprogramm.de>
parents:
4111
diff
changeset
|
1116 (not (ask-about-user-init-file-migration-p))) |
428 | 1117 (unless (or inhibit-startup-message |
1118 (input-pending-p)) | |
2505 | 1119 (let (tmout) |
428 | 1120 (unwind-protect |
1121 ;; Guts of with-timeout | |
1122 (catch 'tmout | |
1123 (setq tmout (add-timeout startup-message-timeout | |
1124 (lambda (ignore) | |
1125 (condition-case nil | |
1126 (throw 'tmout t) | |
1127 (error nil))) | |
1128 nil)) | |
2505 | 1129 (display-splash-screen) |
428 | 1130 (or nil;; (pos-visible-in-window-p (point-min)) |
1131 (goto-char (point-min))) | |
1132 (sit-for 0) | |
1133 (setq unread-command-event (next-command-event))) | |
2505 | 1134 (when tmout (disable-timeout tmout))))) |
428 | 1135 (with-current-buffer (get-buffer "*scratch*") |
1136 ;; In case the XEmacs server has already selected | |
1137 ;; another buffer, erase the one our message is in. | |
1138 (erase-buffer) | |
1139 (when (stringp initial-scratch-message) | |
1140 (insert initial-scratch-message)) | |
1141 (set-buffer-modified-p nil))))) | |
1142 | |
1143 (t | |
1144 ;; Command-line-options exist | |
1145 (let ((dir command-line-default-directory) | |
1146 (file-count 0) | |
1147 (line nil) | |
1148 (end-of-options nil) | |
442 | 1149 file-p arg tem) |
428 | 1150 (while command-line-args-left |
1151 (setq arg (pop command-line-args-left)) | |
1152 (cond | |
1153 (end-of-options | |
1154 (setq file-p t)) | |
1155 ((setq tem (when (eq (aref arg 0) ?-) | |
1156 (or (assoc arg command-switch-alist) | |
1157 (assoc (substring arg 1) | |
1158 command-switch-alist)))) | |
1159 (funcall (cdr tem) arg)) | |
1160 ((string-match "\\`\\+[0-9]+\\'" arg) | |
1161 (setq line (string-to-int arg))) | |
1162 ;; "- file" means don't treat "file" as a switch | |
1163 ;; ("+0 file" has the same effect; "-" added | |
1164 ;; for unixoidiality). | |
1165 ;; This is worthless; the `unixoid' way is "./file". -jwz | |
1166 ((or (string= arg "-") (string= arg "--")) | |
1167 (setq end-of-options t)) | |
1168 (t | |
1169 (setq file-p t))) | |
438 | 1170 |
428 | 1171 (when file-p |
1172 (setq file-p nil) | |
1173 (incf file-count) | |
1174 (setq arg (expand-file-name arg dir)) | |
1175 (cond | |
442 | 1176 ((= file-count 1) |
1177 (find-file arg)) | |
428 | 1178 (noninteractive (find-file arg)) |
1179 (t (find-file-other-window arg))) | |
1180 (when line | |
1181 (goto-line line) | |
1182 (setq line nil)))))))) | |
1183 | |
2505 | 1184 |
428 | 1185 (defun startup-presentation-hack-help (e) |
1186 (setq e (extent-property e 'startup-presentation-hack)) | |
2505 | 1187 (symbol-name e)) |
1188 | |
1189 (defun startup-presentation-activate (ev ex) | |
1190 (call-interactively (extent-property ex 'startup-presentation-hack))) | |
428 | 1191 |
2505 | 1192 (defun splash-screen-present-hack (e v) |
1193 ; (set-extent-property e 'mouse-face 'highlight) | |
1194 ; (set-extent-property e 'startup-presentation-hack v) | |
1195 ; (set-extent-property e 'help-echo | |
1196 ; 'startup-presentation-hack-help) | |
1197 ; (set-extent-property e 'activate-function 'startup-presentation-activate) | |
428 | 1198 ) |
1199 | |
1200 (defun splash-hack-version-string () | |
1201 (save-excursion | |
1202 (save-restriction | |
1203 (goto-char (point-min)) | |
1204 (re-search-forward "^XEmacs" nil t) | |
1205 (narrow-to-region (point-at-bol) (point-at-eol)) | |
1206 (goto-char (point-min)) | |
1207 (when (re-search-forward " \\[Lucid\\]" nil t) | |
1208 (delete-region (match-beginning 0) (match-end 0))) | |
1209 (when (re-search-forward "[^(][^)]*-[^)]*-" nil t) | |
1210 (delete-region (1+ (match-beginning 0)) (match-end 0)) | |
1211 (insert "(")) | |
1212 (goto-char (point-max)) | |
1213 (search-backward " " nil t) | |
1214 (when (search-forward "." nil t) | |
1215 (delete-region (1- (point)) (point-max)))))) | |
1216 | |
2505 | 1217 ;; parse one page description (see `splash-screen-body') and display |
1218 ;; at point. | |
1219 (defun splash-screen-present (l) | |
428 | 1220 (cond ((stringp l) |
1221 (insert l)) | |
1222 ((eq (car-safe l) 'face) | |
1223 ;; (face name string) | |
1224 (let ((p (point))) | |
2505 | 1225 (splash-screen-present (elt l 2)) |
1226 (set-extent-face (make-extent p (point)) | |
1227 (elt l 1)))) | |
428 | 1228 ((eq (car-safe l) 'key) |
1229 (let* ((c (elt l 1)) | |
1230 (p (point)) | |
1231 (k (where-is-internal c nil t))) | |
1232 (insert (if k (key-description k) | |
1233 (format "M-x %s" c))) | |
2505 | 1234 (let ((e (make-extent p (point)))) |
1235 (set-extent-face e 'bold) | |
1236 (splash-screen-present-hack e c)))) | |
428 | 1237 ((eq (car-safe l) 'funcall) |
1238 ;; (funcall (fun . args) string) | |
1239 (let ((p (point))) | |
2505 | 1240 (splash-screen-present (elt l 2)) |
1241 (splash-screen-present-hack (make-extent p (point)) | |
1242 (elt l 1)))) | |
428 | 1243 ((consp l) |
2505 | 1244 (mapcar 'splash-screen-present l)) |
428 | 1245 (t |
1246 (error "WTF!?")))) | |
1247 | |
1248 (defun startup-center-spaces (glyph) | |
1249 ;; Return the number of spaces to insert in order to center | |
1250 ;; the given glyph (may be a string or a pixmap). | |
438 | 1251 ;; Assume spaces are as wide as avg-pixwidth. |
428 | 1252 ;; Won't be quite right for proportional fonts, but it's the best we can do. |
1253 ;; Maybe the new redisplay will export something a glyph-width function. | |
1254 ;;; #### Yes, there is a glyph-width function but it isn't quite what | |
1255 ;;; #### this was expecting. Or is it? | |
1256 ;; (An alternate way to get avg-pixwidth would be to use x-font-properties | |
1257 ;; and calculate RESOLUTION_X * AVERAGE_WIDTH / 722.7, but it's no better.) | |
1258 | |
1259 ;; This function is used in about.el too. | |
1260 (let* ((avg-pixwidth (round (/ (frame-pixel-width) (frame-width)))) | |
1261 (fill-area-width (* avg-pixwidth (- fill-column left-margin))) | |
438 | 1262 (glyph-pixwidth (cond ((stringp glyph) |
428 | 1263 (* avg-pixwidth (length glyph))) |
1264 ((glyphp glyph) | |
1265 (glyph-width glyph)) | |
1266 (t | |
1267 (error "startup-center-spaces: bad arg"))))) | |
1268 (+ left-margin | |
1269 (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth))))) | |
1270 | |
2505 | 1271 ;; the splash screen originated in 19.10 as splash-screen-*. When |
1272 ;; Chuck made the global screen->frame change for 19.12, he | |
1273 ;; accidentally changed these too. This randomness is getting on my | |
1274 ;; nerves, so let's fix it and provide minimal aliases for the | |
1275 ;; `locale' mule package. --ben | |
1276 | |
1277 ;; returns either of vector of page descriptions, each describing one | |
1278 ;; screenful of information, or just one such page descriptions Each | |
1279 ;; page description is a list of textual elements describing how to | |
1280 ;; display a section of text. The elements are processed in turn and | |
1281 ;; the results inserted one after the previous in a buffer. Each | |
1282 ;; textual element is either: | |
1283 | |
1284 ;; -- a string, inserted as-is with no decoration. | |
1285 ;; -- a list of (face FACES "text"), where FACES is the name of a face | |
1286 ;; or a list of such names, and specifies the face(s) used when | |
1287 ;; displaying the text. | |
1288 ;; -- a list of (key COMMAND-NAME); the key sequence corresponding to | |
1289 ;; the command will be inserted, in boldface. | |
1290 ;; -- a list of textual elements. | |
1291 | |
1292 (defun splash-screen-window-body () | |
1293 `( | |
1294 (face (blue bold underline) | |
1295 "Useful Help-menu entries:\n\n") | |
1296 ,@(if (string-match "beta" emacs-version) | |
1297 `((face bold "Beta Info:") | |
1298 (face (red bold) | |
1299 " This is an Experimental version of XEmacs.\n")) | |
1300 `( "")) | |
1301 (face bold "XEmacs FAQ:") | |
1302 " Read the XEmacs FAQ.\n" | |
1303 (face bold "Info (Online Docs):") | |
1304 " Read the on-line documentation.\n" | |
1305 (face bold "Tutorial:") | |
1306 " XEmacs tutorial.\n" | |
1307 (face bold "Samples->View Sample init.el:") | |
1308 " A useful initialization file.\n" | |
1309 (face bold "About XEmacs:") | |
1310 " See who's developing XEmacs.\n" | |
1311 "\n" | |
1312 (face (bold blue) "XEmacs website:") | |
1313 " http://www.xemacs.org/\n\n" | |
428 | 1314 ,@(if (featurep 'sparcworks) |
1315 `( "\ | |
1316 Sun provides support for the WorkShop/XEmacs integration package only. | |
1317 All other XEmacs packages are provided to you \"AS IS\".\n" | |
438 | 1318 ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") |
428 | 1319 (getenv "LANG")))) |
1320 (if (and | |
1321 (not (featurep 'mule)) ;; Already got mule? | |
1322 lang ;; Non-English locale? | |
1323 (not (string= lang "C")) | |
1324 (not (string-match "^en" lang)) | |
1325 ;; Comes with Sun WorkShop | |
1326 (locate-file "xemacs-mule" exec-path)) | |
1327 '( "\ | |
1328 This version of XEmacs has been built with support for Latin-1 languages only. | |
1329 To handle other languages you need to run a Multi-lingual (`Mule') version of | |
1330 XEmacs, by either running the command `xemacs-mule', or by using the X resource | |
1331 `ESERVE*defaultXEmacsPath: xemacs-mule' when starting XEmacs from Sun WorkShop. | |
1332 \n"))))) | |
1333 (face italic "\ | |
1334 Copyright (C) 1985-1999 Free Software Foundation, Inc. | |
1335 Copyright (C) 1990-1994 Lucid, Inc. | |
1336 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved. | |
2505 | 1337 Copyright (C) 1994-1996 Board of Trustees, University of Illinois. |
1338 Copyright (C) 1995-2005 Ben Wing.\n") | |
1339 )) | |
438 | 1340 |
2505 | 1341 (defun splash-screen-tty-body () |
1342 `( | |
1343 (face italic "[`C-' means the control key, `M-' means the meta key]\n\n") | |
428 | 1344 ,@(if (string-match "beta" emacs-version) |
438 | 1345 `((key describe-beta) |
428 | 1346 ": " (face (red bold) |
1347 "This is an Experimental version of XEmacs.\n")) | |
1348 `( "\n")) | |
1349 ((key xemacs-local-faq) | |
2505 | 1350 ": Read the XEmacs FAQ. (A " (face underline "capital") " F!)\n") |
1351 ((key info) ": Read the on-line documentation.\n") | |
428 | 1352 ((key help-command) |
2505 | 1353 ": Get help on using XEmacs.\n") |
1354 ((key help-with-tutorial) | |
1355 ": Read the XEmacs tutorial.\n") | |
1356 ((key view-sample-init-el) | |
1357 ": View the sample init.el file.\n") | |
1358 ((key about-xemacs) ": See who's developing XEmacs.\n") | |
1359 ((key save-buffers-kill-emacs) | |
1360 ": exit XEmacs\n") | |
1361 "\n" | |
1362 (face (bold blue) "XEmacs website: ") | |
1363 "http://www.xemacs.org/\n\n" | |
1364 (face italic "\ | |
1365 Copyright (C) 1985-1999 Free Software Foundation, Inc. | |
1366 Copyright (C) 1990-1994 Lucid, Inc. | |
1367 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved. | |
1368 Copyright (C) 1994-1996 Board of Trustees, University of Illinois. | |
1369 Copyright (C) 1995-2004 Ben Wing.") | |
1370 ; ((key find-file) ": visit a file; ") | |
1371 ; ((key save-buffer) ": save changes; ") | |
1372 ; ((key undo) ": undo changes; ") | |
1373 )) | |
428 | 1374 |
1375 ;; I really hate global variables, oh well. | |
1376 ;(defvar xemacs-startup-logo-function nil | |
1377 ; "If non-nil, function called to provide the startup logo. | |
1378 ;This function should return an initialized glyph if it is used.") | |
1379 | |
438 | 1380 ;; This will hopefully go away when gettext is functional. |
2505 | 1381 (defconst splash-screen-static-body |
1382 `(,(emacs-version) "\n\n")) | |
1383 ;; temporary support for old locale files. | |
1384 (define-obsolete-variable-alias 'splash-frame-static-body | |
1385 'splash-screen-static-body) | |
428 | 1386 |
2505 | 1387 (defun display-splash-screen () |
1388 ;; display the splash screen in the current buffer and put it in the | |
1389 ;; current window. | |
428 | 1390 (let ((logo xemacs-logo) |
1391 (buffer-read-only nil) | |
2505 | 1392 (tty (eq 'tty (console-type)))) |
1393 (unless tty | |
1394 (insert "\n") | |
1395 (indent-to (startup-center-spaces logo)) | |
1396 (set-extent-begin-glyph (make-extent (point) (point)) logo) | |
1397 ;;(splash-screen-present-hack (make-extent p (point)) 'about-xemacs)) | |
1398 (insert "\n\n")) | |
1399 (splash-screen-present splash-screen-static-body) | |
428 | 1400 (splash-hack-version-string) |
1401 (goto-char (point-max)) | |
1402 (let* ((after-change-functions nil) ; no font-lock, thank you | |
2505 | 1403 (elements (cond (tty (splash-screen-tty-body)) |
1404 (t (splash-screen-window-body))))) | |
1405 (splash-screen-present elements) | |
1406 (set-buffer-modified-p nil)))) | |
1407 | |
1408 (defun xemacs-splash-buffer () | |
1409 "Display XEmacs splash screen in a buffer." | |
1410 (interactive) | |
1411 (let ((buffer (get-buffer-create "*Splash*"))) | |
1412 (set-buffer buffer) | |
1413 (setq buffer-read-only nil) | |
1414 (erase-buffer buffer) | |
3643 | 1415 (pop-to-buffer buffer) |
1416 (delete-other-windows) | |
2505 | 1417 (display-splash-screen))) |
428 | 1418 |
1419 ;; (let ((present-file | |
1420 ;; #'(lambda (f) | |
2505 | 1421 ;; (splash-screen-present |
428 | 1422 ;; (list 'funcall |
1423 ;; (list 'find-file-other-window | |
1424 ;; (expand-file-name f data-directory)) | |
1425 ;; f))))) | |
1426 ;; (insert "For customization examples, see the files ") | |
2505 | 1427 ;; (funcall present-file "sample.init.el") |
428 | 1428 ;; (insert " and ") |
1389 | 1429 ;; (funcall present-file "sample.Xresources") |
428 | 1430 ;; (insert (format "\nin the directory %s." data-directory))) |
1431 | |
2505 | 1432 |
428 | 1433 (defun startup-set-invocation-environment () |
1434 ;; XEmacs -- Steven Baur says invocation directory is nil if you | |
1435 ;; try to use XEmacs as a login shell. | |
1436 (or invocation-directory (setq invocation-directory default-directory)) | |
1437 (setq invocation-directory | |
1438 ;; don't let /tmp_mnt/... get into the load-path or exec-path. | |
1439 (abbreviate-file-name invocation-directory))) | |
1440 | |
2456 | 1441 ;;; High-level functions to set up the paths. |
1442 | |
1443 (defun startup-find-load-path (&optional inhibit-packages | |
1444 set-global-package-paths) | |
1445 "Determine the value for `load-path'. | |
1446 INHIBIT-PACKAGES says which types of packages, if any, to omit from the | |
1447 returned value. It can be `t' (omit all), one of the symbols `early', | |
1448 `late', or `last', or a list of one or more of the symbols. | |
1449 | |
1450 If SET-GLOBAL-PACKAGE-PATHS is non-nil, initialize the global package path | |
1451 variables referring to the particular types of packages | |
1452 (`early-package-hierarchies', `early-package-load-path', | |
1453 `late-package-hierarchies', `late-package-load-path', | |
1454 `last-package-hierarchies', `last-package-load-path')." | |
1455 (let (earlyp latep lastp earlyp-lp latep-lp lastp-lp) | |
1456 (apply #'(lambda (early late last) | |
1457 (setq earlyp (and (not (memq 'early inhibit-packages)) early)) | |
1458 (setq latep (and (not (memq 'late inhibit-packages)) late)) | |
1459 (setq lastp (and (not (memq 'last inhibit-packages)) last))) | |
1460 (packages-find-all-package-hierarchies | |
1461 emacs-data-roots)) | |
1462 | |
1463 (setq earlyp-lp (packages-find-package-load-path earlyp)) | |
1464 (setq latep-lp (packages-find-package-load-path latep)) | |
1465 (setq lastp-lp (packages-find-package-load-path lastp)) | |
1466 | |
1467 (when set-global-package-paths | |
1468 (setq early-package-hierarchies earlyp | |
1469 late-package-hierarchies latep | |
1470 last-package-hierarchies lastp | |
1471 early-package-load-path earlyp-lp | |
1472 late-package-load-path latep-lp | |
1473 last-package-load-path lastp-lp)) | |
1474 | |
1475 (paths-construct-load-path emacs-roots earlyp-lp latep-lp lastp-lp | |
1476 lisp-directory site-directory | |
1477 mule-lisp-directory))) | |
1478 | |
1479 (defun startup-setup-paths (&optional inhibit-packages called-early) | |
1480 "Setup all the various paths. | |
1481 INHIBIT-PACKAGES says which types of packages, if any, to omit from the | |
1482 returned value. It can be `t' (omit all), one of the symbols `early', | |
1483 `late', or `last', or a list of one or more of the symbols. | |
1484 | |
1485 This function is idempotent, so call this as often as you like!" | |
1486 | |
1487 (setq debug-paths (or debug-paths | |
1488 (and (getenv "EMACSDEBUGPATHS") | |
1489 t))) | |
1490 | |
1491 (setq emacs-roots (paths-find-emacs-roots invocation-directory invocation-name | |
4093 | 1492 #'paths-emacs-root-p)) |
2456 | 1493 |
1494 (setq emacs-data-roots (paths-find-emacs-roots invocation-directory invocation-name | |
1495 #'paths-emacs-data-root-p)) | |
1496 | |
1497 (if (null emacs-roots) | |
1498 (save-excursion | |
1499 (set-buffer (get-buffer-create " *warning-tmp*")) | |
1500 (erase-buffer) | |
1501 (buffer-disable-undo (current-buffer)) | |
1502 | |
1503 (insert "Couldn't find an obvious default for the root of the\n" | |
1504 "XEmacs hierarchy.") | |
1505 | |
1506 (princ "\nWARNING:\n" 'external-debugging-output) | |
1507 (princ (buffer-string) 'external-debugging-output))) | |
1508 | |
1509 (if (eq inhibit-packages t) | |
1510 (setq inhibit-packages '(early late last))) | |
1511 (if (not (listp inhibit-packages)) | |
1512 (setq inhibit-packages (list inhibit-packages))) | |
1513 | |
1514 (when debug-paths | |
1515 (princ (format | |
1516 "startup-setup-paths arguments: | |
1517 inhibit-packages: %S | |
1518 inhibit-site-lisp: %S | |
1519 called-early: %S | |
1520 " inhibit-packages inhibit-site-lisp called-early) | |
1521 'external-debugging-output) | |
1522 (princ (format | |
1523 "emacs-roots: | |
1524 %S | |
1525 emacs-data-roots: | |
1526 %S | |
1527 user-init-directory: %S | |
1528 configure-package-path: %S | |
1529 " emacs-roots emacs-data-roots user-init-directory configure-package-path) | |
1530 'external-debugging-output) | |
1531 ) | |
1532 | |
1533 (setq lisp-directory (paths-find-lisp-directory emacs-roots)) | |
1534 | |
1535 (if debug-paths | |
3985 | 1536 (princ (format "configure-lisp-directory and lisp-directory:\n%S\n%S\n" |
1537 configure-lisp-directory lisp-directory) | |
2456 | 1538 'external-debugging-output)) |
1539 | |
1540 (if (featurep 'mule) | |
1541 (progn | |
1542 (setq mule-lisp-directory | |
1543 (paths-find-mule-lisp-directory emacs-roots | |
1544 lisp-directory)) | |
1545 (if debug-paths | |
3985 | 1546 (princ (format "configure-mule-lisp-directory and mule-lisp-directory:\n%S\n%S\n" |
1547 configure-mule-lisp-directory mule-lisp-directory) | |
2456 | 1548 'external-debugging-output))) |
1549 (setq mule-lisp-directory '())) | |
1550 | |
1551 (setq site-directory (and (null inhibit-site-lisp) | |
1552 (paths-find-site-lisp-directory emacs-roots))) | |
1553 | |
1554 (if (and debug-paths (null inhibit-site-lisp)) | |
3985 | 1555 (princ (format "configure-site-directory and site-directory:\n%S\n%S\n" |
1556 configure-site-directory site-directory) | |
2456 | 1557 'external-debugging-output)) |
1558 | |
1559 (setq load-path (startup-find-load-path inhibit-packages t)) | |
1560 | |
1561 (when debug-paths | |
3985 | 1562 (princ (format "configure-early-package-directories, early-package-hierarchies and early-package-load-path:\n%S\n%S\n%S\n" |
1563 configure-early-package-directories early-package-hierarchies early-package-load-path) | |
2456 | 1564 'external-debugging-output) |
3985 | 1565 (princ (format "configure-late-package-directories, late-package-hierarchies and late-package-load-path:\n%S\n%S\n" |
1566 configure-late-package-directories late-package-hierarchies late-package-load-path) | |
2456 | 1567 'external-debugging-output) |
3985 | 1568 (princ (format "configure-last-package-directories, last-package-hierarchies and last-package-load-path:\n%S\n%S\n" |
1569 configure-last-package-directories last-package-hierarchies last-package-load-path) | |
2456 | 1570 'external-debugging-output)) |
1571 | |
1572 (if debug-paths | |
1573 (princ (format "load-path:\n%S\n" load-path) | |
1574 'external-debugging-output)) | |
1575 (setq module-directory (paths-find-module-directory emacs-roots)) | |
1576 (if debug-paths | |
3985 | 1577 (princ (format "configure-module-directory and module-directory:\n%S\n" |
1578 configure-module-directory module-directory) | |
2456 | 1579 'external-debugging-output)) |
1580 (setq site-module-directory (and (null inhibit-site-modules) | |
1581 (paths-find-site-module-directory | |
1582 emacs-roots))) | |
1583 (if (and debug-paths (null inhibit-site-modules)) | |
3985 | 1584 (princ (format "configure-site-module-directory and site-module-directory:\n%S\n%S\n" |
1585 configure-site-module-directory site-module-directory) | |
2456 | 1586 'external-debugging-output)) |
1587 | |
1588 (setq module-load-path (paths-construct-module-load-path | |
1589 emacs-roots | |
1590 module-directory | |
1591 site-module-directory)) | |
1592 | |
1593 (unless called-early | |
1594 (setq Info-directory-list | |
1595 (paths-construct-info-path | |
1596 emacs-roots | |
1597 early-package-hierarchies late-package-hierarchies last-package-hierarchies)) | |
1598 | |
1599 (if debug-paths | |
3985 | 1600 (princ (format "configure-info-directory, configure-info-path and Info-directory-list:\n%S\n%S\n%S\n" |
1601 configure-info-directory configure-info-path Info-directory-list) | |
2456 | 1602 'external-debugging-output)) |
1603 | |
1604 (setq exec-directory (paths-find-exec-directory emacs-roots)) | |
1605 | |
1606 (if debug-paths | |
3985 | 1607 (princ (format "configure-exec-directory and exec-directory:\n%S\n%S\n" |
1608 configure-exec-directory exec-directory) | |
2456 | 1609 'external-debugging-output)) |
1610 | |
1611 (setq exec-path | |
1612 (paths-construct-exec-path emacs-roots exec-directory | |
1613 early-package-hierarchies late-package-hierarchies | |
1614 last-package-hierarchies)) | |
1615 | |
1616 (if debug-paths | |
1617 (princ (format "exec-path:\n%S\n" exec-path) | |
1618 'external-debugging-output)) | |
1619 | |
1620 (setq doc-directory (paths-find-doc-directory emacs-roots)) | |
1621 | |
1622 (if debug-paths | |
3985 | 1623 (princ (format "configure-doc-directory and doc-directory:\n%S\n%S\n" |
1624 configure-doc-directory doc-directory) | |
2456 | 1625 'external-debugging-output)) |
1626 | |
1627 (setq data-directory (paths-find-data-directory emacs-roots)) | |
1628 | |
1629 (if debug-paths | |
3985 | 1630 (princ (format "configure-data-directory and data-directory:\n%S\n%S\n" |
1631 configure-data-directory data-directory) | |
2456 | 1632 'external-debugging-output)) |
1633 | |
1634 (setq data-directory-list (paths-construct-data-directory-list | |
1635 data-directory early-package-hierarchies | |
1636 late-package-hierarchies last-package-hierarchies)) | |
1637 (if debug-paths | |
1638 (princ (format "data-directory-list:\n%S\n" data-directory-list) | |
1639 'external-debugging-output)))) | |
1640 | |
1641 (defun startup-find-load-path-for-packages (packages) | |
1642 "Return a suitable load-path for PACKAGES. | |
1643 PACKAGES is a list of package names (strings). This looks for package | |
1644 directories in the load path whose last component is one of the members of | |
1645 PACKAGES." | |
1646 (mapcan | |
1647 #'(lambda (package) | |
1648 (and (member (file-name-nondirectory (directory-file-name package)) | |
1649 packages) | |
1650 (list package))) | |
1651 (startup-find-load-path))) | |
1652 | |
1653 ; (defun startup-set-basic-packages-load-path () | |
1654 ; "#### This is a hack. When recompiling .el files, we use -no-packages | |
1655 ; to avoid problems with packages shadowing standard Lisp files | |
1656 ; (e.g. unicode.el), but we really still need the stuff in xemacs-base and | |
1657 ; xemacs-devel." | |
1658 ; (setq load-path (startup-find-load-path-for-packages | |
1659 ; '("xemacs-base" "xemacs-devel")))) | |
1660 | |
428 | 1661 (defun startup-setup-paths-warning () |
442 | 1662 (let ((warnings '())) |
428 | 1663 (cond |
1664 ((null (and lisp-directory exec-directory data-directory doc-directory | |
442 | 1665 load-path)) |
428 | 1666 (save-excursion |
1667 (set-buffer (get-buffer-create " *warning-tmp*")) | |
1668 (erase-buffer) | |
1669 (buffer-disable-undo (current-buffer)) | |
1670 (if (null lisp-directory) (push "lisp-directory" warnings)) | |
460 | 1671 (if (and (featurep 'mule) |
1672 (null mule-lisp-directory)) | |
1673 (push "mule-lisp-directory" warnings)) | |
428 | 1674 (if (null exec-directory) (push "exec-directory" warnings)) |
1675 (if (null data-directory) (push "data-directory" warnings)) | |
1676 (if (null doc-directory) (push "doc-directory" warnings)) | |
1677 (if (null load-path) (push "load-path" warnings)) | |
1678 | |
1679 (insert "Couldn't find obvious defaults for:\n") | |
1680 (while warnings | |
1681 (insert (car warnings) "\n") | |
1682 (setq warnings (cdr warnings))) | |
1683 (insert "Perhaps some directories don't exist, " | |
1684 "or the XEmacs executable,\n" (concat invocation-directory | |
1685 invocation-name) | |
1686 "\nis in a strange place?") | |
1687 | |
1688 (princ "\nWARNING:\n" 'external-debugging-output) | |
1689 (princ (buffer-string) 'external-debugging-output) | |
1690 (erase-buffer) | |
1691 t))))) | |
1692 | |
2456 | 1693 |
1694 ;;; Now actually set the paths up, for bootstrapping purposes. This is run | |
1695 ;;; at early dump time and in certain cases where we use a minimal temacs | |
1696 ;;; to do useful things, like rebuild DOC. | |
1697 | |
1698 (startup-setup-paths (if inhibit-all-packages t '(early last)) t) | |
1699 | |
1700 | |
528 | 1701 (defun startup-load-autoloads () |
1232 | 1702 (when (and (not inhibit-autoloads) lisp-directory) |
1703 (load (expand-file-name (file-name-sans-extension autoload-file-name) | |
1704 lisp-directory) | |
1705 nil t) | |
1706 (when (featurep 'mule) | |
528 | 1707 (load (expand-file-name (file-name-sans-extension autoload-file-name) |
1232 | 1708 (file-name-as-directory |
1709 (expand-file-name "mule" lisp-directory))) | |
1710 nil t))) | |
528 | 1711 |
996 | 1712 ;; Hey! Let's use a packages-* function for a non-package purpose! |
1232 | 1713 (when (and (not inhibit-autoloads) (featurep 'modules)) |
1714 (packages-load-package-auto-autoloads module-load-path)) | |
996 | 1715 |
1232 | 1716 (unless (or inhibit-autoloads inhibit-all-packages) |
1717 (unless inhibit-early-packages | |
1718 (packages-load-package-auto-autoloads early-package-load-path)) | |
1719 (packages-load-package-auto-autoloads late-package-load-path) | |
1720 (packages-load-package-auto-autoloads last-package-load-path))) | |
528 | 1721 |
428 | 1722 ;;; startup.el ends here |