]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a new after-pdump-load-hook variable
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 12 Oct 2021 11:55:28 +0000 (13:55 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 12 Oct 2021 11:57:52 +0000 (13:57 +0200)
* doc/lispref/internals.texi (Building Emacs): Document it.

* lisp/subr.el (after-pdump-load-hook): New variable.
* src/emacs.c (main): Run the new hook.

* src/pdumper.c (syms_of_pdumper): Define a symbol.

doc/lispref/internals.texi
etc/NEWS
lisp/subr.el
src/emacs.c
src/pdumper.c

index d3edd633171c7d7e90632f917623934dbb4d9338..7718712b9b8f230ab0c0a5c2f3a4a7b248221b6d 100644 (file)
@@ -218,6 +218,14 @@ the Emacs executable that dumped them.
 
 If you want to use this function in an Emacs that was already dumped,
 you must run Emacs with the @samp{-batch} option.
+
+@vindex after-pdump-load-hook
+If you're including @samp{.el} files in the dumped Emacs and that
+@samp{.el} file has code that is normally run at load time, that code
+won't be run when Emacs starts after dumping.  To help work around
+that problem, you can put functions on the
+@code{after-pdump-load-hook} hook.  This hook is run when starting
+Emacs.
 @end defun
 
 @defun dump-emacs to-file from-file
index fe6f21fec2d054d353a2a4079257a5413f37a083..9daf958b07e8e81636a4866008150f65ba947dea 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -31,6 +31,12 @@ applies, and please also update docstrings as needed.
 ** Emacs now has a --fingerprint option.
 This will output a string identifying the current Emacs build.
 
++++
+** New hook 'after-pdump-load-hook'.
+This is run at the end of the Emacs startup process, and it meant to
+be used to reinitialize structures that would normally be done at load
+time.
+
 \f
 * Changes in Emacs 29.1
 
index 90f24a237fbfaecdbbcbcac3beaffdd30c162cfe..805c14eae3bf649393ee92eb0b1cb90972fbab63 100644 (file)
@@ -3568,6 +3568,9 @@ If either NAME or VAL are specified, both should be specified."
 (defvar suspend-resume-hook nil
   "Normal hook run by `suspend-emacs', after Emacs is continued.")
 
+(defvar after-pdump-load-hook nil
+  "Normal hook run after loading the .pdmp file.")
+
 (defvar temp-buffer-show-hook nil
   "Normal hook run by `with-output-to-temp-buffer' after displaying the buffer.
 When the hook runs, the temporary buffer is current, and the window it
index b178c6a06cfdd6b9bd7d52a45fd6e4cbd1e55ff1..1f6490fbc047998b7a329107075753b262d8ff10 100644 (file)
@@ -2333,6 +2333,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
   if (dump_mode)
     Vdump_mode = build_string (dump_mode);
 
+#ifdef HAVE_PDUMPER
+  /* Allow code to be run (mostly useful after redumping). */
+  safe_run_hooks (Qafter_pdump_load_hook);
+#endif
+
   /* Enter editor command loop.  This never returns.  */
   set_initial_minibuffer_mode ();
   Frecursive_edit ();
index 96fbd56a23643b6bfbedd1d1665f2a210c398756..6cf7b847cb7555d071aa53a4a1780df92e4f3705 100644 (file)
@@ -5706,6 +5706,7 @@ pdumper_load (const char *dump_filename, char *argv0)
     dump_mmap_release (&sections[i]);
   if (dump_fd >= 0)
     emacs_close (dump_fd);
+
   return err;
 }
 
@@ -5790,6 +5791,7 @@ syms_of_pdumper (void)
   DEFSYM (Qdumped_with_pdumper, "dumped-with-pdumper");
   DEFSYM (Qload_time, "load-time");
   DEFSYM (Qdump_file_name, "dump-file-name");
+  DEFSYM (Qafter_pdump_load_hook, "after-pdump-load-hook");
   defsubr (&Spdumper_stats);
 #endif /* HAVE_PDUMPER */
 }