diff options
| author | Eli Zaretskii | 2017-11-26 20:23:15 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-11-26 20:23:15 +0200 |
| commit | 16358d4fcbad3fa60ff36167ae666b1ec7e7c02a (patch) | |
| tree | fe8f563ab7c0bb7e43992e2db7e4ddea857dda1a | |
| parent | a89f0b6f33f9eb8910a1fceda9028d76ef50b05d (diff) | |
| download | emacs-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.texi | 7 | ||||
| -rw-r--r-- | doc/lispref/variables.texi | 13 | ||||
| -rw-r--r-- | src/buffer.c | 2 | ||||
| -rw-r--r-- | src/data.c | 6 | ||||
| -rw-r--r-- | src/font.c | 9 |
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 |
| 174 | The message is @samp{Attempt to set a constant symbol}. This happens | 174 | The message is @samp{Attempt to set a constant symbol}. This happens |
| 175 | when attempting to assign values to @code{nil}, @code{t}, and keyword | 175 | when attempting to assign values to @code{nil}, @code{t}, |
| 176 | symbols. @xref{Constant Variables}. | 176 | @code{most-positive-fixnum}, @code{most-negative-fixnum}, and keyword |
| 177 | symbols. It also happens when attempting to assign values to | ||
| 178 | @code{enable-multibyte-characters} and some other symbols whose direct | ||
| 179 | assignment 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 | |||
| 139 | that you do not intend to change the value of a variable, but Emacs | 139 | that you do not intend to change the value of a variable, but Emacs |
| 140 | does not raise an error if you actually change it. | 140 | does not raise an error if you actually change it. |
| 141 | 141 | ||
| 142 | @cindex read-only variables | ||
| 143 | A small number of additional symbols are made read-only for various | ||
| 144 | practical reasons. These include @code{enable-multibyte-characters}, | ||
| 145 | @code{most-positive-fixnum}, @code{most-negative-fixnum}, and a few | ||
| 146 | others. 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 | |||
| 1355 | because @code{let} does not distinguish between different kinds of | 1362 | because @code{let} does not distinguish between different kinds of |
| 1356 | bindings; it knows only which variable the binding was made for. | 1363 | bindings; it knows only which variable the binding was made for. |
| 1357 | 1364 | ||
| 1365 | It is an error to make a constant or a read-only variable | ||
| 1366 | buffer-local. @xref{Constant Variables}. | ||
| 1367 | |||
| 1358 | If the variable is terminal-local (@pxref{Multiple Terminals}), this | 1368 | If the variable is terminal-local (@pxref{Multiple Terminals}), this |
| 1359 | function signals an error. Such variables cannot have buffer-local | 1369 | function signals an error. Such variables cannot have buffer-local |
| 1360 | bindings as well. | 1370 | bindings as well. |
| @@ -1394,6 +1404,9 @@ in a void buffer-local value and leave the default value unaffected. | |||
| 1394 | 1404 | ||
| 1395 | The value returned is @var{variable}. | 1405 | The value returned is @var{variable}. |
| 1396 | 1406 | ||
| 1407 | It is an error to make a constant or a read-only variable | ||
| 1408 | buffer-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 |
| 1399 | because users @emph{might} want to customize them differently in | 1412 | because 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 | ||
| 5621 | This variable is buffer-local but you cannot set it directly; | 5621 | This variable is buffer-local but you cannot set it directly; |
| 5622 | use the function `set-buffer-multibyte' to change a buffer's representation. | 5622 | use the function `set-buffer-multibyte' to change a buffer's representation. |
| 5623 | To prevent any attempts to set it or make it buffer-local, Emacs will | ||
| 5624 | signal an error in those cases. | ||
| 5623 | See also Info node `(elisp)Text Representations'. */); | 5625 | See 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. |
| 3884 | This 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. |
| 3890 | This 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. |
| 5422 | Each element has the form: | 5422 | Each element has the form: |
| 5423 | [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] | 5423 | [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] |
| 5424 | NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. */); | 5424 | NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. |
| 5425 | This 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. |
| 5430 | See `font-weight-table' for the format of the vector. */); | 5431 | See `font-weight-table' for the format of the vector. |
| 5432 | This 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. |
| 5436 | See `font-weight-table' for the format of the vector. */); | 5438 | See `font-weight-table' for the format of the vector. |
| 5439 | This 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 | ||