emacs-diffs
[Top][All Lists]
Advanced

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

scratch/pkg a3c2746c0ef: Make sure *package* is buffer-local


From: Gerd Moellmann
Subject: scratch/pkg a3c2746c0ef: Make sure *package* is buffer-local
Date: Tue, 5 Dec 2023 04:01:26 -0500 (EST)

branch: scratch/pkg
commit a3c2746c0ef7f48e3a15799746741dda50395b5f
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>

    Make sure *package* is buffer-local
    
    * src/pkg.c (pkg_in_emacs_package): New function.
    * src/lisp.h: Declare it.
    * src/eval.c (run_hook_with_args): Use it.
    * src/lread.c (Fload): Use it.
    * src/xdisp.c (handle_fontified_prop): Use it.
---
 src/eval.c  |  2 +-
 src/lisp.h  |  1 +
 src/lread.c |  2 +-
 src/pkg.c   | 11 +++++++++++
 src/xdisp.c |  2 +-
 5 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 540da7dd0bf..1b8e0c248e2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2874,7 +2874,7 @@ run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args,
     return ret;
 
   specpdl_ref count = SPECPDL_INDEX ();
-  specbind (Qearmuffs_package, Vemacs_package);
+  pkg_in_emacs_package ();
 
   if (!CONSP (val) || FUNCTIONP (val))
     {
diff --git a/src/lisp.h b/src/lisp.h
index 54dd12bf291..b4792e03f8c 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2311,6 +2311,7 @@ extern void pkg_define_builtin_symbols (void);
 extern void pkg_map_symbols_c_fn (void (*fn) (Lisp_Object, Lisp_Object), 
Lisp_Object arg);
 extern Lisp_Object pkg_find_package (Lisp_Object name);
 extern Lisp_Object pkg_find_symbol (Lisp_Object name, Lisp_Object package, 
Lisp_Object *status);
+extern void pkg_in_emacs_package (void);
 
 
 /* Return whether a value might be a valid docstring.
diff --git a/src/lread.c b/src/lread.c
index e6ef7930f50..aafeb601075 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1585,7 +1585,7 @@ Return t if the file exists and loads successfully.  */)
      Vload_source_file_function.  */
   specbind (Qlexical_binding, Qnil);
   specbind (Qsymbol_packages, Qnil);
-  specbind (Qearmuffs_package, Vemacs_package);
+  pkg_in_emacs_package ();
 
   Lisp_Object found_eff =
     is_native_elisp
diff --git a/src/pkg.c b/src/pkg.c
index 272a2b5868f..c00a8a4d032 100644
--- a/src/pkg.c
+++ b/src/pkg.c
@@ -1001,6 +1001,17 @@ DEFUN ("test-completion-in-all-packages",
   return Qnil;
 }
 
+/* Bind *package* to the emacs package, but make sure that we have a
+   buffer-local *package*, so that we can change the value with
+   set-buffer-local-value.  */
+
+void
+pkg_in_emacs_package (void)
+{
+  Fmake_local_variable (Qearmuffs_package);
+  specbind (Qearmuffs_package, Vemacs_package);
+}
+
 
 /***********************************************************************
                            Initialization
diff --git a/src/xdisp.c b/src/xdisp.c
index c73e648f2d7..d123e273643 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4591,7 +4591,7 @@ handle_fontified_prop (struct it *it)
 
       val = Vfontification_functions;
       specbind (Qfontification_functions, Qnil);
-      specbind (Qearmuffs_package, Vemacs_package);
+      pkg_in_emacs_package ();
 
       eassert (it->end_charpos == ZV);
 



reply via email to

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