From 5c5aad07106282d3534823d9212f800918bc5df8 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Wed, 8 Apr 1998 18:56:20 +0000 Subject: [PATCH] (keyword_symbols_constant_flag): New variable. (syms_of_data): Set up Lisp variable. (set_internal): Obey it and give error for :-symbols. (Fmakunbound): Likewise. --- src/data.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/data.c b/src/data.c index c9eaee7a9b2..5b3a33bddfa 100644 --- a/src/data.c +++ b/src/data.c @@ -68,6 +68,10 @@ Boston, MA 02111-1307, USA. */ extern double atof (); #endif /* !atof */ +/* Nonzero means it is an error to set a symbol whose name starts with + colon. */ +int keyword_symbols_constant_flag; + Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range; @@ -611,7 +615,9 @@ DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, "Make SYMBOL's value be register Lisp_Object symbol; { CHECK_SYMBOL (symbol, 0); - if (NILP (symbol) || EQ (symbol, Qt)) + if (NILP (symbol) || EQ (symbol, Qt) + || (XSYMBOL (symbol)->name->data[0] == ':' + && keyword_symbols_constant_flag)) return Fsignal (Qsetting_constant, Fcons (symbol, Qnil)); Fset (symbol, Qunbound); return symbol; @@ -960,7 +966,9 @@ set_internal (symbol, newval, bindflag) register Lisp_Object valcontents, tem1, current_alist_element; CHECK_SYMBOL (symbol, 0); - if (NILP (symbol) || EQ (symbol, Qt)) + if (NILP (symbol) || EQ (symbol, Qt) + || (XSYMBOL (symbol)->name->data[0] == ':' + && keyword_symbols_constant_flag)) return Fsignal (Qsetting_constant, Fcons (symbol, Qnil)); valcontents = XSYMBOL (symbol)->value; @@ -2833,6 +2841,11 @@ syms_of_data () staticpro (&Qchar_table); staticpro (&Qbool_vector); + DEFVAR_BOOL ("keyword-symbols-constant-flag", &keyword_symbols_constant_flag, + "Non-nil means it is an error to set a keyword symbol.\n\ +A keyword symbol is a symbol whose name starts with a colon (`:')."); + keyword_symbols_constant_flag = 1; + defsubr (&Seq); defsubr (&Snull); defsubr (&Stype_of); -- 2.39.2