]> code.delx.au - gnu-emacs/blobdiff - lisp/loadup.el
Fmarker_position doc string clarification
[gnu-emacs] / lisp / loadup.el
index ef60130ca5143d0288b03cc1f398232909b75c8c..21c64a8c3b40167ad60b6564cc7d2af5dd4d694a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
 
-;; Copyright (C) 1985-1986, 1992, 1994, 2001-2015 Free Software
+;; Copyright (C) 1985-1986, 1992, 1994, 2001-2016 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: emacs-devel@gnu.org
 
 ;; This is loaded into a bare Emacs to make a dumpable one.
 
-;; If you add/remove Lisp files to be loaded here, consider the
-;; following issues:
+;; If you add a file to be loaded here, keep the following points in mind:
 
-;; i) Any file loaded on any platform should appear in $lisp in src/lisp.mk.
-;; Use the .el or .elc version as appropriate.
+;; i) If the file is no-byte-compile, explicitly load the .el version.
+;; Such files should (where possible) obey the doc-string conventions
+;; expected by make-docfile.  They should also be added to the
+;; uncompiled[] list in make-docfile.c.
 
+;; ii) If the file is dumped with Emacs (on any platform), put the
+;; load statement at the start of a line (leading whitespace is ok).
+
+;; iii) If the file is _not_ dumped with Emacs, make sure the load
+;; statement is _not_ at the start of a line.  See pcase for an example.
+
+;; These rules are so that src/Makefile can construct lisp.mk automatically.
 ;; This ensures both that the Lisp files are compiled (if necessary)
 ;; before the emacs executable is dumped, and that they are passed to
 ;; make-docfile.  (Any that are not processed for DOC will not have
-;; doc strings in the dumped Emacs.)  Because of this:
-
-;; ii) If the file is loaded uncompiled, it should (where possible)
-;; obey the doc-string conventions expected by make-docfile.  It
-;; should also be added to the uncompiled[] list in make-docfile.c.
+;; doc strings in the dumped Emacs.)
 
 ;;; Code:
 
+;; This is used in xdisp.c to determine when bidi reordering is safe.
+;; (It starts non-nil in temacs, but we set it non-nil here anyway, in
+;; case someone loads loadup one more time.)  We reset it after
+;; successfully loading charprop.el, which defines the Unicode tables
+;; bidi.c needs for its job.
+(setq redisplay--inhibit-bidi t)
+
 ;; Add subdirectories to the load-path for files that might get
 ;; autoloaded when bootstrapping.
 ;; This is because PATH_DUMPLOADSEARCH is just "../lisp".
-(if (or (equal (nth 3 command-line-args) "bootstrap")
-       (equal (nth 4 command-line-args) "bootstrap")
+(if (or (equal (member "bootstrap" command-line-args) '("bootstrap"))
        ;; FIXME this is irritatingly fragile.
        (equal (nth 4 command-line-args) "unidata-gen.el")
        (equal (nth 7 command-line-args) "unidata-gen-files")
                            (expand-file-name "textmodes" dir)
                            (expand-file-name "vc" dir)))))
 
+;; Prevent build-time PATH getting stored in the binary.
+;; Mainly cosmetic, but helpful for Guix.  (Bug#20330)
+(setq exec-path nil)
+
 (if (eq t purify-flag)
     ;; Hash consing saved around 11% of pure space in my tests.
-    (setq purify-flag (make-hash-table :test 'equal :size 70000)))
+    (setq purify-flag (make-hash-table :test 'equal :size 80000)))
 
 (message "Using load-path %s" load-path)
 
-(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
-       (member (nth 4 command-line-args) '("dump" "bootstrap")))
-    ;; To reduce the size of dumped Emacs, we avoid making huge
-    ;; char-tables.
-    (setq inhibit-load-charset-map t))
+;; This is a poor man's `last', since we haven't loaded subr.el yet.
+(if (or (equal (member "bootstrap" command-line-args) '("bootstrap"))
+       (equal (member "dump" command-line-args) '("dump")))
+    (progn
+      ;; To reduce the size of dumped Emacs, we avoid making huge char-tables.
+      (setq inhibit-load-charset-map t)
+      ;; --eval gets handled too late.
+      (defvar load--prefer-newer load-prefer-newer)
+      (setq load-prefer-newer t)))
 
 ;; We don't want to have any undo records in the dumped Emacs.
 (set-buffer "*scratch*")
 (load "env")
 (load "format")
 (load "bindings")
-;; This sets temporary-file-directory, used by eg
-;; auto-save-file-name-transforms in files.el.
-(load "cus-start")
 (load "window")  ; Needed here for `replace-buffer-in-windows'.
+;; We are now capable of resizing the mini-windows, so give the
+;; variable its advertised default value (it starts as nil, see
+;; xdisp.c).
+(setq resize-mini-windows 'grow-only)
 (setq load-source-file-function 'load-with-code-conversion)
 (load "files")
 
   ;; Since loaddefs is not yet loaded, macroexp's uses of pcase will simply
   ;; fail until pcase is explicitly loaded.  This also means that we have to
   ;; disable eager macro-expansion while loading pcase.
-  (let ((macroexp--pending-eager-loads '(skip)))
-    (load "emacs-lisp/pcase"))
+  (let ((macroexp--pending-eager-loads '(skip))) (load "emacs-lisp/pcase"))
   ;; Re-load macroexp so as to eagerly macro-expand its uses of pcase.
-  (load "emacs-lisp/macroexp"))
+  (let ((max-lisp-eval-depth (* 2 max-lisp-eval-depth)))
+    (load "emacs-lisp/macroexp")))
 
 (load "cus-face")
 (load "faces")  ; after here, `defface' may be used.
 
 (load "button")
-(load "startup")
 
 ;; We don't want to store loaddefs.el in the repository because it is
 ;; a generated file; but it is required in order to compile the lisp files.
 ;; should be updated by overwriting it with an up-to-date copy of
 ;; loaddefs.el that is uncorrupted by local changes.
 ;; autogen/update_autogen can be used to periodically update ldefs-boot.
-(condition-case nil
-    ;; Don't get confused if someone compiled this by mistake.
-    (load "loaddefs.el")
+(condition-case nil (load "loaddefs.el")
   ;; In case loaddefs hasn't been generated yet.
   (file-error (load "ldefs-boot.el")))
 
 (load "emacs-lisp/nadvice")
-(load "minibuffer")
+(load "emacs-lisp/cl-preloaded")
+(load "minibuffer")            ;After loaddefs, for define-minor-mode.
 (load "abbrev")         ;lisp-mode.el and simple.el use define-abbrev-table.
 (load "simple")
 
 (load "case-table")
 ;; This file doesn't exist when building a development version of Emacs
 ;; from the repository.  It is generated just after temacs is built.
-(load "international/charprop.el" t)
+(if (load "international/charprop.el" t)
+    (setq redisplay--inhibit-bidi nil))
 (load "international/characters")
 (load "composite")
 
 (load "language/romanian")
 (load "language/greek")
 (load "language/hebrew")
+(load "international/cp51932")
+(load "international/eucjp-ms")
 (load "language/japanese")
 (load "language/korean")
 (load "language/lao")
 (load "language/cham")
 
 (load "indent")
+(load "emacs-lisp/cl-generic")
 (load "frame")
+(load "startup")
 (load "term/tty-colors")
 (load "font-core")
 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
 (load "font-lock")
 (load "jit-lock")
 
-(if (fboundp 'track-mouse)
-    (progn
-      (load "mouse")
-      (and (boundp 'x-toolkit-scroll-bars)
-          (load "scroll-bar"))
-      (load "select")))
+(load "mouse")
+(if (boundp 'x-toolkit-scroll-bars)
+    (load "scroll-bar"))
+(load "select")
 (load "emacs-lisp/timer")
 (load "isearch")
 (load "rfn-eshadow")
 (load "textmodes/paragraphs")
 (load "progmodes/prog-mode")
 (load "emacs-lisp/lisp-mode")
+(load "progmodes/elisp-mode")
 (load "textmodes/text-mode")
 (load "textmodes/fill")
 (load "newcomment")
       (load "w32-vars")
       (load "term/w32-win")
       (load "disp-table")
-      (load "w32-common-fns")
       (when (eq system-type 'windows-nt)
         (load "w32-fns")
         (load "ls-lisp")
 (if (featurep 'ns)
     (progn
       (load "term/common-win")
-      (load "term/ns-win")))
+      ;; Don't load ucs-normalize.el unless uni-*.el files were
+      ;; already produced, because it needs uni-*.el files that might
+      ;; not be built early enough during bootstrap.
+      (when (load-history-filename-element "charprop\\.el")
+        (load "international/ucs-normalize")
+        (load "term/ns-win"))))
 (if (fboundp 'x-create-frame)
     ;; Do it after loading term/foo-win.el since the value of the
     ;; mouse-wheel-*-event vars depends on those files being loaded or not.
 (load "vc/ediff-hook")
 (load "uniquify")
 (load "electric")
-(if (not (eq system-type 'ms-dos)) (load "tooltip"))
+(load "emacs-lisp/eldoc")
+(load "cus-start") ;Late to reduce customize-rogue (needs loaddefs.el anyway)
+(if (not (eq system-type 'ms-dos))
+    (load "tooltip"))
 
 ;; This file doesn't exist when building a development version of Emacs
 ;; from the repository.  It is generated just after temacs is built.
@@ -308,17 +336,13 @@ lost after dumping")))
 ;; file primitive.  So the only workable solution to support building
 ;; in non-ASCII directories is to manipulate unibyte strings in the
 ;; current locale's encoding.
-(if (and (or (equal (nth 3 command-line-args) "dump")
-            (equal (nth 4 command-line-args) "dump")
-            (equal (nth 3 command-line-args) "bootstrap")
-            (equal (nth 4 command-line-args) "bootstrap"))
+(if (and (member (car (last command-line-args)) '("dump" "bootstrap"))
         (multibyte-string-p default-directory))
     (error "default-directory must be unibyte when dumping Emacs!"))
 
 ;; Determine which last version number to use
 ;; based on the executables that now exist.
-(if (and (or (equal (nth 3 command-line-args) "dump")
-            (equal (nth 4 command-line-args) "dump"))
+(if (and (equal (last command-line-args) '("dump"))
         (not (eq system-type 'ms-dos)))
     (let* ((base (concat "emacs-" emacs-version "."))
           (exelen (if (eq system-type 'windows-nt) -4))
@@ -337,8 +361,7 @@ lost after dumping")))
 
 
 (message "Finding pointers to doc strings...")
-(if (or (equal (nth 3 command-line-args) "dump")
-       (equal (nth 4 command-line-args) "dump"))
+(if (equal (last command-line-args) '("dump"))
     (Snarf-documentation "DOC")
   (condition-case nil
       (Snarf-documentation "DOC")
@@ -355,6 +378,8 @@ lost after dumping")))
 lost after dumping")))
 
 (setq current-load-list nil)
+;; Avoid storing references to build directory in the binary.
+(setq custom-current-group-alist nil)
 
 ;; We keep the load-history data in PURE space.
 ;; Make sure that the spine of the list is not in pure space because it can
@@ -365,6 +390,12 @@ lost after dumping")))
 
 (remove-hook 'after-load-functions (lambda (f) (garbage-collect)))
 
+(if (boundp 'load--prefer-newer)
+    (progn
+      (setq load-prefer-newer load--prefer-newer)
+      (put 'load-prefer-newer 'standard-value load--prefer-newer)
+      (makunbound 'load--prefer-newer)))
+
 (setq inhibit-load-charset-map nil)
 (clear-charset-maps)
 (garbage-collect)
@@ -396,8 +427,10 @@ lost after dumping")))
 (if (null (garbage-collect))
     (setq pure-space-overflow t))
 
-(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
-       (member (nth 4 command-line-args) '("dump" "bootstrap")))
+;; Make sure we will attempt bidi reordering henceforth.
+(setq redisplay--inhibit-bidi nil)
+
+(if (member (car (last command-line-args)) '("dump" "bootstrap"))
     (progn
       (message "Dumping under the name emacs")
       (condition-case ()
@@ -413,8 +446,7 @@ lost after dumping")))
       (if (not (or (eq system-type 'ms-dos)
                    ;; Don't bother adding another name if we're just
                    ;; building bootstrap-emacs.
-                   (equal (nth 3 command-line-args) "bootstrap")
-                   (equal (nth 4 command-line-args) "bootstrap")))
+                   (equal (last command-line-args) '("bootstrap"))))
          (let ((name (concat "emacs-" emacs-version))
                (exe (if (eq system-type 'windows-nt) ".exe" "")))
            (while (string-match "[^-+_.a-zA-Z0-9]+" name)
@@ -435,7 +467,7 @@ lost after dumping")))
 ;; this file must be loaded each time Emacs is run.
 ;; So run the startup code now.  First, remove `-l loadup' from args.
 
-(if (and (equal (nth 1 command-line-args) "-l")
+(if (and (member (nth 1 command-line-args) '("-l" "--load"))
         (equal (nth 2 command-line-args) "loadup"))
     (setcdr command-line-args (nthcdr 3 command-line-args)))