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