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