merge from trunk, fix conflicts
[emacs.git] / lisp / startup.el
blob72169799acf6fa028d3d76e5a370a4241151157d
1 ;;; startup.el --- process Emacs shell arguments
3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 ;; Free Software Foundation, Inc.
7 ;; Maintainer: FSF
8 ;; Keywords: internal
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; This file parses the command line and gets Emacs running. Options
28 ;; on the command line are handled in precedence order. For priorities
29 ;; see the structure standard_args in the emacs.c file.
31 ;;; Code:
33 (setq top-level '(normal-top-level))
35 (defvar command-line-processed nil
36 "Non-nil once command line has been processed.")
38 (defgroup initialization nil
39 "Emacs start-up procedure."
40 :group 'environment)
42 (defcustom initial-buffer-choice nil
43 "Buffer to show after starting Emacs.
44 If the value is nil and `inhibit-startup-screen' is nil, show the
45 startup screen. If the value is string, visit the specified file or
46 directory using `find-file'. If t, open the `*scratch*' buffer."
47 :type '(choice
48 (const :tag "Startup screen" nil)
49 (directory :tag "Directory" :value "~/")
50 (file :tag "File" :value "~/.emacs")
51 (const :tag "Lisp scratch buffer" t))
52 :version "23.1"
53 :group 'initialization)
55 (defcustom inhibit-startup-screen nil
56 "Non-nil inhibits the startup screen.
58 This is for use in your personal init file (but NOT site-start.el),
59 once you are familiar with the contents of the startup screen."
60 :type 'boolean
61 :group 'initialization)
63 (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen)
64 (defvaralias 'inhibit-startup-message 'inhibit-startup-screen)
66 (defvar startup-screen-inhibit-startup-screen nil)
68 (defcustom inhibit-startup-echo-area-message nil
69 "Non-nil inhibits the initial startup echo area message.
70 Setting this variable takes effect
71 only if you do it with the customization buffer
72 or if your `.emacs' file contains a line of this form:
73 (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")
74 If your `.emacs' file is byte-compiled, use the following form instead:
75 (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\"))
76 Thus, someone else using a copy of your `.emacs' file will see
77 the startup message unless he personally acts to inhibit it."
78 :type '(choice (const :tag "Don't inhibit")
79 (string :tag "Enter your user name, to inhibit"))
80 :group 'initialization)
82 (defcustom inhibit-default-init nil
83 "Non-nil inhibits loading the `default' library."
84 :type 'boolean
85 :group 'initialization)
87 (defcustom inhibit-startup-buffer-menu nil
88 "Non-nil inhibits display of buffer list when more than 2 files are loaded."
89 :type 'boolean
90 :group 'initialization)
92 (defvar command-switch-alist nil
93 "Alist of command-line switches.
94 Elements look like (SWITCH-STRING . HANDLER-FUNCTION).
95 HANDLER-FUNCTION receives the switch string as its sole argument;
96 the remaining command-line args are in the variable `command-line-args-left'.")
98 (defvar command-line-args-left nil
99 "List of command-line args not yet processed.")
101 (defvaralias 'argv 'command-line-args-left
102 "List of command-line args not yet processed.
103 This is a convenience alias, so that one can write \(pop argv\)
104 inside of --eval command line arguments in order to access
105 following arguments.")
107 (defvar command-line-functions nil ;; lrs 7/31/89
108 "List of functions to process unrecognized command-line arguments.
109 Each function should access the dynamically bound variables
110 `argi' (the current argument) and `command-line-args-left' (the remaining
111 arguments). The function should return non-nil only if it recognizes and
112 processes `argi'. If it does so, it may consume successive arguments by
113 altering `command-line-args-left' to remove them.")
115 (defvar command-line-default-directory nil
116 "Default directory to use for command line arguments.
117 This is normally copied from `default-directory' when Emacs starts.")
119 ;;; This is here, rather than in x-win.el, so that we can ignore these
120 ;;; options when we are not using X.
121 (defconst command-line-x-option-alist
122 '(("-bw" 1 x-handle-numeric-switch border-width)
123 ("-d" 1 x-handle-display)
124 ("-display" 1 x-handle-display)
125 ("-name" 1 x-handle-name-switch)
126 ("-title" 1 x-handle-switch title)
127 ("-T" 1 x-handle-switch title)
128 ("-r" 0 x-handle-switch reverse t)
129 ("-rv" 0 x-handle-switch reverse t)
130 ("-reverse" 0 x-handle-switch reverse t)
131 ("-reverse-video" 0 x-handle-switch reverse t)
132 ("-fn" 1 x-handle-switch font)
133 ("-font" 1 x-handle-switch font)
134 ("-fs" 0 x-handle-initial-switch fullscreen fullboth)
135 ("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
136 ("-fh" 0 x-handle-initial-switch fullscreen fullheight)
137 ("-mm" 0 x-handle-initial-switch fullscreen maximized)
138 ("-ib" 1 x-handle-numeric-switch internal-border-width)
139 ("-g" 1 x-handle-geometry)
140 ("-lsp" 1 x-handle-numeric-switch line-spacing)
141 ("-geometry" 1 x-handle-geometry)
142 ("-fg" 1 x-handle-switch foreground-color)
143 ("-foreground" 1 x-handle-switch foreground-color)
144 ("-bg" 1 x-handle-switch background-color)
145 ("-background" 1 x-handle-switch background-color)
146 ("-ms" 1 x-handle-switch mouse-color)
147 ("-nbi" 0 x-handle-switch icon-type nil)
148 ("-iconic" 0 x-handle-iconic)
149 ("-xrm" 1 x-handle-xrm-switch)
150 ("-cr" 1 x-handle-switch cursor-color)
151 ("-vb" 0 x-handle-switch vertical-scroll-bars t)
152 ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
153 ("-bd" 1 x-handle-switch)
154 ("--border-width" 1 x-handle-numeric-switch border-width)
155 ("--display" 1 x-handle-display)
156 ("--name" 1 x-handle-name-switch)
157 ("--title" 1 x-handle-switch title)
158 ("--reverse-video" 0 x-handle-switch reverse t)
159 ("--font" 1 x-handle-switch font)
160 ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
161 ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
162 ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
163 ("--maximized" 0 x-handle-initial-switch fullscreen maximized)
164 ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
165 ("--geometry" 1 x-handle-geometry)
166 ("--foreground-color" 1 x-handle-switch foreground-color)
167 ("--background-color" 1 x-handle-switch background-color)
168 ("--mouse-color" 1 x-handle-switch mouse-color)
169 ("--no-bitmap-icon" 0 x-handle-no-bitmap-icon)
170 ("--iconic" 0 x-handle-iconic)
171 ("--xrm" 1 x-handle-xrm-switch)
172 ("--cursor-color" 1 x-handle-switch cursor-color)
173 ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
174 ("--line-spacing" 1 x-handle-numeric-switch line-spacing)
175 ("--border-color" 1 x-handle-switch border-color)
176 ("--smid" 1 x-handle-smid)
177 ("--parent-id" 1 x-handle-parent-id))
178 "Alist of X Windows options.
179 Each element has the form
180 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
181 where NAME is the option name string, NUMARGS is the number of arguments
182 that the option accepts, HANDLER is a function to call to handle the option.
183 FRAME-PARAM (optional) is the frame parameter this option specifies,
184 and VALUE is the value which is given to that frame parameter
185 \(most options use the argument for this, so VALUE is not present).")
187 (defconst command-line-ns-option-alist
188 '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
189 ("-NXAutoLaunch" 1 ns-ignore-1-arg)
190 ("-macosx" 0 ignore)
191 ("-NSHost" 1 ns-ignore-1-arg)
192 ("-_NSMachLaunch" 1 ns-ignore-1-arg)
193 ("-MachLaunch" 1 ns-ignore-1-arg)
194 ("-NXOpen" 1 ns-ignore-1-arg)
195 ("-NSOpen" 1 ns-handle-nxopen)
196 ("-NXOpenTemp" 1 ns-ignore-1-arg)
197 ("-NSOpenTemp" 1 ns-handle-nxopentemp)
198 ("-GSFilePath" 1 ns-handle-nxopen)
199 ;;("-bw" . x-handle-numeric-switch)
200 ;;("-d" . x-handle-display)
201 ;;("-display" . x-handle-display)
202 ("-name" 1 ns-handle-name-switch)
203 ("-title" 1 ns-handle-switch title)
204 ("-T" 1 ns-handle-switch title)
205 ("-r" 0 ns-handle-switch reverse t)
206 ("-rv" 0 ns-handle-switch reverse t)
207 ("-reverse" 0 ns-handle-switch reverse t)
208 ("-fn" 1 ns-handle-switch font)
209 ("-font" 1 ns-handle-switch font)
210 ("-ib" 1 ns-handle-numeric-switch internal-border-width)
211 ;;("-g" . x-handle-geometry)
212 ;;("-geometry" . x-handle-geometry)
213 ("-fg" 1 ns-handle-switch foreground-color)
214 ("-foreground" 1 ns-handle-switch foreground-color)
215 ("-bg" 1 ns-handle-switch background-color)
216 ("-background" 1 ns-handle-switch background-color)
217 ; ("-ms" 1 ns-handle-switch mouse-color)
218 ("-itype" 0 ns-handle-switch icon-type t)
219 ("-i" 0 ns-handle-switch icon-type t)
220 ("-iconic" 0 ns-handle-iconic icon-type t)
221 ;;("-xrm" . x-handle-xrm-switch)
222 ("-cr" 1 ns-handle-switch cursor-color)
223 ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
224 ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
225 ("-bd" 1 ns-handle-switch)
226 ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
227 ;; ("--display" 1 ns-handle-display)
228 ("--name" 1 ns-handle-name-switch)
229 ("--title" 1 ns-handle-switch title)
230 ("--reverse-video" 0 ns-handle-switch reverse t)
231 ("--font" 1 ns-handle-switch font)
232 ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
233 ;; ("--geometry" 1 ns-handle-geometry)
234 ("--foreground-color" 1 ns-handle-switch foreground-color)
235 ("--background-color" 1 ns-handle-switch background-color)
236 ("--mouse-color" 1 ns-handle-switch mouse-color)
237 ("--icon-type" 0 ns-handle-switch icon-type t)
238 ("--iconic" 0 ns-handle-iconic)
239 ;; ("--xrm" 1 ns-handle-xrm-switch)
240 ("--cursor-color" 1 ns-handle-switch cursor-color)
241 ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
242 ("--border-color" 1 ns-handle-switch border-width))
243 "Alist of NS options.
244 Each element has the form
245 (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
246 where NAME is the option name string, NUMARGS is the number of arguments
247 that the option accepts, HANDLER is a function to call to handle the option.
248 FRAME-PARAM (optional) is the frame parameter this option specifies,
249 and VALUE is the value which is given to that frame parameter
250 \(most options use the argument for this, so VALUE is not present).")
253 (defvar before-init-hook nil
254 "Normal hook run after handling urgent options but before loading init files.")
256 (defvar after-init-hook nil
257 "Normal hook run after loading the init files, `~/.emacs' and `default.el'.
258 There is no `condition-case' around the running of these functions;
259 therefore, if you set `debug-on-error' non-nil in `.emacs',
260 an error in one of these functions will invoke the debugger.")
262 (defvar emacs-startup-hook nil
263 "Normal hook run after loading init files and handling the command line.")
265 (defvar term-setup-hook nil
266 "Normal hook run after loading terminal-specific Lisp code.
267 It also follows `emacs-startup-hook'. This hook exists for users to set,
268 so as to override the definitions made by the terminal-specific file.
269 Emacs never sets this variable itself.")
271 (defvar inhibit-startup-hooks nil
272 "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'.
273 This is because we already did so.")
275 (defvar keyboard-type nil
276 "The brand of keyboard you are using.
277 This variable is used to define the proper function and keypad
278 keys for use under X. It is used in a fashion analogous to the
279 environment variable TERM.")
281 (defvar window-setup-hook nil
282 "Normal hook run to initialize window system display.
283 Emacs runs this hook after processing the command line arguments and loading
284 the user's init file.")
286 (defcustom initial-major-mode 'lisp-interaction-mode
287 "Major mode command symbol to use for the initial `*scratch*' buffer."
288 :type 'function
289 :group 'initialization)
291 (defvar init-file-user nil
292 "Identity of user whose `.emacs' file is or was read.
293 The value is nil if `-q' or `--no-init-file' was specified,
294 meaning do not load any init file.
296 Otherwise, the value may be an empty string, meaning
297 use the init file for the user who originally logged in,
298 or it may be a string containing a user's name meaning
299 use that person's init file.
301 In either of the latter cases, `(concat \"~\" init-file-user \"/\")'
302 evaluates to the name of the directory where the `.emacs' file was
303 looked for.
305 Setting `init-file-user' does not prevent Emacs from loading
306 `site-start.el'. The only way to do that is to use `--no-site-file'.")
308 (defcustom site-run-file (purecopy "site-start")
309 "File containing site-wide run-time initializations.
310 This file is loaded at run-time before `~/.emacs'. It contains inits
311 that need to be in place for the entire site, but which, due to their
312 higher incidence of change, don't make sense to load into Emacs's
313 dumped image. Thus, the run-time load order is: 1. file described in
314 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'.
316 Don't use the `site-start.el' file for things some users may not like.
317 Put them in `default.el' instead, so that users can more easily
318 override them. Users can prevent loading `default.el' with the `-q'
319 option or by setting `inhibit-default-init' in their own init files,
320 but inhibiting `site-start.el' requires `--no-site-file', which
321 is less convenient.
323 This variable is defined for customization so as to make
324 it visible in the relevant context. However, actually customizing it
325 is not allowed, since it would not work anyway. The only way to set
326 this variable usefully is to set it while building and dumping Emacs."
327 :type '(choice (const :tag "none" nil) string)
328 :group 'initialization
329 :initialize 'custom-initialize-default
330 :set (lambda (variable value)
331 (error "Customizing `site-run-file' does not work")))
333 (defcustom mail-host-address nil
334 "Name of this machine, for purposes of naming users."
335 :type '(choice (const nil) string)
336 :group 'mail)
338 (defcustom user-mail-address (if command-line-processed
339 (or (getenv "EMAIL")
340 (concat (user-login-name) "@"
341 (or mail-host-address
342 (system-name))))
343 ;; Empty string means "not set yet".
345 "Full mailing address of this user.
346 This is initialized with environment variable `EMAIL' or, as a
347 fallback, using `mail-host-address'. This is done after your
348 init file is read, in case it sets `mail-host-address'."
349 :type 'string
350 :group 'mail)
352 (defcustom auto-save-list-file-prefix
353 (cond ((eq system-type 'ms-dos)
354 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
355 (concat user-emacs-directory "auto-save.list/_s"))
357 (concat user-emacs-directory "auto-save-list/.saves-")))
358 "Prefix for generating `auto-save-list-file-name'.
359 This is used after reading your `.emacs' file to initialize
360 `auto-save-list-file-name', by appending Emacs's pid and the system name,
361 if you have not already set `auto-save-list-file-name' yourself.
362 Directories in the prefix will be created if necessary.
363 Set this to nil if you want to prevent `auto-save-list-file-name'
364 from being initialized."
365 :type '(choice (const :tag "Don't record a session's auto save list" nil)
366 string)
367 :group 'auto-save)
369 (defvar emacs-basic-display nil)
371 (defvar init-file-debug nil)
373 (defvar init-file-had-error nil
374 "Non-nil if there was an error loading the user's init file.")
376 (defvar normal-top-level-add-subdirs-inode-list nil)
378 (defvar no-blinking-cursor nil)
380 (defvar default-frame-background-mode)
382 (defvar pure-space-overflow nil
383 "Non-nil if building Emacs overflowed pure space.")
385 (defvar pure-space-overflow-message (purecopy "\
386 Warning Warning!!! Pure space overflow !!!Warning Warning
387 \(See the node Pure Storage in the Lisp manual for details.)\n"))
389 (defcustom tutorial-directory
390 (file-name-as-directory (expand-file-name "tutorials" data-directory))
391 "Directory containing the Emacs TUTORIAL files."
392 :group 'installation
393 :type 'directory
394 :initialize 'custom-initialize-delay)
396 (defun normal-top-level-add-subdirs-to-load-path ()
397 "Add all subdirectories of current directory to `load-path'.
398 More precisely, this uses only the subdirectories whose names
399 start with letters or digits; it excludes any subdirectory named `RCS'
400 or `CVS', and any subdirectory that contains a file named `.nosearch'."
401 (let (dirs
402 attrs
403 (pending (list default-directory)))
404 ;; This loop does a breadth-first tree walk on DIR's subtree,
405 ;; putting each subdir into DIRS as its contents are examined.
406 (while pending
407 (push (pop pending) dirs)
408 (let* ((this-dir (car dirs))
409 (contents (directory-files this-dir))
410 (default-directory this-dir)
411 (canonicalized (if (fboundp 'untranslated-canonical-name)
412 (untranslated-canonical-name this-dir))))
413 ;; The Windows version doesn't report meaningful inode
414 ;; numbers, so use the canonicalized absolute file name of the
415 ;; directory instead.
416 (setq attrs (or canonicalized
417 (nthcdr 10 (file-attributes this-dir))))
418 (unless (member attrs normal-top-level-add-subdirs-inode-list)
419 (push attrs normal-top-level-add-subdirs-inode-list)
420 (dolist (file contents)
421 ;; The lower-case variants of RCS and CVS are for DOS/Windows.
422 (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs"))
423 (when (and (string-match "\\`[[:alnum:]]" file)
424 ;; Avoid doing a `stat' when it isn't necessary
425 ;; because that can cause trouble when an NFS server
426 ;; is down.
427 (not (string-match "\\.elc?\\'" file))
428 (file-directory-p file))
429 (let ((expanded (expand-file-name file)))
430 (unless (file-exists-p (expand-file-name ".nosearch"
431 expanded))
432 (setq pending (nconc pending (list expanded)))))))))))
433 (normal-top-level-add-to-load-path (cdr (nreverse dirs)))))
435 ;; This function is called from a subdirs.el file.
436 ;; It assumes that default-directory is the directory
437 ;; in which the subdirs.el file exists,
438 ;; and it adds to load-path the subdirs of that directory
439 ;; as specified in DIRS. Normally the elements of DIRS are relative.
440 (defun normal-top-level-add-to-load-path (dirs)
441 (let ((tail load-path)
442 (thisdir (directory-file-name default-directory)))
443 (while (and tail
444 ;;Don't go all the way to the nil terminator.
445 (cdr tail)
446 (not (equal thisdir (car tail)))
447 (not (and (memq system-type '(ms-dos windows-nt))
448 (equal (downcase thisdir) (downcase (car tail))))))
449 (setq tail (cdr tail)))
450 ;;Splice the new section in.
451 (when tail
452 (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail))))))
454 (defun normal-top-level ()
455 (if command-line-processed
456 (message "Back to top level.")
457 (setq command-line-processed t)
458 (let ((dir default-directory))
459 (with-current-buffer "*Messages*"
460 ;; Make it easy to do like "tail -f".
461 (set (make-local-variable 'window-point-insertion-type) t)
462 ;; Give *Messages* the same default-directory as *scratch*,
463 ;; just to keep things predictable.
464 (setq default-directory dir)))
465 ;; `user-full-name' is now known; reset its standard-value here.
466 (put 'user-full-name 'standard-value
467 (list (default-value 'user-full-name)))
468 ;; For root, preserve owner and group when editing files.
469 (if (equal (user-uid) 0)
470 (setq backup-by-copying-when-mismatch t))
471 ;; Look in each dir in load-path for a subdirs.el file.
472 ;; If we find one, load it, which will add the appropriate subdirs
473 ;; of that dir into load-path,
474 ;; Look for a leim-list.el file too. Loading it will register
475 ;; available input methods.
476 (let ((tail load-path) dir)
477 (while tail
478 (setq dir (car tail))
479 (let ((default-directory dir))
480 (load (expand-file-name "subdirs.el") t t t))
481 (let ((default-directory dir))
482 (load (expand-file-name "leim-list.el") t t t))
483 ;; We don't use a dolist loop and we put this "setq-cdr" command at
484 ;; the end, because the subdirs.el files may add elements to the end
485 ;; of load-path and we want to take it into account.
486 (setq tail (cdr tail))))
487 ;; If the PWD environment variable isn't accurate, delete it.
488 (let ((pwd (getenv "PWD")))
489 (and (stringp pwd)
490 ;; Use FOO/., so that if FOO is a symlink, file-attributes
491 ;; describes the directory linked to, not FOO itself.
492 (or (equal (file-attributes
493 (concat (file-name-as-directory pwd) "."))
494 (file-attributes
495 (concat (file-name-as-directory default-directory)
496 ".")))
497 (setq process-environment
498 (delete (concat "PWD=" pwd)
499 process-environment)))))
500 (setq default-directory (abbreviate-file-name default-directory))
501 (let ((old-face-font-rescale-alist face-font-rescale-alist))
502 (unwind-protect
503 (command-line)
504 ;; Do this again, in case .emacs defined more abbreviations.
505 (setq default-directory (abbreviate-file-name default-directory))
506 ;; Specify the file for recording all the auto save files of this session.
507 ;; This is used by recover-session.
508 (or auto-save-list-file-name
509 (and auto-save-list-file-prefix
510 (setq auto-save-list-file-name
511 ;; Under MS-DOS our PID is almost always reused between
512 ;; Emacs invocations. We need something more unique.
513 (cond ((eq system-type 'ms-dos)
514 ;; We are going to access the auto-save
515 ;; directory, so make sure it exists.
516 (make-directory
517 (file-name-directory auto-save-list-file-prefix)
519 (concat
520 (make-temp-name
521 (expand-file-name
522 auto-save-list-file-prefix))
523 "~"))
525 (expand-file-name
526 (format "%s%d-%s~"
527 auto-save-list-file-prefix
528 (emacs-pid)
529 (system-name))))))))
530 (unless inhibit-startup-hooks
531 (run-hooks 'emacs-startup-hook)
532 (and term-setup-hook
533 (run-hooks 'term-setup-hook)))
535 ;; Don't do this if we failed to create the initial frame,
536 ;; for instance due to a dense colormap.
537 (when (or frame-initial-frame
538 ;; If frame-initial-frame has no meaning, do this anyway.
539 (not (and initial-window-system
540 (not noninteractive)
541 (not (eq initial-window-system 'pc)))))
543 ;; FIXME: The user's init file may change
544 ;; face-font-rescale-alist. However, the default face
545 ;; already has an assigned font object, which does not take
546 ;; face-font-rescale-alist into account. For such
547 ;; situations, we ought to have a way to find all font
548 ;; objects and regenerate them; currently we do not. As a
549 ;; workaround, we specifically reset te default face's :font
550 ;; attribute here. See bug#1785.
551 (unless (eq face-font-rescale-alist
552 old-face-font-rescale-alist)
553 (set-face-attribute 'default nil :font (font-spec)))
555 ;; Modify the initial frame based on what .emacs puts into
556 ;; ...-frame-alist.
557 (if (fboundp 'frame-notice-user-settings)
558 (frame-notice-user-settings))
559 ;; Set the faces for the initial background mode even if
560 ;; frame-notice-user-settings didn't (such as on a tty).
561 ;; frame-set-background-mode is idempotent, so it won't
562 ;; cause any harm if it's already been done.
563 (if (fboundp 'frame-set-background-mode)
564 (frame-set-background-mode (selected-frame))))
566 ;; Now we know the user's default font, so add it to the menu.
567 (if (fboundp 'font-menu-add-default)
568 (font-menu-add-default))
569 (and window-setup-hook
570 (run-hooks 'window-setup-hook))))
571 ;; Subprocesses of Emacs do not have direct access to the terminal, so
572 ;; unless told otherwise they should only assume a dumb terminal.
573 ;; We are careful to do it late (after term-setup-hook), although the
574 ;; new multi-tty code does not use $TERM any more there anyway.
575 (setenv "TERM" "dumb")
576 ;; Remove DISPLAY from the process-environment as well. This allows
577 ;; `callproc.c' to give it a useful adaptive default which is either
578 ;; the value of the `display' frame-parameter or the DISPLAY value
579 ;; from initial-environment.
580 (let ((display (frame-parameter nil 'display)))
581 ;; Be careful which DISPLAY to remove from process-environment: follow
582 ;; the logic of `callproc.c'.
583 (if (stringp display) (setq display (concat "DISPLAY=" display))
584 (dolist (varval initial-environment)
585 (if (string-match "\\`DISPLAY=" varval)
586 (setq display varval))))
587 (when display
588 (delete display process-environment)))))
590 ;; Precompute the keyboard equivalents in the menu bar items.
591 ;; Command-line options supported by tty's:
592 (defconst tty-long-option-alist
593 '(("--name" . "-name")
594 ("--title" . "-T")
595 ("--reverse-video" . "-reverse")
596 ("--foreground-color" . "-fg")
597 ("--background-color" . "-bg")
598 ("--color" . "-color")))
600 (defconst tool-bar-images-pixel-height 24
601 "Height in pixels of images in the tool-bar.")
603 (defvar tool-bar-originally-present nil
604 "Non-nil if tool-bars are present before user and site init files are read.")
606 (defvar handle-args-function-alist '((nil . tty-handle-args))
607 "Functions for processing window-system dependent command-line arguments.
608 Window system startup files should add their own function to this
609 alist, which should parse the command line arguments. Those
610 pertaining to the window system should be processed and removed
611 from the returned command line.")
613 (defvar window-system-initialization-alist '((nil . ignore))
614 "Alist of window-system initialization functions.
615 Window-system startup files should add their own initialization
616 function to this list. The function should take no arguments,
617 and initialize the window system environment to prepare for
618 opening the first frame (e.g. open a connection to an X server).")
620 ;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
621 (defun tty-handle-args (args)
622 (let (rest)
623 (message "%S" args)
624 (while (and args
625 (not (equal (car args) "--")))
626 (let* ((argi (pop args))
627 (orig-argi argi)
628 argval completion)
629 ;; Check for long options with attached arguments
630 ;; and separate out the attached option argument into argval.
631 (when (string-match "^\\(--[^=]*\\)=" argi)
632 (setq argval (substring argi (match-end 0))
633 argi (match-string 1 argi)))
634 (when (string-match "^--" argi)
635 (setq completion (try-completion argi tty-long-option-alist))
636 (if (eq completion t)
637 ;; Exact match for long option.
638 (setq argi (cdr (assoc argi tty-long-option-alist)))
639 (if (stringp completion)
640 (let ((elt (assoc completion tty-long-option-alist)))
641 ;; Check for abbreviated long option.
642 (or elt
643 (error "Option `%s' is ambiguous" argi))
644 (setq argi (cdr elt)))
645 ;; Check for a short option.
646 (setq argval nil
647 argi orig-argi))))
648 (cond ((member argi '("-fg" "-foreground"))
649 (push (cons 'foreground-color (or argval (pop args)))
650 default-frame-alist))
651 ((member argi '("-bg" "-background"))
652 (push (cons 'background-color (or argval (pop args)))
653 default-frame-alist))
654 ((member argi '("-T" "-name"))
655 (unless argval (setq argval (pop args)))
656 (push (cons 'title
657 (if (stringp argval)
658 argval
659 (let ((case-fold-search t)
661 (setq argval (invocation-name))
663 ;; Change any . or * characters in name to
664 ;; hyphens, so as to emulate behavior on X.
665 (while
666 (setq i (string-match "[.*]" argval))
667 (aset argval i ?-))
668 argval)))
669 default-frame-alist))
670 ((member argi '("-r" "-rv" "-reverse"))
671 (push '(reverse . t)
672 default-frame-alist))
673 ((equal argi "-color")
674 (unless argval (setq argval 8)) ; default --color means 8 ANSI colors
675 (push (cons 'tty-color-mode
676 (cond
677 ((numberp argval) argval)
678 ((string-match "-?[0-9]+" argval)
679 (string-to-number argval))
680 (t (intern argval))))
681 default-frame-alist))
683 (push argi rest)))))
684 (nreverse rest)))
686 (declare-function x-get-resource "frame.c"
687 (attribute class &optional component subclass))
688 (declare-function tool-bar-mode "tool-bar" (&optional arg))
689 (declare-function tool-bar-setup "tool-bar")
691 (defvar server-name)
692 (defvar server-process)
694 (defun command-line ()
695 (setq before-init-time (current-time)
696 after-init-time nil
697 command-line-default-directory default-directory)
699 ;; Force recomputation, in case it was computed during the dump.
700 (setq abbreviated-home-dir nil)
702 ;; See if we should import version-control from the environment variable.
703 (let ((vc (getenv "VERSION_CONTROL")))
704 (cond ((eq vc nil)) ;don't do anything if not set
705 ((member vc '("t" "numbered"))
706 (setq version-control t))
707 ((member vc '("nil" "existing"))
708 (setq version-control nil))
709 ((member vc '("never" "simple"))
710 (setq version-control 'never))))
712 ;;! This has been commented out; I currently find the behavior when
713 ;;! split-window-keep-point is nil disturbing, but if I can get used
714 ;;! to it, then it would be better to eliminate the option.
715 ;;! ;; Choose a good default value for split-window-keep-point.
716 ;;! (setq split-window-keep-point (> baud-rate 2400))
718 ;; Set the default strings to display in mode line for
719 ;; end-of-line formats that aren't native to this platform.
720 (cond
721 ((memq system-type '(ms-dos windows-nt))
722 (setq eol-mnemonic-unix "(Unix)"
723 eol-mnemonic-mac "(Mac)"))
724 (t ; this is for Unix/GNU/Linux systems
725 (setq eol-mnemonic-dos "(DOS)"
726 eol-mnemonic-mac "(Mac)")))
728 (set-locale-environment nil)
730 ;; Convert preloaded file names in load-history to absolute.
731 (let ((simple-file-name
732 ;; Look for simple.el or simple.elc and use their directory
733 ;; as the place where all Lisp files live.
734 (locate-file "simple" load-path (get-load-suffixes)))
735 lisp-dir)
736 ;; Don't abort if simple.el cannot be found, but print a warning.
737 (if (null simple-file-name)
738 (progn
739 (princ "Warning: Could not find simple.el nor simple.elc"
740 'external-debugging-output)
741 (terpri 'external-debugging-output))
742 (setq lisp-dir (file-truename (file-name-directory simple-file-name)))
743 (setq load-history
744 (mapcar (lambda (elt)
745 (if (and (stringp (car elt))
746 (not (file-name-absolute-p (car elt))))
747 (cons (concat lisp-dir
748 (car elt))
749 (cdr elt))
750 elt))
751 load-history))))
753 ;; Convert the arguments to Emacs internal representation.
754 (let ((args (cdr command-line-args)))
755 (while args
756 (setcar args
757 (decode-coding-string (car args) locale-coding-system t))
758 (pop args)))
760 (let ((done nil)
761 (args (cdr command-line-args))
762 display-arg)
764 ;; Figure out which user's init file to load,
765 ;; either from the environment or from the options.
766 (setq init-file-user (if noninteractive nil (user-login-name)))
767 ;; If user has not done su, use current $HOME to find .emacs.
768 (and init-file-user
769 (equal init-file-user (user-real-login-name))
770 (setq init-file-user ""))
772 ;; Process the command-line args, and delete the arguments
773 ;; processed. This is consistent with the way main in emacs.c
774 ;; does things.
775 (while (and (not done) args)
776 (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--debug-init")
777 ("--user") ("--iconic") ("--icon-type") ("--quick")
778 ("--no-blinking-cursor") ("--basic-display")))
779 (argi (pop args))
780 (orig-argi argi)
781 argval)
782 ;; Handle --OPTION=VALUE format.
783 (when (string-match "\\`\\(--[^=]*\\)=" argi)
784 (setq argval (substring argi (match-end 0))
785 argi (match-string 1 argi)))
786 (when (string-match "\\`--." orig-argi)
787 (let ((completion (try-completion argi longopts)))
788 (cond ((eq completion t)
789 (setq argi (substring argi 1)))
790 ((stringp completion)
791 (let ((elt (assoc completion longopts)))
792 (unless elt
793 (error "Option `%s' is ambiguous" argi))
794 (setq argi (substring (car elt) 1))))
796 (setq argval nil
797 argi orig-argi)))))
798 (cond
799 ;; The --display arg is handled partly in C, partly in Lisp.
800 ;; When it shows up here, we just put it back to be handled
801 ;; by `command-line-1'.
802 ((member argi '("-d" "-display"))
803 (setq display-arg (list argi (pop args))))
804 ((member argi '("-Q" "-quick"))
805 (setq init-file-user nil
806 site-run-file nil
807 inhibit-x-resources t))
808 ((member argi '("-D" "-basic-display"))
809 (setq no-blinking-cursor t
810 emacs-basic-display t)
811 (push '(vertical-scroll-bars . nil) initial-frame-alist))
812 ((member argi '("-q" "-no-init-file"))
813 (setq init-file-user nil))
814 ((member argi '("-u" "-user"))
815 (setq init-file-user (or argval (pop args))
816 argval nil))
817 ((equal argi "-no-site-file")
818 (setq site-run-file nil))
819 ((equal argi "-debug-init")
820 (setq init-file-debug t))
821 ((equal argi "-iconic")
822 (push '(visibility . icon) initial-frame-alist))
823 ((member argi '("-nbc" "-no-blinking-cursor"))
824 (setq no-blinking-cursor t))
825 ;; Push the popped arg back on the list of arguments.
827 (push argi args)
828 (setq done t)))
829 ;; Was argval set but not used?
830 (and argval
831 (error "Option `%s' doesn't allow an argument" argi))))
833 ;; Re-attach the --display arg.
834 (and display-arg (setq args (append display-arg args)))
836 ;; Re-attach the program name to the front of the arg list.
837 (and command-line-args
838 (setcdr command-line-args args)))
840 ;; Make sure window system's init file was loaded in loadup.el if
841 ;; using a window system.
842 ;; Initialize the window-system only after processing the command-line
843 ;; args so that -Q can influence this initialization.
844 (condition-case error
845 (unless noninteractive
846 (if (and initial-window-system
847 (not (featurep
848 (intern
849 (concat (symbol-name initial-window-system) "-win")))))
850 (error "Unsupported window system `%s'" initial-window-system))
851 ;; Process window-system specific command line parameters.
852 (setq command-line-args
853 (funcall
854 (or (cdr (assq initial-window-system handle-args-function-alist))
855 (error "Unsupported window system `%s'" initial-window-system))
856 command-line-args))
857 ;; Initialize the window system. (Open connection, etc.)
858 (funcall
859 (or (cdr (assq initial-window-system window-system-initialization-alist))
860 (error "Unsupported window system `%s'" initial-window-system))))
861 ;; If there was an error, print the error message and exit.
862 (error
863 (princ
864 (if (eq (car error) 'error)
865 (apply 'concat (cdr error))
866 (if (memq 'file-error (get (car error) 'error-conditions))
867 (format "%s: %s"
868 (nth 1 error)
869 (mapconcat (lambda (obj) (prin1-to-string obj t))
870 (cdr (cdr error)) ", "))
871 (format "%s: %s"
872 (get (car error) 'error-message)
873 (mapconcat (lambda (obj) (prin1-to-string obj t))
874 (cdr error) ", "))))
875 'external-debugging-output)
876 (terpri 'external-debugging-output)
877 (setq initial-window-system nil)
878 (kill-emacs)))
880 (run-hooks 'before-init-hook)
882 ;; Under X, this creates the X frame and deletes the terminal frame.
883 (unless (daemonp)
884 ;; Enable or disable the tool-bar and menu-bar.
885 ;; While we're at it, set `no-blinking-cursor' too.
886 (cond
887 ((or noninteractive emacs-basic-display)
888 (setq menu-bar-mode nil
889 tool-bar-mode nil
890 no-blinking-cursor t))
891 ;; Check X resources if available.
892 ((memq initial-window-system '(x w32 ns))
893 (let ((no-vals '("no" "off" "false" "0")))
894 (if (member (x-get-resource "menuBar" "MenuBar") no-vals)
895 (setq menu-bar-mode nil))
896 (if (member (x-get-resource "toolBar" "ToolBar") no-vals)
897 (setq tool-bar-mode nil))
898 (if (member (x-get-resource "cursorBlink" "CursorBlink")
899 no-vals)
900 (setq no-blinking-cursor t)))))
901 (frame-initialize))
903 (when (fboundp 'x-create-frame)
904 ;; Set up the tool-bar (even in tty frames, since Emacs might open a
905 ;; graphical frame later).
906 (unless noninteractive
907 (tool-bar-setup)))
909 ;; Turn off blinking cursor if so specified in X resources. This is here
910 ;; only because all other settings of no-blinking-cursor are here.
911 (unless (or noninteractive
912 emacs-basic-display
913 (and (memq window-system '(x w32 ns))
914 (not (member (x-get-resource "cursorBlink" "CursorBlink")
915 '("off" "false")))))
916 (setq no-blinking-cursor t))
918 ;; Re-evaluate predefined variables whose initial value depends on
919 ;; the runtime context.
920 (mapc 'custom-reevaluate-setting
921 ;; Initialize them in the same order they were loaded, in case there
922 ;; are dependencies between them.
923 (prog1 (nreverse custom-delayed-init-variables)
924 (setq custom-delayed-init-variables nil)))
926 (normal-erase-is-backspace-setup-frame)
928 ;; Register default TTY colors for the case the terminal hasn't a
929 ;; terminal init file. We do this regardles of whether the terminal
930 ;; supports colors or not and regardless the current display type,
931 ;; since users can connect to color-capable terminals and also
932 ;; switch color support on or off in mid-session by setting the
933 ;; tty-color-mode frame parameter.
934 ;; Exception: the `pc' ``window system'' has only 16 fixed colors,
935 ;; and they are already set at this point by a suitable function in
936 ;; window-system-initialization-alist.
937 (or (eq initial-window-system 'pc)
938 (tty-register-default-colors))
940 ;; Record whether the tool-bar is present before the user and site
941 ;; init files are processed. frame-notice-user-settings uses this
942 ;; to determine if the tool-bar has been disabled by the init files,
943 ;; and the frame needs to be resized.
944 (when (fboundp 'frame-notice-user-settings)
945 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
946 (assq 'tool-bar-lines default-frame-alist))))
947 (setq tool-bar-originally-present
948 (and tool-bar-lines
949 (cdr tool-bar-lines)
950 (not (eq 0 (cdr tool-bar-lines)))))))
952 (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
953 (old-font-list-limit font-list-limit)
954 (old-face-ignored-fonts face-ignored-fonts))
956 ;; Run the site-start library if it exists. The point of this file is
957 ;; that it is run before .emacs. There is no point in doing this after
958 ;; .emacs; that is useless.
959 ;; Note that user-init-file is nil at this point. Code that might
960 ;; be loaded from site-run-file and wants to test if -q was given
961 ;; should check init-file-user instead, since that is already set.
962 ;; See cus-edit.el for an example.
963 (if site-run-file
964 (load site-run-file t t))
966 ;; Sites should not disable this. Only individuals should disable
967 ;; the startup screen.
968 (setq inhibit-startup-screen nil)
970 ;; Warn for invalid user name.
971 (when init-file-user
972 (if (string-match "[~/:\n]" init-file-user)
973 (display-warning 'initialization
974 (format "Invalid user name %s"
975 init-file-user)
976 :error)
977 (if (file-directory-p (expand-file-name
978 ;; We don't support ~USER on MS-Windows
979 ;; and MS-DOS except for the current
980 ;; user, and always load .emacs from
981 ;; the current user's home directory
982 ;; (see below). So always check "~",
983 ;; even if invoked with "-u USER", or
984 ;; if $USER or $LOGNAME are set to
985 ;; something different.
986 (if (memq system-type '(windows-nt ms-dos))
988 (concat "~" init-file-user))))
990 (display-warning 'initialization
991 (format "User %s has no home directory"
992 init-file-user)
993 :error))))
995 ;; Load that user's init file, or the default one, or none.
996 (let (debug-on-error-from-init-file
997 debug-on-error-should-be-set
998 (debug-on-error-initial
999 (if (eq init-file-debug t) 'startup init-file-debug))
1000 (orig-enable-multibyte (default-value 'enable-multibyte-characters)))
1001 (let ((debug-on-error debug-on-error-initial)
1002 ;; This function actually reads the init files.
1003 (inner
1004 (function
1005 (lambda ()
1006 (if init-file-user
1007 (let ((user-init-file-1
1008 (cond
1009 ((eq system-type 'ms-dos)
1010 (concat "~" init-file-user "/_emacs"))
1011 ((eq system-type 'windows-nt)
1012 ;; Prefer .emacs on Windows.
1013 (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
1014 "~/.emacs"
1015 ;; Also support _emacs for compatibility.
1016 (if (directory-files "~" nil "^_emacs\\(\\.elc?\\)?$")
1017 "~/_emacs"
1018 ;; But default to .emacs if _emacs does not exist.
1019 "~/.emacs")))
1021 (concat "~" init-file-user "/.emacs")))))
1022 ;; This tells `load' to store the file name found
1023 ;; into user-init-file.
1024 (setq user-init-file t)
1025 (load user-init-file-1 t t)
1027 (when (eq user-init-file t)
1028 ;; If we did not find ~/.emacs, try
1029 ;; ~/.emacs.d/init.el.
1030 (let ((otherfile
1031 (expand-file-name
1032 "init"
1033 (file-name-as-directory
1034 (concat "~" init-file-user "/.emacs.d")))))
1035 (load otherfile t t)
1037 ;; If we did not find the user's init file,
1038 ;; set user-init-file conclusively.
1039 ;; Don't let it be set from default.el.
1040 (when (eq user-init-file t)
1041 (setq user-init-file user-init-file-1))))
1043 ;; If we loaded a compiled file, set
1044 ;; `user-init-file' to the source version if that
1045 ;; exists.
1046 (when (and user-init-file
1047 (equal (file-name-extension user-init-file)
1048 "elc"))
1049 (let* ((source (file-name-sans-extension user-init-file))
1050 (alt (concat source ".el")))
1051 (setq source (cond ((file-exists-p alt) alt)
1052 ((file-exists-p source) source)
1053 (t nil)))
1054 (when source
1055 (when (file-newer-than-file-p source user-init-file)
1056 (message "Warning: %s is newer than %s"
1057 source user-init-file)
1058 (sit-for 1))
1059 (setq user-init-file source))))
1061 (unless inhibit-default-init
1062 (let ((inhibit-startup-screen nil))
1063 ;; Users are supposed to be told their rights.
1064 ;; (Plus how to get help and how to undo.)
1065 ;; Don't you dare turn this off for anyone
1066 ;; except yourself.
1067 (load "default" t t)))))))))
1068 (if init-file-debug
1069 ;; Do this without a condition-case if the user wants to debug.
1070 (funcall inner)
1071 (condition-case error
1072 (progn
1073 (funcall inner)
1074 (setq init-file-had-error nil))
1075 (error
1076 (display-warning
1077 'initialization
1078 (format "An error occurred while loading `%s':\n\n%s%s%s\n\n\
1079 To ensure normal operation, you should investigate and remove the
1080 cause of the error in your initialization file. Start Emacs with
1081 the `--debug-init' option to view a complete error backtrace."
1082 user-init-file
1083 (get (car error) 'error-message)
1084 (if (cdr error) ": " "")
1085 (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
1086 :warning)
1087 (setq init-file-had-error t))))
1089 (if (and deactivate-mark transient-mark-mode)
1090 (with-current-buffer (window-buffer)
1091 (deactivate-mark)))
1093 ;; If the user has a file of abbrevs, read it (unless -batch).
1094 (when (and (not noninteractive)
1095 (file-exists-p abbrev-file-name)
1096 (file-readable-p abbrev-file-name))
1097 (quietly-read-abbrev-file abbrev-file-name))
1099 ;; If the abbrevs came entirely from the init file or the
1100 ;; abbrevs file, they do not need saving.
1101 (setq abbrevs-changed nil)
1103 ;; If we can tell that the init file altered debug-on-error,
1104 ;; arrange to preserve the value that it set up.
1105 (or (eq debug-on-error debug-on-error-initial)
1106 (setq debug-on-error-should-be-set t
1107 debug-on-error-from-init-file debug-on-error)))
1108 (if debug-on-error-should-be-set
1109 (setq debug-on-error debug-on-error-from-init-file))
1110 (unless (or (default-value 'enable-multibyte-characters)
1111 (eq orig-enable-multibyte (default-value
1112 'enable-multibyte-characters)))
1113 ;; Init file changed to unibyte. Reset existing multibyte
1114 ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
1115 ;; Arguably this should only be done if they're free of
1116 ;; multibyte characters.
1117 (mapc (lambda (buffer)
1118 (with-current-buffer buffer
1119 (if enable-multibyte-characters
1120 (set-buffer-multibyte nil))))
1121 (buffer-list))
1122 ;; Also re-set the language environment in case it was
1123 ;; originally done before unibyte was set and is sensitive to
1124 ;; unibyte (display table, terminal coding system &c).
1125 (set-language-environment current-language-environment)))
1127 ;; Do this here in case the init file sets mail-host-address.
1128 (if (equal user-mail-address "")
1129 (setq user-mail-address (or (getenv "EMAIL")
1130 (concat (user-login-name) "@"
1131 (or mail-host-address
1132 (system-name))))))
1134 ;; Originally face attributes were specified via
1135 ;; `font-lock-face-attributes'. Users then changed the default
1136 ;; face attributes by setting that variable. However, we try and
1137 ;; be back-compatible and respect its value if set except for
1138 ;; faces where M-x customize has been used to save changes for the
1139 ;; face.
1140 (when (boundp 'font-lock-face-attributes)
1141 (let ((face-attributes font-lock-face-attributes))
1142 (while face-attributes
1143 (let* ((face-attribute (pop face-attributes))
1144 (face (car face-attribute)))
1145 ;; Rustle up a `defface' SPEC from a
1146 ;; `font-lock-face-attributes' entry.
1147 (unless (get face 'saved-face)
1148 (let ((foreground (nth 1 face-attribute))
1149 (background (nth 2 face-attribute))
1150 (bold-p (nth 3 face-attribute))
1151 (italic-p (nth 4 face-attribute))
1152 (underline-p (nth 5 face-attribute))
1153 face-spec)
1154 (when foreground
1155 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1156 (when background
1157 (setq face-spec (cons ':background (cons background face-spec))))
1158 (when bold-p
1159 (setq face-spec (append '(:weight bold) face-spec)))
1160 (when italic-p
1161 (setq face-spec (append '(:slant italic) face-spec)))
1162 (when underline-p
1163 (setq face-spec (append '(:underline t) face-spec)))
1164 (face-spec-set face (list (list t face-spec)) nil)))))))
1166 ;; If parameter have been changed in the init file which influence
1167 ;; face realization, clear the face cache so that new faces will
1168 ;; be realized.
1169 (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed)
1170 (eq font-list-limit old-font-list-limit)
1171 (eq face-ignored-fonts old-face-ignored-fonts))
1172 (clear-face-cache)))
1174 ;; Load ELPA packages.
1175 (and user-init-file package-enable-at-startup (package-initialize))
1177 (setq after-init-time (current-time))
1178 (run-hooks 'after-init-hook)
1180 ;; Decode all default-directory.
1181 (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
1182 (save-excursion
1183 (dolist (elt (buffer-list))
1184 (set-buffer elt)
1185 (if default-directory
1186 (setq default-directory
1187 (decode-coding-string default-directory
1188 locale-coding-system t))))
1189 (setq command-line-default-directory
1190 (decode-coding-string command-line-default-directory
1191 locale-coding-system t))))
1193 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1194 (if (get-buffer "*scratch*")
1195 (with-current-buffer "*scratch*"
1196 (if (eq major-mode 'fundamental-mode)
1197 (funcall initial-major-mode))))
1199 ;; Load library for our terminal type.
1200 ;; User init file can set term-file-prefix to nil to prevent this.
1201 (unless (or noninteractive
1202 initial-window-system)
1203 (tty-run-terminal-initialization (selected-frame)))
1205 ;; Update the out-of-memory error message based on user's key bindings
1206 ;; for save-some-buffers.
1207 (setq memory-signal-data
1208 (list 'error
1209 (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs")))
1211 ;; Process the remaining args.
1212 (command-line-1 (cdr command-line-args))
1214 ;; If -batch, terminate after processing the command options.
1215 (if noninteractive (kill-emacs t))
1217 ;; In daemon mode, start the server to allow clients to connect.
1218 ;; This is done after loading the user's init file and after
1219 ;; processing all command line arguments to allow e.g. `server-name'
1220 ;; to be changed before the server starts.
1221 (let ((dn (daemonp)))
1222 (when dn
1223 (when (stringp dn) (setq server-name dn))
1224 (server-start)
1225 (if server-process
1226 (daemon-initialized)
1227 (if (stringp dn)
1228 (message
1229 "Unable to start daemon: Emacs server named %S already running"
1230 server-name)
1231 (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process."))
1232 (kill-emacs 1))))
1234 ;; Run emacs-session-restore (session management) if started by
1235 ;; the session manager and we have a session manager connection.
1236 (if (and (boundp 'x-session-previous-id)
1237 (stringp x-session-previous-id))
1238 (with-no-warnings
1239 (emacs-session-restore x-session-previous-id))))
1241 (defcustom initial-scratch-message (purecopy "\
1242 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.
1243 ;; If you want to create a file, visit that file with C-x C-f,
1244 ;; then enter the text in that file's own buffer.
1247 "Initial message displayed in *scratch* buffer at startup.
1248 If this is nil, no message will be displayed."
1249 :type '(choice (text :tag "Message")
1250 (const :tag "none" nil))
1251 :group 'initialization)
1254 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1255 ;;; Fancy splash screen
1256 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1258 (defconst fancy-startup-text
1259 '((:face (variable-pitch (:foreground "red"))
1260 "Welcome to "
1261 :link ("GNU Emacs"
1262 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/"))
1263 "Browse http://www.gnu.org/software/emacs/")
1264 ", one component of the "
1265 :link
1266 (lambda ()
1267 (if (eq system-type 'gnu/linux)
1268 '("GNU/Linux"
1269 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1270 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1271 '("GNU" (lambda (button) (describe-gnu-project))
1272 "Display info on the GNU project")))
1273 " operating system.\n\n"
1274 :face variable-pitch
1275 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1276 "\tLearn basic keystroke commands"
1277 (lambda ()
1278 (let* ((en "TUTORIAL")
1279 (tut (or (get-language-info current-language-environment
1280 'tutorial)
1281 en))
1282 (title (with-temp-buffer
1283 (insert-file-contents
1284 (expand-file-name tut tutorial-directory)
1285 nil 0 256)
1286 (search-forward ".")
1287 (buffer-substring (point-min) (1- (point))))))
1288 ;; If there is a specific tutorial for the current language
1289 ;; environment and it is not English, append its title.
1290 (if (string= en tut)
1292 (concat " (" title ")"))))
1293 "\n"
1294 :link ("Emacs Guided Tour"
1295 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
1296 "Browse http://www.gnu.org/software/emacs/tour/")
1297 "\tOverview of Emacs features at gnu.org\n"
1298 :link ("View Emacs Manual" (lambda (button) (info-emacs-manual)))
1299 "\tView the Emacs manual using Info\n"
1300 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1301 "\tGNU Emacs comes with "
1302 :face (variable-pitch (:slant oblique))
1303 "ABSOLUTELY NO WARRANTY\n"
1304 :face variable-pitch
1305 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1306 "\tConditions for redistributing and changing Emacs\n"
1307 :link ("Ordering Manuals" (lambda (button) (view-order-manuals)))
1308 "\tPurchasing printed copies of manuals\n"
1309 "\n"))
1310 "A list of texts to show in the middle part of splash screens.
1311 Each element in the list should be a list of strings or pairs
1312 `:face FACE', like `fancy-splash-insert' accepts them.")
1314 (defconst fancy-about-text
1315 '((:face (variable-pitch (:foreground "red"))
1316 "This is "
1317 :link ("GNU Emacs"
1318 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/"))
1319 "Browse http://www.gnu.org/software/emacs/")
1320 ", one component of the "
1321 :link
1322 (lambda ()
1323 (if (eq system-type 'gnu/linux)
1324 '("GNU/Linux"
1325 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
1326 "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
1327 '("GNU" (lambda (button) (describe-gnu-project))
1328 "Display info on the GNU project.")))
1329 " operating system.\n"
1330 :face (lambda ()
1331 (list 'variable-pitch
1332 (list :foreground
1333 (if (eq (frame-parameter nil 'background-mode) 'dark)
1334 "cyan" "darkblue"))))
1335 "\n"
1336 (lambda () (emacs-version))
1337 "\n"
1338 :face (variable-pitch (:height 0.8))
1339 (lambda () emacs-copyright)
1340 "\n\n"
1341 :face variable-pitch
1342 :link ("Authors"
1343 (lambda (button)
1344 (view-file (expand-file-name "AUTHORS" data-directory))
1345 (goto-char (point-min))))
1346 "\tMany people have contributed code included in GNU Emacs\n"
1347 :link ("Contributing"
1348 (lambda (button)
1349 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1350 (goto-char (point-min))))
1351 "\tHow to contribute improvements to Emacs\n"
1352 "\n"
1353 :link ("GNU and Freedom" (lambda (button) (describe-gnu-project)))
1354 "\tWhy we developed GNU Emacs, and the GNU operating system\n"
1355 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty)))
1356 "\tGNU Emacs comes with "
1357 :face (variable-pitch (:slant oblique))
1358 "ABSOLUTELY NO WARRANTY\n"
1359 :face variable-pitch
1360 :link ("Copying Conditions" (lambda (button) (describe-copying)))
1361 "\tConditions for redistributing and changing Emacs\n"
1362 :link ("Getting New Versions" (lambda (button) (describe-distribution)))
1363 "\tHow to obtain the latest version of Emacs\n"
1364 :link ("Ordering Manuals" (lambda (button) (view-order-manuals)))
1365 "\tBuying printed manuals from the FSF\n"
1366 "\n"
1367 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
1368 "\tLearn basic Emacs keystroke commands"
1369 (lambda ()
1370 (let* ((en "TUTORIAL")
1371 (tut (or (get-language-info current-language-environment
1372 'tutorial)
1373 en))
1374 (title (with-temp-buffer
1375 (insert-file-contents
1376 (expand-file-name tut tutorial-directory)
1377 nil 0 256)
1378 (search-forward ".")
1379 (buffer-substring (point-min) (1- (point))))))
1380 ;; If there is a specific tutorial for the current language
1381 ;; environment and it is not English, append its title.
1382 (if (string= en tut)
1384 (concat " (" title ")"))))
1385 "\n"
1386 :link ("Emacs Guided Tour"
1387 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
1388 "Browse http://www.gnu.org/software/emacs/tour/")
1389 "\tSee an overview of Emacs features at gnu.org"
1391 "A list of texts to show in the middle part of the About screen.
1392 Each element in the list should be a list of strings or pairs
1393 `:face FACE', like `fancy-splash-insert' accepts them.")
1396 (defgroup fancy-splash-screen ()
1397 "Fancy splash screen when Emacs starts."
1398 :version "21.1"
1399 :group 'initialization)
1401 (defcustom fancy-splash-image nil
1402 "The image to show in the splash screens, or nil for defaults."
1403 :group 'fancy-splash-screen
1404 :type '(choice (const :tag "Default" nil)
1405 (file :tag "File")))
1408 (defvar splash-screen-keymap
1409 (let ((map (make-sparse-keymap)))
1410 (suppress-keymap map)
1411 (set-keymap-parent map button-buffer-map)
1412 (define-key map "\C-?" 'scroll-down)
1413 (define-key map " " 'scroll-up)
1414 (define-key map "q" 'exit-splash-screen)
1415 map)
1416 "Keymap for splash screen buffer.")
1418 ;; These are temporary storage areas for the splash screen display.
1420 (defun fancy-splash-insert (&rest args)
1421 "Insert text into the current buffer, with faces.
1422 Arguments from ARGS should be either strings; functions called
1423 with no args that return a string; pairs `:face FACE', where FACE
1424 is a face specification usable with `put-text-property'; or pairs
1425 `:link LINK' where LINK is a list of arguments to pass to
1426 `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which
1427 specifies the button's label, `action' property and help-echo string.
1428 FACE and LINK can also be functions, which are evaluated to obtain
1429 a face or button specification."
1430 (let ((current-face nil))
1431 (while args
1432 (cond ((eq (car args) :face)
1433 (setq args (cdr args) current-face (car args))
1434 (if (functionp current-face)
1435 (setq current-face (funcall current-face))))
1436 ((eq (car args) :link)
1437 (setq args (cdr args))
1438 (let ((spec (car args)))
1439 (if (functionp spec)
1440 (setq spec (funcall spec)))
1441 (insert-button (car spec)
1442 'face (list 'link current-face)
1443 'action (cadr spec)
1444 'help-echo (concat "mouse-2, RET: "
1445 (or (nth 2 spec)
1446 "Follow this link"))
1447 'follow-link t)))
1448 (t (insert (propertize (let ((it (car args)))
1449 (if (functionp it)
1450 (funcall it)
1451 it))
1452 'face current-face
1453 'help-echo (startup-echo-area-message)))))
1454 (setq args (cdr args)))))
1456 (declare-function image-size "image.c" (spec &optional pixels frame))
1458 (defun fancy-splash-head ()
1459 "Insert the head part of the splash screen into the current buffer."
1460 (let* ((image-file (cond ((stringp fancy-splash-image)
1461 fancy-splash-image)
1462 ((display-color-p)
1463 (cond ((<= (display-planes) 8)
1464 (if (image-type-available-p 'xpm)
1465 "splash.xpm"
1466 "splash.pbm"))
1467 ((image-type-available-p 'svg)
1468 "splash.svg")
1469 ((image-type-available-p 'png)
1470 "splash.png")
1471 ((image-type-available-p 'xpm)
1472 "splash.xpm")
1473 (t "splash.pbm")))
1474 (t "splash.pbm")))
1475 (img (create-image image-file))
1476 (image-width (and img (car (image-size img))))
1477 (window-width (window-width (selected-window))))
1478 (when img
1479 (when (> window-width image-width)
1480 ;; Center the image in the window.
1481 (insert (propertize " " 'display
1482 `(space :align-to (+ center (-0.5 . ,img)))))
1484 ;; Change the color of the XPM version of the splash image
1485 ;; so that it is visible with a dark frame background.
1486 (when (and (memq 'xpm img)
1487 (eq (frame-parameter nil 'background-mode) 'dark))
1488 (setq img (append img '(:color-symbols (("#000000" . "gray30"))))))
1490 ;; Insert the image with a help-echo and a link.
1491 (make-button (prog1 (point) (insert-image img)) (point)
1492 'face 'default
1493 'help-echo "mouse-2, RET: Browse http://www.gnu.org/"
1494 'action (lambda (button) (browse-url "http://www.gnu.org/"))
1495 'follow-link t)
1496 (insert "\n\n")))))
1498 (defun fancy-startup-tail (&optional concise)
1499 "Insert the tail part of the splash screen into the current buffer."
1500 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark)
1501 "cyan" "darkblue")))
1502 (unless concise
1503 (fancy-splash-insert
1504 :face 'variable-pitch
1505 "\nTo start... "
1506 :link '("Open a File"
1507 (lambda (button) (call-interactively 'find-file))
1508 "Specify a new file's name, to edit the file")
1510 :link '("Open Home Directory"
1511 (lambda (button) (dired "~"))
1512 "Open your home directory, to operate on its files")
1514 :link '("Customize Startup"
1515 (lambda (button) (customize-group 'initialization))
1516 "Change initialization settings including this screen")
1517 "\n"))
1518 (fancy-splash-insert
1519 :face 'variable-pitch "To quit a partially entered command, type "
1520 :face 'default "Control-g"
1521 :face 'variable-pitch ".\n")
1522 (fancy-splash-insert :face `(variable-pitch (:foreground ,fg))
1523 "\nThis is "
1524 (emacs-version)
1525 "\n"
1526 :face '(variable-pitch (:height 0.8))
1527 emacs-copyright
1528 "\n")
1529 (and auto-save-list-file-prefix
1530 ;; Don't signal an error if the
1531 ;; directory for auto-save-list files
1532 ;; does not yet exist.
1533 (file-directory-p (file-name-directory
1534 auto-save-list-file-prefix))
1535 (directory-files
1536 (file-name-directory auto-save-list-file-prefix)
1538 (concat "\\`"
1539 (regexp-quote (file-name-nondirectory
1540 auto-save-list-file-prefix)))
1542 (fancy-splash-insert :face '(variable-pitch (:foreground "red"))
1543 "\nIf an Emacs session crashed recently, "
1544 "type "
1545 :face '(fixed-pitch :foreground "red")
1546 "Meta-x recover-session RET"
1547 :face '(variable-pitch (:foreground "red"))
1548 "\nto recover"
1549 " the files you were editing."))
1551 (when concise
1552 (fancy-splash-insert
1553 :face 'variable-pitch "\n"
1554 :link '("Dismiss this startup screen"
1555 (lambda (button)
1556 (when startup-screen-inhibit-startup-screen
1557 (customize-set-variable 'inhibit-startup-screen t)
1558 (customize-mark-to-save 'inhibit-startup-screen)
1559 (custom-save-all))
1560 (let ((w (get-buffer-window "*GNU Emacs*")))
1561 (and w (not (one-window-p)) (delete-window w)))
1562 (kill-buffer "*GNU Emacs*")))
1563 " ")
1564 (when (or user-init-file custom-file)
1565 (let ((checked (create-image "\300\300\141\143\067\076\034\030"
1566 'xbm t :width 8 :height 8 :background "grey75"
1567 :foreground "black" :relief -2 :ascent 'center))
1568 (unchecked (create-image (make-string 8 0)
1569 'xbm t :width 8 :height 8 :background "grey75"
1570 :foreground "black" :relief -2 :ascent 'center)))
1571 (insert-button
1572 " " :on-glyph checked :off-glyph unchecked 'checked nil
1573 'display unchecked 'follow-link t
1574 'action (lambda (button)
1575 (if (overlay-get button 'checked)
1576 (progn (overlay-put button 'checked nil)
1577 (overlay-put button 'display (overlay-get button :off-glyph))
1578 (setq startup-screen-inhibit-startup-screen nil))
1579 (overlay-put button 'checked t)
1580 (overlay-put button 'display (overlay-get button :on-glyph))
1581 (setq startup-screen-inhibit-startup-screen t)))))
1582 (fancy-splash-insert :face '(variable-pitch (:height 0.9))
1583 " Never show it again.")))))
1585 (defun exit-splash-screen ()
1586 "Stop displaying the splash screen buffer."
1587 (interactive)
1588 (quit-window t))
1590 (defun fancy-startup-screen (&optional concise)
1591 "Display fancy startup screen.
1592 If CONCISE is non-nil, display a concise version of the
1593 splash screen in another window."
1594 (let ((splash-buffer (get-buffer-create "*GNU Emacs*")))
1595 (with-current-buffer splash-buffer
1596 (let ((inhibit-read-only t))
1597 (erase-buffer)
1598 (setq default-directory command-line-default-directory)
1599 (make-local-variable 'startup-screen-inhibit-startup-screen)
1600 (if pure-space-overflow
1601 (insert pure-space-overflow-message))
1602 (unless concise
1603 (fancy-splash-head))
1604 (dolist (text fancy-startup-text)
1605 (apply #'fancy-splash-insert text)
1606 (insert "\n"))
1607 (skip-chars-backward "\n")
1608 (delete-region (point) (point-max))
1609 (insert "\n")
1610 (fancy-startup-tail concise))
1611 (use-local-map splash-screen-keymap)
1612 (setq tab-width 22
1613 buffer-read-only t)
1614 (set-buffer-modified-p nil)
1615 (if (and view-read-only (not view-mode))
1616 (view-mode-enter nil 'kill-buffer))
1617 (goto-char (point-min))
1618 (forward-line (if concise 2 4)))
1619 (if concise
1620 (progn
1621 (display-buffer splash-buffer)
1622 ;; If the splash screen is in a split window, fit it.
1623 (let ((window (get-buffer-window splash-buffer t)))
1624 (or (null window)
1625 (eq window (selected-window))
1626 (eq window (next-window window))
1627 (fit-window-to-buffer window))))
1628 (switch-to-buffer splash-buffer))))
1630 (defun fancy-about-screen ()
1631 "Display fancy About screen."
1632 (let ((frame (fancy-splash-frame)))
1633 (save-selected-window
1634 (select-frame frame)
1635 (switch-to-buffer "*About GNU Emacs*")
1636 (setq buffer-undo-list t
1637 mode-line-format
1638 (concat "----"
1639 (propertize "%b" 'face 'mode-line-buffer-id)
1640 "%-"))
1641 (let ((inhibit-read-only t))
1642 (erase-buffer)
1643 (if pure-space-overflow
1644 (insert pure-space-overflow-message))
1645 (fancy-splash-head)
1646 (dolist (text fancy-about-text)
1647 (apply #'fancy-splash-insert text)
1648 (insert "\n"))
1649 (set-buffer-modified-p nil)
1650 (goto-char (point-min))
1651 (force-mode-line-update))
1652 (use-local-map splash-screen-keymap)
1653 (setq tab-width 22)
1654 (message "%s" (startup-echo-area-message))
1655 (setq buffer-read-only t)
1656 (goto-char (point-min))
1657 (forward-line 3))))
1659 (defun fancy-splash-frame ()
1660 "Return the frame to use for the fancy splash screen.
1661 Returning non-nil does not mean we should necessarily
1662 use the fancy splash screen, but if we do use it,
1663 we put it on this frame."
1664 (let (chosen-frame)
1665 (dolist (frame (append (frame-list) (list (selected-frame))))
1666 (if (and (frame-visible-p frame)
1667 (not (window-minibuffer-p (frame-selected-window frame))))
1668 (setq chosen-frame frame)))
1669 chosen-frame))
1671 (defun use-fancy-splash-screens-p ()
1672 "Return t if fancy splash screens should be used."
1673 (when (and (display-graphic-p)
1674 (or (and (display-color-p)
1675 (image-type-available-p 'xpm))
1676 (image-type-available-p 'pbm)))
1677 (let ((frame (fancy-splash-frame)))
1678 (when frame
1679 (let* ((img (create-image (or fancy-splash-image
1680 (if (and (display-color-p)
1681 (image-type-available-p 'xpm))
1682 "splash.xpm" "splash.pbm"))))
1683 (image-height (and img (cdr (image-size img nil frame))))
1684 ;; We test frame-height so that, if the frame is split
1685 ;; by displaying a warning, that doesn't cause the normal
1686 ;; splash screen to be used.
1687 (frame-height (1- (frame-height frame))))
1688 (> frame-height (+ image-height 19)))))))
1691 (defun normal-splash-screen (&optional startup concise)
1692 "Display non-graphic splash screen.
1693 If optional argument STARTUP is non-nil, display the startup screen
1694 after Emacs starts. If STARTUP is nil, display the About screen.
1695 If CONCISE is non-nil, display a concise version of the
1696 splash screen in another window."
1697 (let ((splash-buffer (get-buffer-create "*About GNU Emacs*")))
1698 (with-current-buffer splash-buffer
1699 (setq buffer-read-only nil)
1700 (erase-buffer)
1701 (setq default-directory command-line-default-directory)
1702 (set (make-local-variable 'tab-width) 8)
1703 (if (not startup)
1704 (set (make-local-variable 'mode-line-format)
1705 (propertize "---- %b %-" 'face 'mode-line-buffer-id)))
1707 (if pure-space-overflow
1708 (insert pure-space-overflow-message))
1710 ;; The convention for this piece of code is that
1711 ;; each piece of output starts with one or two newlines
1712 ;; and does not end with any newlines.
1713 (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs"))
1714 (insert
1715 (if (eq system-type 'gnu/linux)
1716 ", one component of the GNU/Linux operating system.\n"
1717 ", a part of the GNU operating system.\n"))
1719 (if startup
1720 (if (display-mouse-p)
1721 ;; The user can use the mouse to activate menus
1722 ;; so give help in terms of menu items.
1723 (normal-mouse-startup-screen)
1725 ;; No mouse menus, so give help using kbd commands.
1726 (normal-no-mouse-startup-screen))
1728 (normal-about-screen))
1730 ;; The rest of the startup screen is the same on all
1731 ;; kinds of terminals.
1733 ;; Give information on recovering, if there was a crash.
1734 (and startup
1735 auto-save-list-file-prefix
1736 ;; Don't signal an error if the
1737 ;; directory for auto-save-list files
1738 ;; does not yet exist.
1739 (file-directory-p (file-name-directory
1740 auto-save-list-file-prefix))
1741 (directory-files
1742 (file-name-directory auto-save-list-file-prefix)
1744 (concat "\\`"
1745 (regexp-quote (file-name-nondirectory
1746 auto-save-list-file-prefix)))
1748 (insert "\n\nIf an Emacs session crashed recently, "
1749 "type Meta-x recover-session RET\nto recover"
1750 " the files you were editing.\n"))
1752 (use-local-map splash-screen-keymap)
1754 ;; Display the input that we set up in the buffer.
1755 (set-buffer-modified-p nil)
1756 (setq buffer-read-only t)
1757 (if (and view-read-only (not view-mode))
1758 (view-mode-enter nil 'kill-buffer))
1759 (if startup (rename-buffer "*GNU Emacs*" t))
1760 (goto-char (point-min)))
1761 (if concise
1762 (display-buffer splash-buffer)
1763 (switch-to-buffer splash-buffer))))
1765 (defun normal-mouse-startup-screen ()
1766 ;; The user can use the mouse to activate menus
1767 ;; so give help in terms of menu items.
1768 (insert "\
1769 To follow a link, click Mouse-1 on it, or move to it and type RET.
1770 To quit a partially entered command, type Control-g.\n")
1772 (insert "\nImportant Help menu items:\n")
1773 (insert-button "Emacs Tutorial"
1774 'action (lambda (button) (help-with-tutorial))
1775 'follow-link t)
1776 (insert "\t\tLearn basic Emacs keystroke commands\n")
1777 (insert-button "Read the Emacs Manual"
1778 'action (lambda (button) (info-emacs-manual))
1779 'follow-link t)
1780 (insert "\tView the Emacs manual using Info\n")
1781 (insert-button "\(Non)Warranty"
1782 'action (lambda (button) (describe-no-warranty))
1783 'follow-link t)
1784 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1785 (insert-button "Copying Conditions"
1786 'action (lambda (button) (describe-copying))
1787 'follow-link t)
1788 (insert "\tConditions for redistributing and changing Emacs\n")
1789 (insert-button "More Manuals / Ordering Manuals"
1790 'action (lambda (button) (view-order-manuals))
1791 'follow-link t)
1792 (insert " How to order printed manuals from the FSF\n")
1794 (insert "\nUseful tasks:\n")
1795 (insert-button "Visit New File"
1796 'action (lambda (button) (call-interactively 'find-file))
1797 'follow-link t)
1798 (insert "\t\tSpecify a new file's name, to edit the file\n")
1799 (insert-button "Open Home Directory"
1800 'action (lambda (button) (dired "~"))
1801 'follow-link t)
1802 (insert "\tOpen your home directory, to operate on its files\n")
1803 (insert-button "Customize Startup"
1804 'action (lambda (button) (customize-group 'initialization))
1805 'follow-link t)
1806 (insert "\tChange initialization settings including this screen\n")
1808 (insert "\n" (emacs-version)
1809 "\n" emacs-copyright))
1811 ;; No mouse menus, so give help using kbd commands.
1812 (defun normal-no-mouse-startup-screen ()
1814 ;; If keys have their default meanings,
1815 ;; use precomputed string to save lots of time.
1816 (let* ((c-h-accessible
1817 ;; If normal-erase-is-backspace is used on a tty, there's
1818 ;; no way to invoke C-h and you have to use F1 instead.
1819 (or (not (char-table-p keyboard-translate-table))
1820 (eq (aref keyboard-translate-table ?\C-h) ?\C-h)))
1821 (minor-mode-overriding-map-alist
1822 (cons (cons (not c-h-accessible)
1823 ;; If C-h can't be invoked, temporarily disable its
1824 ;; binding, so where-is uses alternative bindings.
1825 (let ((map (make-sparse-keymap)))
1826 (define-key map [?\C-h] 'undefined)
1827 map))
1828 minor-mode-overriding-map-alist)))
1830 (insert (format "\nGet help\t %s\n"
1831 (let ((where (where-is-internal 'help-command nil t)))
1832 (cond
1833 ((equal where [?\C-h])
1834 "C-h (Hold down CTRL and press h)")
1835 (where (key-description where))
1836 (t "M-x help")))))
1837 (insert-button "Emacs manual"
1838 'action (lambda (button) (info-emacs-manual))
1839 'follow-link t)
1840 (insert (substitute-command-keys"\t \\[info-emacs-manual]\t"))
1841 (insert-button "Browse manuals"
1842 'action (lambda (button) (Info-directory))
1843 'follow-link t)
1844 (insert (substitute-command-keys "\t \\[info]\n"))
1845 (insert-button "Emacs tutorial"
1846 'action (lambda (button) (help-with-tutorial))
1847 'follow-link t)
1848 (insert (substitute-command-keys
1849 "\t \\[help-with-tutorial]\tUndo changes\t \\[undo]\n"))
1850 (insert-button "Buy manuals"
1851 'action (lambda (button) (view-order-manuals))
1852 'follow-link t)
1853 (insert (substitute-command-keys
1854 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
1856 ;; Say how to use the menu bar with the keyboard.
1857 (insert "\n")
1858 (insert-button "Activate menubar"
1859 'action (lambda (button) (tmm-menubar))
1860 'follow-link t)
1861 (if (and (eq (key-binding "\M-`") 'tmm-menubar)
1862 (eq (key-binding [f10]) 'tmm-menubar))
1863 (insert " F10 or ESC ` or M-`")
1864 (insert (substitute-command-keys " \\[tmm-menubar]")))
1866 ;; Many users seem to have problems with these.
1867 (insert "
1868 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
1869 If you have no Meta key, you may instead type ESC followed by the character.)")
1871 ;; Insert links to useful tasks
1872 (insert "\nUseful tasks:\n")
1874 (insert-button "Visit New File"
1875 'action (lambda (button) (call-interactively 'find-file))
1876 'follow-link t)
1877 (insert "\t\t\t")
1878 (insert-button "Open Home Directory"
1879 'action (lambda (button) (dired "~"))
1880 'follow-link t)
1881 (insert "\n")
1883 (insert-button "Customize Startup"
1884 'action (lambda (button) (customize-group 'initialization))
1885 'follow-link t)
1886 (insert "\t\t")
1887 (insert-button "Open *scratch* buffer"
1888 'action (lambda (button) (switch-to-buffer
1889 (get-buffer-create "*scratch*")))
1890 'follow-link t)
1891 (insert "\n")
1892 (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
1894 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying)
1895 (eq (key-binding "\C-h\C-d") 'describe-distribution)
1896 (eq (key-binding "\C-h\C-w") 'describe-no-warranty))
1897 (progn
1898 (insert
1900 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ")
1901 (insert-button "full details"
1902 'action (lambda (button) (describe-no-warranty))
1903 'follow-link t)
1904 (insert ".
1905 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1906 of Emacs and modify it; type C-h C-c to see ")
1907 (insert-button "the conditions"
1908 'action (lambda (button) (describe-copying))
1909 'follow-link t)
1910 (insert ".
1911 Type C-h C-d for information on ")
1912 (insert-button "getting the latest version"
1913 'action (lambda (button) (describe-distribution))
1914 'follow-link t)
1915 (insert "."))
1916 (insert (substitute-command-keys
1918 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for "))
1919 (insert-button "full details"
1920 'action (lambda (button) (describe-no-warranty))
1921 'follow-link t)
1922 (insert (substitute-command-keys ".
1923 Emacs is Free Software--Free as in Freedom--so you can redistribute copies
1924 of Emacs and modify it; type \\[describe-copying] to see "))
1925 (insert-button "the conditions"
1926 'action (lambda (button) (describe-copying))
1927 'follow-link t)
1928 (insert (substitute-command-keys".
1929 Type \\[describe-distribution] for information on "))
1930 (insert-button "getting the latest version"
1931 'action (lambda (button) (describe-distribution))
1932 'follow-link t)
1933 (insert ".")))
1935 (defun normal-about-screen ()
1936 (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n")
1938 (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n")
1940 (insert-button "Authors"
1941 'action
1942 (lambda (button)
1943 (view-file (expand-file-name "AUTHORS" data-directory))
1944 (goto-char (point-min)))
1945 'follow-link t)
1946 (insert "\t\tMany people have contributed code included in GNU Emacs\n")
1948 (insert-button "Contributing"
1949 'action
1950 (lambda (button)
1951 (view-file (expand-file-name "CONTRIBUTE" data-directory))
1952 (goto-char (point-min)))
1953 'follow-link t)
1954 (insert "\tHow to contribute improvements to Emacs\n\n")
1956 (insert-button "GNU and Freedom"
1957 'action (lambda (button) (describe-gnu-project))
1958 'follow-link t)
1959 (insert "\t\tWhy we developed GNU Emacs and the GNU system\n")
1961 (insert-button "Absence of Warranty"
1962 'action (lambda (button) (describe-no-warranty))
1963 'follow-link t)
1964 (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n")
1966 (insert-button "Copying Conditions"
1967 'action (lambda (button) (describe-copying))
1968 'follow-link t)
1969 (insert "\tConditions for redistributing and changing Emacs\n")
1971 (insert-button "Getting New Versions"
1972 'action (lambda (button) (describe-distribution))
1973 'follow-link t)
1974 (insert "\tHow to get the latest version of GNU Emacs\n")
1976 (insert-button "More Manuals / Ordering Manuals"
1977 'action (lambda (button) (view-order-manuals))
1978 'follow-link t)
1979 (insert "\tBuying printed manuals from the FSF\n"))
1981 (defun startup-echo-area-message ()
1982 (cond ((daemonp)
1983 "Starting Emacs daemon.")
1984 ((eq (key-binding "\C-h\C-a") 'about-emacs)
1985 "For information about GNU Emacs and the GNU system, type C-h C-a.")
1987 (substitute-command-keys
1988 "For information about GNU Emacs and the GNU system, type \
1989 \\[about-emacs]."))))
1991 (defun display-startup-echo-area-message ()
1992 (let ((resize-mini-windows t))
1993 (or noninteractive ;(input-pending-p) init-file-had-error
1994 ;; t if the init file says to inhibit the echo area startup message.
1995 (and inhibit-startup-echo-area-message
1996 user-init-file
1997 (or (and (get 'inhibit-startup-echo-area-message 'saved-value)
1998 (equal inhibit-startup-echo-area-message
1999 (if (equal init-file-user "")
2000 (user-login-name)
2001 init-file-user)))
2002 ;; Wasn't set with custom; see if .emacs has a setq.
2003 (let ((buffer (get-buffer-create " *temp*")))
2004 (prog1
2005 (condition-case nil
2006 (with-current-buffer buffer
2007 (insert-file-contents user-init-file)
2008 (re-search-forward
2009 (concat
2010 "([ \t\n]*setq[ \t\n]+"
2011 "inhibit-startup-echo-area-message[ \t\n]+"
2012 (regexp-quote
2013 (prin1-to-string
2014 (if (equal init-file-user "")
2015 (user-login-name)
2016 init-file-user)))
2017 "[ \t\n]*)")
2018 nil t))
2019 (error nil))
2020 (kill-buffer buffer)))))
2021 (message "%s" (startup-echo-area-message)))))
2023 (defun display-startup-screen (&optional concise)
2024 "Display startup screen according to display.
2025 A fancy display is used on graphic displays, normal otherwise.
2027 If CONCISE is non-nil, display a concise version of the startup
2028 screen."
2029 ;; Prevent recursive calls from server-process-filter.
2030 (if (not (get-buffer "*GNU Emacs*"))
2031 (if (use-fancy-splash-screens-p)
2032 (fancy-startup-screen concise)
2033 (normal-splash-screen t concise))))
2035 (defun display-about-screen ()
2036 "Display the *About GNU Emacs* buffer.
2037 A fancy display is used on graphic displays, normal otherwise."
2038 (interactive)
2039 (if (use-fancy-splash-screens-p)
2040 (fancy-about-screen)
2041 (normal-splash-screen nil)))
2043 (defalias 'about-emacs 'display-about-screen)
2044 (defalias 'display-splash-screen 'display-startup-screen)
2046 (defun command-line-1 (command-line-args-left)
2047 (display-startup-echo-area-message)
2048 (when (and pure-space-overflow
2049 (not noninteractive))
2050 (display-warning
2051 'initialization
2052 "Building Emacs overflowed pure space.\
2053 (See the node Pure Storage in the Lisp manual for details.)"
2054 :warning))
2056 (let ((file-count 0)
2057 first-file-buffer)
2058 (when command-line-args-left
2059 ;; We have command args; process them.
2060 ;; Note that any local variables in this function affect the
2061 ;; ability of -f batch-byte-compile to detect free variables.
2062 ;; So we give some of them with common names a cl1- prefix.
2063 (let ((cl1-dir command-line-default-directory)
2064 cl1-tem
2065 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
2066 ;; if foo is intended to be found in DIR.
2068 ;; ;; The directories listed in --directory/-L options will *appear*
2069 ;; ;; at the front of `load-path' in the order they appear on the
2070 ;; ;; command-line. We cannot do this by *placing* them at the front
2071 ;; ;; in the order they appear, so we need this variable to hold them,
2072 ;; ;; temporarily.
2073 ;; extra-load-path
2075 ;; To DTRT we keep track of the splice point and modify `load-path'
2076 ;; straight away upon any --directory/-L option.
2077 splice
2078 just-files ;; t if this follows the magic -- option.
2079 ;; This includes our standard options' long versions
2080 ;; and long versions of what's on command-switch-alist.
2081 (longopts
2082 (append '("--funcall" "--load" "--insert" "--kill"
2083 "--directory" "--eval" "--execute" "--no-splash"
2084 "--find-file" "--visit" "--file" "--no-desktop")
2085 (mapcar (lambda (elt) (concat "-" (car elt)))
2086 command-switch-alist)))
2087 (cl1-line 0)
2088 (cl1-column 0))
2090 ;; Add the long X options to longopts.
2091 (dolist (tem command-line-x-option-alist)
2092 (if (string-match "^--" (car tem))
2093 (push (car tem) longopts)))
2095 ;; Add the long NS options to longopts.
2096 (dolist (tem command-line-ns-option-alist)
2097 (if (string-match "^--" (car tem))
2098 (push (list (car tem)) longopts)))
2100 ;; Loop, processing options.
2101 (while command-line-args-left
2102 (let* ((argi (car command-line-args-left))
2103 (orig-argi argi)
2104 argval completion)
2105 (setq command-line-args-left (cdr command-line-args-left))
2107 ;; Do preliminary decoding of the option.
2108 (if just-files
2109 ;; After --, don't look for options; treat all args as files.
2110 (setq argi "")
2111 ;; Convert long options to ordinary options
2112 ;; and separate out an attached option argument into argval.
2113 (when (string-match "\\`\\(--[^=]*\\)=" argi)
2114 (setq argval (substring argi (match-end 0))
2115 argi (match-string 1 argi)))
2116 (when (string-match "\\`--?[^-]" orig-argi)
2117 (setq completion (try-completion argi longopts))
2118 (if (eq completion t)
2119 (setq argi (substring argi 1))
2120 (if (stringp completion)
2121 (let ((elt (member completion longopts)))
2122 (or elt
2123 (error "Option `%s' is ambiguous" argi))
2124 (setq argi (substring (car elt) 1)))
2125 (setq argval nil
2126 argi orig-argi)))))
2128 ;; Execute the option.
2129 (cond ((setq cl1-tem (assoc argi command-switch-alist))
2130 (if argval
2131 (let ((command-line-args-left
2132 (cons argval command-line-args-left)))
2133 (funcall (cdr cl1-tem) argi))
2134 (funcall (cdr cl1-tem) argi)))
2136 ((equal argi "-no-splash")
2137 (setq inhibit-startup-screen t))
2139 ((member argi '("-f" ; what the manual claims
2140 "-funcall"
2141 "-e")) ; what the source used to say
2142 (setq inhibit-startup-screen t)
2143 (setq cl1-tem (intern (or argval (pop command-line-args-left))))
2144 (if (commandp cl1-tem)
2145 (command-execute cl1-tem)
2146 (funcall cl1-tem)))
2148 ((member argi '("-eval" "-execute"))
2149 (setq inhibit-startup-screen t)
2150 (eval (read (or argval (pop command-line-args-left)))))
2152 ((member argi '("-L" "-directory"))
2153 (setq cl1-tem (expand-file-name
2154 (command-line-normalize-file-name
2155 (or argval (pop command-line-args-left)))))
2156 (cond (splice (setcdr splice (cons cl1-tem (cdr splice)))
2157 (setq splice (cdr splice)))
2158 (t (setq load-path (cons cl1-tem load-path)
2159 splice load-path))))
2161 ((member argi '("-l" "-load"))
2162 (let* ((file (command-line-normalize-file-name
2163 (or argval (pop command-line-args-left))))
2164 ;; Take file from default dir if it exists there;
2165 ;; otherwise let `load' search for it.
2166 (file-ex (expand-file-name file)))
2167 (when (file-exists-p file-ex)
2168 (setq file file-ex))
2169 (load file nil t)))
2171 ;; This is used to handle -script. It's not clear
2172 ;; we need to document it (it is totally internal).
2173 ((member argi '("-scriptload"))
2174 (let* ((file (command-line-normalize-file-name
2175 (or argval (pop command-line-args-left))))
2176 ;; Take file from default dir.
2177 (file-ex (expand-file-name file)))
2178 (load file-ex nil t t)))
2180 ((equal argi "-insert")
2181 (setq inhibit-startup-screen t)
2182 (setq cl1-tem (or argval (pop command-line-args-left)))
2183 (or (stringp cl1-tem)
2184 (error "File name omitted from `-insert' option"))
2185 (insert-file-contents (command-line-normalize-file-name cl1-tem)))
2187 ((equal argi "-kill")
2188 (kill-emacs t))
2190 ;; This is for when they use --no-desktop with -q, or
2191 ;; don't load Desktop in their .emacs. If desktop.el
2192 ;; _is_ loaded, it will handle this switch, and we
2193 ;; won't see it by the time we get here.
2194 ((equal argi "-no-desktop")
2195 (message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
2197 ((string-match "^\\+[0-9]+\\'" argi)
2198 (setq cl1-line (string-to-number argi)))
2200 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
2201 (setq cl1-line (string-to-number (match-string 1 argi))
2202 cl1-column (string-to-number (match-string 2 argi))))
2204 ((setq cl1-tem (assoc orig-argi command-line-x-option-alist))
2205 ;; Ignore X-windows options and their args if not using X.
2206 (setq command-line-args-left
2207 (nthcdr (nth 1 cl1-tem) command-line-args-left)))
2209 ((setq cl1-tem (assoc orig-argi command-line-ns-option-alist))
2210 ;; Ignore NS-windows options and their args if not using NS.
2211 (setq command-line-args-left
2212 (nthcdr (nth 1 cl1-tem) command-line-args-left)))
2214 ((member argi '("-find-file" "-file" "-visit"))
2215 (setq inhibit-startup-screen t)
2216 ;; An explicit option to specify visiting a file.
2217 (setq cl1-tem (or argval (pop command-line-args-left)))
2218 (unless (stringp cl1-tem)
2219 (error "File name omitted from `%s' option" argi))
2220 (setq file-count (1+ file-count))
2221 (let ((file (expand-file-name
2222 (command-line-normalize-file-name cl1-tem)
2223 cl1-dir)))
2224 (if (= file-count 1)
2225 (setq first-file-buffer (find-file file))
2226 (find-file-other-window file)))
2227 (unless (zerop cl1-line)
2228 (goto-char (point-min))
2229 (forward-line (1- cl1-line)))
2230 (setq cl1-line 0)
2231 (unless (< cl1-column 1)
2232 (move-to-column (1- cl1-column)))
2233 (setq cl1-column 0))
2235 ;; These command lines now have no effect.
2236 ((string-match "\\`--?\\(no-\\)?\\(uni\\|multi\\)byte$" argi)
2237 (display-warning 'initialization
2238 (format "Ignoring obsolete arg %s" argi)))
2240 ((equal argi "--")
2241 (setq just-files t))
2243 ;; We have almost exhausted our options. See if the
2244 ;; user has made any other command-line options available
2245 (let ((hooks command-line-functions)
2246 (did-hook nil))
2247 (while (and hooks
2248 (not (setq did-hook (funcall (car hooks)))))
2249 (setq hooks (cdr hooks)))
2250 (if (not did-hook)
2251 ;; Presume that the argument is a file name.
2252 (progn
2253 (if (string-match "\\`-" argi)
2254 (error "Unknown option `%s'" argi))
2255 (unless initial-window-system
2256 (setq inhibit-startup-screen t))
2257 (setq file-count (1+ file-count))
2258 (let ((file
2259 (expand-file-name
2260 (command-line-normalize-file-name orig-argi)
2261 cl1-dir)))
2262 (cond ((= file-count 1)
2263 (setq first-file-buffer (find-file file)))
2264 (inhibit-startup-screen
2265 (find-file-other-window file))
2266 (t (find-file file))))
2267 (unless (zerop cl1-line)
2268 (goto-char (point-min))
2269 (forward-line (1- cl1-line)))
2270 (setq cl1-line 0)
2271 (unless (< cl1-column 1)
2272 (move-to-column (1- cl1-column)))
2273 (setq cl1-column 0))))))
2274 ;; In unusual circumstances, the execution of Lisp code due
2275 ;; to command-line options can cause the last visible frame
2276 ;; to be deleted. In this case, kill emacs to avoid an
2277 ;; abort later.
2278 (unless (frame-live-p (selected-frame)) (kill-emacs nil))))))
2280 (when initial-buffer-choice
2281 (cond ((eq initial-buffer-choice t)
2282 (switch-to-buffer (get-buffer-create "*scratch*")))
2283 ((stringp initial-buffer-choice)
2284 (find-file initial-buffer-choice))))
2286 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2287 (and initial-scratch-message
2288 (get-buffer "*scratch*")
2289 (with-current-buffer "*scratch*"
2290 (when (zerop (buffer-size))
2291 (insert initial-scratch-message)
2292 (set-buffer-modified-p nil))))
2294 (if (or inhibit-startup-screen
2295 initial-buffer-choice
2296 noninteractive
2297 inhibit-x-resources)
2299 ;; Not displaying a startup screen. If 3 or more files
2300 ;; visited, and not all visible, show user what they all are.
2301 (and (> file-count 2)
2302 (not noninteractive)
2303 (not inhibit-startup-buffer-menu)
2304 (or (get-buffer-window first-file-buffer)
2305 (list-buffers)))
2307 ;; Display a startup screen, after some preparations.
2309 ;; If there are no switches to process, we might as well
2310 ;; run this hook now, and there may be some need to do it
2311 ;; before doing any output.
2312 (run-hooks 'emacs-startup-hook)
2313 (and term-setup-hook
2314 (run-hooks 'term-setup-hook))
2315 (setq inhibit-startup-hooks t)
2317 ;; It's important to notice the user settings before we
2318 ;; display the startup message; otherwise, the settings
2319 ;; won't take effect until the user gives the first
2320 ;; keystroke, and that's distracting.
2321 (when (fboundp 'frame-notice-user-settings)
2322 (frame-notice-user-settings))
2324 ;; If there are no switches to process, we might as well
2325 ;; run this hook now, and there may be some need to do it
2326 ;; before doing any output.
2327 (when window-setup-hook
2328 (run-hooks 'window-setup-hook)
2329 ;; Don't let the hook be run twice.
2330 (setq window-setup-hook nil))
2332 ;; ;; Do this now to avoid an annoying delay if the user
2333 ;; ;; clicks the menu bar during the sit-for.
2334 ;; (when (display-popup-menus-p)
2335 ;; (precompute-menubar-bindings))
2336 ;; (with-no-warnings
2337 ;; (setq menubar-bindings-done t))
2339 (if (> file-count 0)
2340 (display-startup-screen t)
2341 (display-startup-screen nil)))))
2343 (defun command-line-normalize-file-name (file)
2344 "Collapse multiple slashes to one, to handle non-Emacs file names."
2345 (save-match-data
2346 ;; Use arg 1 so that we don't collapse // at the start of the file name.
2347 ;; That is significant on some systems.
2348 ;; However, /// at the beginning is supposed to mean just /, not //.
2349 (if (string-match "^///+" file)
2350 (setq file (replace-match "/" t t file)))
2351 (and (memq system-type '(ms-dos windows-nt))
2352 (string-match "^[A-Za-z]:\\(\\\\[\\\\/]\\)" file) ; C:\/ or C:\\
2353 (setq file (replace-match "/" t t file 1)))
2354 (while (string-match "//+" file 1)
2355 (setq file (replace-match "/" t t file)))
2356 file))
2358 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
2359 ;;; startup.el ends here