diff options
| author | Stefan Kangas | 2023-09-11 01:40:30 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2023-09-11 01:49:36 +0200 |
| commit | 5ab2792d5c19ccd2509e94a0ad3e024b6d33537e (patch) | |
| tree | 88998d2298afeb820469ad54a5acca625bda123b | |
| parent | 35d88c657e15a762cb37ee354c63f1540c035268 (diff) | |
| download | emacs-5ab2792d5c19ccd2509e94a0ad3e024b6d33537e.tar.gz emacs-5ab2792d5c19ccd2509e94a0ad3e024b6d33537e.zip | |
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)
| -rw-r--r-- | doc/lispref/variables.texi | 16 |
1 files 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.) | |||
| 678 | it as safe or risky; see @ref{File Local Variables}. | 678 | it as safe or risky; see @ref{File Local Variables}. |
| 679 | 679 | ||
| 680 | When defining and initializing a variable that holds a complicated | 680 | When defining and initializing a variable that holds a complicated |
| 681 | value (such as a keymap with bindings in it), it's best to put the | 681 | value (such as a syntax table for a major mode), it's best to put the |
| 682 | entire computation of the value into the @code{defvar}, like this: | 682 | entire computation of the value into the @code{defvar}, like this: |
| 683 | 683 | ||
| 684 | @example | 684 | @example |
| 685 | (defvar my-mode-map | 685 | (defvar my-major-mode-syntax-table |
| 686 | (let ((map (make-sparse-keymap))) | 686 | (let ((table (make-syntax-table))) |
| 687 | (keymap-set map "C-c C-a" 'my-command) | 687 | (modify-syntax-entry ?# "<" table) |
| 688 | @dots{} | 688 | @dots{} |
| 689 | map) | 689 | table) |
| 690 | @var{docstring}) | 690 | @var{docstring}) |
| 691 | @end example | 691 | @end example |
| 692 | 692 | ||
| @@ -696,9 +696,9 @@ loading the file, the variable is either still uninitialized or | |||
| 696 | initialized properly, never in-between. If it is still uninitialized, | 696 | initialized properly, never in-between. If it is still uninitialized, |
| 697 | reloading the file will initialize it properly. Second, reloading the | 697 | reloading the file will initialize it properly. Second, reloading the |
| 698 | file once the variable is initialized will not alter it; that is | 698 | file once the variable is initialized will not alter it; that is |
| 699 | important if the user has run hooks to alter part of the contents | 699 | important if the user has changed its value. Third, evaluating the |
| 700 | (such as, to rebind keys). Third, evaluating the @code{defvar} form | 700 | @code{defvar} form with @kbd{C-M-x} will reinitialize the variable |
| 701 | with @kbd{C-M-x} will reinitialize the map completely. | 701 | completely. |
| 702 | 702 | ||
| 703 | @node Accessing Variables | 703 | @node Accessing Variables |
| 704 | @section Accessing Variable Values | 704 | @section Accessing Variable Values |