From 5ab2792d5c19ccd2509e94a0ad3e024b6d33537e Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 11 Sep 2023 01:40:30 +0200 Subject: [PATCH] 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) --- doc/lispref/variables.texi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index f7322e11365..5de5ac6efa7 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -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