Update defvar usage tips example in manual
* doc/lispref/variables.texi (Tips for Defining): Change example to be about syntax tables instead of old way of defining keymaps using 'defvar' and 'make-sparse-keymap'. (Bug#59224)
This commit is contained in:
parent
35d88c657e
commit
5ab2792d5c
1 changed files with 8 additions and 8 deletions
|
@ -678,15 +678,15 @@ which are being phased out.)
|
||||||
it as safe or risky; see @ref{File Local Variables}.
|
it as safe or risky; see @ref{File Local Variables}.
|
||||||
|
|
||||||
When defining and initializing a variable that holds a complicated
|
When defining and initializing a variable that holds a complicated
|
||||||
value (such as a keymap with bindings in it), it's best to put the
|
value (such as a syntax table for a major mode), it's best to put the
|
||||||
entire computation of the value into the @code{defvar}, like this:
|
entire computation of the value into the @code{defvar}, like this:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
(defvar my-mode-map
|
(defvar my-major-mode-syntax-table
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((table (make-syntax-table)))
|
||||||
(keymap-set map "C-c C-a" 'my-command)
|
(modify-syntax-entry ?# "<" table)
|
||||||
@dots{}
|
@dots{}
|
||||||
map)
|
table)
|
||||||
@var{docstring})
|
@var{docstring})
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@ -696,9 +696,9 @@ loading the file, the variable is either still uninitialized or
|
||||||
initialized properly, never in-between. If it is still uninitialized,
|
initialized properly, never in-between. If it is still uninitialized,
|
||||||
reloading the file will initialize it properly. Second, reloading the
|
reloading the file will initialize it properly. Second, reloading the
|
||||||
file once the variable is initialized will not alter it; that is
|
file once the variable is initialized will not alter it; that is
|
||||||
important if the user has run hooks to alter part of the contents
|
important if the user has changed its value. Third, evaluating the
|
||||||
(such as, to rebind keys). Third, evaluating the @code{defvar} form
|
@code{defvar} form with @kbd{C-M-x} will reinitialize the variable
|
||||||
with @kbd{C-M-x} will reinitialize the map completely.
|
completely.
|
||||||
|
|
||||||
@node Accessing Variables
|
@node Accessing Variables
|
||||||
@section Accessing Variable Values
|
@section Accessing Variable Values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue