emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6d68fbd 1/2: Add a new after-pdump-load-hook variable


From: Lars Ingebrigtsen
Subject: master 6d68fbd 1/2: Add a new after-pdump-load-hook variable
Date: Tue, 12 Oct 2021 07:57:58 -0400 (EDT)

branch: master
commit 6d68fbd57f730051dd3af470e7b0c41b41238bd0
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a new after-pdump-load-hook variable
    
    * 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 | 8 ++++++++
 etc/NEWS                   | 6 ++++++
 lisp/subr.el               | 3 +++
 src/emacs.c                | 5 +++++
 src/pdumper.c              | 2 ++
 5 files changed, 24 insertions(+)

diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index d3edd63..7718712 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index fe6f21f..9daf958 100644
--- 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.
+
 
 * Changes in Emacs 29.1
 
diff --git a/lisp/subr.el b/lisp/subr.el
index 90f24a2..805c14e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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
diff --git a/src/emacs.c b/src/emacs.c
index b178c6a..1f6490f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -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 ();
diff --git a/src/pdumper.c b/src/pdumper.c
index 96fbd56..6cf7b84 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -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 */
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]