diff options
| author | Glenn Morris | 2020-04-20 07:50:19 -0700 |
|---|---|---|
| committer | Glenn Morris | 2020-04-20 07:50:19 -0700 |
| commit | 477b9eaf45da1ebc4f2117d69df3571f0bf61e47 (patch) | |
| tree | 4600314923713c339c41cd450f50e64c3f16a8aa /doc/lispintro | |
| parent | 80f04b5d7c817977a365a999693443c4e04e5223 (diff) | |
| parent | 05089a4d65831c5e873956f5f2d92a3d5672d405 (diff) | |
| download | emacs-477b9eaf45da1ebc4f2117d69df3571f0bf61e47.tar.gz emacs-477b9eaf45da1ebc4f2117d69df3571f0bf61e47.zip | |
Merge from origin/emacs-27
05089a4d65 (origin/emacs-27) Tweak wording re constant variables
a1040861f1 Tweak setcar-related wording
751510f865 * lisp/image-mode.el: Add prefix key 's' and reduce depend...
9261a219ec * doc/emacs/windows.texi (Window Convenience): Decribe mor...
e1d42da0d6 Fix mutability glitches reported by Drew Adams
5805df74f5 Improve mutability doc
dca35b31d0 Improve mutability documentation
81e7d7f111 Document that quoting yields constants
5734339f40 * doc/lispref/keymaps.texi (Extended Menu Items, Easy Menu...
14a570afae Remove #' and function quoting from lambda forms in manual
d5ec18c66b * src/regex-emacs.c (re_match_2_internal): Rework comment ...
4df8a61117 Add new node "Image Mode" to Emacs Manual.
d7d5ee6c57 ; Fix a typo in cmdargs.texi (bug#40701)
5e9db48fbe * doc/lispref/display.texi (Customizing Bitmaps): Fix typo.
eebfb72c90 Document constant vs mutable objects better
6c187ed6b0 Improve documentation of 'sort-lines'
52288f4b66 Mention 'spam-stat-process-directory-age' in the documenta...
067b070598 ; Fix some typos and doc issues (bug#40695)
# Conflicts:
# etc/NEWS
Diffstat (limited to 'doc/lispintro')
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index 1726936de10..7484ce57607 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi | |||
| @@ -2329,7 +2329,7 @@ area. | |||
| 2329 | 2329 | ||
| 2330 | @cindex @samp{bind} defined | 2330 | @cindex @samp{bind} defined |
| 2331 | There are several ways by which a variable can be given a value. One of | 2331 | There are several ways by which a variable can be given a value. One of |
| 2332 | the ways is to use either the function @code{set} or the function | 2332 | the ways is to use either the function @code{set} or the special form |
| 2333 | @code{setq}. Another way is to use @code{let} (@pxref{let}). (The | 2333 | @code{setq}. Another way is to use @code{let} (@pxref{let}). (The |
| 2334 | jargon for this process is to @dfn{bind} a variable to a value.) | 2334 | jargon for this process is to @dfn{bind} a variable to a value.) |
| 2335 | 2335 | ||
| @@ -4517,7 +4517,7 @@ number; it will be printed as the character with that @sc{ascii} code. | |||
| 4517 | 4517 | ||
| 4518 | @item setq | 4518 | @item setq |
| 4519 | @itemx set | 4519 | @itemx set |
| 4520 | The @code{setq} function sets the value of its first argument to the | 4520 | The @code{setq} special form sets the value of its first argument to the |
| 4521 | value of the second argument. The first argument is automatically | 4521 | value of the second argument. The first argument is automatically |
| 4522 | quoted by @code{setq}. It does the same for succeeding pairs of | 4522 | quoted by @code{setq}. It does the same for succeeding pairs of |
| 4523 | arguments. Another function, @code{set}, takes only two arguments and | 4523 | arguments. Another function, @code{set}, takes only two arguments and |
| @@ -7317,11 +7317,21 @@ which leave the original list as it was. One way to find out how this | |||
| 7317 | works is to experiment. We will start with the @code{setcar} function. | 7317 | works is to experiment. We will start with the @code{setcar} function. |
| 7318 | 7318 | ||
| 7319 | @need 1200 | 7319 | @need 1200 |
| 7320 | @cindex constant lists | ||
| 7321 | @cindex mutable lists | ||
| 7320 | First, we can make a list and then set the value of a variable to the | 7322 | First, we can make a list and then set the value of a variable to the |
| 7321 | list, using the @code{setq} function. Here is a list of animals: | 7323 | list, using the @code{setq} special form. Because we intend to use |
| 7324 | @code{setcar} to change the list, this @code{setq} should not use the | ||
| 7325 | quoted form @code{'(antelope giraffe lion tiger)}, as that would yield | ||
| 7326 | a list that is part of the program and bad things could happen if we | ||
| 7327 | tried to change part of the program while running it. Generally | ||
| 7328 | speaking an Emacs Lisp program's components should be constant (or | ||
| 7329 | unchanged) while the program is running. So we instead construct an | ||
| 7330 | animal list that is @dfn{mutable} (or changeable) by using the | ||
| 7331 | @code{list} function, as follows: | ||
| 7322 | 7332 | ||
| 7323 | @smallexample | 7333 | @smallexample |
| 7324 | (setq animals '(antelope giraffe lion tiger)) | 7334 | (setq animals (list 'antelope 'giraffe 'lion 'tiger)) |
| 7325 | @end smallexample | 7335 | @end smallexample |
| 7326 | 7336 | ||
| 7327 | @noindent | 7337 | @noindent |
| @@ -7398,7 +7408,7 @@ To see how this works, set the value of the variable to a list of | |||
| 7398 | domesticated animals by evaluating the following expression: | 7408 | domesticated animals by evaluating the following expression: |
| 7399 | 7409 | ||
| 7400 | @smallexample | 7410 | @smallexample |
| 7401 | (setq domesticated-animals '(horse cow sheep goat)) | 7411 | (setq domesticated-animals (list 'horse 'cow 'sheep 'goat)) |
| 7402 | @end smallexample | 7412 | @end smallexample |
| 7403 | 7413 | ||
| 7404 | @need 1200 | 7414 | @need 1200 |
| @@ -8846,7 +8856,7 @@ and then find the value of @code{trees}: | |||
| 8846 | 8856 | ||
| 8847 | @smallexample | 8857 | @smallexample |
| 8848 | @group | 8858 | @group |
| 8849 | (setq trees '(maple oak pine birch)) | 8859 | (setq trees (list 'maple 'oak 'pine 'birch)) |
| 8850 | @result{} (maple oak pine birch) | 8860 | @result{} (maple oak pine birch) |
| 8851 | @end group | 8861 | @end group |
| 8852 | 8862 | ||
| @@ -9366,7 +9376,7 @@ For example: | |||
| 9366 | 9376 | ||
| 9367 | @smallexample | 9377 | @smallexample |
| 9368 | @group | 9378 | @group |
| 9369 | (setq triple '(1 2 3)) | 9379 | (setq triple (list 1 2 3)) |
| 9370 | 9380 | ||
| 9371 | (setcar triple '37) | 9381 | (setcar triple '37) |
| 9372 | 9382 | ||
| @@ -9547,7 +9557,7 @@ part of which is the address of the next pair. The very last box | |||
| 9547 | points to the symbol @code{nil}, which marks the end of the list. | 9557 | points to the symbol @code{nil}, which marks the end of the list. |
| 9548 | 9558 | ||
| 9549 | @need 1200 | 9559 | @need 1200 |
| 9550 | When a variable is set to a list with a function such as @code{setq}, | 9560 | When a variable is set to a list with an operation such as @code{setq}, |
| 9551 | it stores the address of the first box in the variable. Thus, | 9561 | it stores the address of the first box in the variable. Thus, |
| 9552 | evaluation of the expression | 9562 | evaluation of the expression |
| 9553 | 9563 | ||
| @@ -17092,7 +17102,7 @@ reminders. | |||
| 17092 | 17102 | ||
| 17093 | @cindex Mail aliases | 17103 | @cindex Mail aliases |
| 17094 | @noindent | 17104 | @noindent |
| 17095 | This @code{setq} command sets the value of the variable | 17105 | This @code{setq} sets the value of the variable |
| 17096 | @code{mail-aliases} to @code{t}. Since @code{t} means true, the line | 17106 | @code{mail-aliases} to @code{t}. Since @code{t} means true, the line |
| 17097 | says, in effect, ``Yes, use mail aliases.'' | 17107 | says, in effect, ``Yes, use mail aliases.'' |
| 17098 | 17108 | ||
| @@ -17130,8 +17140,8 @@ The following turns off Indent Tabs mode: | |||
| 17130 | @end smallexample | 17140 | @end smallexample |
| 17131 | 17141 | ||
| 17132 | Note that this line uses @code{setq-default} rather than the | 17142 | Note that this line uses @code{setq-default} rather than the |
| 17133 | @code{setq} command that we have seen before. The @code{setq-default} | 17143 | @code{setq} that we have seen before; @code{setq-default} |
| 17134 | command sets values only in buffers that do not have their own local | 17144 | sets values only in buffers that do not have their own local |
| 17135 | values for the variable. | 17145 | values for the variable. |
| 17136 | 17146 | ||
| 17137 | @ifinfo | 17147 | @ifinfo |