aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2017-11-26 20:23:15 +0200
committerEli Zaretskii2017-11-26 20:23:15 +0200
commit16358d4fcbad3fa60ff36167ae666b1ec7e7c02a (patch)
treefe8f563ab7c0bb7e43992e2db7e4ddea857dda1a
parenta89f0b6f33f9eb8910a1fceda9028d76ef50b05d (diff)
downloademacs-16358d4fcbad3fa60ff36167ae666b1ec7e7c02a.tar.gz
emacs-16358d4fcbad3fa60ff36167ae666b1ec7e7c02a.zip
Improve documentation of "constant" symbols
* src/font.c (syms_of_font) <font-weight-table, font-slant-table> <font-width-table>: * src/data.c (syms_of_data) <most-positive-fixnum> <most-negative-fixnum>: * src/buffer.c (syms_of_buffer) <enable-multibyte-characters>: Mention in the doc strings that these variables are read-only. * doc/lispref/variables.texi (Creating Buffer-Local): Document that making a constant variable buffer-local signals an error. * doc/lispref/variables.texi (Constant Variables): * doc/lispref/errors.texi (Standard Errors): More accurate and up-to-date documentation of which symbols cannot be assigned values.
-rw-r--r--doc/lispref/errors.texi7
-rw-r--r--doc/lispref/variables.texi13
-rw-r--r--src/buffer.c2
-rw-r--r--src/data.c6
-rw-r--r--src/font.c9
5 files changed, 30 insertions, 7 deletions
diff --git a/doc/lispref/errors.texi b/doc/lispref/errors.texi
index 1f67819c34e..cd22b70800d 100644
--- a/doc/lispref/errors.texi
+++ b/doc/lispref/errors.texi
@@ -172,8 +172,11 @@ The message is @samp{Search failed}. @xref{Searching and Matching}.
172 172
173@item setting-constant 173@item setting-constant
174The message is @samp{Attempt to set a constant symbol}. This happens 174The message is @samp{Attempt to set a constant symbol}. This happens
175when attempting to assign values to @code{nil}, @code{t}, and keyword 175when attempting to assign values to @code{nil}, @code{t},
176symbols. @xref{Constant Variables}. 176@code{most-positive-fixnum}, @code{most-negative-fixnum}, and keyword
177symbols. It also happens when attempting to assign values to
178@code{enable-multibyte-characters} and some other symbols whose direct
179assignment is not allowed for some reason. @xref{Constant Variables}.
177 180
178@c simple.el 181@c simple.el
179@item text-read-only 182@item text-read-only
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 99bbfc91243..a871352b004 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -139,6 +139,13 @@ Variables}). A @code{defconst} form serves to inform human readers
139that you do not intend to change the value of a variable, but Emacs 139that you do not intend to change the value of a variable, but Emacs
140does not raise an error if you actually change it. 140does not raise an error if you actually change it.
141 141
142@cindex read-only variables
143A small number of additional symbols are made read-only for various
144practical reasons. These include @code{enable-multibyte-characters},
145@code{most-positive-fixnum}, @code{most-negative-fixnum}, and a few
146others. Any attempt to set or bind these also signals a
147@code{setting-constant} error.
148
142@node Local Variables 149@node Local Variables
143@section Local Variables 150@section Local Variables
144@cindex binding local variables 151@cindex binding local variables
@@ -1355,6 +1362,9 @@ is not current either on entry to or exit from the @code{let}. This is
1355because @code{let} does not distinguish between different kinds of 1362because @code{let} does not distinguish between different kinds of
1356bindings; it knows only which variable the binding was made for. 1363bindings; it knows only which variable the binding was made for.
1357 1364
1365It is an error to make a constant or a read-only variable
1366buffer-local. @xref{Constant Variables}.
1367
1358If the variable is terminal-local (@pxref{Multiple Terminals}), this 1368If the variable is terminal-local (@pxref{Multiple Terminals}), this
1359function signals an error. Such variables cannot have buffer-local 1369function signals an error. Such variables cannot have buffer-local
1360bindings as well. 1370bindings as well.
@@ -1394,6 +1404,9 @@ in a void buffer-local value and leave the default value unaffected.
1394 1404
1395The value returned is @var{variable}. 1405The value returned is @var{variable}.
1396 1406
1407It is an error to make a constant or a read-only variable
1408buffer-local. @xref{Constant Variables}.
1409
1397@strong{Warning:} Don't assume that you should use 1410@strong{Warning:} Don't assume that you should use
1398@code{make-variable-buffer-local} for user-option variables, simply 1411@code{make-variable-buffer-local} for user-option variables, simply
1399because users @emph{might} want to customize them differently in 1412because users @emph{might} want to customize them differently in
diff --git a/src/buffer.c b/src/buffer.c
index 6e3412c3d05..c6f9eb28e25 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5620,6 +5620,8 @@ file I/O and the behavior of various editing commands.
5620 5620
5621This variable is buffer-local but you cannot set it directly; 5621This variable is buffer-local but you cannot set it directly;
5622use the function `set-buffer-multibyte' to change a buffer's representation. 5622use the function `set-buffer-multibyte' to change a buffer's representation.
5623To prevent any attempts to set it or make it buffer-local, Emacs will
5624signal an error in those cases.
5623See also Info node `(elisp)Text Representations'. */); 5625See also Info node `(elisp)Text Representations'. */);
5624 make_symbol_constant (intern_c_string ("enable-multibyte-characters")); 5626 make_symbol_constant (intern_c_string ("enable-multibyte-characters"));
5625 5627
diff --git a/src/data.c b/src/data.c
index b4f6fd5c652..d54c46d72bf 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3880,12 +3880,14 @@ syms_of_data (void)
3880 set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->u.s.function); 3880 set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->u.s.function);
3881 3881
3882 DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum, 3882 DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum,
3883 doc: /* The largest value that is representable in a Lisp integer. */); 3883 doc: /* The largest value that is representable in a Lisp integer.
3884This variable cannot be set; trying to do so will signal an error. */);
3884 Vmost_positive_fixnum = make_number (MOST_POSITIVE_FIXNUM); 3885 Vmost_positive_fixnum = make_number (MOST_POSITIVE_FIXNUM);
3885 make_symbol_constant (intern_c_string ("most-positive-fixnum")); 3886 make_symbol_constant (intern_c_string ("most-positive-fixnum"));
3886 3887
3887 DEFVAR_LISP ("most-negative-fixnum", Vmost_negative_fixnum, 3888 DEFVAR_LISP ("most-negative-fixnum", Vmost_negative_fixnum,
3888 doc: /* The smallest value that is representable in a Lisp integer. */); 3889 doc: /* The smallest value that is representable in a Lisp integer.
3890This variable cannot be set; trying to do so will signal an error. */);
3889 Vmost_negative_fixnum = make_number (MOST_NEGATIVE_FIXNUM); 3891 Vmost_negative_fixnum = make_number (MOST_NEGATIVE_FIXNUM);
3890 make_symbol_constant (intern_c_string ("most-negative-fixnum")); 3892 make_symbol_constant (intern_c_string ("most-negative-fixnum"));
3891 3893
diff --git a/src/font.c b/src/font.c
index 51625b49fa8..f7cebdce78c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -5421,19 +5421,22 @@ gets the repertory information by an opened font and ENCODING. */);
5421 doc: /* Vector of valid font weight values. 5421 doc: /* Vector of valid font weight values.
5422Each element has the form: 5422Each element has the form:
5423 [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] 5423 [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...]
5424NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. */); 5424NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols.
5425This variable cannot be set; trying to do so will signal an error. */);
5425 Vfont_weight_table = BUILD_STYLE_TABLE (weight_table); 5426 Vfont_weight_table = BUILD_STYLE_TABLE (weight_table);
5426 make_symbol_constant (intern_c_string ("font-weight-table")); 5427 make_symbol_constant (intern_c_string ("font-weight-table"));
5427 5428
5428 DEFVAR_LISP_NOPRO ("font-slant-table", Vfont_slant_table, 5429 DEFVAR_LISP_NOPRO ("font-slant-table", Vfont_slant_table,
5429 doc: /* Vector of font slant symbols vs the corresponding numeric values. 5430 doc: /* Vector of font slant symbols vs the corresponding numeric values.
5430See `font-weight-table' for the format of the vector. */); 5431See `font-weight-table' for the format of the vector.
5432This variable cannot be set; trying to do so will signal an error. */);
5431 Vfont_slant_table = BUILD_STYLE_TABLE (slant_table); 5433 Vfont_slant_table = BUILD_STYLE_TABLE (slant_table);
5432 make_symbol_constant (intern_c_string ("font-slant-table")); 5434 make_symbol_constant (intern_c_string ("font-slant-table"));
5433 5435
5434 DEFVAR_LISP_NOPRO ("font-width-table", Vfont_width_table, 5436 DEFVAR_LISP_NOPRO ("font-width-table", Vfont_width_table,
5435 doc: /* Alist of font width symbols vs the corresponding numeric values. 5437 doc: /* Alist of font width symbols vs the corresponding numeric values.
5436See `font-weight-table' for the format of the vector. */); 5438See `font-weight-table' for the format of the vector.
5439This variable cannot be set; trying to do so will signal an error. */);
5437 Vfont_width_table = BUILD_STYLE_TABLE (width_table); 5440 Vfont_width_table = BUILD_STYLE_TABLE (width_table);
5438 make_symbol_constant (intern_c_string ("font-width-table")); 5441 make_symbol_constant (intern_c_string ("font-width-table"));
5439 5442