annotate lisp/prim/startup.el @ 16:0293115a14e9 r19-15b91

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