]> code.delx.au - gnu-emacs/blob - lisp/startup.el
(command-line): Don't register default colors for
[gnu-emacs] / lisp / startup.el
1 ;;; startup.el --- process Emacs shell arguments
2
3 ;; Copyright (C) 1985, 86, 92, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: internal
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; This file parses the command line and gets Emacs running. Options on
28 ;; the command line are handled in precedence order. The order is the
29 ;; one in the list below; first described means first handled. Options
30 ;; within each category (delimited by a bar) are handled in the order
31 ;; encountered on the command line.
32
33 ;; -------------------------
34 ;; -version Print Emacs version to stderr, then exit
35 ;; --version successfully right away.
36 ;; This option is handled by emacs.c
37 ;; -------------------------
38 ;; -help Print a short usage description and exit
39 ;; --help successfully right away.
40 ;; This option is handled by emacs.c
41 ;; -------------------------
42 ;; -nl Do not use shared memory (for systems that
43 ;; -no-shared-memory support this) for the dumped Emacs data.
44 ;; This option is handled by emacs.c
45 ;;
46 ;; -map For VMS.
47 ;; --map-data This option is handled by emacs.c
48 ;; -------------------------
49 ;; -t FILE Use FILE as the name of the terminal.
50 ;; --terminal FILE Using this implies "-nw" also.
51 ;; This option is handled by emacs.c
52 ;; -------------------------
53 ;; -d DISPNAME Use DISPNAME as the name of the X-windows
54 ;; -display DISPNAME display for the initial frame.
55 ;; --display DISPNAME This option is handled by emacs.c
56 ;; -------------------------
57 ;; -nw Do not use a windows system (but use the
58 ;; --no-windows terminal instead.)
59 ;; This option is handled by emacs.c
60 ;; -------------------------
61 ;; -batch Execute noninteractively (messages go to stdout,
62 ;; --batch variable noninteractive set to t)
63 ;; This option is handled by emacs.c
64 ;; -------------------------
65 ;; -q Do not load user's init file and do not load
66 ;; -no-init-file "default.el". Regardless of this switch,
67 ;; --no-init-file "site-start" is still loaded.
68 ;; -------------------------
69 ;; -no-site-file Do not load "site-start.el". (This is the ONLY
70 ;; --no-site-file way to prevent loading that file.)
71 ;; -------------------------
72 ;; -u USER Load USER's init file instead of the init
73 ;; -user USER file belonging to the user starting Emacs.
74 ;; --user USER
75 ;; -------------------------
76 ;; -debug-init Don't catch errors in init files; let the
77 ;; --debug-init debugger run.
78 ;; -------------------------
79 ;; -i ICONTYPE Set type of icon using when Emacs is
80 ;; -itype ICONTYPE iconified under X-windows.
81 ;; --icon-type ICONTYPE This option is passed on to term/x-win.el
82 ;;
83 ;; -iconic Start Emacs iconified under X-windows.
84 ;; --iconic This option is passed on to term/x-win.el
85 ;; -------------------------
86 ;; Various X-windows options for colors/fonts/geometry/title etc.
87 ;; These options are passed on to term/x-win.el which see. Certain
88 ;; of these are also found in term/pc-win.el
89 ;; -------------------------
90 ;; FILE Visit FILE.
91 ;;
92 ;; -L DIRNAME Add DIRNAME to load-path
93 ;; -directory DIRNAME
94 ;; --directory DIRNAME
95 ;;
96 ;; -l FILE Load and execute the Emacs lisp code
97 ;; -load FILE in FILE.
98 ;; --load FILE
99 ;;
100 ;; -f FUNC Execute Emacs lisp function FUNC with
101 ;; -funcall FUNC no arguments. The "-e" form is outdated
102 ;; --funcall FUNC and should not be used. (It's a typo
103 ;; -e FUNC promoted to a feature.)
104 ;;
105 ;; -eval FORM Execute Emacs lisp form FORM.
106 ;; --eval FORM
107 ;;
108 ;; -insert FILE Insert the contents of FILE into buffer.
109 ;; --insert FILE
110 ;; -------------------------
111 ;; -kill Kill (exit) Emacs right away.
112 ;; --kill
113 ;; -------------------------
114
115 ;;; Code:
116
117 (setq top-level '(normal-top-level))
118
119 (defvar command-line-processed nil
120 "Non-nil once command line has been processed")
121
122 (defgroup initialization nil
123 "Emacs start-up procedure"
124 :group 'internal)
125
126 (defcustom inhibit-startup-message nil
127 "*Non-nil inhibits the initial startup message.
128 This is for use in your personal init file, once you are familiar
129 with the contents of the startup message."
130 :type 'boolean
131 :group 'initialization)
132
133 (defcustom inhibit-startup-echo-area-message nil
134 "*Non-nil inhibits the initial startup echo area message.
135 Setting this variable takes effect
136 only if you do it with the customization buffer
137 or if your `.emacs' file contains a line of this form:
138 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
139 If your `.emacs' file is byte-compiled, use the following form instead:
140 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
141 Thus, someone else using a copy of your `.emacs' file will see
142 the startup message unless he personally acts to inhibit it."
143 :type '(choice (const :tag "Don't inhibit")
144 (string :tag "Enter your user name, to inhibit"))
145 :group 'initialization)
146
147 (defcustom inhibit-default-init nil
148 "*Non-nil inhibits loading the `default' library."
149 :type 'boolean
150 :group 'initialization)
151
152 (defvar command-switch-alist nil
153 "Alist of command-line switches.
154 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
155 HANDLER-FUNCTION receives switch name as sole arg;
156 remaining command-line args are in the variable `command-line-args-left'.")
157
158 (defvar command-line-args-left nil
159 "List of command-line args not yet processed.")
160
161 (defvar command-line-functions nil ;; lrs 7/31/89
162 "List of functions to process unrecognized command-line arguments.
163 Each function should access the dynamically bound variables
164 `argi' (the current argument) and `command-line-args-left' (the remaining
165 arguments). The function should return non-nil only if it recognizes and
166 processes `argi'. If it does so, it may consume successive arguments by
167 altering `command-line-args-left' to remove them.")
168
169 (defvar command-line-default-directory nil
170 "Default directory to use for command line arguments.
171 This is normally copied from `default-directory' when Emacs starts.")
172
173 ;;; This is here, rather than in x-win.el, so that we can ignore these
174 ;;; options when we are not using X.
175 (defvar command-line-x-option-alist
176 '(("-bw" 1 x-handle-numeric-switch border-width)
177 ("-d" 1 x-handle-display)
178 ("-display" 1 x-handle-display)
179 ("-name" 1 x-handle-name-switch)
180 ("-title" 1 x-handle-switch title)
181 ("-T" 1 x-handle-switch title)
182 ("-r" 0 x-handle-switch reverse t)
183 ("-rv" 0 x-handle-switch reverse t)
184 ("-reverse" 0 x-handle-switch reverse t)
185 ("-reverse-video" 0 x-handle-switch reverse t)
186 ("-fn" 1 x-handle-switch font)
187 ("-font" 1 x-handle-switch font)
188 ("-ib" 1 x-handle-numeric-switch internal-border-width)
189 ("-g" 1 x-handle-geometry)
190 ("-geometry" 1 x-handle-geometry)
191 ("-fg" 1 x-handle-switch foreground-color)
192 ("-foreground" 1 x-handle-switch foreground-color)
193 ("-bg" 1 x-handle-switch background-color)
194 ("-background" 1 x-handle-switch background-color)
195 ("-ms" 1 x-handle-switch mouse-color)
196 ("-itype" 0 x-handle-switch icon-type t)
197 ("-i" 0 x-handle-switch icon-type t)
198 ("-iconic" 0 x-handle-iconic)
199 ("-xrm" 1 x-handle-xrm-switch)
200 ("-cr" 1 x-handle-switch cursor-color)
201 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
202 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
203 ("-bd" 1 x-handle-switch)
204 ("--border-width" 1 x-handle-numeric-switch border-width)
205 ("--display" 1 x-handle-display)
206 ("--name" 1 x-handle-name-switch)
207 ("--title" 1 x-handle-switch title)
208 ("--reverse-video" 0 x-handle-switch reverse t)
209 ("--font" 1 x-handle-switch font)
210 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
211 ("--geometry" 1 x-handle-geometry)
212 ("--foreground-color" 1 x-handle-switch foreground-color)
213 ("--background-color" 1 x-handle-switch background-color)
214 ("--mouse-color" 1 x-handle-switch mouse-color)
215 ("--icon-type" 0 x-handle-switch icon-type t)
216 ("--iconic" 0 x-handle-iconic)
217 ("--xrm" 1 x-handle-xrm-switch)
218 ("--cursor-color" 1 x-handle-switch cursor-color)
219 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
220 ("--border-color" 1 x-handle-switch border-width))
221 "Alist of X Windows options.
222 Each element has the form
223 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
224 where NAME is the option name string, NUMARGS is the number of arguments
225 that the option accepts, HANDLER is a function to call to handle the option.
226 FRAME-PARAM (optional) is the frame parameter this option specifies,
227 and VALUE is the value which is given to that frame parameter
228 \(most options use the argument for this, so VALUE is not present).")
229
230 (defvar before-init-hook nil
231 "Normal hook run after handling urgent options but before loading init files.")
232
233 (defvar after-init-hook nil
234 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
235 There is no `condition-case' around the running of these functions;
236 therefore, if you set `debug-on-error' non-nil in `.emacs',
237 an error in one of these functions will invoke the debugger.")
238
239 (defvar emacs-startup-hook nil
240 "Normal hook run after loading init files and handling the command line.")
241
242 (defvar term-setup-hook nil
243 "Normal hook run after loading terminal-specific Lisp code.
244 It also follows `emacs-startup-hook'. This hook exists for users to set,
245 so as to override the definitions made by the terminal-specific file.
246 Emacs never sets this variable itself.")
247
248 (defvar keyboard-type nil
249 "The brand of keyboard you are using.
250 This variable is used to define
251 the proper function and keypad keys for use under X. It is used in a
252 fashion analogous to the environment variable TERM.")
253
254 (defvar window-setup-hook nil
255 "Normal hook run to initialize window system display.
256 Emacs runs this hook after processing the command line arguments and loading
257 the user's init file.")
258
259 (defcustom initial-major-mode 'lisp-interaction-mode
260 "Major mode command symbol to use for the initial *scratch* buffer."
261 :type 'function
262 :group 'initialization)
263
264 (defcustom init-file-user nil
265 "Identity of user whose `.emacs' file is or was read.
266 The value is nil if `-q' or `--no-init-file' was specified,
267 meaning do not load any init file.
268
269 Otherwise, the value may be the null string, meaning use the init file
270 for the user that originally logged in, or it may be a
271 string containing a user's name meaning use that person's init file.
272
273 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
274 evaluates to the name of the directory where the `.emacs' file was
275 looked for.
276
277 Setting `init-file-user' does not prevent Emacs from loading
278 `site-start.el'. The only way to do that is to use `--no-site-file'."
279 :type '(choice (const :tag "none" nil) string)
280 :group 'initialization)
281
282 (defcustom site-run-file "site-start"
283 "File containing site-wide run-time initializations.
284 This file is loaded at run-time before `~/.emacs'. It contains inits
285 that need to be in place for the entire site, but which, due to their
286 higher incidence of change, don't make sense to load into emacs'
287 dumped image. Thus, the run-time load order is: 1. file described in
288 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
289
290 Don't use the `site-start.el' file for things some users may not like.
291 Put them in `default.el' instead, so that users can more easily
292 override them. Users can prevent loading `default.el' with the `-q'
293 option or by setting `inhibit-default-init' in their own init files,
294 but inhibiting `site-start.el' requires `--no-site-file', which
295 is less convenient."
296 :type '(choice (const :tag "none" nil) string)
297 :group 'initialization)
298
299 (defconst iso-8859-n-locale-regexp "8859[-_]?\\([1-49]\\)\\>"
300 "Regexp that specifies when to enable an ISO 8859-N character set.
301 We do that if this regexp matches the locale name specified by
302 one of the environment variables LC_ALL, LC_CTYPE, or LANG.
303 The paren group in the regexp should match the specific character
304 set number, N. Currently only Latin-[12345] are supported.
305 \(Note that Latin-5 is ISO 8859-9, because 8859-[678] are non-Latin
306 alphabets; hence, supported values of N are [12349].\)")
307
308 (defcustom mail-host-address nil
309 "*Name of this machine, for purposes of naming users."
310 :type '(choice (const nil) string)
311 :group 'mail)
312
313 (defcustom user-mail-address nil
314 "*Full mailing address of this user.
315 This is initialized based on `mail-host-address',
316 after your init file is read, in case it sets `mail-host-address'."
317 :type 'string
318 :group 'mail)
319
320 (defcustom auto-save-list-file-prefix
321 (if (eq system-type 'ms-dos)
322 "~/_s" ; MS-DOS cannot have initial dot, and allows only 8.3 names
323 "~/.saves-")
324 "Prefix for generating `auto-save-list-file-name'.
325 This is used after reading your `.emacs' file to initialize
326 `auto-save-list-file-name', by appending Emacs's pid and the system name,
327 if you have not already set `auto-save-list-file-name' yourself.
328 Set this to nil if you want to prevent `auto-save-list-file-name'
329 from being initialized."
330 :type '(choice (const :tag "Don't record a session's auto save list" nil)
331 string)
332 :group 'auto-save)
333
334 (defvar locale-translation-file-name
335 (let ((files '("/usr/lib/X11/locale/locale.alias" ; e.g. X11R6.4
336 "/usr/X11R6/lib/X11/locale/locale.alias" ; e.g. RedHat 4.2
337 "/usr/openwin/lib/locale/locale.alias" ; e.g. Solaris 2.6
338 ;;
339 ;; The following name appears after the X-related names above,
340 ;; since the X-related names are what X actually uses.
341 "/usr/share/locale/locale.alias" ; GNU/Linux sans X
342 )))
343 (while (and files (not (file-exists-p (car files))))
344 (setq files (cdr files)))
345 (car files))
346 "*File name for the system's file of locale-name aliases, or nil if none.")
347
348 (defvar init-file-debug nil)
349
350 (defvar init-file-had-error nil)
351
352 (defvar normal-top-level-add-subdirs-inode-list nil)
353
354 (defun normal-top-level-add-subdirs-to-load-path ()
355 "Add all subdirectories of current directory to `load-path'.
356 More precisely, this uses only the subdirectories whose names
357 start with letters or digits; it excludes any subdirectory named `RCS'
358 or `CVS', and any subdirectory that contains a file named `.nosearch'."
359 (let (dirs
360 attrs
361 (pending (list default-directory)))
362 ;; This loop does a breadth-first tree walk on DIR's subtree,
363 ;; putting each subdir into DIRS as its contents are examined.
364 (while pending
365 (setq dirs (cons (car pending) dirs))
366 (setq pending (cdr pending))
367 (setq attrs (nthcdr 10 (file-attributes (car dirs))))
368 (let ((contents (directory-files (car dirs)))
369 (default-directory (car dirs)))
370 (unless (member attrs normal-top-level-add-subdirs-inode-list)
371 (setq normal-top-level-add-subdirs-inode-list
372 (cons attrs normal-top-level-add-subdirs-inode-list))
373 (while contents
374 (unless (member (car contents) '("." ".." "RCS" "CVS"))
375 (when (and (string-match "\\`[a-zA-Z0-9]" (car contents))
376 ;; Avoid doing a `stat' when it isn't necessary
377 ;; because that can cause trouble when an NFS server
378 ;; is down.
379 (not (string-match "\\.elc?\\'" (car contents)))
380 (file-directory-p (car contents)))
381 (let ((expanded (expand-file-name (car contents))))
382 (unless (file-exists-p (expand-file-name ".nosearch"
383 expanded))
384 (setq pending (nconc pending (list expanded)))))))
385 (setq contents (cdr contents))))))
386 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
387
388 ;; This function is called from a subdirs.el file.
389 ;; It assumes that default-directory is the directory
390 ;; in which the subdirs.el file exists,
391 ;; and it adds to load-path the subdirs of that directory
392 ;; as specified in DIRS. Normally the elements of DIRS are relative.
393 (defun normal-top-level-add-to-load-path (dirs)
394 (let ((tail load-path)
395 (thisdir (directory-file-name default-directory)))
396 (while (and tail
397 (not (equal thisdir (car tail)))
398 (not (and (memq system-type '(ms-dos windows-nt))
399 (equal (downcase thisdir) (downcase (car tail))))))
400 (setq tail (cdr tail)))
401 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail)))))
402
403 (defun normal-top-level ()
404 (if command-line-processed
405 (message "Back to top level.")
406 (setq command-line-processed t)
407 ;; Give *Messages* the same default-directory as *scratch*,
408 ;; just to keep things predictable.
409 (let ((dir default-directory))
410 (save-excursion
411 (set-buffer (get-buffer "*Messages*"))
412 (setq default-directory dir)))
413 ;; For root, preserve owner and group when editing files.
414 (if (equal (user-uid) 0)
415 (setq backup-by-copying-when-mismatch t))
416 ;; Look in each dir in load-path for a subdirs.el file.
417 ;; If we find one, load it, which will add the appropriate subdirs
418 ;; of that dir into load-path,
419 (let ((tail load-path)
420 new)
421 (while tail
422 (setq new (cons (car tail) new))
423 (let ((default-directory (car tail)))
424 (load (expand-file-name "subdirs.el" (car tail)) t t t))
425 (setq tail (cdr tail))))
426 (if (not (eq system-type 'vax-vms))
427 (progn
428 ;; If the PWD environment variable isn't accurate, delete it.
429 (let ((pwd (getenv "PWD")))
430 (and (stringp pwd)
431 ;; Use FOO/., so that if FOO is a symlink, file-attributes
432 ;; describes the directory linked to, not FOO itself.
433 (or (equal (file-attributes
434 (concat (file-name-as-directory pwd) "."))
435 (file-attributes
436 (concat (file-name-as-directory default-directory)
437 ".")))
438 (setq process-environment
439 (delete (concat "PWD=" pwd)
440 process-environment)))))))
441 (setq default-directory (abbreviate-file-name default-directory))
442 (let ((menubar-bindings-done nil))
443 (unwind-protect
444 (command-line)
445 ;; Do this again, in case .emacs defined more abbreviations.
446 (setq default-directory (abbreviate-file-name default-directory))
447 ;; Specify the file for recording all the auto save files of this session.
448 ;; This is used by recover-session.
449 (or auto-save-list-file-name
450 (and auto-save-list-file-prefix
451 (setq auto-save-list-file-name
452 ;; Under MS-DOS our PID is almost always reused between
453 ;; Emacs invocations. We need something more unique.
454 (if (eq system-type 'ms-dos)
455 (concat
456 (make-temp-name
457 (expand-file-name auto-save-list-file-prefix))
458 "~")
459
460 (expand-file-name (format "%s%d-%s~"
461 auto-save-list-file-prefix
462 (emacs-pid)
463 (system-name)))))))
464 (run-hooks 'emacs-startup-hook)
465 (and term-setup-hook
466 (run-hooks 'term-setup-hook))
467 ;; Modify the initial frame based on what .emacs puts into
468 ;; ...-frame-alist.
469 (if (fboundp 'frame-notice-user-settings)
470 (frame-notice-user-settings))
471 ;; Now we know the user's default font, so add it to the menu.
472 (if (fboundp 'font-menu-add-default)
473 (font-menu-add-default))
474 (and window-setup-hook
475 (run-hooks 'window-setup-hook))
476 (or menubar-bindings-done
477 (if (memq window-system '(x w32))
478 (precompute-menubar-bindings)))))))
479
480 ;; Precompute the keyboard equivalents in the menu bar items.
481 (defun precompute-menubar-bindings ()
482 (let ((submap (lookup-key global-map [menu-bar])))
483 (while submap
484 (and (consp (car submap))
485 (symbolp (car (car submap)))
486 (stringp (car-safe (cdr (car submap))))
487 (keymapp (cdr (cdr (car submap))))
488 (progn
489 (x-popup-menu nil (cdr (cdr (car submap))))
490 (if purify-flag
491 (garbage-collect))))
492 (setq submap (cdr submap))))
493 (setq define-key-rebound-commands t))
494
495 (defun command-line ()
496 (setq command-line-default-directory default-directory)
497
498 ;; Choose a reasonable location for temporary files.
499 (setq temporary-file-directory
500 (file-name-as-directory
501 (cond ((memq system-type '(ms-dos windows-nt))
502 (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
503 ((memq system-type '(vax-vms axp-vms))
504 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
505 (t
506 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp")))))
507
508 ;; See if we should import version-control from the environment variable.
509 (let ((vc (getenv "VERSION_CONTROL")))
510 (cond ((eq vc nil)) ;don't do anything if not set
511 ((or (string= vc "t")
512 (string= vc "numbered"))
513 (setq version-control t))
514 ((or (string= vc "nil")
515 (string= vc "existing"))
516 (setq version-control nil))
517 ((or (string= vc "never")
518 (string= vc "simple"))
519 (setq version-control 'never))))
520
521 (let ((ctype
522 ;; Use the first of these three envvars that has a nonempty value.
523 (or (let ((string (getenv "LC_ALL")))
524 (and (not (equal string "")) string))
525 (let ((string (getenv "LC_CTYPE")))
526 (and (not (equal string "")) string))
527 (let ((string (getenv "LANG")))
528 (and (not (equal string "")) string)))))
529 ;; Translate "swedish" into "sv_SE.ISO-8859-1", and so on,
530 ;; using the translation file that GNU/Linux systems have.
531 (and ctype
532 locale-translation-file-name
533 (not (string-match iso-8859-n-locale-regexp ctype))
534 (with-temp-buffer
535 (insert-file-contents locale-translation-file-name)
536 (if (re-search-forward
537 (concat "^" (regexp-quote ctype) ":?[ \t]+") nil t)
538 (setq ctype (buffer-substring (point)
539 (progn (end-of-line) (point)))))))
540 ;; Now see if the locale specifies an ISO 8859 character set.
541 (when (and ctype
542 (string-match iso-8859-n-locale-regexp ctype))
543 (let (charset (which (match-string 1 ctype)))
544 (if (equal "9" which)
545 (setq which "5"))
546 (setq charset (concat "latin-" which))
547 (when (string-match "latin-[12345]" charset)
548 ;; Set up for this character set.
549 ;; This is now the right way to do it
550 ;; for both unibyte and multibyte modes.
551 (set-language-environment charset)
552 (unless (or noninteractive (eq window-system 'x))
553 ;; Send those codes literally to a non-X terminal.
554 (when default-enable-multibyte-characters
555 ;; If this is nil, we are using single-byte characters,
556 ;; so the terminal coding system is irrelevant.
557 (set-terminal-coding-system
558 (intern (downcase charset)))))
559 (standard-display-european-internal)))))
560
561 ;;! This has been commented out; I currently find the behavior when
562 ;;! split-window-keep-point is nil disturbing, but if I can get used
563 ;;! to it, then it would be better to eliminate the option.
564 ;;! ;; Choose a good default value for split-window-keep-point.
565 ;;! (setq split-window-keep-point (> baud-rate 2400))
566
567 ;; Set the default strings to display in mode line for
568 ;; end-of-line formats that aren't native to this platform.
569 (cond
570 ((memq system-type '(ms-dos windows-nt emx))
571 (setq eol-mnemonic-unix "(Unix)")
572 (setq eol-mnemonic-mac "(Mac)"))
573 ;; Mac-specific settings should come here, once there's a
574 ;; system-type symbol specific to MacOS.
575 (t ; this is for Unix/GNU/Linux systems
576 (setq eol-mnemonic-dos "(DOS)")
577 (setq eol-mnemonic-mac "(Mac)")))
578
579 ;; Read window system's init file if using a window system.
580 (condition-case error
581 (if (and window-system (not noninteractive))
582 (load (concat term-file-prefix
583 (symbol-name window-system)
584 "-win")
585 ;; Every window system should have a startup file;
586 ;; barf if we can't find it.
587 nil t))
588 ;; If we can't read it, print the error message and exit.
589 (error
590 (princ
591 (if (eq (car error) 'error)
592 (apply 'concat (cdr error))
593 (if (memq 'file-error (get (car error) 'error-conditions))
594 (format "%s: %s"
595 (nth 1 error)
596 (mapconcat '(lambda (obj) (prin1-to-string obj t))
597 (cdr (cdr error)) ", "))
598 (format "%s: %s"
599 (get (car error) 'error-message)
600 (mapconcat '(lambda (obj) (prin1-to-string obj t))
601 (cdr error) ", "))))
602 'external-debugging-output)
603 (setq window-system nil)
604 (kill-emacs)))
605
606 (let ((done nil)
607 (args (cdr command-line-args)))
608
609 ;; Figure out which user's init file to load,
610 ;; either from the environment or from the options.
611 (setq init-file-user (if noninteractive nil (user-login-name)))
612 ;; If user has not done su, use current $HOME to find .emacs.
613 (and init-file-user (string= init-file-user (user-real-login-name))
614 (setq init-file-user ""))
615
616 ;; Process the command-line args, and delete the arguments
617 ;; processed. This is consistent with the way main in emacs.c
618 ;; does things.
619 (while (and (not done) args)
620 (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
621 ("--debug-init") ("--iconic") ("--icon-type")))
622 (argi (car args))
623 (argval nil))
624 ;; Handle --OPTION=VALUE format.
625 (if (and (string-match "\\`--" argi)
626 (string-match "=" argi))
627 (setq argval (substring argi (match-end 0))
628 argi (substring argi 0 (match-beginning 0))))
629 (or (equal argi "--")
630 (let ((completion (try-completion argi longopts)))
631 (if (eq completion t)
632 (setq argi (substring argi 1))
633 (if (stringp completion)
634 (let ((elt (assoc completion longopts)))
635 (or elt
636 (error "Option `%s' is ambiguous" argi))
637 (setq argi (substring (car elt) 1)))
638 (setq argval nil)))))
639 (cond
640 ((or (string-equal argi "-q")
641 (string-equal argi "-no-init-file"))
642 (setq init-file-user nil
643 args (cdr args)))
644 ((or (string-equal argi "-u")
645 (string-equal argi "-user"))
646 (or argval
647 (setq args (cdr args)
648 argval (car args)))
649 (setq init-file-user argval
650 argval nil
651 args (cdr args)))
652 ((string-equal argi "-no-site-file")
653 (setq site-run-file nil
654 args (cdr args)))
655 ((string-equal argi "-debug-init")
656 (setq init-file-debug t
657 args (cdr args)))
658 ((string-equal argi "-iconic")
659 (setq initial-frame-alist
660 (cons '(visibility . icon) initial-frame-alist))
661 (setq args (cdr args)))
662 ((or (string-equal argi "-icon-type")
663 (string-equal argi "-i")
664 (string-equal argi "-itype"))
665 (setq default-frame-alist
666 (cons '(icon-type . t) default-frame-alist))
667 (setq args (cdr args)))
668 (t (setq done t)))
669 ;; Was argval set but not used?
670 (and argval
671 (error "Option `%s' doesn't allow an argument" argi))))
672
673 ;; Re-attach the program name to the front of the arg list.
674 (and command-line-args (setcdr command-line-args args)))
675
676 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
677 (if (fboundp 'frame-initialize)
678 (frame-initialize))
679 ;; If frame was created with a menu bar, set menu-bar-mode on.
680 (if (or (not (memq window-system '(x w32)))
681 (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
682 (menu-bar-mode t))
683
684 (run-hooks 'before-init-hook)
685
686 ;; Run the site-start library if it exists. The point of this file is
687 ;; that it is run before .emacs. There is no point in doing this after
688 ;; .emacs; that is useless.
689 (if site-run-file
690 (load site-run-file t t))
691
692 ;; Register available input methods by loading LEIM list file.
693 (load "leim-list.el" 'noerror 'nomessage 'nosuffix)
694
695 ;; Sites should not disable this. Only individuals should disable
696 ;; the startup message.
697 (setq inhibit-startup-message nil)
698
699 ;; Load that user's init file, or the default one, or none.
700 (let (debug-on-error-from-init-file
701 debug-on-error-should-be-set
702 (debug-on-error-initial
703 (if (eq init-file-debug t) 'startup init-file-debug))
704 (orig-enable-multibyte default-enable-multibyte-characters))
705 (let ((debug-on-error debug-on-error-initial)
706 ;; This function actually reads the init files.
707 (inner
708 (function
709 (lambda ()
710 (if init-file-user
711 (let ((user-init-file-1
712 (cond
713 ((eq system-type 'ms-dos)
714 (concat "~" init-file-user "/_emacs"))
715 ((eq system-type 'windows-nt)
716 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
717 "~/.emacs"
718 "~/_emacs"))
719 ((eq system-type 'vax-vms)
720 "sys$login:.emacs")
721 (t
722 (concat "~" init-file-user "/.emacs")))))
723 ;; This tells `load' to store the file name found
724 ;; into user-init-file.
725 (setq user-init-file t)
726 (load user-init-file-1 t t)
727 ;; If we did not find the user's init file,
728 ;; set user-init-file conclusively to nil;
729 ;; don't let it be set from default.el.
730 (if (eq user-init-file t)
731 (setq user-init-file nil))
732 (or inhibit-default-init
733 (let ((inhibit-startup-message nil))
734 ;; Users are supposed to be told their rights.
735 ;; (Plus how to get help and how to undo.)
736 ;; Don't you dare turn this off for anyone
737 ;; except yourself.
738 (load "default" t t)))))))))
739 (if init-file-debug
740 ;; Do this without a condition-case if the user wants to debug.
741 (funcall inner)
742 (condition-case error
743 (progn
744 (funcall inner)
745 (setq init-file-had-error nil))
746 (error (message "Error in init file: %s%s%s"
747 (get (car error) 'error-message)
748 (if (cdr error) ": " "")
749 (mapconcat 'prin1-to-string (cdr error) ", "))
750 (setq init-file-had-error t))))
751 ;; If we can tell that the init file altered debug-on-error,
752 ;; arrange to preserve the value that it set up.
753 (or (eq debug-on-error debug-on-error-initial)
754 (setq debug-on-error-should-be-set t
755 debug-on-error-from-init-file debug-on-error)))
756 (if debug-on-error-should-be-set
757 (setq debug-on-error debug-on-error-from-init-file))
758 (unless (or default-enable-multibyte-characters
759 (eq orig-enable-multibyte default-enable-multibyte-characters))
760 ;; Init file changed to unibyte. Reset existing multibyte
761 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
762 ;; Arguably this should only be done if they're free of
763 ;; multibyte characters.
764 (mapcar (lambda (buffer)
765 (with-current-buffer buffer
766 (if enable-multibyte-characters
767 (set-buffer-multibyte nil))))
768 (buffer-list))
769 ;; Also re-set the language environment in case it was
770 ;; originally done before unibyte was set and is sensitive to
771 ;; unibyte (display table, terminal coding system &c).
772 (set-language-environment current-language-environment)))
773
774 ;; Do this here in case the init file sets mail-host-address.
775 (or user-mail-address
776 (setq user-mail-address (concat (user-login-name) "@"
777 (or mail-host-address
778 (system-name)))))
779
780 (run-hooks 'after-init-hook)
781
782 ;; If *scratch* exists and init file didn't change its mode, initialize it.
783 (if (get-buffer "*scratch*")
784 (save-excursion
785 (set-buffer "*scratch*")
786 (if (eq major-mode 'fundamental-mode)
787 (funcall initial-major-mode))))
788
789 ;; Register default TTY colors for the case the terminal hasn't a
790 ;; terminal init file. The colors are good for xterm-color and the
791 ;; FreeBSD console (cons.*). They should be sufficient for Linux
792 ;; too, I guess.
793 (or (eq window-system 'pc) ; pc-win.el did this already
794 (let ((colors '("black" "red" "green" "yellow" "blue" "magenta"
795 "cyan" "white"))
796 (i 0))
797 (while colors
798 (face-register-tty-color (car colors) i)
799 (setq colors (cdr colors) i (1+ i)))))
800
801 ;; Load library for our terminal type.
802 ;; User init file can set term-file-prefix to nil to prevent this.
803 (and term-file-prefix (not noninteractive) (not window-system)
804 (let ((term (getenv "TERM"))
805 hyphend)
806 (while (and term
807 (not (load (concat term-file-prefix term) t t)))
808 ;; Strip off last hyphen and what follows, then try again
809 (if (setq hyphend (string-match "[-_][^-_]+$" term))
810 (setq term (substring term 0 hyphend))
811 (setq term nil)))))
812
813 ;; Process the remaining args.
814 (command-line-1 (cdr command-line-args))
815
816 ;; If -batch, terminate after processing the command options.
817 (if noninteractive (kill-emacs t)))
818
819 (defcustom initial-scratch-message "\
820 This buffer is for notes you don't want to save, and for Lisp evaluation.
821 If you want to create a file, visit that file with C-x C-f,
822 then enter the text in that file's own buffer.
823
824 "
825 "Initial message displayed in *scratch* buffer at startup.
826 If this is nil, no message will be displayed."
827 :type 'string)
828
829 (defun command-line-1 (command-line-args-left)
830 (or noninteractive (input-pending-p) init-file-had-error
831 (and inhibit-startup-echo-area-message
832 user-init-file
833 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
834 (equal inhibit-startup-echo-area-message
835 (if (string= init-file-user "")
836 (user-login-name)
837 init-file-user)))
838 ;; Wasn't set with custom; see if .emacs has a setq.
839 (let ((buffer (get-buffer-create " *temp*")))
840 (prog1
841 (condition-case nil
842 (save-excursion
843 (set-buffer buffer)
844 (insert-file-contents user-init-file)
845 (re-search-forward
846 (concat
847 "([ \t\n]*setq[ \t\n]+"
848 "inhibit-startup-echo-area-message[ \t\n]+"
849 (regexp-quote
850 (prin1-to-string
851 (if (string= init-file-user "")
852 (user-login-name)
853 init-file-user)))
854 "[ \t\n]*)")
855 nil t))
856 (error nil))
857 (kill-buffer buffer)))))
858 (message (if (eq (key-binding "\C-h\C-p") 'describe-project)
859 "For information about the GNU Project and its goals, type C-h C-p."
860 (substitute-command-keys
861 "For information about the GNU Project and its goals, type \\[describe-project]."))))
862 (when (and (not noninteractive)
863 (memq window-system '(x w32)))
864 (make-mode-line-mouse-sensitive))
865 (if (null command-line-args-left)
866 (cond ((and (not inhibit-startup-message) (not noninteractive)
867 ;; Don't clobber a non-scratch buffer if init file
868 ;; has selected it.
869 (string= (buffer-name) "*scratch*"))
870 ;; If there are no switches to process, we might as well
871 ;; run this hook now, and there may be some need to do it
872 ;; before doing any output.
873 (and term-setup-hook
874 (run-hooks 'term-setup-hook))
875 ;; Don't let the hook be run twice.
876 (setq term-setup-hook nil)
877
878 ;; It's important to notice the user settings before we
879 ;; display the startup message; otherwise, the settings
880 ;; won't take effect until the user gives the first
881 ;; keystroke, and that's distracting.
882 (if (fboundp 'frame-notice-user-settings)
883 (frame-notice-user-settings))
884
885 (and window-setup-hook
886 (run-hooks 'window-setup-hook))
887 (setq window-setup-hook nil)
888 ;; Do this now to avoid an annoying delay if the user
889 ;; clicks the menu bar during the sit-for.
890 (when (memq window-system '(x w32))
891 (precompute-menubar-bindings))
892 (setq menubar-bindings-done t)
893 (when (= (buffer-size) 0)
894 (let ((buffer-undo-list t))
895 (unwind-protect
896 (when (not (input-pending-p))
897 (goto-char (point-max))
898 ;; The convention for this piece of code is that
899 ;; each piece of output starts with one or two newlines
900 ;; and does not end with any newlines.
901 (insert "Welcome to GNU Emacs")
902 (if (eq system-type 'gnu/linux)
903 (insert ", one component of a Linux-based GNU system."))
904 (insert "\n")
905 (if (assq 'display (frame-parameters))
906 (progn
907 (insert "\
908 The menu bar and scroll bar are sufficient for basic editing with the mouse.
909
910 Useful Files menu items:
911 Exit Emacs (or type Control-x followed by Control-c)
912 Recover Session recover files you were editing before a crash
913
914 Important Help menu items:
915 Emacs Tutorial Learn-by-doing tutorial for using Emacs efficiently.
916 \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY
917 Copying Conditions Conditions for redistributing and changing Emacs.
918 Getting New Versions How to obtain the latest version of Emacs.
919 ")
920 (insert "\n\n" (emacs-version)
921 "
922 Copyright (C) 1999 Free Software Foundation, Inc."))
923 ;; If keys have their default meanings,
924 ;; use precomputed string to save lots of time.
925 (if (and (eq (key-binding "\C-h") 'help-command)
926 (eq (key-binding "\C-xu") 'advertised-undo)
927 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
928 (eq (key-binding "\C-ht") 'help-with-tutorial)
929 (eq (key-binding "\C-hi") 'info)
930 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
931 (insert "
932 Get help C-h (Hold down CTRL and press h)
933 Undo changes C-x u Exit Emacs C-x C-c
934 Get a tutorial C-h t Use Info to read docs C-h i")
935 (insert (substitute-command-keys
936 (format "\n
937 Get help %s
938 Undo changes \\[advertised-undo]
939 Exit Emacs \\[save-buffers-kill-emacs]
940 Get a tutorial \\[help-with-tutorial]
941 Use Info to read docs \\[info]"
942 (let ((where (where-is-internal
943 'help-command nil t)))
944 (if where
945 (key-description where)
946 "M-x help"))))))
947 ;; Say how to use the menu bar
948 ;; if that is not with the mouse.
949 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
950 (eq (key-binding [f10]) 'tmm-menubar))
951 (insert "
952 Activate menubar F10 or ESC ` or M-`")
953 (insert (substitute-command-keys "
954 Activate menubar \\[tmm-menubar]")))
955
956 ;; Windows and MSDOS (currently) do not count as
957 ;; window systems, but do have mouse support.
958 (if window-system
959 (insert "
960 Mode-specific menu C-mouse-3 (third button, with CTRL)"))
961 ;; Many users seem to have problems with these.
962 (insert "
963 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
964 If you have no Meta key, you may instead type ESC followed by the character.)")
965 (and auto-save-list-file-prefix
966 (directory-files
967 (file-name-directory auto-save-list-file-prefix)
968 nil
969 (concat "\\`"
970 (regexp-quote (file-name-nondirectory
971 auto-save-list-file-prefix)))
972 t)
973 (insert "\n\nIf an Emacs session crashed recently, "
974 "type M-x recover-session RET\nto recover"
975 " the files you were editing."))
976
977 (insert "\n\n" (emacs-version)
978 "
979 Copyright (C) 1999 Free Software Foundation, Inc.")
980 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
981 (eq (key-binding "\C-h\C-d") 'describe-distribution)
982 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
983 (insert
984 "\n
985 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
986 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
987 of Emacs and modify it; type C-h C-c to see the conditions.
988 Type C-h C-d for information on getting the latest version.")
989 (insert (substitute-command-keys
990 "\n
991 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
992 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
993 of Emacs and modify it; type \\[describe-copying] to see the conditions.
994 Type \\[describe-distribution] for information on getting the latest version."))))
995 (goto-char (point-min))
996
997 (set-buffer-modified-p nil)
998 (sit-for 120))
999 (with-current-buffer (get-buffer "*scratch*")
1000 (erase-buffer)
1001 (and initial-scratch-message
1002 (insert initial-scratch-message))
1003 (set-buffer-modified-p nil)))))))
1004 ;; Delay 2 seconds after the init file error message
1005 ;; was displayed, so user can read it.
1006 (if init-file-had-error
1007 (sit-for 2))
1008 (let ((dir command-line-default-directory)
1009 (file-count 0)
1010 first-file-buffer
1011 tem
1012 just-files ;; t if this follows the magic -- option.
1013 ;; This includes our standard options' long versions
1014 ;; and long versions of what's on command-switch-alist.
1015 (longopts
1016 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1017 ("--directory") ("--eval") ("--find-file") ("--visit"))
1018 (mapcar '(lambda (elt)
1019 (list (concat "-" (car elt))))
1020 command-switch-alist)))
1021 (line 0))
1022
1023 ;; Add the long X options to longopts.
1024 (setq tem command-line-x-option-alist)
1025 (while tem
1026 (if (string-match "^--" (car (car tem)))
1027 (setq longopts (cons (list (car (car tem))) longopts)))
1028 (setq tem (cdr tem)))
1029
1030 ;; Loop, processing options.
1031 (while (and command-line-args-left)
1032 (let* ((argi (car command-line-args-left))
1033 (orig-argi argi)
1034 argval completion
1035 ;; List of directories specified in -L/--directory,
1036 ;; in reverse of the order specified.
1037 extra-load-path
1038 (initial-load-path load-path))
1039 (setq command-line-args-left (cdr command-line-args-left))
1040
1041 ;; Do preliminary decoding of the option.
1042 (if just-files
1043 ;; After --, don't look for options; treat all args as files.
1044 (setq argi "")
1045 ;; Convert long options to ordinary options
1046 ;; and separate out an attached option argument into argval.
1047 (if (string-match "^--[^=]*=" argi)
1048 (setq argval (substring argi (match-end 0))
1049 argi (substring argi 0 (1- (match-end 0)))))
1050 (if (equal argi "--")
1051 (setq completion nil)
1052 (setq completion (try-completion argi longopts)))
1053 (if (eq completion t)
1054 (setq argi (substring argi 1))
1055 (if (stringp completion)
1056 (let ((elt (assoc completion longopts)))
1057 (or elt
1058 (error "Option `%s' is ambiguous" argi))
1059 (setq argi (substring (car elt) 1)))
1060 (setq argval nil argi orig-argi))))
1061
1062 ;; Execute the option.
1063 (cond ((setq tem (assoc argi command-switch-alist))
1064 (if argval
1065 (let ((command-line-args-left
1066 (cons argval command-line-args-left)))
1067 (funcall (cdr tem) argi))
1068 (funcall (cdr tem) argi)))
1069 ((or (string-equal argi "-f") ;what the manual claims
1070 (string-equal argi "-funcall")
1071 (string-equal argi "-e")) ; what the source used to say
1072 (if argval
1073 (setq tem (intern argval))
1074 (setq tem (intern (car command-line-args-left)))
1075 (setq command-line-args-left (cdr command-line-args-left)))
1076 (if (arrayp (symbol-function tem))
1077 (command-execute tem)
1078 (funcall tem)))
1079 ((string-equal argi "-eval")
1080 (if argval
1081 (setq tem argval)
1082 (setq tem (car command-line-args-left))
1083 (setq command-line-args-left (cdr command-line-args-left)))
1084 (eval (read tem)))
1085 ;; Set the default directory as specified in -L.
1086 ((or (string-equal argi "-L")
1087 (string-equal argi "-directory"))
1088 (if argval
1089 (setq tem argval)
1090 (setq tem (car command-line-args-left)
1091 command-line-args-left (cdr command-line-args-left)))
1092 (setq tem (command-line-normalize-file-name tem))
1093 (setq extra-load-path
1094 (cons (expand-file-name tem) extra-load-path))
1095 (setq load-path (append (nreverse extra-load-path)
1096 initial-load-path)))
1097 ((or (string-equal argi "-l")
1098 (string-equal argi "-load"))
1099 (if argval
1100 (setq tem argval)
1101 (setq tem (car command-line-args-left)
1102 command-line-args-left (cdr command-line-args-left)))
1103 (let ((file (command-line-normalize-file-name tem)))
1104 ;; Take file from default dir if it exists there;
1105 ;; otherwise let `load' search for it.
1106 (if (file-exists-p (expand-file-name file))
1107 (setq file (expand-file-name file)))
1108 (load file nil t)))
1109 ((string-equal argi "-insert")
1110 (if argval
1111 (setq tem argval)
1112 (setq tem (car command-line-args-left)
1113 command-line-args-left (cdr command-line-args-left)))
1114 (or (stringp tem)
1115 (error "File name omitted from `-insert' option"))
1116 (insert-file-contents (command-line-normalize-file-name tem)))
1117 ((string-equal argi "-kill")
1118 (kill-emacs t))
1119 ((string-match "^\\+[0-9]+\\'" argi)
1120 (setq line (string-to-int argi)))
1121 ((setq tem (assoc argi command-line-x-option-alist))
1122 ;; Ignore X-windows options and their args if not using X.
1123 (setq command-line-args-left
1124 (nthcdr (nth 1 tem) command-line-args-left)))
1125 ((or (string-equal argi "-find-file")
1126 (string-equal argi "-visit"))
1127 ;; An explicit option to specify visiting a file.
1128 (setq file-count (1+ file-count))
1129 (let ((file
1130 (expand-file-name
1131 (command-line-normalize-file-name orig-argi)
1132 dir)))
1133 (if (= file-count 1)
1134 (setq first-file-buffer (find-file file))
1135 (find-file-other-window file)))
1136 (or (zerop line)
1137 (goto-line line))
1138 (setq line 0))
1139 ((equal argi "--")
1140 (setq just-files t))
1141 (t
1142 ;; We have almost exhausted our options. See if the
1143 ;; user has made any other command-line options available
1144 (let ((hooks command-line-functions);; lrs 7/31/89
1145 (did-hook nil))
1146 (while (and hooks
1147 (not (setq did-hook (funcall (car hooks)))))
1148 (setq hooks (cdr hooks)))
1149 (if (not did-hook)
1150 ;; Ok, presume that the argument is a file name
1151 (progn
1152 (if (string-match "\\`-" argi)
1153 (error "Unknown option `%s'" argi))
1154 (setq file-count (1+ file-count))
1155 (let ((file
1156 (expand-file-name
1157 (command-line-normalize-file-name orig-argi)
1158 dir)))
1159 (if (= file-count 1)
1160 (setq first-file-buffer (find-file file))
1161 (find-file-other-window file)))
1162 (or (zerop line)
1163 (goto-line line))
1164 (setq line 0))))))))
1165 ;; If 3 or more files visited, and not all visible,
1166 ;; show user what they all are.
1167 (and (> file-count 2)
1168 (not noninteractive)
1169 (or (get-buffer-window first-file-buffer)
1170 (progn (other-window 1)
1171 (buffer-menu)))))))
1172
1173 (defun command-line-normalize-file-name (file)
1174 "Collapse multiple slashes to one, to handle non-Emacs file names."
1175 (save-match-data
1176 ;; Use arg 1 so that we don't collapse // at the start of the file name.
1177 ;; That is significant on some systems.
1178 ;; However, /// at the beginning is supposed to mean just /, not //.
1179 (if (string-match "^///+" file)
1180 (setq file (replace-match "/" t t file)))
1181 (while (string-match "//+" file 1)
1182 (setq file (replace-match "/" t t file)))
1183 file))
1184
1185 ;;; startup.el ends here