aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorJens Schmidt2025-03-14 23:07:11 +0100
committerStefan Monnier2025-03-16 12:52:40 -0400
commit7f2e4508cebe76a885b72ca4789ae839d5bd45e1 (patch)
treeb219eb77c73eed956415017dafa9272b784bcdc2 /src/eval.c
parentb8104dadbf285d12c356d4cddd28ac3eaf05f263 (diff)
downloademacs-7f2e4508cebe76a885b72ca4789ae839d5bd45e1.tar.gz
emacs-7f2e4508cebe76a885b72ca4789ae839d5bd45e1.zip
Correctly unload variable aliases.
* src/eval.c (Finternal_delete_indirect_variable): Add function. * lisp/loadhist.el (loadhist-unload-element): Use it for variable aliases. * test/src/eval-tests.el (eval-tests--internal-delete-indirect-variable): Test function `internal-delete-indirect-variable'. * test/lisp/loadhist-tests.el (loadhist-test-unload-feature-alias): * test/lisp/loadhist-resources/loadhist--alias.el: Test unloading of features that define variable aliases. (Bug#76748)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 5de723cf3bc..335fdae8ab9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -720,6 +720,24 @@ signal a `cyclic-variable-indirection' error. */)
720 return base_variable; 720 return base_variable;
721} 721}
722 722
723DEFUN ("internal-delete-indirect-variable", Finternal_delete_indirect_variable, Sinternal_delete_indirect_variable,
724 1, 1, 0,
725 doc: /* Internal use only.
726Undeclare SYMBOL as variable alias, then unbind it.
727Return SYMBOL. */)
728 (register Lisp_Object symbol)
729{
730 CHECK_SYMBOL (symbol);
731 if (XSYMBOL (symbol)->u.s.redirect != SYMBOL_VARALIAS)
732 xsignal2 (Qerror,
733 build_string ("Cannot undeclare a variable that is not an alias"),
734 symbol);
735 XSYMBOL (symbol)->u.s.redirect = SYMBOL_PLAINVAL;
736 Fput (symbol, Qvariable_documentation, Qnil);
737 Fset (symbol, Qunbound);
738 return symbol;
739}
740
723static union specbinding * 741static union specbinding *
724default_toplevel_binding (Lisp_Object symbol) 742default_toplevel_binding (Lisp_Object symbol)
725{ 743{
@@ -4488,6 +4506,7 @@ alist of active lexical bindings. */);
4488 defsubr (&Sdefvar_1); 4506 defsubr (&Sdefvar_1);
4489 defsubr (&Sdefvaralias); 4507 defsubr (&Sdefvaralias);
4490 DEFSYM (Qdefvaralias, "defvaralias"); 4508 DEFSYM (Qdefvaralias, "defvaralias");
4509 defsubr (&Sinternal_delete_indirect_variable);
4491 defsubr (&Sdefconst); 4510 defsubr (&Sdefconst);
4492 defsubr (&Sdefconst_1); 4511 defsubr (&Sdefconst_1);
4493 defsubr (&Sinternal__define_uninitialized_variable); 4512 defsubr (&Sinternal__define_uninitialized_variable);