Mercurial > hg > xemacs-beta
comparison lisp/prim/startup.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 8d2a9b52c682 |
children | b9518feda344 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 ;; General Public License for more details. | 20 ;; General Public License for more details. |
21 | 21 |
22 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
23 ;; along with XEmacs; see the file COPYING. If not, write to the | 23 ;; along with XEmacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
25 ;; Boston, MA 02111-1307, USA. | 25 ;; Boston, MA 02111-1307, USA. |
26 | 26 |
27 ;;; Synched up with: FSF 19.28. | 27 ;;; Synched up with: FSF 19.34. |
28 | 28 |
29 ;;; Code: | 29 ;;; Code: |
30 | 30 |
31 ;;; -batch, -t, and -nw are processed by main() in emacs.c and are | |
32 ;;; never seen by lisp code. | |
33 | |
34 ;;; -version and -help are special-cased as well: they imply -batch, | |
35 ;;; but are left on the list for lisp code to process. | |
36 | |
37 | |
38 (setq top-level '(normal-top-level)) | |
39 | |
40 (defvar command-line-processed nil "t once command line has been processed") | |
41 | |
42 (defconst startup-message-timeout 120) | |
43 | |
44 (defconst inhibit-startup-message nil | |
45 "*Non-nil inhibits the initial startup message. | |
46 This is for use in your personal init file, once you are familiar | |
47 with the contents of the startup message.") | |
48 | |
49 ;; #### FSFmacs randomness | |
50 ;;(defconst inhibit-startup-echo-area-message nil | |
51 ;; "*Non-nil inhibits the initial startup echo area message. | |
52 ;;Inhibition takes effect only if your `.emacs' file contains | |
53 ;;a line of this form: | |
54 ;; (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\") | |
55 ;;If your `.emacs' file is byte-compiled, use the following form instead: | |
56 ;; (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")) | |
57 ;;Thus, someone else using a copy of your `.emacs' file will see | |
58 ;;the startup message unless he personally acts to inhibit it.") | |
59 | |
60 (defconst inhibit-default-init nil | |
61 "*Non-nil inhibits loading the `default' library.") | |
62 | |
63 (defvar command-line-args-left nil | |
64 "List of command-line args not yet processed.") ; bound by `command-line' | |
65 | |
66 (defvar command-line-default-directory nil | |
67 "Default directory to use for command line arguments. | |
68 This is normally copied from `default-directory' when XEmacs starts.") | |
69 | |
70 (defvar before-init-hook nil | |
71 "Functions to call after handling urgent options but before init files. | |
72 The frame system uses this to open frames to display messages while | |
73 XEmacs loads the user's initialization file.") | |
74 | |
75 (defvar after-init-hook nil | |
76 "Functions to call after loading the init file (`~/.emacs'). | |
77 The call is not protected by a condition-case, so you can set `debug-on-error' | |
78 in `.emacs', and put all the actual code on `after-init-hook'.") | |
79 | |
80 (defvar term-setup-hook nil | |
81 "Functions to be called after loading terminal-specific Lisp code. | |
82 See `run-hooks'. This variable exists for users to set, | |
83 so as to override the definitions made by the terminal-specific file. | |
84 XEmacs never sets this variable itself.") | |
85 | |
86 (defvar keyboard-type nil | |
87 "The brand of keyboard you are using. | |
88 This variable is used to define | |
89 the proper function and keypad keys for use under X. It is used in a | |
90 fashion analogous to the environment value TERM.") | |
91 | |
92 (defvar window-setup-hook nil | |
93 "Normal hook run to initialize window system display. | |
94 XEmacs runs this hook after processing the command line arguments and loading | |
95 the user's init file.") | |
96 | |
97 (defconst initial-major-mode 'lisp-interaction-mode | |
98 "Major mode command symbol to use for the initial *scratch* buffer.") | |
99 | |
100 (defvar init-file-user nil | |
101 "Identity of user whose `.emacs' file is or was read. | |
102 The value is nil if no init file is being used; otherwise, it may be either | |
103 the null string, meaning that the init file was taken from the user that | |
104 originally logged in, or it may be a string containing a user's name. | |
105 | |
106 In either of the latter cases, `(concat \"~\" init-file-user \"/\")' | |
107 evaluates to the name of the directory where the `.emacs' file was | |
108 looked for. | |
109 | |
110 Setting `init-file-user' does not prevent Emacs from loading | |
111 `site-start.el'. The only way to do that is to use `--no-site-file'.") | |
112 | |
113 ;; #### called `site-run-file' in FSFmacs | |
114 | |
115 (defvar site-start-file (purecopy "site-start") | |
116 "File containing site-wide run-time initializations. | |
117 This file is loaded at run-time before `~/.emacs'. It contains inits | |
118 that need to be in place for the entire site, but which, due to their | |
119 higher incidence of change, don't make sense to load into XEmacs' | |
120 dumped image. Thus, the run-time load order is: 1. file described in | |
121 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'. | |
122 | |
123 Don't use the `site-start.el' file for things some users may not like. | |
124 Put them in `default.el' instead, so that users can more easily | |
125 override them. Users can prevent loading `default.el' with the `-q' | |
126 option or by setting `inhibit-default-init' in their own init files, | |
127 but inhibiting `site-start.el' requires `--no-site-file', which | |
128 is less convenient.") | |
129 | |
130 ;;(defconst iso-8859-1-locale-regexp "8859[-_]?1" | |
131 ;; "Regexp that specifies when to enable the ISO 8859-1 character set. | |
132 ;;We do that if this regexp matches the locale name | |
133 ;;specified by the LC_ALL, LC_CTYPE and LANG environment variables.") | |
134 | |
135 (defvar mail-host-address nil | |
136 "*Name of this machine, for purposes of naming users.") | |
137 | |
138 (defvar user-mail-address nil | |
139 "*Full mailing address of this user. | |
140 This is initialized based on `mail-host-address', | |
141 after your init file is read, in case it sets `mail-host-address'.") | |
142 | |
143 (defvar auto-save-list-file-prefix "~/.saves-" | |
144 "Prefix for generating auto-save-list-file-name. | |
145 Emacs's pid and the system name will be appended to | |
146 this prefix to create a unique file name.") | |
147 | |
148 (defvar init-file-debug nil) | |
149 | |
150 (defvar init-file-had-error nil) | |
151 | |
152 (defvar init-file-loaded nil | |
153 "True after the user's init file has been loaded (or suppressed with -q). | |
154 This will be true when `after-init-hook' is run and at all times | |
155 after, and will not be true at any time before.") | |
156 | |
157 (defvar initial-frame-unmapped-p nil) | |
158 | |
159 | |
160 | |
161 (defvar command-switch-alist | |
162 (purecopy | |
163 '(("-help" . command-line-do-help) | |
164 ("-flags" . command-line-do-help) | |
165 ("-h" . command-line-do-help) | |
166 ("-?" . command-line-do-help) | |
167 ("-version". command-line-do-version) | |
168 ("-V" . command-line-do-version) | |
169 ("-funcall". command-line-do-funcall) | |
170 ("-f" . command-line-do-funcall) | |
171 ("-e" . command-line-do-funcall-1) | |
172 ("-eval" . command-line-do-eval) | |
173 ("-load" . command-line-do-load) | |
174 ("-l" . command-line-do-load) | |
175 ("-insert" . command-line-do-insert) | |
176 ("-i" . command-line-do-insert) | |
177 ("-kill" . command-line-do-kill) | |
178 ;; Options like +35 are handled specially. | |
179 ;; Window-system, site, or package-specific code might add to this. | |
180 ;; X11 handles its options by letting Xt remove args from this list. | |
181 )) | |
182 "Alist of command-line switches. | |
183 Elements look like (SWITCH-STRING . HANDLER-FUNCTION). | |
184 HANDLER-FUNCTION receives switch name as sole arg; | |
185 remaining command-line args are in the variable `command-line-args-left'.") | |
186 | |
187 ;;; default switches | |
188 ;;; Note: these doc strings are semi-magical. | |
189 | |
31 (defun command-line-do-help (arg) | 190 (defun command-line-do-help (arg) |
32 "Print this message and exit." | 191 "Print the XEmacs usage message and exit." |
33 (let ((standard-output 'external-debugging-output)) | 192 (let ((standard-output 'external-debugging-output)) |
34 (princ (emacs-version)) | 193 (princ (concat "\n" (emacs-version) "\n\n")) |
35 (princ "\n\n") | 194 (princ |
36 (cond ((fboundp 'x-create-frame) | 195 (if (featurep 'x) |
37 (princ "XEmacs") | 196 (concat "XEmacs accepts all standard X Toolkit command line options.\n" |
38 (princ " accepts all standard X Toolkit command line options.\ | 197 "In addition, the") |
39 In addition,\nthe ")) | 198 "The")) |
40 (t (princ "The "))) | 199 (princ " following options are accepted: |
41 (princ "following options are processed in the order encountered:\n\n") | 200 |
42 (let ((l command-switch-alist) | 201 -t <device> Use TTY <device> instead of the terminal for input |
43 (insert (function (lambda (&rest x) | 202 and output. This implies the -nw option. |
44 (princ " ") | 203 -nw Inhibit the use of any window-system-specific |
45 (let ((len 2)) | 204 display code: use the current tty. |
46 (while x | 205 -batch Execute noninteractively (messages go to stderr). |
47 (princ (car x)) | 206 -debug-init Enter the debugger if an error in the init file occurs. |
48 (setq len (+ len (length (car x)))) | 207 -unmapped Do not map the initial frame. |
49 (setq x (cdr x))) | 208 -no-site-file Do not load the site-specific init file (site-start.el). |
50 (if (>= len 24) | 209 -no-init-file Do not load the user-specific init file (~/.emacs). |
51 (progn (terpri) (setq len 0))) | 210 -q Same as -no-init-file. |
52 (while (< len 24) | 211 -user <user> Load user's init file instead of your own. |
53 (princ " ") | 212 -u <user> Same as -user.\n") |
54 (setq len (1+ len)))))))) | 213 (let ((l command-switch-alist) |
214 (insert (lambda (&rest x) | |
215 (princ " ") | |
216 (let ((len 2)) | |
217 (while x | |
218 (princ (car x)) | |
219 (incf len (length (car x))) | |
220 (setq x (cdr x))) | |
221 (when (>= len 24) | |
222 (terpri) (setq len 0)) | |
223 (while (< len 24) | |
224 (princ " ") | |
225 (incf len)))))) | |
55 (while l | 226 (while l |
56 (let ((name (car (car l))) | 227 (let ((name (car (car l))) |
57 (fn (cdr (car l))) | 228 (fn (cdr (car l))) |
58 doc arg cons) | 229 doc arg cons) |
59 (cond | 230 (cond |
77 (terpri)))) | 248 (terpri)))) |
78 (setq l (cdr l)))) | 249 (setq l (cdr l)))) |
79 (princ "\ | 250 (princ "\ |
80 +N <file> Start displaying <file> at line N. | 251 +N <file> Start displaying <file> at line N. |
81 | 252 |
82 These options are processed only if they appear before all other options: | |
83 | |
84 -t <device> Use TTY <device> instead of the terminal for input | |
85 and output. This implies the -nw option. | |
86 -batch Execute noninteractively (messages go to stderr). | |
87 This option must be first in the list after -t. | |
88 -nw Inhibit the use of any window-system-specific | |
89 display code: use the current tty. | |
90 -debug-init Enter the debugger if an error in the init file occurs. | |
91 -unmapped Do not map the initial frame. | |
92 -no-site-file Do not load the site-specific init file (site-start.el). | |
93 -no-init-file Do not load the user-specific init file (~/.emacs). | |
94 -q Same as -no-init-file. | |
95 -user <user> Load user's init file instead of your own. | |
96 -u <user> Same as -user.") | |
97 | |
98 (princ " | |
99 | |
100 Anything else is considered a file name, and is placed into a buffer for | 253 Anything else is considered a file name, and is placed into a buffer for |
101 editing. | 254 editing. |
102 | 255 |
103 XEmacs has an online tutorial and manuals. Type ^Ht (Control-h t) after | 256 XEmacs has an online tutorial and manuals. Type ^Ht (Control-h t) after |
104 starting XEmacs to run the tutorial. Type ^Hi to enter the manual browser.\n") | 257 starting XEmacs to run the tutorial. Type ^Hi to enter the manual browser. |
105 (kill-emacs 0) | 258 Type ^H^H^H (Control-h Control-h Control-h) to get more help options.\n") |
106 )) | 259 |
107 | 260 (kill-emacs 0))) |
108 ;;; -batch, -t, and -nw are processed by main() in emacs.c and are | |
109 ;;; never seen by lisp code. | |
110 | |
111 ;;; -version and -help are special-cased as well: they imply -batch, | |
112 ;;; but are left on the list for lisp code to process. | |
113 | |
114 | |
115 (setq top-level '(normal-top-level)) | |
116 | |
117 (defvar command-line-processed nil "t once command line has been processed") | |
118 | |
119 (defconst startup-message-timeout 1200) ; More or less disable the timeout | |
120 | |
121 (defconst inhibit-startup-message nil | |
122 "*Non-nil inhibits the initial startup message. | |
123 This is for use in your personal init file, once you are familiar | |
124 with the contents of the startup message.") | |
125 | |
126 ;; #### FSFmacs randomness | |
127 ;(defconst inhibit-startup-echo-area-message nil | |
128 ; "*Non-nil inhibits the initial startup echo area message. | |
129 ;Inhibition takes effect only if your `.emacs' file contains | |
130 ;a line of this form: | |
131 ; (setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\") | |
132 ;If your `.emacs' file is byte-compiled, use the following form instead: | |
133 ; (eval '(setq inhibit-startup-echo-area-message \"YOUR-USER-NAME\")) | |
134 ;Thus, someone else using a copy of your `.emacs' file will see | |
135 ;the startup message unless he personally acts to inhibit it.") | |
136 | |
137 (defconst inhibit-default-init nil | |
138 "*Non-nil inhibits loading the `default' library.") | |
139 | |
140 (defconst command-switch-alist nil | |
141 "Alist of command-line switches. | |
142 Elements look like (SWITCH-STRING . HANDLER-FUNCTION). | |
143 HANDLER-FUNCTION receives switch name as sole arg; | |
144 remaining command-line args are in the variable `command-line-args-left'.") | |
145 | |
146 (defvar command-line-args-left nil | |
147 "List of command-line args not yet processed.") ; bound by `command-line' | |
148 | |
149 (defvar command-line-default-directory nil | |
150 "Default directory to use for command line arguments. | |
151 This is normally copied from `default-directory' when XEmacs starts.") | |
152 | |
153 (defvar before-init-hook nil | |
154 "Functions to call after handling urgent options but before init files. | |
155 The frame system uses this to open frames to display messages while | |
156 XEmacs loads the user's initialization file.") | |
157 | |
158 (defvar after-init-hook nil | |
159 "Functions to call after loading the init file (`~/.emacs'). | |
160 The call is not protected by a condition-case, so you can set `debug-on-error' | |
161 in `.emacs', and put all the actual code on `after-init-hook'.") | |
162 | |
163 (defvar term-setup-hook nil | |
164 "Functions to be called after loading terminal-specific Lisp code. | |
165 See `run-hooks'. This variable exists for users to set, | |
166 so as to override the definitions made by the terminal-specific file. | |
167 XEmacs never sets this variable itself.") | |
168 | |
169 (defvar keyboard-type nil | |
170 "The brand of keyboard you are using. | |
171 This variable is used to define | |
172 the proper function and keypad keys for use under X. It is used in a | |
173 fashion analogous to the environment value TERM.") | |
174 | |
175 (defvar window-setup-hook nil | |
176 "Normal hook run to initialize window system display. | |
177 XEmacs runs this hook after processing the command line arguments and loading | |
178 the user's init file.") | |
179 | |
180 (defconst initial-major-mode 'lisp-interaction-mode | |
181 "Major mode command symbol to use for the initial *scratch* buffer.") | |
182 | |
183 (defvar init-file-user nil | |
184 "Identity of user whose `.emacs' file is or was read. | |
185 The value is nil if no init file is being used; otherwise, it may be either | |
186 the null string, meaning that the init file was taken from the user that | |
187 originally logged in, or it may be a string containing a user's name. | |
188 | |
189 In either of the latter cases, `(concat \"~\" init-file-user \"/\")' | |
190 evaluates to the name of the directory where the `.emacs' file was | |
191 looked for. | |
192 | |
193 Setting `init-file-user' does not prevent Emacs from loading | |
194 `site-start.el'. The only way to do that is to use `--no-site-file'.") | |
195 | |
196 ;; #### called `site-run-file' in FSFmacs | |
197 | |
198 (defvar site-start-file (purecopy "site-start") | |
199 "File containing site-wide run-time initializations. | |
200 This file is loaded at run-time before `~/.emacs'. It contains inits | |
201 that need to be in place for the entire site, but which, due to their | |
202 higher incidence of change, don't make sense to load into XEmacs' | |
203 dumped image. Thus, the run-time load order is: 1. file described in | |
204 this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'. | |
205 | |
206 Don't use the `site-start.el' file for things some users may not like. | |
207 Put them in `default.el' instead, so that users can more easily | |
208 override them. Users can prevent loading `default.el' with the `-q' | |
209 option or by setting `inhibit-default-init' in their own init files, | |
210 but inhibiting `site-start.el' requires `--no-site-file', which | |
211 is less convenient.") | |
212 | |
213 ;(defconst iso-8859-1-locale-regexp "8859[-_]?1" | |
214 ; "Regexp that specifies when to enable the ISO 8859-1 character set. | |
215 ;We do that if this regexp matches the locale name | |
216 ;specified by the LC_ALL, LC_CTYPE and LANG environment variables.") | |
217 | |
218 (defvar mail-host-address nil | |
219 "*Name of this machine, for purposes of naming users.") | |
220 | |
221 (defvar user-mail-address nil | |
222 "*Full mailing address of this user. | |
223 This is initialized based on `mail-host-address', | |
224 after your init file is read, in case it sets `mail-host-address'.") | |
225 | |
226 (defvar auto-save-list-file-prefix "~/.saves-" | |
227 "Prefix for generating auto-save-list-file-name. | |
228 Emacs's pid and the system name will be appended to | |
229 this prefix to create a unique file name.") | |
230 | |
231 (defvar init-file-debug nil) | |
232 | |
233 (defvar init-file-had-error nil) | |
234 | |
235 (defvar init-file-loaded nil | |
236 "True after the user's init file has been loaded (or suppressed with -q). | |
237 This will be true when `after-init-hook' is run and at all times | |
238 after, and will not be true at any time before.") | |
239 | |
240 (defvar initial-frame-unmapped-p nil) | |
241 | |
242 | |
243 ;;; default switches | |
244 ;;; Note: these doc strings are semi-magical. | |
245 | 261 |
246 (defun command-line-do-funcall (arg) | 262 (defun command-line-do-funcall (arg) |
247 "Invoke the named lisp function with no arguments. | 263 "Invoke the named lisp function with no arguments. |
248 <function>" | 264 <function>" |
249 (let ((fn (intern (car command-line-args-left)))) | 265 (funcall (intern (pop command-line-args-left)))) |
250 (setq command-line-args-left (cdr command-line-args-left)) | |
251 (funcall fn))) | |
252 (fset 'command-line-do-funcall-1 'command-line-do-funcall) | 266 (fset 'command-line-do-funcall-1 'command-line-do-funcall) |
253 (put 'command-line-do-funcall-1 'undocumented t) | 267 (put 'command-line-do-funcall-1 'undocumented t) |
254 | 268 |
255 (defun command-line-do-eval (arg) | 269 (defun command-line-do-eval (arg) |
256 "Evaluate the lisp form. Quote it carefully. | 270 "Evaluate the lisp form. Quote it carefully. |
257 <form>" | 271 <form>" |
258 (let ((form (car command-line-args-left))) | 272 (eval (read (pop command-line-args-left)))) |
259 (setq command-line-args-left (cdr command-line-args-left)) | |
260 (eval (read form)))) | |
261 | 273 |
262 (defun command-line-do-load (arg) | 274 (defun command-line-do-load (arg) |
263 "Load the named file of Lisp code into XEmacs. | 275 "Load the named file of Lisp code into XEmacs. |
264 <file>" | 276 <file>" |
265 (let ((file (car command-line-args-left))) | 277 (let ((file (pop command-line-args-left))) |
266 ;; Take file from default dir if it exists there; | 278 ;; Take file from default dir if it exists there; |
267 ;; otherwise let `load' search for it. | 279 ;; otherwise let `load' search for it. |
268 (if (file-exists-p (expand-file-name file)) | 280 (if (file-exists-p (expand-file-name file)) |
269 (setq file (expand-file-name file))) | 281 (setq file (expand-file-name file))) |
270 (load file nil t)) | 282 (load file nil t))) |
271 (setq command-line-args-left (cdr command-line-args-left))) | |
272 | 283 |
273 (defun command-line-do-insert (arg) | 284 (defun command-line-do-insert (arg) |
274 "Insert file into the current buffer. | 285 "Insert file into the current buffer. |
275 <file>" | 286 <file>" |
276 (insert-file-contents (car command-line-args-left)) | 287 (insert-file-contents (pop command-line-args-left))) |
277 (setq command-line-args-left (cdr command-line-args-left))) | |
278 | 288 |
279 (defun command-line-do-kill (arg) | 289 (defun command-line-do-kill (arg) |
280 "Exit XEmacs." | 290 "Exit XEmacs." |
281 (kill-emacs t)) | 291 (kill-emacs t)) |
282 | 292 |
283 (defun command-line-do-version (arg) | 293 (defun command-line-do-version (arg) |
284 "Print version info and exit." | 294 "Print version info and exit." |
285 (princ (concat (emacs-version) "\n") 'external-debugging-output) | 295 (princ (concat (emacs-version) "\n")) |
286 (kill-emacs 0)) | 296 (kill-emacs 0)) |
287 | 297 |
288 (setq command-switch-alist | |
289 (purecopy | |
290 '(("-help" . command-line-do-help) | |
291 ("-version" . command-line-do-version) | |
292 ("-funcall" . command-line-do-funcall) | |
293 ("-f" . command-line-do-funcall) | |
294 ("-e" . command-line-do-funcall-1) | |
295 ("-eval" . command-line-do-eval) | |
296 ("-load" . command-line-do-load) | |
297 ("-l" . command-line-do-load) | |
298 ("-insert" . command-line-do-insert) | |
299 ("-i" . command-line-do-insert) | |
300 ("-kill" . command-line-do-kill) | |
301 ;; Options like +35 are handled specially. | |
302 ;; Window-system, site, or package-specific code might add to this. | |
303 ;; X11 handles its options by letting Xt remove args from this list. | |
304 ))) | |
305 | 298 |
306 ;;; Processing the command line and loading various init files | 299 ;;; Processing the command line and loading various init files |
307 | 300 |
308 (defun early-error-handler (&rest debugger-args) | 301 (defun early-error-handler (&rest debugger-args) |
309 "You should probably not be using this." | 302 "You should probably not be using this." |
332 (if (memq (car-safe error) '(void-function void-variable)) | 325 (if (memq (car-safe error) '(void-function void-variable)) |
333 (princ " | 326 (princ " |
334 This probably means that XEmacs is picking up an old version of | 327 This probably means that XEmacs is picking up an old version of |
335 the lisp library, or that some .elc files are not up-to-date.\n" | 328 the lisp library, or that some .elc files are not up-to-date.\n" |
336 stream))) | 329 stream))) |
337 (if (not suppress-early-error-handler-backtrace) | 330 (when (not suppress-early-error-handler-backtrace) |
338 (let ((print-length 1000) | 331 (let ((print-length 1000) |
339 (print-level 1000) | 332 (print-level 1000) |
340 (print-escape-newlines t) | 333 (print-escape-newlines t) |
341 (print-readably nil)) | 334 (print-readably nil)) |
342 (if (getenv "EMACSLOADPATH") | 335 (when (getenv "EMACSLOADPATH") |
343 (princ (format "\n$EMACSLOADPATH is %s" (getenv "EMACSLOADPATH")) | 336 (princ (format "\n$EMACSLOADPATH is %s" (getenv "EMACSLOADPATH")) |
344 stream)) | 337 stream)) |
345 (princ (format "\nexec-directory is %S" exec-directory) stream) | 338 (princ (format "\nexec-directory is %S" exec-directory) stream) |
346 (princ (format "\ndata-directory is %S" data-directory) stream) | 339 (princ (format "\ndata-directory is %S" data-directory) stream) |
347 (princ (format "\ndoc-directory is %S" doc-directory) stream) | 340 (princ (format "\ndoc-directory is %S" doc-directory) stream) |
348 (princ (format "\nload-path is %S" load-path) stream) | 341 (princ (format "\nload-path is %S" load-path) stream) |
349 (princ "\n\n" stream))) | 342 (princ "\n\n" stream))) |
350 (if (not suppress-early-error-handler-backtrace) | 343 (when (not suppress-early-error-handler-backtrace) |
351 (backtrace stream t))) | 344 (backtrace stream t))) |
352 (kill-emacs -1)) | 345 (kill-emacs -1)) |
353 | 346 |
354 (defun normal-top-level () | 347 (defun normal-top-level () |
355 (if command-line-processed | 348 (if command-line-processed |
356 (message "Back to top level.") | 349 (message "Back to top level.") |
357 (setq command-line-processed t) | 350 (setq command-line-processed t) |
358 ;; Canonicalize HOME (PWD is canonicalized by init_buffer in buffer.c) | 351 ;; Canonicalize HOME (PWD is canonicalized by init_buffer in buffer.c) |
359 (if (not (eq system-type 'vax-vms)) | 352 (unless (eq system-type 'vax-vms) |
360 (let ((value (getenv "HOME"))) | 353 (let ((value (getenv "HOME"))) |
361 (if (and value | 354 (if (and value |
362 (< (length value) (length default-directory)) | 355 (< (length value) (length default-directory)) |
363 (equal (file-attributes default-directory) | 356 (equal (file-attributes default-directory) |
364 (file-attributes value))) | 357 (file-attributes value))) |
365 (setq default-directory (file-name-as-directory value))))) | 358 (setq default-directory (file-name-as-directory value))))) |
366 (setq default-directory (abbreviate-file-name default-directory)) | 359 (setq default-directory (abbreviate-file-name default-directory)) |
367 (initialize-xemacs-paths) | 360 (initialize-xemacs-paths) |
368 (unwind-protect | 361 (unwind-protect |
369 (command-line) | 362 (command-line) |
370 ;; Do this again, in case .emacs defined more abbreviations. | 363 ;; Do this again, in case .emacs defined more abbreviations. |
379 (system-name)))) | 372 (system-name)))) |
380 (run-hooks 'emacs-startup-hook) | 373 (run-hooks 'emacs-startup-hook) |
381 (and term-setup-hook | 374 (and term-setup-hook |
382 (run-hooks 'term-setup-hook)) | 375 (run-hooks 'term-setup-hook)) |
383 (setq term-setup-hook nil) | 376 (setq term-setup-hook nil) |
384 ; ;; Modify the initial frame based on what .emacs puts into | 377 ;; ;; Modify the initial frame based on what .emacs puts into |
385 ; ;; ...-frame-alist. | 378 ;; ;; ...-frame-alist. |
386 (frame-notice-user-settings) | 379 (frame-notice-user-settings) |
387 ; ;;####FSFmacs junk | 380 ;; ;;####FSFmacs junk |
388 ; ;; Now we know the user's default font, so add it to the menu. | 381 ;; ;; Now we know the user's default font, so add it to the menu. |
389 ; (if (fboundp 'font-menu-add-default) | 382 ;; (if (fboundp 'font-menu-add-default) |
390 ; (font-menu-add-default)) | 383 ;; (font-menu-add-default)) |
391 (and window-setup-hook | 384 (when window-setup-hook |
392 (run-hooks 'window-setup-hook)) | 385 (run-hooks 'window-setup-hook)) |
393 (setq window-setup-hook nil)) | 386 (setq window-setup-hook nil)) |
394 ;;####FSFmacs junk | 387 ;;####FSFmacs junk |
395 ; (or menubar-bindings-done | 388 ;; (or menubar-bindings-done |
396 ; (precompute-menubar-bindings)) | 389 ;; (precompute-menubar-bindings)) |
397 )) | 390 )) |
398 | 391 |
399 ;;####FSFmacs junk | 392 ;;####FSFmacs junk |
400 ;;; Precompute the keyboard equivalents in the menu bar items. | 393 ;;; Precompute the keyboard equivalents in the menu bar items. |
401 ;(defun precompute-menubar-bindings () | 394 ;;(defun precompute-menubar-bindings () |
402 ; (if (eq window-system 'x) | 395 ;; (if (eq window-system 'x) |
403 ; (let ((submap (lookup-key global-map [menu-bar]))) | 396 ;; (let ((submap (lookup-key global-map [menu-bar]))) |
404 ; (while submap | 397 ;; (while submap |
405 ; (and (consp (car submap)) | 398 ;; (and (consp (car submap)) |
406 ; (symbolp (car (car submap))) | 399 ;; (symbolp (car (car submap))) |
407 ; (stringp (car-safe (cdr (car submap)))) | 400 ;; (stringp (car-safe (cdr (car submap)))) |
408 ; (keymapp (cdr (cdr (car submap)))) | 401 ;; (keymapp (cdr (cdr (car submap)))) |
409 ; (x-popup-menu nil (cdr (cdr (car submap))))) | 402 ;; (x-popup-menu nil (cdr (cdr (car submap))))) |
410 ; (setq submap (cdr submap)))))) | 403 ;; (setq submap (cdr submap)))))) |
411 | 404 |
412 (defun command-line-early () | 405 (defun command-line-early (args) |
413 ;; This processes those switches which need to be processed before | 406 ;; This processes those switches which need to be processed before |
414 ;; starting up the window system. | 407 ;; starting up the window system. |
415 | 408 |
416 (setq command-line-default-directory default-directory) | 409 (setq command-line-default-directory default-directory) |
417 | 410 |
426 (setq version-control nil)) | 419 (setq version-control nil)) |
427 ((or (string= vc "never") | 420 ((or (string= vc "never") |
428 (string= vc "simple")) | 421 (string= vc "simple")) |
429 (setq version-control 'never)))) | 422 (setq version-control 'never)))) |
430 | 423 |
431 ;;####FSFmacs | 424 ;;####FSFmacs |
432 ; (if (let ((ctype | 425 ;; (if (let ((ctype |
433 ; ;; Use the first of these three envvars that has a nonempty value. | 426 ;; ;; Use the first of these three envvars that has a nonempty value. |
434 ; (or (let ((string (getenv "LC_ALL"))) | 427 ;; (or (let ((string (getenv "LC_ALL"))) |
435 ; (and (not (equal string "")) string)) | 428 ;; (and (not (equal string "")) string)) |
436 ; (let ((string (getenv "LC_CTYPE"))) | 429 ;; (let ((string (getenv "LC_CTYPE"))) |
437 ; (and (not (equal string "")) string)) | 430 ;; (and (not (equal string "")) string)) |
438 ; (let ((string (getenv "LANG"))) | 431 ;; (let ((string (getenv "LANG"))) |
439 ; (and (not (equal string "")) string))))) | 432 ;; (and (not (equal string "")) string))))) |
440 ; (and ctype | 433 ;; (and ctype |
441 ; (string-match iso-8859-1-locale-regexp ctype))) | 434 ;; (string-match iso-8859-1-locale-regexp ctype))) |
442 ; (progn | 435 ;; (progn |
443 ; (standard-display-european t) | 436 ;; (standard-display-european t) |
444 ; (require 'iso-syntax))) | 437 ;; (require 'iso-syntax))) |
445 | 438 |
446 (let ((done nil)) | 439 ;; Figure out which user's init file to load, |
447 ;; Figure out which user's init file to load, | 440 ;; either from the environment or from the options. |
448 ;; either from the environment or from the options. | 441 (setq init-file-user (if (noninteractive) nil (user-login-name))) |
449 (setq init-file-user (if (noninteractive) nil (user-login-name))) | 442 ;; If user has not done su, use current $HOME to find .emacs. |
450 ;; If user has not done su, use current $HOME to find .emacs. | 443 (and init-file-user (string= init-file-user (user-real-login-name)) |
451 (and init-file-user (string= init-file-user (user-real-login-name)) | 444 (setq init-file-user "")) |
452 (setq init-file-user "")) | 445 |
453 | 446 ;; Allow (at least) these arguments anywhere in the command line |
454 (while (and (not done) command-line-args-left) | 447 (let ((new-args nil) |
455 (let ((argi (car command-line-args-left))) | 448 (arg nil)) |
456 (cond ((or (string-equal argi "-q") | 449 (while args |
457 (string-equal argi "-no-init-file")) | 450 (setq arg (pop args)) |
458 (setq init-file-user nil | 451 (cond |
459 command-line-args-left (cdr command-line-args-left))) | 452 ((or (string= arg "-q") |
460 ((string-equal argi "-no-site-file") | 453 (string= arg "-no-init-file")) |
461 (setq site-start-file nil | 454 (setq init-file-user nil)) |
462 command-line-args-left (cdr command-line-args-left))) | 455 ((string= arg "-no-site-file") |
463 ((or (string-equal argi "-u") | 456 (setq site-start-file nil)) |
464 (string-equal argi "-user")) | 457 ((or (string= arg "-u") |
465 (setq command-line-args-left (cdr command-line-args-left) | 458 (string= arg "-user")) |
466 init-file-user (car command-line-args-left) | 459 (setq init-file-user (pop args))) |
467 command-line-args-left (cdr command-line-args-left))) | 460 ((string= arg "-debug-init") |
468 ((string-equal argi "-debug-init") | 461 (setq init-file-debug t)) |
469 (setq init-file-debug t | 462 ((string= arg "-unmapped") |
470 command-line-args-left (cdr command-line-args-left))) | 463 (setq initial-frame-unmapped-p t)) |
471 ((string-equal argi "-unmapped") | 464 ((or (string= arg "--") (string= arg "-")) |
472 (setq initial-frame-unmapped-p t | 465 (while args |
473 command-line-args-left (cdr command-line-args-left))) | 466 (push (pop args) new-args))) |
474 (t (setq done t))))))) | 467 (t (push arg new-args)))) |
475 | 468 |
469 (nreverse new-args))) | |
476 | 470 |
477 (defun command-line () | 471 (defun command-line () |
478 (let ((command-line-args-left (cdr command-line-args))) | 472 (let ((command-line-args-left (cdr command-line-args))) |
479 | 473 |
480 (let ((debugger 'early-error-handler) | 474 (let ((debugger 'early-error-handler) |
484 ;; Process magic command-line switches like -q and -u. Do this | 478 ;; Process magic command-line switches like -q and -u. Do this |
485 ;; before creating the first frame because some of these switches | 479 ;; before creating the first frame because some of these switches |
486 ;; may affect that. I think it's ok to do this before establishing | 480 ;; may affect that. I think it's ok to do this before establishing |
487 ;; the X connection, and maybe someday things like -nw can be | 481 ;; the X connection, and maybe someday things like -nw can be |
488 ;; handled here instead of down in C. | 482 ;; handled here instead of down in C. |
489 (command-line-early) | 483 (setq command-line-args-left (command-line-early command-line-args-left)) |
490 | 484 |
491 ;; Setup the toolbar icon directory | 485 ;; Setup the toolbar icon directory |
492 (if (featurep 'toolbar) | 486 (when (featurep 'toolbar) |
493 (init-toolbar-location)) | 487 (init-toolbar-location)) |
494 | 488 |
495 ;; Initialize the built-in glyphs and the default specifier | 489 ;; Initialize the built-in glyphs and default specifier lists |
496 ;; lists | 490 (when (not noninteractive) |
497 (if (not noninteractive) | 491 (init-glyphs)) |
498 (init-glyphs)) | |
499 | 492 |
500 ;; Run the window system's init function. tty is considered to be | 493 ;; Run the window system's init function. tty is considered to be |
501 ;; a type of window system for this purpose. This creates the | 494 ;; a type of window system for this purpose. This creates the |
502 ;; initial (non stdio) device. | 495 ;; initial (non stdio) device. |
503 (if (and initial-window-system (not noninteractive)) | 496 (when (and initial-window-system (not noninteractive)) |
504 (funcall (intern (concat "init-" | 497 (funcall (intern (concat "init-" |
505 (symbol-name initial-window-system) | 498 (symbol-name initial-window-system) |
506 "-win")))) | 499 "-win")))) |
507 | 500 |
508 ;; When not in batch mode, this creates the first visible frame, | 501 ;; When not in batch mode, this creates the first visible frame, |
509 ;; and deletes the stdio device. | 502 ;; and deletes the stdio device. |
510 (frame-initialize)) | 503 (frame-initialize)) |
511 | 504 |
517 | 510 |
518 ;;; Load init files. | 511 ;;; Load init files. |
519 (load-init-file) | 512 (load-init-file) |
520 | 513 |
521 ;; If *scratch* exists and init file didn't change its mode, initialize it. | 514 ;; If *scratch* exists and init file didn't change its mode, initialize it. |
522 (if (get-buffer "*scratch*") | 515 (when (get-buffer "*scratch*") |
523 (save-excursion | 516 (save-excursion |
524 (set-buffer "*scratch*") | 517 (set-buffer "*scratch*") |
525 (if (eq major-mode 'fundamental-mode) | 518 (when (eq major-mode 'fundamental-mode) |
526 (funcall initial-major-mode)))) | 519 (funcall initial-major-mode)))) |
527 | 520 |
528 ;; Load library for our terminal type. | 521 ;; Load library for our terminal type. |
529 ;; User init file can set term-file-prefix to nil to prevent this. | 522 ;; User init file can set term-file-prefix to nil to prevent this. |
530 ;; Note that for any TTY's opened subsequently, the TTY init | 523 ;; Note that for any TTY's opened subsequently, the TTY init |
531 ;; code will run this. | 524 ;; code will run this. |
532 (if (and (eq 'tty (console-type)) | 525 (when (and (eq 'tty (console-type)) |
533 (not (noninteractive))) | 526 (not (noninteractive))) |
534 (load-terminal-library)) | 527 (load-terminal-library)) |
535 | 528 |
536 ;; Process the remaining args. | 529 ;; Process the remaining args. |
537 (command-line-1) | 530 (command-line-1) |
538 | 531 |
539 ;; it was turned on by default so that the warnings don't get displayed | 532 ;; it was turned on by default so that the warnings don't get displayed |
540 ;; until after the splash screen. | 533 ;; until after the splash screen. |
541 (setq inhibit-warning-display nil) | 534 (setq inhibit-warning-display nil) |
542 ;; If -batch, terminate after processing the command options. | 535 ;; If -batch, terminate after processing the command options. |
543 (if (noninteractive) (kill-emacs t)))) | 536 (when (noninteractive) (kill-emacs t)))) |
544 | 537 |
545 (defun load-terminal-library () | 538 (defun load-terminal-library () |
546 (and term-file-prefix | 539 (when term-file-prefix |
547 (let ((term (getenv "TERM")) | 540 (let ((term (getenv "TERM")) |
548 hyphend) | 541 hyphend) |
549 (while (and term | 542 (while (and term |
550 (not (load (concat term-file-prefix term) t t))) | 543 (not (load (concat term-file-prefix term) t t))) |
551 ;; Strip off last hyphen and what follows, then try again | 544 ;; Strip off last hyphen and what follows, then try again |
552 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) | 545 (if (setq hyphend (string-match "[-_][^-_]+\\'" term)) |
553 (setq term (substring term 0 hyphend)) | 546 (setq term (substring term 0 hyphend)) |
554 (setq term nil)))))) | 547 (setq term nil)))))) |
555 | 548 |
556 (defun load-user-init-file (init-file-user) | 549 (defun load-user-init-file (init-file-user) |
557 ;; This function actually reads the init files. | 550 ;; This function actually reads the init files. |
558 (if init-file-user | 551 (when init-file-user |
559 (progn | 552 (setq user-init-file |
560 (setq user-init-file | 553 (cond |
561 (cond | 554 ((eq system-type 'ms-dos) |
562 ((eq system-type 'ms-dos) | 555 (concat "~" init-file-user "/_emacs")) |
563 (concat "~" init-file-user "/_emacs")) | 556 ((eq system-type 'vax-vms) |
564 ((eq system-type 'vax-vms) | 557 "sys$login:.emacs") |
565 "sys$login:.emacs") | 558 (t |
566 (t | 559 (concat "~" init-file-user "/.emacs")))) |
567 (concat "~" init-file-user "/.emacs")))) | 560 (load user-init-file t t t) |
568 (load user-init-file t t t) | 561 (unless inhibit-default-init |
569 (or inhibit-default-init | 562 (let ((inhibit-startup-message nil)) |
570 (let ((inhibit-startup-message nil)) | 563 ;; Users are supposed to be told their rights. |
571 ;; Users are supposed to be told their rights. | 564 ;; (Plus how to get help and how to undo.) |
572 ;; (Plus how to get help and how to undo.) | 565 ;; Don't you dare turn this off for anyone except yourself. |
573 ;; Don't you dare turn this off for anyone | 566 (load "default" t t))))) |
574 ;; except yourself. | |
575 (load "default" t t)))))) | |
576 | 567 |
577 ;;; Load user's init file and default ones. | 568 ;;; Load user's init file and default ones. |
578 (defun load-init-file () | 569 (defun load-init-file () |
579 (run-hooks 'before-init-hook) | 570 (run-hooks 'before-init-hook) |
580 | 571 |
581 ;; Run the site-start library if it exists. The point of this file is | 572 ;; Run the site-start library if it exists. The point of this file is |
582 ;; that it is run before .emacs. There is no point in doing this after | 573 ;; that it is run before .emacs. There is no point in doing this after |
583 ;; .emacs; that is useless. | 574 ;; .emacs; that is useless. |
584 (if site-start-file | 575 (when site-start-file |
585 (load site-start-file t t)) | 576 (load site-start-file t t)) |
586 | 577 |
587 ;; Sites should not disable this. Only individuals should disable | 578 ;; Sites should not disable this. Only individuals should disable |
588 ;; the startup message. | 579 ;; the startup message. |
589 (setq inhibit-startup-message nil) | 580 (setq inhibit-startup-message nil) |
590 | 581 |
607 ;; If we can tell that the init file altered debug-on-error, | 598 ;; If we can tell that the init file altered debug-on-error, |
608 ;; arrange to preserve the value that it set up. | 599 ;; arrange to preserve the value that it set up. |
609 (or (eq debug-on-error debug-on-error-initial) | 600 (or (eq debug-on-error debug-on-error-initial) |
610 (setq debug-on-error-should-be-set t | 601 (setq debug-on-error-should-be-set t |
611 debug-on-error-from-init-file debug-on-error))) | 602 debug-on-error-from-init-file debug-on-error))) |
612 (if debug-on-error-should-be-set | 603 (when debug-on-error-should-be-set |
613 (setq debug-on-error debug-on-error-from-init-file))) | 604 (setq debug-on-error debug-on-error-from-init-file))) |
614 | 605 |
615 (setq init-file-loaded t) | 606 (setq init-file-loaded t) |
616 | 607 |
617 ;; Do this here in case the init file sets mail-host-address. | 608 ;; Do this here in case the init file sets mail-host-address. |
618 ;; Don't do this here unless noninteractive, it is frequently wrong. -sb | |
619 (or user-mail-address | 609 (or user-mail-address |
620 (setq user-mail-address (concat (user-login-name) "@" | 610 (setq user-mail-address (concat (user-login-name) "@" |
621 (or mail-host-address | 611 (or mail-host-address |
622 (system-name))))) | 612 (system-name))))) |
623 | 613 |
631 a new format, when variables have changed, etc." | 621 a new format, when variables have changed, etc." |
632 (load filename)) | 622 (load filename)) |
633 | 623 |
634 (defun command-line-1 () | 624 (defun command-line-1 () |
635 (if (null command-line-args-left) | 625 (if (null command-line-args-left) |
636 (cond ((and (not inhibit-startup-message) (not (noninteractive)) | 626 (unless (or inhibit-startup-message |
627 noninteractive | |
637 ;; Don't clobber a non-scratch buffer if init file | 628 ;; Don't clobber a non-scratch buffer if init file |
638 ;; has selected it. | 629 ;; has selected it. |
639 (string= (buffer-name) "*scratch*") | 630 (not (string= (buffer-name) "*scratch*")) |
640 (not (input-pending-p))) | 631 (input-pending-p)) |
641 | 632 |
642 ;; If there are no switches to process, run the term-setup-hook | 633 ;; If there are no switches to process, run the term-setup-hook |
643 ;; before displaying the copyright notice; there may be some need | 634 ;; before displaying the copyright notice; there may be some need |
644 ;; to do it before doing any output. If we're not going to | 635 ;; to do it before doing any output. If we're not going to |
645 ;; display a copyright notice (because other options are present) | 636 ;; display a copyright notice (because other options are present) |
646 ;; then this is run after those options are processed. | 637 ;; then this is run after those options are processed. |
647 (run-hooks 'term-setup-hook) | 638 (run-hooks 'term-setup-hook) |
648 ;; Don't let the hook be run twice. | 639 ;; Don't let the hook be run twice. |
649 (setq term-setup-hook nil) | 640 (setq term-setup-hook nil) |
650 | 641 |
651 (let ((timeout nil)) | 642 (let ((timeout nil)) |
652 (unwind-protect | 643 (unwind-protect |
653 ;; Guts of with-timeout | 644 ;; Guts of with-timeout |
654 (catch 'timeout | 645 (catch 'timeout |
655 (setq timeout (add-timeout startup-message-timeout | 646 (setq timeout (add-timeout startup-message-timeout |
656 #'(lambda (ignore) | 647 (lambda (ignore) |
657 (condition-case nil | 648 (condition-case nil |
658 (throw 'timeout t) | 649 (throw 'timeout t) |
659 (error nil))) | 650 (error nil))) |
660 nil)) | 651 nil)) |
661 (startup-splash-frame) | 652 (startup-splash-frame) |
662 (or nil ;; (pos-visible-in-window-p (point-min)) | 653 (or nil;; (pos-visible-in-window-p (point-min)) |
663 (goto-char (point-min))) | 654 (goto-char (point-min))) |
664 (sit-for 0) | 655 (sit-for 0) |
665 (setq unread-command-event (next-command-event))) | 656 (setq unread-command-event (next-command-event))) |
666 (if timeout (disable-timeout timeout)) | 657 (when timeout (disable-timeout timeout)) |
667 (save-excursion | 658 (save-excursion |
668 ;; In case the XEmacs server has already selected | 659 ;; In case the XEmacs server has already selected |
669 ;; another buffer, erase the one our message is in. | 660 ;; another buffer, erase the one our message is in. |
670 (progn | 661 (set-buffer (get-buffer "*scratch*")) |
671 (set-buffer (get-buffer "*scratch*")) | 662 (erase-buffer) |
672 (erase-buffer) | 663 (set-buffer-modified-p nil))))) |
673 (set-buffer-modified-p nil))))))) | 664 |
665 ;; Command-line-options exist | |
674 (let ((dir command-line-default-directory) | 666 (let ((dir command-line-default-directory) |
675 (file-count 0) | 667 (file-count 0) |
676 first-file-buffer | 668 (line nil) |
677 (line nil)) | 669 (end-of-options nil) |
670 first-file-buffer file-p arg tem) | |
678 (while command-line-args-left | 671 (while command-line-args-left |
679 (let ((argi (car command-line-args-left)) | 672 (setq arg (pop command-line-args-left)) |
680 tem) | 673 (cond |
681 (setq command-line-args-left (cdr command-line-args-left)) | 674 (end-of-options |
682 (or (cond (line | 675 (setq file-p t)) |
683 nil) | 676 ((setq tem (when (eq (aref arg 0) ?-) |
684 ((setq tem (or (assoc argi command-switch-alist) | 677 (or (assoc arg command-switch-alist) |
685 (and (string-match "\\`--" argi) | 678 (assoc (substring arg 1) |
686 (assoc (substring argi 1) | 679 command-switch-alist)))) |
687 command-switch-alist)))) | 680 (funcall (cdr tem) arg)) |
688 (funcall (cdr tem) argi) | 681 ((string-match "\\`\\+[0-9]+\\'" arg) |
689 t) | 682 (setq line (string-to-int arg))) |
690 ((string-match "\\`\\+[0-9]+\\'" argi) | 683 ;; "- file" means don't treat "file" as a switch |
691 (setq line (string-to-int argi)) | 684 ;; ("+0 file" has the same effect; "-" added |
692 t) | 685 ;; for unixoidiality). |
693 ((or (equal argi "-") (equal argi "--")) | 686 ;; This is worthless; the `unixoid' way is "./file". -jwz |
694 ;; "- file" means don't treat "file" as a switch | 687 ((or (string= arg "-") (string= arg "--")) |
695 ;; ("+0 file" has the same effect; "-" added | 688 (setq end-of-options t)) |
696 ;; for unixoidiality). | 689 (t |
697 ;; This is worthless; the `unixoid' way is "./file". -jwz | 690 (setq file-p t))) |
698 (setq line 0)) | 691 |
699 (t | 692 (when file-p |
700 nil)) | 693 (setq file-p nil) |
701 (progn | 694 (incf file-count) |
702 (setq file-count (1+ file-count)) | 695 (setq arg (expand-file-name arg dir)) |
703 (setq argi (expand-file-name argi dir)) | 696 (cond |
704 (if (= file-count 1) | 697 ((= file-count 1) (setq first-file-buffer |
705 (setq first-file-buffer (progn (find-file argi) | 698 (progn (find-file arg) (current-buffer)))) |
706 (current-buffer))) | 699 (noninteractive (find-file arg)) |
707 (if noninteractive | 700 (t (find-file-other-window arg))) |
708 (find-file argi) | 701 (when line |
709 (find-file-other-window argi))) | 702 (goto-line line) |
710 (or (null line) | 703 (setq line nil)))) |
711 (zerop line) | |
712 (goto-line line)) | |
713 (setq line 0))))) | |
714 ;; If 3 or more files visited, and not all visible, | 704 ;; If 3 or more files visited, and not all visible, |
715 ;; show user what they all are. | 705 ;; show user what they all are. |
716 (if (and (not noninteractive) | 706 (when (and (not noninteractive) |
717 (> file-count 2)) | 707 (> file-count 2) |
718 (or (get-buffer-window first-file-buffer) | 708 (not (get-buffer-window first-file-buffer))) |
719 (progn (other-window 1) | 709 (other-window 1) |
720 (buffer-menu nil))))))) | 710 (buffer-menu nil))))) |
721 | 711 |
722 (defvar startup-presentation-hack-keymap | 712 (defvar startup-presentation-hack-keymap |
723 (let ((map (make-sparse-keymap))) | 713 (let ((map (make-sparse-keymap))) |
724 (set-keymap-name map 'startup-presentation-hack-keymap) | 714 (set-keymap-name map 'startup-presentation-hack-keymap) |
725 (define-key map '[button1] 'startup-presentation-hack) | 715 (define-key map '[button1] 'startup-presentation-hack) |
735 (event-buffer e) | 725 (event-buffer e) |
736 'startup-presentation-hack)) | 726 'startup-presentation-hack)) |
737 (setq e (extent-property e 'startup-presentation-hack)) | 727 (setq e (extent-property e 'startup-presentation-hack)) |
738 (if (consp e) | 728 (if (consp e) |
739 (apply (car e) (cdr e)) | 729 (apply (car e) (cdr e)) |
740 (progn | 730 (while (keymapp (indirect-function e)) |
741 (while (keymapp (indirect-function e)) | 731 (let ((map e) |
742 (let ((map e) | 732 (overriding-local-map (indirect-function e))) |
743 (overriding-local-map (indirect-function e))) | 733 (setq e (read-key-sequence |
744 (setq e (read-key-sequence | 734 (let ((p (keymap-prompt map t))) |
745 (let ((p (keymap-prompt map t))) | 735 (cond ((symbolp map) |
746 (cond ((symbolp map) | 736 (if p |
747 (if p | 737 (format "%s %s " map p) |
748 (format "%s %s " map p) | 738 (format "%s " map))) |
749 (format "%s " map p))) | 739 (p) |
750 (p) | 740 (t |
751 (t | 741 (prin1-to-string map)))))) |
752 (prin1-to-string map)))))) | 742 (if (and (button-release-event-p (elt e 0)) |
753 (if (and (button-release-event-p (elt e 0)) | 743 (null (key-binding e))) |
754 (null (key-binding e))) | 744 (setq e map) ; try again |
755 (setq e map) ; try again | 745 (setq e (key-binding e))))) |
756 (setq e (key-binding e))))) | 746 (call-interactively e))))) |
757 (call-interactively e)))))) | |
758 | 747 |
759 (defun startup-presentation-hack-help (e) | 748 (defun startup-presentation-hack-help (e) |
760 (setq e (extent-property e 'startup-presentation-hack)) | 749 (setq e (extent-property e 'startup-presentation-hack)) |
761 (if (consp e) | 750 (if (consp e) |
762 (format "Evaluate %S" e) | 751 (format "Evaluate %S" e) |
763 (symbol-name e))) | 752 (symbol-name e))) |
764 | 753 |
765 (defun splash-frame-present-hack (e v) | 754 (defun splash-frame-present-hack (e v) |
766 ; (set-extent-property e 'mouse-face 'highlight) | 755 ;; (set-extent-property e 'mouse-face 'highlight) |
767 ; (set-extent-property e 'keymap | 756 ;; (set-extent-property e 'keymap |
768 ; startup-presentation-hack-keymap) | 757 ;; startup-presentation-hack-keymap) |
769 ; (set-extent-property e 'startup-presentation-hack v) | 758 ;; (set-extent-property e 'startup-presentation-hack v) |
770 ; (set-extent-property e 'help-echo | 759 ;; (set-extent-property e 'help-echo |
771 ; 'startup-presentation-hack-help)) | 760 ;; 'startup-presentation-hack-help)) |
772 ) | 761 ) |
773 | |
774 (defun splash-hack-version-string () | |
775 (save-excursion | |
776 (save-restriction | |
777 (goto-char (point-min)) | |
778 (re-search-forward "^XEmacs" nil t) | |
779 (narrow-to-region (point-at-bol) (point-at-eol)) | |
780 (goto-char (point-min)) | |
781 (when (re-search-forward " \\[Lucid\\]" nil t) | |
782 (delete-region (match-beginning 0) (match-end 0))) | |
783 (when (re-search-forward "[^(][^)]*-[^)]*-" nil t) | |
784 (delete-region (1+ (match-beginning 0)) (match-end 0)) | |
785 (insert "(")) | |
786 (goto-char (point-max)) | |
787 (search-backward " " nil t) | |
788 (when (search-forward "." nil t) | |
789 (delete-region (1- (point)) (point-max)))))) | |
790 | 762 |
791 (defun splash-frame-present (l) | 763 (defun splash-frame-present (l) |
792 (cond ((stringp l) | 764 (cond ((stringp l) |
793 (insert l) | 765 (insert l)) |
794 (splash-hack-version-string)) | |
795 ((eq (car-safe l) 'face) | 766 ((eq (car-safe l) 'face) |
796 ;; (face name string) | 767 ;; (face name string) |
797 (let ((p (point))) | 768 (let ((p (point))) |
798 (splash-frame-present (elt l 2)) | 769 (splash-frame-present (elt l 2)) |
799 (if (fboundp 'set-extent-face) | 770 (if (fboundp 'set-extent-face) |
802 ((eq (car-safe l) 'key) | 773 ((eq (car-safe l) 'key) |
803 (let* ((c (elt l 1)) | 774 (let* ((c (elt l 1)) |
804 (p (point)) | 775 (p (point)) |
805 (k (where-is-internal c nil t))) | 776 (k (where-is-internal c nil t))) |
806 (insert (if k (key-description k) | 777 (insert (if k (key-description k) |
807 (format "M-x %s" c))) | 778 (format "M-x %s" c))) |
808 (if (fboundp 'set-extent-face) | 779 (if (fboundp 'set-extent-face) |
809 (let ((e (make-extent p (point)))) | 780 (let ((e (make-extent p (point)))) |
810 (set-extent-face e 'bold) | 781 (set-extent-face e 'bold) |
811 (splash-frame-present-hack e c))))) | 782 (splash-frame-present-hack e c))))) |
812 ((eq (car-safe l) 'funcall) | 783 ((eq (car-safe l) 'funcall) |
813 ;; (funcall (fun . args) string) | 784 ;; (funcall (fun . args) string) |
814 (let ((p (point))) | 785 (let ((p (point))) |
815 (splash-frame-present (elt l 2)) | 786 (splash-frame-present (elt l 2)) |
816 (if (fboundp 'set-extent-face) | 787 (if (fboundp 'set-extent-face) |
817 (splash-frame-present-hack (make-extent p (point)) | 788 (splash-frame-present-hack (make-extent p (point)) |
818 (elt l 1))))) | 789 (elt l 1))))) |
819 ((consp l) | 790 ((consp l) |
820 (mapcar 'splash-frame-present l)) | 791 (mapcar 'splash-frame-present l)) |
821 (t | 792 (t |
822 (error "WTF!?")))) | 793 (error "WTF!?")))) |
823 | 794 |
847 (+ left-margin | 818 (+ left-margin |
848 (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth))))) | 819 (round (/ (/ (- fill-area-width glyph-pixwidth) 2) avg-pixwidth))))) |
849 | 820 |
850 (defun startup-splash-frame-body () | 821 (defun startup-splash-frame-body () |
851 `("\n" ,(emacs-version) "\n" | 822 `("\n" ,(emacs-version) "\n" |
852 ,@(if (string-match "beta" emacs-version) | |
853 `( (face (bold blue) ( "This is an Experimental version of XEmacs. " | |
854 " Type " (key describe-beta) | |
855 " to see what this means.\n"))) | |
856 `( "\n")) | |
857 (face bold-italic "\ | 823 (face bold-italic "\ |
858 Copyright (C) 1985-1997 Free Software Foundation, Inc. | 824 Copyright (C) 1985-1996 Free Software Foundation, Inc. |
859 Copyright (C) 1990-1994 Lucid, Inc. | 825 Copyright (C) 1990-1994 Lucid, Inc. |
860 Copyright (C) 1993-1997 Sun Microsystems, Inc. All Rights Reserved. | 826 Copyright (C) 1993-1996 Sun Microsystems, Inc. All Rights Reserved. |
861 Copyright (C) 1994-1996 Board of Trustees, University of Illinois | 827 Copyright (C) 1994-1996 Board of Trustees, University of Illinois |
862 Copyright (C) 1995-1996 Ben Wing\n\n") | 828 Copyright (C) 1995-1996 Ben Wing\n\n") |
863 | 829 |
864 ,@(if (featurep 'sparcworks) | 830 ,@(if (featurep 'sparcworks) |
865 `( "\ | 831 `( "\ |
866 Sun provides support for the WorkShop/XEmacs integration package only. | 832 Sun provides support for the WorkShop/XEmacs integration package only. |
867 All other XEmacs packages are provided to you \"AS IS\". | 833 All other XEmacs packages are provided to you \"AS IS\". |
868 For full details, type " (key describe-no-warranty) | 834 For full details, type " (key describe-no-warranty) |
869 " to refer to the GPL Version 2, dated June 1991.\n\n" | 835 " to refer to the GPL Version 2, dated June 1991.\n\n" |
870 ,@(let ((lang (or (getenv "LANG") (getenv "LC_ALL")))) | 836 ,@(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") (getenv "LANG")))) |
871 (if (and | 837 (if (and |
872 (not (featurep 'mule)) ; Already got mule? | 838 (not (featurep 'mule)) ; Already got mule? |
873 (not (eq 'tty (console-type))) ; No Mule support on tty's yet | 839 (not (eq 'tty (console-type))) ; No Mule support on tty's yet |
874 lang ; Non-English locale? | 840 lang ; Non-English locale? |
875 (not (string-equal lang "C")) | 841 (not (string= lang "C")) |
876 (not (string-match "^en" lang)) | 842 (not (string-match "^en" lang)) |
877 (locate-file "xemacs-mule" exec-path)) ; Comes with Sun WorkShop | 843 (locate-file "xemacs-mule" exec-path)) ; Comes with Sun WorkShop |
878 '( "\ | 844 '( "\ |
879 This version of XEmacs has been built with support for Latin-1 languages only. | 845 This version of XEmacs has been built with support for Latin-1 languages only. |
880 To handle other languages you need to run a Multi-lingual (`Mule') version of | 846 To handle other languages you need to run a Multi-lingual (`Mule') version of |
892 "Type " (key help-command) " or use the " (face bold "Help") " menu to get help.\n" | 858 "Type " (key help-command) " or use the " (face bold "Help") " menu to get help.\n" |
893 "Type " (key advertised-undo) " to undo changes (`C-' means use the Control key).\n" | 859 "Type " (key advertised-undo) " to undo changes (`C-' means use the Control key).\n" |
894 "To get out of XEmacs, type " (key save-buffers-kill-emacs) ".\n" | 860 "To get out of XEmacs, type " (key save-buffers-kill-emacs) ".\n" |
895 "Type " (key help-with-tutorial) " for a tutorial on using XEmacs.\n" | 861 "Type " (key help-with-tutorial) " for a tutorial on using XEmacs.\n" |
896 "Type " (key info) " to enter Info, " | 862 "Type " (key info) " to enter Info, " |
897 "which you can use to read online documentation.\n" | 863 "which you can use to read online documentation.\n\n" |
898 (face (bold red) ( "\ | 864 (face (bold red) ( "\ |
899 For tips and answers to frequently asked questions, see the XEmacs FAQ. | 865 For tips and answers to frequently asked questions, see the XEmacs FAQ. |
900 \(It's on the Help menu, or type " (key xemacs-local-faq) " [a capital F!].\)")))) | 866 \(It's on the Help menu, or type " (key xemacs-local-faq) " [a capital F!].\)")))) |
901 | 867 |
902 (defun startup-splash-frame () | 868 (defun startup-splash-frame () |
906 (indent-to (startup-center-spaces xemacs-logo)) | 872 (indent-to (startup-center-spaces xemacs-logo)) |
907 (set-extent-begin-glyph (make-extent (point) (point)) xemacs-logo) | 873 (set-extent-begin-glyph (make-extent (point) (point)) xemacs-logo) |
908 (insert (if cramped-p "\n" "\n\n")) | 874 (insert (if cramped-p "\n" "\n\n")) |
909 (splash-frame-present-hack (make-extent p (point)) 'about-xemacs)) | 875 (splash-frame-present-hack (make-extent p (point)) 'about-xemacs)) |
910 | 876 |
911 (let ((after-change-functions nil)) ; no font-lock, thank you | 877 (let ((after-change-functions nil)) ; no font-lock, thank you |
912 (dolist (l (startup-splash-frame-body)) | 878 (dolist (l (startup-splash-frame-body)) |
913 (splash-frame-present l))) | 879 (splash-frame-present l))) |
914 (set-buffer-modified-p nil)) | 880 (set-buffer-modified-p nil)) |
915 | 881 |
916 ; (let ((present-file | 882 ;; (let ((present-file |
917 ; #'(lambda (f) | 883 ;; #'(lambda (f) |
918 ; (splash-frame-present | 884 ;; (splash-frame-present |
919 ; (list 'funcall | 885 ;; (list 'funcall |
920 ; (list 'find-file-other-window | 886 ;; (list 'find-file-other-window |
921 ; (expand-file-name f data-directory)) | 887 ;; (expand-file-name f data-directory)) |
922 ; f))))) | 888 ;; f))))) |
923 ; (insert "For customization examples, see the files ") | 889 ;; (insert "For customization examples, see the files ") |
924 ; (funcall present-file "sample.emacs") | 890 ;; (funcall present-file "sample.emacs") |
925 ; (insert " and ") | 891 ;; (insert " and ") |
926 ; (funcall present-file "sample.Xdefaults") | 892 ;; (funcall present-file "sample.Xdefaults") |
927 ; (insert (format "\nin the directory %s." data-directory))) | 893 ;; (insert (format "\nin the directory %s." data-directory))) |
928 | 894 |
929 | 895 |
930 ;;;; Computing the default load-path, etc. | 896 ;;;; Computing the default load-path, etc. |
931 ;;; | 897 ;;; |
932 ;;; This stuff is a complete mess and isn't nearly as general as it | 898 ;;; This stuff is a complete mess and isn't nearly as general as it |
966 ;;; which of those three layouts is mostly in place, so that we can suggest | 932 ;;; which of those three layouts is mostly in place, so that we can suggest |
967 ;;; the right directories in the error message. | 933 ;;; the right directories in the error message. |
968 | 934 |
969 | 935 |
970 ;; extremely low-tech debugging, since this happens so early in startup. | 936 ;; extremely low-tech debugging, since this happens so early in startup. |
971 ;(or (fboundp 'orig-file-directory-p) | 937 ;;(or (fboundp 'orig-file-directory-p) |
972 ; (fset 'orig-file-directory-p (symbol-function 'file-directory-p))) | 938 ;; (fset 'orig-file-directory-p (symbol-function 'file-directory-p))) |
973 ;(defun file-directory-p (path) | 939 ;;(defun file-directory-p (path) |
974 ; (send-string-to-terminal (format "PROBING %S" path)) | 940 ;; (send-string-to-terminal (format "PROBING %S" path)) |
975 ; (let ((v (orig-file-directory-p path))) | 941 ;; (let ((v (orig-file-directory-p path))) |
976 ; (send-string-to-terminal (format " -> %S\n" v)) | 942 ;; (send-string-to-terminal (format " -> %S\n" v)) |
977 ; v)) | 943 ;; v)) |
978 | 944 |
979 (defun startup-make-version-dir () | 945 (defun startup-make-version-dir () |
980 (let ((version (and (string-match "\\`[^0-9]*\\([0-9]+\\.[0-9]+\\)" | 946 (let ((version (and (string-match "\\`[^0-9]*\\([0-9]+\\.[0-9]+\\)" |
981 emacs-version) | 947 emacs-version) |
982 (substring emacs-version | 948 (substring emacs-version |
1073 ;; general direction of a clue. | 1039 ;; general direction of a clue. |
1074 ;; | 1040 ;; |
1075 nil))) | 1041 nil))) |
1076 | 1042 |
1077 (defun find-emacs-root-internal (path) | 1043 (defun find-emacs-root-internal (path) |
1078 ;; (send-string-to-terminal (format "FINDING ROOT FOR %S\n" path)) | 1044 ;; (send-string-to-terminal (format "FINDING ROOT FOR %S\n" path)) |
1079 ;; first look for lisp/prim and lib-src; then just look for lib-src. | 1045 ;; first look for lisp/prim and lib-src; then just look for lib-src. |
1080 ;; XEmacs can run (kind of) if the lisp directory is omitted, which | 1046 ;; XEmacs can run (kind of) if the lisp directory is omitted, which |
1081 ;; some people might want to do for space reasons. | 1047 ;; some people might want to do for space reasons. |
1082 (or (find-emacs-root-internal-1 path t) | 1048 (or (find-emacs-root-internal-1 path t) |
1083 (find-emacs-root-internal-1 path nil) | 1049 (find-emacs-root-internal-1 path nil) |
1108 (let* ((root (find-emacs-root-internal (concat invocation-directory | 1074 (let* ((root (find-emacs-root-internal (concat invocation-directory |
1109 invocation-name))) | 1075 invocation-name))) |
1110 (lisp (and root | 1076 (lisp (and root |
1111 (let ((f (expand-file-name "lisp" root))) | 1077 (let ((f (expand-file-name "lisp" root))) |
1112 (and (file-directory-p f) f)))) | 1078 (and (file-directory-p f) f)))) |
1113 (site-lisp (and root | 1079 (site-lisp |
1114 (or | 1080 (and root |
1115 (let ((f (expand-file-name "xemacs/site-lisp" root))) | 1081 (or |
1116 (and (file-directory-p f) f)) | 1082 (let ((f (expand-file-name "xemacs/site-lisp" root))) |
1117 (let ((f (expand-file-name "../xemacs/site-lisp" | 1083 (and (file-directory-p f) f)) |
1118 root))) | 1084 (let ((f (expand-file-name "../xemacs/site-lisp" root))) |
1119 (and (file-directory-p f) f)) | 1085 (and (file-directory-p f) f)) |
1120 ;; the next two are for --run-in-place | 1086 ;; the next two are for --run-in-place |
1121 (let ((f (expand-file-name "site-lisp" root))) | 1087 (let ((f (expand-file-name "site-lisp" root))) |
1122 (and (file-directory-p f) f)) | 1088 (and (file-directory-p f) f)) |
1123 (let ((f (expand-file-name "lisp/site-lisp" root))) | 1089 (let ((f (expand-file-name "lisp/site-lisp" root))) |
1124 (and (file-directory-p f) f)) | 1090 (and (file-directory-p f) f)) |
1125 ))) | 1091 ))) |
1126 (lib-src (and root | 1092 (lib-src |
1127 (or | 1093 (and root |
1128 (let ((f (expand-file-name | 1094 (or |
1129 (concat "lib-src/" system-configuration) | 1095 (let ((f (expand-file-name |
1130 root))) | 1096 (concat "lib-src/" system-configuration) |
1131 (and (file-directory-p f) f)) | 1097 root))) |
1132 (let ((f (expand-file-name "lib-src" root))) | 1098 (and (file-directory-p f) f)) |
1133 (and (file-directory-p f) f)) | 1099 (let ((f (expand-file-name "lib-src" root))) |
1134 (let ((f (expand-file-name system-configuration root))) | 1100 (and (file-directory-p f) f)) |
1135 (and (file-directory-p f) f))))) | 1101 (let ((f (expand-file-name system-configuration root))) |
1136 (etc (and root | 1102 (and (file-directory-p f) f))))) |
1137 (let ((f (expand-file-name "etc" root))) | 1103 (etc |
1138 (and (file-directory-p f) f)))) | 1104 (and root |
1139 (info (and root | 1105 (let ((f (expand-file-name "etc" root))) |
1140 (let ((f (expand-file-name "info" root))) | 1106 (and (file-directory-p f) f)))) |
1141 (and (file-directory-p f) (file-name-as-directory f))))) | 1107 (info |
1142 (lock (and root | 1108 (and root |
1143 (boundp 'lock-directory) | 1109 (let ((f (expand-file-name "info" root))) |
1144 (if (and lock-directory (file-directory-p lock-directory)) | 1110 (and (file-directory-p f) (file-name-as-directory f))))) |
1145 (file-name-as-directory lock-directory) | 1111 (lock |
1146 (or | 1112 (and root |
1147 (let ((f (expand-file-name "xemacs/lock" root))) | 1113 (boundp 'lock-directory) |
1148 (and (file-directory-p f) | 1114 (if (and lock-directory (file-directory-p lock-directory)) |
1149 (file-name-as-directory f))) | 1115 (file-name-as-directory lock-directory) |
1150 (let ((f (expand-file-name "../xemacs/lock" root))) | 1116 (or |
1151 (and (file-directory-p f) | 1117 (let ((f (expand-file-name "xemacs/lock" root))) |
1152 (file-name-as-directory f))) | 1118 (and (file-directory-p f) |
1153 (let ((f (expand-file-name "lock" root))) | 1119 (file-name-as-directory f))) |
1154 (and (file-directory-p f) | 1120 (let ((f (expand-file-name "../xemacs/lock" root))) |
1155 (file-name-as-directory f))) | 1121 (and (file-directory-p f) |
1156 ;; if none of them exist, make the "guess" be | 1122 (file-name-as-directory f))) |
1157 ;; the one that set-default-load-path-warning | 1123 (let ((f (expand-file-name "lock" root))) |
1158 ;; will suggest. | 1124 (and (file-directory-p f) |
1159 (file-name-as-directory | 1125 (file-name-as-directory f))) |
1160 (expand-file-name "../xemacs/lock" root)) | 1126 ;; if none of them exist, make the "guess" be |
1161 ))))) | 1127 ;; the one that set-default-load-path-warning |
1162 | 1128 ;; will suggest. |
1163 ;; 1996/12/6 by MORIOKA Tomohiko <morioka@jaist.ac.jp> | 1129 (file-name-as-directory |
1164 ;; define `default-load-path' for file-detect.el | 1130 (expand-file-name "../xemacs/lock" root)) |
1165 (setq default-load-path load-path) | 1131 ))))) |
1166 | |
1167 ;; add site-lisp dir to load-path | 1132 ;; add site-lisp dir to load-path |
1168 (if site-lisp | 1133 (when site-lisp |
1169 (progn | 1134 ;; If the site-lisp dir isn't on the load-path, add it to the end. |
1170 ;; If the site-lisp dir isn't on the load-path, add it to the end. | 1135 (or (member site-lisp load-path) |
1171 (or (member site-lisp load-path) | 1136 (setq load-path (append load-path (list site-lisp)))) |
1172 (setq load-path (append load-path (list site-lisp)))) | 1137 ;; Also add any direct subdirectories of the site-lisp directory |
1173 ;; Also add any direct subdirectories of the site-lisp directory | 1138 ;; to the load-path. But don't add dirs whose names begin |
1174 ;; to the load-path. But don't add dirs whose names begin | 1139 ;; with dot or hyphen. |
1175 ;; with dot or hyphen. | 1140 (let ((files (directory-files site-lisp nil "^[^-.]" nil 'dirs-only)) |
1176 (let ((files (directory-files site-lisp nil "^[^-.]" nil 'dirs-only)) | 1141 file) |
1177 file) | 1142 (while files |
1178 (while files | 1143 (setq file (car files)) |
1179 (setq file (car files)) | 1144 (if (and (not (member file '("RCS" "CVS" "SCCS"))) |
1180 (if (and (not (member file '("RCS" "CVS" "SCCS"))) | 1145 (setq file (expand-file-name file site-lisp)) |
1181 (setq file (expand-file-name file site-lisp)) | 1146 (not (member file load-path))) |
1182 (not (member file load-path))) | 1147 (setq load-path |
1183 (setq load-path | 1148 (nconc load-path |
1184 (nconc load-path | 1149 (list (file-name-as-directory file))))) |
1185 (list (file-name-as-directory file))))) | 1150 (setq files (cdr files))))) |
1186 (setq files (cdr files)))) | 1151 |
1187 )) | |
1188 ;; add lisp dir to load-path | 1152 ;; add lisp dir to load-path |
1189 (if lisp | 1153 (when lisp |
1190 (progn | 1154 ;; If the lisp dir isn't on the load-path, add it to the end. |
1191 ;; If the lisp dir isn't on the load-path, add it to the end. | 1155 (or (member lisp load-path) |
1192 (or (member lisp load-path) | 1156 (setq load-path (append load-path (list lisp)))) |
1193 (setq load-path (append load-path (list lisp)))) | 1157 ;; Also add any direct subdirectories of the lisp directory |
1194 ;; Also add any direct subdirectories of the lisp directory | 1158 ;; to the load-path. But don't add dirs whose names begin |
1195 ;; to the load-path. But don't add dirs whose names begin | 1159 ;; with dot or hyphen. |
1196 ;; with dot or hyphen. | 1160 (let ((files (directory-files lisp nil "^[^-.]" nil 'dirs-only)) |
1197 (let ((files (directory-files lisp nil "^[^-.]" nil 'dirs-only)) | 1161 file) |
1198 file) | 1162 (while files |
1199 (while files | 1163 (setq file (car files)) |
1200 (setq file (car files)) | 1164 (when (and (not (member file '("RCS" "CVS" "SCCS"))) |
1201 (if (and (not (member file '("RCS" "CVS" "SCCS"))) | 1165 (setq file (expand-file-name file lisp)) |
1202 (setq file (expand-file-name file lisp)) | 1166 (not (member file load-path))) |
1203 (not (member file load-path))) | 1167 (setq load-path |
1204 (setq load-path | 1168 (nconc load-path |
1205 (nconc load-path | 1169 (list (file-name-as-directory file))))) |
1206 (list (file-name-as-directory file))))) | 1170 (setq files (cdr files))))) |
1207 (setq files (cdr files)))))) | |
1208 | |
1209 ;; 1996/12/6 by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
1210 ;; define `default-load-path' for file-detect.el | |
1211 (setq default-load-path | |
1212 (append default-load-path | |
1213 (if site-lisp | |
1214 (list site-lisp)) | |
1215 (if lisp | |
1216 (list lisp) | |
1217 ) | |
1218 )) | |
1219 | |
1220 ;; 1997/03/06 by Jeff Miller <jmiller@bayserve.net> | |
1221 ;; initialize 'site-directory'. This is the site-lisp dir used by | |
1222 ;; XEmacs | |
1223 (if site-lisp | |
1224 (setq site-directory (file-name-as-directory site-lisp)) | |
1225 ) | |
1226 | 1171 |
1227 ;; If running from the build directory, always prefer the exec-directory | 1172 ;; If running from the build directory, always prefer the exec-directory |
1228 ;; that is here over the one that came from paths.h. | 1173 ;; that is here over to the one that came from paths.h. |
1229 (if (or (and (null exec-directory) lib-src) | 1174 (when (or (and (null exec-directory) lib-src) |
1230 (and (equal lib-src (expand-file-name "lib-src" root)) | 1175 (and (string= lib-src (expand-file-name "lib-src" root)) |
1231 (not (equal exec-directory lib-src)))) | 1176 (not (string= exec-directory lib-src)))) |
1232 (setq exec-directory (file-name-as-directory lib-src))) | 1177 (setq exec-directory (file-name-as-directory lib-src))) |
1233 (if (or (and (null doc-directory) lib-src) | 1178 (when (or (and (null doc-directory) lib-src) |
1234 (and (equal lib-src (expand-file-name "lib-src" root)) | 1179 (and (string= lib-src (expand-file-name "lib-src" root)) |
1235 (not (equal doc-directory lib-src)))) | 1180 (not (string= doc-directory lib-src)))) |
1236 (setq doc-directory (file-name-as-directory lib-src))) | 1181 (setq doc-directory (file-name-as-directory lib-src))) |
1237 | 1182 |
1238 (if exec-directory | 1183 (when exec-directory |
1239 (or (member exec-directory exec-path) | 1184 (or (member exec-directory exec-path) |
1240 (setq exec-path (append exec-path (list exec-directory))))) | 1185 (setq exec-path (append exec-path (list exec-directory))))) |
1241 (if (or (and (null data-directory) etc) | 1186 (when (or (and (null data-directory) etc) |
1242 (and (equal etc (expand-file-name "etc" root)) | 1187 (and (string= etc (expand-file-name "etc" root)) |
1243 (not (equal data-directory etc)))) | 1188 (not (string= data-directory etc)))) |
1244 (setq data-directory (file-name-as-directory etc))) | 1189 (setq data-directory (file-name-as-directory etc))) |
1245 | 1190 |
1246 | 1191 |
1247 | 1192 |
1248 ;; If `configure' specified an info dir, use it. | 1193 ;; If `configure' specified an info dir, use it. |
1249 (or (boundp 'Info-default-directory-list) | 1194 (or (boundp 'Info-default-directory-list) |
1254 (or (member configure-info-directory Info-default-directory-list) | 1199 (or (member configure-info-directory Info-default-directory-list) |
1255 (setq Info-default-directory-list | 1200 (setq Info-default-directory-list |
1256 (append Info-default-directory-list | 1201 (append Info-default-directory-list |
1257 (list configure-info-directory)))))) | 1202 (list configure-info-directory)))))) |
1258 ;; If we've guessed the info dir, use that (too). | 1203 ;; If we've guessed the info dir, use that (too). |
1259 (if (and info (not (member info Info-default-directory-list))) | 1204 (when (and info (not (member info Info-default-directory-list))) |
1260 (setq Info-default-directory-list | 1205 (setq Info-default-directory-list |
1261 (append Info-default-directory-list (list info)))) | 1206 (append Info-default-directory-list (list info)))) |
1262 | 1207 |
1263 ;; Default the lock dir to being a sibling of the data-directory. | 1208 ;; Default the lock dir to being a sibling of the data-directory. |
1264 ;; If superlock isn't set, or is set to a file in a nonexistent | 1209 ;; If superlock isn't set, or is set to a file in a nonexistent |
1265 ;; directory, derive it from the lock dir. | 1210 ;; directory, derive it from the lock dir. |
1266 (if (boundp 'lock-directory) | 1211 (when (boundp 'lock-directory) |
1267 (progn | 1212 (setq lock-directory lock) |
1268 (setq lock-directory lock) | 1213 (cond ((null lock-directory) |
1269 (cond ((null lock-directory) | 1214 (setq superlock-file nil)) |
1270 (setq superlock-file nil)) | 1215 ((or (null superlock-file) |
1271 ((or (null superlock-file) | 1216 (not (file-directory-p |
1272 (not (file-directory-p | 1217 (file-name-directory superlock-file)))) |
1273 (file-name-directory superlock-file)))) | 1218 (setq superlock-file |
1274 (setq superlock-file | 1219 (expand-file-name "!!!SuperLock!!!" |
1275 (expand-file-name "!!!SuperLock!!!" | 1220 lock-directory))))) |
1276 lock-directory)))))) | |
1277 | 1221 |
1278 (set-default-load-path-warning))) | 1222 (set-default-load-path-warning))) |
1279 | 1223 |
1280 | 1224 |
1281 (defun set-default-load-path-warning () | 1225 (defun set-default-load-path-warning () |
1282 (let ((lock (if (boundp 'lock-directory) lock-directory 't)) | 1226 (let ((lock (if (boundp 'lock-directory) lock-directory 't)) |
1283 warnings message guess) | 1227 warnings message guess) |
1284 (if (and (stringp lock) (not (file-directory-p lock))) | 1228 (when (and (stringp lock) (not (file-directory-p lock))) |
1285 (setq lock nil)) | 1229 (setq lock nil)) |
1286 (cond | 1230 (cond |
1287 ((not (and exec-directory data-directory doc-directory load-path lock)) | 1231 ((not (and exec-directory data-directory doc-directory load-path lock)) |
1288 (save-excursion | 1232 (save-excursion |
1289 (set-buffer (get-buffer-create " *warning-tmp*")) | 1233 (set-buffer (get-buffer-create " *warning-tmp*")) |
1290 (erase-buffer) | 1234 (erase-buffer) |
1291 (buffer-disable-undo (current-buffer)) | 1235 (buffer-disable-undo (current-buffer)) |
1292 (if (null lock) | 1236 (when (null lock) (push "lock-directory" warnings)) |
1293 (setq warnings (cons "lock-directory" warnings))) | 1237 (when (null exec-directory) (push "exec-directory" warnings)) |
1294 (if (null exec-directory) | 1238 (when (null data-directory) (push "data-directory" warnings)) |
1295 (setq warnings (cons "exec-directory" warnings))) | 1239 (when (null doc-directory) (push "doc-directory" warnings)) |
1296 (if (null data-directory) | 1240 (when (null load-path) (push "load-path" warnings)) |
1297 (setq warnings (cons "data-directory" warnings))) | |
1298 (if (null doc-directory) | |
1299 (setq warnings (cons "doc-directory" warnings))) | |
1300 (if (null load-path) | |
1301 (setq warnings (cons "load-path" warnings))) | |
1302 (cond ((cdr (cdr warnings)) | 1241 (cond ((cdr (cdr warnings)) |
1303 (setq message (apply 'format "%s, %s, and %s" warnings))) | 1242 (setq message (apply 'format "%s, %s, and %s" warnings))) |
1304 ((cdr warnings) | 1243 ((cdr warnings) |
1305 (setq message (apply 'format "%s and %s" warnings))) | 1244 (setq message (apply 'format "%s and %s" warnings))) |
1306 (t (setq message (format "variable %s" (car warnings))))) | 1245 (t (setq message (format "variable %s" (car warnings))))) |
1315 doc-directory | 1254 doc-directory |
1316 (car load-path) | 1255 (car load-path) |
1317 (and (string-match "/[^/]+\\'" invocation-directory) | 1256 (and (string-match "/[^/]+\\'" invocation-directory) |
1318 (substring invocation-directory 0 | 1257 (substring invocation-directory 0 |
1319 (match-beginning 0))))) | 1258 (match-beginning 0))))) |
1320 (if (and guess | 1259 (when (and guess |
1321 (or | 1260 (or |
1322 ;; parent of a terminal bin/<configuration> pair (hack hack). | 1261 ;; parent of a terminal bin/<configuration> pair (hack hack). |
1323 (string-match (concat "/bin/" | 1262 (string-match (concat "/bin/" |
1324 (regexp-quote system-configuration) | 1263 (regexp-quote system-configuration) |
1325 "/?\\'") | 1264 "/?\\'") |
1326 guess) | 1265 guess) |
1327 ;; parent of terminal src, lib-src, etc, or lisp dir. | 1266 ;; parent of terminal src, lib-src, etc, or lisp dir. |
1328 (string-match | 1267 (string-match |
1329 "/\\(bin\\|src\\|lib-src\\|etc\\|lisp\\)[^/]*/?\\'" | 1268 "/\\(bin\\|src\\|lib-src\\|etc\\|lisp\\)[^/]*/?\\'" |
1330 guess))) | 1269 guess))) |
1331 (setq guess (substring guess 0 (match-beginning 0)))) | 1270 (setq guess (substring guess 0 (match-beginning 0)))) |
1332 | 1271 |
1333 ;; If neither the exec nor lisp dirs are around, then "guess" that | 1272 ;; If neither the exec nor lisp dirs are around, then "guess" that |
1334 ;; the new configure-style lib dir should be used. Otherwise, if | 1273 ;; the new configure-style lib dir should be used. Otherwise, if |
1335 ;; only one of them appears to be missing, or it's just lock, | 1274 ;; only one of them appears to be missing, or it's just lock, |
1336 ;; then guess it to be a sibling of whatever already exists. | 1275 ;; then guess it to be a sibling of whatever already exists. |
1337 (if (and (null exec-directory) (null load-path)) | 1276 (when (and (null exec-directory) (null load-path)) |
1338 (setq guess (expand-file-name (startup-make-version-dir) guess))) | 1277 (setq guess (expand-file-name (startup-make-version-dir) guess))) |
1339 | 1278 |
1340 (if (or (null exec-directory) (null load-path)) | 1279 (when (or (null exec-directory) (null load-path)) |
1280 (insert | |
1281 "\n\nWithout both exec-directory and load-path, XEmacs will " | |
1282 "be very broken. ")) | |
1283 (when (and (null exec-directory) guess) | |
1284 (insert | |
1285 "Consider making a symbolic link from " | |
1286 (expand-file-name system-configuration guess) | |
1287 " to wherever the appropriate XEmacs exec-directory " | |
1288 "directory is")) | |
1289 (when (and (null data-directory) guess) | |
1290 (insert | |
1291 (if exec-directory | |
1292 "\n\nConsider making a symbolic link " ", and ") | |
1293 "from " | |
1294 (expand-file-name "etc" (if load-path | |
1295 (file-name-directory | |
1296 (directory-file-name | |
1297 (car load-path))) | |
1298 guess)) | |
1299 " to wherever the appropriate XEmacs data-directory is")) | |
1300 (when (and (null load-path) guess) | |
1301 (insert | |
1302 (if (and exec-directory data-directory) | |
1303 "Consider making a symbolic link " | |
1304 ", and ") | |
1305 "from " | |
1306 (expand-file-name "lisp" guess) | |
1307 " to wherever the appropriate XEmacs lisp library is")) | |
1308 (insert ".") | |
1309 | |
1310 (when (null lock) | |
1311 (insert | |
1312 "\n\nWithout lock-directory set, file locking won't work. ") | |
1313 (when guess | |
1341 (insert | 1314 (insert |
1342 "\n\nWithout both exec-directory and load-path, XEmacs will " | 1315 "Consider creating " |
1343 "be very broken. ")) | 1316 (expand-file-name "../xemacs/lock" |
1344 (if (and (null exec-directory) guess) | 1317 (or (find-emacs-root-internal |
1345 (insert | 1318 (concat invocation-directory |
1346 "Consider making a symbolic link from " | 1319 invocation-name)) |
1347 (expand-file-name system-configuration guess) | 1320 guess)) |
1348 " to wherever the appropriate XEmacs exec-directory " | 1321 " as a directory or symbolic link for use as the lock " |
1349 "directory is")) | 1322 "directory. (This directory must be globally writable.)" |
1350 (if (and (null data-directory) guess) | 1323 ))) |
1351 (insert | 1324 |
1352 (if exec-directory | 1325 (when (fboundp 'fill-region) |
1353 "\n\nConsider making a symbolic link " ", and ") | 1326 ;; Might not be bound in the cold load environment... |
1354 "from " | 1327 (let ((fill-column 76)) |
1355 (expand-file-name "etc" (if load-path | 1328 (fill-region (point-min) (point-max)))) |
1356 (file-name-directory | |
1357 (directory-file-name | |
1358 (car load-path))) | |
1359 guess)) | |
1360 " to wherever the appropriate XEmacs data-directory is")) | |
1361 (if (and (null load-path) guess) | |
1362 (insert | |
1363 (if (and exec-directory data-directory) | |
1364 "Consider making a symbolic link " | |
1365 ", and ") | |
1366 "from " | |
1367 (expand-file-name "lisp" guess) | |
1368 " to wherever the appropriate XEmacs lisp library is")) | |
1369 (insert ".") | |
1370 | |
1371 (if (null lock) | |
1372 (progn | |
1373 (insert | |
1374 "\n\nWithout lock-directory set, file locking won't work. ") | |
1375 (if guess | |
1376 (insert | |
1377 "Consider creating " | |
1378 (expand-file-name "../xemacs/lock" | |
1379 (or (find-emacs-root-internal | |
1380 (concat invocation-directory | |
1381 invocation-name)) | |
1382 guess)) | |
1383 " as a directory or symbolic link for use as the lock " | |
1384 "directory. (This directory must be globally writable.)" | |
1385 )))) | |
1386 | |
1387 (if (fboundp 'fill-region) | |
1388 ;; Might not be bound in the cold load environment... | |
1389 (let ((fill-column 76)) | |
1390 (fill-region (point-min) (point-max)))) | |
1391 (goto-char (point-min)) | 1329 (goto-char (point-min)) |
1392 (princ "\nWARNING:\n" 'external-debugging-output) | 1330 (princ "\nWARNING:\n" 'external-debugging-output) |
1393 (princ (buffer-string) 'external-debugging-output) | 1331 (princ (buffer-string) 'external-debugging-output) |
1394 (erase-buffer) | 1332 (erase-buffer) |
1395 t))))) | 1333 t))))) |
1396 | 1334 |
1397 | |
1398 ;;; startup.el ends here | 1335 ;;; startup.el ends here |