mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
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
@ -678,15 +678,15 @@ which are being phased out.)
|
||||
it as safe or risky; see @ref{File Local Variables}.
|
||||
|
||||
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:
|
||||
|
||||
@example
|
||||
(defvar my-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(keymap-set map "C-c C-a" 'my-command)
|
||||
(defvar my-major-mode-syntax-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(modify-syntax-entry ?# "<" table)
|
||||
@dots{}
|
||||
map)
|
||||
table)
|
||||
@var{docstring})
|
||||
@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,
|
||||
reloading the file will initialize it properly. Second, reloading the
|
||||
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
|
||||
(such as, to rebind keys). Third, evaluating the @code{defvar} form
|
||||
with @kbd{C-M-x} will reinitialize the map completely.
|
||||
important if the user has changed its value. Third, evaluating the
|
||||
@code{defvar} form with @kbd{C-M-x} will reinitialize the variable
|
||||
completely.
|
||||
|
||||
@node Accessing Variables
|
||||
@section Accessing Variable Values
|
||||
|
Loading…
Reference in New Issue
Block a user