]> code.delx.au - gnu-emacs/blob - lisp/startup.el
(iswitchb-exhibit): Extract user-input only
[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]\\|1[45]\\)\\>"
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-[1234589] 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 1, 2, 3, 4, 9, 14 and 15.\)")
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 (setq small-temporary-file-directory
508 (if (eq system-type 'ms-dos)
509 (getenv "TMPDIR")))
510
511 ;; See if we should import version-control from the environment variable.
512 (let ((vc (getenv "VERSION_CONTROL")))
513 (cond ((eq vc nil)) ;don't do anything if not set
514 ((or (string= vc "t")
515 (string= vc "numbered"))
516 (setq version-control t))
517 ((or (string= vc "nil")
518 (string= vc "existing"))
519 (setq version-control nil))
520 ((or (string= vc "never")
521 (string= vc "simple"))
522 (setq version-control 'never))))
523
524 (let ((ctype
525 ;; Use the first of these three envvars that has a nonempty value.
526 (or (let ((string (getenv "LC_ALL")))
527 (and (not (equal string "")) string))
528 (let ((string (getenv "LC_CTYPE")))
529 (and (not (equal string "")) string))
530 (let ((string (getenv "LANG")))
531 (and (not (equal string "")) string)))))
532 ;; Translate "swedish" into "sv_SE.ISO-8859-1", and so on,
533 ;; using the translation file that GNU/Linux systems have.
534 (and ctype
535 locale-translation-file-name
536 (not (string-match iso-8859-n-locale-regexp ctype))
537 (with-temp-buffer
538 (insert-file-contents locale-translation-file-name)
539 (if (re-search-forward
540 (concat "^" (regexp-quote ctype) ":?[ \t]+") nil t)
541 (setq ctype (buffer-substring (point) (line-end-position))))))
542 ;; Now see if the locale specifies an ISO 8859 character set.
543 (when (and ctype
544 (string-match iso-8859-n-locale-regexp ctype))
545 (let* ((which (match-string 1 ctype))
546 (latin (cdr (assoc which '(("9" . "5") ("14" . "8")
547 ("15" . "9")))))
548 charset)
549 (if latin (setq which latin))
550 (setq charset (concat "latin-" which))
551 (when (string-match "latin-[1-589]" charset)
552 ;; Set up for this character set.
553 ;; This is now the right way to do it
554 ;; for both unibyte and multibyte modes.
555 (set-language-environment charset)
556 (unless (or noninteractive (eq window-system 'x))
557 ;; Send those codes literally to a non-X terminal.
558 (when default-enable-multibyte-characters
559 ;; If this is nil, we are using single-byte characters,
560 ;; so the terminal coding system is irrelevant.
561 (set-terminal-coding-system
562 (intern (downcase charset)))))
563 (standard-display-european-internal)))))
564
565 ;;! This has been commented out; I currently find the behavior when
566 ;;! split-window-keep-point is nil disturbing, but if I can get used
567 ;;! to it, then it would be better to eliminate the option.
568 ;;! ;; Choose a good default value for split-window-keep-point.
569 ;;! (setq split-window-keep-point (> baud-rate 2400))
570
571 ;; Set the default strings to display in mode line for
572 ;; end-of-line formats that aren't native to this platform.
573 (cond
574 ((memq system-type '(ms-dos windows-nt emx))
575 (setq eol-mnemonic-unix "(Unix)")
576 (setq eol-mnemonic-mac "(Mac)"))
577 ;; Mac-specific settings should come here, once there's a
578 ;; system-type symbol specific to MacOS.
579 (t ; this is for Unix/GNU/Linux systems
580 (setq eol-mnemonic-dos "(DOS)")
581 (setq eol-mnemonic-mac "(Mac)")))
582
583 ;; Read window system's init file if using a window system.
584 (condition-case error
585 (if (and window-system (not noninteractive))
586 (load (concat term-file-prefix
587 (symbol-name window-system)
588 "-win")
589 ;; Every window system should have a startup file;
590 ;; barf if we can't find it.
591 nil t))
592 ;; If we can't read it, print the error message and exit.
593 (error
594 (princ
595 (if (eq (car error) 'error)
596 (apply 'concat (cdr error))
597 (if (memq 'file-error (get (car error) 'error-conditions))
598 (format "%s: %s"
599 (nth 1 error)
600 (mapconcat '(lambda (obj) (prin1-to-string obj t))
601 (cdr (cdr error)) ", "))
602 (format "%s: %s"
603 (get (car error) 'error-message)
604 (mapconcat '(lambda (obj) (prin1-to-string obj t))
605 (cdr error) ", "))))
606 'external-debugging-output)
607 (setq window-system nil)
608 (kill-emacs)))
609
610 (let ((done nil)
611 (args (cdr command-line-args)))
612
613 ;; Figure out which user's init file to load,
614 ;; either from the environment or from the options.
615 (setq init-file-user (if noninteractive nil (user-login-name)))
616 ;; If user has not done su, use current $HOME to find .emacs.
617 (and init-file-user (string= init-file-user (user-real-login-name))
618 (setq init-file-user ""))
619
620 ;; Process the command-line args, and delete the arguments
621 ;; processed. This is consistent with the way main in emacs.c
622 ;; does things.
623 (while (and (not done) args)
624 (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user")
625 ("--debug-init") ("--iconic") ("--icon-type")))
626 (argi (car args))
627 (argval nil))
628 ;; Handle --OPTION=VALUE format.
629 (if (and (string-match "\\`--" argi)
630 (string-match "=" argi))
631 (setq argval (substring argi (match-end 0))
632 argi (substring argi 0 (match-beginning 0))))
633 (or (equal argi "--")
634 (let ((completion (try-completion argi longopts)))
635 (if (eq completion t)
636 (setq argi (substring argi 1))
637 (if (stringp completion)
638 (let ((elt (assoc completion longopts)))
639 (or elt
640 (error "Option `%s' is ambiguous" argi))
641 (setq argi (substring (car elt) 1)))
642 (setq argval nil)))))
643 (cond
644 ((or (string-equal argi "-q")
645 (string-equal argi "-no-init-file"))
646 (setq init-file-user nil
647 args (cdr args)))
648 ((or (string-equal argi "-u")
649 (string-equal argi "-user"))
650 (or argval
651 (setq args (cdr args)
652 argval (car args)))
653 (setq init-file-user argval
654 argval nil
655 args (cdr args)))
656 ((string-equal argi "-no-site-file")
657 (setq site-run-file nil
658 args (cdr args)))
659 ((string-equal argi "-debug-init")
660 (setq init-file-debug t
661 args (cdr args)))
662 ((string-equal argi "-iconic")
663 (setq initial-frame-alist
664 (cons '(visibility . icon) initial-frame-alist))
665 (setq args (cdr args)))
666 ((or (string-equal argi "-icon-type")
667 (string-equal argi "-i")
668 (string-equal argi "-itype"))
669 (setq default-frame-alist
670 (cons '(icon-type . t) default-frame-alist))
671 (setq args (cdr args)))
672 (t (setq done t)))
673 ;; Was argval set but not used?
674 (and argval
675 (error "Option `%s' doesn't allow an argument" argi))))
676
677 ;; Re-attach the program name to the front of the arg list.
678 (and command-line-args (setcdr command-line-args args)))
679
680 ;; Under X Windows, this creates the X frame and deletes the terminal frame.
681 (if (fboundp 'frame-initialize)
682 (frame-initialize))
683 ;; If frame was created with a menu bar, set menu-bar-mode on.
684 (if (or (not (memq window-system '(x w32)))
685 (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
686 (menu-bar-mode t))
687
688 (run-hooks 'before-init-hook)
689
690 ;; Run the site-start library if it exists. The point of this file is
691 ;; that it is run before .emacs. There is no point in doing this after
692 ;; .emacs; that is useless.
693 (if site-run-file
694 (load site-run-file t t))
695
696 ;; Register available input methods by loading LEIM list file.
697 (load "leim-list.el" 'noerror 'nomessage 'nosuffix)
698
699 ;; Sites should not disable this. Only individuals should disable
700 ;; the startup message.
701 (setq inhibit-startup-message nil)
702
703 ;; Load that user's init file, or the default one, or none.
704 (let (debug-on-error-from-init-file
705 debug-on-error-should-be-set
706 (debug-on-error-initial
707 (if (eq init-file-debug t) 'startup init-file-debug))
708 (orig-enable-multibyte default-enable-multibyte-characters))
709 (let ((debug-on-error debug-on-error-initial)
710 ;; This function actually reads the init files.
711 (inner
712 (function
713 (lambda ()
714 (if init-file-user
715 (let ((user-init-file-1
716 (cond
717 ((eq system-type 'ms-dos)
718 (concat "~" init-file-user "/_emacs"))
719 ((eq system-type 'windows-nt)
720 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
721 "~/.emacs"
722 "~/_emacs"))
723 ((eq system-type 'vax-vms)
724 "sys$login:.emacs")
725 (t
726 (concat "~" init-file-user "/.emacs")))))
727 ;; This tells `load' to store the file name found
728 ;; into user-init-file.
729 (setq user-init-file t)
730 (load user-init-file-1 t t)
731 ;; If we did not find the user's init file,
732 ;; set user-init-file conclusively to nil;
733 ;; don't let it be set from default.el.
734 (if (eq user-init-file t)
735 (setq user-init-file nil))
736 (or inhibit-default-init
737 (let ((inhibit-startup-message nil))
738 ;; Users are supposed to be told their rights.
739 ;; (Plus how to get help and how to undo.)
740 ;; Don't you dare turn this off for anyone
741 ;; except yourself.
742 (load "default" t t)))))))))
743 (if init-file-debug
744 ;; Do this without a condition-case if the user wants to debug.
745 (funcall inner)
746 (condition-case error
747 (progn
748 (funcall inner)
749 (setq init-file-had-error nil))
750 (error (message "Error in init file: %s%s%s"
751 (get (car error) 'error-message)
752 (if (cdr error) ": " "")
753 (mapconcat 'prin1-to-string (cdr error) ", "))
754 (setq init-file-had-error t))))
755 ;; If we can tell that the init file altered debug-on-error,
756 ;; arrange to preserve the value that it set up.
757 (or (eq debug-on-error debug-on-error-initial)
758 (setq debug-on-error-should-be-set t
759 debug-on-error-from-init-file debug-on-error)))
760 (if debug-on-error-should-be-set
761 (setq debug-on-error debug-on-error-from-init-file))
762 (unless (or default-enable-multibyte-characters
763 (eq orig-enable-multibyte default-enable-multibyte-characters))
764 ;; Init file changed to unibyte. Reset existing multibyte
765 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
766 ;; Arguably this should only be done if they're free of
767 ;; multibyte characters.
768 (mapcar (lambda (buffer)
769 (with-current-buffer buffer
770 (if enable-multibyte-characters
771 (set-buffer-multibyte nil))))
772 (buffer-list))
773 ;; Also re-set the language environment in case it was
774 ;; originally done before unibyte was set and is sensitive to
775 ;; unibyte (display table, terminal coding system &c).
776 (set-language-environment current-language-environment)))
777
778 ;; Do this here in case the init file sets mail-host-address.
779 (or user-mail-address
780 (setq user-mail-address (concat (user-login-name) "@"
781 (or mail-host-address
782 (system-name)))))
783
784 (run-hooks 'after-init-hook)
785
786 ;; If *scratch* exists and init file didn't change its mode, initialize it.
787 (if (get-buffer "*scratch*")
788 (save-excursion
789 (set-buffer "*scratch*")
790 (if (eq major-mode 'fundamental-mode)
791 (funcall initial-major-mode))))
792
793 ;; Register default TTY colors for the case the terminal hasn't a
794 ;; terminal init file. The colors are good for xterm-color and the
795 ;; FreeBSD console (cons.*). They should be sufficient for Linux
796 ;; too, I guess.
797 (or (eq window-system 'pc) ; pc-win.el did this already
798 (let ((colors '("black" "red" "green" "yellow" "blue" "magenta"
799 "cyan" "white"))
800 (i 0))
801 (while colors
802 (face-register-tty-color (car colors) i)
803 (setq colors (cdr colors) i (1+ i)))))
804
805 ;; Load library for our terminal type.
806 ;; User init file can set term-file-prefix to nil to prevent this.
807 (and term-file-prefix (not noninteractive) (not window-system)
808 (let ((term (getenv "TERM"))
809 hyphend)
810 (while (and term
811 (not (load (concat term-file-prefix term) t t)))
812 ;; Strip off last hyphen and what follows, then try again
813 (if (setq hyphend (string-match "[-_][^-_]+$" term))
814 (setq term (substring term 0 hyphend))
815 (setq term nil)))))
816
817 ;; Process the remaining args.
818 (command-line-1 (cdr command-line-args))
819
820 ;; If -batch, terminate after processing the command options.
821 (if noninteractive (kill-emacs t)))
822
823 (defcustom initial-scratch-message "\
824 This buffer is for notes you don't want to save, and for Lisp evaluation.
825 If you want to create a file, visit that file with C-x C-f,
826 then enter the text in that file's own buffer.
827
828 "
829 "Initial message displayed in *scratch* buffer at startup.
830 If this is nil, no message will be displayed."
831 :type 'string)
832
833 (defun command-line-1 (command-line-args-left)
834 (or noninteractive (input-pending-p) init-file-had-error
835 (and inhibit-startup-echo-area-message
836 user-init-file
837 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
838 (equal inhibit-startup-echo-area-message
839 (if (string= init-file-user "")
840 (user-login-name)
841 init-file-user)))
842 ;; Wasn't set with custom; see if .emacs has a setq.
843 (let ((buffer (get-buffer-create " *temp*")))
844 (prog1
845 (condition-case nil
846 (save-excursion
847 (set-buffer buffer)
848 (insert-file-contents user-init-file)
849 (re-search-forward
850 (concat
851 "([ \t\n]*setq[ \t\n]+"
852 "inhibit-startup-echo-area-message[ \t\n]+"
853 (regexp-quote
854 (prin1-to-string
855 (if (string= init-file-user "")
856 (user-login-name)
857 init-file-user)))
858 "[ \t\n]*)")
859 nil t))
860 (error nil))
861 (kill-buffer buffer)))))
862 (message (if (eq (key-binding "\C-h\C-p") 'describe-project)
863 "For information about the GNU Project and its goals, type C-h C-p."
864 (substitute-command-keys
865 "For information about the GNU Project and its goals, type \\[describe-project]."))))
866 (when (and (not noninteractive)
867 (memq window-system '(x w32)))
868 (make-mode-line-mouse-sensitive))
869 (if (null command-line-args-left)
870 (cond ((and (not inhibit-startup-message) (not noninteractive)
871 ;; Don't clobber a non-scratch buffer if init file
872 ;; has selected it.
873 (string= (buffer-name) "*scratch*"))
874 ;; If there are no switches to process, we might as well
875 ;; run this hook now, and there may be some need to do it
876 ;; before doing any output.
877 (and term-setup-hook
878 (run-hooks 'term-setup-hook))
879 ;; Don't let the hook be run twice.
880 (setq term-setup-hook nil)
881
882 ;; It's important to notice the user settings before we
883 ;; display the startup message; otherwise, the settings
884 ;; won't take effect until the user gives the first
885 ;; keystroke, and that's distracting.
886 (if (fboundp 'frame-notice-user-settings)
887 (frame-notice-user-settings))
888
889 (and window-setup-hook
890 (run-hooks 'window-setup-hook))
891 (setq window-setup-hook nil)
892 ;; Do this now to avoid an annoying delay if the user
893 ;; clicks the menu bar during the sit-for.
894 (when (memq window-system '(x w32))
895 (precompute-menubar-bindings))
896 (setq menubar-bindings-done t)
897 (when (= (buffer-size) 0)
898 (let ((buffer-undo-list t))
899 (unwind-protect
900 (when (not (input-pending-p))
901 (goto-char (point-max))
902 ;; The convention for this piece of code is that
903 ;; each piece of output starts with one or two newlines
904 ;; and does not end with any newlines.
905 (insert "Welcome to GNU Emacs")
906 (if (eq system-type 'gnu/linux)
907 (insert ", one component of a Linux-based GNU system."))
908 (insert "\n")
909 (if (assq 'display (frame-parameters))
910 (progn
911 (insert "\
912 The menu bar and scroll bar are sufficient for basic editing with the mouse.
913
914 Useful Files menu items:
915 Exit Emacs (or type Control-x followed by Control-c)
916 Recover Session recover files you were editing before a crash
917
918 Important Help menu items:
919 Emacs Tutorial Learn-by-doing tutorial for using Emacs efficiently.
920 \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY
921 Copying Conditions Conditions for redistributing and changing Emacs.
922 Getting New Versions How to obtain the latest version of Emacs.
923 ")
924 (insert "\n\n" (emacs-version)
925 "
926 Copyright (C) 1999 Free Software Foundation, Inc."))
927 ;; If keys have their default meanings,
928 ;; use precomputed string to save lots of time.
929 (if (and (eq (key-binding "\C-h") 'help-command)
930 (eq (key-binding "\C-xu") 'advertised-undo)
931 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs)
932 (eq (key-binding "\C-ht") 'help-with-tutorial)
933 (eq (key-binding "\C-hi") 'info)
934 (eq (key-binding "\C-h\C-n") 'view-emacs-news))
935 (insert "
936 Get help C-h (Hold down CTRL and press h)
937 Undo changes C-x u Exit Emacs C-x C-c
938 Get a tutorial C-h t Use Info to read docs C-h i")
939 (insert (substitute-command-keys
940 (format "\n
941 Get help %s
942 Undo changes \\[advertised-undo]
943 Exit Emacs \\[save-buffers-kill-emacs]
944 Get a tutorial \\[help-with-tutorial]
945 Use Info to read docs \\[info]"
946 (let ((where (where-is-internal
947 'help-command nil t)))
948 (if where
949 (key-description where)
950 "M-x help"))))))
951 ;; Say how to use the menu bar
952 ;; if that is not with the mouse.
953 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
954 (eq (key-binding [f10]) 'tmm-menubar))
955 (insert "
956 Activate menubar F10 or ESC ` or M-`")
957 (insert (substitute-command-keys "
958 Activate menubar \\[tmm-menubar]")))
959
960 ;; Windows and MSDOS (currently) do not count as
961 ;; window systems, but do have mouse support.
962 (if window-system
963 (insert "
964 Mode-specific menu C-mouse-3 (third button, with CTRL)"))
965 ;; Many users seem to have problems with these.
966 (insert "
967 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
968 If you have no Meta key, you may instead type ESC followed by the character.)")
969 (and auto-save-list-file-prefix
970 (directory-files
971 (file-name-directory auto-save-list-file-prefix)
972 nil
973 (concat "\\`"
974 (regexp-quote (file-name-nondirectory
975 auto-save-list-file-prefix)))
976 t)
977 (insert "\n\nIf an Emacs session crashed recently, "
978 "type M-x recover-session RET\nto recover"
979 " the files you were editing."))
980
981 (insert "\n\n" (emacs-version)
982 "
983 Copyright (C) 1999 Free Software Foundation, Inc.")
984 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
985 (eq (key-binding "\C-h\C-d") 'describe-distribution)
986 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
987 (insert
988 "\n
989 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
990 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
991 of Emacs and modify it; type C-h C-c to see the conditions.
992 Type C-h C-d for information on getting the latest version.")
993 (insert (substitute-command-keys
994 "\n
995 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details.
996 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
997 of Emacs and modify it; type \\[describe-copying] to see the conditions.
998 Type \\[describe-distribution] for information on getting the latest version."))))
999 (goto-char (point-min))
1000
1001 (set-buffer-modified-p nil)
1002 (sit-for 120))
1003 (with-current-buffer (get-buffer "*scratch*")
1004 (erase-buffer)
1005 (and initial-scratch-message
1006 (insert initial-scratch-message))
1007 (set-buffer-modified-p nil)))))))
1008 ;; Delay 2 seconds after the init file error message
1009 ;; was displayed, so user can read it.
1010 (if init-file-had-error
1011 (sit-for 2))
1012 (let ((dir command-line-default-directory)
1013 (file-count 0)
1014 first-file-buffer
1015 tem
1016 just-files ;; t if this follows the magic -- option.
1017 ;; This includes our standard options' long versions
1018 ;; and long versions of what's on command-switch-alist.
1019 (longopts
1020 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1021 ("--directory") ("--eval") ("--find-file") ("--visit"))
1022 (mapcar '(lambda (elt)
1023 (list (concat "-" (car elt))))
1024 command-switch-alist)))
1025 (line 0))
1026
1027 ;; Add the long X options to longopts.
1028 (setq tem command-line-x-option-alist)
1029 (while tem
1030 (if (string-match "^--" (car (car tem)))
1031 (setq longopts (cons (list (car (car tem))) longopts)))
1032 (setq tem (cdr tem)))
1033
1034 ;; Loop, processing options.
1035 (while (and command-line-args-left)
1036 (let* ((argi (car command-line-args-left))
1037 (orig-argi argi)
1038 argval completion
1039 ;; List of directories specified in -L/--directory,
1040 ;; in reverse of the order specified.
1041 extra-load-path
1042 (initial-load-path load-path))
1043 (setq command-line-args-left (cdr command-line-args-left))
1044
1045 ;; Do preliminary decoding of the option.
1046 (if just-files
1047 ;; After --, don't look for options; treat all args as files.
1048 (setq argi "")
1049 ;; Convert long options to ordinary options
1050 ;; and separate out an attached option argument into argval.
1051 (if (string-match "^--[^=]*=" argi)
1052 (setq argval (substring argi (match-end 0))
1053 argi (substring argi 0 (1- (match-end 0)))))
1054 (if (equal argi "--")
1055 (setq completion nil)
1056 (setq completion (try-completion argi longopts)))
1057 (if (eq completion t)
1058 (setq argi (substring argi 1))
1059 (if (stringp completion)
1060 (let ((elt (assoc completion longopts)))
1061 (or elt
1062 (error "Option `%s' is ambiguous" argi))
1063 (setq argi (substring (car elt) 1)))
1064 (setq argval nil argi orig-argi))))
1065
1066 ;; Execute the option.
1067 (cond ((setq tem (assoc argi command-switch-alist))
1068 (if argval
1069 (let ((command-line-args-left
1070 (cons argval command-line-args-left)))
1071 (funcall (cdr tem) argi))
1072 (funcall (cdr tem) argi)))
1073 ((or (string-equal argi "-f") ;what the manual claims
1074 (string-equal argi "-funcall")
1075 (string-equal argi "-e")) ; what the source used to say
1076 (if argval
1077 (setq tem (intern argval))
1078 (setq tem (intern (car command-line-args-left)))
1079 (setq command-line-args-left (cdr command-line-args-left)))
1080 (if (arrayp (symbol-function tem))
1081 (command-execute tem)
1082 (funcall tem)))
1083 ((string-equal argi "-eval")
1084 (if argval
1085 (setq tem argval)
1086 (setq tem (car command-line-args-left))
1087 (setq command-line-args-left (cdr command-line-args-left)))
1088 (eval (read tem)))
1089 ;; Set the default directory as specified in -L.
1090 ((or (string-equal argi "-L")
1091 (string-equal argi "-directory"))
1092 (if argval
1093 (setq tem argval)
1094 (setq tem (car command-line-args-left)
1095 command-line-args-left (cdr command-line-args-left)))
1096 (setq tem (command-line-normalize-file-name tem))
1097 (setq extra-load-path
1098 (cons (expand-file-name tem) extra-load-path))
1099 (setq load-path (append (nreverse extra-load-path)
1100 initial-load-path)))
1101 ((or (string-equal argi "-l")
1102 (string-equal argi "-load"))
1103 (if argval
1104 (setq tem argval)
1105 (setq tem (car command-line-args-left)
1106 command-line-args-left (cdr command-line-args-left)))
1107 (let ((file (command-line-normalize-file-name tem)))
1108 ;; Take file from default dir if it exists there;
1109 ;; otherwise let `load' search for it.
1110 (if (file-exists-p (expand-file-name file))
1111 (setq file (expand-file-name file)))
1112 (load file nil t)))
1113 ((string-equal argi "-insert")
1114 (if argval
1115 (setq tem argval)
1116 (setq tem (car command-line-args-left)
1117 command-line-args-left (cdr command-line-args-left)))
1118 (or (stringp tem)
1119 (error "File name omitted from `-insert' option"))
1120 (insert-file-contents (command-line-normalize-file-name tem)))
1121 ((string-equal argi "-kill")
1122 (kill-emacs t))
1123 ((string-match "^\\+[0-9]+\\'" argi)
1124 (setq line (string-to-int argi)))
1125 ((setq tem (assoc argi command-line-x-option-alist))
1126 ;; Ignore X-windows options and their args if not using X.
1127 (setq command-line-args-left
1128 (nthcdr (nth 1 tem) command-line-args-left)))
1129 ((or (string-equal argi "-find-file")
1130 (string-equal argi "-visit"))
1131 ;; An explicit option to specify visiting a file.
1132 (setq file-count (1+ file-count))
1133 (let ((file
1134 (expand-file-name
1135 (command-line-normalize-file-name orig-argi)
1136 dir)))
1137 (if (= file-count 1)
1138 (setq first-file-buffer (find-file file))
1139 (find-file-other-window file)))
1140 (or (zerop line)
1141 (goto-line line))
1142 (setq line 0))
1143 ((equal argi "--")
1144 (setq just-files t))
1145 (t
1146 ;; We have almost exhausted our options. See if the
1147 ;; user has made any other command-line options available
1148 (let ((hooks command-line-functions);; lrs 7/31/89
1149 (did-hook nil))
1150 (while (and hooks
1151 (not (setq did-hook (funcall (car hooks)))))
1152 (setq hooks (cdr hooks)))
1153 (if (not did-hook)
1154 ;; Ok, presume that the argument is a file name
1155 (progn
1156 (if (string-match "\\`-" argi)
1157 (error "Unknown option `%s'" argi))
1158 (setq file-count (1+ file-count))
1159 (let ((file
1160 (expand-file-name
1161 (command-line-normalize-file-name orig-argi)
1162 dir)))
1163 (if (= file-count 1)
1164 (setq first-file-buffer (find-file file))
1165 (find-file-other-window file)))
1166 (or (zerop line)
1167 (goto-line line))
1168 (setq line 0))))))))
1169 ;; If 3 or more files visited, and not all visible,
1170 ;; show user what they all are.
1171 (and (> file-count 2)
1172 (not noninteractive)
1173 (or (get-buffer-window first-file-buffer)
1174 (progn (other-window 1)
1175 (buffer-menu)))))))
1176
1177 (defun command-line-normalize-file-name (file)
1178 "Collapse multiple slashes to one, to handle non-Emacs file names."
1179 (save-match-data
1180 ;; Use arg 1 so that we don't collapse // at the start of the file name.
1181 ;; That is significant on some systems.
1182 ;; However, /// at the beginning is supposed to mean just /, not //.
1183 (if (string-match "^///+" file)
1184 (setq file (replace-match "/" t t file)))
1185 (while (string-match "//+" file 1)
1186 (setq file (replace-match "/" t t file)))
1187 file))
1188
1189 ;;; startup.el ends here