Commit | Line | Data |
---|---|---|
c88ab9ce ER |
1 | ;;; startup.el --- process Emacs shell arguments |
2 | ||
84691156 | 3 | ;; Copyright (C) 1985, 86, 92, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 |
347d0813 | 4 | ;; Free Software Foundation, Inc. |
eea8d4ef | 5 | |
630cc463 | 6 | ;; Maintainer: FSF |
d7b4d18f | 7 | ;; Keywords: internal |
630cc463 | 8 | |
a726e0d1 JB |
9 | ;; This file is part of GNU Emacs. |
10 | ||
11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 | ;; it under the terms of the GNU General Public License as published by | |
4746118a | 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
a726e0d1 JB |
14 | ;; any later version. |
15 | ||
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
b578f267 EN |
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 | ;; Boston, MA 02111-1307, USA. | |
a726e0d1 | 25 | |
630cc463 | 26 | ;;; Commentary: |
a726e0d1 | 27 | |
ab30fc8a RS |
28 | ;; This file parses the command line and gets Emacs running. Options on |
29 | ;; the command line are handled in precedence order. The order is the | |
30 | ;; one in the list below; first described means first handled. Options | |
31 | ;; within each category (delimited by a bar) are handled in the order | |
32 | ;; encountered on the command line. | |
33 | ||
34 | ;; ------------------------- | |
35 | ;; -version Print Emacs version to stderr, then exit | |
36 | ;; --version successfully right away. | |
37 | ;; This option is handled by emacs.c | |
38 | ;; ------------------------- | |
39 | ;; -help Print a short usage description and exit | |
40 | ;; --help successfully right away. | |
41 | ;; This option is handled by emacs.c | |
42 | ;; ------------------------- | |
43 | ;; -nl Do not use shared memory (for systems that | |
44 | ;; -no-shared-memory support this) for the dumped Emacs data. | |
45 | ;; This option is handled by emacs.c | |
46 | ;; | |
47 | ;; -map For VMS. | |
48 | ;; --map-data This option is handled by emacs.c | |
49 | ;; ------------------------- | |
50 | ;; -t FILE Use FILE as the name of the terminal. | |
51 | ;; --terminal FILE Using this implies "-nw" also. | |
52 | ;; This option is handled by emacs.c | |
53 | ;; ------------------------- | |
64b0dbdb | 54 | ;; -d DISPNAME Use DISPNAME as the name of the X |
ab30fc8a RS |
55 | ;; -display DISPNAME display for the initial frame. |
56 | ;; --display DISPNAME This option is handled by emacs.c | |
57 | ;; ------------------------- | |
58 | ;; -nw Do not use a windows system (but use the | |
568bd708 | 59 | ;; --no-window-system terminal instead.) |
ab30fc8a RS |
60 | ;; This option is handled by emacs.c |
61 | ;; ------------------------- | |
62 | ;; -batch Execute noninteractively (messages go to stdout, | |
63 | ;; --batch variable noninteractive set to t) | |
64 | ;; This option is handled by emacs.c | |
65 | ;; ------------------------- | |
66 | ;; -q Do not load user's init file and do not load | |
67 | ;; -no-init-file "default.el". Regardless of this switch, | |
6f9340dd | 68 | ;; --no-init-file "site-start" is still loaded. |
ab30fc8a | 69 | ;; ------------------------- |
6f9340dd | 70 | ;; -no-site-file Do not load "site-start.el". (This is the ONLY |
ab30fc8a RS |
71 | ;; --no-site-file way to prevent loading that file.) |
72 | ;; ------------------------- | |
f6a9d2d8 CW |
73 | ;; -no-splash Don't display a splash screen on startup. |
74 | ;; --no-splash | |
1b207153 | 75 | ;; ------------------------- |
ab30fc8a RS |
76 | ;; -u USER Load USER's init file instead of the init |
77 | ;; -user USER file belonging to the user starting Emacs. | |
78 | ;; --user USER | |
79 | ;; ------------------------- | |
80 | ;; -debug-init Don't catch errors in init files; let the | |
81 | ;; --debug-init debugger run. | |
82 | ;; ------------------------- | |
83 | ;; -i ICONTYPE Set type of icon using when Emacs is | |
64b0dbdb | 84 | ;; -itype ICONTYPE iconified under X. |
ab30fc8a RS |
85 | ;; --icon-type ICONTYPE This option is passed on to term/x-win.el |
86 | ;; | |
64b0dbdb | 87 | ;; -iconic Start Emacs iconified. |
ab30fc8a RS |
88 | ;; --iconic This option is passed on to term/x-win.el |
89 | ;; ------------------------- | |
64b0dbdb | 90 | ;; Various X options for colors/fonts/geometry/title etc. |
f5627e93 | 91 | ;; These options are passed on to term/x-win.el which see. |
ab30fc8a RS |
92 | ;; ------------------------- |
93 | ;; FILE Visit FILE. | |
dc2cd811 GM |
94 | ;; -visit FILE |
95 | ;; --visit FILE | |
96 | ;; -file FILE | |
97 | ;; --file FILE | |
ab30fc8a RS |
98 | ;; |
99 | ;; -L DIRNAME Add DIRNAME to load-path | |
100 | ;; -directory DIRNAME | |
101 | ;; --directory DIRNAME | |
102 | ;; | |
103 | ;; -l FILE Load and execute the Emacs lisp code | |
104 | ;; -load FILE in FILE. | |
105 | ;; --load FILE | |
106 | ;; | |
107 | ;; -f FUNC Execute Emacs lisp function FUNC with | |
108 | ;; -funcall FUNC no arguments. The "-e" form is outdated | |
109 | ;; --funcall FUNC and should not be used. (It's a typo | |
110 | ;; -e FUNC promoted to a feature.) | |
111 | ;; | |
955093c9 EN |
112 | ;; -eval FORM Execute Emacs lisp form FORM. |
113 | ;; --eval FORM | |
dc2cd811 GM |
114 | ;; -execute EXPR |
115 | ;; --execute EXPR | |
e6b75e30 | 116 | ;; |
ab30fc8a RS |
117 | ;; -insert FILE Insert the contents of FILE into buffer. |
118 | ;; --insert FILE | |
119 | ;; ------------------------- | |
120 | ;; -kill Kill (exit) Emacs right away. | |
121 | ;; --kill | |
122 | ;; ------------------------- | |
a726e0d1 | 123 | |
630cc463 ER |
124 | ;;; Code: |
125 | ||
a726e0d1 JB |
126 | (setq top-level '(normal-top-level)) |
127 | ||
42a3e6fa | 128 | (defvar command-line-processed nil |
2879a13b | 129 | "Non-nil once command line has been processed.") |
a726e0d1 | 130 | |
42a3e6fa RS |
131 | (defgroup initialization nil |
132 | "Emacs start-up procedure" | |
133 | :group 'internal) | |
134 | ||
135 | (defcustom inhibit-startup-message nil | |
1d7da582 | 136 | "*Non-nil inhibits the initial startup message. |
a726e0d1 | 137 | This is for use in your personal init file, once you are familiar |
42a3e6fa RS |
138 | with the contents of the startup message." |
139 | :type 'boolean | |
140 | :group 'initialization) | |
a726e0d1 | 141 | |
1b207153 CW |
142 | (defvaralias 'inhibit-splash-screen 'inhibit-startup-message) |
143 | ||
42a3e6fa | 144 | (defcustom inhibit-startup-echo-area-message nil |
1d7da582 | 145 | "*Non-nil inhibits the initial startup echo area message. |
42a3e6fa RS |
146 | Setting this variable takes effect |
147 | only if you do it with the customization buffer | |
94487c4e | 148 | or if your `.emacs' file contains a line of this form: |
54a003f7 | 149 | (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\") |
e5575c06 RS |
150 | If your `.emacs' file is byte-compiled, use the following form instead: |
151 | (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")) | |
1d7da582 | 152 | Thus, someone else using a copy of your `.emacs' file will see |
42a3e6fa RS |
153 | the startup message unless he personally acts to inhibit it." |
154 | :type '(choice (const :tag "Don't inhibit") | |
155 | (string :tag "Enter your user name, to inhibit")) | |
156 | :group 'initialization) | |
1d7da582 | 157 | |
42a3e6fa RS |
158 | (defcustom inhibit-default-init nil |
159 | "*Non-nil inhibits loading the `default' library." | |
160 | :type 'boolean | |
161 | :group 'initialization) | |
a726e0d1 | 162 | |
802a980a GM |
163 | (defcustom inhibit-startup-buffer-menu nil |
164 | "*Non-nil inhibits display of buffer list when more than 2 files are loaded." | |
165 | :type 'boolean | |
166 | :group 'initialization) | |
167 | ||
d7fa5aa2 | 168 | (defvar command-switch-alist nil |
a726e0d1 JB |
169 | "Alist of command-line switches. |
170 | Elements look like (SWITCH-STRING . HANDLER-FUNCTION). | |
171 | HANDLER-FUNCTION receives switch name as sole arg; | |
172 | remaining command-line args are in the variable `command-line-args-left'.") | |
173 | ||
860befc8 RS |
174 | (defvar command-line-args-left nil |
175 | "List of command-line args not yet processed.") | |
176 | ||
a726e0d1 JB |
177 | (defvar command-line-functions nil ;; lrs 7/31/89 |
178 | "List of functions to process unrecognized command-line arguments. | |
179 | Each function should access the dynamically bound variables | |
b4484ea8 | 180 | `argi' (the current argument) and `command-line-args-left' (the remaining |
a726e0d1 | 181 | arguments). The function should return non-nil only if it recognizes and |
b4484ea8 RS |
182 | processes `argi'. If it does so, it may consume successive arguments by |
183 | altering `command-line-args-left' to remove them.") | |
a726e0d1 | 184 | |
09a1077c RS |
185 | (defvar command-line-default-directory nil |
186 | "Default directory to use for command line arguments. | |
187 | This is normally copied from `default-directory' when Emacs starts.") | |
188 | ||
b3afdeb8 RS |
189 | ;;; This is here, rather than in x-win.el, so that we can ignore these |
190 | ;;; options when we are not using X. | |
46cfd295 | 191 | (defconst command-line-x-option-alist |
b3afdeb8 RS |
192 | '(("-bw" 1 x-handle-numeric-switch border-width) |
193 | ("-d" 1 x-handle-display) | |
194 | ("-display" 1 x-handle-display) | |
5676ab57 | 195 | ("-name" 1 x-handle-name-switch) |
2c3fef40 RS |
196 | ("-title" 1 x-handle-switch title) |
197 | ("-T" 1 x-handle-switch title) | |
b3afdeb8 RS |
198 | ("-r" 0 x-handle-switch reverse t) |
199 | ("-rv" 0 x-handle-switch reverse t) | |
200 | ("-reverse" 0 x-handle-switch reverse t) | |
201 | ("-reverse-video" 0 x-handle-switch reverse t) | |
202 | ("-fn" 1 x-handle-switch font) | |
203 | ("-font" 1 x-handle-switch font) | |
188b6a5e EZ |
204 | ("-fs" 0 x-handle-initial-switch fullscreen fullboth) |
205 | ("-fw" 0 x-handle-initial-switch fullscreen fullwidth) | |
206 | ("-fh" 0 x-handle-initial-switch fullscreen fullheight) | |
b3afdeb8 | 207 | ("-ib" 1 x-handle-numeric-switch internal-border-width) |
1f7f78f1 | 208 | ("-g" 1 x-handle-geometry) |
9ff6bda1 | 209 | ("-lsp" 1 x-handle-numeric-switch line-spacing) |
1f7f78f1 | 210 | ("-geometry" 1 x-handle-geometry) |
b3afdeb8 RS |
211 | ("-fg" 1 x-handle-switch foreground-color) |
212 | ("-foreground" 1 x-handle-switch foreground-color) | |
213 | ("-bg" 1 x-handle-switch background-color) | |
214 | ("-background" 1 x-handle-switch background-color) | |
215 | ("-ms" 1 x-handle-switch mouse-color) | |
216 | ("-itype" 0 x-handle-switch icon-type t) | |
217 | ("-i" 0 x-handle-switch icon-type t) | |
218 | ("-iconic" 0 x-handle-iconic) | |
219 | ("-xrm" 1 x-handle-xrm-switch) | |
220 | ("-cr" 1 x-handle-switch cursor-color) | |
221 | ("-vb" 0 x-handle-switch vertical-scroll-bars t) | |
222 | ("-hb" 0 x-handle-switch horizontal-scroll-bars t) | |
223 | ("-bd" 1 x-handle-switch) | |
224 | ("--border-width" 1 x-handle-numeric-switch border-width) | |
225 | ("--display" 1 x-handle-display) | |
5676ab57 | 226 | ("--name" 1 x-handle-name-switch) |
7775acb8 | 227 | ("--title" 1 x-handle-switch title) |
b3afdeb8 RS |
228 | ("--reverse-video" 0 x-handle-switch reverse t) |
229 | ("--font" 1 x-handle-switch font) | |
188b6a5e EZ |
230 | ("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth) |
231 | ("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth) | |
232 | ("--fullheight" 0 x-handle-initial-switch fullscreen fullheight) | |
b3afdeb8 | 233 | ("--internal-border" 1 x-handle-numeric-switch internal-border-width) |
1f7f78f1 | 234 | ("--geometry" 1 x-handle-geometry) |
b3afdeb8 RS |
235 | ("--foreground-color" 1 x-handle-switch foreground-color) |
236 | ("--background-color" 1 x-handle-switch background-color) | |
237 | ("--mouse-color" 1 x-handle-switch mouse-color) | |
238 | ("--icon-type" 0 x-handle-switch icon-type t) | |
239 | ("--iconic" 0 x-handle-iconic) | |
240 | ("--xrm" 1 x-handle-xrm-switch) | |
241 | ("--cursor-color" 1 x-handle-switch cursor-color) | |
242 | ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t) | |
9ff6bda1 | 243 | ("--line-spacing" 1 x-handle-numeric-switch line-spacing) |
ca57f55d JD |
244 | ("--border-color" 1 x-handle-switch border-width) |
245 | ("--smid" 1 x-handle-smid)) | |
b3afdeb8 RS |
246 | "Alist of X Windows options. |
247 | Each element has the form | |
248 | (NAME NUMARGS HANDLER FRAME-PARAM VALUE) | |
249 | where NAME is the option name string, NUMARGS is the number of arguments | |
250 | that the option accepts, HANDLER is a function to call to handle the option. | |
251 | FRAME-PARAM (optional) is the frame parameter this option specifies, | |
252 | and VALUE is the value which is given to that frame parameter | |
253 | \(most options use the argument for this, so VALUE is not present).") | |
254 | ||
e3bd99f5 | 255 | (defvar before-init-hook nil |
db3f571a | 256 | "Normal hook run after handling urgent options but before loading init files.") |
3fc958a4 | 257 | |
e3bd99f5 | 258 | (defvar after-init-hook nil |
db3f571a KH |
259 | "Normal hook run after loading the init files, `~/.emacs' and `default.el'. |
260 | There is no `condition-case' around the running of these functions; | |
261 | therefore, if you set `debug-on-error' non-nil in `.emacs', | |
262 | an error in one of these functions will invoke the debugger.") | |
263 | ||
264 | (defvar emacs-startup-hook nil | |
265 | "Normal hook run after loading init files and handling the command line.") | |
e3bd99f5 | 266 | |
a726e0d1 | 267 | (defvar term-setup-hook nil |
db3f571a KH |
268 | "Normal hook run after loading terminal-specific Lisp code. |
269 | It also follows `emacs-startup-hook'. This hook exists for users to set, | |
a726e0d1 JB |
270 | so as to override the definitions made by the terminal-specific file. |
271 | Emacs never sets this variable itself.") | |
272 | ||
deebb0e9 RS |
273 | (defvar inhibit-startup-hooks nil |
274 | "Non-nil means don't run `term-setup-hook' and `emacs-startup-hook'. | |
275 | This is because we already did so.") | |
276 | ||
a726e0d1 | 277 | (defvar keyboard-type nil |
b4484ea8 RS |
278 | "The brand of keyboard you are using. |
279 | This variable is used to define | |
a726e0d1 | 280 | the proper function and keypad keys for use under X. It is used in a |
94487c4e | 281 | fashion analogous to the environment variable TERM.") |
a726e0d1 JB |
282 | |
283 | (defvar window-setup-hook nil | |
b4484ea8 RS |
284 | "Normal hook run to initialize window system display. |
285 | Emacs runs this hook after processing the command line arguments and loading | |
286 | the user's init file.") | |
a726e0d1 | 287 | |
42a3e6fa RS |
288 | (defcustom initial-major-mode 'lisp-interaction-mode |
289 | "Major mode command symbol to use for the initial *scratch* buffer." | |
ce2f921e | 290 | :type 'function |
42a3e6fa | 291 | :group 'initialization) |
a726e0d1 | 292 | |
42a3e6fa | 293 | (defcustom init-file-user nil |
a726e0d1 | 294 | "Identity of user whose `.emacs' file is or was read. |
d7fa5aa2 RS |
295 | The value is nil if `-q' or `--no-init-file' was specified, |
296 | meaning do not load any init file. | |
297 | ||
298 | Otherwise, the value may be the null string, meaning use the init file | |
299 | for the user that originally logged in, or it may be a | |
300 | string containing a user's name meaning use that person's init file. | |
a726e0d1 | 301 | |
2bdfaa42 KH |
302 | In either of the latter cases, `(concat \"~\" init-file-user \"/\")' |
303 | evaluates to the name of the directory where the `.emacs' file was | |
13fce4e6 RS |
304 | looked for. |
305 | ||
306 | Setting `init-file-user' does not prevent Emacs from loading | |
42a3e6fa RS |
307 | `site-start.el'. The only way to do that is to use `--no-site-file'." |
308 | :type '(choice (const :tag "none" nil) string) | |
309 | :group 'initialization) | |
a726e0d1 | 310 | |
42a3e6fa | 311 | (defcustom site-run-file "site-start" |
b7444d31 RS |
312 | "File containing site-wide run-time initializations. |
313 | This file is loaded at run-time before `~/.emacs'. It contains inits | |
314 | that need to be in place for the entire site, but which, due to their | |
315 | higher incidence of change, don't make sense to load into emacs' | |
316 | dumped image. Thus, the run-time load order is: 1. file described in | |
13fce4e6 RS |
317 | this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'. |
318 | ||
319 | Don't use the `site-start.el' file for things some users may not like. | |
320 | Put them in `default.el' instead, so that users can more easily | |
321 | override them. Users can prevent loading `default.el' with the `-q' | |
322 | option or by setting `inhibit-default-init' in their own init files, | |
323 | but inhibiting `site-start.el' requires `--no-site-file', which | |
42a3e6fa | 324 | is less convenient." |
93812130 | 325 | :type '(choice (const :tag "none" nil) string) |
42a3e6fa | 326 | :group 'initialization) |
b7444d31 | 327 | |
42a3e6fa RS |
328 | (defcustom mail-host-address nil |
329 | "*Name of this machine, for purposes of naming users." | |
330 | :type '(choice (const nil) string) | |
331 | :group 'mail) | |
c13fbb62 | 332 | |
680ebfa6 RS |
333 | (defcustom user-mail-address (if command-line-processed |
334 | (concat (user-login-name) "@" | |
335 | (or mail-host-address | |
336 | (system-name))) | |
337 | ;; Empty string means "not set yet". | |
338 | "") | |
452e9090 RS |
339 | "*Full mailing address of this user. |
340 | This is initialized based on `mail-host-address', | |
42a3e6fa RS |
341 | after your init file is read, in case it sets `mail-host-address'." |
342 | :type 'string | |
343 | :group 'mail) | |
c10d1f06 | 344 | |
42a3e6fa | 345 | (defcustom auto-save-list-file-prefix |
73f13e5a GM |
346 | (cond ((eq system-type 'ms-dos) |
347 | ;; MS-DOS cannot have initial dot, and allows only 8.3 names | |
4b33deaa | 348 | "~/_emacs.d/auto-save.list/_s") |
73f13e5a GM |
349 | (t |
350 | "~/.emacs.d/auto-save-list/.saves-")) | |
cdee38c3 KH |
351 | "Prefix for generating `auto-save-list-file-name'. |
352 | This is used after reading your `.emacs' file to initialize | |
353 | `auto-save-list-file-name', by appending Emacs's pid and the system name, | |
354 | if you have not already set `auto-save-list-file-name' yourself. | |
73f13e5a | 355 | Directories in the prefix will be created if necessary. |
cdee38c3 | 356 | Set this to nil if you want to prevent `auto-save-list-file-name' |
42a3e6fa | 357 | from being initialized." |
3671f444 KH |
358 | :type '(choice (const :tag "Don't record a session's auto save list" nil) |
359 | string) | |
42a3e6fa | 360 | :group 'auto-save) |
2e05d063 | 361 | |
a726e0d1 JB |
362 | (defvar init-file-debug nil) |
363 | ||
52320897 RS |
364 | (defvar init-file-had-error nil) |
365 | ||
95eada65 RS |
366 | (defvar normal-top-level-add-subdirs-inode-list nil) |
367 | ||
859e15c1 | 368 | (defun normal-top-level-add-subdirs-to-load-path () |
0412d833 RS |
369 | "Add all subdirectories of current directory to `load-path'. |
370 | More precisely, this uses only the subdirectories whose names | |
f734a13e DL |
371 | start with letters or digits; it excludes any subdirectory named `RCS' |
372 | or `CVS', and any subdirectory that contains a file named `.nosearch'." | |
f1180544 | 373 | (let (dirs |
95eada65 | 374 | attrs |
859e15c1 KH |
375 | (pending (list default-directory))) |
376 | ;; This loop does a breadth-first tree walk on DIR's subtree, | |
377 | ;; putting each subdir into DIRS as its contents are examined. | |
378 | (while pending | |
4e0a3971 | 379 | (push (pop pending) dirs) |
722a451d EZ |
380 | (let* ((this-dir (car dirs)) |
381 | (contents (directory-files this-dir)) | |
382 | (default-directory this-dir) | |
383 | (canonicalized (and (eq system-type 'windows-nt) | |
384 | (untranslated-canonical-name this-dir)))) | |
385 | ;; The Windows version doesn't report meaningful inode | |
386 | ;; numbers, so use the canonicalized absolute file name of the | |
387 | ;; directory instead. | |
388 | (setq attrs (or canonicalized | |
389 | (nthcdr 10 (file-attributes this-dir)))) | |
95eada65 | 390 | (unless (member attrs normal-top-level-add-subdirs-inode-list) |
4e0a3971 SM |
391 | (push attrs normal-top-level-add-subdirs-inode-list) |
392 | (dolist (file contents) | |
c4a40544 | 393 | ;; The lower-case variants of RCS and CVS are for DOS/Windows. |
4e0a3971 SM |
394 | (unless (member file '("." ".." "RCS" "CVS" "rcs" "cvs")) |
395 | (when (and (string-match "\\`[[:alnum:]]" file) | |
9d1fb179 RS |
396 | ;; Avoid doing a `stat' when it isn't necessary |
397 | ;; because that can cause trouble when an NFS server | |
398 | ;; is down. | |
4e0a3971 SM |
399 | (not (string-match "\\.elc?\\'" file)) |
400 | (file-directory-p file)) | |
401 | (let ((expanded (expand-file-name file))) | |
95eada65 RS |
402 | (unless (file-exists-p (expand-file-name ".nosearch" |
403 | expanded)) | |
4e0a3971 | 404 | (setq pending (nconc pending (list expanded))))))))))) |
bb15e81a | 405 | (normal-top-level-add-to-load-path (cdr (nreverse dirs))))) |
859e15c1 | 406 | |
537b6e4e RS |
407 | ;; This function is called from a subdirs.el file. |
408 | ;; It assumes that default-directory is the directory | |
409 | ;; in which the subdirs.el file exists, | |
410 | ;; and it adds to load-path the subdirs of that directory | |
411 | ;; as specified in DIRS. Normally the elements of DIRS are relative. | |
e87a7309 | 412 | (defun normal-top-level-add-to-load-path (dirs) |
cd1c10f6 RS |
413 | (let ((tail load-path) |
414 | (thisdir (directory-file-name default-directory))) | |
415 | (while (and tail | |
138e541f GM |
416 | ;;Don't go all the way to the nil terminator. |
417 | (cdr tail) | |
cd1c10f6 RS |
418 | (not (equal thisdir (car tail))) |
419 | (not (and (memq system-type '(ms-dos windows-nt)) | |
420 | (equal (downcase thisdir) (downcase (car tail)))))) | |
421 | (setq tail (cdr tail))) | |
138e541f GM |
422 | ;;Splice the new section in. |
423 | (when tail | |
424 | (setcdr tail (append (mapcar 'expand-file-name dirs) (cdr tail)))))) | |
e87a7309 | 425 | |
a726e0d1 JB |
426 | (defun normal-top-level () |
427 | (if command-line-processed | |
428 | (message "Back to top level.") | |
429 | (setq command-line-processed t) | |
8d4c2221 RS |
430 | ;; Give *Messages* the same default-directory as *scratch*, |
431 | ;; just to keep things predictable. | |
432 | (let ((dir default-directory)) | |
433 | (save-excursion | |
434 | (set-buffer (get-buffer "*Messages*")) | |
435 | (setq default-directory dir))) | |
9715399e MR |
436 | ;; `user-full-name' is now known; reset its standard-value here. |
437 | (put 'user-full-name 'standard-value | |
438 | (list (default-value 'user-full-name))) | |
80d71556 KH |
439 | ;; For root, preserve owner and group when editing files. |
440 | (if (equal (user-uid) 0) | |
441 | (setq backup-by-copying-when-mismatch t)) | |
e87a7309 RS |
442 | ;; Look in each dir in load-path for a subdirs.el file. |
443 | ;; If we find one, load it, which will add the appropriate subdirs | |
444 | ;; of that dir into load-path, | |
357438eb KH |
445 | ;; Look for a leim-list.el file too. Loading it will register |
446 | ;; available input methods. | |
e87a7309 RS |
447 | (let ((tail load-path) |
448 | new) | |
449 | (while tail | |
4e0a3971 | 450 | (push (car tail) new) |
bbfc7591 GM |
451 | (condition-case nil |
452 | (let ((default-directory (car tail))) | |
453 | (load (expand-file-name "subdirs.el" (car tail)) t t t))) | |
357438eb KH |
454 | (condition-case nil |
455 | (let ((default-directory (car tail))) | |
456 | (load (expand-file-name "leim-list.el" (car tail)) t t t))) | |
e87a7309 | 457 | (setq tail (cdr tail)))) |
ffd56f97 | 458 | (if (not (eq system-type 'vax-vms)) |
a4b33896 JB |
459 | (progn |
460 | ;; If the PWD environment variable isn't accurate, delete it. | |
461 | (let ((pwd (getenv "PWD"))) | |
462 | (and (stringp pwd) | |
463 | ;; Use FOO/., so that if FOO is a symlink, file-attributes | |
464 | ;; describes the directory linked to, not FOO itself. | |
465 | (or (equal (file-attributes | |
466 | (concat (file-name-as-directory pwd) ".")) | |
467 | (file-attributes | |
468 | (concat (file-name-as-directory default-directory) | |
469 | "."))) | |
470 | (setq process-environment | |
471 | (delete (concat "PWD=" pwd) | |
472 | process-environment))))))) | |
492878e4 | 473 | (setq default-directory (abbreviate-file-name default-directory)) |
6f2c86fa KH |
474 | (let ((menubar-bindings-done nil)) |
475 | (unwind-protect | |
476 | (command-line) | |
477 | ;; Do this again, in case .emacs defined more abbreviations. | |
478 | (setq default-directory (abbreviate-file-name default-directory)) | |
b3c7c12c RS |
479 | ;; Specify the file for recording all the auto save files of this session. |
480 | ;; This is used by recover-session. | |
cdee38c3 KH |
481 | (or auto-save-list-file-name |
482 | (and auto-save-list-file-prefix | |
483 | (setq auto-save-list-file-name | |
1f7f78f1 RS |
484 | ;; Under MS-DOS our PID is almost always reused between |
485 | ;; Emacs invocations. We need something more unique. | |
4b33deaa EZ |
486 | (cond ((eq system-type 'ms-dos) |
487 | ;; We are going to access the auto-save | |
488 | ;; directory, so make sure it exists. | |
489 | (make-directory | |
490 | (file-name-directory auto-save-list-file-prefix) | |
491 | t) | |
f1180544 | 492 | (concat |
4b33deaa EZ |
493 | (make-temp-name |
494 | (expand-file-name | |
495 | auto-save-list-file-prefix)) | |
496 | "~")) | |
497 | (t | |
498 | (expand-file-name | |
499 | (format "%s%d-%s~" | |
500 | auto-save-list-file-prefix | |
501 | (emacs-pid) | |
502 | (system-name)))))))) | |
deebb0e9 RS |
503 | (unless inhibit-startup-hooks |
504 | (run-hooks 'emacs-startup-hook) | |
505 | (and term-setup-hook | |
506 | (run-hooks 'term-setup-hook))) | |
6a1e7d67 GM |
507 | |
508 | ;; Don't do this if we failed to create the initial frame, | |
509 | ;; for instance due to a dense colormap. | |
538ef02a GM |
510 | (when (or frame-initial-frame |
511 | ;; If frame-initial-frame has no meaning, do this anyway. | |
512 | (not (and window-system | |
513 | (not noninteractive) | |
514 | (not (eq window-system 'pc))))) | |
6a1e7d67 GM |
515 | ;; Modify the initial frame based on what .emacs puts into |
516 | ;; ...-frame-alist. | |
517 | (if (fboundp 'frame-notice-user-settings) | |
518 | (frame-notice-user-settings)) | |
519 | (if (fboundp 'frame-set-background-mode) | |
520 | ;; Set the faces for the initial background mode even if | |
521 | ;; frame-notice-user-settings didn't (such as on a tty). | |
522 | ;; frame-set-background-mode is idempotent, so it won't | |
523 | ;; cause any harm if it's already been done. | |
524 | (let ((frame-background-mode frame-background-mode) | |
525 | (frame (selected-frame)) | |
526 | term) | |
527 | (when (and (null window-system) | |
528 | ;; Don't override a possibly customized value. | |
529 | (null frame-background-mode) | |
530 | ;; Don't override user specifications. | |
531 | (null (frame-parameter frame 'reverse)) | |
532 | (let ((bg (frame-parameter frame 'background-color))) | |
533 | (or (null bg) | |
534 | (member bg '(unspecified "unspecified-bg"))))) | |
535 | (setq term (getenv "TERM")) | |
818cd248 EZ |
536 | ;; Some files in lisp/term do a better job with the |
537 | ;; background mode, but we leave this here anyway, in | |
538 | ;; case they remove those files. | |
6a1e7d67 GM |
539 | (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" |
540 | term) | |
541 | (setq frame-background-mode 'light))) | |
542 | (frame-set-background-mode (selected-frame))))) | |
13ab33c4 | 543 | |
6f2c86fa KH |
544 | ;; Now we know the user's default font, so add it to the menu. |
545 | (if (fboundp 'font-menu-add-default) | |
546 | (font-menu-add-default)) | |
547 | (and window-setup-hook | |
548 | (run-hooks 'window-setup-hook)) | |
549 | (or menubar-bindings-done | |
66c24e1e EZ |
550 | (if (display-popup-menus-p) |
551 | (precompute-menubar-bindings))))))) | |
6f2c86fa KH |
552 | |
553 | ;; Precompute the keyboard equivalents in the menu bar items. | |
554 | (defun precompute-menubar-bindings () | |
365636dc RS |
555 | (let ((submap (lookup-key global-map [menu-bar]))) |
556 | (while submap | |
557 | (and (consp (car submap)) | |
558 | (symbolp (car (car submap))) | |
559 | (stringp (car-safe (cdr (car submap)))) | |
560 | (keymapp (cdr (cdr (car submap)))) | |
a18042d7 RS |
561 | (progn |
562 | (x-popup-menu nil (cdr (cdr (car submap)))) | |
563 | (if purify-flag | |
564 | (garbage-collect)))) | |
365636dc | 565 | (setq submap (cdr submap)))) |
5b61c6a7 | 566 | (setq define-key-rebound-commands t)) |
a726e0d1 | 567 | |
c381f482 EZ |
568 | ;; Command-line options supported by tty's: |
569 | (defconst tty-long-option-alist | |
8957d2bf EZ |
570 | '(("--name" . "-name") |
571 | ("--title" . "-T") | |
572 | ("--reverse-video" . "-reverse") | |
c381f482 | 573 | ("--foreground-color" . "-fg") |
8957d2bf EZ |
574 | ("--background-color" . "-bg") |
575 | ("--color" . "-color"))) | |
c381f482 | 576 | |
b66b6aeb GM |
577 | (defconst tool-bar-images-pixel-height 24 |
578 | "Height in pixels of images in the tool bar.") | |
579 | ||
3a55d3d0 JR |
580 | (defvar tool-bar-originally-present nil |
581 | "Non-nil if tool-bars are present before user and site init files are read.") | |
582 | ||
c381f482 EZ |
583 | ;; Handle the X-like command line parameters "-fg", "-bg", "-name", etc. |
584 | (defun tty-handle-args (args) | |
585 | (let ((rest nil)) | |
586 | (message "%s" args) | |
587 | (while (and args | |
588 | (not (equal (car args) "--"))) | |
589 | (let* ((this (car args)) | |
590 | (orig-this this) | |
591 | completion argval) | |
592 | (setq args (cdr args)) | |
593 | ;; Check for long options with attached arguments | |
594 | ;; and separate out the attached option argument into argval. | |
595 | (if (string-match "^--[^=]*=" this) | |
596 | (setq argval (substring this (match-end 0)) | |
597 | this (substring this 0 (1- (match-end 0))))) | |
598 | (when (string-match "^--" this) | |
599 | (setq completion (try-completion this tty-long-option-alist)) | |
600 | (if (eq completion t) | |
601 | ;; Exact match for long option. | |
602 | (setq this (cdr (assoc this tty-long-option-alist))) | |
603 | (if (stringp completion) | |
604 | (let ((elt (assoc completion tty-long-option-alist))) | |
605 | ;; Check for abbreviated long option. | |
606 | (or elt | |
607 | (error "Option `%s' is ambiguous" this)) | |
608 | (setq this (cdr elt))) | |
609 | ;; Check for a short option. | |
610 | (setq argval nil this orig-this)))) | |
611 | (cond ((or (string= this "-fg") (string= this "-foreground")) | |
612 | (or argval (setq argval (car args) args (cdr args))) | |
613 | (setq default-frame-alist | |
614 | (cons (cons 'foreground-color argval) | |
615 | default-frame-alist))) | |
616 | ((or (string= this "-bg") (string= this "-background")) | |
617 | (or argval (setq argval (car args) args (cdr args))) | |
618 | (setq default-frame-alist | |
619 | (cons (cons 'background-color argval) | |
620 | default-frame-alist))) | |
621 | ((or (string= this "-T") (string= this "-name")) | |
622 | (or argval (setq argval (car args) args (cdr args))) | |
623 | (setq default-frame-alist | |
624 | (cons | |
625 | (cons 'title | |
626 | (if (stringp argval) | |
627 | argval | |
628 | (let ((case-fold-search t) | |
629 | i) | |
630 | (setq argval (invocation-name)) | |
631 | ||
632 | ;; Change any . or * characters in name to | |
633 | ;; hyphens, so as to emulate behavior on X. | |
634 | (while | |
635 | (setq i (string-match "[.*]" argval)) | |
636 | (aset argval i ?-)) | |
637 | argval))) | |
638 | default-frame-alist))) | |
639 | ((or (string= this "-r") | |
640 | (string= this "-rv") | |
641 | (string= this "-reverse")) | |
642 | (setq default-frame-alist | |
643 | (cons '(reverse . t) | |
644 | default-frame-alist))) | |
8957d2bf EZ |
645 | ((string= this "-color") |
646 | (if (null argval) | |
647 | (setq argval 8)) ; default --color means 8 ANSI colors | |
648 | (setq default-frame-alist | |
649 | (cons (cons 'tty-color-mode | |
650 | (cond | |
651 | ((numberp argval) argval) | |
652 | ((string-match "-?[0-9]+" argval) | |
653 | (string-to-number argval)) | |
654 | (t (intern argval)))) | |
655 | default-frame-alist))) | |
c381f482 EZ |
656 | (t (setq rest (cons this rest)))))) |
657 | (nreverse rest))) | |
658 | ||
a726e0d1 | 659 | (defun command-line () |
09a1077c RS |
660 | (setq command-line-default-directory default-directory) |
661 | ||
849eedba RS |
662 | ;; Choose a reasonable location for temporary files. |
663 | (setq temporary-file-directory | |
664 | (file-name-as-directory | |
665 | (cond ((memq system-type '(ms-dos windows-nt)) | |
666 | (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp")) | |
667 | ((memq system-type '(vax-vms axp-vms)) | |
668 | (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:")) | |
669 | (t | |
670 | (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))) | |
607f86f5 EZ |
671 | (setq small-temporary-file-directory |
672 | (if (eq system-type 'ms-dos) | |
f5568df0 | 673 | (getenv "TMPDIR"))) |
d88c92eb EZ |
674 | (setq auto-save-file-name-transforms |
675 | (list (list "\\`/[^/]*:\\(.+/\\)*\\(.*\\)" | |
676 | ;; Don't put "\\2" inside expand-file-name, since | |
677 | ;; it will be transformed to "/2" on DOS/Windows. | |
5ecad17d | 678 | (concat temporary-file-directory "\\2") t))) |
849eedba | 679 | |
74f2ab06 | 680 | ;; See if we should import version-control from the environment variable. |
a726e0d1 JB |
681 | (let ((vc (getenv "VERSION_CONTROL"))) |
682 | (cond ((eq vc nil)) ;don't do anything if not set | |
683 | ((or (string= vc "t") | |
684 | (string= vc "numbered")) | |
685 | (setq version-control t)) | |
686 | ((or (string= vc "nil") | |
687 | (string= vc "existing")) | |
688 | (setq version-control nil)) | |
689 | ((or (string= vc "never") | |
690 | (string= vc "simple")) | |
691 | (setq version-control 'never)))) | |
692 | ||
79058860 JB |
693 | ;;! This has been commented out; I currently find the behavior when |
694 | ;;! split-window-keep-point is nil disturbing, but if I can get used | |
695 | ;;! to it, then it would be better to eliminate the option. | |
696 | ;;! ;; Choose a good default value for split-window-keep-point. | |
697 | ;;! (setq split-window-keep-point (> baud-rate 2400)) | |
f35fe3c6 | 698 | |
d4308a4d EZ |
699 | ;; Set the default strings to display in mode line for |
700 | ;; end-of-line formats that aren't native to this platform. | |
701 | (cond | |
702 | ((memq system-type '(ms-dos windows-nt emx)) | |
703 | (setq eol-mnemonic-unix "(Unix)") | |
704 | (setq eol-mnemonic-mac "(Mac)")) | |
bde61f8b EZ |
705 | ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the |
706 | ;; abbreviated strings `/' and `:' set in coding.c for them. | |
707 | ((eq system-type 'macos) | |
708 | (setq eol-mnemonic-dos "(DOS)")) | |
d4308a4d EZ |
709 | (t ; this is for Unix/GNU/Linux systems |
710 | (setq eol-mnemonic-dos "(DOS)") | |
711 | (setq eol-mnemonic-mac "(Mac)"))) | |
712 | ||
a726e0d1 | 713 | ;; Read window system's init file if using a window system. |
1ed14cfd RS |
714 | (condition-case error |
715 | (if (and window-system (not noninteractive)) | |
716 | (load (concat term-file-prefix | |
717 | (symbol-name window-system) | |
718 | "-win") | |
719 | ;; Every window system should have a startup file; | |
720 | ;; barf if we can't find it. | |
721 | nil t)) | |
722 | ;; If we can't read it, print the error message and exit. | |
723 | (error | |
2677ad61 RS |
724 | (princ |
725 | (if (eq (car error) 'error) | |
726 | (apply 'concat (cdr error)) | |
727 | (if (memq 'file-error (get (car error) 'error-conditions)) | |
728 | (format "%s: %s" | |
729 | (nth 1 error) | |
ffaf8bbb | 730 | (mapconcat (lambda (obj) (prin1-to-string obj t)) |
2677ad61 RS |
731 | (cdr (cdr error)) ", ")) |
732 | (format "%s: %s" | |
733 | (get (car error) 'error-message) | |
ffaf8bbb | 734 | (mapconcat (lambda (obj) (prin1-to-string obj t)) |
2677ad61 RS |
735 | (cdr error) ", ")))) |
736 | 'external-debugging-output) | |
27f5188c | 737 | (terpri 'external-debugging-output) |
2677ad61 | 738 | (setq window-system nil) |
1ed14cfd | 739 | (kill-emacs))) |
a726e0d1 | 740 | |
c381f482 EZ |
741 | ;; Windowed displays do this inside their *-win.el. |
742 | (when (and (not (display-graphic-p)) | |
743 | (not noninteractive)) | |
744 | (setq command-line-args (tty-handle-args command-line-args))) | |
745 | ||
640a9cdd JR |
746 | (set-locale-environment nil) |
747 | ||
c16eb7b0 RS |
748 | ;; Convert the arguments to Emacs internal representation. |
749 | (let ((args (cdr command-line-args))) | |
750 | (while args | |
751 | (setcar args | |
752 | (decode-coding-string (car args) locale-coding-system t)) | |
753 | (setq args (cdr args)))) | |
754 | ||
03e3c30a JB |
755 | (let ((done nil) |
756 | (args (cdr command-line-args))) | |
757 | ||
a726e0d1 JB |
758 | ;; Figure out which user's init file to load, |
759 | ;; either from the environment or from the options. | |
760 | (setq init-file-user (if noninteractive nil (user-login-name))) | |
761 | ;; If user has not done su, use current $HOME to find .emacs. | |
762 | (and init-file-user (string= init-file-user (user-real-login-name)) | |
763 | (setq init-file-user "")) | |
03e3c30a JB |
764 | |
765 | ;; Process the command-line args, and delete the arguments | |
766 | ;; processed. This is consistent with the way main in emacs.c | |
767 | ;; does things. | |
a726e0d1 | 768 | (while (and (not done) args) |
096b7031 | 769 | (let ((longopts '(("--no-init-file") ("--no-site-file") ("--user") |
a360cae9 | 770 | ("--debug-init") ("--iconic") ("--icon-type"))) |
4e0a3971 | 771 | (argi (pop args)) |
096b7031 | 772 | (argval nil)) |
452e9090 | 773 | ;; Handle --OPTION=VALUE format. |
1b207153 CW |
774 | (when (and (string-match "\\`--" argi) |
775 | (string-match "=" argi)) | |
776 | (setq argval (substring argi (match-end 0)) | |
777 | argi (substring argi 0 (match-beginning 0)))) | |
778 | (unless (equal argi "--") | |
779 | (let ((completion (try-completion argi longopts))) | |
780 | (if (eq completion t) | |
781 | (setq argi (substring argi 1)) | |
782 | (if (stringp completion) | |
783 | (let ((elt (assoc completion longopts))) | |
784 | (or elt | |
785 | (error "Option `%s' is ambiguous" argi)) | |
786 | (setq argi (substring (car elt) 1))) | |
787 | (setq argval nil))))) | |
a726e0d1 | 788 | (cond |
4e0a3971 SM |
789 | ((member argi '("-q" "-no-init-file")) |
790 | (setq init-file-user nil)) | |
791 | ((member argi '("-u" "-user")) | |
096b7031 | 792 | (or argval |
4e0a3971 | 793 | (setq argval (pop args))) |
096b7031 | 794 | (setq init-file-user argval |
4e0a3971 | 795 | argval nil)) |
b7444d31 | 796 | ((string-equal argi "-no-site-file") |
4e0a3971 | 797 | (setq site-run-file nil)) |
a726e0d1 | 798 | ((string-equal argi "-debug-init") |
4e0a3971 | 799 | (setq init-file-debug t)) |
a360cae9 | 800 | ((string-equal argi "-iconic") |
4e0a3971 | 801 | (push '(visibility . icon) initial-frame-alist)) |
a360cae9 RS |
802 | ((or (string-equal argi "-icon-type") |
803 | (string-equal argi "-i") | |
804 | (string-equal argi "-itype")) | |
4e0a3971 SM |
805 | (push '(icon-type . t) default-frame-alist)) |
806 | ;; Push the popped arg back on the list of arguments. | |
807 | (t (push argi args) (setq done t))) | |
096b7031 KH |
808 | ;; Was argval set but not used? |
809 | (and argval | |
810 | (error "Option `%s' doesn't allow an argument" argi)))) | |
811 | ||
03e3c30a | 812 | ;; Re-attach the program name to the front of the arg list. |
4048e56d | 813 | (and command-line-args (setcdr command-line-args args))) |
a726e0d1 | 814 | |
c722566c | 815 | ;; Under X Windows, this creates the X frame and deletes the terminal frame. |
14f16b9c GM |
816 | (when (fboundp 'frame-initialize) |
817 | (frame-initialize)) | |
818 | ||
1fe0333f | 819 | ;; If frame was created with a menu bar, set menu-bar-mode on. |
ffaf8bbb SM |
820 | (if (and (not noninteractive) |
821 | (or (not (memq window-system '(x w32))) | |
4e0a3971 | 822 | (> (frame-parameter nil 'menu-bar-lines) 0))) |
1fe0333f | 823 | (menu-bar-mode t)) |
c722566c | 824 | |
7d1eb6a4 GM |
825 | ;; If frame was created with a tool bar, switch tool-bar-mode on. |
826 | (when (and (not noninteractive) | |
66c24e1e | 827 | (display-graphic-p) |
7d1eb6a4 | 828 | (> (frame-parameter nil 'tool-bar-lines) 0)) |
b66b6aeb | 829 | (tool-bar-mode 1)) |
7d1eb6a4 | 830 | |
6753393b GM |
831 | ;; Can't do this init in defcustom because window-system isn't set. |
832 | (when (and (not noninteractive) | |
833 | (not (eq system-type 'ms-dos)) | |
834 | (memq window-system '(x w32))) | |
835 | (setq-default blink-cursor t) | |
836 | (blink-cursor-mode 1)) | |
837 | ||
3ecd8ad0 GM |
838 | (unless noninteractive |
839 | ;; DOS/Windows systems have a PC-type keyboard which has both | |
840 | ;; <delete> and <backspace> keys. | |
841 | (when (or (memq system-type '(ms-dos windows-nt)) | |
842 | (and (memq window-system '(x)) | |
843 | (fboundp 'x-backspace-delete-keys-p) | |
7360b8aa GM |
844 | (x-backspace-delete-keys-p)) |
845 | ;; If the terminal Emacs is running on has erase char | |
846 | ;; set to ^H, use the Backspace key for deleting | |
847 | ;; backward and, and the Delete key for deleting forward. | |
848 | (and (null window-system) | |
849 | (eq tty-erase-char 8))) | |
d8e17bc6 EZ |
850 | (setq-default normal-erase-is-backspace t) |
851 | (normal-erase-is-backspace-mode 1))) | |
14f076a8 | 852 | |
3b73087e GM |
853 | (when (and (not noninteractive) |
854 | (display-graphic-p) | |
855 | (fboundp 'x-show-tip)) | |
856 | (setq-default tooltip-mode t) | |
857 | (tooltip-mode 1)) | |
858 | ||
1592c1ef EZ |
859 | ;; Register default TTY colors for the case the terminal hasn't a |
860 | ;; terminal init file. | |
861 | (or (memq window-system '(x w32)) | |
8957d2bf EZ |
862 | ;; We do this regardles of whether the terminal supports colors |
863 | ;; or not, since they can switch that support on or off in | |
864 | ;; mid-session by setting the tty-color-mode frame parameter. | |
d4bc31e9 | 865 | (tty-register-default-colors)) |
1592c1ef | 866 | |
3a55d3d0 JR |
867 | ;; Record whether the tool-bar is present before the user and site |
868 | ;; init files are processed. frame-notice-user-settings uses this | |
869 | ;; to determine if the tool-bar has been disabled by the init files, | |
870 | ;; and the frame needs to be resized. | |
871 | (when (fboundp 'frame-notice-user-settings) | |
872 | (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist) | |
873 | (assq 'tool-bar-lines default-frame-alist)))) | |
874 | (setq tool-bar-originally-present | |
875 | (not (or (null tool-bar-lines) | |
876 | (null (cdr tool-bar-lines)) | |
6811051d | 877 | (eq 0 (cdr tool-bar-lines))))))) |
3a55d3d0 | 878 | |
752ef254 GM |
879 | (let ((old-scalable-fonts-allowed scalable-fonts-allowed) |
880 | (old-font-list-limit font-list-limit) | |
881 | (old-face-ignored-fonts face-ignored-fonts)) | |
882 | ||
883 | (run-hooks 'before-init-hook) | |
884 | ||
885 | ;; Run the site-start library if it exists. The point of this file is | |
886 | ;; that it is run before .emacs. There is no point in doing this after | |
887 | ;; .emacs; that is useless. | |
f1180544 | 888 | (if site-run-file |
752ef254 GM |
889 | (load site-run-file t t)) |
890 | ||
891 | ;; Sites should not disable this. Only individuals should disable | |
892 | ;; the startup message. | |
893 | (setq inhibit-startup-message nil) | |
894 | ||
895 | ;; Load that user's init file, or the default one, or none. | |
896 | (let (debug-on-error-from-init-file | |
897 | debug-on-error-should-be-set | |
898 | (debug-on-error-initial | |
899 | (if (eq init-file-debug t) 'startup init-file-debug)) | |
900 | (orig-enable-multibyte default-enable-multibyte-characters)) | |
901 | (let ((debug-on-error debug-on-error-initial) | |
902 | ;; This function actually reads the init files. | |
903 | (inner | |
904 | (function | |
905 | (lambda () | |
906 | (if init-file-user | |
907 | (let ((user-init-file-1 | |
4e0a3971 | 908 | (cond |
752ef254 GM |
909 | ((eq system-type 'ms-dos) |
910 | (concat "~" init-file-user "/_emacs")) | |
911 | ((eq system-type 'windows-nt) | |
912 | (if (directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$") | |
913 | "~/.emacs" | |
914 | "~/_emacs")) | |
f1180544 | 915 | ((eq system-type 'vax-vms) |
752ef254 | 916 | "sys$login:.emacs") |
4e0a3971 | 917 | (t |
752ef254 GM |
918 | (concat "~" init-file-user "/.emacs"))))) |
919 | ;; This tells `load' to store the file name found | |
920 | ;; into user-init-file. | |
921 | (setq user-init-file t) | |
922 | (load user-init-file-1 t t) | |
f1180544 | 923 | |
a04d5983 RS |
924 | (when (eq user-init-file t) |
925 | ;; If we did not find ~/.emacs, try | |
926 | ;; ~/.emacs.d/.emacs. | |
927 | (let ((otherfile | |
928 | (expand-file-name | |
929 | (file-name-nondirectory user-init-file-1) | |
930 | (file-name-as-directory | |
931 | (expand-file-name | |
932 | ".emacs.d" | |
933 | (file-name-directory user-init-file-1)))))) | |
934 | (load otherfile t t) | |
935 | ||
936 | ;; If we did not find the user's init file, | |
937 | ;; set user-init-file conclusively. | |
938 | ;; Don't let it be set from default.el. | |
939 | (when (eq user-init-file t) | |
940 | (setq user-init-file user-init-file-1)))) | |
f1180544 | 941 | |
752ef254 GM |
942 | ;; If we loaded a compiled file, set |
943 | ;; `user-init-file' to the source version if that | |
944 | ;; exists. | |
945 | (when (and user-init-file | |
946 | (equal (file-name-extension user-init-file) | |
947 | "elc")) | |
948 | (let* ((source (file-name-sans-extension user-init-file)) | |
949 | (alt (concat source ".el"))) | |
950 | (setq source (cond ((file-exists-p alt) alt) | |
951 | ((file-exists-p source) source) | |
952 | (t nil))) | |
953 | (when source | |
954 | (when (file-newer-than-file-p source user-init-file) | |
955 | (message "Warning: %s is newer than %s" | |
956 | source user-init-file) | |
957 | (sit-for 1)) | |
958 | (setq user-init-file source)))) | |
f1180544 | 959 | |
694210c4 SM |
960 | (when (and (stringp custom-file) |
961 | (not (assoc custom-file load-history))) | |
962 | ;; If the .emacs file has set `custom-file' but hasn't | |
963 | ;; loaded the file yet, let's load it. | |
964 | (load custom-file t t)) | |
f1180544 | 965 | |
752ef254 GM |
966 | (or inhibit-default-init |
967 | (let ((inhibit-startup-message nil)) | |
968 | ;; Users are supposed to be told their rights. | |
969 | ;; (Plus how to get help and how to undo.) | |
970 | ;; Don't you dare turn this off for anyone | |
971 | ;; except yourself. | |
972 | (load "default" t t))))))))) | |
973 | (if init-file-debug | |
974 | ;; Do this without a condition-case if the user wants to debug. | |
975 | (funcall inner) | |
976 | (condition-case error | |
977 | (progn | |
978 | (funcall inner) | |
979 | (setq init-file-had-error nil)) | |
980 | (error | |
981 | (let ((message-log-max nil)) | |
982 | (save-excursion | |
983 | (set-buffer (get-buffer-create "*Messages*")) | |
984 | (insert "\n\n" | |
985 | (format "An error has occurred while loading `%s':\n\n" | |
986 | user-init-file) | |
987 | (format "%s%s%s" | |
988 | (get (car error) 'error-message) | |
989 | (if (cdr error) ": " "") | |
f5b6cffd | 990 | (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", ")) |
752ef254 | 991 | "\n\n" |
f5b6cffd KS |
992 | "To ensure normal operation, you should investigate and remove the\n" |
993 | "cause of the error in your initialization file. Start Emacs with\n" | |
994 | "the `--debug-init' option to view a complete error backtrace.\n\n")) | |
752ef254 GM |
995 | (message "Error in init file: %s%s%s" |
996 | (get (car error) 'error-message) | |
997 | (if (cdr error) ": " "") | |
998 | (mapconcat 'prin1-to-string (cdr error) ", ")) | |
f5b6cffd KS |
999 | (let ((pop-up-windows nil)) |
1000 | (pop-to-buffer "*Messages*")) | |
752ef254 | 1001 | (setq init-file-had-error t))))) |
ac3186fd RS |
1002 | |
1003 | ;; If the user has a file of abbrevs, read it. | |
1004 | (if (file-exists-p abbrev-file-name) | |
1005 | (quietly-read-abbrev-file abbrev-file-name)) | |
1006 | ||
70b199c3 RS |
1007 | ;; If the abbrevs came entirely from the init file or the |
1008 | ;; abbrevs file, they do not need saving. | |
1009 | (setq abbrevs-changed nil) | |
1010 | ||
752ef254 GM |
1011 | ;; If we can tell that the init file altered debug-on-error, |
1012 | ;; arrange to preserve the value that it set up. | |
1013 | (or (eq debug-on-error debug-on-error-initial) | |
1014 | (setq debug-on-error-should-be-set t | |
1015 | debug-on-error-from-init-file debug-on-error))) | |
1016 | (if debug-on-error-should-be-set | |
1017 | (setq debug-on-error debug-on-error-from-init-file)) | |
1018 | (unless (or default-enable-multibyte-characters | |
1019 | (eq orig-enable-multibyte default-enable-multibyte-characters)) | |
1020 | ;; Init file changed to unibyte. Reset existing multibyte | |
1021 | ;; buffers (probably *scratch*, *Messages*, *Minibuff-0*). | |
1022 | ;; Arguably this should only be done if they're free of | |
1023 | ;; multibyte characters. | |
1024 | (mapcar (lambda (buffer) | |
1025 | (with-current-buffer buffer | |
1026 | (if enable-multibyte-characters | |
1027 | (set-buffer-multibyte nil)))) | |
1028 | (buffer-list)) | |
1029 | ;; Also re-set the language environment in case it was | |
1030 | ;; originally done before unibyte was set and is sensitive to | |
1031 | ;; unibyte (display table, terminal coding system &c). | |
1032 | (set-language-environment current-language-environment))) | |
f1180544 | 1033 | |
752ef254 | 1034 | ;; Do this here in case the init file sets mail-host-address. |
5b88a2c5 | 1035 | (if (equal user-mail-address "") |
752ef254 GM |
1036 | (setq user-mail-address (concat (user-login-name) "@" |
1037 | (or mail-host-address | |
1038 | (system-name))))) | |
1039 | ||
1040 | ;; If parameter have been changed in the init file which influence | |
1041 | ;; face realization, clear the face cache so that new faces will | |
1042 | ;; be realized. | |
1043 | (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed) | |
1044 | (eq font-list-limit old-font-list-limit) | |
1045 | (eq face-ignored-fonts old-face-ignored-fonts)) | |
1046 | (clear-face-cache))) | |
f1180544 | 1047 | |
e3bd99f5 RM |
1048 | (run-hooks 'after-init-hook) |
1049 | ||
a726e0d1 JB |
1050 | ;; If *scratch* exists and init file didn't change its mode, initialize it. |
1051 | (if (get-buffer "*scratch*") | |
694210c4 | 1052 | (with-current-buffer "*scratch*" |
a726e0d1 JB |
1053 | (if (eq major-mode 'fundamental-mode) |
1054 | (funcall initial-major-mode)))) | |
f1180544 | 1055 | |
a726e0d1 JB |
1056 | ;; Load library for our terminal type. |
1057 | ;; User init file can set term-file-prefix to nil to prevent this. | |
1058 | (and term-file-prefix (not noninteractive) (not window-system) | |
1059 | (let ((term (getenv "TERM")) | |
1060 | hyphend) | |
1061 | (while (and term | |
1062 | (not (load (concat term-file-prefix term) t t))) | |
1063 | ;; Strip off last hyphen and what follows, then try again | |
1064 | (if (setq hyphend (string-match "[-_][^-_]+$" term)) | |
1065 | (setq term (substring term 0 hyphend)) | |
1066 | (setq term nil))))) | |
1067 | ||
5777a167 RS |
1068 | ;; Update the out-of-memory error message based on user's key bindings |
1069 | ;; for save-some-buffers. | |
1070 | (setq memory-signal-data | |
1071 | (list 'error | |
1072 | (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs"))) | |
1073 | ||
03e3c30a | 1074 | ;; Process the remaining args. |
a726e0d1 JB |
1075 | (command-line-1 (cdr command-line-args)) |
1076 | ||
1077 | ;; If -batch, terminate after processing the command options. | |
ca57f55d JD |
1078 | (if noninteractive (kill-emacs t)) |
1079 | ||
1080 | ;; Run emacs-session-restore (session management) if started by | |
1081 | ;; the session manager and we have a session manager connection. | |
70646cf0 JD |
1082 | (if (and (boundp 'x-session-previous-id) (stringp x-session-previous-id)) |
1083 | (emacs-session-restore x-session-previous-id))) | |
a726e0d1 | 1084 | |
46cfd295 | 1085 | (defcustom initial-scratch-message (purecopy "\ |
3b79c219 GM |
1086 | ;; This buffer is for notes you don't want to save, and for Lisp evaluation. |
1087 | ;; If you want to create a file, visit that file with C-x C-f, | |
1088 | ;; then enter the text in that file's own buffer. | |
9fe3219e | 1089 | |
46cfd295 | 1090 | ") |
9fe3219e RS |
1091 | "Initial message displayed in *scratch* buffer at startup. |
1092 | If this is nil, no message will be displayed." | |
fa071a47 RS |
1093 | :type '(choice (text :tag "Message") |
1094 | (const :tag "none" nil)) | |
1095 | :group 'initialization) | |
9fe3219e | 1096 | |
ce9ded5d GM |
1097 | \f |
1098 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1099 | ;;; Fancy splash screen | |
1100 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1101 | ||
1102 | (defvar fancy-splash-text | |
26ff68aa | 1103 | '((:face variable-pitch |
926aa0ee | 1104 | "You can do basic editing with the menu bar and scroll bar \ |
926aa0ee | 1105 | using the mouse.\n\n" |
26ff68aa | 1106 | :face (variable-pitch :weight bold) |
ce9ded5d | 1107 | "Important Help menu items:\n" |
26ff68aa | 1108 | :face variable-pitch "\ |
d7618b60 | 1109 | Emacs Tutorial\tLearn-by-doing tutorial for using Emacs efficiently |
1fc02b3c | 1110 | Emacs FAQ\tFrequently asked questions and answers |
5777a167 | 1111 | Read the Emacs Manual\tView the Emacs manual using Info |
1fc02b3c | 1112 | \(Non)Warranty\tGNU Emacs comes with " |
26ff68aa | 1113 | :face (variable-pitch :slant oblique) |
ce9ded5d | 1114 | "ABSOLUTELY NO WARRANTY\n" |
26ff68aa | 1115 | :face variable-pitch |
d3c5bad2 | 1116 | "\ |
d7618b60 | 1117 | Copying Conditions\tConditions for redistributing and changing Emacs |
682b60ae | 1118 | More Manuals / Ordering Manuals Buying printed manuals from the FSF\n") |
d7618b60 GM |
1119 | (:face variable-pitch |
1120 | "You can do basic editing with the menu bar and scroll bar \ | |
1121 | using the mouse.\n\n" | |
1122 | :face (variable-pitch :weight bold) | |
1123 | "Useful File menu items:\n" | |
1124 | :face variable-pitch "\ | |
1125 | Exit Emacs\t(Or type Control-x followed by Control-c) | |
1126 | Recover Session\tRecover files you were editing before a crash | |
1127 | ||
1128 | ||
1129 | ||
3f334882 | 1130 | |
d7618b60 GM |
1131 | " |
1132 | )) | |
ce9ded5d GM |
1133 | "A list of texts to show in the middle part of splash screens. |
1134 | Each element in the list should be a list of strings or pairs | |
1135 | `:face FACE', like `fancy-splash-insert' accepts them.") | |
1136 | ||
1137 | ||
fb275c02 | 1138 | (defgroup fancy-splash-screen () |
a01bb1db | 1139 | "Fancy splash screen when Emacs starts." |
fb275c02 | 1140 | :version "21.1" |
a01bb1db GM |
1141 | :group 'initialization) |
1142 | ||
1143 | ||
e9da51a1 | 1144 | (defcustom fancy-splash-delay 10 |
49939379 | 1145 | "*Delay in seconds between splash screens." |
a01bb1db | 1146 | :group 'fancy-splash-screen |
ce9ded5d GM |
1147 | :type 'integer) |
1148 | ||
1149 | ||
e9da51a1 GM |
1150 | (defcustom fancy-splash-max-time 60 |
1151 | "*Show splash screens for at most this number of seconds. | |
1152 | Values less than 60 seconds are ignored." | |
1153 | :group 'fancy-splash-screen | |
1154 | :type 'integer) | |
1155 | ||
1156 | ||
8ad8561b GM |
1157 | (defcustom fancy-splash-image nil |
1158 | "*The image to show in the splash screens, or nil for defaults." | |
a01bb1db | 1159 | :group 'fancy-splash-screen |
8ad8561b GM |
1160 | :type '(choice (const :tag "Default" nil) |
1161 | (file :tag "File"))) | |
ce9ded5d GM |
1162 | |
1163 | ||
f645586f GM |
1164 | ;; These are temporary storage areas for the splash screen display. |
1165 | ||
1166 | (defvar fancy-current-text nil) | |
1167 | (defvar fancy-splash-help-echo nil) | |
e9da51a1 | 1168 | (defvar fancy-splash-stop-time nil) |
eae91b60 | 1169 | (defvar fancy-splash-outer-buffer nil) |
f645586f | 1170 | |
ce9ded5d GM |
1171 | (defun fancy-splash-insert (&rest args) |
1172 | "Insert text into the current buffer, with faces. | |
1173 | Arguments from ARGS should be either strings or pairs `:face FACE', | |
1174 | where FACE is a valid face specification, as it can be used with | |
1175 | `put-text-properties'." | |
1176 | (let ((current-face nil)) | |
1177 | (while args | |
1178 | (if (eq (car args) :face) | |
1179 | (setq args (cdr args) current-face (car args)) | |
f645586f GM |
1180 | (insert (propertize (car args) |
1181 | 'face current-face | |
1182 | 'help-echo fancy-splash-help-echo))) | |
ce9ded5d GM |
1183 | (setq args (cdr args))))) |
1184 | ||
1185 | ||
1186 | (defun fancy-splash-head () | |
1187 | "Insert the head part of the splash screen into the current buffer." | |
51e8cfdd GM |
1188 | (let* ((image-file (cond ((stringp fancy-splash-image) |
1189 | fancy-splash-image) | |
1190 | ((and (display-color-p) | |
1191 | (image-type-available-p 'xpm)) | |
1192 | (if (and (fboundp 'x-display-planes) | |
1193 | (= (funcall 'x-display-planes) 8)) | |
1194 | "splash8.xpm" | |
1195 | "splash.xpm")) | |
1196 | (t "splash.pbm"))) | |
1197 | (img (create-image image-file)) | |
ce9ded5d GM |
1198 | (image-width (and img (car (image-size img)))) |
1199 | (window-width (window-width (selected-window)))) | |
1200 | (when img | |
1201 | (when (> window-width image-width) | |
f645586f | 1202 | ;; Center the image in the window. |
ce9ded5d GM |
1203 | (let ((pos (/ (- window-width image-width) 2))) |
1204 | (insert (propertize " " 'display `(space :align-to ,pos)))) | |
f645586f | 1205 | |
e7f3afa9 MB |
1206 | ;; Change the color of the XPM version of the splash image |
1207 | ;; so that it is visible with a dark frame background. | |
1208 | (when (and (memq 'xpm img) | |
1209 | (eq (frame-parameter nil 'background-mode) 'dark)) | |
1210 | (setq img (append img '(:color-symbols (("#000000" . "gray30")))))) | |
1211 | ||
f645586f GM |
1212 | ;; Insert the image with a help-echo and a keymap. |
1213 | (let ((map (make-sparse-keymap)) | |
a622451f | 1214 | (help-echo "mouse-2: browse http://www.gnu.org/")) |
f645586f GM |
1215 | (define-key map [mouse-2] |
1216 | (lambda () | |
1217 | (interactive) | |
a622451f | 1218 | (browse-url "http://www.gnu.org/") |
f645586f GM |
1219 | (throw 'exit nil))) |
1220 | (define-key map [down-mouse-2] 'ignore) | |
1221 | (define-key map [up-mouse-2] 'ignore) | |
1222 | (insert-image img (propertize "xxx" 'help-echo help-echo | |
1223 | 'keymap map))) | |
ce9ded5d | 1224 | (insert "\n")))) |
9d5cf87c RS |
1225 | (fancy-splash-insert |
1226 | :face '(variable-pitch :foreground "red") | |
1227 | (if (eq system-type 'gnu/linux) | |
1228 | "GNU Emacs is one component of the GNU/Linux operating system." | |
b831c087 | 1229 | "GNU Emacs is one component of the GNU operating system.")) |
eae91b60 RS |
1230 | (insert "\n") |
1231 | (unless (equal (buffer-name fancy-splash-outer-buffer) "*scratch*") | |
1232 | (fancy-splash-insert :face 'variable-pitch | |
1233 | (substitute-command-keys | |
1234 | "Type \\[recenter] to begin editing your file.\n")))) | |
ce9ded5d GM |
1235 | |
1236 | ||
1237 | (defun fancy-splash-tail () | |
1238 | "Insert the tail part of the splash screen into the current buffer." | |
95fadcca GM |
1239 | (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark) |
1240 | "cyan" "darkblue"))) | |
1241 | (fancy-splash-insert :face `(variable-pitch :foreground ,fg) | |
1242 | "\nThis is " | |
1243 | (emacs-version) | |
1244 | "\n" | |
1245 | :face '(variable-pitch :height 0.5) | |
84691156 | 1246 | "Copyright (C) 2002 Free Software Foundation, Inc.") |
ed638cc9 RS |
1247 | (and auto-save-list-file-prefix |
1248 | ;; Don't signal an error if the | |
1249 | ;; directory for auto-save-list files | |
1250 | ;; does not yet exist. | |
1251 | (file-directory-p (file-name-directory | |
1252 | auto-save-list-file-prefix)) | |
1253 | (directory-files | |
1254 | (file-name-directory auto-save-list-file-prefix) | |
1255 | nil | |
1256 | (concat "\\`" | |
1257 | (regexp-quote (file-name-nondirectory | |
1258 | auto-save-list-file-prefix))) | |
1259 | t) | |
1260 | (fancy-splash-insert :face '(variable-pitch :foreground "red") | |
1261 | "\n\nIf an Emacs session crashed recently, " | |
1262 | "type M-x recover-session RET\nto recover" | |
1263 | " the files you were editing.")))) | |
ce9ded5d | 1264 | |
f645586f GM |
1265 | (defun fancy-splash-screens-1 (buffer) |
1266 | "Timer function displaying a splash screen." | |
e9da51a1 GM |
1267 | (when (> (float-time) fancy-splash-stop-time) |
1268 | (throw 'stop-splashing nil)) | |
f645586f GM |
1269 | (unless fancy-current-text |
1270 | (setq fancy-current-text fancy-splash-text)) | |
1271 | (let ((text (car fancy-current-text))) | |
1272 | (set-buffer buffer) | |
1273 | (erase-buffer) | |
1274 | (fancy-splash-head) | |
1275 | (apply #'fancy-splash-insert text) | |
1276 | (fancy-splash-tail) | |
1277 | (unless (current-message) | |
1278 | (message fancy-splash-help-echo)) | |
1279 | (set-buffer-modified-p nil) | |
dbeb499b | 1280 | (goto-char (point-min)) |
f645586f GM |
1281 | (force-mode-line-update) |
1282 | (setq fancy-current-text (cdr fancy-current-text)))) | |
1283 | ||
1284 | ||
1285 | (defun fancy-splash-default-action () | |
1286 | "Default action for events in the splash screen buffer." | |
1287 | (interactive) | |
1288 | (push last-command-event unread-command-events) | |
1289 | (throw 'exit nil)) | |
1290 | ||
1291 | ||
ce9ded5d | 1292 | (defun fancy-splash-screens () |
f645586f | 1293 | "Display fancy splash screens when Emacs starts." |
5b61c6a7 | 1294 | (setq fancy-splash-help-echo (startup-echo-area-message)) |
848c7757 | 1295 | (let ((old-hourglass display-hourglass) |
eae91b60 RS |
1296 | (fancy-splash-outer-buffer (current-buffer)) |
1297 | splash-buffer | |
ff4ec1f7 | 1298 | (old-minor-mode-map-alist minor-mode-map-alist) |
6b20fb8e | 1299 | (frame (fancy-splash-frame)) |
5b61c6a7 | 1300 | timer) |
6b20fb8e RS |
1301 | (save-selected-window |
1302 | (select-frame frame) | |
1303 | (switch-to-buffer "GNU Emacs") | |
1304 | (setq tab-width 20) | |
1305 | (setq splash-buffer (current-buffer)) | |
1306 | (catch 'stop-splashing | |
1307 | (unwind-protect | |
1308 | (let ((map (make-sparse-keymap))) | |
1309 | (use-local-map map) | |
1310 | (define-key map [switch-frame] 'ignore) | |
1311 | (define-key map [t] 'fancy-splash-default-action) | |
1312 | (define-key map [mouse-movement] 'ignore) | |
1313 | (define-key map [mode-line t] 'ignore) | |
1314 | (setq cursor-type nil | |
1315 | display-hourglass nil | |
1316 | minor-mode-map-alist nil | |
1317 | buffer-undo-list t | |
f1180544 | 1318 | mode-line-format (propertize "---- %b %-" |
6b20fb8e RS |
1319 | 'face '(:weight bold)) |
1320 | fancy-splash-stop-time (+ (float-time) | |
1321 | (max 60 fancy-splash-max-time)) | |
1322 | timer (run-with-timer 0 fancy-splash-delay | |
1323 | #'fancy-splash-screens-1 | |
1324 | splash-buffer)) | |
1325 | (recursive-edit)) | |
e9da51a1 | 1326 | (cancel-timer timer) |
ff4ec1f7 GM |
1327 | (setq display-hourglass old-hourglass |
1328 | minor-mode-map-alist old-minor-mode-map-alist) | |
6b20fb8e RS |
1329 | (kill-buffer splash-buffer)))))) |
1330 | ||
1331 | (defun fancy-splash-frame () | |
1332 | "Return the frame to use for the fancy splash screen. | |
1333 | Returning non-nil does not mean we should necessarily | |
1334 | use the fancy splash screen, but if we do use it, | |
1335 | we put it on this frame." | |
1336 | (let (chosen-frame) | |
3a321ddb | 1337 | (dolist (frame (append (frame-list) (list (selected-frame)))) |
6b20fb8e RS |
1338 | (if (and (frame-visible-p frame) |
1339 | (not (window-minibuffer-p (frame-selected-window frame)))) | |
1340 | (setq chosen-frame frame))) | |
1341 | chosen-frame)) | |
f645586f | 1342 | |
285991dc GM |
1343 | (defun use-fancy-splash-screens-p () |
1344 | "Return t if fancy splash screens should be used." | |
1345 | (when (or (and (display-color-p) | |
1346 | (image-type-available-p 'xpm)) | |
1347 | (image-type-available-p 'pbm)) | |
16d2fae9 JPW |
1348 | (let ((frame (fancy-splash-frame))) |
1349 | (when frame | |
1350 | (let* ((img (create-image (or fancy-splash-image | |
1351 | (if (and (display-color-p) | |
1352 | (image-type-available-p 'xpm)) | |
1353 | "splash.xpm" "splash.pbm")))) | |
1354 | (image-height (and img (cdr (image-size img)))) | |
1355 | (window-height (1- (window-height (frame-selected-window frame))))) | |
1356 | (> window-height (+ image-height 19))))))) | |
285991dc GM |
1357 | |
1358 | ||
c61453ea PJ |
1359 | (defun normal-splash-screen () |
1360 | "Display splash screen when Emacs starts." | |
82e736c1 JPW |
1361 | (let ((prev-buffer (current-buffer))) |
1362 | (unwind-protect | |
1363 | (with-current-buffer (get-buffer-create "GNU Emacs") | |
1364 | (let ((tab-width 8) | |
f1180544 | 1365 | (mode-line-format (propertize "---- %b %-" |
82e736c1 JPW |
1366 | 'face '(:weight bold)))) |
1367 | ||
1368 | ;; The convention for this piece of code is that | |
1369 | ;; each piece of output starts with one or two newlines | |
1370 | ;; and does not end with any newlines. | |
1371 | (insert "Welcome to GNU Emacs") | |
9d5cf87c RS |
1372 | (insert |
1373 | (if (eq system-type 'gnu/linux) | |
1374 | ", one component of the GNU/Linux operating system.\n" | |
1375 | ", a part of the GNU operating system.\n")) | |
82e736c1 JPW |
1376 | |
1377 | (unless (equal (buffer-name prev-buffer) "*scratch*") | |
1378 | (insert (substitute-command-keys | |
1379 | "\nType \\[recenter] to begin editing your file.\n"))) | |
1380 | ||
1381 | (if (display-mouse-p) | |
1382 | ;; The user can use the mouse to activate menus | |
1383 | ;; so give help in terms of menu items. | |
1384 | (progn | |
1385 | (insert "\ | |
c61453ea PJ |
1386 | You can do basic editing with the menu bar and scroll bar using the mouse. |
1387 | ||
1388 | Useful File menu items: | |
1389 | Exit Emacs (or type Control-x followed by Control-c) | |
1390 | Recover Session recover files you were editing before a crash | |
1391 | ||
1392 | Important Help menu items: | |
1393 | Emacs Tutorial Learn-by-doing tutorial for using Emacs efficiently. | |
1394 | Emacs FAQ Frequently asked questions and answers | |
5777a167 | 1395 | Read the Emacs Manual View the Emacs manual using Info |
c61453ea PJ |
1396 | \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY |
1397 | Copying Conditions Conditions for redistributing and changing Emacs. | |
1398 | Getting New Versions How to obtain the latest version of Emacs. | |
682b60ae | 1399 | More Manuals / Ordering Manuals How to order printed manuals from the FSF. |
c61453ea | 1400 | ") |
82e736c1 JPW |
1401 | (insert "\n\n" (emacs-version) |
1402 | " | |
84691156 | 1403 | Copyright (C) 2002 Free Software Foundation, Inc.")) |
c61453ea | 1404 | |
82e736c1 JPW |
1405 | ;; No mouse menus, so give help using kbd commands. |
1406 | ||
1407 | ;; If keys have their default meanings, | |
1408 | ;; use precomputed string to save lots of time. | |
1409 | (if (and (eq (key-binding "\C-h") 'help-command) | |
1410 | (eq (key-binding "\C-xu") 'advertised-undo) | |
1411 | (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs) | |
1412 | (eq (key-binding "\C-ht") 'help-with-tutorial) | |
1413 | (eq (key-binding "\C-hi") 'info) | |
1414 | (eq (key-binding "\C-hr") 'info-emacs-manual) | |
1415 | (eq (key-binding "\C-h\C-n") 'view-emacs-news)) | |
1416 | (insert " | |
c61453ea | 1417 | Get help C-h (Hold down CTRL and press h) |
5777a167 RS |
1418 | Emacs manual C-h r |
1419 | Emacs tutorial C-h t Undo changes C-x u | |
1420 | Buy manuals C-h C-m Exit Emacs C-x C-c | |
1421 | Browse manuals C-h i") | |
1422 | ||
82e736c1 JPW |
1423 | (insert (substitute-command-keys |
1424 | (format "\n | |
c61453ea | 1425 | Get help %s |
5777a167 | 1426 | Emacs manual \\[info-emacs-manual] |
82e736c1 JPW |
1427 | Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo] |
1428 | Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs] | |
5777a167 | 1429 | Browse manuals \\[info]" |
82e736c1 JPW |
1430 | (let ((where (where-is-internal |
1431 | 'help-command nil t))) | |
1432 | (if where | |
1433 | (key-description where) | |
1434 | "M-x help")))))) | |
1435 | ||
1436 | ;; Say how to use the menu bar with the keyboard. | |
1437 | (if (and (eq (key-binding "\M-`") 'tmm-menubar) | |
1438 | (eq (key-binding [f10]) 'tmm-menubar)) | |
1439 | (insert " | |
c61453ea | 1440 | Activate menubar F10 or ESC ` or M-`") |
82e736c1 | 1441 | (insert (substitute-command-keys " |
c61453ea PJ |
1442 | Activate menubar \\[tmm-menubar]"))) |
1443 | ||
82e736c1 JPW |
1444 | ;; Many users seem to have problems with these. |
1445 | (insert " | |
c61453ea PJ |
1446 | \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key. |
1447 | If you have no Meta key, you may instead type ESC followed by the character.)") | |
1448 | ||
82e736c1 JPW |
1449 | (insert "\n\n" (emacs-version) |
1450 | " | |
84691156 | 1451 | Copyright (C) 2002 Free Software Foundation, Inc.") |
c61453ea | 1452 | |
82e736c1 JPW |
1453 | (if (and (eq (key-binding "\C-h\C-c") 'describe-copying) |
1454 | (eq (key-binding "\C-h\C-d") 'describe-distribution) | |
1455 | (eq (key-binding "\C-h\C-w") 'describe-no-warranty)) | |
f1180544 | 1456 | (insert |
82e736c1 | 1457 | "\n |
c61453ea PJ |
1458 | GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details. |
1459 | Emacs is Free Software--Free as in Freedom--so you can redistribute copies | |
1460 | of Emacs and modify it; type C-h C-c to see the conditions. | |
1461 | Type C-h C-d for information on getting the latest version.") | |
82e736c1 JPW |
1462 | (insert (substitute-command-keys |
1463 | "\n | |
c61453ea PJ |
1464 | GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details. |
1465 | Emacs is Free Software--Free as in Freedom--so you can redistribute copies | |
1466 | of Emacs and modify it; type \\[describe-copying] to see the conditions. | |
1467 | Type \\[describe-distribution] for information on getting the latest version.")))) | |
1468 | ||
82e736c1 JPW |
1469 | ;; The rest of the startup screen is the same on all |
1470 | ;; kinds of terminals. | |
1471 | ||
1472 | ;; Give information on recovering, if there was a crash. | |
1473 | (and auto-save-list-file-prefix | |
1474 | ;; Don't signal an error if the | |
1475 | ;; directory for auto-save-list files | |
1476 | ;; does not yet exist. | |
1477 | (file-directory-p (file-name-directory | |
1478 | auto-save-list-file-prefix)) | |
1479 | (directory-files | |
1480 | (file-name-directory auto-save-list-file-prefix) | |
1481 | nil | |
1482 | (concat "\\`" | |
1483 | (regexp-quote (file-name-nondirectory | |
1484 | auto-save-list-file-prefix))) | |
1485 | t) | |
1486 | (insert "\n\nIf an Emacs session crashed recently, " | |
1487 | "type M-x recover-session RET\nto recover" | |
1488 | " the files you were editing.")) | |
1489 | ||
1490 | ;; Display the input that we set up in the buffer. | |
1491 | (set-buffer-modified-p nil) | |
1492 | (goto-char (point-min)) | |
1493 | (save-window-excursion | |
1494 | (switch-to-buffer (current-buffer)) | |
1495 | (sit-for 120)))) | |
1496 | ;; Unwind ... ensure splash buffer is killed | |
1497 | (kill-buffer "GNU Emacs")))) | |
1498 | ||
c61453ea | 1499 | |
f645586f GM |
1500 | (defun startup-echo-area-message () |
1501 | (if (eq (key-binding "\C-h\C-p") 'describe-project) | |
1502 | "For information about the GNU Project and its goals, type C-h C-p." | |
1503 | (substitute-command-keys | |
1504 | "For information about the GNU Project and its goals, type \ | |
1505 | \\[describe-project]."))) | |
ce9ded5d GM |
1506 | |
1507 | ||
49939379 | 1508 | (defun display-startup-echo-area-message () |
15fa6db0 GM |
1509 | (let ((resize-mini-windows t)) |
1510 | (message (startup-echo-area-message)))) | |
f645586f | 1511 | |
49939379 | 1512 | |
c61453ea PJ |
1513 | (defun display-splash-screen () |
1514 | "Display splash screen according to display. | |
1515 | Fancy splash screens are used on graphic displays, | |
1516 | normal otherwise." | |
1517 | (interactive) | |
1518 | (if (and (display-graphic-p) | |
1519 | (use-fancy-splash-screens-p)) | |
1520 | (fancy-splash-screens) | |
1521 | (normal-splash-screen))) | |
1522 | ||
1523 | ||
a726e0d1 | 1524 | (defun command-line-1 (command-line-args-left) |
52320897 | 1525 | (or noninteractive (input-pending-p) init-file-had-error |
ed638cc9 RS |
1526 | ;; t if the init file says to inhibit the echo area startup message. |
1527 | (and inhibit-startup-echo-area-message | |
1528 | user-init-file | |
1529 | (or (and (get 'inhibit-startup-echo-area-message 'saved-value) | |
1530 | (equal inhibit-startup-echo-area-message | |
1531 | (if (string= init-file-user "") | |
1532 | (user-login-name) | |
1533 | init-file-user))) | |
1534 | ;; Wasn't set with custom; see if .emacs has a setq. | |
1535 | (let ((buffer (get-buffer-create " *temp*"))) | |
1536 | (prog1 | |
1537 | (condition-case nil | |
1538 | (save-excursion | |
1539 | (set-buffer buffer) | |
1540 | (insert-file-contents user-init-file) | |
1541 | (re-search-forward | |
1542 | (concat | |
1543 | "([ \t\n]*setq[ \t\n]+" | |
1544 | "inhibit-startup-echo-area-message[ \t\n]+" | |
1545 | (regexp-quote | |
1546 | (prin1-to-string | |
1547 | (if (string= init-file-user "") | |
1548 | (user-login-name) | |
1549 | init-file-user))) | |
1550 | "[ \t\n]*)") | |
1551 | nil t)) | |
1552 | (error nil)) | |
1553 | (kill-buffer buffer))))) | |
1554 | (display-startup-echo-area-message)) | |
1555 | ||
1556 | ;; Delay 2 seconds after an init file error message | |
1557 | ;; was displayed, so user can read it. | |
1558 | (if init-file-had-error | |
1559 | (sit-for 2)) | |
1560 | ||
1561 | (if command-line-args-left | |
1562 | ;; We have command args; process them. | |
1563 | (let ((dir command-line-default-directory) | |
1564 | (file-count 0) | |
1565 | first-file-buffer | |
1566 | tem | |
1567 | just-files ;; t if this follows the magic -- option. | |
1568 | ;; This includes our standard options' long versions | |
1569 | ;; and long versions of what's on command-switch-alist. | |
1570 | (longopts | |
1571 | (append '(("--funcall") ("--load") ("--insert") ("--kill") | |
f6a9d2d8 | 1572 | ("--directory") ("--eval") ("--execute") ("--no-splash") |
ed638cc9 RS |
1573 | ("--find-file") ("--visit") ("--file")) |
1574 | (mapcar (lambda (elt) | |
1575 | (list (concat "-" (car elt)))) | |
1576 | command-switch-alist))) | |
1577 | (line 0) | |
1578 | (column 0)) | |
1579 | ||
1580 | ;; Add the long X options to longopts. | |
4e0a3971 SM |
1581 | (dolist (tem command-line-x-option-alist) |
1582 | (if (string-match "^--" (car tem)) | |
1583 | (push (list (car tem)) longopts))) | |
ed638cc9 RS |
1584 | |
1585 | ;; Loop, processing options. | |
1586 | (while (and command-line-args-left) | |
1587 | (let* ((argi (car command-line-args-left)) | |
1588 | (orig-argi argi) | |
1589 | argval completion | |
1590 | ;; List of directories specified in -L/--directory, | |
1591 | ;; in reverse of the order specified. | |
1592 | extra-load-path | |
1593 | (initial-load-path load-path)) | |
1594 | (setq command-line-args-left (cdr command-line-args-left)) | |
1595 | ||
1596 | ;; Do preliminary decoding of the option. | |
1597 | (if just-files | |
1598 | ;; After --, don't look for options; treat all args as files. | |
1599 | (setq argi "") | |
1600 | ;; Convert long options to ordinary options | |
1601 | ;; and separate out an attached option argument into argval. | |
1602 | (if (string-match "^--[^=]*=" argi) | |
1603 | (setq argval (substring argi (match-end 0)) | |
1604 | argi (substring argi 0 (1- (match-end 0))))) | |
1605 | (if (equal argi "--") | |
1606 | (setq completion nil) | |
1607 | (setq completion (try-completion argi longopts))) | |
1608 | (if (eq completion t) | |
1609 | (setq argi (substring argi 1)) | |
1610 | (if (stringp completion) | |
1611 | (let ((elt (assoc completion longopts))) | |
1612 | (or elt | |
1613 | (error "Option `%s' is ambiguous" argi)) | |
1614 | (setq argi (substring (car elt) 1))) | |
1615 | (setq argval nil argi orig-argi)))) | |
1616 | ||
1617 | ;; Execute the option. | |
1618 | (cond ((setq tem (assoc argi command-switch-alist)) | |
1619 | (if argval | |
1620 | (let ((command-line-args-left | |
1621 | (cons argval command-line-args-left))) | |
1622 | (funcall (cdr tem) argi)) | |
1623 | (funcall (cdr tem) argi))) | |
1624 | ||
f6a9d2d8 | 1625 | ((string-equal argi "-no-splash") |
1b207153 CW |
1626 | (setq inhibit-startup-message t)) |
1627 | ||
4e0a3971 SM |
1628 | ((member argi '("-f" ;what the manual claims |
1629 | "-funcall" | |
1630 | "-e")) ; what the source used to say | |
ed638cc9 RS |
1631 | (if argval |
1632 | (setq tem (intern argval)) | |
1633 | (setq tem (intern (car command-line-args-left))) | |
1634 | (setq command-line-args-left (cdr command-line-args-left))) | |
1635 | (if (arrayp (symbol-function tem)) | |
1636 | (command-execute tem) | |
1637 | (funcall tem))) | |
1638 | ||
4e0a3971 | 1639 | ((member argi '("-eval" "-execute")) |
ed638cc9 RS |
1640 | (if argval |
1641 | (setq tem argval) | |
1642 | (setq tem (car command-line-args-left)) | |
1643 | (setq command-line-args-left (cdr command-line-args-left))) | |
1644 | (eval (read tem))) | |
1645 | ;; Set the default directory as specified in -L. | |
1646 | ||
4e0a3971 | 1647 | ((member argi '("-L" "-directory")) |
ed638cc9 RS |
1648 | (if argval |
1649 | (setq tem argval) | |
1650 | (setq tem (car command-line-args-left) | |
1651 | command-line-args-left (cdr command-line-args-left))) | |
1652 | (setq tem (command-line-normalize-file-name tem)) | |
1653 | (setq extra-load-path | |
1654 | (cons (expand-file-name tem) extra-load-path)) | |
1655 | (setq load-path (append (nreverse extra-load-path) | |
1656 | initial-load-path))) | |
1657 | ||
4e0a3971 | 1658 | ((member argi '("-l" "-load")) |
ed638cc9 RS |
1659 | (if argval |
1660 | (setq tem argval) | |
1661 | (setq tem (car command-line-args-left) | |
1662 | command-line-args-left (cdr command-line-args-left))) | |
1663 | (let ((file (command-line-normalize-file-name tem))) | |
1664 | ;; Take file from default dir if it exists there; | |
1665 | ;; otherwise let `load' search for it. | |
1666 | (if (file-exists-p (expand-file-name file)) | |
1667 | (setq file (expand-file-name file))) | |
1668 | (load file nil t))) | |
1669 | ||
1670 | ((string-equal argi "-insert") | |
1671 | (if argval | |
1672 | (setq tem argval) | |
1673 | (setq tem (car command-line-args-left) | |
1674 | command-line-args-left (cdr command-line-args-left))) | |
1675 | (or (stringp tem) | |
1676 | (error "File name omitted from `-insert' option")) | |
1677 | (insert-file-contents (command-line-normalize-file-name tem))) | |
1678 | ||
1679 | ((string-equal argi "-kill") | |
1680 | (kill-emacs t)) | |
1681 | ||
1682 | ((string-match "^\\+[0-9]+\\'" argi) | |
1683 | (setq line (string-to-int argi))) | |
1684 | ||
1685 | ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi) | |
1686 | (setq line (string-to-int (match-string 1 argi)) | |
1687 | column (string-to-int (match-string 2 argi)))) | |
1688 | ||
1689 | ((setq tem (assoc argi command-line-x-option-alist)) | |
1690 | ;; Ignore X-windows options and their args if not using X. | |
1691 | (setq command-line-args-left | |
1692 | (nthcdr (nth 1 tem) command-line-args-left))) | |
1693 | ||
4e0a3971 | 1694 | ((member argi '("-find-file" "-file" "-visit")) |
ed638cc9 RS |
1695 | ;; An explicit option to specify visiting a file. |
1696 | (if argval | |
1697 | (setq tem argval) | |
1698 | (setq tem (car command-line-args-left) | |
1699 | command-line-args-left (cdr command-line-args-left))) | |
1700 | (unless (stringp tem) | |
1701 | (error "File name omitted from `%s' option" argi)) | |
1702 | (setq file-count (1+ file-count)) | |
1703 | (let ((file (expand-file-name | |
1704 | (command-line-normalize-file-name tem) dir))) | |
1705 | (if (= file-count 1) | |
1706 | (setq first-file-buffer (find-file file)) | |
1707 | (find-file-other-window file))) | |
1708 | (or (zerop line) | |
1709 | (goto-line line)) | |
1710 | (setq line 0) | |
1711 | (unless (< column 1) | |
1712 | (move-to-column (1- column))) | |
1713 | (setq column 0)) | |
1714 | ||
1715 | ((equal argi "--") | |
1716 | (setq just-files t)) | |
1717 | (t | |
1718 | ;; We have almost exhausted our options. See if the | |
1719 | ;; user has made any other command-line options available | |
1720 | (let ((hooks command-line-functions) ;; lrs 7/31/89 | |
1721 | (did-hook nil)) | |
1722 | (while (and hooks | |
1723 | (not (setq did-hook (funcall (car hooks))))) | |
1724 | (setq hooks (cdr hooks))) | |
1725 | (if (not did-hook) | |
1726 | ;; Ok, presume that the argument is a file name | |
1727 | (progn | |
1728 | (if (string-match "\\`-" argi) | |
1729 | (error "Unknown option `%s'" argi)) | |
1730 | (setq file-count (1+ file-count)) | |
1731 | (let ((file | |
1732 | (expand-file-name | |
1733 | (command-line-normalize-file-name orig-argi) | |
1734 | dir))) | |
1735 | (if (= file-count 1) | |
1736 | (setq first-file-buffer (find-file file)) | |
1737 | (find-file-other-window file))) | |
1738 | (or (zerop line) | |
1739 | (goto-line line)) | |
1740 | (setq line 0) | |
1741 | (unless (< column 1) | |
1742 | (move-to-column (1- column))) | |
1743 | (setq column 0)))))))) | |
1744 | ;; If 3 or more files visited, and not all visible, | |
1745 | ;; show user what they all are. But leave the last one current. | |
1746 | (and (> file-count 2) | |
1747 | (not noninteractive) | |
26780e5b | 1748 | (not inhibit-startup-buffer-menu) |
ed638cc9 | 1749 | (or (get-buffer-window first-file-buffer) |
eae91b60 RS |
1750 | (list-buffers))))) |
1751 | ||
1752 | ;; Maybe display a startup screen. | |
1753 | (when (and (not inhibit-startup-message) (not noninteractive) | |
1754 | ;; Don't display startup screen if init file | |
1755 | ;; has started some sort of server. | |
1756 | (not (and (fboundp 'process-list) | |
1757 | (process-list)))) | |
1758 | ;; Display a startup screen, after some preparations. | |
1759 | ||
1760 | ;; If there are no switches to process, we might as well | |
1761 | ;; run this hook now, and there may be some need to do it | |
1762 | ;; before doing any output. | |
deebb0e9 | 1763 | (run-hooks 'emacs-startup-hook) |
eae91b60 RS |
1764 | (and term-setup-hook |
1765 | (run-hooks 'term-setup-hook)) | |
deebb0e9 | 1766 | (setq inhibit-startup-hooks t) |
eae91b60 RS |
1767 | |
1768 | ;; It's important to notice the user settings before we | |
1769 | ;; display the startup message; otherwise, the settings | |
1770 | ;; won't take effect until the user gives the first | |
1771 | ;; keystroke, and that's distracting. | |
1772 | (when (fboundp 'frame-notice-user-settings) | |
1773 | (frame-notice-user-settings)) | |
1774 | ||
1775 | ;; If there are no switches to process, we might as well | |
1776 | ;; run this hook now, and there may be some need to do it | |
1777 | ;; before doing any output. | |
1778 | (when window-setup-hook | |
1779 | (run-hooks 'window-setup-hook) | |
1780 | ;; Don't let the hook be run twice. | |
1781 | (setq window-setup-hook nil)) | |
1782 | ||
1783 | ;; Do this now to avoid an annoying delay if the user | |
1784 | ;; clicks the menu bar during the sit-for. | |
1785 | (when (display-popup-menus-p) | |
1786 | (precompute-menubar-bindings)) | |
1787 | (setq menubar-bindings-done t) | |
ed638cc9 | 1788 | |
eae91b60 RS |
1789 | ;; If *scratch* is selected and it is empty, insert an |
1790 | ;; initial message saying not to create a file there. | |
1791 | (when (and initial-scratch-message | |
ed638cc9 | 1792 | (string= (buffer-name) "*scratch*") |
ed638cc9 | 1793 | (= 0 (buffer-size))) |
eae91b60 RS |
1794 | (insert initial-scratch-message) |
1795 | (set-buffer-modified-p nil)) | |
ed638cc9 | 1796 | |
eae91b60 RS |
1797 | ;; If user typed input during all that work, |
1798 | ;; abort the startup screen. Otherwise, display it now. | |
c61453ea PJ |
1799 | (unless (input-pending-p) |
1800 | (display-splash-screen)))) | |
c88ab9ce | 1801 | |
49939379 | 1802 | |
47c7adae RS |
1803 | (defun command-line-normalize-file-name (file) |
1804 | "Collapse multiple slashes to one, to handle non-Emacs file names." | |
6b9e794f RS |
1805 | (save-match-data |
1806 | ;; Use arg 1 so that we don't collapse // at the start of the file name. | |
1807 | ;; That is significant on some systems. | |
1808 | ;; However, /// at the beginning is supposed to mean just /, not //. | |
1809 | (if (string-match "^///+" file) | |
1810 | (setq file (replace-match "/" t t file))) | |
1811 | (while (string-match "//+" file 1) | |
1812 | (setq file (replace-match "/" t t file))) | |
1813 | file)) | |
47c7adae | 1814 | |
c88ab9ce | 1815 | ;;; startup.el ends here |