loadup.el 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
  2. ;; Copyright (C) 1985-1986, 1992, 1994, 2001-2012
  3. ;; Free Software Foundation, Inc.
  4. ;; Maintainer: FSF
  5. ;; Keywords: internal
  6. ;; Package: emacs
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This is loaded into a bare Emacs to make a dumpable one.
  20. ;; If you add/remove Lisp files to be loaded here, consider the
  21. ;; following issues:
  22. ;; i) Any file loaded on any platform should appear in $lisp in src/lisp.mk.
  23. ;; Use the .el or .elc version as appropriate.
  24. ;; This ensures both that the Lisp files are compiled (if necessary)
  25. ;; before the emacs executable is dumped, and that they are passed to
  26. ;; make-docfile. (Any that are not processed for DOC will not have
  27. ;; doc strings in the dumped Emacs.) Because of this:
  28. ;; ii) If the file is loaded uncompiled, it should (where possible)
  29. ;; obey the doc-string conventions expected by make-docfile.
  30. ;;; Code:
  31. ;; Add subdirectories to the load-path for files that might get
  32. ;; autoloaded when bootstrapping.
  33. (if (or (equal (nth 3 command-line-args) "bootstrap")
  34. (equal (nth 4 command-line-args) "bootstrap")
  35. (equal (nth 3 command-line-args) "unidata-gen.el")
  36. (equal (nth 4 command-line-args) "unidata-gen-files")
  37. ;; In case CANNOT_DUMP.
  38. (string-match "src/bootstrap-emacs" (nth 0 command-line-args)))
  39. (let ((dir (car load-path)))
  40. ;; We'll probably overflow the pure space.
  41. (setq purify-flag nil)
  42. (setq load-path (list dir
  43. (expand-file-name "emacs-lisp" dir)
  44. (expand-file-name "language" dir)
  45. (expand-file-name "international" dir)
  46. (expand-file-name "textmodes" dir)))))
  47. (if (eq t purify-flag)
  48. ;; Hash consing saved around 11% of pure space in my tests.
  49. (setq purify-flag (make-hash-table :test 'equal)))
  50. (message "Using load-path %s" load-path)
  51. (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
  52. (member (nth 4 command-line-args) '("dump" "bootstrap")))
  53. ;; To reduce the size of dumped Emacs, we avoid making huge
  54. ;; char-tables.
  55. (setq inhibit-load-charset-map t))
  56. ;; We don't want to have any undo records in the dumped Emacs.
  57. (set-buffer "*scratch*")
  58. (setq buffer-undo-list t)
  59. (load "emacs-lisp/byte-run")
  60. (load "emacs-lisp/backquote")
  61. (load "subr")
  62. ;; Do it after subr, since both after-load-functions and add-hook are
  63. ;; implemented in subr.el.
  64. (add-hook 'after-load-functions (lambda (f) (garbage-collect)))
  65. ;; We specify .el in case someone compiled version.el by mistake.
  66. (load "version.el")
  67. (load "widget")
  68. (load "custom")
  69. (load "emacs-lisp/map-ynp")
  70. (load "cus-start")
  71. (load "international/mule")
  72. (load "international/mule-conf")
  73. (load "env")
  74. (load "format")
  75. (load "bindings")
  76. (load "window") ; Needed here for `replace-buffer-in-windows'.
  77. (setq load-source-file-function 'load-with-code-conversion)
  78. (load "files")
  79. (load "cus-face")
  80. (load "faces") ; after here, `defface' may be used.
  81. (load "button")
  82. (load "startup")
  83. (condition-case nil
  84. ;; Don't get confused if someone compiled this by mistake.
  85. (load "loaddefs.el")
  86. ;; In case loaddefs hasn't been generated yet.
  87. (file-error (load "ldefs-boot.el")))
  88. (load "minibuffer")
  89. (load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
  90. (load "simple")
  91. (load "help")
  92. (load "jka-cmpr-hook")
  93. (load "epa-hook")
  94. ;; Any Emacs Lisp source file (*.el) loaded here after can contain
  95. ;; multilingual text.
  96. (load "international/mule-cmds")
  97. (load "case-table")
  98. ;; This file doesn't exist when building a development version of Emacs
  99. ;; from the repository. It is generated just after temacs is built.
  100. (load "international/charprop.el" t)
  101. (load "international/characters")
  102. (load "composite")
  103. ;; Load language-specific files.
  104. (load "language/chinese")
  105. (load "language/cyrillic")
  106. (load "language/indian")
  107. (load "language/sinhala")
  108. (load "language/english")
  109. (load "language/ethiopic")
  110. (load "language/european")
  111. (load "language/czech")
  112. (load "language/slovak")
  113. (load "language/romanian")
  114. (load "language/greek")
  115. (load "language/hebrew")
  116. (load "language/japanese")
  117. (load "language/korean")
  118. (load "language/lao")
  119. (load "language/tai-viet")
  120. (load "language/thai")
  121. (load "language/tibetan")
  122. (load "language/vietnamese")
  123. (load "language/misc-lang")
  124. (load "language/utf-8-lang")
  125. (load "language/georgian")
  126. (load "language/khmer")
  127. (load "language/burmese")
  128. (load "language/cham")
  129. (load "indent")
  130. (load "frame")
  131. (load "term/tty-colors")
  132. (load "font-core")
  133. ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
  134. ;; needs to be defined when font-lock is loaded.
  135. (load "facemenu")
  136. (load "emacs-lisp/syntax")
  137. (load "font-lock")
  138. (load "jit-lock")
  139. (if (fboundp 'track-mouse)
  140. (progn
  141. (load "mouse")
  142. (and (boundp 'x-toolkit-scroll-bars)
  143. (load "scroll-bar"))
  144. (load "select")))
  145. (load "emacs-lisp/timer")
  146. (load "isearch")
  147. (load "rfn-eshadow")
  148. (load "menu-bar")
  149. (load "paths.el") ;Don't get confused if someone compiled paths by mistake.
  150. (load "emacs-lisp/lisp")
  151. (load "textmodes/page")
  152. (load "register")
  153. (load "textmodes/paragraphs")
  154. (load "emacs-lisp/lisp-mode")
  155. (load "textmodes/text-mode")
  156. (load "textmodes/fill")
  157. (load "replace")
  158. (load "buff-menu")
  159. (if (fboundp 'x-create-frame)
  160. (progn
  161. (load "fringe")
  162. (load "image")
  163. (load "international/fontset")
  164. (load "dnd")
  165. (load "tool-bar")))
  166. (if (featurep 'dynamic-setting)
  167. (load "dynamic-setting"))
  168. (if (featurep 'x)
  169. (progn
  170. (load "x-dnd")
  171. (load "term/common-win")
  172. (load "term/x-win")))
  173. (if (eq system-type 'windows-nt)
  174. (progn
  175. (load "w32-vars")
  176. (load "term/common-win")
  177. (load "term/w32-win")
  178. (load "ls-lisp")
  179. (load "disp-table")
  180. (load "dos-w32")
  181. (load "w32-fns")))
  182. (if (eq system-type 'ms-dos)
  183. (progn
  184. (load "dos-w32")
  185. (load "dos-fns")
  186. (load "dos-vars")
  187. ;; Don't load term/common-win: it isn't appropriate for the `pc'
  188. ;; ``window system'', which generally behaves like a terminal.
  189. (load "term/pc-win")
  190. (load "ls-lisp")
  191. (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
  192. (if (featurep 'ns)
  193. (progn
  194. (load "term/common-win")
  195. (load "term/ns-win")))
  196. (if (fboundp 'x-create-frame)
  197. ;; Do it after loading term/foo-win.el since the value of the
  198. ;; mouse-wheel-*-event vars depends on those files being loaded or not.
  199. (load "mwheel"))
  200. ;; Preload some constants and floating point functions.
  201. (load "emacs-lisp/float-sup")
  202. (load "vc/vc-hooks")
  203. (load "vc/ediff-hook")
  204. (if (fboundp 'x-show-tip) (load "tooltip"))
  205. ;If you want additional libraries to be preloaded and their
  206. ;doc strings kept in the DOC file rather than in core,
  207. ;you may load them with a "site-load.el" file.
  208. ;But you must also cause them to be scanned when the DOC file
  209. ;is generated.
  210. ;For other systems, you must edit ../src/Makefile.in.
  211. (load "site-load" t)
  212. ;; Determine which last version number to use
  213. ;; based on the executables that now exist.
  214. (if (and (or (equal (nth 3 command-line-args) "dump")
  215. (equal (nth 4 command-line-args) "dump"))
  216. (not (eq system-type 'ms-dos)))
  217. (let* ((base (concat "emacs-" emacs-version "."))
  218. (files (file-name-all-completions base default-directory))
  219. (versions (mapcar (function (lambda (name)
  220. (string-to-number (substring name (length base)))))
  221. files)))
  222. ;; `emacs-version' is a constant, so we shouldn't change it with `setq'.
  223. (defconst emacs-version
  224. (format "%s.%d"
  225. emacs-version (if versions (1+ (apply 'max versions)) 1)))))
  226. (message "Finding pointers to doc strings...")
  227. (if (or (equal (nth 3 command-line-args) "dump")
  228. (equal (nth 4 command-line-args) "dump"))
  229. (let ((name emacs-version))
  230. (while (string-match "[^-+_.a-zA-Z0-9]+" name)
  231. (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  232. "-"
  233. (substring name (match-end 0)))))
  234. (if (memq system-type '(ms-dos windows-nt))
  235. (setq name (expand-file-name
  236. (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
  237. (setq name (concat (expand-file-name "../etc/DOC-") name))
  238. (if (file-exists-p name)
  239. (delete-file name))
  240. (copy-file (expand-file-name "../etc/DOC") name t))
  241. (Snarf-documentation (file-name-nondirectory name)))
  242. (condition-case nil
  243. (Snarf-documentation "DOC")
  244. (error nil)))
  245. (message "Finding pointers to doc strings...done")
  246. ;; Note: You can cause additional libraries to be preloaded
  247. ;; by writing a site-init.el that loads them.
  248. ;; See also "site-load" above.
  249. (load "site-init" t)
  250. (setq current-load-list nil)
  251. ;; We keep the load-history data in PURE space.
  252. ;; Make sure that the spine of the list is not in pure space because it can
  253. ;; be destructively mutated in lread.c:build_load_history.
  254. (setq load-history (mapcar 'purecopy load-history))
  255. (set-buffer-modified-p nil)
  256. ;; reset the load-path. See lread.c:init_lread why.
  257. (if (or (equal (nth 3 command-line-args) "bootstrap")
  258. (equal (nth 4 command-line-args) "bootstrap"))
  259. (setcdr load-path nil))
  260. (remove-hook 'after-load-functions (lambda (f) (garbage-collect)))
  261. (setq inhibit-load-charset-map nil)
  262. (clear-charset-maps)
  263. (garbage-collect)
  264. ;; At this point, we're ready to resume undo recording for scratch.
  265. (buffer-enable-undo "*scratch*")
  266. ;; Avoid error if user loads some more libraries now and make sure the
  267. ;; hash-consing hash table is GC'd.
  268. (setq purify-flag nil)
  269. (if (null (garbage-collect))
  270. (setq pure-space-overflow t))
  271. (if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
  272. (member (nth 4 command-line-args) '("dump" "bootstrap")))
  273. (progn
  274. (if (memq system-type '(ms-dos windows-nt cygwin))
  275. (message "Dumping under the name emacs")
  276. (message "Dumping under the name emacs"))
  277. (condition-case ()
  278. (delete-file "emacs")
  279. (file-error nil))
  280. ;; We used to dump under the name xemacs, but that occasionally
  281. ;; confused people installing Emacs (they'd install the file
  282. ;; under the name `xemacs'), and it's inconsistent with every
  283. ;; other GNU program's build process.
  284. (dump-emacs "emacs" "temacs")
  285. (message "%d pure bytes used" pure-bytes-used)
  286. ;; Recompute NAME now, so that it isn't set when we dump.
  287. (if (not (or (memq system-type '(ms-dos windows-nt))
  288. ;; Don't bother adding another name if we're just
  289. ;; building bootstrap-emacs.
  290. (equal (nth 3 command-line-args) "bootstrap")
  291. (equal (nth 4 command-line-args) "bootstrap")))
  292. (let ((name (concat "emacs-" emacs-version)))
  293. (while (string-match "[^-+_.a-zA-Z0-9]+" name)
  294. (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  295. "-"
  296. (substring name (match-end 0)))))
  297. (message "Adding name %s" name)
  298. (add-name-to-file "emacs" name t)))
  299. (kill-emacs)))
  300. ;; For machines with CANNOT_DUMP defined in config.h,
  301. ;; this file must be loaded each time Emacs is run.
  302. ;; So run the startup code now. First, remove `-l loadup' from args.
  303. (if (and (equal (nth 1 command-line-args) "-l")
  304. (equal (nth 2 command-line-args) "loadup"))
  305. (setcdr command-line-args (nthcdr 3 command-line-args)))
  306. (eval top-level)
  307. ;; Local Variables:
  308. ;; no-byte-compile: t
  309. ;; no-update-autoloads: t
  310. ;; End:
  311. ;;; loadup.el ends here