diff options
| author | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
| commit | 969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch) | |
| tree | 5d7d0399caf410b5c4849aa9d43352b18f68d4c9 | |
| parent | b933f645ac70a31659f364cabf7da730d27eb244 (diff) | |
| download | emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip | |
*** empty log message ***
45 files changed, 3570 insertions, 2889 deletions
diff --git a/lispref/abbrevs.texi b/lispref/abbrevs.texi index 175bfb6824f..674082b6289 100644 --- a/lispref/abbrevs.texi +++ b/lispref/abbrevs.texi | |||
| @@ -54,7 +54,7 @@ of abbrevs when their abbreviations are inserted into a buffer. | |||
| 54 | If the value is @code{nil}, abbrevs may be defined, but they are not | 54 | If the value is @code{nil}, abbrevs may be defined, but they are not |
| 55 | expanded automatically. | 55 | expanded automatically. |
| 56 | 56 | ||
| 57 | This variable automatically becomes local when set in any fashion. | 57 | This variable automatically becomes buffer-local when set in any fashion. |
| 58 | @end defvar | 58 | @end defvar |
| 59 | 59 | ||
| 60 | @defvar default-abbrev-mode | 60 | @defvar default-abbrev-mode |
| @@ -337,10 +337,6 @@ it is the local abbrev table in all buffers in Fundamental mode. | |||
| 337 | This is the local abbrev table used in Text mode. | 337 | This is the local abbrev table used in Text mode. |
| 338 | @end defvar | 338 | @end defvar |
| 339 | 339 | ||
| 340 | @defvar c-mode-abbrev-table | ||
| 341 | This is the local abbrev table used in C mode. | ||
| 342 | @end defvar | ||
| 343 | |||
| 344 | @defvar lisp-mode-abbrev-table | 340 | @defvar lisp-mode-abbrev-table |
| 345 | This is the local abbrev table used in Lisp mode and Emacs Lisp mode. | 341 | This is the local abbrev table used in Lisp mode and Emacs Lisp mode. |
| 346 | @end defvar | 342 | @end defvar |
diff --git a/lispref/anti.texi b/lispref/anti.texi index dcd8be78987..df81194f29d 100644 --- a/lispref/anti.texi +++ b/lispref/anti.texi | |||
| @@ -144,6 +144,9 @@ This means that if you insert text with text properties into the minibuffer, | |||
| 144 | the minibuffer value really will contain text properties. | 144 | the minibuffer value really will contain text properties. |
| 145 | 145 | ||
| 146 | @item | 146 | @item |
| 147 | Only the simple menu item format is supported (@pxref{Simple Menu Items}). | ||
| 148 | |||
| 149 | @item | ||
| 147 | You can still bind @code{x-resource-class} around a call to | 150 | You can still bind @code{x-resource-class} around a call to |
| 148 | @code{x-get-resource}, but it won't do anything special. | 151 | @code{x-get-resource}, but it won't do anything special. |
| 149 | 152 | ||
| @@ -225,7 +228,7 @@ special events. If you want to hold a party in Emacs, please let us | |||
| 225 | know. | 228 | know. |
| 226 | 229 | ||
| 227 | @item | 230 | @item |
| 228 | You can't do date arithmentic with @code{encode-time} any more. | 231 | You can't do date arithmetic with @code{encode-time} any more. |
| 229 | 232 | ||
| 230 | @item | 233 | @item |
| 231 | The functions @code{command-execute} and @code{call-interactively} no | 234 | The functions @code{command-execute} and @code{call-interactively} no |
diff --git a/lispref/backups.texi b/lispref/backups.texi index 3a8221bab4f..9707ade9eef 100644 --- a/lispref/backups.texi +++ b/lispref/backups.texi | |||
| @@ -294,8 +294,7 @@ The standard definition of this function is as follows: | |||
| 294 | @smallexample | 294 | @smallexample |
| 295 | @group | 295 | @group |
| 296 | (defun make-backup-file-name (file) | 296 | (defun make-backup-file-name (file) |
| 297 | "Create the non-numeric backup file name for FILE. | 297 | "Create the non-numeric backup file name for FILE@enddots{}" |
| 298 | @dots{}" | ||
| 299 | (concat file "~")) | 298 | (concat file "~")) |
| 300 | @end group | 299 | @end group |
| 301 | @end smallexample | 300 | @end smallexample |
| @@ -442,8 +441,7 @@ The standard definition of this function is as follows: | |||
| 442 | @group | 441 | @group |
| 443 | (defun make-auto-save-file-name () | 442 | (defun make-auto-save-file-name () |
| 444 | "Return file name to use for auto-saves \ | 443 | "Return file name to use for auto-saves \ |
| 445 | of current buffer. | 444 | of current buffer@enddots{}" |
| 446 | @dots{}" | ||
| 447 | (if buffer-file-name | 445 | (if buffer-file-name |
| 448 | @end group | 446 | @end group |
| 449 | @group | 447 | @group |
| @@ -550,7 +548,7 @@ buffer as of the last time it was read in, saved, or auto-saved. This is | |||
| 550 | used to detect a substantial decrease in size, and turn off auto-saving | 548 | used to detect a substantial decrease in size, and turn off auto-saving |
| 551 | in response. | 549 | in response. |
| 552 | 550 | ||
| 553 | If it is -1, that means auto-saving is temporarily shut off in this | 551 | If it is @minus{}1, that means auto-saving is temporarily shut off in this |
| 554 | buffer due to a substantial deletion. Explicitly saving the buffer | 552 | buffer due to a substantial deletion. Explicitly saving the buffer |
| 555 | stores a positive value in this variable, thus reenabling auto-saving. | 553 | stores a positive value in this variable, thus reenabling auto-saving. |
| 556 | Turning auto-save mode off or on also alters this variable. | 554 | Turning auto-save mode off or on also alters this variable. |
diff --git a/lispref/buffers.texi b/lispref/buffers.texi index 8597305116b..600ff3e54b5 100644 --- a/lispref/buffers.texi +++ b/lispref/buffers.texi | |||
| @@ -130,11 +130,11 @@ string abridged): | |||
| 130 | @end example | 130 | @end example |
| 131 | 131 | ||
| 132 | @noindent | 132 | @noindent |
| 133 | This function binds a local variable to the current buffer, and then | 133 | This function binds a local variable to record the current buffer, and |
| 134 | @code{save-current-buffer} records which buffer that was. Next, | 134 | then @code{save-current-buffer} arranges to make it current again. |
| 135 | @code{set-buffer} makes another buffer current. Finally, | 135 | Next, @code{set-buffer} makes the specified buffer current. Finally, |
| 136 | @code{insert-buffer-substring} copies the string from the original | 136 | @code{insert-buffer-substring} copies the string from the original |
| 137 | current buffer to the new current buffer. | 137 | current buffer to the specified (and now current) buffer. |
| 138 | 138 | ||
| 139 | If the buffer appended to happens to be displayed in some window, | 139 | If the buffer appended to happens to be displayed in some window, |
| 140 | the next redisplay will show how its text has changed. Otherwise, you | 140 | the next redisplay will show how its text has changed. Otherwise, you |
| @@ -204,10 +204,10 @@ existing buffer. | |||
| 204 | @tindex save-current-buffer | 204 | @tindex save-current-buffer |
| 205 | @defmac save-current-buffer body... | 205 | @defmac save-current-buffer body... |
| 206 | The @code{save-current-buffer} macro saves the identity of the current | 206 | The @code{save-current-buffer} macro saves the identity of the current |
| 207 | buffer, evaluates the @var{body} forms, and finally restores the buffer. | 207 | buffer, evaluates the @var{body} forms, and finally restores that buffer |
| 208 | The return value is the value of the last form in @var{body}. The | 208 | as current. The return value is the value of the last form in |
| 209 | current buffer is restored even in case of an abnormal exit via | 209 | @var{body}. The current buffer is restored even in case of an abnormal |
| 210 | @code{throw} or error (@pxref{Nonlocal Exits}). | 210 | exit via @code{throw} or error (@pxref{Nonlocal Exits}). |
| 211 | 211 | ||
| 212 | If the buffer that used to be current has been killed by the time of | 212 | If the buffer that used to be current has been killed by the time of |
| 213 | exit from @code{save-current-buffer}, then it is not made current again, | 213 | exit from @code{save-current-buffer}, then it is not made current again, |
| @@ -383,10 +383,10 @@ buffer-file-name | |||
| 383 | @end example | 383 | @end example |
| 384 | 384 | ||
| 385 | It is risky to change this variable's value without doing various other | 385 | It is risky to change this variable's value without doing various other |
| 386 | things. See the definition of @code{set-visited-file-name} in | 386 | things. Normally it is better to use @code{set-visited-file-name} (see |
| 387 | @file{files.el}; some of the things done there, such as changing the | 387 | below); some of the things done there, such as changing the buffer name, |
| 388 | buffer name, are not strictly necessary, but others are essential to | 388 | are not strictly necessary, but others are essential to avoid confusing |
| 389 | avoid confusing Emacs. | 389 | Emacs. |
| 390 | @end defvar | 390 | @end defvar |
| 391 | 391 | ||
| 392 | @defvar buffer-file-truename | 392 | @defvar buffer-file-truename |
| @@ -399,7 +399,7 @@ local, unaffected by @code{kill-local-variables}. @xref{Truenames}. | |||
| 399 | This buffer-local variable holds the file number and directory device | 399 | This buffer-local variable holds the file number and directory device |
| 400 | number of the file visited in the current buffer, or @code{nil} if no | 400 | number of the file visited in the current buffer, or @code{nil} if no |
| 401 | file or a nonexistent file is visited. It is a permanent local, | 401 | file or a nonexistent file is visited. It is a permanent local, |
| 402 | unaffected by @code{kill-local-variables}. @xref{Truenames}. | 402 | unaffected by @code{kill-local-variables}. |
| 403 | 403 | ||
| 404 | The value is normally a list of the form @code{(@var{filenum} | 404 | The value is normally a list of the form @code{(@var{filenum} |
| 405 | @var{devnum})}. This pair of numbers uniquely identifies the file among | 405 | @var{devnum})}. This pair of numbers uniquely identifies the file among |
| @@ -443,9 +443,6 @@ the buffer as having no visited file. | |||
| 443 | @c Wordy to avoid overfull hbox. --rjc 16mar92 | 443 | @c Wordy to avoid overfull hbox. --rjc 16mar92 |
| 444 | When the function @code{set-visited-file-name} is called interactively, it | 444 | When the function @code{set-visited-file-name} is called interactively, it |
| 445 | prompts for @var{filename} in the minibuffer. | 445 | prompts for @var{filename} in the minibuffer. |
| 446 | |||
| 447 | See also @code{clear-visited-file-modtime} and | ||
| 448 | @code{verify-visited-file-modtime} in @ref{Buffer Modification}. | ||
| 449 | @end deffn | 446 | @end deffn |
| 450 | 447 | ||
| 451 | @defvar list-buffers-directory | 448 | @defvar list-buffers-directory |
| @@ -669,19 +666,23 @@ buried (see @code{bury-buffer}, below). Several functions, notably | |||
| 669 | @code{other-buffer}, use this ordering. A buffer list displayed for the | 666 | @code{other-buffer}, use this ordering. A buffer list displayed for the |
| 670 | user also follows this order. | 667 | user also follows this order. |
| 671 | 668 | ||
| 672 | @defun buffer-list &optional frame | 669 | In addition to the fundamental Emacs buffer list, each frame has its |
| 673 | This function returns a list of all buffers, including those whose names | 670 | own version of the buffer list, in which the buffers that have been |
| 674 | begin with a space. The elements are actual buffers, not their names. | 671 | selected in that frame come first, starting with the buffers most |
| 672 | recently selected @emph{in that frame}. (This order is recorded in | ||
| 673 | @var{frame}'s @code{buffer-list} frame parameter; see @ref{Window Frame | ||
| 674 | Parameters}.) The buffers that were never selected in @var{frame} come | ||
| 675 | afterward, ordered according to the fundamental Emacs buffer list. | ||
| 675 | 676 | ||
| 676 | If @var{frame} is @code{nil}, all the buffers appear in order of most | 677 | @defun buffer-list &optional frame |
| 677 | recent selection, regardless of which frames they were selected in. | 678 | This function returns the buffer list, including all buffers, even those |
| 679 | whose names begin with a space. The elements are actual buffers, not | ||
| 680 | their names. | ||
| 678 | 681 | ||
| 679 | If @var{frame} is a frame, then the buffers that have been selected in | 682 | If @var{frame} is a frame, this returns @var{frame}'s buffer list. If |
| 680 | @var{frame} all come at the front of the list, ordered by most recent | 683 | @var{frame} is @code{nil}, the fundamental Emacs buffer list is used: |
| 681 | selection in @var{frame}. (This order is recorded in @var{frame}'s | 684 | all the buffers appear in order of most recent selection, regardless of |
| 682 | @code{buffer-list} frame parameter; see @ref{X Frame Parameters}.) The | 685 | which frames they were selected in. |
| 683 | buffers that were never selected in @var{frame} come afterward, ordered | ||
| 684 | according to most recent selection in other frames. | ||
| 685 | 686 | ||
| 686 | @example | 687 | @example |
| 687 | @group | 688 | @group |
| @@ -735,7 +736,7 @@ buffer list that is not now visible in any window in a visible frame. | |||
| 735 | If the selected frame has a non-@code{nil} @code{buffer-predicate} | 736 | If the selected frame has a non-@code{nil} @code{buffer-predicate} |
| 736 | parameter, then @code{other-buffer} uses that predicate to decide which | 737 | parameter, then @code{other-buffer} uses that predicate to decide which |
| 737 | buffers to consider. It calls the predicate once for each buffer, and | 738 | buffers to consider. It calls the predicate once for each buffer, and |
| 738 | if the value is @code{nil}, that buffer is ignored. @xref{X Frame | 739 | if the value is @code{nil}, that buffer is ignored. @xref{Window Frame |
| 739 | Parameters}. | 740 | Parameters}. |
| 740 | 741 | ||
| 741 | @c Emacs 19 feature | 742 | @c Emacs 19 feature |
| @@ -946,7 +947,7 @@ themselves. | |||
| 946 | completely separate. They have different names, different values of | 947 | completely separate. They have different names, different values of |
| 947 | point, different narrowing, different markers and overlays (though | 948 | point, different narrowing, different markers and overlays (though |
| 948 | inserting or deleting text in either buffer relocates the markers and | 949 | inserting or deleting text in either buffer relocates the markers and |
| 949 | overlays for both), different major modes, and different local | 950 | overlays for both), different major modes, and different buffer-local |
| 950 | variables. | 951 | variables. |
| 951 | 952 | ||
| 952 | An indirect buffer cannot visit a file, but its base buffer can. If | 953 | An indirect buffer cannot visit a file, but its base buffer can. If |
diff --git a/lispref/calendar.texi b/lispref/calendar.texi index bae0543b5e7..ff1fec3cffc 100644 --- a/lispref/calendar.texi +++ b/lispref/calendar.texi | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | @c This is part of the GNU Emacs Lisp Reference Manual. | 2 | @c This is part of the GNU Emacs Lisp Reference Manual. |
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1995, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1995, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @node Calendar, Tips, Display, Top | 5 | @node Calendar, System Interface, Display, Top |
| 6 | @chapter Customizing the Calendar and Diary | 6 | @chapter Customizing the Calendar and Diary |
| 7 | 7 | ||
| 8 | There are many customizations that you can use to make the calendar and | 8 | There are many customizations that you can use to make the calendar and |
diff --git a/lispref/commands.texi b/lispref/commands.texi index 90d8cecbe4e..29e43d4dfc7 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi | |||
| @@ -385,7 +385,7 @@ one. No I/O. | |||
| 385 | @item s | 385 | @item s |
| 386 | Arbitrary text, read in the minibuffer and returned as a string | 386 | Arbitrary text, read in the minibuffer and returned as a string |
| 387 | (@pxref{Text from Minibuffer}). Terminate the input with either | 387 | (@pxref{Text from Minibuffer}). Terminate the input with either |
| 388 | @key{LFD} or @key{RET}. (@kbd{C-q} may be used to include either of | 388 | @kbd{C-j} or @key{RET}. (@kbd{C-q} may be used to include either of |
| 389 | these characters in the input.) Prompt. | 389 | these characters in the input.) Prompt. |
| 390 | 390 | ||
| 391 | @item S | 391 | @item S |
| @@ -401,7 +401,7 @@ Completion, Prompt. | |||
| 401 | 401 | ||
| 402 | @item x | 402 | @item x |
| 403 | A Lisp object, specified with its read syntax, terminated with a | 403 | A Lisp object, specified with its read syntax, terminated with a |
| 404 | @key{LFD} or @key{RET}. The object is not evaluated. @xref{Object from | 404 | @kbd{C-j} or @key{RET}. The object is not evaluated. @xref{Object from |
| 405 | Minibuffer}. Prompt. | 405 | Minibuffer}. Prompt. |
| 406 | 406 | ||
| 407 | @item X | 407 | @item X |
| @@ -482,7 +482,7 @@ expressions, autoload objects that are declared as interactive | |||
| 482 | (non-@code{nil} fourth argument to @code{autoload}), and some of the | 482 | (non-@code{nil} fourth argument to @code{autoload}), and some of the |
| 483 | primitive functions. | 483 | primitive functions. |
| 484 | 484 | ||
| 485 | A symbol is @code{commandp} if its function definition is | 485 | A symbol satisfies @code{commandp} if its function definition satisfies |
| 486 | @code{commandp}. | 486 | @code{commandp}. |
| 487 | 487 | ||
| 488 | Keys and keymaps are not commands. Rather, they are used to look up | 488 | Keys and keymaps are not commands. Rather, they are used to look up |
| @@ -507,7 +507,7 @@ Otherwise, the command is added only if it uses the minibuffer to read | |||
| 507 | an argument. @xref{Command History}. | 507 | an argument. @xref{Command History}. |
| 508 | 508 | ||
| 509 | The argument @var{keys}, if given, specifies the sequence of events to | 509 | The argument @var{keys}, if given, specifies the sequence of events to |
| 510 | use if the command inquires which events were used to invoke it. | 510 | supply if the command inquires which events were used to invoke it. |
| 511 | @end defun | 511 | @end defun |
| 512 | 512 | ||
| 513 | @defun command-execute command &optional record-flag keys | 513 | @defun command-execute command &optional record-flag keys |
| @@ -527,7 +527,7 @@ definition is handled by loading the specified library and then | |||
| 527 | rechecking the definition of the symbol. | 527 | rechecking the definition of the symbol. |
| 528 | 528 | ||
| 529 | The argument @var{keys}, if given, specifies the sequence of events to | 529 | The argument @var{keys}, if given, specifies the sequence of events to |
| 530 | use if the command inquires which events were used to invoke it. | 530 | supply if the command inquires which events were used to invoke it. |
| 531 | @end defun | 531 | @end defun |
| 532 | 532 | ||
| 533 | @deffn Command execute-extended-command prefix-argument | 533 | @deffn Command execute-extended-command prefix-argument |
| @@ -571,21 +571,22 @@ no difference whether @code{call-interactively} was called from Lisp or | |||
| 571 | directly from the editor command loop.) If the containing function was | 571 | directly from the editor command loop.) If the containing function was |
| 572 | called by Lisp evaluation (or with @code{apply} or @code{funcall}), then | 572 | called by Lisp evaluation (or with @code{apply} or @code{funcall}), then |
| 573 | it was not called interactively. | 573 | it was not called interactively. |
| 574 | @end defun | ||
| 574 | 575 | ||
| 575 | The most common use of @code{interactive-p} is for deciding whether to | 576 | The most common use of @code{interactive-p} is for deciding whether to |
| 576 | print an informative message. As a special exception, | 577 | print an informative message. As a special exception, |
| 577 | @code{interactive-p} returns @code{nil} whenever a keyboard macro is | 578 | @code{interactive-p} returns @code{nil} whenever a keyboard macro is |
| 578 | being run. This is to suppress the informative messages and speed | 579 | being run. This is to suppress the informative messages and speed |
| 579 | execution of the macro. | 580 | execution of the macro. |
| 580 | 581 | ||
| 581 | For example: | 582 | For example: |
| 582 | 583 | ||
| 583 | @example | 584 | @example |
| 584 | @group | 585 | @group |
| 585 | (defun foo () | 586 | (defun foo () |
| 586 | (interactive) | 587 | (interactive) |
| 587 | (and (interactive-p) | 588 | (when (interactive-p) |
| 588 | (message "foo"))) | 589 | (message "foo"))) |
| 589 | @result{} foo | 590 | @result{} foo |
| 590 | @end group | 591 | @end group |
| 591 | 592 | ||
| @@ -611,7 +612,20 @@ foobar | |||
| 611 | @result{} (nil t) | 612 | @result{} (nil t) |
| 612 | @end group | 613 | @end group |
| 613 | @end example | 614 | @end example |
| 614 | @end defun | 615 | |
| 616 | The other way to do this sort of job is to make the command take an | ||
| 617 | argument @code{print-message} which should be non-@code{nil} in an | ||
| 618 | interactive call, and use the @code{interactive} spec to make sure it is | ||
| 619 | non-@code{nil}. Here's how: | ||
| 620 | |||
| 621 | @example | ||
| 622 | (defun foo (&optional print-message) | ||
| 623 | (interactive "p") | ||
| 624 | (when print-message | ||
| 625 | (message "foo"))) | ||
| 626 | @end example | ||
| 627 | |||
| 628 | The numeric prefix argument, provided by @samp{p}, is never @code{nil}. | ||
| 615 | 629 | ||
| 616 | @node Command Loop Info | 630 | @node Command Loop Info |
| 617 | @comment node-name, next, previous, up | 631 | @comment node-name, next, previous, up |
| @@ -687,12 +701,19 @@ if all those events were characters. @xref{Input Events}. | |||
| 687 | @end example | 701 | @end example |
| 688 | @end defun | 702 | @end defun |
| 689 | 703 | ||
| 704 | @defun this-command-keys-vector | ||
| 705 | Like @code{this-command-keys}, except that it always returns | ||
| 706 | the events in a vector, so you do never need to deal with the complexities | ||
| 707 | of storing input events in a string (@pxref{Strings of Events}). | ||
| 708 | @end defun | ||
| 709 | |||
| 690 | @defvar last-nonmenu-event | 710 | @defvar last-nonmenu-event |
| 691 | This variable holds the last input event read as part of a key | 711 | This variable holds the last input event read as part of a key sequence, |
| 692 | sequence, not counting events resulting from mouse menus. | 712 | not counting events resulting from mouse menus. |
| 693 | 713 | ||
| 694 | One use of this variable is for telling @code{x-popup-menu} where to pop | 714 | One use of this variable is for telling @code{x-popup-menu} where to pop |
| 695 | up a menu. | 715 | up a menu. It is also used internally by @code{y-or-n-p} |
| 716 | (@pxref{Yes-or-No Queries}). | ||
| 696 | @end defvar | 717 | @end defvar |
| 697 | 718 | ||
| 698 | @defvar last-command-event | 719 | @defvar last-command-event |
| @@ -765,10 +786,9 @@ A symbol | |||
| 765 | 786 | ||
| 766 | There are two kinds of input you can get from the keyboard: ordinary | 787 | There are two kinds of input you can get from the keyboard: ordinary |
| 767 | keys, and function keys. Ordinary keys correspond to characters; the | 788 | keys, and function keys. Ordinary keys correspond to characters; the |
| 768 | events they generate are represented in Lisp as characters. In Emacs | 789 | events they generate are represented in Lisp as characters. The event |
| 769 | versions 18 and earlier, characters were the only events. The event | 790 | type of a character event is the character itself (an integer); see |
| 770 | type of a character event is the character itself (an integer); | 791 | @ref{Classifying Events}. |
| 771 | see @ref{Classifying Events}. | ||
| 772 | 792 | ||
| 773 | @cindex modifier bits (of input character) | 793 | @cindex modifier bits (of input character) |
| 774 | @cindex basic code (of input character) | 794 | @cindex basic code (of input character) |
| @@ -778,9 +798,9 @@ An input character event consists of a @dfn{basic code} between 0 and | |||
| 778 | @table @asis | 798 | @table @asis |
| 779 | @item meta | 799 | @item meta |
| 780 | The | 800 | The |
| 781 | @iftex | 801 | @tex |
| 782 | $2^{27}$ | 802 | $2^{27}$ |
| 783 | @end iftex | 803 | @end tex |
| 784 | @ifinfo | 804 | @ifinfo |
| 785 | 2**27 | 805 | 2**27 |
| 786 | @end ifinfo | 806 | @end ifinfo |
| @@ -789,9 +809,9 @@ typed with the meta key held down. | |||
| 789 | 809 | ||
| 790 | @item control | 810 | @item control |
| 791 | The | 811 | The |
| 792 | @iftex | 812 | @tex |
| 793 | $2^{26}$ | 813 | $2^{26}$ |
| 794 | @end iftex | 814 | @end tex |
| 795 | @ifinfo | 815 | @ifinfo |
| 796 | 2**26 | 816 | 2**26 |
| 797 | @end ifinfo | 817 | @end ifinfo |
| @@ -805,9 +825,9 @@ Thus, the code for @kbd{C-a} is just 1. | |||
| 805 | But if you type a control combination not in @sc{ASCII}, such as | 825 | But if you type a control combination not in @sc{ASCII}, such as |
| 806 | @kbd{%} with the control key, the numeric value you get is the code | 826 | @kbd{%} with the control key, the numeric value you get is the code |
| 807 | for @kbd{%} plus | 827 | for @kbd{%} plus |
| 808 | @iftex | 828 | @tex |
| 809 | $2^{26}$ | 829 | $2^{26}$ |
| 810 | @end iftex | 830 | @end tex |
| 811 | @ifinfo | 831 | @ifinfo |
| 812 | 2**26 | 832 | 2**26 |
| 813 | @end ifinfo | 833 | @end ifinfo |
| @@ -816,9 +836,9 @@ control characters). | |||
| 816 | 836 | ||
| 817 | @item shift | 837 | @item shift |
| 818 | The | 838 | The |
| 819 | @iftex | 839 | @tex |
| 820 | $2^{25}$ | 840 | $2^{25}$ |
| 821 | @end iftex | 841 | @end tex |
| 822 | @ifinfo | 842 | @ifinfo |
| 823 | 2**25 | 843 | 2**25 |
| 824 | @end ifinfo | 844 | @end ifinfo |
| @@ -829,9 +849,9 @@ For letters, the basic code itself indicates upper versus lower case; | |||
| 829 | for digits and punctuation, the shift key selects an entirely different | 849 | for digits and punctuation, the shift key selects an entirely different |
| 830 | character with a different basic code. In order to keep within the | 850 | character with a different basic code. In order to keep within the |
| 831 | @sc{ASCII} character set whenever possible, Emacs avoids using the | 851 | @sc{ASCII} character set whenever possible, Emacs avoids using the |
| 832 | @iftex | 852 | @tex |
| 833 | $2^{25}$ | 853 | $2^{25}$ |
| 834 | @end iftex | 854 | @end tex |
| 835 | @ifinfo | 855 | @ifinfo |
| 836 | 2**25 | 856 | 2**25 |
| 837 | @end ifinfo | 857 | @end ifinfo |
| @@ -839,9 +859,9 @@ bit for those characters. | |||
| 839 | 859 | ||
| 840 | However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from | 860 | However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from |
| 841 | @kbd{C-a}, so Emacs uses the | 861 | @kbd{C-a}, so Emacs uses the |
| 842 | @iftex | 862 | @tex |
| 843 | $2^{25}$ | 863 | $2^{25}$ |
| 844 | @end iftex | 864 | @end tex |
| 845 | @ifinfo | 865 | @ifinfo |
| 846 | 2**25 | 866 | 2**25 |
| 847 | @end ifinfo | 867 | @end ifinfo |
| @@ -850,9 +870,9 @@ bit in @kbd{C-A} and not in | |||
| 850 | 870 | ||
| 851 | @item hyper | 871 | @item hyper |
| 852 | The | 872 | The |
| 853 | @iftex | 873 | @tex |
| 854 | $2^{24}$ | 874 | $2^{24}$ |
| 855 | @end iftex | 875 | @end tex |
| 856 | @ifinfo | 876 | @ifinfo |
| 857 | 2**24 | 877 | 2**24 |
| 858 | @end ifinfo | 878 | @end ifinfo |
| @@ -861,9 +881,9 @@ typed with the hyper key held down. | |||
| 861 | 881 | ||
| 862 | @item super | 882 | @item super |
| 863 | The | 883 | The |
| 864 | @iftex | 884 | @tex |
| 865 | $2^{23}$ | 885 | $2^{23}$ |
| 866 | @end iftex | 886 | @end tex |
| 867 | @ifinfo | 887 | @ifinfo |
| 868 | 2**23 | 888 | 2**23 |
| 869 | @end ifinfo | 889 | @end ifinfo |
| @@ -872,9 +892,9 @@ typed with the super key held down. | |||
| 872 | 892 | ||
| 873 | @item alt | 893 | @item alt |
| 874 | The | 894 | The |
| 875 | @iftex | 895 | @tex |
| 876 | $2^{22}$ | 896 | $2^{22}$ |
| 877 | @end iftex | 897 | @end tex |
| 878 | @ifinfo | 898 | @ifinfo |
| 879 | 2**22 | 899 | 2**22 |
| 880 | @end ifinfo | 900 | @end ifinfo |
| @@ -1119,12 +1139,13 @@ events (@pxref{Click Events}), except that the @var{event-type} symbol | |||
| 1119 | name contains the prefix @samp{down-}. The @samp{down-} prefix follows | 1139 | name contains the prefix @samp{down-}. The @samp{down-} prefix follows |
| 1120 | modifier key prefixes such as @samp{C-} and @samp{M-}. | 1140 | modifier key prefixes such as @samp{C-} and @samp{M-}. |
| 1121 | 1141 | ||
| 1122 | The function @code{read-key-sequence}, and therefore the Emacs command | 1142 | The function @code{read-key-sequence} ignores any button-down events |
| 1123 | loop as well, ignore any button-down events that don't have command | 1143 | that don't have command bindings; therefore, the Emacs command loop |
| 1124 | bindings. This means that you need not worry about defining button-down | 1144 | ignores them too. This means that you need not worry about defining |
| 1125 | events unless you want them to do something. The usual reason to define | 1145 | button-down events unless you want them to do something. The usual |
| 1126 | a button-down event is so that you can track mouse motion (by reading | 1146 | reason to define a button-down event is so that you can track mouse |
| 1127 | motion events) until the button is released. @xref{Motion Events}. | 1147 | motion (by reading motion events) until the button is released. |
| 1148 | @xref{Motion Events}. | ||
| 1128 | 1149 | ||
| 1129 | @node Repeat Events | 1150 | @node Repeat Events |
| 1130 | @subsection Repeat Events | 1151 | @subsection Repeat Events |
| @@ -1220,8 +1241,7 @@ of the mouse without any button activity. Mouse motion events are | |||
| 1220 | represented by lists that look like this: | 1241 | represented by lists that look like this: |
| 1221 | 1242 | ||
| 1222 | @example | 1243 | @example |
| 1223 | (mouse-movement | 1244 | (mouse-movement (@var{window} @var{buffer-pos} (@var{x} . @var{y}) @var{timestamp})) |
| 1224 | (@var{window} @var{buffer-pos} (@var{x} . @var{y}) @var{timestamp})) | ||
| 1225 | @end example | 1245 | @end example |
| 1226 | 1246 | ||
| 1227 | The second element of the list describes the current position of the | 1247 | The second element of the list describes the current position of the |
| @@ -1230,17 +1250,7 @@ mouse, just as in a click event (@pxref{Click Events}). | |||
| 1230 | The special form @code{track-mouse} enables generation of motion events | 1250 | The special form @code{track-mouse} enables generation of motion events |
| 1231 | within its body. Outside of @code{track-mouse} forms, Emacs does not | 1251 | within its body. Outside of @code{track-mouse} forms, Emacs does not |
| 1232 | generate events for mere motion of the mouse, and these events do not | 1252 | generate events for mere motion of the mouse, and these events do not |
| 1233 | appear. | 1253 | appear. @xref{Mouse Tracking}. |
| 1234 | |||
| 1235 | @defspec track-mouse body@dots{} | ||
| 1236 | This special form executes @var{body}, with generation of mouse motion | ||
| 1237 | events enabled. Typically @var{body} would use @code{read-event} | ||
| 1238 | to read the motion events and modify the display accordingly. | ||
| 1239 | |||
| 1240 | When the user releases the button, that generates a click event. | ||
| 1241 | Typically, @var{body} should return when it sees the click event, and | ||
| 1242 | discard that event. | ||
| 1243 | @end defspec | ||
| 1244 | 1254 | ||
| 1245 | @node Focus Events | 1255 | @node Focus Events |
| 1246 | @subsection Focus Events | 1256 | @subsection Focus Events |
| @@ -1454,7 +1464,7 @@ to an event type which specifies all of them. For example, | |||
| 1454 | a mouse button or motion event. | 1464 | a mouse button or motion event. |
| 1455 | 1465 | ||
| 1456 | These two functions return the starting or ending position of a | 1466 | These two functions return the starting or ending position of a |
| 1457 | mouse-button event. The position is a list of this form: | 1467 | mouse-button event, as a list of this form: |
| 1458 | 1468 | ||
| 1459 | @example | 1469 | @example |
| 1460 | (@var{window} @var{buffer-position} (@var{x} . @var{y}) @var{timestamp}) | 1470 | (@var{window} @var{buffer-position} (@var{x} . @var{y}) @var{timestamp}) |
| @@ -1477,8 +1487,8 @@ event, the value is actually the starting position, which is the only | |||
| 1477 | position such events have. | 1487 | position such events have. |
| 1478 | @end defun | 1488 | @end defun |
| 1479 | 1489 | ||
| 1480 | These five functions take a position as described above, and return | 1490 | These five functions take a position list as described above, and |
| 1481 | various parts of it. | 1491 | return various parts of it. |
| 1482 | 1492 | ||
| 1483 | @defun posn-window position | 1493 | @defun posn-window position |
| 1484 | Return the window that @var{position} is in. | 1494 | Return the window that @var{position} is in. |
| @@ -1503,6 +1513,8 @@ a cons cell @code{(@var{col} . @var{row})}. These are computed from the | |||
| 1503 | Return the timestamp in @var{position}. | 1513 | Return the timestamp in @var{position}. |
| 1504 | @end defun | 1514 | @end defun |
| 1505 | 1515 | ||
| 1516 | These functions are useful for decoding scroll bar events. | ||
| 1517 | |||
| 1506 | @defun scroll-bar-event-ratio event | 1518 | @defun scroll-bar-event-ratio event |
| 1507 | This function returns the fractional vertical position of a scroll bar | 1519 | This function returns the fractional vertical position of a scroll bar |
| 1508 | event within the scroll bar. The value is a cons cell | 1520 | event within the scroll bar. The value is a cons cell |
| @@ -1537,28 +1549,59 @@ of a pair of x and y coordinates. | |||
| 1537 | string as containing text characters---the same kind of characters found | 1549 | string as containing text characters---the same kind of characters found |
| 1538 | in buffers or files. Occasionally Lisp programs use strings that | 1550 | in buffers or files. Occasionally Lisp programs use strings that |
| 1539 | conceptually contain keyboard characters; for example, they may be key | 1551 | conceptually contain keyboard characters; for example, they may be key |
| 1540 | sequences or keyboard macro definitions. There are special rules for | 1552 | sequences or keyboard macro definitions. However, storing keyboard |
| 1541 | how to put keyboard characters into a string, because they are not | 1553 | characters in a string is a complex matter, for reasons of historical |
| 1542 | limited to the range of 0 to 255 as text characters are. | 1554 | compatibility, and it is not always possible. |
| 1555 | |||
| 1556 | We recommend that new programs avoid dealing with these complexities | ||
| 1557 | by not storing keyboard events in strings. Here is how to do that: | ||
| 1558 | |||
| 1559 | @itemize @bullet | ||
| 1560 | @item | ||
| 1561 | Use vectors instead of strings for key sequences, when you plan to use | ||
| 1562 | them for anything other than as arguments @code{lookup-key} and | ||
| 1563 | @code{define-key}. For example, you can use | ||
| 1564 | @code{read-key-sequence-vector} instead of @code{read-key-sequence}, and | ||
| 1565 | @code{this-command-keys-vector} instead of @code{this-command-keys}. | ||
| 1566 | |||
| 1567 | @item | ||
| 1568 | Use vectors to write key sequence constants containing meta characters, | ||
| 1569 | even when passing them directly to @code{define-key}. | ||
| 1570 | |||
| 1571 | @item | ||
| 1572 | When you have to look at the contents of a key sequence that might be a | ||
| 1573 | string, use @code{listify-key-sequence} (@pxref{Event Input Misc}) | ||
| 1574 | first, to convert it to a list. | ||
| 1575 | @end itemize | ||
| 1543 | 1576 | ||
| 1544 | A keyboard character typed using the @key{META} key is called a | 1577 | The complexities stem from the modifier bits that keyboard input |
| 1545 | @dfn{meta character}. The numeric code for such an event includes the | 1578 | characters can include. Aside from the Meta modifier, none of these |
| 1546 | @iftex | 1579 | modifier bits can be included in a string, and the Meta modifier is |
| 1580 | allowed only in special cases. | ||
| 1581 | |||
| 1582 | The earliest GNU Emacs versions represented meta characters as codes | ||
| 1583 | in the range of 128 to 255. At that time, the basic character codes | ||
| 1584 | ranged from 0 to 127, so all keyboard character codes did fit in a | ||
| 1585 | string. Many Lisp programs used @samp{\M-} in string constants to stand | ||
| 1586 | for meta characters, especially in arguments to @code{define-key} and | ||
| 1587 | similar functions, and key sequences and sequences of events were always | ||
| 1588 | represented as strings. | ||
| 1589 | |||
| 1590 | When we added support for larger basic character codes beyond 127, and | ||
| 1591 | additional modifier bits, we had to change the representation of meta | ||
| 1592 | characters. Now the flag that represents the Meta modifier in a | ||
| 1593 | character is | ||
| 1594 | @tex | ||
| 1547 | $2^{27}$ | 1595 | $2^{27}$ |
| 1548 | @end iftex | 1596 | @end tex |
| 1549 | @ifinfo | 1597 | @ifinfo |
| 1550 | 2**27 | 1598 | 2**27 |
| 1551 | @end ifinfo | 1599 | @end ifinfo |
| 1552 | bit; it does not even come close to fitting in a string. However, | 1600 | and such numbers cannot be included in a string. |
| 1553 | earlier Emacs versions used a different representation for these | ||
| 1554 | characters, which gave them codes in the range of 128 to 255. That did | ||
| 1555 | fit in a string, and many Lisp programs contain string constants that | ||
| 1556 | use @samp{\M-} to express meta characters, especially as the argument to | ||
| 1557 | @code{define-key} and similar functions. | ||
| 1558 | 1601 | ||
| 1559 | We provide backward compatibility to run those programs using special | 1602 | To support programs with @samp{\M-} in string constants, there are |
| 1560 | rules for how to put a keyboard character event in a string. Here are | 1603 | special rules for including certain meta characters in a string. |
| 1561 | the rules: | 1604 | Here are the rules for interpreting keyboard |
| 1562 | 1605 | ||
| 1563 | @itemize @bullet | 1606 | @itemize @bullet |
| 1564 | @item | 1607 | @item |
| @@ -1567,36 +1610,39 @@ in the string unchanged. | |||
| 1567 | 1610 | ||
| 1568 | @item | 1611 | @item |
| 1569 | The meta variants of those characters, with codes in the range of | 1612 | The meta variants of those characters, with codes in the range of |
| 1570 | @iftex | 1613 | @tex |
| 1571 | $2^{27}$ | 1614 | $2^{27}$ |
| 1572 | @end iftex | 1615 | @end tex |
| 1573 | @ifinfo | 1616 | @ifinfo |
| 1574 | 2**27 | 1617 | 2**27 |
| 1575 | @end ifinfo | 1618 | @end ifinfo |
| 1576 | to | 1619 | to |
| 1577 | @iftex | 1620 | @tex |
| 1578 | $2^{27} + 127$, | 1621 | $2^{27} + 127$, |
| 1579 | @end iftex | 1622 | @end tex |
| 1580 | @ifinfo | 1623 | @ifinfo |
| 1581 | 2**27+127, | 1624 | 2**27+127, |
| 1582 | @end ifinfo | 1625 | @end ifinfo |
| 1583 | can also go in the string, but you must change their | 1626 | can also go in the string, but you must change their |
| 1584 | numeric values. You must set the | 1627 | numeric values. You must set the |
| 1585 | @iftex | 1628 | @tex |
| 1586 | $2^{7}$ | 1629 | $2^{7}$ |
| 1587 | @end iftex | 1630 | @end tex |
| 1588 | @ifinfo | 1631 | @ifinfo |
| 1589 | 2**7 | 1632 | 2**7 |
| 1590 | @end ifinfo | 1633 | @end ifinfo |
| 1591 | bit instead of the | 1634 | bit instead of the |
| 1592 | @iftex | 1635 | @tex |
| 1593 | $2^{27}$ | 1636 | $2^{27}$ |
| 1594 | @end iftex | 1637 | @end tex |
| 1595 | @ifinfo | 1638 | @ifinfo |
| 1596 | 2**27 | 1639 | 2**27 |
| 1597 | @end ifinfo | 1640 | @end ifinfo |
| 1598 | bit, | 1641 | bit, resulting in a value between 128 and 255. Only a unibyte string |
| 1599 | resulting in a value between 128 and 255. | 1642 | can include these codes. |
| 1643 | |||
| 1644 | @item | ||
| 1645 | Non-@sc{ASCII} characters above 256 can be included in a multibyte string. | ||
| 1600 | 1646 | ||
| 1601 | @item | 1647 | @item |
| 1602 | Other keyboard character events cannot fit in a string. This includes | 1648 | Other keyboard character events cannot fit in a string. This includes |
| @@ -1613,31 +1659,18 @@ modify the corresponding keyboard event to put it in the string. Thus, | |||
| 1613 | meta events in strings work consistently regardless of how they get into | 1659 | meta events in strings work consistently regardless of how they get into |
| 1614 | the strings. | 1660 | the strings. |
| 1615 | 1661 | ||
| 1616 | The reason we changed the representation of meta characters as | 1662 | However, most programs would do well to avoid these issues by |
| 1617 | keyboard events is to make room for basic character codes beyond 127, | 1663 | following the recommendations at the beginning of this section. |
| 1618 | and support meta variants of such larger character codes. | ||
| 1619 | |||
| 1620 | New programs can avoid dealing with these special compatibility rules | ||
| 1621 | by using vectors instead of strings for key sequences when there is any | ||
| 1622 | possibility that they might contain meta characters, and by using | ||
| 1623 | @code{listify-key-sequence} to access a string of events. | ||
| 1624 | |||
| 1625 | @defun listify-key-sequence key | ||
| 1626 | This function converts the string or vector @var{key} to a list of | ||
| 1627 | events, which you can put in @code{unread-command-events}. Converting a | ||
| 1628 | vector is simple, but converting a string is tricky because of the | ||
| 1629 | special representation used for meta characters in a string. | ||
| 1630 | @end defun | ||
| 1631 | 1664 | ||
| 1632 | @node Reading Input | 1665 | @node Reading Input |
| 1633 | @section Reading Input | 1666 | @section Reading Input |
| 1634 | 1667 | ||
| 1635 | The editor command loop reads keyboard input using the function | 1668 | The editor command loop reads key sequences using the function |
| 1636 | @code{read-key-sequence}, which uses @code{read-event}. These and other | 1669 | @code{read-key-sequence}, which uses @code{read-event}. These and other |
| 1637 | functions for keyboard input are also available for use in Lisp | 1670 | functions for event input are also available for use in Lisp programs. |
| 1638 | programs. See also @code{momentary-string-display} in @ref{Temporary | 1671 | See also @code{momentary-string-display} in @ref{Temporary Displays}, |
| 1639 | Displays}, and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, | 1672 | and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for |
| 1640 | for functions and variables for controlling terminal input modes and | 1673 | functions and variables for controlling terminal input modes and |
| 1641 | debugging terminal input. @xref{Translating Input}, for features you | 1674 | debugging terminal input. @xref{Translating Input}, for features you |
| 1642 | can use for translating or modifying input events while reading them. | 1675 | can use for translating or modifying input events while reading them. |
| 1643 | 1676 | ||
| @@ -1671,10 +1704,6 @@ Otherwise, it returns a vector, since a vector can hold all kinds of | |||
| 1671 | events---characters, symbols, and lists. The elements of the string or | 1704 | events---characters, symbols, and lists. The elements of the string or |
| 1672 | vector are the events in the key sequence. | 1705 | vector are the events in the key sequence. |
| 1673 | 1706 | ||
| 1674 | The function @code{read-key-sequence} suppresses quitting: @kbd{C-g} | ||
| 1675 | typed while reading with this function works like any other character, | ||
| 1676 | and does not set @code{quit-flag}. @xref{Quitting}. | ||
| 1677 | |||
| 1678 | The argument @var{prompt} is either a string to be displayed in the echo | 1707 | The argument @var{prompt} is either a string to be displayed in the echo |
| 1679 | area as a prompt, or @code{nil}, meaning not to display a prompt. | 1708 | area as a prompt, or @code{nil}, meaning not to display a prompt. |
| 1680 | 1709 | ||
| @@ -1692,6 +1721,16 @@ and the user types @kbd{C-x C-f}. | |||
| 1692 | @result{} "^X^F" | 1721 | @result{} "^X^F" |
| 1693 | @end group | 1722 | @end group |
| 1694 | @end example | 1723 | @end example |
| 1724 | |||
| 1725 | The function @code{read-key-sequence} suppresses quitting: @kbd{C-g} | ||
| 1726 | typed while reading with this function works like any other character, | ||
| 1727 | and does not set @code{quit-flag}. @xref{Quitting}. | ||
| 1728 | @end defun | ||
| 1729 | |||
| 1730 | @defun read-key-sequence-vector prompt | ||
| 1731 | This is like @code{read-key-sequence} except that it always | ||
| 1732 | returns the key sequence as a vector, never as a string. | ||
| 1733 | @xref{Strings of Events}. | ||
| 1695 | @end defun | 1734 | @end defun |
| 1696 | 1735 | ||
| 1697 | @cindex upper case key sequence | 1736 | @cindex upper case key sequence |
| @@ -1819,9 +1858,9 @@ The command @code{quoted-insert} uses this function. | |||
| 1819 | @cindex control characters, reading | 1858 | @cindex control characters, reading |
| 1820 | @cindex nonprinting characters, reading | 1859 | @cindex nonprinting characters, reading |
| 1821 | This function is like @code{read-char}, except that if the first | 1860 | This function is like @code{read-char}, except that if the first |
| 1822 | character read is an octal digit (0-7), it reads up to two more octal digits | 1861 | character read is an octal digit (0-7), it reads any number of octal |
| 1823 | (but stopping if a non-octal digit is found) and returns the | 1862 | digits (but stopping if a non-octal digit is found), and returns the |
| 1824 | character represented by those digits in octal. | 1863 | character represented by that numeric character code. |
| 1825 | 1864 | ||
| 1826 | Quitting is suppressed when the first character is read, so that the | 1865 | Quitting is suppressed when the first character is read, so that the |
| 1827 | user can enter a @kbd{C-g}. @xref{Quitting}. | 1866 | user can enter a @kbd{C-g}. @xref{Quitting}. |
| @@ -1882,6 +1921,11 @@ Normally you add events to the front of this list, so that the events | |||
| 1882 | most recently unread will be reread first. | 1921 | most recently unread will be reread first. |
| 1883 | @end defvar | 1922 | @end defvar |
| 1884 | 1923 | ||
| 1924 | @defun listify-key-sequence key | ||
| 1925 | This function converts the string or vector @var{key} to a list of | ||
| 1926 | individual events, which you can put in @code{unread-command-events}. | ||
| 1927 | @end defun | ||
| 1928 | |||
| 1885 | @defvar unread-command-char | 1929 | @defvar unread-command-char |
| 1886 | This variable holds a character to be read as command input. | 1930 | This variable holds a character to be read as command input. |
| 1887 | A value of -1 means ``empty''. | 1931 | A value of -1 means ``empty''. |
| @@ -1900,6 +1944,7 @@ may return @code{t} when no input is available. | |||
| 1900 | @end defun | 1944 | @end defun |
| 1901 | 1945 | ||
| 1902 | @defvar last-input-event | 1946 | @defvar last-input-event |
| 1947 | @defvarx last-input-char | ||
| 1903 | This variable records the last terminal input event read, whether | 1948 | This variable records the last terminal input event read, whether |
| 1904 | as part of a command or explicitly by a Lisp program. | 1949 | as part of a command or explicitly by a Lisp program. |
| 1905 | 1950 | ||
| @@ -1919,7 +1964,6 @@ this expression) remains the value of @code{last-command-event}. | |||
| 1919 | @end group | 1964 | @end group |
| 1920 | @end example | 1965 | @end example |
| 1921 | 1966 | ||
| 1922 | @vindex last-input-char | ||
| 1923 | The alias @code{last-input-char} exists for compatibility with | 1967 | The alias @code{last-input-char} exists for compatibility with |
| 1924 | Emacs version 18. | 1968 | Emacs version 18. |
| 1925 | @end defvar | 1969 | @end defvar |
| @@ -2049,9 +2093,9 @@ innermost active command loop. | |||
| 2049 | does not cause a quit; it acts as an ordinary input character. In the | 2093 | does not cause a quit; it acts as an ordinary input character. In the |
| 2050 | simplest case, you cannot tell the difference, because @kbd{C-g} | 2094 | simplest case, you cannot tell the difference, because @kbd{C-g} |
| 2051 | normally runs the command @code{keyboard-quit}, whose effect is to quit. | 2095 | normally runs the command @code{keyboard-quit}, whose effect is to quit. |
| 2052 | However, when @kbd{C-g} follows a prefix key, the result is an undefined | 2096 | However, when @kbd{C-g} follows a prefix key, they combine to form an |
| 2053 | key. The effect is to cancel the prefix key as well as any prefix | 2097 | undefined key. The effect is to cancel the prefix key as well as any |
| 2054 | argument. | 2098 | prefix argument. |
| 2055 | 2099 | ||
| 2056 | In the minibuffer, @kbd{C-g} has a different definition: it aborts out | 2100 | In the minibuffer, @kbd{C-g} has a different definition: it aborts out |
| 2057 | of the minibuffer. This means, in effect, that it exits the minibuffer | 2101 | of the minibuffer. This means, in effect, that it exits the minibuffer |
| @@ -2104,15 +2148,15 @@ normal quitting is permitted after the first character of input. | |||
| 2104 | @example | 2148 | @example |
| 2105 | (defun read-quoted-char (&optional prompt) | 2149 | (defun read-quoted-char (&optional prompt) |
| 2106 | "@dots{}@var{documentation}@dots{}" | 2150 | "@dots{}@var{documentation}@dots{}" |
| 2107 | (let ((count 0) (code 0) char) | 2151 | (let ((message-log-max nil) done (first t) (code 0) char) |
| 2108 | (while (< count 3) | 2152 | (while (not done) |
| 2109 | (let ((inhibit-quit (zerop count)) | 2153 | (let ((inhibit-quit first) |
| 2110 | (help-form nil)) | 2154 | @dots{}) |
| 2111 | (and prompt (message "%s-" prompt)) | 2155 | (and prompt (message "%s-" prompt)) |
| 2112 | (setq char (read-char)) | 2156 | (setq char (read-event)) |
| 2113 | (if inhibit-quit (setq quit-flag nil))) | 2157 | (if inhibit-quit (setq quit-flag nil))) |
| 2114 | @dots{}) | 2158 | @r{@dots{}set the variable @code{code}@dots{}}) |
| 2115 | (logand 255 code))) | 2159 | code)) |
| 2116 | @end example | 2160 | @end example |
| 2117 | 2161 | ||
| 2118 | @defvar quit-flag | 2162 | @defvar quit-flag |
diff --git a/lispref/compile.texi b/lispref/compile.texi index 0ccdd568b1c..007a4a6b094 100644 --- a/lispref/compile.texi +++ b/lispref/compile.texi | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/compile | 5 | @setfilename ../info/compile |
| 6 | @node Byte Compilation, Debugging, Loading, Top | 6 | @node Byte Compilation, Advising, Loading, Top |
| 7 | @chapter Byte Compilation | 7 | @chapter Byte Compilation |
| 8 | @cindex byte-code | 8 | @cindex byte-code |
| 9 | @cindex compilation | 9 | @cindex compilation |
| 10 | 10 | ||
| 11 | GNU Emacs Lisp has a @dfn{compiler} that translates functions written | 11 | Emacs Lisp has a @dfn{compiler} that translates functions written |
| 12 | in Lisp into a special representation called @dfn{byte-code} that can be | 12 | in Lisp into a special representation called @dfn{byte-code} that can be |
| 13 | executed more efficiently. The compiler replaces Lisp function | 13 | executed more efficiently. The compiler replaces Lisp function |
| 14 | definitions with byte-code. When a byte-code function is called, its | 14 | definitions with byte-code. When a byte-code function is called, its |
| @@ -21,15 +21,17 @@ transportable from machine to machine without recompilation. It is not, | |||
| 21 | however, as fast as true compiled code. | 21 | however, as fast as true compiled code. |
| 22 | 22 | ||
| 23 | In general, any version of Emacs can run byte-compiled code produced | 23 | In general, any version of Emacs can run byte-compiled code produced |
| 24 | by recent earlier versions of Emacs, but the reverse is not true. In | 24 | by recent earlier versions of Emacs, but the reverse is not true. A |
| 25 | particular, if you compile a program with Emacs 19.29, the compiled | 25 | major incompatible change was introduced in Emacs version 19.29, and |
| 26 | code does not run in earlier versions. | 26 | files compiled with versions since that one will definitely not run |
| 27 | in earlier versions unless you specify a special option. | ||
| 27 | @iftex | 28 | @iftex |
| 28 | @xref{Docs and Compilation}. | 29 | @xref{Docs and Compilation}. |
| 29 | @end iftex | 30 | @end iftex |
| 30 | Files compiled in versions before 19.29 may not work in 19.29 if they | 31 | In addition, the modifier bits in keyboard characters were renumbered in |
| 31 | contain character constants with modifier bits, because the bits were | 32 | Emacs 19.29; as a result, files compiled in versions before 19.29 will |
| 32 | renumbered in Emacs 19.29. | 33 | not work in subsequent versions if they contain character constants with |
| 34 | modifier bits. | ||
| 33 | 35 | ||
| 34 | @xref{Compilation Errors}, for how to investigate errors occurring in | 36 | @xref{Compilation Errors}, for how to investigate errors occurring in |
| 35 | byte compilation. | 37 | byte compilation. |
| @@ -99,9 +101,10 @@ in a buffer called @samp{*Compile-Log*}. These report things in your | |||
| 99 | program that suggest a problem but are not necessarily erroneous. | 101 | program that suggest a problem but are not necessarily erroneous. |
| 100 | 102 | ||
| 101 | @cindex macro compilation | 103 | @cindex macro compilation |
| 102 | Be careful when byte-compiling code that uses macros. Macro calls are | 104 | Be careful when writing macro calls in files that you may someday |
| 103 | expanded when they are compiled, so the macros must already be defined | 105 | byte-compile. Macro calls are expanded when they are compiled, so the |
| 104 | for proper compilation. For more details, see @ref{Compiling Macros}. | 106 | macros must already be defined for proper compilation. For more |
| 107 | details, see @ref{Compiling Macros}. | ||
| 105 | 108 | ||
| 106 | Normally, compiling a file does not evaluate the file's contents or | 109 | Normally, compiling a file does not evaluate the file's contents or |
| 107 | load the file. But it does execute any @code{require} calls at top | 110 | load the file. But it does execute any @code{require} calls at top |
| @@ -200,10 +203,9 @@ This function recompiles every @samp{.el} file in @var{directory} that | |||
| 200 | needs recompilation. A file needs recompilation if a @samp{.elc} file | 203 | needs recompilation. A file needs recompilation if a @samp{.elc} file |
| 201 | exists but is older than the @samp{.el} file. | 204 | exists but is older than the @samp{.el} file. |
| 202 | 205 | ||
| 203 | When a @samp{.el} file has no corresponding @samp{.elc} file, then | 206 | When a @samp{.el} file has no corresponding @samp{.elc} file, @var{flag} |
| 204 | @var{flag} says what to do. If it is @code{nil}, these files are | 207 | says what to do. If it is @code{nil}, these files are ignored. If it |
| 205 | ignored. If it is non-@code{nil}, the user is asked whether to compile | 208 | is non-@code{nil}, the user is asked whether to compile each such file. |
| 206 | each such file. | ||
| 207 | 209 | ||
| 208 | The returned value of this command is unpredictable. | 210 | The returned value of this command is unpredictable. |
| 209 | @end deffn | 211 | @end deffn |
| @@ -225,12 +227,13 @@ status code. | |||
| 225 | @cindex byte-code interpreter | 227 | @cindex byte-code interpreter |
| 226 | This function actually interprets byte-code. A byte-compiled function | 228 | This function actually interprets byte-code. A byte-compiled function |
| 227 | is actually defined with a body that calls @code{byte-code}. Don't call | 229 | is actually defined with a body that calls @code{byte-code}. Don't call |
| 228 | this function yourself. Only the byte compiler knows how to generate | 230 | this function yourself---only the byte compiler knows how to generate |
| 229 | valid calls to this function. | 231 | valid calls to this function. |
| 230 | 232 | ||
| 231 | In newer Emacs versions (19 and up), byte-code is usually executed as | 233 | In Emacs version 18, byte-code was always executed by way of a call to |
| 232 | part of a byte-code function object, and only rarely due to an explicit | 234 | the function @code{byte-code}. Nowadays, byte-code is usually executed |
| 233 | call to @code{byte-code}. | 235 | as part of a byte-code function object, and only rarely through an |
| 236 | explicit call to @code{byte-code}. | ||
| 234 | @end defun | 237 | @end defun |
| 235 | 238 | ||
| 236 | @node Docs and Compilation | 239 | @node Docs and Compilation |
| @@ -269,13 +272,14 @@ directory where you built it, you will experience this problem | |||
| 269 | occasionally if you edit and recompile Lisp files. When it happens, you | 272 | occasionally if you edit and recompile Lisp files. When it happens, you |
| 270 | can cure the problem by reloading the file after recompiling it. | 273 | can cure the problem by reloading the file after recompiling it. |
| 271 | 274 | ||
| 272 | Byte-compiled files made with Emacs 19.29 will not load into older | 275 | Byte-compiled files made with recent versions of Emacs (since 19.29) |
| 273 | versions because the older versions don't support this feature. You can | 276 | will not load into older versions because the older versions don't |
| 274 | turn off this feature by setting @code{byte-compile-dynamic-docstrings} | 277 | support this feature. You can turn off this feature at compile time by |
| 275 | to @code{nil}. Once this is done, you can compile files that will load | 278 | setting @code{byte-compile-dynamic-docstrings} to @code{nil}; then you |
| 276 | into older Emacs versions. You can do this globally, or for one source | 279 | can compile files that will load into older Emacs versions. You can do |
| 277 | file by specifying a file-local binding for the variable. Here's one | 280 | this globally, or for one source file by specifying a file-local binding |
| 278 | way to do that: | 281 | for the variable. One way to do that is by adding this string to the |
| 282 | file's first line: | ||
| 279 | 283 | ||
| 280 | @example | 284 | @example |
| 281 | -*-byte-compile-dynamic-docstrings: nil;-*- | 285 | -*-byte-compile-dynamic-docstrings: nil;-*- |
| @@ -292,7 +296,9 @@ that are set up for dynamic loading of documentation strings. | |||
| 292 | use a special Lisp reader construct, @samp{#@@@var{count}}. This | 296 | use a special Lisp reader construct, @samp{#@@@var{count}}. This |
| 293 | construct skips the next @var{count} characters. It also uses the | 297 | construct skips the next @var{count} characters. It also uses the |
| 294 | @samp{#$} construct, which stands for ``the name of this file, as a | 298 | @samp{#$} construct, which stands for ``the name of this file, as a |
| 295 | string.'' It is best not to use these constructs in Lisp source files. | 299 | string.'' It is usually best not to use these constructs in Lisp source |
| 300 | files, since they are not designed to be clear to humans reading the | ||
| 301 | file. | ||
| 296 | 302 | ||
| 297 | @node Dynamic Loading | 303 | @node Dynamic Loading |
| 298 | @section Dynamic Loading of Individual Functions | 304 | @section Dynamic Loading of Individual Functions |
| @@ -309,10 +315,10 @@ replace the place-holder. | |||
| 309 | 315 | ||
| 310 | The advantage of dynamic function loading is that loading the file | 316 | The advantage of dynamic function loading is that loading the file |
| 311 | becomes much faster. This is a good thing for a file which contains | 317 | becomes much faster. This is a good thing for a file which contains |
| 312 | many separate commands, provided that using one of them does not imply | 318 | many separate user-callable functions, if using one of them does not |
| 313 | you will soon (or ever) use the rest. A specialized mode which provides | 319 | imply you will probably also use the rest. A specialized mode which |
| 314 | many keyboard commands often has that usage pattern: a user may invoke | 320 | provides many keyboard commands often has that usage pattern: a user may |
| 315 | the mode, but use only a few of the commands it provides. | 321 | invoke the mode, but use only a few of the commands it provides. |
| 316 | 322 | ||
| 317 | The dynamic loading feature has certain disadvantages: | 323 | The dynamic loading feature has certain disadvantages: |
| 318 | 324 | ||
| @@ -323,19 +329,21 @@ longer load the remaining function definitions not already loaded. | |||
| 323 | 329 | ||
| 324 | @item | 330 | @item |
| 325 | If you alter the compiled file (such as by compiling a new version), | 331 | If you alter the compiled file (such as by compiling a new version), |
| 326 | then trying to load any function not already loaded will get nonsense | 332 | then trying to load any function not already loaded will yield nonsense |
| 327 | results. | 333 | results. |
| 328 | @end itemize | 334 | @end itemize |
| 329 | 335 | ||
| 330 | If you compile a new version of the file, the best thing to do is | 336 | These problems will never happen in normal circumstances with |
| 331 | immediately load the new compiled file. That will prevent any future | 337 | installed Emacs files. But they are quite likely to happen with Lisp |
| 332 | problems. | 338 | files that you are changing. The easiest way to prevent these problems |
| 339 | is to reload the new compiled file immediately after each recompilation. | ||
| 333 | 340 | ||
| 334 | The byte compiler uses the dynamic function loading feature if the | 341 | The byte compiler uses the dynamic function loading feature if the |
| 335 | variable @code{byte-compile-dynamic} is non-@code{nil} at compilation | 342 | variable @code{byte-compile-dynamic} is non-@code{nil} at compilation |
| 336 | time. Do not set this variable globally, since dynamic loading is | 343 | time. Do not set this variable globally, since dynamic loading is |
| 337 | desirable only for certain files. Instead, enable the feature for | 344 | desirable only for certain files. Instead, enable the feature for |
| 338 | specific source files with file-local variable bindings, like this: | 345 | specific source files with file-local variable bindings. For example, |
| 346 | you could do it by writing this text in the source file's first line: | ||
| 339 | 347 | ||
| 340 | @example | 348 | @example |
| 341 | -*-byte-compile-dynamic: t;-*- | 349 | -*-byte-compile-dynamic: t;-*- |
| @@ -363,9 +371,8 @@ This form marks @var{body} to be evaluated both when you compile the | |||
| 363 | containing code and when you run it (whether compiled or not). | 371 | containing code and when you run it (whether compiled or not). |
| 364 | 372 | ||
| 365 | You can get a similar result by putting @var{body} in a separate file | 373 | You can get a similar result by putting @var{body} in a separate file |
| 366 | and referring to that file with @code{require}. Using @code{require} is | 374 | and referring to that file with @code{require}. That method is |
| 367 | preferable if there is a substantial amount of code to be executed in | 375 | preferable when @var{body} is large. |
| 368 | this way. | ||
| 369 | @end defspec | 376 | @end defspec |
| 370 | 377 | ||
| 371 | @defspec eval-when-compile body | 378 | @defspec eval-when-compile body |
| @@ -375,10 +382,10 @@ compiler becomes a constant which appears in the compiled program. If | |||
| 375 | you load the source file, rather than compiling it, @var{body} is | 382 | you load the source file, rather than compiling it, @var{body} is |
| 376 | evaluated normally. | 383 | evaluated normally. |
| 377 | 384 | ||
| 378 | At top level, this is analogous to the Common Lisp idiom | 385 | @strong{Common Lisp Note:} At top level, this is analogous to the Common |
| 379 | @code{(eval-when (compile eval) @dots{})}. Elsewhere, the Common Lisp | 386 | Lisp idiom @code{(eval-when (compile eval) @dots{})}. Elsewhere, the |
| 380 | @samp{#.} reader macro (but not when interpreting) is closer to what | 387 | Common Lisp @samp{#.} reader macro (but not when interpreting) is closer |
| 381 | @code{eval-when-compile} does. | 388 | to what @code{eval-when-compile} does. |
| 382 | @end defspec | 389 | @end defspec |
| 383 | 390 | ||
| 384 | @node Byte-Code Objects | 391 | @node Byte-Code Objects |
| @@ -395,12 +402,8 @@ as a function to be called. The printed representation for a byte-code | |||
| 395 | function object is like that for a vector, with an additional @samp{#} | 402 | function object is like that for a vector, with an additional @samp{#} |
| 396 | before the opening @samp{[}. | 403 | before the opening @samp{[}. |
| 397 | 404 | ||
| 398 | In Emacs version 18, there was no byte-code function object data type; | ||
| 399 | compiled functions used the function @code{byte-code} to run the byte | ||
| 400 | code. | ||
| 401 | |||
| 402 | A byte-code function object must have at least four elements; there is | 405 | A byte-code function object must have at least four elements; there is |
| 403 | no maximum number, but only the first six elements are actually used. | 406 | no maximum number, but only the first six elements have any normal use. |
| 404 | They are: | 407 | They are: |
| 405 | 408 | ||
| 406 | @table @var | 409 | @table @var |
diff --git a/lispref/control.texi b/lispref/control.texi index 19d82fe7c08..1fbb668da0f 100644 --- a/lispref/control.texi +++ b/lispref/control.texi | |||
| @@ -460,8 +460,8 @@ first argument of @code{while}, as shown here: | |||
| 460 | 460 | ||
| 461 | @noindent | 461 | @noindent |
| 462 | This moves forward one line and continues moving by lines until it | 462 | This moves forward one line and continues moving by lines until it |
| 463 | reaches an empty. It is unusual in that the @code{while} has no body, | 463 | reaches an empty line. It is peculiar in that the @code{while} has no |
| 464 | just the end test (which also does the real work of moving point). | 464 | body, just the end test (which also does the real work of moving point). |
| 465 | @end defspec | 465 | @end defspec |
| 466 | 466 | ||
| 467 | @node Nonlocal Exits | 467 | @node Nonlocal Exits |
| @@ -718,15 +718,13 @@ These examples show typical uses of @code{error}: | |||
| 718 | 718 | ||
| 719 | @example | 719 | @example |
| 720 | @group | 720 | @group |
| 721 | (error "You have committed an error. | 721 | (error "That is an error -- try something else") |
| 722 | Try something else.") | 722 | @error{} That is an error -- try something else |
| 723 | @error{} You have committed an error. | ||
| 724 | Try something else. | ||
| 725 | @end group | 723 | @end group |
| 726 | 724 | ||
| 727 | @group | 725 | @group |
| 728 | (error "You have committed %d errors." 10) | 726 | (error "You have committed %d errors" 10) |
| 729 | @error{} You have committed 10 errors. | 727 | @error{} You have committed 10 errors |
| 730 | @end group | 728 | @end group |
| 731 | @end example | 729 | @end example |
| 732 | 730 | ||
| @@ -752,7 +750,7 @@ errors. | |||
| 752 | 750 | ||
| 753 | The number and significance of the objects in @var{data} depends on | 751 | The number and significance of the objects in @var{data} depends on |
| 754 | @var{error-symbol}. For example, with a @code{wrong-type-arg} error, | 752 | @var{error-symbol}. For example, with a @code{wrong-type-arg} error, |
| 755 | there are two objects in the list: a predicate that describes the type | 753 | there should be two objects in the list: a predicate that describes the type |
| 756 | that was expected, and the object that failed to fit that type. | 754 | that was expected, and the object that failed to fit that type. |
| 757 | @xref{Error Symbols}, for a description of error symbols. | 755 | @xref{Error Symbols}, for a description of error symbols. |
| 758 | 756 | ||
| @@ -772,8 +770,8 @@ it could sometimes return). | |||
| 772 | @end group | 770 | @end group |
| 773 | 771 | ||
| 774 | @group | 772 | @group |
| 775 | (signal 'no-such-error '("My unknown error condition.")) | 773 | (signal 'no-such-error '("My unknown error condition")) |
| 776 | @error{} peculiar error: "My unknown error condition." | 774 | @error{} peculiar error: "My unknown error condition" |
| 777 | @end group | 775 | @end group |
| 778 | @end smallexample | 776 | @end smallexample |
| 779 | @end defun | 777 | @end defun |
| @@ -876,8 +874,8 @@ execution at the point of the error, nor can it examine variable | |||
| 876 | bindings that were made within the protected form. All it can do is | 874 | bindings that were made within the protected form. All it can do is |
| 877 | clean up and proceed. | 875 | clean up and proceed. |
| 878 | 876 | ||
| 879 | @code{condition-case} is often used to trap errors that are | 877 | The @code{condition-case} construct is often used to trap errors that |
| 880 | predictable, such as failure to open a file in a call to | 878 | are predictable, such as failure to open a file in a call to |
| 881 | @code{insert-file-contents}. It is also used to trap errors that are | 879 | @code{insert-file-contents}. It is also used to trap errors that are |
| 882 | totally unpredictable, such as when the program evaluates an expression | 880 | totally unpredictable, such as when the program evaluates an expression |
| 883 | read from the user. | 881 | read from the user. |
| @@ -1159,7 +1157,12 @@ You might think that we could just as well write @code{(kill-buffer | |||
| 1159 | However, the way shown above is safer, if @var{body} happens to get an | 1157 | However, the way shown above is safer, if @var{body} happens to get an |
| 1160 | error after switching to a different buffer! (Alternatively, you could | 1158 | error after switching to a different buffer! (Alternatively, you could |
| 1161 | write another @code{save-excursion} around the body, to ensure that the | 1159 | write another @code{save-excursion} around the body, to ensure that the |
| 1162 | temporary buffer becomes current in time to kill it.) | 1160 | temporary buffer becomes current again in time to kill it.) |
| 1161 | |||
| 1162 | Emacs includes a standard macro called @code{with-temp-buffer} which | ||
| 1163 | expands into more or less the code shown above (@pxref{Current Buffer}). | ||
| 1164 | Several of the macros defined in this manual use @code{unwind-protect} | ||
| 1165 | in this way. | ||
| 1163 | 1166 | ||
| 1164 | @findex ftp-login | 1167 | @findex ftp-login |
| 1165 | Here is an actual example taken from the file @file{ftp.el}. It | 1168 | Here is an actual example taken from the file @file{ftp.el}. It |
| @@ -1188,18 +1191,3 @@ quit, and the quit happens immediately after the function | |||
| 1188 | @code{ftp-setup-buffer} returns but before the variable @code{process} is | 1191 | @code{ftp-setup-buffer} returns but before the variable @code{process} is |
| 1189 | set, the process will not be killed. There is no easy way to fix this bug, | 1192 | set, the process will not be killed. There is no easy way to fix this bug, |
| 1190 | but at least it is very unlikely. | 1193 | but at least it is very unlikely. |
| 1191 | |||
| 1192 | Here is another example which uses @code{unwind-protect} to make sure | ||
| 1193 | to kill a temporary buffer. In this example, the value returned by | ||
| 1194 | @code{unwind-protect} is used. | ||
| 1195 | |||
| 1196 | @smallexample | ||
| 1197 | (defun shell-command-string (cmd) | ||
| 1198 | "Return the output of the shell command CMD, as a string." | ||
| 1199 | (save-excursion | ||
| 1200 | (set-buffer (generate-new-buffer " OS*cmd")) | ||
| 1201 | (shell-command cmd t) | ||
| 1202 | (unwind-protect | ||
| 1203 | (buffer-string) | ||
| 1204 | (kill-buffer (current-buffer))))) | ||
| 1205 | @end smallexample | ||
diff --git a/lispref/customize.texi b/lispref/customize.texi index 738734fe7c4..2b61848d643 100644 --- a/lispref/customize.texi +++ b/lispref/customize.texi | |||
| @@ -6,30 +6,29 @@ | |||
| 6 | @node Customization, Loading, Macros, Top | 6 | @node Customization, Loading, Macros, Top |
| 7 | @chapter Writing Customization Definitions | 7 | @chapter Writing Customization Definitions |
| 8 | 8 | ||
| 9 | This chapter describes how to declare customization groups, variables, | 9 | This chapter describes how to declare user options for customization, |
| 10 | and faces. We use the term @dfn{customization item} to include all | 10 | and also customization groups for classifying them. We use the term |
| 11 | three of those. This has few examples, but please look at the file | 11 | @dfn{customization item} to include both kinds of customization |
| 12 | @file{cus-edit.el}, which contains many declarations you can learn from. | 12 | definitions---as well as face definitions (@pxref{Defining Faces}). |
| 13 | 13 | ||
| 14 | @menu | 14 | @menu |
| 15 | * Common Keywords:: | 15 | * Common Keywords:: |
| 16 | * Group Definitions:: | 16 | * Group Definitions:: |
| 17 | * Variable Definitions:: | 17 | * Variable Definitions:: |
| 18 | * Face Definitions:: | ||
| 19 | * Customization Types:: | 18 | * Customization Types:: |
| 20 | @end menu | 19 | @end menu |
| 21 | 20 | ||
| 22 | @node Common Keywords | 21 | @node Common Keywords |
| 23 | @section Common Keywords for All Kinds of Items | 22 | @section Common Keywords for All Kinds of Items |
| 24 | 23 | ||
| 25 | All three kinds of customization declarations (for groups, variables, | 24 | All kinds of customization declarations (for variables and groups, and |
| 26 | and faces) accept keyword arguments for specifying various information. | 25 | for faces) accept keyword arguments for specifying various information. |
| 27 | This section describes some keywords that apply to all three. | 26 | This section describes some keywords that apply to all kinds. |
| 28 | 27 | ||
| 29 | All of these keywords, except @code{:tag}, can be used more than once in | 28 | All of these keywords, except @code{:tag}, can be used more than once |
| 30 | a given item. Each use of the keyword has an independent effect. The | 29 | in a given item. Each use of the keyword has an independent effect. |
| 31 | keyword @code{:tag} is an exception because any given item can only | 30 | The keyword @code{:tag} is an exception because any given item can only |
| 32 | display one name item. | 31 | display one name. |
| 33 | 32 | ||
| 34 | @table @code | 33 | @table @code |
| 35 | @item :group @var{group} | 34 | @item :group @var{group} |
| @@ -49,6 +48,10 @@ other documentation. | |||
| 49 | There are three alternatives you can use for @var{link-data}: | 48 | There are three alternatives you can use for @var{link-data}: |
| 50 | 49 | ||
| 51 | @table @code | 50 | @table @code |
| 51 | @item :tag @var{name} | ||
| 52 | Use @var{name}, a string, instead of the item's name, to label the item | ||
| 53 | in customization menus and buffers. | ||
| 54 | |||
| 52 | @item (custom-manual @var{info-node}) | 55 | @item (custom-manual @var{info-node}) |
| 53 | Link to an Info node; @var{info-node} is a string which specifies the | 56 | Link to an Info node; @var{info-node} is a string which specifies the |
| 54 | node name, as in @code{"(emacs)Top"}. The link appears as | 57 | node name, as in @code{"(emacs)Top"}. The link appears as |
| @@ -59,8 +62,8 @@ Like @code{custom-manual} except that the link appears | |||
| 59 | in the customization buffer with the Info node name. | 62 | in the customization buffer with the Info node name. |
| 60 | 63 | ||
| 61 | @item (url-link @var{url}) | 64 | @item (url-link @var{url}) |
| 62 | Link to a web page; @var{url} is a string which specifies the URL. The | 65 | Link to a web page; @var{url} is a string which specifies the @sc{url}. |
| 63 | link appears in the customization buffer as @var{url}. | 66 | The link appears in the customization buffer as @var{url}. |
| 64 | @end table | 67 | @end table |
| 65 | 68 | ||
| 66 | You can specify the text to use in the customization buffer by adding | 69 | You can specify the text to use in the customization buffer by adding |
| @@ -84,30 +87,27 @@ feature. This is done by calling @code{require}. | |||
| 84 | The most common reason to use @code{:require} is when a variable enables | 87 | The most common reason to use @code{:require} is when a variable enables |
| 85 | a feature such as a minor mode, and just setting the variable won't have | 88 | a feature such as a minor mode, and just setting the variable won't have |
| 86 | any effect unless the code which implements the mode is loaded. | 89 | any effect unless the code which implements the mode is loaded. |
| 87 | |||
| 88 | @item :tag @var{name} | ||
| 89 | Use @var{name}, a string, instead of the item's name, to label the item | ||
| 90 | in customization menus and buffers. | ||
| 91 | @end table | 90 | @end table |
| 92 | 91 | ||
| 93 | @node Group Definitions | 92 | @node Group Definitions |
| 94 | @section Defining Custom Groups | 93 | @section Defining Custom Groups |
| 95 | 94 | ||
| 96 | Each Emacs Lisp package should have one main customization group which | 95 | Each Emacs Lisp package should have one main customization group which |
| 97 | contains all the options, faces and other groups in the package. If the | 96 | contains all the options, faces and other groups in the package. If the |
| 98 | package has a small number of options and faces, use just one group and | 97 | package has a small number of options and faces, use just one group and |
| 99 | put everything in it. When there are more than twelve or so options and | 98 | put everything in it. When there are more than twelve or so options and |
| 100 | faces, then you should structure them into subgroups, and put the | 99 | faces, then you should structure them into subgroups, and put the |
| 101 | subgroups under the package's main customization group. It is ok to | 100 | subgroups under the package's main customization group. It is OK to |
| 102 | have some of the options and faces in the package's main group alongside | 101 | put some of the options and faces in the package's main group alongside |
| 103 | the subgroups. | 102 | the subgroups. |
| 104 | 103 | ||
| 105 | The package's main or only group should be a member of one or more of | 104 | The package's main or only group should be a member of one or more of |
| 106 | the standard customization groups. Type press @kbd{C-h p} to display a | 105 | the standard customization groups. (To display the full list of them, |
| 107 | list of finder keywords; them choose some of them add your group to each | 106 | use @kbd{M-x customize}.) Choose one or more of them (but not too |
| 108 | of them, using the @code{:group} keyword. | 107 | many), and add your group to each of them using the @code{:group} |
| 108 | keyword. | ||
| 109 | 109 | ||
| 110 | The way to declare new customization groups is with @code{defgroup}. | 110 | The way to declare new customization groups is with @code{defgroup}. |
| 111 | 111 | ||
| 112 | @tindex defgroup | 112 | @tindex defgroup |
| 113 | @defmac defgroup group members doc [keyword value]... | 113 | @defmac defgroup group members doc [keyword value]... |
| @@ -116,9 +116,9 @@ Do not quote the symbol @var{group}. The argument @var{doc} specifies | |||
| 116 | the documentation string for the group. | 116 | the documentation string for the group. |
| 117 | 117 | ||
| 118 | The arguments @var{members} can be an alist whose elements specify | 118 | The arguments @var{members} can be an alist whose elements specify |
| 119 | members of the group; however, normally @var{members} is @code{nil}, and | 119 | customization items to be members of the group; however, normally |
| 120 | you specify the group's members by using the @code{:group} keyword when | 120 | @var{members} is @code{nil}, and you specify the group's members by |
| 121 | defining those members. | 121 | using the @code{:group} keyword when defining those members. |
| 122 | 122 | ||
| 123 | @ignore | 123 | @ignore |
| 124 | @code{(@var{name} @var{widget})}. Here @var{name} is a symbol, and | 124 | @code{(@var{name} @var{widget})}. Here @var{name} is a symbol, and |
| @@ -139,40 +139,40 @@ One group can have any number of prefixes. | |||
| 139 | @end table | 139 | @end table |
| 140 | @end defmac | 140 | @end defmac |
| 141 | 141 | ||
| 142 | The @code{:prefix} feature is currently turned off, which means that | 142 | The prefix-discarding feature is currently turned off, which means |
| 143 | @code{:prefix} currently has no effect. We did this because we found | 143 | that @code{:prefix} currently has no effect. We did this because we |
| 144 | that discarding the specified prefixes often led to confusing names for | 144 | found that discarding the specified prefixes often led to confusing |
| 145 | options. This happened because the people who wrote the @code{defgroup} | 145 | names for options. This happened because the people who wrote the |
| 146 | definitions for various groups added @code{:prefix} keywords whenever | 146 | @code{defgroup} definitions for various groups added @code{:prefix} |
| 147 | they make logical sense---that is, whenever they say that there was a | 147 | keywords whenever they make logical sense---that is, whenever the |
| 148 | common prefix for the option names in a library. | 148 | variables in the library have a common prefix. |
| 149 | 149 | ||
| 150 | In order to obtain good results with @code{:prefix}, it is necessary to | 150 | In order to obtain good results with @code{:prefix}, it would be |
| 151 | check the specific effects of discarding a particular prefix, given the | 151 | necessary to check the specific effects of discarding a particular |
| 152 | specific items in a group and their names and documentation. If the | 152 | prefix, given the specific items in a group and their names and |
| 153 | resulting text is not clear, then @code{:prefix} should not be used in | 153 | documentation. If the resulting text is not clear, then @code{:prefix} |
| 154 | that case. | 154 | should not be used in that case. |
| 155 | 155 | ||
| 156 | It should be possible to recheck all the customization groups, delete | 156 | It should be possible to recheck all the customization groups, delete |
| 157 | the @code{:prefix} specifications which give unclear results, and then | 157 | the @code{:prefix} specifications which give unclear results, and then |
| 158 | turn this feature back on, if someone would like to do the work. | 158 | turn this feature back on, if someone would like to do the work. |
| 159 | 159 | ||
| 160 | @node Variable Definitions | 160 | @node Variable Definitions |
| 161 | @section Defining Customization Variables | 161 | @section Defining Customization Variables |
| 162 | 162 | ||
| 163 | Use @code{defcustom} to declare user editable variables. | 163 | Use @code{defcustom} to declare user-editable variables. |
| 164 | 164 | ||
| 165 | @tindex defcustom | 165 | @tindex defcustom |
| 166 | @defmac defcustom option value doc [keyword value]... | 166 | @defmac defcustom option default doc [keyword value]... |
| 167 | Declare @var{option} as a customizable user option variable that | 167 | Declare @var{option} as a customizable user option variable. Do not |
| 168 | defaults to @var{value}. Do not quote @var{option}. @var{value} should | 168 | quote @var{option}. The argument @var{doc} specifies the documentation |
| 169 | be an expression to compute the value; it will be be evaluated on more | 169 | string for the variable. |
| 170 | |||
| 171 | If @var{option} is void, @code{defcustom} initializes it to | ||
| 172 | @var{default}. @var{default} should be an expression to compute the | ||
| 173 | value; be careful in writing it, because it can be be evaluated on more | ||
| 170 | than one occasion. | 174 | than one occasion. |
| 171 | 175 | ||
| 172 | If @var{option} is void, @code{defcustom} initializes it to @var{value}. | ||
| 173 | |||
| 174 | The argument @var{doc} specifies the documentation string for the variable. | ||
| 175 | |||
| 176 | The following additional keywords are defined: | 176 | The following additional keywords are defined: |
| 177 | 177 | ||
| 178 | @table @code | 178 | @table @code |
| @@ -185,11 +185,10 @@ values are legitimate, and how to display the value. | |||
| 185 | Specify @var{list} as the list of reasonable values for use in this | 185 | Specify @var{list} as the list of reasonable values for use in this |
| 186 | option. | 186 | option. |
| 187 | 187 | ||
| 188 | Currently this is meaningful only when type is @code{hook}. The | 188 | Currently this is meaningful only when the type is @code{hook}. In that |
| 189 | elements of @var{list} are functions that you might likely want to use | 189 | case, the elements of @var{list} should be functions that are useful as |
| 190 | as elements of the hook value. The user is not actually restricted to | 190 | elements of the hook value. The user is not restricted to using only |
| 191 | using only these functions, but they are offered as convenient | 191 | these functions, but they are offered as convenient alternatives. |
| 192 | alternatives. | ||
| 193 | 192 | ||
| 194 | @item :version @var{version} | 193 | @item :version @var{version} |
| 195 | This option specifies that the variable's default value was changed in | 194 | This option specifies that the variable's default value was changed in |
| @@ -226,35 +225,47 @@ this way: | |||
| 226 | 225 | ||
| 227 | @table @code | 226 | @table @code |
| 228 | @item custom-initialize-set | 227 | @item custom-initialize-set |
| 229 | Use the variable's @code{:set} function to initialize the variable. Do | 228 | Use the variable's @code{:set} function to initialize the variable, but |
| 230 | not reinitialize it if it is already non-void. This is the default | 229 | do not reinitialize it if it is already non-void. This is the default |
| 231 | @code{:initialize} function. | 230 | @code{:initialize} function. |
| 232 | 231 | ||
| 233 | @item custom-initialize-default | 232 | @item custom-initialize-default |
| 234 | Always use @code{set-default} to initialize the variable, even if some | 233 | Like @code{custom-initialize-set}, but use the function |
| 235 | other @code{:set} function has been specified. | 234 | @code{set-default} to set the variable, instead of the variable's |
| 235 | @code{:set} function. This is the usual choice for a variable whose | ||
| 236 | @code{:set} function enables or disables a minor mode; with this choice, | ||
| 237 | defining the variable will not call the minor mode function, but | ||
| 238 | customizing the variable will do so. | ||
| 236 | 239 | ||
| 237 | @item custom-initialize-reset | 240 | @item custom-initialize-reset |
| 238 | Even if the variable is already non-void, reset it by calling the | 241 | Always use the @code{:set} function to initialize the variable. If the |
| 239 | @code{:set} function using the current value (returned by the | 242 | variable is already non-void, reset it by calling the @code{:set} |
| 240 | @code{:get} method). | 243 | function using the current value (returned by the @code{:get} method). |
| 241 | 244 | ||
| 242 | @item custom-initialize-changed | 245 | @item custom-initialize-changed |
| 243 | Like @code{custom-initialize-reset}, except use @code{set-default} | 246 | Use the @code{:set} function to initialize the variable, if it is |
| 244 | (rather than the @code{:set} function) to initialize the variable if it | 247 | already set or has been customized; otherwise, just use |
| 245 | is not bound and has not been set already. | 248 | @code{set-default}. |
| 246 | @end table | 249 | @end table |
| 250 | @end table | ||
| 251 | @end defmac | ||
| 247 | 252 | ||
| 248 | @item :require @var{feature} | 253 | The @code{:require} option is useful for an option that turns on the |
| 249 | If the user saves a customized value for this item, them Emacs should do | ||
| 250 | @code{(require @var{feature})} after installing the saved value. | ||
| 251 | |||
| 252 | The place to use this feature is for an option that turns on the | ||
| 253 | operation of a certain feature. Assuming that the package is coded to | 254 | operation of a certain feature. Assuming that the package is coded to |
| 254 | check the value of the option, you still need to arrange for the package | 255 | check the value of the option, you still need to arrange for the package |
| 255 | to be loaded. That is what @code{:require} is for. | 256 | to be loaded. You can do that with @code{:require}. @xref{Common |
| 256 | @end table | 257 | Keywords}. Here is an example, from the library @file{paren.el}: |
| 257 | @end defmac | 258 | |
| 259 | @example | ||
| 260 | (defcustom show-paren-mode nil | ||
| 261 | "Toggle Show Paren mode@enddots{}" | ||
| 262 | :set (lambda (symbol value) | ||
| 263 | (show-paren-mode (or value 0))) | ||
| 264 | :initialize 'custom-initialize-default | ||
| 265 | :type 'boolean | ||
| 266 | :group 'paren-showing | ||
| 267 | :require 'paren) | ||
| 268 | @end example | ||
| 258 | 269 | ||
| 259 | @ignore | 270 | @ignore |
| 260 | Use @code{custom-add-option} to specify that a specific function is | 271 | Use @code{custom-add-option} to specify that a specific function is |
| @@ -274,103 +285,37 @@ and @code{saved-value} to record the value saved by the user with the | |||
| 274 | customization buffer. The @code{saved-value} property is actually a | 285 | customization buffer. The @code{saved-value} property is actually a |
| 275 | list whose car is an expression which evaluates to the value. | 286 | list whose car is an expression which evaluates to the value. |
| 276 | 287 | ||
| 277 | @node Face Definitions | ||
| 278 | @section Defining Faces | ||
| 279 | |||
| 280 | Faces are declared with @code{defface}. | ||
| 281 | |||
| 282 | @tindex defface | ||
| 283 | @defmac defface face spec doc [keyword value]... | ||
| 284 | Declare @var{face} as a customizable face that defaults according to | ||
| 285 | @var{spec}. Do not quote the symbol @var{face}. | ||
| 286 | |||
| 287 | @var{doc} is the face documentation. | ||
| 288 | |||
| 289 | @var{spec} should be an alist whose elements have the form | ||
| 290 | @code{(@var{display} @var{atts})} (see below). When @code{defface} | ||
| 291 | executes, it defines the face according to @var{spec}, then uses any | ||
| 292 | customizations saved in the @file{.emacs} file to override that | ||
| 293 | specification. | ||
| 294 | |||
| 295 | In each element of @var{spec}, @var{atts} is a list of face attributes | ||
| 296 | and their values. The possible attributes are defined in the variable | ||
| 297 | @code{custom-face-attributes}. | ||
| 298 | |||
| 299 | The @var{display} part of an element of @var{spec} determines which | ||
| 300 | frames the element applies to. If more than one element of @var{spec} | ||
| 301 | matches a given frame, the first matching element is the only one used | ||
| 302 | for that frame. | ||
| 303 | |||
| 304 | If @var{display} is @code{t} in a @var{spec} element, that element | ||
| 305 | matches all frames. (This means that any subsequent elements of | ||
| 306 | @var{spec} are never used.) | ||
| 307 | |||
| 308 | Alternatively, @var{display} can be an alist whose elements have the | ||
| 309 | form @code{(@var{characteristic} @var{value}@dots{})}. Here | ||
| 310 | @var{characteristic} specifies a way of classifying frames, and the | ||
| 311 | @var{value}s are possible classifications which @var{display} should | ||
| 312 | apply to. Here are the possible values of @var{characteristic}: | ||
| 313 | |||
| 314 | @table @code | ||
| 315 | @item type | ||
| 316 | The kind of window system the frame uses---either @code{x}, @code{pc} | ||
| 317 | (for the MS-DOS console), @code{w32} (for MS Windows 9X/NT), or | ||
| 318 | @code{tty}. | ||
| 319 | |||
| 320 | @item class | ||
| 321 | What kinds of colors the frame supports---either @code{color}, | ||
| 322 | @code{grayscale}, or @code{mono}. | ||
| 323 | |||
| 324 | @item background | ||
| 325 | The kind of background--- either @code{light} or @code{dark}. | ||
| 326 | @end table | ||
| 327 | |||
| 328 | If an element of @var{display} specifies more than one | ||
| 329 | @var{value} for a given @var{characteristic}, any of those values | ||
| 330 | is acceptable. If an element of @var{display} has elements for | ||
| 331 | more than one @var{characteristic}, then @var{each} characteristic | ||
| 332 | of the frame must match one of the values specified for it. | ||
| 333 | @end defmac | ||
| 334 | |||
| 335 | Internally, @code{defface} uses the symbol property | ||
| 336 | @code{face-defface-spec} to record the face attributes specified in | ||
| 337 | @code{defface}, @code{saved-face} for the attributes saved by the user | ||
| 338 | with the customization buffer, and @code{face-documentation} for the | ||
| 339 | documentation string. | ||
| 340 | |||
| 341 | @node Customization Types | 288 | @node Customization Types |
| 342 | @section Customization Types | 289 | @section Customization Types |
| 343 | 290 | ||
| 344 | When you define a user option with @code{defcustom}, you must specify | 291 | When you define a user option with @code{defcustom}, you must specify |
| 345 | its @dfn{customization type}. That is a Lisp object which indictaes (1) | 292 | its @dfn{customization type}. That is a Lisp object which describes (1) |
| 346 | which values are legitimate and (2) how to display the value in the | 293 | which values are legitimate and (2) how to display the value in the |
| 347 | customization buffer for editing. | 294 | customization buffer for editing. |
| 348 | 295 | ||
| 349 | You specify the customization type in @code{defcustom} with the | 296 | You specify the customization type in @code{defcustom} with the |
| 350 | @code{:type} keyword. The argument of @code{:type} is evaluated; since | 297 | @code{:type} keyword. The argument of @code{:type} is evaluated; since |
| 351 | types that vary at run time are rarely useful, normally it is a quoted | 298 | types that vary at run time are rarely useful, normally you use a quoted |
| 352 | constant. For example: | 299 | constant. For example: |
| 353 | 300 | ||
| 354 | @example | 301 | @example |
| 355 | (defcustom diff-command "diff" | 302 | (defcustom diff-command "diff" |
| 356 | "*The command to use to run diff." | 303 | "*The command to use to run diff." |
| 357 | :type 'string | 304 | :type '(string) |
| 358 | :group 'diff) | 305 | :group 'diff) |
| 359 | @end example | 306 | @end example |
| 360 | 307 | ||
| 361 | In general, a customization type appears is a list whose first element | 308 | In general, a customization type is a list whose first element is a |
| 362 | is a symbol, one of the customization type names defined in the | 309 | symbol, one of the customization type names defined in the following |
| 363 | following sections. After this symbol come a number of arguments, | 310 | sections. After this symbol come a number of arguments, depending on |
| 364 | depending on the symbol. Some of the type symbols do not use any | 311 | the symbol. Between the type symbol and its arguments, you can |
| 365 | arguments; those are called @dfn{simple types}. | 312 | optionally write keyword-value pairs (@pxref{Type Keywords}). |
| 366 | |||
| 367 | In between the type symbol and its arguments, you can optionally | ||
| 368 | write keyword-value pairs. @xref{Type Keywords}. | ||
| 369 | 313 | ||
| 370 | For a simple type, if you do not use any keyword-value pairs, you can | 314 | Some of the type symbols do not use any arguments; those are called |
| 371 | omit the parentheses around the type symbol. The above example does | 315 | @dfn{simple types}. For a simple type, if you do not use any |
| 372 | this, using just @code{string} as the customization type. | 316 | keyword-value pairs, you can omit the parentheses around the type |
| 373 | But @code{(string)} would mean the same thing. | 317 | symbol. For example just @code{string} as a customization type is |
| 318 | equivalent to @code{(string)}. | ||
| 374 | 319 | ||
| 375 | @menu | 320 | @menu |
| 376 | * Simple Types:: | 321 | * Simple Types:: |
| @@ -400,10 +345,12 @@ customization buffer. | |||
| 400 | 345 | ||
| 401 | @item string | 346 | @item string |
| 402 | The value must be a string, and the customization buffer shows just the | 347 | The value must be a string, and the customization buffer shows just the |
| 403 | contents, with no @samp{"} characters or quoting with @samp{\}. | 348 | contents, with no delimiting @samp{"} characters and no quoting with |
| 349 | @samp{\}. | ||
| 404 | 350 | ||
| 405 | @item regexp | 351 | @item regexp |
| 406 | The value must be a string which is a valid regular expression. | 352 | Like @code{string} except that the string must be a valid regular |
| 353 | expression. | ||
| 407 | 354 | ||
| 408 | @item character | 355 | @item character |
| 409 | The value must be a character code. A character code is actually an | 356 | The value must be a character code. A character code is actually an |
| @@ -435,15 +382,19 @@ The value must be a variable name, and you can do completion with | |||
| 435 | @kbd{M-@key{TAB}}. | 382 | @kbd{M-@key{TAB}}. |
| 436 | 383 | ||
| 437 | @item boolean | 384 | @item boolean |
| 438 | The value is boolean---either @code{nil} or @code{t}. | 385 | The value is boolean---either @code{nil} or @code{t}. Note that by |
| 386 | using @code{choice} and @code{const} together (see the next section), | ||
| 387 | you can specify that the value must be @code{nil} or @code{t}, but also | ||
| 388 | specify the text to describe each value in a way that fits the specific | ||
| 389 | meaning of the alternative. | ||
| 439 | @end table | 390 | @end table |
| 440 | 391 | ||
| 441 | @node Composite Types | 392 | @node Composite Types |
| 442 | @subsection Composite Types | 393 | @subsection Composite Types |
| 443 | 394 | ||
| 444 | When none of the simple types is appropriate, you can use composite | 395 | When none of the simple types is appropriate, you can use composite |
| 445 | types, which build from simple types. Here are several ways of doing | 396 | types, which build new types from other types. Here are several ways of |
| 446 | that: | 397 | doing that: |
| 447 | 398 | ||
| 448 | @table @code | 399 | @table @code |
| 449 | @item (restricted-sexp :match-alternatives @var{criteria}) | 400 | @item (restricted-sexp :match-alternatives @var{criteria}) |
| @@ -459,7 +410,7 @@ are acceptable. | |||
| 459 | 410 | ||
| 460 | @item | 411 | @item |
| 461 | A quoted constant---that is, @code{'@var{object}}. This means that | 412 | A quoted constant---that is, @code{'@var{object}}. This means that |
| 462 | @var{object} is an acceptable value. | 413 | @var{object} itself is an acceptable value. |
| 463 | @end itemize | 414 | @end itemize |
| 464 | 415 | ||
| 465 | For example, | 416 | For example, |
| @@ -480,7 +431,7 @@ its @sc{cdr} must fit @var{cdr-type}. For example, @code{(const string | |||
| 480 | symbol)} is a customization type which matches values such as | 431 | symbol)} is a customization type which matches values such as |
| 481 | @code{("foo" . foo)}. | 432 | @code{("foo" . foo)}. |
| 482 | 433 | ||
| 483 | In the customization buffeer, the @sc{car} and the @sc{cdr} are | 434 | In the customization buffer, the @sc{car} and the @sc{cdr} are |
| 484 | displayed and edited separately, each according to the type | 435 | displayed and edited separately, each according to the type |
| 485 | that you specify for it. | 436 | that you specify for it. |
| 486 | 437 | ||
| @@ -493,7 +444,7 @@ For example, @code{(list integer string function)} describes a list of | |||
| 493 | three elements; the first element must be an integer, the second a | 444 | three elements; the first element must be an integer, the second a |
| 494 | string, and the third a function. | 445 | string, and the third a function. |
| 495 | 446 | ||
| 496 | In the customization buffeer, the each element is displayed and edited | 447 | In the customization buffer, the each element is displayed and edited |
| 497 | separately, according to the type specified for it. | 448 | separately, according to the type specified for it. |
| 498 | 449 | ||
| 499 | @item (vector @var{element-types}@dots{}) | 450 | @item (vector @var{element-types}@dots{}) |
| @@ -523,22 +474,37 @@ verbatim, you might write the customization type this way, | |||
| 523 | @noindent | 474 | @noindent |
| 524 | so that the menu offers @samp{Number of spaces} and @samp{Literal Text}. | 475 | so that the menu offers @samp{Number of spaces} and @samp{Literal Text}. |
| 525 | 476 | ||
| 477 | In any alternative for which @code{nil} is not a valid value, other than | ||
| 478 | a @code{const}, you should specify a valid default for that alternative | ||
| 479 | using the @code{:value} keyword. @xref{Type Keywords}. | ||
| 480 | |||
| 526 | @item (const @var{value}) | 481 | @item (const @var{value}) |
| 527 | The value must be @var{value}---nothing else is allowed. | 482 | The value must be @var{value}---nothing else is allowed. |
| 528 | 483 | ||
| 529 | The main use of @code{const} is inside of @code{choice}. For example, | 484 | The main use of @code{const} is inside of @code{choice}. For example, |
| 530 | @code{(choice integer (const nil))} allows either an integer or | 485 | @code{(choice integer (const nil))} allows either an integer or |
| 531 | @code{nil}. @code{:tag} is often used with @code{const}. | 486 | @code{nil}. |
| 487 | |||
| 488 | @code{:tag} is often used with @code{const}, inside of @code{choice}. | ||
| 489 | For example, | ||
| 490 | |||
| 491 | @smallexample | ||
| 492 | (choice (const :tag "Yes" t) | ||
| 493 | (const :tag "No" nil) | ||
| 494 | (const :tag "Ask" foo)) | ||
| 495 | @end smallexample | ||
| 532 | 496 | ||
| 533 | @item (function-item @var{function}) | 497 | @item (function-item @var{function}) |
| 534 | Like @code{const}, but used for values which are functions. This | 498 | Like @code{const}, but used for values which are functions. This |
| 535 | displays the documentation string of the function @var{function} | 499 | displays the documentation string as well as the function name. |
| 536 | as well as its name. | 500 | The documentation string is either the one you specify with |
| 501 | @code{:doc}, or @var{function}'s own documentation string. | ||
| 537 | 502 | ||
| 538 | @item (variable-item @var{variable}) | 503 | @item (variable-item @var{variable}) |
| 539 | Like @code{const}, but used for values which are variable names. This | 504 | Like @code{const}, but used for values which are variable names. This |
| 540 | displays the documentation string of the variable @var{variable} as well | 505 | displays the documentation string as well as the variable name. The |
| 541 | as its name. | 506 | documentation string is either the one you specify with @code{:doc}, or |
| 507 | @var{variable}'s own documentation string. | ||
| 542 | 508 | ||
| 543 | @item (set @var{elements}@dots{}) | 509 | @item (set @var{elements}@dots{}) |
| 544 | The value must be a list and each element of the list must be one of the | 510 | The value must be a list and each element of the list must be one of the |
| @@ -611,20 +577,22 @@ meanings: | |||
| 611 | @table @code | 577 | @table @code |
| 612 | @item :value @var{default} | 578 | @item :value @var{default} |
| 613 | This is used for a type that appears as an alternative inside of | 579 | This is used for a type that appears as an alternative inside of |
| 614 | @code{:choice}; it specifies the default value to use, at first, if and | 580 | @code{choice}; it specifies the default value to use, at first, if and |
| 615 | when the user selects this alternative with the menu in the | 581 | when the user selects this alternative with the menu in the |
| 616 | customization buffer. | 582 | customization buffer. |
| 617 | 583 | ||
| 618 | Of course, if the actual value of the option fits this alternative, it | 584 | Of course, if the actual value of the option fits this alternative, it |
| 619 | will appear showing the actual value, not @var{default}. | 585 | will appear showing the actual value, not @var{default}. |
| 620 | 586 | ||
| 587 | If @code{nil} is not a valid value for the alternative, then it is | ||
| 588 | essential to specify a valid default with @code{:value}. | ||
| 589 | |||
| 621 | @item :format @var{format-string} | 590 | @item :format @var{format-string} |
| 622 | This string will be inserted in the buffer to represent the value | 591 | This string will be inserted in the buffer to represent the value |
| 623 | corresponding to the type. The following @samp{%} escapes are available | 592 | corresponding to the type. The following @samp{%} escapes are available |
| 624 | for use in @var{format-string}: | 593 | for use in @var{format-string}: |
| 625 | 594 | ||
| 626 | @table @samp | 595 | @table @samp |
| 627 | @ignore | ||
| 628 | @item %[@var{button}%] | 596 | @item %[@var{button}%] |
| 629 | Display the text @var{button} marked as a button. The @code{:action} | 597 | Display the text @var{button} marked as a button. The @code{:action} |
| 630 | attribute specifies what the button will do if the user invokes it; | 598 | attribute specifies what the button will do if the user invokes it; |
| @@ -632,8 +600,7 @@ its value is a function which takes two arguments---the widget which | |||
| 632 | the button appears in, and the event. | 600 | the button appears in, and the event. |
| 633 | 601 | ||
| 634 | There is no way to specify two different buttons with different | 602 | There is no way to specify two different buttons with different |
| 635 | actions; but perhaps there is no need for one. | 603 | actions. |
| 636 | @end ignore | ||
| 637 | 604 | ||
| 638 | @item %@{@var{sample}%@} | 605 | @item %@{@var{sample}%@} |
| 639 | Show @var{sample} in a special face specified by @code{:sample-face}. | 606 | Show @var{sample} in a special face specified by @code{:sample-face}. |
| @@ -658,11 +625,15 @@ keyword. | |||
| 658 | Display a literal @samp{%}. | 625 | Display a literal @samp{%}. |
| 659 | @end table | 626 | @end table |
| 660 | 627 | ||
| 628 | @item :action @var{action} | ||
| 629 | Perform @var{action} if the user clicks on a button. | ||
| 630 | |||
| 661 | @item :button-face @var{face} | 631 | @item :button-face @var{face} |
| 662 | Use face @var{face} for text displayed with @samp{%[@dots{}%]}. | 632 | Use the face @var{face} (a face name or a list of face names) for button |
| 633 | text displayed with @samp{%[@dots{}%]}. | ||
| 663 | 634 | ||
| 664 | @item :button-prefix | 635 | @item :button-prefix @var{prefix} |
| 665 | @itemx :button-suffix | 636 | @itemx :button-suffix @var{suffix} |
| 666 | These specify the text to display before and after a button. | 637 | These specify the text to display before and after a button. |
| 667 | Each can be: | 638 | Each can be: |
| 668 | 639 | ||
| @@ -677,11 +648,19 @@ The string is inserted literally. | |||
| 677 | The symbol's value is used. | 648 | The symbol's value is used. |
| 678 | @end table | 649 | @end table |
| 679 | 650 | ||
| 651 | @item :tag @var{tag} | ||
| 652 | Use @var{tag} (a string) as the tag for the value (or part of the value) | ||
| 653 | that corresponds to this type. | ||
| 654 | |||
| 680 | @item :doc @var{doc} | 655 | @item :doc @var{doc} |
| 681 | Use @var{doc} as the documentation string for this item. | 656 | Use @var{doc} as the documentation string for this value (or part of the |
| 657 | value) that corresponds to this type. In order for this to work, you | ||
| 658 | must specify a value for @code{:format}, and use @samp{%d} or @samp{%h} | ||
| 659 | in that value. | ||
| 682 | 660 | ||
| 683 | @item :tag @var{tag} | 661 | The usual reason to specify a documentation string for a type is to |
| 684 | Use @var{tag} (a string) as the tag for this item. | 662 | provide more information about the meanings of alternatives inside a |
| 663 | @code{:choice} type or the parts of some other composite type. | ||
| 685 | 664 | ||
| 686 | @item :help-echo @var{motion-doc} | 665 | @item :help-echo @var{motion-doc} |
| 687 | When you move to this item with @code{widget-forward} or | 666 | When you move to this item with @code{widget-forward} or |
| @@ -689,9 +668,10 @@ When you move to this item with @code{widget-forward} or | |||
| 689 | in the echo area. | 668 | in the echo area. |
| 690 | 669 | ||
| 691 | @item :match @var{function} | 670 | @item :match @var{function} |
| 692 | Specify how to decide whether a value matches the type. @var{function} | 671 | Specify how to decide whether a value matches the type. The |
| 693 | should be a function that accepts two arguments, a widget and a value; | 672 | corresponding value, @var{function}, should be a function that accepts |
| 694 | it should return non-@code{nil} if the value is acceptable. | 673 | two arguments, a widget and a value; it should return non-@code{nil} if |
| 674 | the value is acceptable. | ||
| 695 | 675 | ||
| 696 | @ignore | 676 | @ignore |
| 697 | @item :indent @var{columns} | 677 | @item :indent @var{columns} |
diff --git a/lispref/debugging.texi b/lispref/debugging.texi index 99e5e034358..9c7a4fd7be7 100644 --- a/lispref/debugging.texi +++ b/lispref/debugging.texi | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/debugging | 5 | @setfilename ../info/debugging |
| 6 | @node Debugging, Read and Print, Byte Compilation, Top | 6 | @node Debugging, Read and Print, Advising, Top |
| 7 | @chapter Debugging Lisp Programs | 7 | @chapter Debugging Lisp Programs |
| 8 | 8 | ||
| 9 | There are three ways to investigate a problem in an Emacs Lisp program, | 9 | There are three ways to investigate a problem in an Emacs Lisp program, |
| @@ -104,14 +104,18 @@ that error does not enter the debugger, regardless of the value of | |||
| 104 | @code{debug-on-error}. | 104 | @code{debug-on-error}. |
| 105 | 105 | ||
| 106 | The normal value of this variable lists several errors that happen often | 106 | The normal value of this variable lists several errors that happen often |
| 107 | during editing but rarely result from bugs in Lisp programs. | 107 | during editing but rarely result from bugs in Lisp programs. However, |
| 108 | ``rarely'' is not ``never''; if your program fails with an error that | ||
| 109 | matches this list, you will need to change this list in order to debug | ||
| 110 | the error. The easiest way is usually to set | ||
| 111 | @code{debug-ignored-errors} to @code{nil}. | ||
| 108 | @end defopt | 112 | @end defopt |
| 109 | 113 | ||
| 110 | @defopt debug-on-signal | 114 | @defopt debug-on-signal |
| 111 | Normally, errors that are caught by @code{condition-case} never run the | 115 | Normally, errors that are caught by @code{condition-case} never run the |
| 112 | debugger, even if @code{debug-on-error} is non-@code{nil}. In other | 116 | debugger, even if @code{debug-on-error} is non-@code{nil}. In other |
| 113 | words, @code{condition-case} gets a chance to catch the error before the | 117 | words, @code{condition-case} gets a chance to handle the error before |
| 114 | debugger gets a chance. | 118 | the debugger gets a chance. |
| 115 | 119 | ||
| 116 | If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets | 120 | If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets |
| 117 | first chance at every error; an error will invoke the debugger | 121 | first chance at every error; an error will invoke the debugger |
| @@ -119,7 +123,7 @@ regardless of any @code{condition-case}, if the fits the criterion | |||
| 119 | specified by the values of @code{debug-on-error} and | 123 | specified by the values of @code{debug-on-error} and |
| 120 | @code{debug-ignored-errors}. | 124 | @code{debug-ignored-errors}. |
| 121 | 125 | ||
| 122 | @strong{Warning:} This variable is strong medecine! Various parts of | 126 | @strong{Warning:} This variable is strong medicine! Various parts of |
| 123 | Emacs handle errors in the normal course of affairs, and you may not | 127 | Emacs handle errors in the normal course of affairs, and you may not |
| 124 | even realize that errors happen there. If you set | 128 | even realize that errors happen there. If you set |
| 125 | @code{debug-on-signal} to a non-@code{nil} value, those errors will | 129 | @code{debug-on-signal} to a non-@code{nil} value, those errors will |
| @@ -132,7 +136,7 @@ enter the debugger. | |||
| 132 | To debug an error that happens during loading of the @file{.emacs} | 136 | To debug an error that happens during loading of the @file{.emacs} |
| 133 | file, use the option @samp{-debug-init}, which binds | 137 | file, use the option @samp{-debug-init}, which binds |
| 134 | @code{debug-on-error} to @code{t} while @file{.emacs} is loaded and | 138 | @code{debug-on-error} to @code{t} while @file{.emacs} is loaded and |
| 135 | inhibits use of @code{condition-case} to catch init file errors. | 139 | inhibits use of @code{condition-case} to catch init-file errors. |
| 136 | 140 | ||
| 137 | If your @file{.emacs} file sets @code{debug-on-error}, the effect may | 141 | If your @file{.emacs} file sets @code{debug-on-error}, the effect may |
| 138 | not last past the end of loading @file{.emacs}. (This is an undesirable | 142 | not last past the end of loading @file{.emacs}. (This is an undesirable |
| @@ -190,26 +194,25 @@ called shortly before the problem, step quickly over the call to that | |||
| 190 | function, and then step through its caller. | 194 | function, and then step through its caller. |
| 191 | 195 | ||
| 192 | @deffn Command debug-on-entry function-name | 196 | @deffn Command debug-on-entry function-name |
| 193 | This function requests @var{function-name} to invoke the debugger each time | 197 | This function requests @var{function-name} to invoke the debugger each time |
| 194 | it is called. It works by inserting the form @code{(debug 'debug)} into | 198 | it is called. It works by inserting the form @code{(debug 'debug)} into |
| 195 | the function definition as the first form. | 199 | the function definition as the first form. |
| 196 | 200 | ||
| 197 | Any function defined as Lisp code may be set to break on entry, | 201 | Any function defined as Lisp code may be set to break on entry, |
| 198 | regardless of whether it is interpreted code or compiled code. If the | 202 | regardless of whether it is interpreted code or compiled code. If the |
| 199 | function is a command, it will enter the debugger when called from Lisp | 203 | function is a command, it will enter the debugger when called from Lisp |
| 200 | and when called interactively (after the reading of the arguments). You | 204 | and when called interactively (after the reading of the arguments). You |
| 201 | can't debug primitive functions (i.e., those written in C) this way. | 205 | can't debug primitive functions (i.e., those written in C) this way. |
| 202 | 206 | ||
| 203 | When @code{debug-on-entry} is called interactively, it prompts | 207 | When @code{debug-on-entry} is called interactively, it prompts for |
| 204 | for @var{function-name} in the minibuffer. | 208 | @var{function-name} in the minibuffer. If the function is already set |
| 209 | up to invoke the debugger on entry, @code{debug-on-entry} does nothing. | ||
| 210 | @code{debug-on-entry} always returns @var{function-name}. | ||
| 205 | 211 | ||
| 206 | If the function is already set up to invoke the debugger on entry, | 212 | @strong{Note:} if you redefine a function after using |
| 207 | @code{debug-on-entry} does nothing. | 213 | @code{debug-on-entry} on it, the code to enter the debugger is discarded |
| 208 | 214 | by the redefinition. In effect, redefining the function cancels | |
| 209 | @strong{Note:} if you redefine a function after using | 215 | the break-on-entry feature for that function. |
| 210 | @code{debug-on-entry} on it, the code to enter the debugger is lost. | ||
| 211 | |||
| 212 | @code{debug-on-entry} returns @var{function-name}. | ||
| 213 | 216 | ||
| 214 | @example | 217 | @example |
| 215 | @group | 218 | @group |
| @@ -252,11 +255,12 @@ Entering: | |||
| 252 | This function undoes the effect of @code{debug-on-entry} on | 255 | This function undoes the effect of @code{debug-on-entry} on |
| 253 | @var{function-name}. When called interactively, it prompts for | 256 | @var{function-name}. When called interactively, it prompts for |
| 254 | @var{function-name} in the minibuffer. If @var{function-name} is | 257 | @var{function-name} in the minibuffer. If @var{function-name} is |
| 255 | @code{nil} or the empty string, it cancels debugging for all functions. | 258 | @code{nil} or the empty string, it cancels break-on-entry for all |
| 259 | functions. | ||
| 256 | 260 | ||
| 257 | If @code{cancel-debug-on-entry} is called more than once on the same | 261 | Calling @code{cancel-debug-on-entry} does nothing to a function which is |
| 258 | function, the second call does nothing. @code{cancel-debug-on-entry} | 262 | not currently set up to break on entry. It always returns |
| 259 | returns @var{function-name}. | 263 | @var{function-name}. |
| 260 | @end deffn | 264 | @end deffn |
| 261 | 265 | ||
| 262 | @node Explicit Debug | 266 | @node Explicit Debug |
| @@ -326,8 +330,8 @@ code, so that you can see how control flows. The debugger can step | |||
| 326 | through the control structures of an interpreted function, but cannot do | 330 | through the control structures of an interpreted function, but cannot do |
| 327 | so in a byte-compiled function. If you would like to step through a | 331 | so in a byte-compiled function. If you would like to step through a |
| 328 | byte-compiled function, replace it with an interpreted definition of the | 332 | byte-compiled function, replace it with an interpreted definition of the |
| 329 | same function. (To do this, visit the source file for the function and | 333 | same function. (To do this, visit the source for the function and type |
| 330 | type @kbd{C-M-x} on its definition.) | 334 | @kbd{C-M-x} on its definition.) |
| 331 | 335 | ||
| 332 | Here is a list of Debugger mode commands: | 336 | Here is a list of Debugger mode commands: |
| 333 | 337 | ||
| @@ -360,7 +364,8 @@ in the backtrace buffer. | |||
| 360 | 364 | ||
| 361 | @item u | 365 | @item u |
| 362 | Don't enter the debugger when the current frame is exited. This | 366 | Don't enter the debugger when the current frame is exited. This |
| 363 | cancels a @kbd{b} command on that frame. | 367 | cancels a @kbd{b} command on that frame. The visible effect is to |
| 368 | remove the star from the line in the backtrace buffer. | ||
| 364 | 369 | ||
| 365 | @item e | 370 | @item e |
| 366 | Read a Lisp expression in the minibuffer, evaluate it, and print the | 371 | Read a Lisp expression in the minibuffer, evaluate it, and print the |
| @@ -371,6 +376,10 @@ examine them. This makes the debugger more transparent. By contrast, | |||
| 371 | @kbd{M-:} does nothing special in the debugger; it shows you the | 376 | @kbd{M-:} does nothing special in the debugger; it shows you the |
| 372 | variable values within the debugger. | 377 | variable values within the debugger. |
| 373 | 378 | ||
| 379 | @item R | ||
| 380 | Like @kbd{e}, but also save the result of evaluation in the | ||
| 381 | buffer @samp{*Debugger-record*}. | ||
| 382 | |||
| 374 | @item q | 383 | @item q |
| 375 | Terminate the program being debugged; return to top-level Emacs | 384 | Terminate the program being debugged; return to top-level Emacs |
| 376 | command execution. | 385 | command execution. |
| @@ -383,11 +392,11 @@ Return a value from the debugger. The value is computed by reading an | |||
| 383 | expression with the minibuffer and evaluating it. | 392 | expression with the minibuffer and evaluating it. |
| 384 | 393 | ||
| 385 | The @kbd{r} command is useful when the debugger was invoked due to exit | 394 | The @kbd{r} command is useful when the debugger was invoked due to exit |
| 386 | from a Lisp call frame (as requested with @kbd{b}); then the value | 395 | from a Lisp call frame (as requested with @kbd{b} or by entering the |
| 387 | specified in the @kbd{r} command is used as the value of that frame. It | 396 | frame with @kbd{d}); then the value specified in the @kbd{r} command is |
| 388 | is also useful if you call @code{debug} and use its return value. | 397 | used as the value of that frame. It is also useful if you call |
| 389 | Otherwise, @kbd{r} has the same effect as @kbd{c}, and the specified | 398 | @code{debug} and use its return value. Otherwise, @kbd{r} has the same |
| 390 | return value does not matter. | 399 | effect as @kbd{c}, and the specified return value does not matter. |
| 391 | 400 | ||
| 392 | You can't use @kbd{r} when the debugger was entered due to an error. | 401 | You can't use @kbd{r} when the debugger was entered due to an error. |
| 393 | @end table | 402 | @end table |
| @@ -448,11 +457,11 @@ Beginning evaluation of function call form: | |||
| 448 | @end smallexample | 457 | @end smallexample |
| 449 | 458 | ||
| 450 | @item exit | 459 | @item exit |
| 451 | When the first argument is @code{exit}, it indicates the exit of a | 460 | When the first argument is @code{exit}, it indicates the exit of a stack |
| 452 | stack frame previously marked to invoke the debugger on exit. The | 461 | frame previously marked to invoke the debugger on exit. The second |
| 453 | second argument given to @code{debug} in this case is the value being | 462 | argument given to @code{debug} in this case is the value being returned |
| 454 | returned from the frame. The debugger displays @samp{Return value:} on | 463 | from the frame. The debugger displays @samp{Return value:} in the top |
| 455 | the top line of the buffer, followed by the value being returned. | 464 | line of the buffer, followed by the value being returned. |
| 456 | 465 | ||
| 457 | @item error | 466 | @item error |
| 458 | @cindex @code{error} in debug | 467 | @cindex @code{error} in debug |
| @@ -605,8 +614,8 @@ bound to @code{nil}. The debugger can set this variable to leave | |||
| 605 | information for future debugger invocations during the same command | 614 | information for future debugger invocations during the same command |
| 606 | invocation. | 615 | invocation. |
| 607 | 616 | ||
| 608 | The advantage, for the debugger, of using this variable rather than | 617 | The advantage, for the debugger, of using this variable rather than an |
| 609 | another global variable is that the data will never carry over to a | 618 | ordinary global variable is that the data will never carry over to a |
| 610 | subsequent command invocation. | 619 | subsequent command invocation. |
| 611 | @end defvar | 620 | @end defvar |
| 612 | 621 | ||
| @@ -671,7 +680,8 @@ close parenthesis, and finally return to the mark.) | |||
| 671 | way to be sure of this except by studying the program, but often the | 680 | way to be sure of this except by studying the program, but often the |
| 672 | existing indentation is a clue to where the parentheses should have | 681 | existing indentation is a clue to where the parentheses should have |
| 673 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} | 682 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} |
| 674 | and see what moves. | 683 | and see what moves. @strong{But don't do this yet!} Keep reading, |
| 684 | first. | ||
| 675 | 685 | ||
| 676 | Before you do this, make sure the defun has enough close parentheses. | 686 | Before you do this, make sure the defun has enough close parentheses. |
| 677 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest | 687 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest |
| @@ -702,7 +712,7 @@ parenthesis at the beginning of the file, back up over it, and type | |||
| 702 | insertion of the open parenthesis, and finally return to the mark.) | 712 | insertion of the open parenthesis, and finally return to the mark.) |
| 703 | 713 | ||
| 704 | Then find the actual matching close parenthesis by typing @kbd{C-M-f} | 714 | Then find the actual matching close parenthesis by typing @kbd{C-M-f} |
| 705 | at the beginning of the defun. This will leave you somewhere short of | 715 | at the beginning of that defun. This will leave you somewhere short of |
| 706 | the place where the defun ought to end. It is possible that you will | 716 | the place where the defun ought to end. It is possible that you will |
| 707 | find a spurious close parenthesis in that vicinity. | 717 | find a spurious close parenthesis in that vicinity. |
| 708 | 718 | ||
diff --git a/lispref/display.texi b/lispref/display.texi index 6a8c477e451..59782034ca6 100644 --- a/lispref/display.texi +++ b/lispref/display.texi | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/display | 5 | @setfilename ../info/display |
| 6 | @node Display, Calendar, System Interface, Top | 6 | @node Display, Calendar, Processes, Top |
| 7 | @chapter Emacs Display | 7 | @chapter Emacs Display |
| 8 | 8 | ||
| 9 | This chapter describes a number of features related to the display | 9 | This chapter describes a number of features related to the display |
| @@ -62,7 +62,7 @@ resumption. | |||
| 62 | @cindex resume (cf. @code{no-redraw-on-reenter}) | 62 | @cindex resume (cf. @code{no-redraw-on-reenter}) |
| 63 | This variable controls whether Emacs redraws the entire screen after it | 63 | This variable controls whether Emacs redraws the entire screen after it |
| 64 | has been suspended and resumed. Non-@code{nil} means there is no need | 64 | has been suspended and resumed. Non-@code{nil} means there is no need |
| 65 | to redraw, @code{nil} means redrawing is needed. | 65 | to redraw, @code{nil} means redrawing is needed. The default is @code{nil}. |
| 66 | @end defvar | 66 | @end defvar |
| 67 | 67 | ||
| 68 | @node Screen Size | 68 | @node Screen Size |
| @@ -136,9 +136,9 @@ line can either be continued on the next screen line, or truncated to | |||
| 136 | one screen line. The additional screen lines used to display a long | 136 | one screen line. The additional screen lines used to display a long |
| 137 | text line are called @dfn{continuation} lines. Normally, a @samp{$} in | 137 | text line are called @dfn{continuation} lines. Normally, a @samp{$} in |
| 138 | the rightmost column of the window indicates truncation; a @samp{\} on | 138 | the rightmost column of the window indicates truncation; a @samp{\} on |
| 139 | the rightmost column indicates a line that ``wraps'' or is continued | 139 | the rightmost column indicates a line that ``wraps'' onto the next line, |
| 140 | onto the next line. (The display table can specify alternative | 140 | which is also called @dfn{continuing} the line. (The display table can |
| 141 | indicators; see @ref{Display Tables}.) | 141 | specify alternative indicators; see @ref{Display Tables}.) |
| 142 | 142 | ||
| 143 | Note that continuation is different from filling; continuation happens | 143 | Note that continuation is different from filling; continuation happens |
| 144 | on the screen only, not in the buffer contents, and it breaks a line | 144 | on the screen only, not in the buffer contents, and it breaks a line |
| @@ -157,7 +157,7 @@ frame) regardless of the value of @code{truncate-lines}. | |||
| 157 | 157 | ||
| 158 | @defopt default-truncate-lines | 158 | @defopt default-truncate-lines |
| 159 | This variable is the default value for @code{truncate-lines}, for | 159 | This variable is the default value for @code{truncate-lines}, for |
| 160 | buffers that do not have local values for it. | 160 | buffers that do not have buffer-local values for it. |
| 161 | @end defopt | 161 | @end defopt |
| 162 | 162 | ||
| 163 | @defopt truncate-partial-width-windows | 163 | @defopt truncate-partial-width-windows |
| @@ -184,7 +184,7 @@ unless they are modified. | |||
| 184 | 184 | ||
| 185 | Turning on the cache slows down processing of short lines somewhat. | 185 | Turning on the cache slows down processing of short lines somewhat. |
| 186 | 186 | ||
| 187 | This variable is automatically local in every buffer. | 187 | This variable is automatically buffer-local in every buffer. |
| 188 | @end defvar | 188 | @end defvar |
| 189 | 189 | ||
| 190 | @node The Echo Area | 190 | @node The Echo Area |
| @@ -242,6 +242,16 @@ This function returns the message currently being displayed in the | |||
| 242 | echo area, or @code{nil} if there is none. | 242 | echo area, or @code{nil} if there is none. |
| 243 | @end defun | 243 | @end defun |
| 244 | 244 | ||
| 245 | @defvar cursor-in-echo-area | ||
| 246 | This variable controls where the cursor appears when a message is | ||
| 247 | displayed in the echo area. If it is non-@code{nil}, then the cursor | ||
| 248 | appears at the end of the message. Otherwise, the cursor appears at | ||
| 249 | point---not in the echo area at all. | ||
| 250 | |||
| 251 | The value is normally @code{nil}; Lisp programs bind it to @code{t} | ||
| 252 | for brief periods of time. | ||
| 253 | @end defvar | ||
| 254 | |||
| 245 | @tindex echo-area-clear-hook | 255 | @tindex echo-area-clear-hook |
| 246 | @defvar echo-area-clear-hook | 256 | @defvar echo-area-clear-hook |
| 247 | This normal hook is run whenever the echo area is cleared---either by | 257 | This normal hook is run whenever the echo area is cleared---either by |
| @@ -274,16 +284,6 @@ characters in the same command will be echoed as well. | |||
| 274 | If the value is zero, then command input is not echoed. | 284 | If the value is zero, then command input is not echoed. |
| 275 | @end defvar | 285 | @end defvar |
| 276 | 286 | ||
| 277 | @defvar cursor-in-echo-area | ||
| 278 | This variable controls where the cursor appears when a message is | ||
| 279 | displayed in the echo area. If it is non-@code{nil}, then the cursor | ||
| 280 | appears at the end of the message. Otherwise, the cursor appears at | ||
| 281 | point---not in the echo area at all. | ||
| 282 | |||
| 283 | The value is normally @code{nil}; Lisp programs bind it to @code{t} | ||
| 284 | for brief periods of time. | ||
| 285 | @end defvar | ||
| 286 | |||
| 287 | @node Invisible Text | 287 | @node Invisible Text |
| 288 | @section Invisible Text | 288 | @section Invisible Text |
| 289 | 289 | ||
| @@ -295,8 +295,7 @@ text property or a property of an overlay. | |||
| 295 | In the simplest case, any non-@code{nil} @code{invisible} property makes | 295 | In the simplest case, any non-@code{nil} @code{invisible} property makes |
| 296 | a character invisible. This is the default case---if you don't alter | 296 | a character invisible. This is the default case---if you don't alter |
| 297 | the default value of @code{buffer-invisibility-spec}, this is how the | 297 | the default value of @code{buffer-invisibility-spec}, this is how the |
| 298 | @code{invisibility} property works. This feature is much like selective | 298 | @code{invisible} property works. |
| 299 | display (@pxref{Selective Display}), but more general and cleaner. | ||
| 300 | 299 | ||
| 301 | More generally, you can use the variable @code{buffer-invisibility-spec} | 300 | More generally, you can use the variable @code{buffer-invisibility-spec} |
| 302 | to control which values of the @code{invisible} property make text | 301 | to control which values of the @code{invisible} property make text |
| @@ -322,17 +321,17 @@ A character is invisible if its @code{invisible} property is | |||
| 322 | non-@code{nil}. This is the default. | 321 | non-@code{nil}. This is the default. |
| 323 | 322 | ||
| 324 | @item a list | 323 | @item a list |
| 325 | Each element of the list makes certain characters invisible. | 324 | Each element of the list specifies a criterion for invisibility; if a |
| 326 | Ultimately, a character is invisible if any of the elements of this list | 325 | character's @code{invisible} property fits any one of these criteria, |
| 327 | applies to it. The list can have two kinds of elements: | 326 | the character is invisible. The list can have two kinds of elements: |
| 328 | 327 | ||
| 329 | @table @code | 328 | @table @code |
| 330 | @item @var{atom} | 329 | @item @var{atom} |
| 331 | A character is invisible if its @code{invisible} propery value | 330 | A character is invisible if its @code{invisible} property value |
| 332 | is @var{atom} or if it is a list with @var{atom} as a member. | 331 | is @var{atom} or if it is a list with @var{atom} as a member. |
| 333 | 332 | ||
| 334 | @item (@var{atom} . t) | 333 | @item (@var{atom} . t) |
| 335 | A character is invisible if its @code{invisible} propery value | 334 | A character is invisible if its @code{invisible} property value |
| 336 | is @var{atom} or if it is a list with @var{atom} as a member. | 335 | is @var{atom} or if it is a list with @var{atom} as a member. |
| 337 | Moreover, if this character is at the end of a line and is followed | 336 | Moreover, if this character is at the end of a line and is followed |
| 338 | by a visible newline, it displays an ellipsis. | 337 | by a visible newline, it displays an ellipsis. |
| @@ -360,17 +359,17 @@ that a major mode should use the mode's own name as an element of | |||
| 360 | property: | 359 | property: |
| 361 | 360 | ||
| 362 | @example | 361 | @example |
| 363 | ;; If we want to display an ellipsis: | 362 | ;; @r{If you want to display an ellipsis:} |
| 364 | (add-to-invisibility-spec '(my-symbol . t)) | 363 | (add-to-invisibility-spec '(my-symbol . t)) |
| 365 | ;; If you don't want ellipsis: | 364 | ;; @r{If you don't want ellipsis:} |
| 366 | (add-to-invisibility-spec 'my-symbol) | 365 | (add-to-invisibility-spec 'my-symbol) |
| 367 | 366 | ||
| 368 | (overlay-put (make-overlay beginning end) | 367 | (overlay-put (make-overlay beginning end) |
| 369 | 'invisible 'my-symbol) | 368 | 'invisible 'my-symbol) |
| 370 | 369 | ||
| 371 | ;; When done with the overlays: | 370 | ;; @r{When done with the overlays:} |
| 372 | (remove-from-invisibility-spec '(my-symbol . t)) | 371 | (remove-from-invisibility-spec '(my-symbol . t)) |
| 373 | ;; Or respectively: | 372 | ;; @r{Or respectively:} |
| 374 | (remove-from-invisibility-spec 'my-symbol) | 373 | (remove-from-invisibility-spec 'my-symbol) |
| 375 | @end example | 374 | @end example |
| 376 | 375 | ||
| @@ -401,14 +400,13 @@ it invisible again. | |||
| 401 | @section Selective Display | 400 | @section Selective Display |
| 402 | @cindex selective display | 401 | @cindex selective display |
| 403 | 402 | ||
| 404 | @dfn{Selective display} is a pair of features that hide certain | 403 | @dfn{Selective display} refers to a pair of related features for |
| 405 | lines on the screen. | 404 | hiding certain lines on the screen. |
| 406 | 405 | ||
| 407 | The first variant, explicit selective display, is designed for use in | 406 | The first variant, explicit selective display, is designed for use in |
| 408 | a Lisp program. The program controls which lines are hidden by altering | 407 | a Lisp program: it controls which lines are hidden by altering the text. |
| 409 | the text. Outline mode has traditionally used this variant. It has | 408 | The invisible text feature (@pxref{Invisible Text}) has partially |
| 410 | been partially replaced by the invisible text feature (@pxref{Invisible | 409 | replaced this feature. |
| 411 | Text}); there is a new version of Outline mode which uses that instead. | ||
| 412 | 410 | ||
| 413 | In the second variant, the choice of lines to hide is made | 411 | In the second variant, the choice of lines to hide is made |
| 414 | automatically based on indentation. This variant is designed to be a | 412 | automatically based on indentation. This variant is designed to be a |
| @@ -441,7 +439,8 @@ lines, or portions of lines, may be made invisible. | |||
| 441 | @itemize @bullet | 439 | @itemize @bullet |
| 442 | @item | 440 | @item |
| 443 | If the value of @code{selective-display} is @code{t}, then any portion | 441 | If the value of @code{selective-display} is @code{t}, then any portion |
| 444 | of a line that follows a control-m is not displayed. | 442 | of a line that follows a control-m is not displayed. This is explicit |
| 443 | selective display. | ||
| 445 | 444 | ||
| 446 | @item | 445 | @item |
| 447 | If the value of @code{selective-display} is a positive integer, then | 446 | If the value of @code{selective-display} is a positive integer, then |
| @@ -543,15 +542,15 @@ given time. | |||
| 543 | @c now. Is it? | 542 | @c now. Is it? |
| 544 | @end defvar | 543 | @end defvar |
| 545 | 544 | ||
| 546 | You can do the same job by creating an overlay with a | 545 | You can do a similar job by creating an overlay with a |
| 547 | @code{before-string} property. @xref{Overlay Properties}. | 546 | @code{before-string} property. @xref{Overlay Properties}. |
| 548 | 547 | ||
| 549 | @node Temporary Displays | 548 | @node Temporary Displays |
| 550 | @section Temporary Displays | 549 | @section Temporary Displays |
| 551 | 550 | ||
| 552 | Temporary displays are used by commands to put output into a buffer | 551 | Temporary displays are used by Lisp programs to put output into a |
| 553 | and then present it to the user for perusal rather than for editing. | 552 | buffer and then present it to the user for perusal rather than for |
| 554 | Many of the help commands use this feature. | 553 | editing. Many help commands use this feature. |
| 555 | 554 | ||
| 556 | @defspec with-output-to-temp-buffer buffer-name forms@dots{} | 555 | @defspec with-output-to-temp-buffer buffer-name forms@dots{} |
| 557 | This function executes @var{forms} while arranging to insert any | 556 | This function executes @var{forms} while arranging to insert any |
| @@ -599,9 +598,6 @@ The value of the last form in @var{forms} is returned. | |||
| 599 | If this variable is non-@code{nil}, @code{with-output-to-temp-buffer} | 598 | If this variable is non-@code{nil}, @code{with-output-to-temp-buffer} |
| 600 | calls it as a function to do the job of displaying a help buffer. The | 599 | calls it as a function to do the job of displaying a help buffer. The |
| 601 | function gets one argument, which is the buffer it should display. | 600 | function gets one argument, which is the buffer it should display. |
| 602 | |||
| 603 | In Emacs versions 18 and earlier, this variable was called | ||
| 604 | @code{temp-buffer-show-hook}. | ||
| 605 | @end defvar | 601 | @end defvar |
| 606 | 602 | ||
| 607 | @defun momentary-string-display string position &optional char message | 603 | @defun momentary-string-display string position &optional char message |
| @@ -620,8 +616,9 @@ the display and later (presumably) move point forward. The argument | |||
| 620 | The return value of @code{momentary-string-display} is not meaningful. | 616 | The return value of @code{momentary-string-display} is not meaningful. |
| 621 | 617 | ||
| 622 | If the string @var{string} does not contain control characters, you can | 618 | If the string @var{string} does not contain control characters, you can |
| 623 | do the same job in a more general way by creating an overlay with a | 619 | do the same job in a more general way by creating (and then subsequently |
| 624 | @code{before-string} property. @xref{Overlay Properties}. | 620 | deleting) an overlay with a @code{before-string} property. |
| 621 | @xref{Overlay Properties}. | ||
| 625 | 622 | ||
| 626 | If @var{message} is non-@code{nil}, it is displayed in the echo area | 623 | If @var{message} is non-@code{nil}, it is displayed in the echo area |
| 627 | while @var{string} is displayed in the buffer. If it is @code{nil}, a | 624 | while @var{string} is displayed in the buffer. If it is @code{nil}, a |
| @@ -685,7 +682,7 @@ not to be part of the text. Thus, copying text between various buffers | |||
| 685 | and strings preserves text properties, but does not try to preserve | 682 | and strings preserves text properties, but does not try to preserve |
| 686 | overlays. Changing a buffer's text properties marks the buffer as | 683 | overlays. Changing a buffer's text properties marks the buffer as |
| 687 | modified, while moving an overlay or changing its properties does not. | 684 | modified, while moving an overlay or changing its properties does not. |
| 688 | Unlike text propery changes, overlay changes are not recorded in the | 685 | Unlike text property changes, overlay changes are not recorded in the |
| 689 | buffer's undo list. | 686 | buffer's undo list. |
| 690 | 687 | ||
| 691 | @table @code | 688 | @table @code |
| @@ -803,8 +800,8 @@ If this property is non-@code{nil}, the overlay is deleted automatically | |||
| 803 | if it ever becomes empty (i.e., if it spans no characters). | 800 | if it ever becomes empty (i.e., if it spans no characters). |
| 804 | 801 | ||
| 805 | @item local-map | 802 | @item local-map |
| 806 | @cindex keymap of character | 803 | @cindex keymap of character (and overlays) |
| 807 | @kindex local-map @r{(text property)} | 804 | @kindex local-map @r{(overlay property)} |
| 808 | If this property is non-@code{nil}, it specifies a keymap for a portion | 805 | If this property is non-@code{nil}, it specifies a keymap for a portion |
| 809 | of the text. The property's value replaces the buffer's local map, when | 806 | of the text. The property's value replaces the buffer's local map, when |
| 810 | the character after point is within the overlay. @xref{Active Keymaps}. | 807 | the character after point is within the overlay. @xref{Active Keymaps}. |
| @@ -912,10 +909,8 @@ end of an overlay, before @var{pos}. | |||
| 912 | @section Width | 909 | @section Width |
| 913 | 910 | ||
| 914 | Since not all characters have the same width, these functions let you | 911 | Since not all characters have the same width, these functions let you |
| 915 | check the width of a character. @ref{Primitive Indent} | 912 | check the width of a character. @xref{Primitive Indent}, and |
| 916 | 913 | @ref{Screen Lines}, for related functions. | |
| 917 | @xref{Screen Lines}, for related | ||
| 918 | functions. | ||
| 919 | 914 | ||
| 920 | @tindex char-width | 915 | @tindex char-width |
| 921 | @defun char-width char | 916 | @defun char-width char |
| @@ -970,7 +965,7 @@ foreground color, background color, and optional underlining. Faces | |||
| 970 | control the display of text on the screen. | 965 | control the display of text on the screen. |
| 971 | 966 | ||
| 972 | @cindex face id | 967 | @cindex face id |
| 973 | Each face has its own @dfn{face id number} which distinguishes faces at | 968 | Each face has its own @dfn{face number}, which distinguishes faces at |
| 974 | low levels within Emacs. However, for most purposes, you can refer to | 969 | low levels within Emacs. However, for most purposes, you can refer to |
| 975 | faces in Lisp programs by their names. | 970 | faces in Lisp programs by their names. |
| 976 | 971 | ||
| @@ -986,6 +981,7 @@ face name a special meaning in one frame if you wish. | |||
| 986 | 981 | ||
| 987 | @menu | 982 | @menu |
| 988 | * Standard Faces:: The faces Emacs normally comes with. | 983 | * Standard Faces:: The faces Emacs normally comes with. |
| 984 | * Defining Faces:: How to define a face with @code{defface}. | ||
| 989 | * Merging Faces:: How Emacs decides which face to use for a character. | 985 | * Merging Faces:: How Emacs decides which face to use for a character. |
| 990 | * Face Functions:: How to define and examine faces. | 986 | * Face Functions:: How to define and examine faces. |
| 991 | @end menu | 987 | @end menu |
| @@ -1036,6 +1032,90 @@ This face uses the bold italic variant of the frame's font, if it has | |||
| 1036 | one. | 1032 | one. |
| 1037 | @end table | 1033 | @end table |
| 1038 | 1034 | ||
| 1035 | @node Defining Faces | ||
| 1036 | @section Defining Faces | ||
| 1037 | |||
| 1038 | The way to define a new face is with @code{defface}. This creates a | ||
| 1039 | kind of customization item (@pxref{Customization}) which the user can | ||
| 1040 | customize using the Customization buffer (@pxref{Easy Customization,,, | ||
| 1041 | emacs, The GNU Emacs Manual}). | ||
| 1042 | |||
| 1043 | @tindex defface | ||
| 1044 | @defmac defface face spec doc [keyword value]... | ||
| 1045 | Declare @var{face} as a customizable face that defaults according to | ||
| 1046 | @var{spec}. Do not quote the symbol @var{face}. The argument @var{doc} | ||
| 1047 | specifies the face documentation. | ||
| 1048 | |||
| 1049 | When @code{defface} executes, it defines the face according to | ||
| 1050 | @var{spec}, then uses any customizations saved in the @file{.emacs} file | ||
| 1051 | to override that specification. | ||
| 1052 | |||
| 1053 | The purpose of @var{spec} is to specify how the face should appear on | ||
| 1054 | different kinds of terminals. It should be an alist whose elements have | ||
| 1055 | the form @code{(@var{display} @var{atts})}. The element's @sc{car}, | ||
| 1056 | @var{display}, specifies a class of terminals. The @sc{cdr}, | ||
| 1057 | @var{atts}, is a list of face attributes and their values; it specifies | ||
| 1058 | what the face should look like on that kind of terminal. The possible | ||
| 1059 | attributes are defined in the value of @code{custom-face-attributes}. | ||
| 1060 | |||
| 1061 | The @var{display} part of an element of @var{spec} determines which | ||
| 1062 | frames the element applies to. If more than one element of @var{spec} | ||
| 1063 | matches a given frame, the first matching element is the only one used | ||
| 1064 | for that frame. There are two possibilities for @var{display}: | ||
| 1065 | |||
| 1066 | @table @asis | ||
| 1067 | @item @code{t} | ||
| 1068 | This element of @var{spec} matches all frames. Therefore, any | ||
| 1069 | subsequent elements of @var{spec} are never used. Normally | ||
| 1070 | @code{t} is used in the last (or only) element of @var{spec}. | ||
| 1071 | |||
| 1072 | @item an list | ||
| 1073 | If @var{display} is alist, each elements should have the form | ||
| 1074 | @code{(@var{characteristic} @var{value}@dots{})}. Here | ||
| 1075 | @var{characteristic} specifies a way of classifying frames, and the | ||
| 1076 | @var{value}s are possible classifications which @var{display} should | ||
| 1077 | apply to. Here are the possible values of @var{characteristic}: | ||
| 1078 | |||
| 1079 | @table @code | ||
| 1080 | @item type | ||
| 1081 | The kind of window system the frame uses---either @code{x}, @code{pc} | ||
| 1082 | (for the MS-DOS console), @code{w32} (for MS Windows 9X/NT), or | ||
| 1083 | @code{tty}. | ||
| 1084 | |||
| 1085 | @item class | ||
| 1086 | What kinds of colors the frame supports---either @code{color}, | ||
| 1087 | @code{grayscale}, or @code{mono}. | ||
| 1088 | |||
| 1089 | @item background | ||
| 1090 | The kind of background--- either @code{light} or @code{dark}. | ||
| 1091 | @end table | ||
| 1092 | |||
| 1093 | If an element of @var{display} specifies more than one @var{value} for a | ||
| 1094 | given @var{characteristic}, any of those values is acceptable. If | ||
| 1095 | @var{display} has more than one element, each element should specify a | ||
| 1096 | different @var{characteristic}; then @emph{each} characteristic of the | ||
| 1097 | frame must match one of the @var{value}s specified for it in | ||
| 1098 | @var{display}. | ||
| 1099 | @end table | ||
| 1100 | @end defmac | ||
| 1101 | |||
| 1102 | Here's how the standard face @code{region} could be defined | ||
| 1103 | with @code{defface}: | ||
| 1104 | |||
| 1105 | @example | ||
| 1106 | (defface region | ||
| 1107 | ((((class color) (background dark)) | ||
| 1108 | (:background "blue")) | ||
| 1109 | (t (:background "gray"))) | ||
| 1110 | "Used for displaying the region.") | ||
| 1111 | @end example | ||
| 1112 | |||
| 1113 | Internally, @code{defface} uses the symbol property | ||
| 1114 | @code{face-defface-spec} to record the face attributes specified in | ||
| 1115 | @code{defface}, @code{saved-face} for the attributes saved by the user | ||
| 1116 | with the customization buffer, and @code{face-documentation} for the | ||
| 1117 | documentation string. | ||
| 1118 | |||
| 1039 | @node Merging Faces | 1119 | @node Merging Faces |
| 1040 | @subsection Merging Faces for Display | 1120 | @subsection Merging Faces for Display |
| 1041 | 1121 | ||
| @@ -1043,9 +1123,9 @@ one. | |||
| 1043 | 1123 | ||
| 1044 | @itemize @bullet | 1124 | @itemize @bullet |
| 1045 | @item | 1125 | @item |
| 1046 | With defaults. Each frame has a @dfn{default face}, whose id number is | 1126 | With defaults. Each frame has a @dfn{default face}, which is used for |
| 1047 | zero, which is used for all text that doesn't somehow specify another | 1127 | all text that doesn't somehow specify another face. (We may change this |
| 1048 | face. | 1128 | in a forthcoming Emacs version to serve as a default for all text.) |
| 1049 | 1129 | ||
| 1050 | @item | 1130 | @item |
| 1051 | With text properties. A character may have a @code{face} property; if so, | 1131 | With text properties. A character may have a @code{face} property; if so, |
| @@ -1064,7 +1144,7 @@ With a region that is active. In Transient Mark mode, the region is | |||
| 1064 | highlighted with a particular face (see @code{region-face}, below). | 1144 | highlighted with a particular face (see @code{region-face}, below). |
| 1065 | 1145 | ||
| 1066 | @item | 1146 | @item |
| 1067 | With special glyphs. Each glyph can specify a particular face id | 1147 | With special glyphs. Each glyph can specify a particular face |
| 1068 | number. @xref{Glyphs}. | 1148 | number. @xref{Glyphs}. |
| 1069 | @end itemize | 1149 | @end itemize |
| 1070 | 1150 | ||
| @@ -1147,11 +1227,6 @@ and italic attributes cease to have any effect, because the precise font | |||
| 1147 | that you specified is always used. | 1227 | that you specified is always used. |
| 1148 | @end defun | 1228 | @end defun |
| 1149 | 1229 | ||
| 1150 | @defun set-face-underline-p face underline-p &optional frame | ||
| 1151 | This function sets the underline attribute of face @var{face}. | ||
| 1152 | Non-@code{nil} means do underline; @code{nil} means don't. | ||
| 1153 | @end defun | ||
| 1154 | |||
| 1155 | @tindex set-face-bold-p | 1230 | @tindex set-face-bold-p |
| 1156 | @defun set-face-bold-p face bold-p &optional frame | 1231 | @defun set-face-bold-p face bold-p &optional frame |
| 1157 | This function sets the bold attribute of face @var{face}. | 1232 | This function sets the bold attribute of face @var{face}. |
| @@ -1164,6 +1239,11 @@ This function sets the italic attribute of face @var{face}. | |||
| 1164 | Non-@code{nil} means italic; @code{nil} means non-italic. | 1239 | Non-@code{nil} means italic; @code{nil} means non-italic. |
| 1165 | @end defun | 1240 | @end defun |
| 1166 | 1241 | ||
| 1242 | @defun set-face-underline-p face underline-p &optional frame | ||
| 1243 | This function sets the underline attribute of face @var{face}. | ||
| 1244 | Non-@code{nil} means do underline; @code{nil} means don't. | ||
| 1245 | @end defun | ||
| 1246 | |||
| 1167 | @defun invert-face face &optional frame | 1247 | @defun invert-face face &optional frame |
| 1168 | Swap the foreground and background colors of face @var{face}. If the | 1248 | Swap the foreground and background colors of face @var{face}. If the |
| 1169 | face doesn't specify both foreground and background, then its foreground | 1249 | face doesn't specify both foreground and background, then its foreground |
| @@ -1189,10 +1269,6 @@ This function returns the name of the background stipple pattern of face | |||
| 1189 | This function returns the name of the font of face @var{face}. | 1269 | This function returns the name of the font of face @var{face}. |
| 1190 | @end defun | 1270 | @end defun |
| 1191 | 1271 | ||
| 1192 | @defun face-underline-p face &optional frame | ||
| 1193 | This function returns the underline attribute of face @var{face}. | ||
| 1194 | @end defun | ||
| 1195 | |||
| 1196 | @tindex face-bold-p | 1272 | @tindex face-bold-p |
| 1197 | @defun face-bold-p face &optional frame | 1273 | @defun face-bold-p face &optional frame |
| 1198 | This function returns the bold attribute of face @var{face}. | 1274 | This function returns the bold attribute of face @var{face}. |
| @@ -1203,8 +1279,12 @@ This function returns the bold attribute of face @var{face}. | |||
| 1203 | This function returns the italic attribute of face @var{face}. | 1279 | This function returns the italic attribute of face @var{face}. |
| 1204 | @end defun | 1280 | @end defun |
| 1205 | 1281 | ||
| 1282 | @defun face-underline-p face &optional frame | ||
| 1283 | This function returns the underline attribute of face @var{face}. | ||
| 1284 | @end defun | ||
| 1285 | |||
| 1206 | @defun face-id face | 1286 | @defun face-id face |
| 1207 | This function returns the face id number of face @var{face}. | 1287 | This function returns the face number of face @var{face}. |
| 1208 | @end defun | 1288 | @end defun |
| 1209 | 1289 | ||
| 1210 | @tindex face-documentation | 1290 | @tindex face-documentation |
| @@ -1226,13 +1306,13 @@ face if each attribute is either the same as that of the default face or | |||
| 1226 | @end defun | 1306 | @end defun |
| 1227 | 1307 | ||
| 1228 | @defvar region-face | 1308 | @defvar region-face |
| 1229 | This variable's value specifies the face id to use to display characters | 1309 | This variable's value specifies the face number to use to display characters |
| 1230 | in the region when it is active (in Transient Mark mode only). The face | 1310 | in the region when it is active (in Transient Mark mode only). The face |
| 1231 | thus specified takes precedence over all faces that come from text | 1311 | thus specified takes precedence over all faces that come from text |
| 1232 | properties and overlays, for characters in the region. @xref{The Mark}, | 1312 | properties and overlays, for characters in the region. @xref{The Mark}, |
| 1233 | for more information about Transient Mark mode. | 1313 | for more information about Transient Mark mode. |
| 1234 | 1314 | ||
| 1235 | Normally, the value is the id number of the face named @code{region}. | 1315 | Normally, the value is the face number of the face named @code{region}. |
| 1236 | @end defvar | 1316 | @end defvar |
| 1237 | 1317 | ||
| 1238 | @node Blinking | 1318 | @node Blinking |
| @@ -1245,19 +1325,11 @@ Normally, the value is the id number of the face named @code{region}. | |||
| 1245 | This section describes the mechanism by which Emacs shows a matching | 1325 | This section describes the mechanism by which Emacs shows a matching |
| 1246 | open parenthesis when the user inserts a close parenthesis. | 1326 | open parenthesis when the user inserts a close parenthesis. |
| 1247 | 1327 | ||
| 1248 | @vindex blink-paren-hook | ||
| 1249 | @defvar blink-paren-function | 1328 | @defvar blink-paren-function |
| 1250 | The value of this variable should be a function (of no arguments) to | 1329 | The value of this variable should be a function (of no arguments) to |
| 1251 | be called whenever a character with close parenthesis syntax is inserted. | 1330 | be called whenever a character with close parenthesis syntax is inserted. |
| 1252 | The value of @code{blink-paren-function} may be @code{nil}, in which | 1331 | The value of @code{blink-paren-function} may be @code{nil}, in which |
| 1253 | case nothing is done. | 1332 | case nothing is done. |
| 1254 | |||
| 1255 | @quotation | ||
| 1256 | @strong{Please note:} This variable was named @code{blink-paren-hook} in | ||
| 1257 | older Emacs versions, but since it is not called with the standard | ||
| 1258 | convention for hooks, it was renamed to @code{blink-paren-function} in | ||
| 1259 | version 19. | ||
| 1260 | @end quotation | ||
| 1261 | @end defvar | 1333 | @end defvar |
| 1262 | 1334 | ||
| 1263 | @defvar blink-matching-paren | 1335 | @defvar blink-matching-paren |
| @@ -1321,7 +1393,7 @@ is non-@code{nil}, then mode lines are displayed in inverse video. | |||
| 1321 | Otherwise, mode lines are displayed normally, just like text. The | 1393 | Otherwise, mode lines are displayed normally, just like text. The |
| 1322 | default is @code{t}. | 1394 | default is @code{t}. |
| 1323 | 1395 | ||
| 1324 | For X window frames, this displays mode lines using the face named | 1396 | For window frames, this displays mode lines using the face named |
| 1325 | @code{modeline}, which is normally the inverse of the default face | 1397 | @code{modeline}, which is normally the inverse of the default face |
| 1326 | unless you change it. | 1398 | unless you change it. |
| 1327 | @end defopt | 1399 | @end defopt |
| @@ -1356,14 +1428,19 @@ just like the codes in the range 128 to 255. | |||
| 1356 | @item | 1428 | @item |
| 1357 | Character codes 128 through 255 map to sequences of four glyphs, where | 1429 | Character codes 128 through 255 map to sequences of four glyphs, where |
| 1358 | the first glyph is the @sc{ASCII} code for @samp{\}, and the others are | 1430 | the first glyph is the @sc{ASCII} code for @samp{\}, and the others are |
| 1359 | digit characters representing the code in octal. (A display table can | 1431 | digit characters representing the charatcer code in octal. (A display |
| 1360 | specify a glyph to use instead of @samp{\}.) | 1432 | table can specify a glyph to use instead of @samp{\}.) |
| 1433 | |||
| 1434 | @item | ||
| 1435 | Multibyte character codes above 256 are displayed as themselves, or as a | ||
| 1436 | question mark or empty box if the terminal cannot display that | ||
| 1437 | character. | ||
| 1361 | @end itemize | 1438 | @end itemize |
| 1362 | 1439 | ||
| 1363 | The usual display conventions apply even when there is a display | 1440 | The usual display conventions apply even when there is a display |
| 1364 | table, for any character whose entry in the active display table is | 1441 | table, for any character whose entry in the active display table is |
| 1365 | @code{nil}. Thus, when you set up a display table, you need only | 1442 | @code{nil}. Thus, when you set up a display table, you need only |
| 1366 | specify the characters for which you want unusual behavior. | 1443 | specify the characters for which you want special behavior. |
| 1367 | 1444 | ||
| 1368 | These variables affect the way certain characters are displayed on the | 1445 | These variables affect the way certain characters are displayed on the |
| 1369 | screen. Since they change the number of columns the characters occupy, | 1446 | screen. Since they change the number of columns the characters occupy, |
| @@ -1397,10 +1474,10 @@ stops used by the command @code{tab-to-tab-stop}. @xref{Indent Tabs}. | |||
| 1397 | @section Display Tables | 1474 | @section Display Tables |
| 1398 | 1475 | ||
| 1399 | @cindex display table | 1476 | @cindex display table |
| 1400 | You can use the @dfn{display table} feature to control how all 256 | 1477 | You can use the @dfn{display table} feature to control how all possible |
| 1401 | possible character codes display on the screen. This is useful for | 1478 | character codes display on the screen. This is useful for displaying |
| 1402 | displaying European languages that have letters not in the @sc{ASCII} | 1479 | European languages that have letters not in the @sc{ASCII} character |
| 1403 | character set. | 1480 | set. |
| 1404 | 1481 | ||
| 1405 | The display table maps each character code into a sequence of | 1482 | The display table maps each character code into a sequence of |
| 1406 | @dfn{glyphs}, each glyph being an image that takes up one character | 1483 | @dfn{glyphs}, each glyph being an image that takes up one character |
| @@ -1438,8 +1515,8 @@ display that character according to the usual display conventions | |||
| 1438 | characters, the whole buffer will be displayed as one long ``line.'' | 1515 | characters, the whole buffer will be displayed as one long ``line.'' |
| 1439 | 1516 | ||
| 1440 | The display table also has six ``extra slots'' which serve special | 1517 | The display table also has six ``extra slots'' which serve special |
| 1441 | purposes. Here is a table of their meanings; @code{nil} means to use | 1518 | purposes. Here is a table of their meanings; @code{nil} in any slot |
| 1442 | the default stated below. | 1519 | means to use the default for that slot, as stated below. |
| 1443 | 1520 | ||
| 1444 | @table @asis | 1521 | @table @asis |
| 1445 | @item 0 | 1522 | @item 0 |
| @@ -1514,9 +1591,10 @@ The argument @var{table} should be either a display table or | |||
| 1514 | @end defun | 1591 | @end defun |
| 1515 | 1592 | ||
| 1516 | @defvar buffer-display-table | 1593 | @defvar buffer-display-table |
| 1517 | This variable is automatically local in all buffers; its value in a | 1594 | This variable is automatically buffer-local in all buffers; its value in |
| 1518 | particular buffer is the display table for that buffer, or @code{nil} if | 1595 | a particular buffer specifies the display table for that buffer. If it |
| 1519 | the buffer does not have an assigned display table. | 1596 | is @code{nil}, that means the buffer does not have an assigned display |
| 1597 | table. | ||
| 1520 | @end defvar | 1598 | @end defvar |
| 1521 | 1599 | ||
| 1522 | @defvar standard-display-table | 1600 | @defvar standard-display-table |
| @@ -1556,22 +1634,23 @@ below). | |||
| 1556 | @item string | 1634 | @item string |
| 1557 | Send the characters in @var{string} to the terminal to output | 1635 | Send the characters in @var{string} to the terminal to output |
| 1558 | this glyph. This alternative is available on character terminals, | 1636 | this glyph. This alternative is available on character terminals, |
| 1559 | but not under X. | 1637 | but not under a window system. |
| 1560 | 1638 | ||
| 1561 | @item integer | 1639 | @item integer |
| 1562 | Define this glyph code as an alias for code @var{integer}. You can use | 1640 | Define this glyph code as an alias for glyph code @var{integer}. You |
| 1563 | an alias to specify a face code for the glyph; see below. | 1641 | can use an alias to specify a face code for the glyph; see below. |
| 1564 | 1642 | ||
| 1565 | @item @code{nil} | 1643 | @item @code{nil} |
| 1566 | This glyph is simple. On an ordinary terminal, the glyph code mod 524288 | 1644 | This glyph is simple. On an ordinary terminal, the glyph code mod |
| 1567 | is the character to output. With X, the glyph code mod 524288 is the | 1645 | 524288 is the character to output. In a window system, the glyph code |
| 1568 | character to output, and the glyph code divided by 524288 specifies the | 1646 | mod 524288 is the character to output, and the glyph code divided by |
| 1569 | @dfn{face id number} to use while outputting it. (524288 is | 1647 | 524288 specifies the face number (@pxref{Face Functions}) to use while |
| 1648 | outputting it. (524288 is | ||
| 1570 | @ifinfo | 1649 | @ifinfo |
| 1571 | 2**19. | 1650 | 2**19.) |
| 1572 | @end ifinfo | 1651 | @end ifinfo |
| 1573 | @tex | 1652 | @tex |
| 1574 | $2^{19}$. | 1653 | $2^{19}$.) |
| 1575 | @end tex | 1654 | @end tex |
| 1576 | @xref{Faces}. | 1655 | @xref{Faces}. |
| 1577 | @end table | 1656 | @end table |
| @@ -1604,9 +1683,9 @@ This is a synonym for @code{ding}. | |||
| 1604 | @defvar visible-bell | 1683 | @defvar visible-bell |
| 1605 | This variable determines whether Emacs should flash the screen to | 1684 | This variable determines whether Emacs should flash the screen to |
| 1606 | represent a bell. Non-@code{nil} means yes, @code{nil} means no. This | 1685 | represent a bell. Non-@code{nil} means yes, @code{nil} means no. This |
| 1607 | is effective under X windows, and on a character-only terminal provided | 1686 | is effective on a window system, and on a character-only terminal |
| 1608 | the terminal's Termcap entry defines the visible bell capability | 1687 | provided the terminal's Termcap entry defines the visible bell |
| 1609 | (@samp{vb}). | 1688 | capability (@samp{vb}). |
| 1610 | @end defvar | 1689 | @end defvar |
| 1611 | 1690 | ||
| 1612 | @tindex ring-bell-function | 1691 | @tindex ring-bell-function |
diff --git a/lispref/edebug.texi b/lispref/edebug.texi index 973021833b6..d8459d2bcea 100644 --- a/lispref/edebug.texi +++ b/lispref/edebug.texi | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | @comment -*-texinfo-*- | 1 | @comment -*-texinfo-*- |
| 2 | @c This is part of the GNU Emacs Lisp Reference Manual. | ||
| 3 | @c Copyright (C) 1992, 1993, 1994, 1998 Free Software Foundation, Inc. | ||
| 4 | @c See the file elisp.texi for copying conditions. | ||
| 2 | 5 | ||
| 3 | @c This file is intended to be used as a section within the Emacs Lisp | 6 | @c This file can also be used by an independent Edebug User |
| 4 | @c Reference Manual. It may also be used by an independent Edebug User | 7 | @c Manual in which case the Edebug node below should be used |
| 5 | @c Manual, edebug.tex, in which case the Edebug node below should be used | ||
| 6 | @c with the following links to the Bugs section and to the top level: | 8 | @c with the following links to the Bugs section and to the top level: |
| 7 | 9 | ||
| 8 | @c , Bugs and Todo List, Top, Top | 10 | @c , Bugs and Todo List, Top, Top |
| @@ -167,9 +169,8 @@ definition @emph{unless} it has a prefix argument. The default value of | |||
| 167 | edebug-all-defs} toggles the value of the variable | 169 | edebug-all-defs} toggles the value of the variable |
| 168 | @code{edebug-all-defs}. | 170 | @code{edebug-all-defs}. |
| 169 | 171 | ||
| 170 | @findex edebug-all-forms | 172 | @findex eval-region @r{(Edebug)} |
| 171 | @findex eval-region (Edebug) | 173 | @findex eval-current-buffer @r{(Edebug)} |
| 172 | @findex eval-current-buffer (Edebug) | ||
| 173 | If @code{edebug-all-defs} is non-@code{nil}, then the commands | 174 | If @code{edebug-all-defs} is non-@code{nil}, then the commands |
| 174 | @code{eval-region}, @code{eval-current-buffer}, and @code{eval-buffer} | 175 | @code{eval-region}, @code{eval-current-buffer}, and @code{eval-buffer} |
| 175 | also instrument any definitions they evaluate. Similarly, | 176 | also instrument any definitions they evaluate. Similarly, |
| @@ -179,16 +180,11 @@ to loading or evaluations in the minibuffer. The command @kbd{M-x | |||
| 179 | edebug-all-forms} toggles this option. | 180 | edebug-all-forms} toggles this option. |
| 180 | 181 | ||
| 181 | @findex edebug-eval-top-level-form | 182 | @findex edebug-eval-top-level-form |
| 182 | Another command, @kbd{M-x edebug-eval-top-level-form}, is available to | 183 | Another command, @kbd{M-x edebug-eval-top-level-form}, is available to |
| 183 | instrument any top-level form regardless of the values of | 184 | instrument any top-level form regardless of the values of |
| 184 | @code{edebug-all-defs} and @code{edebug-all-forms}. | 185 | @code{edebug-all-defs} and @code{edebug-all-forms}. |
| 185 | 186 | ||
| 186 | When Edebug is about to instrument code for the first time in a session, | 187 | While Edebug is active, the command @kbd{I} |
| 187 | it runs the hook @code{edebug-setup-hook}, then sets it to @code{nil}. | ||
| 188 | You can use this to load up Edebug specifications associated with a | ||
| 189 | package you are using, but only when you also use Edebug. | ||
| 190 | |||
| 191 | While Edebug is active, the command @kbd{I} | ||
| 192 | (@code{edebug-instrument-callee}) instruments the definition of the | 188 | (@code{edebug-instrument-callee}) instruments the definition of the |
| 193 | function or macro called by the list form after point, if is not already | 189 | function or macro called by the list form after point, if is not already |
| 194 | instrumented. This is possible only if Edebug knows where to find the | 190 | instrumented. This is possible only if Edebug knows where to find the |
| @@ -201,7 +197,7 @@ steps into the call after instrumenting the function. | |||
| 201 | @cindex interactive commands (Edebug) | 197 | @cindex interactive commands (Edebug) |
| 202 | @cindex anonymous lambda expressions (Edebug) | 198 | @cindex anonymous lambda expressions (Edebug) |
| 203 | @cindex Common Lisp (Edebug) | 199 | @cindex Common Lisp (Edebug) |
| 204 | @pindex cl.el (Edebug) | 200 | @pindex cl.el @r{(Edebug)} |
| 205 | @pindex cl-specs.el | 201 | @pindex cl-specs.el |
| 206 | Edebug knows how to instrument all the standard special forms, an | 202 | Edebug knows how to instrument all the standard special forms, an |
| 207 | interactive form with an expression argument, anonymous lambda | 203 | interactive form with an expression argument, anonymous lambda |
| @@ -209,7 +205,13 @@ expressions, and other defining forms. Edebug cannot know what a | |||
| 209 | user-defined macro will do with the arguments of a macro call, so you | 205 | user-defined macro will do with the arguments of a macro call, so you |
| 210 | must tell it; @xref{Instrumenting Macro Calls}, for details. | 206 | must tell it; @xref{Instrumenting Macro Calls}, for details. |
| 211 | 207 | ||
| 212 | @findex eval-expression (Edebug) | 208 | When Edebug is about to instrument code for the first time in a |
| 209 | session, it runs the hook @code{edebug-setup-hook}, then sets it to | ||
| 210 | @code{nil}. You can use this to arrange to load Edebug specifications | ||
| 211 | (@pxref{Instrumenting Macro Calls}) associated with a package you are | ||
| 212 | using, but actually load them only if you use Edebug. | ||
| 213 | |||
| 214 | @findex eval-expression @r{(Edebug)} | ||
| 213 | To remove instrumentation from a definition, simply reevaluate its | 215 | To remove instrumentation from a definition, simply reevaluate its |
| 214 | definition in a way that does not instrument. There are two ways of | 216 | definition in a way that does not instrument. There are two ways of |
| 215 | evaluating forms that never instrument them: from a file with | 217 | evaluating forms that never instrument them: from a file with |
| @@ -472,7 +474,7 @@ stop point that has a previously established conditional breakpoint puts | |||
| 472 | the previous condition expression in the minibuffer so you can edit it. | 474 | the previous condition expression in the minibuffer so you can edit it. |
| 473 | 475 | ||
| 474 | You can make a conditional or unconditional breakpoint | 476 | You can make a conditional or unconditional breakpoint |
| 475 | @dfn{temporary} by using a prefix arg with the command to set the | 477 | @dfn{temporary} by using a prefix argument with the command to set the |
| 476 | breakpoint. When a temporary breakpoint stops the program, it is | 478 | breakpoint. When a temporary breakpoint stops the program, it is |
| 477 | automatically unset. | 479 | automatically unset. |
| 478 | 480 | ||
| @@ -504,7 +506,6 @@ depending on the execution mode, as if a breakpoint had been hit. If | |||
| 504 | evaluating the condition gets an error, execution does not stop. | 506 | evaluating the condition gets an error, execution does not stop. |
| 505 | 507 | ||
| 506 | @findex edebug-set-global-break-condition | 508 | @findex edebug-set-global-break-condition |
| 507 | @vindex edebug-global-break-condition | ||
| 508 | The condition expression is stored in | 509 | The condition expression is stored in |
| 509 | @code{edebug-global-break-condition}. You can specify a new expression | 510 | @code{edebug-global-break-condition}. You can specify a new expression |
| 510 | using the @kbd{X} command (@code{edebug-set-global-break-condition}). | 511 | using the @kbd{X} command (@code{edebug-set-global-break-condition}). |
| @@ -533,24 +534,24 @@ line as shown below to stop when the argument reaches zero: | |||
| 533 | 1)) | 534 | 1)) |
| 534 | @end example | 535 | @end example |
| 535 | 536 | ||
| 536 | When the @code{fac} definition is instrumented and the function is | 537 | When the @code{fac} definition is instrumented and the function is |
| 537 | called, the call to @code{edebug} acts as a breakpoint. Depending on | 538 | called, the call to @code{edebug} acts as a breakpoint. Depending on |
| 538 | the execution mode, Edebug stops or pauses there. | 539 | the execution mode, Edebug stops or pauses there. |
| 539 | 540 | ||
| 540 | If no instrumented code is being executed when @code{edebug} is called, | 541 | If no instrumented code is being executed when @code{edebug} is called, |
| 541 | that function calls @code{debug}. | 542 | that function calls @code{debug}. |
| 542 | @c This may not be a good idea anymore. | 543 | @c This may not be a good idea anymore. |
| 543 | 544 | ||
| 544 | @node Trapping Errors | 545 | @node Trapping Errors |
| 545 | @subsection Trapping Errors | 546 | @subsection Trapping Errors |
| 546 | 547 | ||
| 547 | Emacs normally displays an error message when an error is signaled and | 548 | Emacs normally displays an error message when an error is signaled and |
| 548 | not handled with @code{condition-case}. While Edebug is active, it | 549 | not handled with @code{condition-case}. While Edebug is active and |
| 549 | normally responds to all unhandled errors. You can customize this with | 550 | executing instrumented code, it normally responds to all unhandled |
| 550 | the options @code{edebug-on-error} and @code{edebug-on-quit}; see | 551 | errors. You can customize this with the options @code{edebug-on-error} |
| 551 | @ref{Edebug Options}. | 552 | and @code{edebug-on-quit}; see @ref{Edebug Options}. |
| 552 | 553 | ||
| 553 | When Edebug responds to an error, it shows the last stop point | 554 | When Edebug responds to an error, it shows the last stop point |
| 554 | encountered before the error. This may be the location of a call to a | 555 | encountered before the error. This may be the location of a call to a |
| 555 | function which was not instrumented, within which the error actually | 556 | function which was not instrumented, within which the error actually |
| 556 | occurred. For an unbound variable error, the last known stop point | 557 | occurred. For an unbound variable error, the last known stop point |
| @@ -558,7 +559,7 @@ might be quite distant from the offending variable reference. In that | |||
| 558 | case you might want to display a full backtrace (@pxref{Edebug Misc}). | 559 | case you might want to display a full backtrace (@pxref{Edebug Misc}). |
| 559 | 560 | ||
| 560 | @c Edebug should be changed for the following: -- dan | 561 | @c Edebug should be changed for the following: -- dan |
| 561 | If you change @code{debug-on-error} or @code{debug-on-quit} while | 562 | If you change @code{debug-on-error} or @code{debug-on-quit} while |
| 562 | Edebug is active, these changes will be forgotten when Edebug becomes | 563 | Edebug is active, these changes will be forgotten when Edebug becomes |
| 563 | inactive. Furthermore, during Edebug's recursive edit, these variables | 564 | inactive. Furthermore, during Edebug's recursive edit, these variables |
| 564 | are bound to the values they had outside of Edebug. | 565 | are bound to the values they had outside of Edebug. |
| @@ -566,7 +567,7 @@ are bound to the values they had outside of Edebug. | |||
| 566 | @node Edebug Views | 567 | @node Edebug Views |
| 567 | @subsection Edebug Views | 568 | @subsection Edebug Views |
| 568 | 569 | ||
| 569 | These Edebug commands let you view aspects of the buffer and window | 570 | These Edebug commands let you view aspects of the buffer and window |
| 570 | status that obtained before entry to Edebug. The outside window | 571 | status that obtained before entry to Edebug. The outside window |
| 571 | configuration is the collection of windows and contents that were in | 572 | configuration is the collection of windows and contents that were in |
| 572 | effect outside of Edebug. | 573 | effect outside of Edebug. |
| @@ -597,12 +598,12 @@ the selected window. To specify a window that is not displaying the | |||
| 597 | source code buffer, you must use @kbd{C-x X W} from the global keymap. | 598 | source code buffer, you must use @kbd{C-x X W} from the global keymap. |
| 598 | @end table | 599 | @end table |
| 599 | 600 | ||
| 600 | You can view the outside window configuration with @kbd{v} or just | 601 | You can view the outside window configuration with @kbd{v} or just |
| 601 | bounce to the point in the current buffer with @kbd{p}, even if | 602 | bounce to the point in the current buffer with @kbd{p}, even if |
| 602 | it is not normally displayed. After moving point, you may wish to jump | 603 | it is not normally displayed. After moving point, you may wish to jump |
| 603 | back to the stop point with @kbd{w} from a source code buffer. | 604 | back to the stop point with @kbd{w} from a source code buffer. |
| 604 | 605 | ||
| 605 | Each time you use @kbd{W} to turn saving @emph{off}, Edebug forgets the | 606 | Each time you use @kbd{W} to turn saving @emph{off}, Edebug forgets the |
| 606 | saved outside window configuration---so that even if you turn saving | 607 | saved outside window configuration---so that even if you turn saving |
| 607 | back @emph{on}, the current window configuration remains unchanged when | 608 | back @emph{on}, the current window configuration remains unchanged when |
| 608 | you next exit Edebug (by continuing the program). However, the | 609 | you next exit Edebug (by continuing the program). However, the |
| @@ -613,7 +614,7 @@ open. | |||
| 613 | @node Edebug Eval | 614 | @node Edebug Eval |
| 614 | @subsection Evaluation | 615 | @subsection Evaluation |
| 615 | 616 | ||
| 616 | While within Edebug, you can evaluate expressions ``as if'' Edebug were | 617 | While within Edebug, you can evaluate expressions ``as if'' Edebug were |
| 617 | not running. Edebug tries to be invisible to the expression's | 618 | not running. Edebug tries to be invisible to the expression's |
| 618 | evaluation and printing. Evaluation of expressions that cause side | 619 | evaluation and printing. Evaluation of expressions that cause side |
| 619 | effects will work as expected except for things that Edebug explicitly | 620 | effects will work as expected except for things that Edebug explicitly |
| @@ -635,16 +636,15 @@ Evaluate the expression before point, in the context outside of Edebug | |||
| 635 | @end table | 636 | @end table |
| 636 | 637 | ||
| 637 | @cindex lexical binding (Edebug) | 638 | @cindex lexical binding (Edebug) |
| 638 | Edebug supports evaluation of expressions containing references to | 639 | Edebug supports evaluation of expressions containing references to |
| 639 | lexically bound symbols created by the following constructs in | 640 | lexically bound symbols created by the following constructs in |
| 640 | @file{cl.el} (version 2.03 or later): @code{lexical-let}, | 641 | @file{cl.el} (version 2.03 or later): @code{lexical-let}, |
| 641 | @code{macrolet}, and @code{symbol-macrolet}. | 642 | @code{macrolet}, and @code{symbol-macrolet}. |
| 642 | 643 | ||
| 643 | |||
| 644 | @node Eval List | 644 | @node Eval List |
| 645 | @subsection Evaluation List Buffer | 645 | @subsection Evaluation List Buffer |
| 646 | 646 | ||
| 647 | You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to | 647 | You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to |
| 648 | evaluate expressions interactively. You can also set up the | 648 | evaluate expressions interactively. You can also set up the |
| 649 | @dfn{evaluation list} of expressions to be evaluated automatically each | 649 | @dfn{evaluation list} of expressions to be evaluated automatically each |
| 650 | time Edebug updates the display. | 650 | time Edebug updates the display. |
| @@ -655,12 +655,12 @@ Switch to the evaluation list buffer @samp{*edebug*} | |||
| 655 | (@code{edebug-visit-eval-list}). | 655 | (@code{edebug-visit-eval-list}). |
| 656 | @end table | 656 | @end table |
| 657 | 657 | ||
| 658 | In the @samp{*edebug*} buffer you can use the commands of Lisp | 658 | In the @samp{*edebug*} buffer you can use the commands of Lisp |
| 659 | Interaction mode (@pxref{Lisp Interaction,,, emacs, The GNU Emacs | 659 | Interaction mode (@pxref{Lisp Interaction,,, emacs, The GNU Emacs |
| 660 | Manual}) as well as these special commands: | 660 | Manual}) as well as these special commands: |
| 661 | 661 | ||
| 662 | @table @kbd | 662 | @table @kbd |
| 663 | @item LFD | 663 | @item C-j |
| 664 | Evaluate the expression before point, in the outside context, and insert | 664 | Evaluate the expression before point, in the outside context, and insert |
| 665 | the value in the buffer (@code{edebug-eval-print-last-sexp}). | 665 | the value in the buffer (@code{edebug-eval-print-last-sexp}). |
| 666 | 666 | ||
| @@ -681,40 +681,36 @@ Switch back to the source code buffer at the current stop point | |||
| 681 | (@code{edebug-where}). | 681 | (@code{edebug-where}). |
| 682 | @end table | 682 | @end table |
| 683 | 683 | ||
| 684 | You can evaluate expressions in the evaluation list window with | 684 | You can evaluate expressions in the evaluation list window with |
| 685 | @kbd{LFD} or @kbd{C-x C-e}, just as you would in @samp{*scratch*}; | 685 | @kbd{C-j} or @kbd{C-x C-e}, just as you would in @samp{*scratch*}; |
| 686 | but they are evaluated in the context outside of Edebug. | 686 | but they are evaluated in the context outside of Edebug. |
| 687 | 687 | ||
| 688 | The expressions you enter interactively (and their results) are lost | 688 | The expressions you enter interactively (and their results) are lost |
| 689 | when you continue execution; but you can set up an @dfn{evaluation list} | 689 | when you continue execution; but you can set up an @dfn{evaluation list} |
| 690 | consisting of expressions to be evaluated each time execution stops. | 690 | consisting of expressions to be evaluated each time execution stops. |
| 691 | 691 | ||
| 692 | @cindex evaluation list group | 692 | @cindex evaluation list group |
| 693 | To do this, write one or more @dfn{evaluation list groups} in the | 693 | To do this, write one or more @dfn{evaluation list groups} in the |
| 694 | evaluation list buffer. An evaluation list group consists of one or | 694 | evaluation list buffer. An evaluation list group consists of one or |
| 695 | more Lisp expressions. Groups are separated by comment lines. | 695 | more Lisp expressions. Groups are separated by comment lines. |
| 696 | 696 | ||
| 697 | The command @kbd{C-c C-u} (@code{edebug-update-eval-list}) rebuilds the | 697 | The command @kbd{C-c C-u} (@code{edebug-update-eval-list}) rebuilds the |
| 698 | evaluation list, scanning the buffer and using the first expression of | 698 | evaluation list, scanning the buffer and using the first expression of |
| 699 | each group. (The idea is that the second expression of the group is the | 699 | each group. (The idea is that the second expression of the group is the |
| 700 | value previously computed and displayed.) | 700 | value previously computed and displayed.) |
| 701 | 701 | ||
| 702 | Be careful not to add expressions that execute instrumented code since | 702 | Each entry to Edebug redisplays the evaluation list by inserting each |
| 703 | that would cause an infinite loop. | ||
| 704 | @c There ought to be a way to fix this. | ||
| 705 | |||
| 706 | Each entry to Edebug redisplays the evaluation list by inserting each | ||
| 707 | expression in the buffer, followed by its current value. It also | 703 | expression in the buffer, followed by its current value. It also |
| 708 | inserts comment lines so that each expression becomes its own group. | 704 | inserts comment lines so that each expression becomes its own group. |
| 709 | Thus, if you type @kbd{C-c C-u} again without changing the buffer text, | 705 | Thus, if you type @kbd{C-c C-u} again without changing the buffer text, |
| 710 | the evaluation list is effectively unchanged. | 706 | the evaluation list is effectively unchanged. |
| 711 | 707 | ||
| 712 | If an error occurs during an evaluation from the evaluation list, the | 708 | If an error occurs during an evaluation from the evaluation list, the |
| 713 | error message is displayed in a string as if it were the result. | 709 | error message is displayed in a string as if it were the result. |
| 714 | Therefore, expressions that use variables not currently valid do not | 710 | Therefore, expressions that use variables not currently valid do not |
| 715 | interrupt your debugging. | 711 | interrupt your debugging. |
| 716 | 712 | ||
| 717 | Here is an example of what the evaluation list window looks like after | 713 | Here is an example of what the evaluation list window looks like after |
| 718 | several expressions have been added to it: | 714 | several expressions have been added to it: |
| 719 | 715 | ||
| 720 | @smallexample | 716 | @smallexample |
| @@ -759,8 +755,6 @@ you continue execution, and recreated next time it is needed. | |||
| 759 | If an expression in your program produces a value containing circular | 755 | If an expression in your program produces a value containing circular |
| 760 | list structure, you may get an error when Edebug attempts to print it. | 756 | list structure, you may get an error when Edebug attempts to print it. |
| 761 | 757 | ||
| 762 | @vindex edebug-print-length | ||
| 763 | @vindex edebug-print-level | ||
| 764 | One way to cope with circular structure is to set @code{print-length} | 758 | One way to cope with circular structure is to set @code{print-length} |
| 765 | or @code{print-level} to truncate the printing. Edebug does this for | 759 | or @code{print-level} to truncate the printing. Edebug does this for |
| 766 | you; it binds @code{print-length} and @code{print-level} to 50 if they | 760 | you; it binds @code{print-length} and @code{print-level} to 50 if they |
| @@ -768,6 +762,17 @@ were @code{nil}. (Actually, the variables @code{edebug-print-length} | |||
| 768 | and @code{edebug-print-level} specify the values to use within Edebug.) | 762 | and @code{edebug-print-level} specify the values to use within Edebug.) |
| 769 | @xref{Output Variables}. | 763 | @xref{Output Variables}. |
| 770 | 764 | ||
| 765 | @defopt edebug-print-length | ||
| 766 | If non-@code{nil}, bind @code{print-length} to this while printing | ||
| 767 | results in Edebug. The default value is @code{50}. | ||
| 768 | @xref{Printing in Edebug}. | ||
| 769 | @end defopt | ||
| 770 | |||
| 771 | @defopt edebug-print-level | ||
| 772 | If non-@code{nil}, bind @code{print-level} to this while printing | ||
| 773 | results in Edebug. The default value is @code{50}. | ||
| 774 | @end defopt | ||
| 775 | |||
| 771 | You can also print circular structures and structures that share | 776 | You can also print circular structures and structures that share |
| 772 | elements more informatively by using the @file{cust-print} package. | 777 | elements more informatively by using the @file{cust-print} package. |
| 773 | 778 | ||
| @@ -790,6 +795,11 @@ Custom printing prints this as @samp{Result: #1=(#1# y)}. The | |||
| 790 | structure. This notation is used for any shared elements of lists or | 795 | structure. This notation is used for any shared elements of lists or |
| 791 | vectors. | 796 | vectors. |
| 792 | 797 | ||
| 798 | @defopt edebug-print-circle | ||
| 799 | If non-@code{nil}, bind @code{print-circle} to this while printing | ||
| 800 | results in Edebug. The default value is @code{nil}. | ||
| 801 | @end defopt | ||
| 802 | |||
| 793 | Other programs can also use custom printing; see @file{cust-print.el} | 803 | Other programs can also use custom printing; see @file{cust-print.el} |
| 794 | for details. | 804 | for details. |
| 795 | 805 | ||
| @@ -850,7 +860,7 @@ Edebug provides rudimentary coverage testing and display of execution | |||
| 850 | frequency. All execution of an instrumented function accumulates | 860 | frequency. All execution of an instrumented function accumulates |
| 851 | frequency counts, both before and after evaluation of each instrumented | 861 | frequency counts, both before and after evaluation of each instrumented |
| 852 | expression, even if the execution mode is Go-nonstop. Coverage testing | 862 | expression, even if the execution mode is Go-nonstop. Coverage testing |
| 853 | is more expensive, so it is only done if @code{edebug-test-coverage} is | 863 | is more expensive, so it is done only if @code{edebug-test-coverage} is |
| 854 | non-@code{nil}. The command @kbd{M-x edebug-display-freq-count} | 864 | non-@code{nil}. The command @kbd{M-x edebug-display-freq-count} |
| 855 | displays both the frequency data and the coverage data (if recorded). | 865 | displays both the frequency data and the coverage data (if recorded). |
| 856 | 866 | ||
| @@ -858,11 +868,11 @@ displays both the frequency data and the coverage data (if recorded). | |||
| 858 | This command displays the frequency count data for each line of the | 868 | This command displays the frequency count data for each line of the |
| 859 | current definition. | 869 | current definition. |
| 860 | 870 | ||
| 861 | The frequency counts appear as comment lines after each line of code, and | 871 | The frequency counts appear as comment lines after each line of code, |
| 862 | you can undo all insertions with one @code{undo} command. The counts | 872 | and you can undo all insertions with one @code{undo} command. The |
| 863 | appear under the @kbd{(} before an expression or the @kbd{)} after | 873 | counts appear under the @samp{(} before an expression or the @samp{)} |
| 864 | an expression, or on the last character of a symbol. Values do not appear if | 874 | after an expression, or on the last character of a symbol. Values do |
| 865 | they are equal to the previous count on the same line. | 875 | not appear if they are equal to the previous count on the same line. |
| 866 | 876 | ||
| 867 | The character @samp{=} following the count for an expression says that | 877 | The character @samp{=} following the count for an expression says that |
| 868 | the expression has returned the same value each time it was evaluated | 878 | the expression has returned the same value each time it was evaluated |
| @@ -1035,14 +1045,16 @@ Edebug is active, @code{defining-kbd-macro} is bound to | |||
| 1035 | @node Instrumenting Macro Calls | 1045 | @node Instrumenting Macro Calls |
| 1036 | @subsection Instrumenting Macro Calls | 1046 | @subsection Instrumenting Macro Calls |
| 1037 | 1047 | ||
| 1038 | When Edebug instruments an expression that calls a Lisp macro, it needs | 1048 | When Edebug instruments an expression that calls a Lisp macro, it needs |
| 1039 | additional advice to do the job properly. This is because there is no | 1049 | additional information about the macro to do the job properly. This is |
| 1040 | way to tell which subexpressions of the macro call are forms to be | 1050 | because there is no a-priori way to tell which subexpressions of the |
| 1041 | evaluated. (Evaluation may occur explicitly in the macro body, or when | 1051 | macro call are forms to be evaluated. (Evaluation may occur explicitly |
| 1042 | the resulting expansion is evaluated, or any time later.) You must | 1052 | in the macro body, or when the resulting expansion is evaluated, or any |
| 1043 | explain the format of calls to each macro to enable Edebug to handle it. | 1053 | time later.) |
| 1044 | To do this, use @code{def-edebug-spec} to define the format of | 1054 | |
| 1045 | calls to a given macro. | 1055 | Therefore, you must define an Edebug specification for each macro that |
| 1056 | Edebug will encounter, to explain the format of calls to that macro. To | ||
| 1057 | do this, use @code{def-edebug-spec}. | ||
| 1046 | 1058 | ||
| 1047 | @deffn Macro def-edebug-spec macro specification | 1059 | @deffn Macro def-edebug-spec macro specification |
| 1048 | Specify which expressions of a call to macro @var{macro} are forms to be | 1060 | Specify which expressions of a call to macro @var{macro} are forms to be |
| @@ -1050,7 +1062,7 @@ evaluated. For simple macros, the @var{specification} often looks very | |||
| 1050 | similar to the formal argument list of the macro definition, but | 1062 | similar to the formal argument list of the macro definition, but |
| 1051 | specifications are much more general than macro arguments. | 1063 | specifications are much more general than macro arguments. |
| 1052 | 1064 | ||
| 1053 | The @var{macro} argument may actually be any symbol, not just a macro | 1065 | The @var{macro} argument can actually be any symbol, not just a macro |
| 1054 | name. | 1066 | name. |
| 1055 | @end deffn | 1067 | @end deffn |
| 1056 | 1068 | ||
| @@ -1108,7 +1120,7 @@ as @code{&optional}). | |||
| 1108 | A specification list may contain sublists which match arguments that are | 1120 | A specification list may contain sublists which match arguments that are |
| 1109 | themselves lists, or it may contain vectors used for grouping. Sublists | 1121 | themselves lists, or it may contain vectors used for grouping. Sublists |
| 1110 | and groups thus subdivide the specification list into a hierarchy of | 1122 | and groups thus subdivide the specification list into a hierarchy of |
| 1111 | levels. Specification keywords only apply to the remainder of the | 1123 | levels. Specification keywords apply only to the remainder of the |
| 1112 | sublist or group they are contained in. | 1124 | sublist or group they are contained in. |
| 1113 | 1125 | ||
| 1114 | When a specification list involves alternatives or repetition, matching | 1126 | When a specification list involves alternatives or repetition, matching |
| @@ -1262,7 +1274,7 @@ sublist-elements@dots{})}. | |||
| 1262 | 1274 | ||
| 1263 | @c Need to document extensions with &symbol and :symbol | 1275 | @c Need to document extensions with &symbol and :symbol |
| 1264 | 1276 | ||
| 1265 | Here is a list of additional specifications that may only appear after | 1277 | Here is a list of additional specifications that may appear only after |
| 1266 | @code{&define}. See the @code{defun} example below. | 1278 | @code{&define}. See the @code{defun} example below. |
| 1267 | 1279 | ||
| 1268 | @table @code | 1280 | @table @code |
| @@ -1304,7 +1316,7 @@ tracing information is not output when the form is executed. See the | |||
| 1304 | @end table | 1316 | @end table |
| 1305 | 1317 | ||
| 1306 | @node Backtracking | 1318 | @node Backtracking |
| 1307 | @subsubsection Backtracking | 1319 | @subsubsection Backtracking in Specifications |
| 1308 | 1320 | ||
| 1309 | @cindex backtracking | 1321 | @cindex backtracking |
| 1310 | @cindex syntax error (Edebug) | 1322 | @cindex syntax error (Edebug) |
| @@ -1473,8 +1485,6 @@ The default value is @code{step}. | |||
| 1473 | @end defopt | 1485 | @end defopt |
| 1474 | 1486 | ||
| 1475 | @defopt edebug-trace | 1487 | @defopt edebug-trace |
| 1476 | @findex edebug-print-trace-before | ||
| 1477 | @findex edebug-print-trace-after | ||
| 1478 | Non-@code{nil} means display a trace of function entry and exit. | 1488 | Non-@code{nil} means display a trace of function entry and exit. |
| 1479 | Tracing output is displayed in a buffer named @samp{*edebug-trace*}, one | 1489 | Tracing output is displayed in a buffer named @samp{*edebug-trace*}, one |
| 1480 | function entry or exit per line, indented by the recursion level. | 1490 | function entry or exit per line, indented by the recursion level. |
| @@ -1504,22 +1514,6 @@ debugged. | |||
| 1504 | @xref{Edebug Execution Modes}. | 1514 | @xref{Edebug Execution Modes}. |
| 1505 | @end defopt | 1515 | @end defopt |
| 1506 | 1516 | ||
| 1507 | @defopt edebug-print-length | ||
| 1508 | If non-@code{nil}, bind @code{print-length} to this while printing | ||
| 1509 | results in Edebug. The default value is @code{50}. | ||
| 1510 | @xref{Printing in Edebug}. | ||
| 1511 | @end defopt | ||
| 1512 | |||
| 1513 | @defopt edebug-print-level | ||
| 1514 | If non-@code{nil}, bind @code{print-level} to this while printing | ||
| 1515 | results in Edebug. The default value is @code{50}. | ||
| 1516 | @end defopt | ||
| 1517 | |||
| 1518 | @defopt edebug-print-circle | ||
| 1519 | If non-@code{nil}, bind @code{print-circle} to this while printing | ||
| 1520 | results in Edebug. The default value is @code{nil}. | ||
| 1521 | @end defopt | ||
| 1522 | |||
| 1523 | @defopt edebug-on-error | 1517 | @defopt edebug-on-error |
| 1524 | Edebug binds @code{debug-on-error} to this value, if | 1518 | Edebug binds @code{debug-on-error} to this value, if |
| 1525 | @code{debug-on-error} was previously @code{nil}. @xref{Trapping | 1519 | @code{debug-on-error} was previously @code{nil}. @xref{Trapping |
diff --git a/lispref/errors.texi b/lispref/errors.texi index 01ddf41ab64..809db995ed0 100644 --- a/lispref/errors.texi +++ b/lispref/errors.texi | |||
| @@ -55,8 +55,7 @@ See @code{/} and @code{%} in @ref{Numbers}. | |||
| 55 | @xref{Read Only Buffers}. | 55 | @xref{Read Only Buffers}. |
| 56 | 56 | ||
| 57 | @item cyclic-function-indirection | 57 | @item cyclic-function-indirection |
| 58 | @code{"Symbol's chain of function indirections contains a@* | 58 | @code{"Symbol's chain of function indirections contains a loop"}@* |
| 59 | loop"}@* | ||
| 60 | @xref{Function Indirection}. | 59 | @xref{Function Indirection}. |
| 61 | 60 | ||
| 62 | @item end-of-buffer | 61 | @item end-of-buffer |
| @@ -65,9 +64,14 @@ loop"}@* | |||
| 65 | 64 | ||
| 66 | @item end-of-file | 65 | @item end-of-file |
| 67 | @code{"End of file during parsing"}@* | 66 | @code{"End of file during parsing"}@* |
| 68 | This is not a @code{file-error}.@* | 67 | Note that this is not a @code{file-error} |
| 68 | because it pertains to the Lisp reader, not to file I/O. | ||
| 69 | @xref{Input Functions}. | 69 | @xref{Input Functions}. |
| 70 | 70 | ||
| 71 | @item file-already-exists | ||
| 72 | This is a @code{file-error}.@* | ||
| 73 | @xref{Writing to Files}. | ||
| 74 | |||
| 71 | @item file-date-error | 75 | @item file-date-error |
| 72 | This is a subcategory of @code{file-error}. It occurs when | 76 | This is a subcategory of @code{file-error}. It occurs when |
| 73 | @code{copy-file} tries and fails to set the last-modification time of | 77 | @code{copy-file} tries and fails to set the last-modification time of |
| @@ -83,10 +87,6 @@ condition @code{file-error} is present.@* | |||
| 83 | This is a @code{file-error}.@* | 87 | This is a @code{file-error}.@* |
| 84 | @xref{File Locks}. | 88 | @xref{File Locks}. |
| 85 | 89 | ||
| 86 | @item file-already-exists | ||
| 87 | This is a @code{file-error}.@* | ||
| 88 | @xref{Writing to Files}. | ||
| 89 | |||
| 90 | @item file-supersession | 90 | @item file-supersession |
| 91 | This is a @code{file-error}.@* | 91 | This is a @code{file-error}.@* |
| 92 | @xref{Modification Time}. | 92 | @xref{Modification Time}. |
| @@ -103,17 +103,28 @@ This is a @code{file-error}.@* | |||
| 103 | @code{"Invalid regexp"}@* | 103 | @code{"Invalid regexp"}@* |
| 104 | @xref{Regular Expressions}. | 104 | @xref{Regular Expressions}. |
| 105 | 105 | ||
| 106 | @item mark-inactive | ||
| 107 | @code{Mark inactive"}@* | ||
| 108 | @xref{The Mark}. | ||
| 109 | |||
| 106 | @item no-catch | 110 | @item no-catch |
| 107 | @code{"No catch for tag"}@* | 111 | @code{"No catch for tag"}@* |
| 108 | @xref{Catch and Throw}. | 112 | @xref{Catch and Throw}. |
| 109 | 113 | ||
| 114 | @item scan-error | ||
| 115 | @code{"Scan error"}@* | ||
| 116 | This happens when certain syntax-parsing functions | ||
| 117 | find invalid syntax or mismatched parentheses.@* | ||
| 118 | @xref{List Motion}, and @ref{Parsing Expressions}. | ||
| 119 | |||
| 110 | @item search-failed | 120 | @item search-failed |
| 111 | @code{"Search failed"}@* | 121 | @code{"Search failed"}@* |
| 112 | @xref{Searching and Matching}. | 122 | @xref{Searching and Matching}. |
| 113 | 123 | ||
| 114 | @item setting-constant | 124 | @item setting-constant |
| 115 | @code{"Attempt to set a constant symbol"}@* | 125 | @code{"Attempt to set a constant symbol"}@* |
| 116 | The values of the symbols @code{nil} and @code{t} | 126 | The values of the symbols @code{nil} and @code{t}, |
| 127 | and any symbols that start with @samp{:}, | ||
| 117 | may not be changed.@* | 128 | may not be changed.@* |
| 118 | @xref{Constant Variables, , Variables that Never Change}. | 129 | @xref{Constant Variables, , Variables that Never Change}. |
| 119 | 130 | ||
| @@ -138,7 +149,7 @@ may not be changed.@* | |||
| 138 | @xref{Type Predicates}. | 149 | @xref{Type Predicates}. |
| 139 | @end table | 150 | @end table |
| 140 | 151 | ||
| 141 | These error types, which are all classified as special cases of | 152 | These kinds of error, which are classified as special cases of |
| 142 | @code{arith-error}, can occur on certain systems for invalid use of | 153 | @code{arith-error}, can occur on certain systems for invalid use of |
| 143 | mathematical functions. | 154 | mathematical functions. |
| 144 | 155 | ||
diff --git a/lispref/eval.texi b/lispref/eval.texi index 7d5cbf7a68e..512e6d927b2 100644 --- a/lispref/eval.texi +++ b/lispref/eval.texi | |||
| @@ -139,7 +139,7 @@ unchanged. | |||
| 139 | 139 | ||
| 140 | @example | 140 | @example |
| 141 | @group | 141 | @group |
| 142 | '123 ; @r{An object, shown without evaluation.} | 142 | '123 ; @r{A number, shown without evaluation.} |
| 143 | @result{} 123 | 143 | @result{} 123 |
| 144 | @end group | 144 | @end group |
| 145 | @group | 145 | @group |
| @@ -210,7 +210,8 @@ value of @code{nil} is always @code{nil}, and the value of @code{t} is | |||
| 210 | always @code{t}; you cannot set or bind them to any other values. Thus, | 210 | always @code{t}; you cannot set or bind them to any other values. Thus, |
| 211 | these two symbols act like self-evaluating forms, even though | 211 | these two symbols act like self-evaluating forms, even though |
| 212 | @code{eval} treats them like any other symbol. A symbol whose name | 212 | @code{eval} treats them like any other symbol. A symbol whose name |
| 213 | starts with @samp{:} also self-evaluates in the same way. | 213 | starts with @samp{:} also self-evaluates in the same way; likewise, |
| 214 | its value ordinarily cannot be changed. @xref{Constant Variables}. | ||
| 214 | 215 | ||
| 215 | @node Classifying Lists | 216 | @node Classifying Lists |
| 216 | @subsection Classification of List Forms | 217 | @subsection Classification of List Forms |
| @@ -646,15 +647,16 @@ buffer. | |||
| 646 | @defvar max-lisp-eval-depth | 647 | @defvar max-lisp-eval-depth |
| 647 | This variable defines the maximum depth allowed in calls to @code{eval}, | 648 | This variable defines the maximum depth allowed in calls to @code{eval}, |
| 648 | @code{apply}, and @code{funcall} before an error is signaled (with error | 649 | @code{apply}, and @code{funcall} before an error is signaled (with error |
| 649 | message @code{"Lisp nesting exceeds max-lisp-eval-depth"}). This counts | 650 | message @code{"Lisp nesting exceeds max-lisp-eval-depth"}). This limit, |
| 650 | internal uses of those functions, such as for calling the functions | 651 | with the associated error when it is exceeded, is one way that Lisp |
| 651 | mentioned in Lisp expressions, and recursive evaluation of function call | 652 | avoids infinite recursion on an ill-defined function. |
| 652 | arguments and function body forms. | ||
| 653 | |||
| 654 | This limit, with the associated error when it is exceeded, is one way | ||
| 655 | that Lisp avoids infinite recursion on an ill-defined function. | ||
| 656 | @cindex Lisp nesting error | 653 | @cindex Lisp nesting error |
| 657 | 654 | ||
| 655 | The depth limit counts internal uses of @code{eval}, @code{apply}, and | ||
| 656 | @code{funcall}, such as for calling the functions mentioned in Lisp | ||
| 657 | expressions, and recursive evaluation of function call arguments and | ||
| 658 | function body forms, as well as explicit calls in Lisp code. | ||
| 659 | |||
| 658 | The default value of this variable is 200. If you set it to a value | 660 | The default value of this variable is 200. If you set it to a value |
| 659 | less than 100, Lisp will reset it to 100 if the given value is reached. | 661 | less than 100, Lisp will reset it to 100 if the given value is reached. |
| 660 | 662 | ||
diff --git a/lispref/files.texi b/lispref/files.texi index 4a5539eac45..45f8097fecd 100644 --- a/lispref/files.texi +++ b/lispref/files.texi | |||
| @@ -35,7 +35,6 @@ substitutions such as @samp{$HOME}. @xref{File Name Expansion}. | |||
| 35 | * Magic File Names:: Defining "magic" special handling | 35 | * Magic File Names:: Defining "magic" special handling |
| 36 | for certain file names. | 36 | for certain file names. |
| 37 | * Format Conversion:: Conversion to and from various file formats. | 37 | * Format Conversion:: Conversion to and from various file formats. |
| 38 | * Files and MS-DOS:: Distinguishing text and binary files on MS-DOS. | ||
| 39 | @end menu | 38 | @end menu |
| 40 | 39 | ||
| 41 | @node Visiting Files | 40 | @node Visiting Files |
| @@ -116,12 +115,11 @@ saved in that buffer. If the file has changed, then this function asks | |||
| 116 | the user whether to reread the changed file. If the user says | 115 | the user whether to reread the changed file. If the user says |
| 117 | @samp{yes}, any changes previously made in the buffer are lost. | 116 | @samp{yes}, any changes previously made in the buffer are lost. |
| 118 | 117 | ||
| 119 | If @code{find-file-noselect} needs to create a buffer, and there is no | ||
| 120 | file named @var{filename}, it displays the message @samp{New file} in | ||
| 121 | the echo area, and leaves the buffer empty. | ||
| 122 | |||
| 123 | This function displays warning or advisory messages in various peculiar | 118 | This function displays warning or advisory messages in various peculiar |
| 124 | cases, unless the optional argument @var{nowarn} is non-@code{nil}. | 119 | cases, unless the optional argument @var{nowarn} is non-@code{nil}. For |
| 120 | example, if it needs to create a buffer, and there is no file named | ||
| 121 | @var{filename}, it displays the message @samp{New file} in the echo | ||
| 122 | area, and leaves the buffer empty. | ||
| 125 | 123 | ||
| 126 | The @code{find-file-noselect} function normally calls | 124 | The @code{find-file-noselect} function normally calls |
| 127 | @code{after-find-file} after reading the file (@pxref{Subroutines of | 125 | @code{after-find-file} after reading the file (@pxref{Subroutines of |
| @@ -297,26 +295,20 @@ the user. | |||
| 297 | 295 | ||
| 298 | The optional @var{exiting} argument, if non-@code{nil}, requests this | 296 | The optional @var{exiting} argument, if non-@code{nil}, requests this |
| 299 | function to offer also to save certain other buffers that are not | 297 | function to offer also to save certain other buffers that are not |
| 300 | visiting files. These are buffers that have a non-@code{nil} local | 298 | visiting files. These are buffers that have a non-@code{nil} |
| 301 | value of @code{buffer-offer-save}. (A user who says yes to saving one | 299 | buffer-local value of @code{buffer-offer-save}. (A user who says yes to |
| 302 | of these is asked to specify a file name to use.) The | 300 | saving one of these is asked to specify a file name to use.) The |
| 303 | @code{save-buffers-kill-emacs} function passes a non-@code{nil} value | 301 | @code{save-buffers-kill-emacs} function passes a non-@code{nil} value |
| 304 | for this argument. | 302 | for this argument. |
| 305 | @end deffn | 303 | @end deffn |
| 306 | 304 | ||
| 307 | @defvar buffer-offer-save | ||
| 308 | When this variable is non-@code{nil} in a buffer, Emacs offers to save | ||
| 309 | the buffer on exit even if the buffer is not visiting a file. The | ||
| 310 | variable is automatically local in all buffers. Normally, Mail mode | ||
| 311 | (used for editing outgoing mail) sets this to @code{t}. | ||
| 312 | @end defvar | ||
| 313 | |||
| 314 | @deffn Command write-file filename | 305 | @deffn Command write-file filename |
| 315 | This function writes the current buffer into file @var{filename}, makes | 306 | This function writes the current buffer into file @var{filename}, makes |
| 316 | the buffer visit that file, and marks it not modified. Then it renames | 307 | the buffer visit that file, and marks it not modified. Then it renames |
| 317 | the buffer based on @var{filename}, appending a string like @samp{<2>} | 308 | the buffer based on @var{filename}, appending a string like @samp{<2>} |
| 318 | if necessary to make a unique buffer name. It does most of this work by | 309 | if necessary to make a unique buffer name. It does most of this work by |
| 319 | calling @code{set-visited-file-name} and @code{save-buffer}. | 310 | calling @code{set-visited-file-name} (@pxref{Buffer File Name}) and |
| 311 | @code{save-buffer}. | ||
| 320 | @end deffn | 312 | @end deffn |
| 321 | 313 | ||
| 322 | Saving a buffer runs several hooks. It also performs format | 314 | Saving a buffer runs several hooks. It also performs format |
| @@ -352,8 +344,8 @@ Even though this is not a normal hook, you can use @code{add-hook} and | |||
| 352 | @c Emacs 19 feature | 344 | @c Emacs 19 feature |
| 353 | @defvar local-write-file-hooks | 345 | @defvar local-write-file-hooks |
| 354 | This works just like @code{write-file-hooks}, but it is intended to be | 346 | This works just like @code{write-file-hooks}, but it is intended to be |
| 355 | made local to particular buffers, and used for hooks that pertain to the | 347 | made buffer-local in particular buffers, and used for hooks that pertain |
| 356 | file name or the way the buffer contents were obtained. | 348 | to the file name or the way the buffer contents were obtained. |
| 357 | 349 | ||
| 358 | The variable is marked as a permanent local, so that changing the major | 350 | The variable is marked as a permanent local, so that changing the major |
| 359 | mode does not alter a buffer-local value. This is convenient for | 351 | mode does not alter a buffer-local value. This is convenient for |
| @@ -372,7 +364,7 @@ This variable automatically becomes buffer-local whenever it is set; | |||
| 372 | switching to a new major mode always resets this variable. When you use | 364 | switching to a new major mode always resets this variable. When you use |
| 373 | @code{add-hooks} to add an element to this hook, you should @emph{not} | 365 | @code{add-hooks} to add an element to this hook, you should @emph{not} |
| 374 | specify a non-@code{nil} @var{local} argument, since this variable is | 366 | specify a non-@code{nil} @var{local} argument, since this variable is |
| 375 | used @emph{only} locally. | 367 | used @emph{only} buffer-locally. |
| 376 | @end defvar | 368 | @end defvar |
| 377 | 369 | ||
| 378 | @c Emacs 19 feature | 370 | @c Emacs 19 feature |
| @@ -392,8 +384,8 @@ As a side effect, backups are necessarily made by copying. @xref{Rename | |||
| 392 | or Copy}. Yet, at the same time, saving a precious file always breaks | 384 | or Copy}. Yet, at the same time, saving a precious file always breaks |
| 393 | all hard links between the file you save and other file names. | 385 | all hard links between the file you save and other file names. |
| 394 | 386 | ||
| 395 | Some modes set this variable non-@code{nil} locally in particular | 387 | Some modes give this variable non-@code{nil} buffer-local value |
| 396 | buffers. | 388 | in particular buffers. |
| 397 | @end defvar | 389 | @end defvar |
| 398 | 390 | ||
| 399 | @defopt require-final-newline | 391 | @defopt require-final-newline |
| @@ -410,16 +402,8 @@ doesn't add newlines at all. @code{nil} is the default value, but a few | |||
| 410 | major modes set it to @code{t} in particular buffers. | 402 | major modes set it to @code{t} in particular buffers. |
| 411 | @end defopt | 403 | @end defopt |
| 412 | 404 | ||
| 413 | @deffn Command set-visited-file-name filename &optional no-query | 405 | See also the function @code{set-visited-file-name} (@pxref{Buffer File |
| 414 | This function changes the visited file name of the current buffer to | 406 | Name}). |
| 415 | @var{filename}. It also renames the buffer based on @var{filename}, | ||
| 416 | appending a string like @samp{<2>} if necessary to make a unique buffer | ||
| 417 | name. It marks the buffer as @emph{modified},a since the contents do not | ||
| 418 | (as far as Emacs knows) match the actual file's contents. | ||
| 419 | |||
| 420 | If the specified file already exists, @code{set-visited-file-name} | ||
| 421 | asks for confirmation unless @var{no-query} is non-@code{nil}. | ||
| 422 | @end deffn | ||
| 423 | 407 | ||
| 424 | @node Reading from Files | 408 | @node Reading from Files |
| 425 | @comment node-name, next, previous, up | 409 | @comment node-name, next, previous, up |
| @@ -542,15 +526,12 @@ files that the user does not need to know about. | |||
| 542 | 526 | ||
| 543 | @tindex with-temp-file | 527 | @tindex with-temp-file |
| 544 | @defmac with-temp-file file body... | 528 | @defmac with-temp-file file body... |
| 545 | The @code{with-temp-file} macro evaluates the @var{body} forms | 529 | The @code{with-temp-file} macro evaluates the @var{body} forms with a |
| 546 | with a temporary buffer as the current buffer; then, at the end, it | 530 | temporary buffer as the current buffer; then, at the end, it writes the |
| 547 | writes the buffer contents into file @var{file}. It kills the temporary | 531 | buffer contents into file @var{file}. It kills the temporary buffer |
| 548 | buffer when finished, restoring the buffer that was current before the | 532 | when finished, restoring the buffer that was current before the |
| 549 | @code{with-temp-file} form. | 533 | @code{with-temp-file} form. Then it returns the value of the last form |
| 550 | 534 | in @var{body}. | |
| 551 | The return value is the value of the last form in @var{body}. You can | ||
| 552 | return the contents of the temporary buffer by using | ||
| 553 | @code{(buffer-string)} as the last form. | ||
| 554 | 535 | ||
| 555 | The current buffer is restored even in case of an abnormal exit via | 536 | The current buffer is restored even in case of an abnormal exit via |
| 556 | @code{throw} or error (@pxref{Nonlocal Exits}). | 537 | @code{throw} or error (@pxref{Nonlocal Exits}). |
| @@ -568,13 +549,12 @@ arising by recording a @dfn{file lock} when a file is being modified. | |||
| 568 | Emacs can then detect the first attempt to modify a buffer visiting a | 549 | Emacs can then detect the first attempt to modify a buffer visiting a |
| 569 | file that is locked by another Emacs job, and ask the user what to do. | 550 | file that is locked by another Emacs job, and ask the user what to do. |
| 570 | 551 | ||
| 571 | File locks do not work properly when multiple machines can share | 552 | File locks are not completely reliable when multiple machines can |
| 572 | file systems, such as with NFS. Perhaps a better file locking system | 553 | share file systems. When file locks do not work, it is possible for two |
| 573 | will be implemented in the future. When file locks do not work, it is | 554 | users to make changes simultaneously, but Emacs can still warn the user |
| 574 | possible for two users to make changes simultaneously, but Emacs can | 555 | who saves second. Also, the detection of modification of a buffer |
| 575 | still warn the user who saves second. Also, the detection of | 556 | visiting a file changed on disk catches some cases of simultaneous |
| 576 | modification of a buffer visiting a file changed on disk catches some | 557 | editing; see @ref{Modification Time}. |
| 577 | cases of simultaneous editing; see @ref{Modification Time}. | ||
| 578 | 558 | ||
| 579 | @defun file-locked-p filename | 559 | @defun file-locked-p filename |
| 580 | This function returns @code{nil} if the file @var{filename} is not | 560 | This function returns @code{nil} if the file @var{filename} is not |
| @@ -1032,18 +1012,12 @@ For example, here are the file attributes for @file{files.texi}: | |||
| 1032 | @example | 1012 | @example |
| 1033 | @group | 1013 | @group |
| 1034 | (file-attributes "files.texi") | 1014 | (file-attributes "files.texi") |
| 1035 | @result{} (nil | 1015 | @result{} (nil 1 2235 75 |
| 1036 | 1 | ||
| 1037 | 2235 | ||
| 1038 | 75 | ||
| 1039 | (8489 20284) | 1016 | (8489 20284) |
| 1040 | (8489 20284) | 1017 | (8489 20284) |
| 1041 | (8489 20285) | 1018 | (8489 20285) |
| 1042 | 14906 | 1019 | 14906 "-rw-rw-rw-" |
| 1043 | "-rw-rw-rw-" | 1020 | nil 129500 -32252) |
| 1044 | nil | ||
| 1045 | 129500 | ||
| 1046 | -32252) | ||
| 1047 | @end group | 1021 | @end group |
| 1048 | @end example | 1022 | @end example |
| 1049 | 1023 | ||
| @@ -1614,7 +1588,7 @@ form. | |||
| 1614 | @defvar default-directory | 1588 | @defvar default-directory |
| 1615 | The value of this buffer-local variable is the default directory for the | 1589 | The value of this buffer-local variable is the default directory for the |
| 1616 | current buffer. It should be an absolute directory name; it may start | 1590 | current buffer. It should be an absolute directory name; it may start |
| 1617 | with @samp{~}. This variable is local in every buffer. | 1591 | with @samp{~}. This variable is buffer-local in every buffer. |
| 1618 | 1592 | ||
| 1619 | @code{expand-file-name} uses the default directory when its second | 1593 | @code{expand-file-name} uses the default directory when its second |
| 1620 | argument is @code{nil}. | 1594 | argument is @code{nil}. |
| @@ -1651,8 +1625,8 @@ the user's home directory name, has value @samp{/xcssun/users/rms}. | |||
| 1651 | @end group | 1625 | @end group |
| 1652 | @end example | 1626 | @end example |
| 1653 | 1627 | ||
| 1654 | If a @samp{~} or a @samp{/} appears following a @samp{/}, after | 1628 | After substitution, if a @samp{~} or a @samp{/} appears following a |
| 1655 | substitution, everything before the following @samp{/} is discarded: | 1629 | @samp{/}, everything before the following @samp{/} is discarded: |
| 1656 | 1630 | ||
| 1657 | @example | 1631 | @example |
| 1658 | @group | 1632 | @group |
| @@ -1996,18 +1970,21 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 1996 | 1970 | ||
| 1997 | @noindent | 1971 | @noindent |
| 1998 | @code{add-name-to-file}, @code{copy-file}, @code{delete-directory}, | 1972 | @code{add-name-to-file}, @code{copy-file}, @code{delete-directory}, |
| 1999 | @code{delete-file},@* | 1973 | @code{delete-file}, |
| 2000 | @code{diff-latest-backup-file}, | 1974 | @code{diff-latest-backup-file}, |
| 2001 | @code{directory-file-name}, | 1975 | @code{directory-file-name}, |
| 2002 | @code{directory-files},@* | 1976 | @code{directory-files}, |
| 2003 | @code{dired-call-process}, | 1977 | @code{dired-call-process}, |
| 2004 | @code{dired-compress-file}, @code{dired-uncache}, | 1978 | @code{dired-compress-file}, @code{dired-uncache}, |
| 2005 | @code{expand-file-name},@* | 1979 | @code{expand-file-name}, |
| 2006 | @code{file-accessible-directory-p}, | 1980 | @code{file-accessible-directory-p},@* |
| 2007 | @code{file-attributes}, @code{file-directory-p},@* | 1981 | @code{file-attributes}, |
| 2008 | @code{file-executable-p}, @code{file-exists-p}, @code{file-local-copy}, | 1982 | @code{file-directory-p}, |
| 2009 | @code{file-modes}, @code{file-name-all-completions}, | 1983 | @code{file-executable-p}, @code{file-exists-p},@* |
| 2010 | @code{file-name-as-directory}, @code{file-name-completion},@* | 1984 | @code{file-local-copy}, |
| 1985 | @code{file-modes}, @code{file-name-all-completions},@* | ||
| 1986 | @code{file-name-as-directory}, | ||
| 1987 | @code{file-name-completion}, | ||
| 2011 | @code{file-name-directory}, | 1988 | @code{file-name-directory}, |
| 2012 | @code{file-name-nondirectory}, | 1989 | @code{file-name-nondirectory}, |
| 2013 | @code{file-name-sans-versions}, @code{file-newer-than-file-p}, | 1990 | @code{file-name-sans-versions}, @code{file-newer-than-file-p}, |
| @@ -2015,15 +1992,16 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 2015 | @code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p}, | 1992 | @code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p}, |
| 2016 | @code{file-truename}, @code{file-writable-p}, | 1993 | @code{file-truename}, @code{file-writable-p}, |
| 2017 | @code{find-backup-file-name}, | 1994 | @code{find-backup-file-name}, |
| 2018 | @code{get-file-buffer}, | 1995 | @code{get-file-buffer},@* |
| 2019 | @code{insert-directory},@* | 1996 | @code{insert-directory}, |
| 2020 | @code{insert-file-contents}, | 1997 | @code{insert-file-contents}, |
| 2021 | @code{load}, @code{make-directory}, | 1998 | @code{load}, @code{make-directory}, |
| 2022 | @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes}, | 1999 | @code{make-symbolic-link}, @code{rename-file}, @code{set-file-modes}, |
| 2023 | @code{set-visited-file-modtime}, @code{shell-command}. | 2000 | @code{set-visited-file-modtime}, @code{shell-command}.@* |
| 2024 | @code{unhandled-file-name-directory},@* | 2001 | @code{unhandled-file-name-directory}, |
| 2025 | @code{vc-registered}, | 2002 | @code{vc-registered}, |
| 2026 | @code{verify-visited-file-modtime}, @code{write-region}. | 2003 | @code{verify-visited-file-modtime},@* |
| 2004 | @code{write-region}. | ||
| 2027 | 2005 | ||
| 2028 | Handlers for @code{insert-file-contents} typically need to clear the | 2006 | Handlers for @code{insert-file-contents} typically need to clear the |
| 2029 | buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the | 2007 | buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the |
| @@ -2140,10 +2118,13 @@ A regular expression which is used to recognize files represented in | |||
| 2140 | this format. | 2118 | this format. |
| 2141 | 2119 | ||
| 2142 | @item from-fn | 2120 | @item from-fn |
| 2143 | A function or shell command to decode data in this format (to convert | 2121 | A shell command or function to decode data in this format (to convert |
| 2144 | file data into the usual Emacs data representation). | 2122 | file data into the usual Emacs data representation). |
| 2145 | 2123 | ||
| 2146 | If @var{from-fn} is a function, it is called with two args, @var{begin} | 2124 | A shell command is represented as a string; Emacs runs the command as a |
| 2125 | filter to perform the conversion. | ||
| 2126 | |||
| 2127 | If @var{from-fn} is a function, it is called with two arguments, @var{begin} | ||
| 2147 | and @var{end}, which specify the part of the buffer it should convert. | 2128 | and @var{end}, which specify the part of the buffer it should convert. |
| 2148 | It should convert the text by editing it in place. Since this can | 2129 | It should convert the text by editing it in place. Since this can |
| 2149 | change the length of the text, @var{from-fn} should return the modified | 2130 | change the length of the text, @var{from-fn} should return the modified |
| @@ -2153,17 +2134,14 @@ One responsibility of @var{from-fn} is to make sure that the beginning | |||
| 2153 | of the file no longer matches @var{regexp}. Otherwise it is likely to | 2134 | of the file no longer matches @var{regexp}. Otherwise it is likely to |
| 2154 | get called again. | 2135 | get called again. |
| 2155 | 2136 | ||
| 2156 | If @var{from-fn} is a string, it is a shell command; Emacs runs the | ||
| 2157 | command as a filter to perform the conversion. | ||
| 2158 | |||
| 2159 | @item to-fn | 2137 | @item to-fn |
| 2160 | A function or shell command to encode data in this format (to convert | 2138 | A shell command or function to encode data in this format---that is, to |
| 2161 | the usual Emacs data representation into this format). | 2139 | convert the usual Emacs data representation into this format. |
| 2162 | 2140 | ||
| 2163 | If @var{to-fn} is a string, it is a shell command; Emacs runs the | 2141 | If @var{to-fn} is a string, it is a shell command; Emacs runs the |
| 2164 | command as a filter to perform the conversion. | 2142 | command as a filter to perform the conversion. |
| 2165 | 2143 | ||
| 2166 | If @var{to-fn} is a function, it is called with two args, @var{begin} | 2144 | If @var{to-fn} is a function, it is called with two arguments, @var{begin} |
| 2167 | and @var{end}, which specify the part of the buffer it should convert. | 2145 | and @var{end}, which specify the part of the buffer it should convert. |
| 2168 | There are two ways it can do the conversion: | 2146 | There are two ways it can do the conversion: |
| 2169 | 2147 | ||
| @@ -2209,7 +2187,7 @@ buffer-local variable @code{buffer-file-format}. | |||
| 2209 | @defvar buffer-file-format | 2187 | @defvar buffer-file-format |
| 2210 | This variable states the format of the visited file. More precisely, | 2188 | This variable states the format of the visited file. More precisely, |
| 2211 | this is a list of the file format names that were decoded in the course | 2189 | this is a list of the file format names that were decoded in the course |
| 2212 | of visiting the current buffer's file. It is always local in all | 2190 | of visiting the current buffer's file. It is always buffer-local in all |
| 2213 | buffers. | 2191 | buffers. |
| 2214 | @end defvar | 2192 | @end defvar |
| 2215 | 2193 | ||
| @@ -2234,7 +2212,7 @@ The argument @var{format} is a list of format names. If @var{format} is | |||
| 2234 | @key{RET} for @var{format} specifies @code{nil}. | 2212 | @key{RET} for @var{format} specifies @code{nil}. |
| 2235 | @end deffn | 2213 | @end deffn |
| 2236 | 2214 | ||
| 2237 | @deffn format-insert-file file format %optional beg end | 2215 | @deffn Command format-insert-file file format &optional beg end |
| 2238 | This command inserts the contents of file @var{file}, converting it | 2216 | This command inserts the contents of file @var{file}, converting it |
| 2239 | according to format @var{format}. If @var{beg} and @var{end} are | 2217 | according to format @var{format}. If @var{beg} and @var{end} are |
| 2240 | non-@code{nil}, they specify which part of the file to read, as in | 2218 | non-@code{nil}, they specify which part of the file to read, as in |
| @@ -2254,62 +2232,5 @@ This variable specifies the format to use for auto-saving. Its value is | |||
| 2254 | a list of format names, just like the value of | 2232 | a list of format names, just like the value of |
| 2255 | @code{buffer-file-format}; but it is used instead of | 2233 | @code{buffer-file-format}; but it is used instead of |
| 2256 | @code{buffer-file-format} for writing auto-save files. This variable | 2234 | @code{buffer-file-format} for writing auto-save files. This variable |
| 2257 | is always local in all buffers. | 2235 | is always buffer-local in all buffers. |
| 2258 | @end defvar | ||
| 2259 | |||
| 2260 | @node Files and MS-DOS | ||
| 2261 | @section Files and MS-DOS | ||
| 2262 | @cindex MS-DOS file types | ||
| 2263 | @cindex file types on MS-DOS | ||
| 2264 | @cindex text files and binary files | ||
| 2265 | @cindex binary files and text files | ||
| 2266 | @cindex Windows file types | ||
| 2267 | |||
| 2268 | @c ??? This needs to be updated. | ||
| 2269 | |||
| 2270 | Emacs on MS-DOS and on Windows NT or 95 makes a distinction between | ||
| 2271 | text files and binary files. This is necessary because ordinary text | ||
| 2272 | files on MS-DOS use a two character sequence between lines: | ||
| 2273 | carriage-return and linefeed (@sc{crlf}). Emacs expects just a newline | ||
| 2274 | character (a linefeed) between lines. When Emacs reads or writes a text | ||
| 2275 | file on MS-DOS, it needs to convert the line separators. This means it | ||
| 2276 | needs to know which files are text files and which are binary. It makes | ||
| 2277 | this decision when visiting a file, and records the decision in the | ||
| 2278 | variable @code{buffer-file-type} for use when the file is saved. | ||
| 2279 | |||
| 2280 | @xref{MS-DOS Subprocesses}, for a related feature for subprocesses. | ||
| 2281 | |||
| 2282 | @defvar buffer-file-type | ||
| 2283 | This variable, automatically local in each buffer, records the file type | ||
| 2284 | of the buffer's visited file. The value is @code{nil} for text, | ||
| 2285 | @code{t} for binary. | ||
| 2286 | @end defvar | 2236 | @end defvar |
| 2287 | |||
| 2288 | @defun find-buffer-file-type filename | ||
| 2289 | This function determines whether file @var{filename} is a text file | ||
| 2290 | or a binary file. It returns @code{nil} for text, @code{t} for binary. | ||
| 2291 | @end defun | ||
| 2292 | |||
| 2293 | @defopt file-name-buffer-file-type-alist | ||
| 2294 | This variable holds an alist for distinguishing text files from binary | ||
| 2295 | files. Each element has the form (@var{regexp} . @var{type}), where | ||
| 2296 | @var{regexp} is matched against the file name, and @var{type} may be | ||
| 2297 | @code{nil} for text, @code{t} for binary, or a function to call to | ||
| 2298 | compute which. If it is a function, then it is called with a single | ||
| 2299 | argument (the file name) and should return @code{t} or @code{nil}. | ||
| 2300 | @end defopt | ||
| 2301 | |||
| 2302 | @defopt default-buffer-file-type | ||
| 2303 | This variable specifies the default file type for files whose names | ||
| 2304 | don't indicate anything in particular. Its value should be @code{nil} | ||
| 2305 | for text, or @code{t} for binary. | ||
| 2306 | @end defopt | ||
| 2307 | |||
| 2308 | @deffn Command find-file-text filename | ||
| 2309 | Like @code{find-file}, but treat the file as text regardless of its name. | ||
| 2310 | @end deffn | ||
| 2311 | |||
| 2312 | @deffn Command find-file-binary filename | ||
| 2313 | Like @code{find-file}, but treat the file as binary regardless of its | ||
| 2314 | name. | ||
| 2315 | @end deffn | ||
diff --git a/lispref/frames.texi b/lispref/frames.texi index 0309abc7a1d..b5c641d891e 100644 --- a/lispref/frames.texi +++ b/lispref/frames.texi | |||
| @@ -18,10 +18,10 @@ horizontally into smaller windows. | |||
| 18 | @dfn{terminal frame}. If you create additional ones, Emacs displays | 18 | @dfn{terminal frame}. If you create additional ones, Emacs displays |
| 19 | one and only one at any given time---on the terminal screen, of course. | 19 | one and only one at any given time---on the terminal screen, of course. |
| 20 | 20 | ||
| 21 | When Emacs communicates directly with an X server, it does not have a | 21 | When Emacs communicates directly with a supported window system, such |
| 22 | terminal frame; instead, it starts with a single @dfn{X window frame}. | 22 | as X Windows, it does not have a terminal frame; instead, it starts with |
| 23 | It can display multiple X window frames at the same time, each in its | 23 | a single @dfn{window frame}, but you can create more, and Emacs can |
| 24 | own X window. | 24 | display several such frames at once as is usual for window systems. |
| 25 | 25 | ||
| 26 | @defun framep object | 26 | @defun framep object |
| 27 | This predicate returns @code{t} if @var{object} is a frame, and | 27 | This predicate returns @code{t} if @var{object} is a frame, and |
| @@ -30,7 +30,7 @@ This predicate returns @code{t} if @var{object} is a frame, and | |||
| 30 | 30 | ||
| 31 | @menu | 31 | @menu |
| 32 | * Creating Frames:: Creating additional frames. | 32 | * Creating Frames:: Creating additional frames. |
| 33 | * Multiple Displays:: Creating frames on other X displays. | 33 | * Multiple Displays:: Creating frames on other displays. |
| 34 | * Frame Parameters:: Controlling frame size, position, font, etc. | 34 | * Frame Parameters:: Controlling frame size, position, font, etc. |
| 35 | * Frame Titles:: Automatic updating of frame titles. | 35 | * Frame Titles:: Automatic updating of frame titles. |
| 36 | * Deleting Frames:: Frames last until explicitly deleted. | 36 | * Deleting Frames:: Frames last until explicitly deleted. |
| @@ -40,7 +40,7 @@ This predicate returns @code{t} if @var{object} is a frame, and | |||
| 40 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. | 40 | * Minibuffers and Frames:: How a frame finds the minibuffer to use. |
| 41 | * Input Focus:: Specifying the selected frame. | 41 | * Input Focus:: Specifying the selected frame. |
| 42 | * Visibility of Frames:: Frames may be visible or invisible, or icons. | 42 | * Visibility of Frames:: Frames may be visible or invisible, or icons. |
| 43 | * Raising and Lowering:: Raising a frame makes it hide other X windows; | 43 | * Raising and Lowering:: Raising a frame makes it hide other windows; |
| 44 | lowering it makes the others hide them. | 44 | lowering it makes the others hide them. |
| 45 | * Frame Configurations:: Saving the state of all frames. | 45 | * Frame Configurations:: Saving the state of all frames. |
| 46 | * Mouse Tracking:: Getting events that say when the mouse moves. | 46 | * Mouse Tracking:: Getting events that say when the mouse moves. |
| @@ -48,7 +48,7 @@ This predicate returns @code{t} if @var{object} is a frame, and | |||
| 48 | * Pop-Up Menus:: Displaying a menu for the user to select from. | 48 | * Pop-Up Menus:: Displaying a menu for the user to select from. |
| 49 | * Dialog Boxes:: Displaying a box to ask yes or no. | 49 | * Dialog Boxes:: Displaying a box to ask yes or no. |
| 50 | * Pointer Shapes:: Specifying the shape of the mouse pointer. | 50 | * Pointer Shapes:: Specifying the shape of the mouse pointer. |
| 51 | * X Selections:: Transferring text to and from other X clients. | 51 | * Window System Selections:: Transferring text to and from other X clients. |
| 52 | * Font Names:: Looking up font names. | 52 | * Font Names:: Looking up font names. |
| 53 | * Color Names:: Getting the definitions of color names. | 53 | * Color Names:: Getting the definitions of color names. |
| 54 | * Resources:: Getting resource values from the server. | 54 | * Resources:: Getting resource values from the server. |
| @@ -63,16 +63,17 @@ This predicate returns @code{t} if @var{object} is a frame, and | |||
| 63 | To create a new frame, call the function @code{make-frame}. | 63 | To create a new frame, call the function @code{make-frame}. |
| 64 | 64 | ||
| 65 | @defun make-frame &optional alist | 65 | @defun make-frame &optional alist |
| 66 | This function creates a new frame. If you are using X, it makes | 66 | This function creates a new frame. If you are using a supported window |
| 67 | an X window frame; otherwise, it makes a terminal frame. | 67 | system, it makes a window frame; otherwise, it makes a terminal frame. |
| 68 | 68 | ||
| 69 | The argument is an alist specifying frame parameters. Any parameters | 69 | The argument is an alist specifying frame parameters. Any parameters |
| 70 | not mentioned in @var{alist} default according to the value of the | 70 | not mentioned in @var{alist} default according to the value of the |
| 71 | variable @code{default-frame-alist}; parameters not specified even there | 71 | variable @code{default-frame-alist}; parameters not specified even there |
| 72 | default from the standard X defaults file and X resources. | 72 | default from the standard X resources or whatever is used instead on |
| 73 | your system. | ||
| 73 | 74 | ||
| 74 | The set of possible parameters depends in principle on what kind of | 75 | The set of possible parameters depends in principle on what kind of |
| 75 | window system Emacs uses to display its frames. @xref{X Frame | 76 | window system Emacs uses to display its frames. @xref{Window Frame |
| 76 | Parameters}, for documentation of individual parameters you can specify. | 77 | Parameters}, for documentation of individual parameters you can specify. |
| 77 | @end defun | 78 | @end defun |
| 78 | 79 | ||
| @@ -95,7 +96,7 @@ frame just created. | |||
| 95 | @cindex multiple X terminals | 96 | @cindex multiple X terminals |
| 96 | @cindex displays, multiple | 97 | @cindex displays, multiple |
| 97 | 98 | ||
| 98 | A single Emacs can talk to more than one X Windows display. | 99 | A single Emacs can talk to more than one X Window display. |
| 99 | Initially, Emacs uses just one display---the one chosen with the | 100 | Initially, Emacs uses just one display---the one chosen with the |
| 100 | @code{DISPLAY} environment variable or with the @samp{--display} option | 101 | @code{DISPLAY} environment variable or with the @samp{--display} option |
| 101 | (@pxref{Initial Options,,, emacs, The GNU Emacs Manual}). To connect to | 102 | (@pxref{Initial Options,,, emacs, The GNU Emacs Manual}). To connect to |
| @@ -108,7 +109,8 @@ have values local to the current terminal (that is, the terminal | |||
| 108 | corresponding to the currently selected frame): these are | 109 | corresponding to the currently selected frame): these are |
| 109 | @code{default-minibuffer-frame}, @code{defining-kbd-macro}, | 110 | @code{default-minibuffer-frame}, @code{defining-kbd-macro}, |
| 110 | @code{last-kbd-macro}, and @code{system-key-alist}. These variables are | 111 | @code{last-kbd-macro}, and @code{system-key-alist}. These variables are |
| 111 | always terminal-local and can never be buffer-local. | 112 | always terminal-local and can never be buffer-local or frame-local |
| 113 | (@pxref{Buffer-Local Variables}). | ||
| 112 | 114 | ||
| 113 | A single X server can handle more than one screen. A display name | 115 | A single X server can handle more than one screen. A display name |
| 114 | @samp{@var{host}.@var{server}.@var{screen}} has three parts; the last | 116 | @samp{@var{host}.@var{server}.@var{screen}} has three parts; the last |
| @@ -163,12 +165,13 @@ uses. | |||
| 163 | 165 | ||
| 164 | Frame parameters exist for the sake of window systems. A terminal frame | 166 | Frame parameters exist for the sake of window systems. A terminal frame |
| 165 | has a few parameters, mostly for compatibility's sake; only the height, | 167 | has a few parameters, mostly for compatibility's sake; only the height, |
| 166 | width and @code{buffer-predicate} parameters really do something. | 168 | width, @code{name}, @code{title}, @code{buffer-list} and |
| 169 | @code{buffer-predicate} parameters do something special. | ||
| 167 | 170 | ||
| 168 | @menu | 171 | @menu |
| 169 | * Parameter Access:: How to change a frame's parameters. | 172 | * Parameter Access:: How to change a frame's parameters. |
| 170 | * Initial Parameters:: Specifying frame parameters when you make a frame. | 173 | * Initial Parameters:: Specifying frame parameters when you make a frame. |
| 171 | * X Frame Parameters:: List of frame parameters. | 174 | * Window Frame Parameters:: List of frame parameters for window systems. |
| 172 | * Size and Position:: Changing the size and position of a frame. | 175 | * Size and Position:: Changing the size and position of a frame. |
| 173 | @end menu | 176 | @end menu |
| 174 | 177 | ||
| @@ -199,7 +202,7 @@ by setting @code{initial-frame-alist} in your @file{.emacs} file. | |||
| 199 | 202 | ||
| 200 | @defvar initial-frame-alist | 203 | @defvar initial-frame-alist |
| 201 | This variable's value is an alist of parameter values used when creating | 204 | This variable's value is an alist of parameter values used when creating |
| 202 | the initial X window frame. You can set this variable to specify the | 205 | the initial window frame. You can set this variable to specify the |
| 203 | appearance of the initial frame without altering subsequent frames. | 206 | appearance of the initial frame without altering subsequent frames. |
| 204 | Each element has the form: | 207 | Each element has the form: |
| 205 | 208 | ||
| @@ -239,8 +242,9 @@ to the parameters for the main initial frame. | |||
| 239 | 242 | ||
| 240 | @defvar default-frame-alist | 243 | @defvar default-frame-alist |
| 241 | This is an alist specifying default values of frame parameters for all | 244 | This is an alist specifying default values of frame parameters for all |
| 242 | Emacs frames---the first frame, and subsequent frames. In many cases, | 245 | Emacs frames---the first frame, and subsequent frames. When using the X |
| 243 | you can get the same results by means of X resources. | 246 | Window System, you can get the same results by means of X resources |
| 247 | in many cases. | ||
| 244 | @end defvar | 248 | @end defvar |
| 245 | 249 | ||
| 246 | See also @code{special-display-frame-alist}, in @ref{Choosing Window}. | 250 | See also @code{special-display-frame-alist}, in @ref{Choosing Window}. |
| @@ -251,28 +255,34 @@ exception is @samp{-geometry}, which adds the specified position to | |||
| 251 | @code{initial-frame-alist} instead. @xref{Command Arguments,,, emacs, | 255 | @code{initial-frame-alist} instead. @xref{Command Arguments,,, emacs, |
| 252 | The GNU Emacs Manual}. | 256 | The GNU Emacs Manual}. |
| 253 | 257 | ||
| 254 | @node X Frame Parameters | 258 | @node Window Frame Parameters |
| 255 | @subsection X Window Frame Parameters | 259 | @subsection Window Frame Parameters |
| 256 | 260 | ||
| 257 | Just what parameters a frame has depends on what display mechanism it | 261 | Just what parameters a frame has depends on what display mechanism it |
| 258 | uses. Here is a table of the parameters of an X window frame; of these, | 262 | uses. Here is a table of the parameters that have special meanings in a |
| 259 | @code{name}, @code{height}, @code{width}, and @code{buffer-predicate} | 263 | window frame; of these, @code{name}, @code{title}, @code{height}, |
| 260 | provide meaningful information in non-X frames. | 264 | @code{width}, @code{buffer-list} and @code{buffer-predicate} provide |
| 265 | meaningful information in terminal frames. | ||
| 261 | 266 | ||
| 262 | @table @code | 267 | @table @code |
| 268 | @item title | ||
| 269 | If a frame has a non-@code{nil} title, it appears in the window system's | ||
| 270 | border for the frame, and also in the mode line of windows in that frame | ||
| 271 | if @code{mode-line-frame-identification} uses @samp{%F} | ||
| 272 | (@pxref{%-Constructs}). This is normally the case when Emacs is not | ||
| 273 | using a window system, and can only display one frame at a time. | ||
| 274 | @xref{Frame Titles}. | ||
| 275 | |||
| 263 | @item name | 276 | @item name |
| 264 | The name of the frame. Most window managers display the frame's name in | 277 | The name of the frame. The frame name serves as a default for the frame |
| 265 | the frame's border, at the top of the frame. If you don't specify a | 278 | title, if the @code{title} parameter is unspecified or @code{nil}. If |
| 266 | name, and you have more than one frame, Emacs sets the frame name based | 279 | you don't specify a name, Emacs sets the frame name automatically |
| 267 | on the buffer displayed in the frame's selected window. | 280 | (@pxref{Frame Titles}). |
| 268 | 281 | ||
| 269 | If you specify the frame name explicitly when you create the frame, the | 282 | If you specify the frame name explicitly when you create the frame, the |
| 270 | name is also used (instead of the name of the Emacs executable) when | 283 | name is also used (instead of the name of the Emacs executable) when |
| 271 | looking up X resources for the frame. | 284 | looking up X resources for the frame. |
| 272 | 285 | ||
| 273 | Since a non-window terminal can display only one frame at a time, the | ||
| 274 | frame name appears in the mode line. | ||
| 275 | |||
| 276 | @item display | 286 | @item display |
| 277 | The display on which to open this frame. It should be a string of the | 287 | The display on which to open this frame. It should be a string of the |
| 278 | form @code{"@var{host}:@var{dpy}.@var{screen}"}, just like the | 288 | form @code{"@var{host}:@var{dpy}.@var{screen}"}, just like the |
| @@ -287,8 +297,9 @@ negative @var{pos} value. | |||
| 287 | A negative number @minus{}@var{pos}, or a list of the form @code{(- | 297 | A negative number @minus{}@var{pos}, or a list of the form @code{(- |
| 288 | @var{pos})}, actually specifies the position of the right edge of the | 298 | @var{pos})}, actually specifies the position of the right edge of the |
| 289 | window with respect to the right edge of the screen. A positive value | 299 | window with respect to the right edge of the screen. A positive value |
| 290 | of @var{pos} counts toward the left. If the parameter is a negative | 300 | of @var{pos} counts toward the left. @strong{Reminder:} if the |
| 291 | integer @minus{}@var{pos} then @var{pos} is positive! | 301 | parameter is a negative integer @minus{}@var{pos}, then @var{pos} is |
| 302 | positive. | ||
| 292 | 303 | ||
| 293 | Some window managers ignore program-specified positions. If you want to | 304 | Some window managers ignore program-specified positions. If you want to |
| 294 | be sure the position you specify is not ignored, specify a | 305 | be sure the position you specify is not ignored, specify a |
| @@ -303,8 +314,9 @@ negative @var{pos} value. | |||
| 303 | A negative number @minus{}@var{pos}, or a list of the form @code{(- | 314 | A negative number @minus{}@var{pos}, or a list of the form @code{(- |
| 304 | @var{pos})}, actually specifies the position of the bottom edge of the | 315 | @var{pos})}, actually specifies the position of the bottom edge of the |
| 305 | window with respect to the bottom edge of the screen. A positive value | 316 | window with respect to the bottom edge of the screen. A positive value |
| 306 | of @var{pos} counts toward the top. If the parameter is a negative | 317 | of @var{pos} counts toward the top. @strong{Reminder:} if the |
| 307 | integer @minus{}@var{pos} then @var{pos} is positive! | 318 | parameter is a negative integer @minus{}@var{pos}, then @var{pos} is |
| 319 | positive. | ||
| 308 | 320 | ||
| 309 | Some window managers ignore program-specified positions. If you want to | 321 | Some window managers ignore program-specified positions. If you want to |
| 310 | be sure the position you specify is not ignored, specify a | 322 | be sure the position you specify is not ignored, specify a |
| @@ -348,7 +360,7 @@ The width of the frame contents, in characters. (To get the height in | |||
| 348 | pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.) | 360 | pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.) |
| 349 | 361 | ||
| 350 | @item window-id | 362 | @item window-id |
| 351 | The number of the X window for the frame. | 363 | The number of the window-system window used by the frame. |
| 352 | 364 | ||
| 353 | @item minibuffer | 365 | @item minibuffer |
| 354 | Whether this frame has its own minibuffer. The value @code{t} means | 366 | Whether this frame has its own minibuffer. The value @code{t} means |
| @@ -360,12 +372,13 @@ the new frame uses that minibuffer. | |||
| 360 | The buffer-predicate function for this frame. The function | 372 | The buffer-predicate function for this frame. The function |
| 361 | @code{other-buffer} uses this predicate (from the selected frame) to | 373 | @code{other-buffer} uses this predicate (from the selected frame) to |
| 362 | decide which buffers it should consider, if the predicate is not | 374 | decide which buffers it should consider, if the predicate is not |
| 363 | @code{nil}. It calls the predicate with one arg, a buffer, once for | 375 | @code{nil}. It calls the predicate with one argument, a buffer, once for |
| 364 | each buffer; if the predicate returns a non-@code{nil} value, it | 376 | each buffer; if the predicate returns a non-@code{nil} value, it |
| 365 | considers that buffer. | 377 | considers that buffer. |
| 366 | 378 | ||
| 367 | @item buffer-list | 379 | @item buffer-list |
| 368 | A list of buffers recently selected in this frame. | 380 | A list of buffers that have been selected in this frame, |
| 381 | ordered most-recently-selected first. | ||
| 369 | 382 | ||
| 370 | @item font | 383 | @item font |
| 371 | The name of the font for displaying text in the frame. This is a | 384 | The name of the font for displaying text in the frame. This is a |
| @@ -401,8 +414,8 @@ The name to use in the icon for this frame, when and if the icon | |||
| 401 | appears. If this is @code{nil}, the frame's title is used. | 414 | appears. If this is @code{nil}, the frame's title is used. |
| 402 | 415 | ||
| 403 | @item foreground-color | 416 | @item foreground-color |
| 404 | The color to use for the image of a character. This is a string; the X | 417 | The color to use for the image of a character. This is a string; the |
| 405 | server defines the meaningful color names. | 418 | window system defines the meaningful color names. |
| 406 | 419 | ||
| 407 | @item background-color | 420 | @item background-color |
| 408 | The color to use for the background of characters. | 421 | The color to use for the background of characters. |
| @@ -507,7 +520,7 @@ Size}. | |||
| 507 | 520 | ||
| 508 | @defun x-parse-geometry geom | 521 | @defun x-parse-geometry geom |
| 509 | @cindex geometry specification | 522 | @cindex geometry specification |
| 510 | The function @code{x-parse-geometry} converts a standard X windows | 523 | The function @code{x-parse-geometry} converts a standard X Windows |
| 511 | geometry string to an alist that you can use as part of the argument to | 524 | geometry string to an alist that you can use as part of the argument to |
| 512 | @code{make-frame}. | 525 | @code{make-frame}. |
| 513 | 526 | ||
| @@ -560,24 +573,25 @@ the second. | |||
| 560 | @node Frame Titles | 573 | @node Frame Titles |
| 561 | @section Frame Titles | 574 | @section Frame Titles |
| 562 | 575 | ||
| 563 | Every frame has a title; most window managers display the frame title at | 576 | Every frame has a @code{name} parameter; this serves as the default |
| 564 | the top of the frame. You can specify an explicit title with the | 577 | for the frame title which window systems typically display at the top of |
| 565 | @code{name} frame property. But normally you don't specify this | 578 | the frame. You can specify a name explicitly by setting the @code{name} |
| 566 | explicitly, and Emacs computes the title automatically. | 579 | frame property. |
| 567 | 580 | ||
| 568 | Emacs computes the frame title based on a template stored in the | 581 | Normally you don't specify the name explicitly, and Emacs computes the |
| 569 | variable @code{frame-title-format}. | 582 | frame name automatically based on a template stored in the variable |
| 583 | @code{frame-title-format}. Emacs recomputes the name each time the | ||
| 584 | frame is redisplayed. | ||
| 570 | 585 | ||
| 571 | @defvar frame-title-format | 586 | @defvar frame-title-format |
| 572 | This variable specifies how to compute a title for a frame | 587 | This variable specifies how to compute a name for a frame when you have |
| 573 | when you have not explicitly specified one. | 588 | not explicitly specified one. The variable's value is actually a mode |
| 574 | 589 | line construct, just like @code{mode-line-format}. @xref{Mode Line | |
| 575 | The variable's value is actually a mode line construct, just like | 590 | Data}. |
| 576 | @code{mode-line-format}. @xref{Mode Line Data}. | ||
| 577 | @end defvar | 591 | @end defvar |
| 578 | 592 | ||
| 579 | @defvar icon-title-format | 593 | @defvar icon-title-format |
| 580 | This variable specifies how to compute the title for an iconified frame, | 594 | This variable specifies how to compute the name for an iconified frame, |
| 581 | when you have not explicitly specified the frame title. This title | 595 | when you have not explicitly specified the frame title. This title |
| 582 | appears in the icon itself. | 596 | appears in the icon itself. |
| 583 | @end defvar | 597 | @end defvar |
| @@ -694,11 +708,11 @@ This function returns the window on @var{frame} that is selected within | |||
| 694 | @var{frame}. | 708 | @var{frame}. |
| 695 | @end defun | 709 | @end defun |
| 696 | 710 | ||
| 697 | Conversely, selecting a window for Emacs with @code{select-window} also | 711 | Conversely, selecting a window for Emacs with @code{select-window} also |
| 698 | makes that window selected within its frame. @xref{Selecting Windows}. | 712 | makes that window selected within its frame. @xref{Selecting Windows}. |
| 699 | 713 | ||
| 700 | Another function that (usually) returns one of the windows in a frame is | 714 | Another function that (usually) returns one of the windows in a given |
| 701 | @code{minibuffer-window}. @xref{Minibuffer Misc}. | 715 | frame is @code{minibuffer-window}. @xref{Minibuffer Misc}. |
| 702 | 716 | ||
| 703 | @node Minibuffers and Frames | 717 | @node Minibuffers and Frames |
| 704 | @section Minibuffers and Frames | 718 | @section Minibuffers and Frames |
| @@ -736,23 +750,23 @@ window always resides on the selected frame. | |||
| 736 | This function returns the selected frame. | 750 | This function returns the selected frame. |
| 737 | @end defun | 751 | @end defun |
| 738 | 752 | ||
| 739 | The X server normally directs keyboard input to the X window that the | 753 | Some window systems and window managers direct keyboard input to the |
| 740 | mouse is in. Some window managers use mouse clicks or keyboard events | 754 | window object that the mouse is in; others require explicit clicks or |
| 741 | to @dfn{shift the focus} to various X windows, overriding the normal | 755 | commands to @dfn{shift the focus} to various window objects. Either |
| 742 | behavior of the server. | 756 | way, Emacs automatically keeps track of which frame has the focus. |
| 743 | 757 | ||
| 744 | Lisp programs can switch frames ``temporarily'' by calling | 758 | Lisp programs can also switch frames ``temporarily'' by calling the |
| 745 | the function @code{select-frame}. This does not override the window | 759 | function @code{select-frame}. This does not alter the window system's |
| 746 | manager; rather, it escapes from the window manager's control until | 760 | concept of focus; rather, it escapes from the window manager's control |
| 747 | that control is somehow reasserted. | 761 | until that control is somehow reasserted. |
| 748 | 762 | ||
| 749 | When using a text-only terminal, there is no window manager; therefore, | 763 | When using a text-only terminal, only the selected terminal frame is |
| 750 | @code{switch-frame} is the only way to switch frames, and the effect | 764 | actually displayed on the terminal. @code{switch-frame} is the only way |
| 751 | lasts until overridden by a subsequent call to @code{switch-frame}. | 765 | to switch frames, and the change lasts until overridden by a subsequent |
| 752 | Only the selected terminal frame is actually displayed on the terminal. | 766 | call to @code{switch-frame}. Each terminal screen except for the |
| 753 | Each terminal screen except for the initial one has a number, and the | 767 | initial one has a number, and the number of the selected frame appears |
| 754 | number of the selected frame appears in the mode line after the word | 768 | in the mode line after the word @samp{Emacs} (@pxref{Mode Line |
| 755 | @samp{Emacs} (@pxref{Mode Line Variables}). | 769 | Variables}). |
| 756 | 770 | ||
| 757 | @c ??? This is not yet implemented properly. | 771 | @c ??? This is not yet implemented properly. |
| 758 | @defun select-frame frame | 772 | @defun select-frame frame |
| @@ -762,10 +776,10 @@ the next time the user does something to select a different frame, or | |||
| 762 | until the next time this function is called. | 776 | until the next time this function is called. |
| 763 | @end defun | 777 | @end defun |
| 764 | 778 | ||
| 765 | Emacs cooperates with the X server and the window managers by arranging | 779 | Emacs cooperates with the window system by arranging to select frames as |
| 766 | to select frames according to what the server and window manager ask | 780 | the server and window manager request. It does so by generating a |
| 767 | for. It does so by generating a special kind of input event, called a | 781 | special kind of input event, called a @dfn{focus} event, when |
| 768 | @dfn{focus} event. The command loop handles a focus event by calling | 782 | appropriate. The command loop handles a focus event by calling |
| 769 | @code{handle-switch-frame}. @xref{Focus Events}. | 783 | @code{handle-switch-frame}. @xref{Focus Events}. |
| 770 | 784 | ||
| 771 | @deffn Command handle-switch-frame frame | 785 | @deffn Command handle-switch-frame frame |
| @@ -806,6 +820,14 @@ The redirection lasts until @code{redirect-frame-focus} is called to | |||
| 806 | change it. | 820 | change it. |
| 807 | @end defun | 821 | @end defun |
| 808 | 822 | ||
| 823 | @tindex focus-follows-mouse | ||
| 824 | @defopt focus-follows-mouse | ||
| 825 | This option is how you inform Emacs whether the window manager transfers | ||
| 826 | focus when the user moves the mouse. Non-@code{nil} says that it does. | ||
| 827 | When this is so, the command @code{other-frame} moves the mouse to a | ||
| 828 | position consistent with the new selected frame. | ||
| 829 | @end defopt | ||
| 830 | |||
| 809 | @node Visibility of Frames | 831 | @node Visibility of Frames |
| 810 | @section Visibility of Frames | 832 | @section Visibility of Frames |
| 811 | @cindex visible frame | 833 | @cindex visible frame |
| @@ -813,7 +835,7 @@ change it. | |||
| 813 | @cindex iconified frame | 835 | @cindex iconified frame |
| 814 | @cindex frame visibility | 836 | @cindex frame visibility |
| 815 | 837 | ||
| 816 | An X window frame may be @dfn{visible}, @dfn{invisible}, or | 838 | A window frame may be @dfn{visible}, @dfn{invisible}, or |
| 817 | @dfn{iconified}. If it is visible, you can see its contents. If it is | 839 | @dfn{iconified}. If it is visible, you can see its contents. If it is |
| 818 | iconified, the frame's contents do not appear on the screen, but an icon | 840 | iconified, the frame's contents do not appear on the screen, but an icon |
| 819 | does. If the frame is invisible, it doesn't show on the screen, not | 841 | does. If the frame is invisible, it doesn't show on the screen, not |
| @@ -844,7 +866,7 @@ This returns the visibility status of frame @var{frame}. The value is | |||
| 844 | @end defun | 866 | @end defun |
| 845 | 867 | ||
| 846 | The visibility status of a frame is also available as a frame | 868 | The visibility status of a frame is also available as a frame |
| 847 | parameter. You can read or change it as such. @xref{X Frame | 869 | parameter. You can read or change it as such. @xref{Window Frame |
| 848 | Parameters}. | 870 | Parameters}. |
| 849 | 871 | ||
| 850 | The user can iconify and deiconify frames with the window manager. | 872 | The user can iconify and deiconify frames with the window manager. |
| @@ -855,23 +877,23 @@ changes. @xref{Misc Events}. | |||
| 855 | @node Raising and Lowering | 877 | @node Raising and Lowering |
| 856 | @section Raising and Lowering Frames | 878 | @section Raising and Lowering Frames |
| 857 | 879 | ||
| 858 | The X Window System uses a desktop metaphor. Part of this metaphor is | 880 | Most window systems use a desktop metaphor. Part of this metaphor is |
| 859 | the idea that windows are stacked in a notional third dimension | 881 | the idea that windows are stacked in a notional third dimension |
| 860 | perpendicular to the screen surface, and thus ordered from ``highest'' | 882 | perpendicular to the screen surface, and thus ordered from ``highest'' |
| 861 | to ``lowest''. Where two X windows overlap, the one higher up covers | 883 | to ``lowest''. Where two windows overlap, the one higher up covers |
| 862 | the one underneath. Even an X window at the bottom of the stack can be | 884 | the one underneath. Even a window at the bottom of the stack can be |
| 863 | seen if no other X window overlaps it. | 885 | seen if no other window overlaps it. |
| 864 | 886 | ||
| 865 | @cindex raising a frame | 887 | @cindex raising a frame |
| 866 | @cindex lowering a frame | 888 | @cindex lowering a frame |
| 867 | An X window's place in this ordering is not fixed; in fact, users tend | 889 | A window's place in this ordering is not fixed; in fact, users tend |
| 868 | to change the order frequently. @dfn{Raising} an X window means moving | 890 | to change the order frequently. @dfn{Raising} a window means moving |
| 869 | it ``up'', to the top of the stack. @dfn{Lowering} an X window means | 891 | it ``up'', to the top of the stack. @dfn{Lowering} a window means |
| 870 | moving it to the bottom of the stack. This motion is in the notional | 892 | moving it to the bottom of the stack. This motion is in the notional |
| 871 | third dimension only, and does not change the position of the X window | 893 | third dimension only, and does not change the position of the window |
| 872 | on the screen. | 894 | on the screen. |
| 873 | 895 | ||
| 874 | You can raise and lower Emacs's X windows with these functions: | 896 | You can raise and lower Emacs frame Windows with these functions: |
| 875 | 897 | ||
| 876 | @deffn Command raise-frame frame | 898 | @deffn Command raise-frame frame |
| 877 | This function raises frame @var{frame}. | 899 | This function raises frame @var{frame}. |
| @@ -888,7 +910,7 @@ that the minibuffer window is in. | |||
| 888 | 910 | ||
| 889 | You can also enable auto-raise (raising automatically when a frame is | 911 | You can also enable auto-raise (raising automatically when a frame is |
| 890 | selected) or auto-lower (lowering automatically when it is deselected) | 912 | selected) or auto-lower (lowering automatically when it is deselected) |
| 891 | for any frame using frame parameters. @xref{X Frame Parameters}. | 913 | for any frame using frame parameters. @xref{Window Frame Parameters}. |
| 892 | 914 | ||
| 893 | @node Frame Configurations | 915 | @node Frame Configurations |
| 894 | @section Frame Configurations | 916 | @section Frame Configurations |
| @@ -896,6 +918,7 @@ for any frame using frame parameters. @xref{X Frame Parameters}. | |||
| 896 | 918 | ||
| 897 | A @dfn{frame configuration} records the current arrangement of frames, | 919 | A @dfn{frame configuration} records the current arrangement of frames, |
| 898 | all their properties, and the window configuration of each one. | 920 | all their properties, and the window configuration of each one. |
| 921 | (@xref{Window Configurations}.) | ||
| 899 | 922 | ||
| 900 | @defun current-frame-configuration | 923 | @defun current-frame-configuration |
| 901 | This function returns a frame configuration list that describes | 924 | This function returns a frame configuration list that describes |
| @@ -925,12 +948,15 @@ mouse forever---only until some other event, such as the release of a | |||
| 925 | button. | 948 | button. |
| 926 | 949 | ||
| 927 | @defspec track-mouse body@dots{} | 950 | @defspec track-mouse body@dots{} |
| 928 | Execute @var{body}, meanwhile generating input events for mouse motion. | 951 | This special form executes @var{body}, with generation of mouse motion |
| 929 | The code in @var{body} can read these events with @code{read-event} or | 952 | events enabled. Typically @var{body} would use @code{read-event} to |
| 930 | @code{read-key-sequence}. @xref{Motion Events}, for the format of mouse | 953 | read the motion events and modify the display accordingly. @xref{Motion |
| 931 | motion events. | 954 | Events}, for the format of mouse motion events. |
| 932 | 955 | ||
| 933 | The value of @code{track-mouse} is that of the last form in @var{body}. | 956 | The value of @code{track-mouse} is that of the last form in @var{body}. |
| 957 | You should design @var{body} to return when it sees the up-event that | ||
| 958 | indicates the release of the button, or whatever kind of event means | ||
| 959 | it is time to stop tracking. | ||
| 934 | @end defspec | 960 | @end defspec |
| 935 | 961 | ||
| 936 | The usual purpose of tracking mouse motion is to indicate on the screen | 962 | The usual purpose of tracking mouse motion is to indicate on the screen |
| @@ -947,7 +973,7 @@ Lisp-level mouse tracking. | |||
| 947 | 973 | ||
| 948 | These functions change the screen appearance instantaneously. The | 974 | These functions change the screen appearance instantaneously. The |
| 949 | effect is transient, only until the next ordinary Emacs redisplay. That | 975 | effect is transient, only until the next ordinary Emacs redisplay. That |
| 950 | is ok for mouse tracking, since it doesn't make sense for mouse tracking | 976 | is OK for mouse tracking, since it doesn't make sense for mouse tracking |
| 951 | to change the text, and the body of @code{track-mouse} normally reads | 977 | to change the text, and the body of @code{track-mouse} normally reads |
| 952 | the events itself and does not do redisplay. | 978 | the events itself and does not do redisplay. |
| 953 | 979 | ||
| @@ -1015,8 +1041,8 @@ characters. These coordinates are not required to be within the frame. | |||
| 1015 | @node Pop-Up Menus | 1041 | @node Pop-Up Menus |
| 1016 | @section Pop-Up Menus | 1042 | @section Pop-Up Menus |
| 1017 | 1043 | ||
| 1018 | When using X windows, a Lisp program can pop up a menu which the | 1044 | When using a window system, a Lisp program can pop up a menu so that |
| 1019 | user can choose from with the mouse. | 1045 | the user can choose an alternative with the mouse. |
| 1020 | 1046 | ||
| 1021 | @defun x-popup-menu position menu | 1047 | @defun x-popup-menu position menu |
| 1022 | This function displays a pop-up menu and returns an indication of | 1048 | This function displays a pop-up menu and returns an indication of |
| @@ -1083,13 +1109,13 @@ the menu keymap as necessary. | |||
| 1083 | @section Dialog Boxes | 1109 | @section Dialog Boxes |
| 1084 | @cindex dialog boxes | 1110 | @cindex dialog boxes |
| 1085 | 1111 | ||
| 1086 | A dialog box is a variant of a pop-up menu. It looks a little | 1112 | A dialog box is a variant of a pop-up menu---it looks a little |
| 1087 | different (if Emacs uses an X toolkit), it always appears in the center | 1113 | different, it always appears in the center of a frame, and it has just |
| 1088 | of a frame, and it has just one level and one pane. The main use of | 1114 | one level and one pane. The main use of dialog boxes is for asking |
| 1089 | dialog boxes is for asking questions that the user can answer with | 1115 | questions that the user can answer with ``yes'', ``no'', and a few other |
| 1090 | ``yes'', ``no'', and a few other alternatives. The functions | 1116 | alternatives. The functions @code{y-or-n-p} and @code{yes-or-no-p} use |
| 1091 | @code{y-or-n-p} and @code{yes-or-no-p} use dialog boxes instead of the | 1117 | dialog boxes instead of the keyboard, when called from commands invoked |
| 1092 | keyboard, when called from commands invoked by mouse clicks. | 1118 | by mouse clicks. |
| 1093 | 1119 | ||
| 1094 | @defun x-popup-dialog position contents | 1120 | @defun x-popup-dialog position contents |
| 1095 | This function displays a pop-up dialog box and returns an indication of | 1121 | This function displays a pop-up dialog box and returns an indication of |
| @@ -1121,9 +1147,9 @@ Dialog boxes always appear in the center of a frame; the argument | |||
| 1121 | @code{x-popup-menu}, but the precise coordinates don't matter; only the | 1147 | @code{x-popup-menu}, but the precise coordinates don't matter; only the |
| 1122 | frame matters. | 1148 | frame matters. |
| 1123 | 1149 | ||
| 1124 | If your Emacs executable does not use an X toolkit, then it cannot | 1150 | In some configurations, Emacs cannot display a real dialog box; so |
| 1125 | display a real dialog box; so instead it displays the same items in a | 1151 | instead it displays the same items in a pop-up menu in the center of the |
| 1126 | pop-up menu in the center of the frame. | 1152 | frame. |
| 1127 | @end defun | 1153 | @end defun |
| 1128 | 1154 | ||
| 1129 | @node Pointer Shapes | 1155 | @node Pointer Shapes |
| @@ -1132,7 +1158,7 @@ pop-up menu in the center of the frame. | |||
| 1132 | @cindex mouse pointer shape | 1158 | @cindex mouse pointer shape |
| 1133 | 1159 | ||
| 1134 | These variables specify which shape to use for the mouse pointer in | 1160 | These variables specify which shape to use for the mouse pointer in |
| 1135 | various situations: | 1161 | various situations, when using the X Window System: |
| 1136 | 1162 | ||
| 1137 | @table @code | 1163 | @table @code |
| 1138 | @item x-pointer-shape | 1164 | @item x-pointer-shape |
| @@ -1149,14 +1175,14 @@ is over mouse-sensitive text. | |||
| 1149 | These variables affect newly created frames. They do not normally | 1175 | These variables affect newly created frames. They do not normally |
| 1150 | affect existing frames; however, if you set the mouse color of a frame, | 1176 | affect existing frames; however, if you set the mouse color of a frame, |
| 1151 | that also updates its pointer shapes based on the current values of | 1177 | that also updates its pointer shapes based on the current values of |
| 1152 | these variables. @xref{X Frame Parameters}. | 1178 | these variables. @xref{Window Frame Parameters}. |
| 1153 | 1179 | ||
| 1154 | The values you can use, to specify either of these pointer shapes, are | 1180 | The values you can use, to specify either of these pointer shapes, are |
| 1155 | defined in the file @file{lisp/term/x-win.el}. Use @kbd{M-x apropos | 1181 | defined in the file @file{lisp/term/x-win.el}. Use @kbd{M-x apropos |
| 1156 | @key{RET} x-pointer @key{RET}} to see a list of them. | 1182 | @key{RET} x-pointer @key{RET}} to see a list of them. |
| 1157 | 1183 | ||
| 1158 | @node X Selections | 1184 | @node Window System Selections |
| 1159 | @section X Selections | 1185 | @section Window System Selections |
| 1160 | @cindex selection (for X windows) | 1186 | @cindex selection (for X windows) |
| 1161 | 1187 | ||
| 1162 | The X server records a set of @dfn{selections} which permit transfer of | 1188 | The X server records a set of @dfn{selections} which permit transfer of |
| @@ -1221,9 +1247,9 @@ like the way successive kills in Emacs move down the kill ring. | |||
| 1221 | 1247 | ||
| 1222 | @defun x-list-font pattern &optional face frame maximum | 1248 | @defun x-list-font pattern &optional face frame maximum |
| 1223 | This function returns a list of available font names that match | 1249 | This function returns a list of available font names that match |
| 1224 | @var{pattern}. If the optional arguments FACE and FRAME are specified, | 1250 | @var{pattern}. If the optional arguments @var{face} and @var{frame} are |
| 1225 | then the list is limited to fonts that are the same size as @var{face} | 1251 | specified, then the list is limited to fonts that are the same size as |
| 1226 | currently is on @var{frame}. | 1252 | @var{face} currently is on @var{frame}. |
| 1227 | 1253 | ||
| 1228 | The argument @var{pattern} should be a string, perhaps with wildcard | 1254 | The argument @var{pattern} should be a string, perhaps with wildcard |
| 1229 | characters: the @samp{*} character matches any substring, and the | 1255 | characters: the @samp{*} character matches any substring, and the |
diff --git a/lispref/functions.texi b/lispref/functions.texi index 4ec73a1445f..b770ac39f7c 100644 --- a/lispref/functions.texi +++ b/lispref/functions.texi | |||
| @@ -112,8 +112,8 @@ byte compiler. @xref{Byte-Code Type}. | |||
| 112 | 112 | ||
| 113 | @tindex functionp | 113 | @tindex functionp |
| 114 | @defun functionp object | 114 | @defun functionp object |
| 115 | This function returns @code{t} if @var{object} is any kind of function; | 115 | This function returns @code{t} if @var{object} is any kind of function, |
| 116 | that is, anything that could be called as a function. | 116 | or a special form or macro. |
| 117 | @end defun | 117 | @end defun |
| 118 | 118 | ||
| 119 | @defun subrp object | 119 | @defun subrp object |
| @@ -386,7 +386,7 @@ facilities. @xref{Documentation}, for how the @var{documentation-string} is | |||
| 386 | accessed. | 386 | accessed. |
| 387 | 387 | ||
| 388 | It is a good idea to provide documentation strings for all the | 388 | It is a good idea to provide documentation strings for all the |
| 389 | functions in your program, even those that are only called from within | 389 | functions in your program, even those that are called only from within |
| 390 | your program. Documentation strings are like comments, except that they | 390 | your program. Documentation strings are like comments, except that they |
| 391 | are easier to access. | 391 | are easier to access. |
| 392 | 392 | ||
| @@ -419,7 +419,7 @@ as the return value and as the documentation. | |||
| 419 | In most computer languages, every function has a name; the idea of a | 419 | In most computer languages, every function has a name; the idea of a |
| 420 | function without a name is nonsensical. In Lisp, a function in the | 420 | function without a name is nonsensical. In Lisp, a function in the |
| 421 | strictest sense has no name. It is simply a list whose first element is | 421 | strictest sense has no name. It is simply a list whose first element is |
| 422 | @code{lambda}, or a primitive subr-object. | 422 | @code{lambda}, a byte-code function object, or a primitive subr-object. |
| 423 | 423 | ||
| 424 | However, a symbol can serve as the name of a function. This happens | 424 | However, a symbol can serve as the name of a function. This happens |
| 425 | when you put the function in the symbol's @dfn{function cell} | 425 | when you put the function in the symbol's @dfn{function cell} |
| @@ -580,7 +580,8 @@ name it calls is written in your program. This means that you choose | |||
| 580 | which function to call, and how many arguments to give it, when you | 580 | which function to call, and how many arguments to give it, when you |
| 581 | write the program. Usually that's just what you want. Occasionally you | 581 | write the program. Usually that's just what you want. Occasionally you |
| 582 | need to compute at run time which function to call. To do that, use the | 582 | need to compute at run time which function to call. To do that, use the |
| 583 | functions @code{funcall} and @code{apply}. | 583 | function @code{funcall}. When you also need to determine at run time |
| 584 | how may arguments to pass, use @code{apply}. | ||
| 584 | 585 | ||
| 585 | @defun funcall function &rest arguments | 586 | @defun funcall function &rest arguments |
| 586 | @code{funcall} calls @var{function} with @var{arguments}, and returns | 587 | @code{funcall} calls @var{function} with @var{arguments}, and returns |
| @@ -690,15 +691,19 @@ This function ignores any arguments and returns @code{nil}. | |||
| 690 | list or other collection. Emacs Lisp has several such functions; | 691 | list or other collection. Emacs Lisp has several such functions; |
| 691 | @code{mapcar} and @code{mapconcat}, which scan a list, are described | 692 | @code{mapcar} and @code{mapconcat}, which scan a list, are described |
| 692 | here. @xref{Creating Symbols}, for the function @code{mapatoms} which | 693 | here. @xref{Creating Symbols}, for the function @code{mapatoms} which |
| 693 | maps over the symbols in an obarray. @xref{Char-Tables}, for the | 694 | maps over the symbols in an obarray. |
| 694 | function @code{map-char-table}, which maps over the elements in a | 695 | |
| 695 | char-table. | 696 | These mapping functions do not allow char-tables because a char-table |
| 697 | is a sparse array whose nominal range of indices is very large. To map | ||
| 698 | over a char-table in a way that deals properly with its sparse nature, | ||
| 699 | use the function @code{map-char-table} (@pxref{Char-Tables}). | ||
| 696 | 700 | ||
| 697 | @defun mapcar function sequence | 701 | @defun mapcar function sequence |
| 698 | @code{mapcar} applies @var{function} to each element of @var{sequence} | 702 | @code{mapcar} applies @var{function} to each element of @var{sequence} |
| 699 | in turn, and returns a list of the results. | 703 | in turn, and returns a list of the results. |
| 700 | 704 | ||
| 701 | The argument @var{sequence} may be a list, a vector, or a string. The | 705 | The argument @var{sequence} can be any kind of sequence except a |
| 706 | char-table; that is, a list, a vector, a bool-vector, or a string. The | ||
| 702 | result is always a list. The length of the result is the same as the | 707 | result is always a list. The length of the result is the same as the |
| 703 | length of @var{sequence}. | 708 | length of @var{sequence}. |
| 704 | 709 | ||
| @@ -720,14 +725,14 @@ length of @var{sequence}. | |||
| 720 | @end group | 725 | @end group |
| 721 | 726 | ||
| 722 | @group | 727 | @group |
| 723 | (defun mapcar* (f &rest args) | 728 | (defun mapcar* (function &rest args) |
| 724 | "Apply FUNCTION to successive cars of all ARGS. | 729 | "Apply FUNCTION to successive cars of all ARGS. |
| 725 | Return the list of results." | 730 | Return the list of results." |
| 726 | ;; @r{If no list is exhausted,} | 731 | ;; @r{If no list is exhausted,} |
| 727 | (if (not (memq 'nil args)) | 732 | (if (not (memq 'nil args)) |
| 728 | ;; @r{apply function to @sc{CAR}s.} | 733 | ;; @r{apply function to @sc{car}s.} |
| 729 | (cons (apply f (mapcar 'car args)) | 734 | (cons (apply function (mapcar 'car args)) |
| 730 | (apply 'mapcar* f | 735 | (apply 'mapcar* function |
| 731 | ;; @r{Recurse for rest of elements.} | 736 | ;; @r{Recurse for rest of elements.} |
| 732 | (mapcar 'cdr args))))) | 737 | (mapcar 'cdr args))))) |
| 733 | @end group | 738 | @end group |
| @@ -747,7 +752,9 @@ Between each pair of result strings, @code{mapconcat} inserts the string | |||
| 747 | other suitable punctuation. | 752 | other suitable punctuation. |
| 748 | 753 | ||
| 749 | The argument @var{function} must be a function that can take one | 754 | The argument @var{function} must be a function that can take one |
| 750 | argument and return a string. | 755 | argument and return a string. The argument @var{sequence} can be any |
| 756 | kind of sequence except a char-table; that is, a list, a vector, a | ||
| 757 | bool-vector, or a string. | ||
| 751 | 758 | ||
| 752 | @smallexample | 759 | @smallexample |
| 753 | @group | 760 | @group |
| @@ -823,7 +830,7 @@ uses a function as its third argument: | |||
| 823 | 830 | ||
| 824 | @noindent | 831 | @noindent |
| 825 | Here we define a function that uses @code{change-property}, | 832 | Here we define a function that uses @code{change-property}, |
| 826 | passing a function that doubles its argument: | 833 | passing it a function to double a number: |
| 827 | 834 | ||
| 828 | @example | 835 | @example |
| 829 | @group | 836 | @group |
| @@ -978,15 +985,18 @@ There are three normal uses of this function: | |||
| 978 | 985 | ||
| 979 | @itemize @bullet | 986 | @itemize @bullet |
| 980 | @item | 987 | @item |
| 981 | Copying one symbol's function definition to another. (In other words, | 988 | Copying one symbol's function definition to another---in other words, |
| 982 | making an alternate name for a function.) | 989 | making an alternate name for a function. (If you think of this as the |
| 990 | definition of the new name, you should use @code{defalias} instead of | ||
| 991 | @code{fset}; see @ref{Defining Functions}.) | ||
| 983 | 992 | ||
| 984 | @item | 993 | @item |
| 985 | Giving a symbol a function definition that is not a list and therefore | 994 | Giving a symbol a function definition that is not a list and therefore |
| 986 | cannot be made with @code{defun}. For example, you can use @code{fset} | 995 | cannot be made with @code{defun}. For example, you can use @code{fset} |
| 987 | to give a symbol @code{s1} a function definition which is another symbol | 996 | to give a symbol @code{s1} a function definition which is another symbol |
| 988 | @code{s2}; then @code{s1} serves as an alias for whatever definition | 997 | @code{s2}; then @code{s1} serves as an alias for whatever definition |
| 989 | @code{s2} presently has. | 998 | @code{s2} presently has. (Once again use @code{defalias} instead of |
| 999 | @code{fset} if you think of this as the definition of @code{s1}.) | ||
| 990 | 1000 | ||
| 991 | @item | 1001 | @item |
| 992 | In constructs for defining or altering functions. If @code{defun} | 1002 | In constructs for defining or altering functions. If @code{defun} |
| @@ -994,21 +1004,17 @@ were not a primitive, it could be written in Lisp (as a macro) using | |||
| 994 | @code{fset}. | 1004 | @code{fset}. |
| 995 | @end itemize | 1005 | @end itemize |
| 996 | 1006 | ||
| 997 | Here are examples of the first two uses: | 1007 | Here are examples of these uses: |
| 998 | 1008 | ||
| 999 | @example | 1009 | @example |
| 1000 | @group | 1010 | @group |
| 1001 | ;; @r{Give @code{first} the same definition @code{car} has.} | 1011 | ;; @r{Save @code{foo}'s definition in @code{old-foo}.} |
| 1002 | (fset 'first (symbol-function 'car)) | 1012 | (fset 'old-foo (symbol-function 'foo)) |
| 1003 | @result{} #<subr car> | ||
| 1004 | @end group | ||
| 1005 | @group | ||
| 1006 | (first '(1 2 3)) | ||
| 1007 | @result{} 1 | ||
| 1008 | @end group | 1013 | @end group |
| 1009 | 1014 | ||
| 1010 | @group | 1015 | @group |
| 1011 | ;; @r{Make the symbol @code{car} the function definition of @code{xfirst}.} | 1016 | ;; @r{Make the symbol @code{car} the function definition of @code{xfirst}.} |
| 1017 | ;; @r{(Most likely, @code{defalias} would be better than @code{fset} here.)} | ||
| 1012 | (fset 'xfirst 'car) | 1018 | (fset 'xfirst 'car) |
| 1013 | @result{} car | 1019 | @result{} car |
| 1014 | @end group | 1020 | @end group |
| @@ -1030,10 +1036,14 @@ Here are examples of the first two uses: | |||
| 1030 | (fset 'kill-two-lines "\^u2\^k") | 1036 | (fset 'kill-two-lines "\^u2\^k") |
| 1031 | @result{} "\^u2\^k" | 1037 | @result{} "\^u2\^k" |
| 1032 | @end group | 1038 | @end group |
| 1033 | @end example | ||
| 1034 | 1039 | ||
| 1035 | See also the related function @code{defalias}, in @ref{Defining | 1040 | @group |
| 1036 | Functions}. | 1041 | ;; @r{Here is a function that alters other functions.} |
| 1042 | (defun copy-function-definition (new old) | ||
| 1043 | "Define NEW with the same function definition as OLD." | ||
| 1044 | (fset new (symbol-function old))) | ||
| 1045 | @end group | ||
| 1046 | @end example | ||
| 1037 | @end defun | 1047 | @end defun |
| 1038 | 1048 | ||
| 1039 | When writing a function that extends a previously defined function, | 1049 | When writing a function that extends a previously defined function, |
| @@ -1058,7 +1068,8 @@ proper results. The only way to avoid this problem is to make sure the | |||
| 1058 | file is loaded before moving aside the old definition of @code{foo}. | 1068 | file is loaded before moving aside the old definition of @code{foo}. |
| 1059 | 1069 | ||
| 1060 | But it is unmodular and unclean, in any case, for a Lisp file to | 1070 | But it is unmodular and unclean, in any case, for a Lisp file to |
| 1061 | redefine a function defined elsewhere. | 1071 | redefine a function defined elsewhere. It is cleaner to use the advice |
| 1072 | facility (@pxref{Advising Functions}). | ||
| 1062 | 1073 | ||
| 1063 | @node Inline Functions | 1074 | @node Inline Functions |
| 1064 | @section Inline Functions | 1075 | @section Inline Functions |
| @@ -1083,15 +1094,14 @@ advantage of inline functions is greatest for small functions, you | |||
| 1083 | generally should not make large functions inline. | 1094 | generally should not make large functions inline. |
| 1084 | 1095 | ||
| 1085 | It's possible to define a macro to expand into the same code that an | 1096 | It's possible to define a macro to expand into the same code that an |
| 1086 | inline function would execute. But the macro would have a limitation: | 1097 | inline function would execute. (@xref{Macros}.) But the macro would be |
| 1087 | you can use it only explicitly---a macro cannot be called with | 1098 | limited to direct use in expressions---a macro cannot be called with |
| 1088 | @code{apply}, @code{mapcar} and so on. Also, it takes some work to | 1099 | @code{apply}, @code{mapcar} and so on. Also, it takes some work to |
| 1089 | convert an ordinary function into a macro. (@xref{Macros}.) To convert | 1100 | convert an ordinary function into a macro. To convert it into an inline |
| 1090 | it into an inline function is very easy; simply replace @code{defun} | 1101 | function is very easy; simply replace @code{defun} with @code{defsubst}. |
| 1091 | with @code{defsubst}. Since each argument of an inline function is | 1102 | Since each argument of an inline function is evaluated exactly once, you |
| 1092 | evaluated exactly once, you needn't worry about how many times the | 1103 | needn't worry about how many times the body uses the arguments, as you |
| 1093 | body uses the arguments, as you do for macros. (@xref{Argument | 1104 | do for macros. (@xref{Argument Evaluation}.) |
| 1094 | Evaluation}.) | ||
| 1095 | 1105 | ||
| 1096 | Inline functions can be used and open-coded later on in the same file, | 1106 | Inline functions can be used and open-coded later on in the same file, |
| 1097 | following the definition, just like macros. | 1107 | following the definition, just like macros. |
| @@ -1127,6 +1137,9 @@ See @ref{Eval}. | |||
| 1127 | @item funcall | 1137 | @item funcall |
| 1128 | See @ref{Calling Functions}. | 1138 | See @ref{Calling Functions}. |
| 1129 | 1139 | ||
| 1140 | @item function | ||
| 1141 | See @ref{Anonymous Functions}. | ||
| 1142 | |||
| 1130 | @item ignore | 1143 | @item ignore |
| 1131 | See @ref{Calling Functions}. | 1144 | See @ref{Calling Functions}. |
| 1132 | 1145 | ||
| @@ -1145,6 +1158,9 @@ See @ref{Creating Symbols}. | |||
| 1145 | @item mapcar | 1158 | @item mapcar |
| 1146 | See @ref{Mapping Functions}. | 1159 | See @ref{Mapping Functions}. |
| 1147 | 1160 | ||
| 1161 | @item map-char-table | ||
| 1162 | See @ref{Char-Tables}. | ||
| 1163 | |||
| 1148 | @item mapconcat | 1164 | @item mapconcat |
| 1149 | See @ref{Mapping Functions}. | 1165 | See @ref{Mapping Functions}. |
| 1150 | 1166 | ||
diff --git a/lispref/help.texi b/lispref/help.texi index 1e94b7406a5..d31315c0ef1 100644 --- a/lispref/help.texi +++ b/lispref/help.texi | |||
| @@ -50,11 +50,11 @@ documentation string follows the initial value of the variable. | |||
| 50 | sentence (or two complete sentences) since some commands, such as | 50 | sentence (or two complete sentences) since some commands, such as |
| 51 | @code{apropos}, show only the first line of a multi-line documentation | 51 | @code{apropos}, show only the first line of a multi-line documentation |
| 52 | string. Also, you should not indent the second line of a documentation | 52 | string. Also, you should not indent the second line of a documentation |
| 53 | string, if you have one, because that looks odd when you use @kbd{C-h f} | 53 | string, if it has one, because that looks odd when you use @kbd{C-h f} |
| 54 | (@code{describe-function}) or @kbd{C-h v} (@code{describe-variable}). | 54 | (@code{describe-function}) or @kbd{C-h v} (@code{describe-variable}) to |
| 55 | @xref{Documentation Tips}. | 55 | view the documentation string. @xref{Documentation Tips}. |
| 56 | 56 | ||
| 57 | Documentation strings may contain several special substrings, which | 57 | Documentation strings can contain several special substrings, which |
| 58 | stand for key bindings to be looked up in the current keymaps when the | 58 | stand for key bindings to be looked up in the current keymaps when the |
| 59 | documentation is displayed. This allows documentation strings to refer | 59 | documentation is displayed. This allows documentation strings to refer |
| 60 | to the keys for related commands and be accurate even when a user | 60 | to the keys for related commands and be accurate even when a user |
| @@ -132,7 +132,7 @@ non-@code{nil}) it calls @code{substitute-command-keys}, to return a | |||
| 132 | value containing the actual (current) key bindings. | 132 | value containing the actual (current) key bindings. |
| 133 | 133 | ||
| 134 | The function @code{documentation} signals a @code{void-function} error | 134 | The function @code{documentation} signals a @code{void-function} error |
| 135 | if @var{function} has no function definition. However, it is ok if | 135 | if @var{function} has no function definition. However, it is OK if |
| 136 | the function definition has no documentation string. In that case, | 136 | the function definition has no documentation string. In that case, |
| 137 | @code{documentation} returns @code{nil}. | 137 | @code{documentation} returns @code{nil}. |
| 138 | @end defun | 138 | @end defun |
| @@ -255,7 +255,7 @@ for in the directory @code{doc-directory}. Usually @var{filename} is | |||
| 255 | 255 | ||
| 256 | @c Emacs 19 feature | 256 | @c Emacs 19 feature |
| 257 | @defvar doc-directory | 257 | @defvar doc-directory |
| 258 | This variable holds the name of the directory which should contion the | 258 | This variable holds the name of the directory which should contain the |
| 259 | file @code{"DOC-@var{version}"} that contains documentation strings for | 259 | file @code{"DOC-@var{version}"} that contains documentation strings for |
| 260 | built-in and preloaded functions and variables. | 260 | built-in and preloaded functions and variables. |
| 261 | 261 | ||
| @@ -288,12 +288,12 @@ stands for a key sequence that will invoke @var{command}, or @samp{M-x | |||
| 288 | @var{command}} if @var{command} has no key bindings. | 288 | @var{command}} if @var{command} has no key bindings. |
| 289 | 289 | ||
| 290 | @item \@{@var{mapvar}@} | 290 | @item \@{@var{mapvar}@} |
| 291 | stands for a summary of the value of @var{mapvar}. The value should be | 291 | stands for a summary of the keymap which is the value of the variable |
| 292 | a keymap. The summary is made by @code{describe-bindings}. | 292 | @var{mapvar}. The summary is made using @code{describe-bindings}. |
| 293 | 293 | ||
| 294 | @item \<@var{mapvar}> | 294 | @item \<@var{mapvar}> |
| 295 | stands for no text itself. It is used only for a side effect: it | 295 | stands for no text itself. It is used only for a side effect: it |
| 296 | specifies @var{mapvar} as the keymap for any following | 296 | specifies @var{mapvar}'s value as the keymap for any following |
| 297 | @samp{\[@var{command}]} sequences in this documentation string. | 297 | @samp{\[@var{command}]} sequences in this documentation string. |
| 298 | 298 | ||
| 299 | @item \= | 299 | @item \= |
| @@ -331,7 +331,7 @@ user's own customized key bindings. | |||
| 331 | ? minibuffer-completion-help | 331 | ? minibuffer-completion-help |
| 332 | SPC minibuffer-complete-word | 332 | SPC minibuffer-complete-word |
| 333 | TAB minibuffer-complete | 333 | TAB minibuffer-complete |
| 334 | LFD minibuffer-complete-and-exit | 334 | C-j minibuffer-complete-and-exit |
| 335 | RET minibuffer-complete-and-exit | 335 | RET minibuffer-complete-and-exit |
| 336 | C-g abort-recursive-edit | 336 | C-g abort-recursive-edit |
| 337 | " | 337 | " |
| @@ -372,7 +372,7 @@ This function returns a string describing @var{event} in the standard | |||
| 372 | Emacs notation for keyboard input. A normal printing character appears | 372 | Emacs notation for keyboard input. A normal printing character appears |
| 373 | as itself, but a control character turns into a string starting with | 373 | as itself, but a control character turns into a string starting with |
| 374 | @samp{C-}, a meta character turns into a string starting with @samp{M-}, | 374 | @samp{C-}, a meta character turns into a string starting with @samp{M-}, |
| 375 | and space, linefeed, etc.@: appear as @samp{SPC}, @samp{LFD}, etc. A | 375 | and space, tab, etc.@: appear as @samp{SPC}, @samp{TAB}, etc. A |
| 376 | function key symbol appears as itself. An event that is a list appears | 376 | function key symbol appears as itself. An event that is a list appears |
| 377 | as the name of the symbol in the @sc{car} of the list. | 377 | as the name of the symbol in the @sc{car} of the list. |
| 378 | 378 | ||
| @@ -383,7 +383,7 @@ as the name of the symbol in the @sc{car} of the list. | |||
| 383 | @end group | 383 | @end group |
| 384 | @group | 384 | @group |
| 385 | (key-description "\C-x \M-y \n \t \r \f123") | 385 | (key-description "\C-x \M-y \n \t \r \f123") |
| 386 | @result{} "C-x SPC M-y SPC LFD SPC TAB SPC RET SPC C-l 1 2 3" | 386 | @result{} "C-x SPC M-y SPC C-j SPC TAB SPC RET SPC C-l 1 2 3" |
| 387 | @end group | 387 | @end group |
| 388 | @group | 388 | @group |
| 389 | (single-key-description 'C-mouse-1) | 389 | (single-key-description 'C-mouse-1) |
| @@ -423,7 +423,7 @@ the user as subcommands of the prefix @kbd{C-h}. For more information | |||
| 423 | about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here | 423 | about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here |
| 424 | we describe some program-level interfaces to the same information. | 424 | we describe some program-level interfaces to the same information. |
| 425 | 425 | ||
| 426 | @deffn Command apropos regexp &optional do-all predicate | 426 | @deffn Command apropos regexp &optional do-all |
| 427 | This function finds all symbols whose names contain a match for the | 427 | This function finds all symbols whose names contain a match for the |
| 428 | regular expression @var{regexp}, and returns a list of them | 428 | regular expression @var{regexp}, and returns a list of them |
| 429 | (@pxref{Regular Expressions}). It also displays the symbols in a buffer | 429 | (@pxref{Regular Expressions}). It also displays the symbols in a buffer |
| @@ -434,15 +434,9 @@ beginning of its documentation string. | |||
| 434 | If @var{do-all} is non-@code{nil}, then @code{apropos} also shows | 434 | If @var{do-all} is non-@code{nil}, then @code{apropos} also shows |
| 435 | key bindings for the functions that are found. | 435 | key bindings for the functions that are found. |
| 436 | 436 | ||
| 437 | If @var{predicate} is non-@code{nil}, it should be a function to be | ||
| 438 | called on each symbol that has matched @var{regexp}. Only symbols for | ||
| 439 | which @var{predicate} returns a non-@code{nil} value are listed or | ||
| 440 | displayed. | ||
| 441 | |||
| 442 | In the first of the following examples, @code{apropos} finds all the | 437 | In the first of the following examples, @code{apropos} finds all the |
| 443 | symbols with names containing @samp{exec}. In the second example, it | 438 | symbols with names containing @samp{exec}. (We don't show here the |
| 444 | finds and returns only those symbols that are also commands. (We don't | 439 | output that results in the @samp{*Help*} buffer.) |
| 445 | show here the output that results in the @samp{*Help*} buffer.) | ||
| 446 | 440 | ||
| 447 | @smallexample | 441 | @smallexample |
| 448 | @group | 442 | @group |
| @@ -451,42 +445,7 @@ show here the output that results in the @samp{*Help*} buffer.) | |||
| 451 | exec-path execute-extended-command execute-kbd-macro | 445 | exec-path execute-extended-command execute-kbd-macro |
| 452 | executing-kbd-macro executing-macro) | 446 | executing-kbd-macro executing-macro) |
| 453 | @end group | 447 | @end group |
| 454 | |||
| 455 | @group | ||
| 456 | (apropos "exec" nil 'commandp) | ||
| 457 | @result{} (Buffer-menu-execute execute-extended-command) | ||
| 458 | @end group | ||
| 459 | @ignore | ||
| 460 | @group | ||
| 461 | ---------- Buffer: *Help* ---------- | ||
| 462 | Buffer-menu-execute | ||
| 463 | Function: Save and/or delete buffers marked with | ||
| 464 | M-x Buffer-menu-save or M-x Buffer-menu-delete commands. | ||
| 465 | execute-extended-command ESC x | ||
| 466 | Function: Read function name, then read its | ||
| 467 | arguments and call it. | ||
| 468 | ---------- Buffer: *Help* ---------- | ||
| 469 | @end group | ||
| 470 | @end ignore | ||
| 471 | @end smallexample | 448 | @end smallexample |
| 472 | |||
| 473 | The command @kbd{C-h a} (@code{command-apropos}) calls @code{apropos}, | ||
| 474 | but specifies a @var{predicate} that restricts the output to symbols | ||
| 475 | that are commands. The call to @code{apropos} looks like this: | ||
| 476 | |||
| 477 | @smallexample | ||
| 478 | (apropos string t 'commandp) | ||
| 479 | @end smallexample | ||
| 480 | @end deffn | ||
| 481 | |||
| 482 | @c Emacs 19 feature | ||
| 483 | @deffn Command super-apropos regexp &optional do-all | ||
| 484 | This function differs from @code{apropos} in that it searches | ||
| 485 | documentation strings as well as symbol names for matches for | ||
| 486 | @var{regexp}. By default, it searches the documentation strings for | ||
| 487 | preloaded functions and variables only. If @var{do-all} is | ||
| 488 | non-@code{nil}, it scans the names and documentation strings of all | ||
| 489 | functions and variables. | ||
| 490 | @end deffn | 449 | @end deffn |
| 491 | 450 | ||
| 492 | @defvar help-map | 451 | @defvar help-map |
| @@ -522,7 +481,7 @@ Documentation}. | |||
| 522 | 481 | ||
| 523 | @defvar help-char | 482 | @defvar help-char |
| 524 | The value of this variable is the help character---the character that | 483 | The value of this variable is the help character---the character that |
| 525 | Emacs recognizes as meaning Help. By default, it is 8, which is | 484 | Emacs recognizes as meaning Help. By default, it stands for 8, which is |
| 526 | @kbd{C-h}. When Emacs reads this character, if @code{help-form} is | 485 | @kbd{C-h}. When Emacs reads this character, if @code{help-form} is |
| 527 | non-@code{nil} Lisp expression, it evaluates that expression, and | 486 | non-@code{nil} Lisp expression, it evaluates that expression, and |
| 528 | displays the result in a window if it is a string. | 487 | displays the result in a window if it is a string. |
| @@ -539,6 +498,13 @@ binding as a subcommand of the prefix key, it runs | |||
| 539 | subcommands of the prefix key. | 498 | subcommands of the prefix key. |
| 540 | @end defvar | 499 | @end defvar |
| 541 | 500 | ||
| 501 | @tindex help-event-list | ||
| 502 | @defvar help-event-list | ||
| 503 | The value of this variable is a list of event types that serve as | ||
| 504 | alternative ``help characters.'' These events are handled just like the | ||
| 505 | event specified by @code{help-char}. | ||
| 506 | @end defvar | ||
| 507 | |||
| 542 | @defvar help-form | 508 | @defvar help-form |
| 543 | If this variable is non-@code{nil}, its value is a form to evaluate | 509 | If this variable is non-@code{nil}, its value is a form to evaluate |
| 544 | whenever the character @code{help-char} is read. If evaluating the form | 510 | whenever the character @code{help-char} is read. If evaluating the form |
| @@ -546,19 +512,19 @@ produces a string, that string is displayed. | |||
| 546 | 512 | ||
| 547 | A command that calls @code{read-event} or @code{read-char} probably | 513 | A command that calls @code{read-event} or @code{read-char} probably |
| 548 | should bind @code{help-form} to a non-@code{nil} expression while it | 514 | should bind @code{help-form} to a non-@code{nil} expression while it |
| 549 | does input. (The exception is when @kbd{C-h} is meaningful input.) | 515 | does input. (The time when you should not do this is when @kbd{C-h} has |
| 550 | Evaluating this expression should result in a string that explains what | 516 | some other meaning.) Evaluating this expression should result in a |
| 551 | the input is for and how to enter it properly. | 517 | string that explains what the input is for and how to enter it properly. |
| 552 | 518 | ||
| 553 | Entry to the minibuffer binds this variable to the value of | 519 | Entry to the minibuffer binds this variable to the value of |
| 554 | @code{minibuffer-help-form} (@pxref{Minibuffer Misc}). | 520 | @code{minibuffer-help-form} (@pxref{Minibuffer Misc}). |
| 555 | @end defvar | 521 | @end defvar |
| 556 | 522 | ||
| 557 | @defvar prefix-help-command | 523 | @defvar prefix-help-command |
| 558 | This variable holds a function to print help for a prefix character. | 524 | This variable holds a function to print help for a prefix key. The |
| 559 | The function is called when the user types a prefix key followed by the | 525 | function is called when the user types a prefix key followed by the help |
| 560 | help character, and the help character has no binding after that prefix. | 526 | character, and the help character has no binding after that prefix. The |
| 561 | The variable's default value is @code{describe-prefix-bindings}. | 527 | variable's default value is @code{describe-prefix-bindings}. |
| 562 | @end defvar | 528 | @end defvar |
| 563 | 529 | ||
| 564 | @defun describe-prefix-bindings | 530 | @defun describe-prefix-bindings |
diff --git a/lispref/internals.texi b/lispref/internals.texi index 77bafab47fa..74d019d2039 100644 --- a/lispref/internals.texi +++ b/lispref/internals.texi | |||
| @@ -12,14 +12,15 @@ the preloaded Lisp libraries in it, how storage is allocated, and some | |||
| 12 | internal aspects of GNU Emacs that may be of interest to C programmers. | 12 | internal aspects of GNU Emacs that may be of interest to C programmers. |
| 13 | 13 | ||
| 14 | @menu | 14 | @menu |
| 15 | * Building Emacs:: How to preload Lisp libraries into Emacs. | 15 | * Building Emacs:: How to the dumped Emacs is made. |
| 16 | * Pure Storage:: A kludge to make preloaded Lisp functions sharable. | 16 | * Pure Storage:: A kludge to make preloaded Lisp functions sharable. |
| 17 | * Garbage Collection:: Reclaiming space for Lisp objects no longer used. | 17 | * Garbage Collection:: Reclaiming space for Lisp objects no longer used. |
| 18 | * Memory Usage:: Info about total size of Lisp objects made so far. | ||
| 18 | * Writing Emacs Primitives:: Writing C code for Emacs. | 19 | * Writing Emacs Primitives:: Writing C code for Emacs. |
| 19 | * Object Internals:: Data formats of buffers, windows, processes. | 20 | * Object Internals:: Data formats of buffers, windows, processes. |
| 20 | @end menu | 21 | @end menu |
| 21 | 22 | ||
| 22 | @node Building Emacs, Pure Storage, GNU Emacs Internals, GNU Emacs Internals | 23 | @node Building Emacs |
| 23 | @appendixsec Building Emacs | 24 | @appendixsec Building Emacs |
| 24 | @cindex building Emacs | 25 | @cindex building Emacs |
| 25 | @pindex temacs | 26 | @pindex temacs |
| @@ -118,54 +119,7 @@ If you want to use this function in an Emacs that was already dumped, | |||
| 118 | you must run Emacs with @samp{-batch}. | 119 | you must run Emacs with @samp{-batch}. |
| 119 | @end defun | 120 | @end defun |
| 120 | 121 | ||
| 121 | @deffn Command emacs-version | 122 | @node Pure Storage |
| 122 | This function returns a string describing the version of Emacs that is | ||
| 123 | running. It is useful to include this string in bug reports. | ||
| 124 | |||
| 125 | @example | ||
| 126 | @group | ||
| 127 | (emacs-version) | ||
| 128 | @result{} "GNU Emacs 20.2.5 (i486-pc-linux-gnulibc1, X toolkit) | ||
| 129 | of Sat Feb 14 1998 on psilocin.gnu.org" | ||
| 130 | @end group | ||
| 131 | @end example | ||
| 132 | |||
| 133 | Called interactively, the function prints the same information in the | ||
| 134 | echo area. | ||
| 135 | @end deffn | ||
| 136 | |||
| 137 | @defvar emacs-build-time | ||
| 138 | The value of this variable is the time at which Emacs was built at the | ||
| 139 | local site. | ||
| 140 | |||
| 141 | @example | ||
| 142 | @group | ||
| 143 | emacs-build-time | ||
| 144 | @result{} "Tue Jun 6 14:55:57 1995" | ||
| 145 | @end group | ||
| 146 | @end example | ||
| 147 | @end defvar | ||
| 148 | |||
| 149 | @defvar emacs-version | ||
| 150 | The value of this variable is the version of Emacs being run. It is a | ||
| 151 | string such as @code{"20.3.1"}. The last number in this string is not | ||
| 152 | really part of the Emacs release version number; it is incremented each | ||
| 153 | time you build Emacs in any given directory. | ||
| 154 | @end defvar | ||
| 155 | |||
| 156 | The following two variables have existed since Emacs version 19.23, | ||
| 157 | |||
| 158 | @defvar emacs-major-version | ||
| 159 | The major version number of Emacs, as an integer. For Emacs version | ||
| 160 | 20.2, the value is 20. | ||
| 161 | @end defvar | ||
| 162 | |||
| 163 | @defvar emacs-minor-version | ||
| 164 | The minor version number of Emacs, as an integer. For Emacs version | ||
| 165 | 20.2, the value is 2. | ||
| 166 | @end defvar | ||
| 167 | |||
| 168 | @node Pure Storage, Garbage Collection, Building Emacs, GNU Emacs Internals | ||
| 169 | @appendixsec Pure Storage | 123 | @appendixsec Pure Storage |
| 170 | @cindex pure storage | 124 | @cindex pure storage |
| 171 | 125 | ||
| @@ -221,7 +175,7 @@ before and after dumping. | |||
| 221 | You should not change this flag in a running Emacs. | 175 | You should not change this flag in a running Emacs. |
| 222 | @end defvar | 176 | @end defvar |
| 223 | 177 | ||
| 224 | @node Garbage Collection, Writing Emacs Primitives, Pure Storage, GNU Emacs Internals | 178 | @node Garbage Collection |
| 225 | @appendixsec Garbage Collection | 179 | @appendixsec Garbage Collection |
| 226 | @cindex garbage collector | 180 | @cindex garbage collector |
| 227 | 181 | ||
| @@ -291,11 +245,16 @@ information: | |||
| 291 | ((@var{used-conses} . @var{free-conses}) | 245 | ((@var{used-conses} . @var{free-conses}) |
| 292 | (@var{used-syms} . @var{free-syms}) | 246 | (@var{used-syms} . @var{free-syms}) |
| 293 | @end group | 247 | @end group |
| 294 | (@var{used-markers} . @var{free-markers}) | 248 | (@var{used-miscs} . @var{free-miscs}) |
| 295 | @var{used-string-chars} | 249 | @var{used-string-chars} |
| 296 | @var{used-vector-slots} | 250 | @var{used-vector-slots} |
| 297 | (@var{used-floats} . @var{free-floats}) | 251 | (@var{used-floats} . @var{free-floats}) |
| 298 | (@var{used-intervals} . @var{free-intervals})) | 252 | (@var{used-intervals} . @var{free-intervals})) |
| 253 | @end example | ||
| 254 | |||
| 255 | Here is an example: | ||
| 256 | |||
| 257 | @example | ||
| 299 | @group | 258 | @group |
| 300 | (garbage-collect) | 259 | (garbage-collect) |
| 301 | @result{} ((106886 . 13184) (9769 . 0) | 260 | @result{} ((106886 . 13184) (9769 . 0) |
| @@ -321,12 +280,13 @@ The number of symbols in use. | |||
| 321 | The number of symbols for which space has been obtained from the | 280 | The number of symbols for which space has been obtained from the |
| 322 | operating system, but that are not currently being used. | 281 | operating system, but that are not currently being used. |
| 323 | 282 | ||
| 324 | @item used-markers | 283 | @item used-miscs |
| 325 | The number of markers in use. | 284 | The number of miscellaneous objects in use. These include markers and |
| 285 | overlays, plus certain objects not visible to users. | ||
| 326 | 286 | ||
| 327 | @item free-markers | 287 | @item free-miscs |
| 328 | The number of markers for which space has been obtained from the | 288 | The number of miscellaneous objects for which space has been obtained |
| 329 | operating system, but that are not currently being used. | 289 | from the operating system, but that are not currently being used. |
| 330 | 290 | ||
| 331 | @item used-string-chars | 291 | @item used-string-chars |
| 332 | The total size of all strings, in characters. | 292 | The total size of all strings, in characters. |
| @@ -373,6 +333,11 @@ until the subsequent garbage collection, at which time | |||
| 373 | @code{garbage-collect} will set the threshold back to 10,000. | 333 | @code{garbage-collect} will set the threshold back to 10,000. |
| 374 | @end defopt | 334 | @end defopt |
| 375 | 335 | ||
| 336 | The value return by @code{garbage-collect} describes the amount of | ||
| 337 | memory used by Lisp data, broken down by data type. By contrast, the | ||
| 338 | function @code{memory-limit} provides information on the total amount of | ||
| 339 | memory Emacs is currently using. | ||
| 340 | |||
| 376 | @c Emacs 19 feature | 341 | @c Emacs 19 feature |
| 377 | @defun memory-limit | 342 | @defun memory-limit |
| 378 | This function returns the address of the last byte Emacs has allocated, | 343 | This function returns the address of the last byte Emacs has allocated, |
| @@ -383,7 +348,53 @@ You can use this to get a general idea of how your actions affect the | |||
| 383 | memory usage. | 348 | memory usage. |
| 384 | @end defun | 349 | @end defun |
| 385 | 350 | ||
| 386 | @node Writing Emacs Primitives, Object Internals, Garbage Collection, GNU Emacs Internals | 351 | @node Memory Usage |
| 352 | @section Memory Usage | ||
| 353 | |||
| 354 | These functions and variables give information about the total amount | ||
| 355 | of memory allocation that Emacs has done, broken down by data type. | ||
| 356 | Note the difference between these and the values returned by | ||
| 357 | @code{(garbage-collect)}; those count objects that currently exist, but | ||
| 358 | these count the number or size of all allocations, including those for | ||
| 359 | objects that have since been freed. | ||
| 360 | |||
| 361 | @defvar cons-cells-consed | ||
| 362 | The total number of cons cells that have been allocated so far | ||
| 363 | in this Emacs session. | ||
| 364 | @end defvar | ||
| 365 | |||
| 366 | @defvar floats-consed | ||
| 367 | The total number of floats that have been allocated so far | ||
| 368 | in this Emacs session. | ||
| 369 | @end defvar | ||
| 370 | |||
| 371 | @defvar vector-cells-consed | ||
| 372 | The total number of vector cells that have been allocated so far | ||
| 373 | in this Emacs session. | ||
| 374 | @end defvar | ||
| 375 | |||
| 376 | @defvar symbols-consed | ||
| 377 | The total number of symbols that have been allocated so far | ||
| 378 | in this Emacs session. | ||
| 379 | @end defvar | ||
| 380 | |||
| 381 | @defvar string-chars-consed | ||
| 382 | The total number of string characters that have been allocated so far | ||
| 383 | in this Emacs session. | ||
| 384 | @end defvar | ||
| 385 | |||
| 386 | @defvar misc-objects-consed | ||
| 387 | The total number of miscellaneous objects that have been allocated so | ||
| 388 | far in this Emacs session. These include markers and overlays, plus | ||
| 389 | certain objects not visible to users. | ||
| 390 | @end defvar | ||
| 391 | |||
| 392 | @defvar intervals-consed | ||
| 393 | The total number of intervals that have been allocated so far | ||
| 394 | in this Emacs session. | ||
| 395 | @end defvar | ||
| 396 | |||
| 397 | @node Writing Emacs Primitives | ||
| 387 | @appendixsec Writing Emacs Primitives | 398 | @appendixsec Writing Emacs Primitives |
| 388 | @cindex primitive function internals | 399 | @cindex primitive function internals |
| 389 | 400 | ||
| @@ -576,57 +587,69 @@ visible in Lisp with a value that is always an integer. | |||
| 576 | @code{DEFVAR_BOOL} makes a C variable of type @code{int} visible in Lisp | 587 | @code{DEFVAR_BOOL} makes a C variable of type @code{int} visible in Lisp |
| 577 | with a value that is either @code{t} or @code{nil}. | 588 | with a value that is either @code{t} or @code{nil}. |
| 578 | 589 | ||
| 590 | If you define a file-scope C variable of type @code{Lisp_Object}, | ||
| 591 | you must protect it for garbage-collection by calling @code{staticpro} | ||
| 592 | in @code{syms_of_@var{filename}}, like this: | ||
| 593 | |||
| 594 | @example | ||
| 595 | staticpro (&@var{variable}); | ||
| 596 | @end example | ||
| 597 | |||
| 579 | Here is another example function, with more complicated arguments. | 598 | Here is another example function, with more complicated arguments. |
| 580 | This comes from the code for the X Window System, and it demonstrates | 599 | This comes from the code in @file{window.c}, and it demonstrates the use |
| 581 | the use of macros and functions to manipulate Lisp objects. | 600 | of macros and functions to manipulate Lisp objects. |
| 582 | 601 | ||
| 583 | @smallexample | 602 | @smallexample |
| 584 | @group | 603 | @group |
| 585 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | 604 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, |
| 586 | Scoordinates_in_window_p, 2, 2, | 605 | Scoordinates_in_window_p, 2, 2, |
| 587 | "xSpecify coordinate pair: \nXExpression which evals to window: ", | 606 | "xSpecify coordinate pair: \nXExpression which evals to window: ", |
| 588 | "Return non-nil if POSITIONS is in WINDOW.\n\ | 607 | "Return non-nil if COORDINATES is in WINDOW.\n\ |
| 589 | \(POSITIONS is a list, (SCREEN-X SCREEN-Y)\)\n\ | 608 | COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ |
| 609 | ... | ||
| 590 | @end group | 610 | @end group |
| 591 | @group | 611 | @group |
| 592 | Returned value is list of positions expressed\n\ | 612 | If they are on the border between WINDOW and its right sibling,\n\ |
| 593 | relative to window upper left corner.") | 613 | `vertical-line' is returned.") |
| 594 | (coordinate, window) | 614 | (coordinates, window) |
| 595 | register Lisp_Object coordinate, window; | 615 | register Lisp_Object coordinates, window; |
| 596 | @{ | 616 | @{ |
| 597 | register Lisp_Object xcoord, ycoord; | 617 | int x, y; |
| 598 | @end group | 618 | @end group |
| 599 | 619 | ||
| 600 | @group | 620 | @group |
| 601 | if (!CONSP (coordinate)) wrong_type_argument (Qlistp, coordinate); | 621 | CHECK_LIVE_WINDOW (window, 0); |
| 602 | CHECK_WINDOW (window, 2); | 622 | CHECK_CONS (coordinates, 1); |
| 603 | xcoord = Fcar (coordinate); | 623 | x = XINT (Fcar (coordinates)); |
| 604 | ycoord = Fcar (Fcdr (coordinate)); | 624 | y = XINT (Fcdr (coordinates)); |
| 605 | CHECK_NUMBER (xcoord, 0); | ||
| 606 | CHECK_NUMBER (ycoord, 1); | ||
| 607 | @end group | 625 | @end group |
| 626 | |||
| 608 | @group | 627 | @group |
| 609 | if ((XINT (xcoord) < XINT (XWINDOW (window)->left)) | 628 | switch (coordinates_in_window (XWINDOW (window), &x, &y)) |
| 610 | || (XINT (xcoord) >= (XINT (XWINDOW (window)->left) | 629 | @{ |
| 611 | + XINT (XWINDOW (window)->width)))) | 630 | case 0: /* NOT in window at all. */ |
| 612 | return Qnil; | 631 | return Qnil; |
| 613 | /* @r{Subtracting from XFASTINT (xcoord) is safe} | ||
| 614 | @r{as long as we know the result is not negative.} */ | ||
| 615 | XFASTINT (xcoord) -= XFASTINT (XWINDOW (window)->left); | ||
| 616 | @end group | 632 | @end group |
| 633 | |||
| 617 | @group | 634 | @group |
| 618 | if (XINT (ycoord) == (screen_height - 1)) | 635 | case 1: /* In text part of window. */ |
| 619 | return Qnil; | 636 | return Fcons (make_number (x), make_number (y)); |
| 620 | @end group | 637 | @end group |
| 638 | |||
| 621 | @group | 639 | @group |
| 622 | if ((XINT (ycoord) < XINT (XWINDOW (window)->top)) | 640 | case 2: /* In mode line of window. */ |
| 623 | || (XINT (ycoord) >= (XINT (XWINDOW (window)->top) | 641 | return Qmode_line; |
| 624 | + XINT (XWINDOW (window)->height)) - 1)) | ||
| 625 | return Qnil; | ||
| 626 | @end group | 642 | @end group |
| 643 | |||
| 627 | @group | 644 | @group |
| 628 | XFASTINT (ycoord) -= XFASTINT (XWINDOW (window)->top); | 645 | case 3: /* On right border of window. */ |
| 629 | return (Fcons (xcoord, Fcons (ycoord, Qnil))); | 646 | return Qvertical_line; |
| 647 | @end group | ||
| 648 | |||
| 649 | @group | ||
| 650 | default: | ||
| 651 | abort (); | ||
| 652 | @} | ||
| 630 | @} | 653 | @} |
| 631 | @end group | 654 | @end group |
| 632 | @end smallexample | 655 | @end smallexample |
| @@ -650,7 +673,7 @@ number of arguments. They work by calling @code{Ffuncall}. | |||
| 650 | @file{lisp.h} contains the definitions for some important macros and | 673 | @file{lisp.h} contains the definitions for some important macros and |
| 651 | functions. | 674 | functions. |
| 652 | 675 | ||
| 653 | @node Object Internals, , Writing Emacs Primitives, GNU Emacs Internals | 676 | @node Object Internals |
| 654 | @appendixsec Object Internals | 677 | @appendixsec Object Internals |
| 655 | @cindex object internals | 678 | @cindex object internals |
| 656 | 679 | ||
| @@ -678,7 +701,7 @@ explicitly using a suitable predicate (@pxref{Type Predicates}). | |||
| 678 | * Process Internals:: Components of a process structure. | 701 | * Process Internals:: Components of a process structure. |
| 679 | @end menu | 702 | @end menu |
| 680 | 703 | ||
| 681 | @node Buffer Internals, Window Internals, Object Internals, Object Internals | 704 | @node Buffer Internals |
| 682 | @appendixsubsec Buffer Internals | 705 | @appendixsubsec Buffer Internals |
| 683 | @cindex internals, of buffer | 706 | @cindex internals, of buffer |
| 684 | @cindex buffer internals | 707 | @cindex buffer internals |
| @@ -717,19 +740,19 @@ This field contains the syntax table for the buffer. @xref{Syntax Tables}. | |||
| 717 | 740 | ||
| 718 | @item downcase_table | 741 | @item downcase_table |
| 719 | This field contains the conversion table for converting text to lower case. | 742 | This field contains the conversion table for converting text to lower case. |
| 720 | @xref{Case Table}. | 743 | @xref{Case Tables}. |
| 721 | 744 | ||
| 722 | @item upcase_table | 745 | @item upcase_table |
| 723 | This field contains the conversion table for converting text to upper case. | 746 | This field contains the conversion table for converting text to upper case. |
| 724 | @xref{Case Table}. | 747 | @xref{Case Tables}. |
| 725 | 748 | ||
| 726 | @item case_canon_table | 749 | @item case_canon_table |
| 727 | This field contains the conversion table for canonicalizing text for | 750 | This field contains the conversion table for canonicalizing text for |
| 728 | case-folding search. @xref{Case Table}. | 751 | case-folding search. @xref{Case Tables}. |
| 729 | 752 | ||
| 730 | @item case_eqv_table | 753 | @item case_eqv_table |
| 731 | This field contains the equivalence table for case-folding search. | 754 | This field contains the equivalence table for case-folding search. |
| 732 | @xref{Case Table}. | 755 | @xref{Case Tables}. |
| 733 | 756 | ||
| 734 | @item display_table | 757 | @item display_table |
| 735 | This field contains the buffer's display table, or @code{nil} if it doesn't | 758 | This field contains the buffer's display table, or @code{nil} if it doesn't |
| @@ -753,10 +776,11 @@ hence it is also included on the list @code{markers}. @xref{The Mark}. | |||
| 753 | This field is non-@code{nil} if the buffer's mark is active. | 776 | This field is non-@code{nil} if the buffer's mark is active. |
| 754 | 777 | ||
| 755 | @item local_var_alist | 778 | @item local_var_alist |
| 756 | This field contains the association list describing the variables local | 779 | This field contains the association list describing the buffer-local |
| 757 | in this buffer, and their values, with the exception of local variables | 780 | variable bindings of this buffer, not including the built-in |
| 758 | that have special slots in the buffer object. (Those slots are omitted | 781 | buffer-local bindings that that have special slots in the buffer object. |
| 759 | from this table.) @xref{Buffer-Local Variables}. | 782 | (Those slots are omitted from this table.) @xref{Buffer-Local |
| 783 | Variables}. | ||
| 760 | 784 | ||
| 761 | @item base_buffer | 785 | @item base_buffer |
| 762 | This field holds the buffer's base buffer (if it is an indirect buffer), | 786 | This field holds the buffer's base buffer (if it is an indirect buffer), |
| @@ -777,9 +801,13 @@ decreasing end position. | |||
| 777 | This field holds a list of the overlays in this buffer that end after | 801 | This field holds a list of the overlays in this buffer that end after |
| 778 | the current overlay center position. They are sorted in order of | 802 | the current overlay center position. They are sorted in order of |
| 779 | increasing beginning position. | 803 | increasing beginning position. |
| 804 | |||
| 805 | @item enable_multibyte_characters | ||
| 806 | This field holds the buffer's local value of | ||
| 807 | @code{enable-multibyte-characters}---either @code{t} or @code{nil}. | ||
| 780 | @end table | 808 | @end table |
| 781 | 809 | ||
| 782 | @node Window Internals, Process Internals, Buffer Internals, Object Internals | 810 | @node Window Internals |
| 783 | @appendixsubsec Window Internals | 811 | @appendixsubsec Window Internals |
| 784 | @cindex internals, of window | 812 | @cindex internals, of window |
| 785 | @cindex window internals | 813 | @cindex window internals |
| @@ -886,7 +914,7 @@ holds the mark position that made one end of that region. Otherwise, | |||
| 886 | this field is @code{nil}. | 914 | this field is @code{nil}. |
| 887 | @end table | 915 | @end table |
| 888 | 916 | ||
| 889 | @node Process Internals, , Window Internals, Object Internals | 917 | @node Process Internals |
| 890 | @appendixsubsec Process Internals | 918 | @appendixsubsec Process Internals |
| 891 | @cindex internals, of process | 919 | @cindex internals, of process |
| 892 | @cindex process internals | 920 | @cindex process internals |
diff --git a/lispref/intro.texi b/lispref/intro.texi index c1cf54000f3..6d2d63981eb 100644 --- a/lispref/intro.texi +++ b/lispref/intro.texi | |||
| @@ -504,7 +504,9 @@ for other purposes as well, such as writing editing commands. | |||
| 504 | with its own idiosyncrasies. Many of them were inspired by Maclisp, | 504 | with its own idiosyncrasies. Many of them were inspired by Maclisp, |
| 505 | which was written in the 1960's at MIT's Project MAC. Eventually the | 505 | which was written in the 1960's at MIT's Project MAC. Eventually the |
| 506 | implementors of the descendants of Maclisp came together and developed a | 506 | implementors of the descendants of Maclisp came together and developed a |
| 507 | standard for Lisp systems, called Common Lisp. | 507 | standard for Lisp systems, called Common Lisp. In the mean time, Gerry |
| 508 | Sussman and Guy Steele at MIT developed a simplified but very powerful | ||
| 509 | dialect of Lisp, called Scheme. | ||
| 508 | 510 | ||
| 509 | GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common | 511 | GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common |
| 510 | Lisp. If you know Common Lisp, you will notice many similarities. | 512 | Lisp. If you know Common Lisp, you will notice many similarities. |
| @@ -515,6 +517,10 @@ might be very confused. We will occasionally point out how GNU Emacs | |||
| 515 | Lisp differs from Common Lisp. If you don't know Common Lisp, don't | 517 | Lisp differs from Common Lisp. If you don't know Common Lisp, don't |
| 516 | worry about it; this manual is self-contained. | 518 | worry about it; this manual is self-contained. |
| 517 | 519 | ||
| 520 | Emacs Lisp is not at all influenced by Scheme; but the GNU project has | ||
| 521 | an implementation of Scheme, called Guile. We use Guile for | ||
| 522 | extensibility in all new GNU software that calls for extensibility. | ||
| 523 | |||
| 518 | @node Conventions | 524 | @node Conventions |
| 519 | @section Conventions | 525 | @section Conventions |
| 520 | 526 | ||
| @@ -529,6 +535,7 @@ manual. You may want to skip this section and refer back to it later. | |||
| 529 | * Error Messages:: The format we use for examples of errors. | 535 | * Error Messages:: The format we use for examples of errors. |
| 530 | * Buffer Text Notation:: The format we use for buffer contents in examples. | 536 | * Buffer Text Notation:: The format we use for buffer contents in examples. |
| 531 | * Format of Descriptions:: Notation for describing functions, variables, etc. | 537 | * Format of Descriptions:: Notation for describing functions, variables, etc. |
| 538 | * Version Info:: Which Emacs version is running? | ||
| 532 | @end menu | 539 | @end menu |
| 533 | 540 | ||
| 534 | @node Some Terms | 541 | @node Some Terms |
| @@ -544,8 +551,9 @@ including those you write. | |||
| 544 | 551 | ||
| 545 | @cindex fonts | 552 | @cindex fonts |
| 546 | Examples of Lisp code appear in this font or form: @code{(list 1 2 | 553 | Examples of Lisp code appear in this font or form: @code{(list 1 2 |
| 547 | 3)}. Names that represent arguments or metasyntactic variables appear | 554 | 3)}. Names that represent metasyntactic variables, or arguments to a |
| 548 | in this font or form: @var{first-number}. | 555 | function being described, appear in this font or form: |
| 556 | @var{first-number}. | ||
| 549 | 557 | ||
| 550 | @node nil and t | 558 | @node nil and t |
| 551 | @subsection @code{nil} and @code{t} | 559 | @subsection @code{nil} and @code{t} |
| @@ -587,7 +595,8 @@ choosing, use @code{t}. The symbol @code{t} always has value @code{t}. | |||
| 587 | In Emacs Lisp, @code{nil} and @code{t} are special symbols that always | 595 | In Emacs Lisp, @code{nil} and @code{t} are special symbols that always |
| 588 | evaluate to themselves. This is so that you do not need to quote them | 596 | evaluate to themselves. This is so that you do not need to quote them |
| 589 | to use them as constants in a program. An attempt to change their | 597 | to use them as constants in a program. An attempt to change their |
| 590 | values results in a @code{setting-constant} error. @xref{Accessing | 598 | values results in a @code{setting-constant} error. The same is true of |
| 599 | any symbol whose name starts with a colon (@samp{:}). @xref{Constant | ||
| 591 | Variables}. | 600 | Variables}. |
| 592 | 601 | ||
| 593 | @node Evaluation Notation | 602 | @node Evaluation Notation |
| @@ -675,7 +684,7 @@ the buffer in question between two lines of dashes containing the buffer | |||
| 675 | name. In addition, @samp{@point{}} indicates the location of point. | 684 | name. In addition, @samp{@point{}} indicates the location of point. |
| 676 | (The symbol for point, of course, is not part of the text in the buffer; | 685 | (The symbol for point, of course, is not part of the text in the buffer; |
| 677 | it indicates the place @emph{between} two characters where point is | 686 | it indicates the place @emph{between} two characters where point is |
| 678 | located.) | 687 | currently located.) |
| 679 | 688 | ||
| 680 | @example | 689 | @example |
| 681 | ---------- Buffer: foo ---------- | 690 | ---------- Buffer: foo ---------- |
| @@ -723,18 +732,18 @@ The description follows on succeeding lines, sometimes with examples. | |||
| 723 | @cindex special form descriptions | 732 | @cindex special form descriptions |
| 724 | 733 | ||
| 725 | In a function description, the name of the function being described | 734 | In a function description, the name of the function being described |
| 726 | appears first. It is followed on the same line by a list of parameters. | 735 | appears first. It is followed on the same line by a list of argument |
| 727 | The names used for the parameters are also used in the body of the | 736 | names. These names are also used in the body of the description, to |
| 728 | description. | 737 | stand for the values of the arguments. |
| 729 | 738 | ||
| 730 | The appearance of the keyword @code{&optional} in the parameter list | 739 | The appearance of the keyword @code{&optional} in the argument list |
| 731 | indicates that the arguments for subsequent parameters may be omitted | 740 | indicates that the subsequent arguments may be omitted (omitted |
| 732 | (omitted parameters default to @code{nil}). Do not write | 741 | arguments default to @code{nil}). Do not write @code{&optional} when |
| 733 | @code{&optional} when you call the function. | 742 | you call the function. |
| 734 | 743 | ||
| 735 | The keyword @code{&rest} (which will always be followed by a single | 744 | The keyword @code{&rest} (which will always be followed by a single |
| 736 | parameter) indicates that any number of arguments can follow. The value | 745 | argument name) indicates that any number of arguments can follow. The value |
| 737 | of the single following parameter will be a list of all these arguments. | 746 | of the single following arguments name will be a list of all these arguments. |
| 738 | Do not write @code{&rest} when you call the function. | 747 | Do not write @code{&rest} when you call the function. |
| 739 | 748 | ||
| 740 | Here is a description of an imaginary function @code{foo}: | 749 | Here is a description of an imaginary function @code{foo}: |
| @@ -760,15 +769,15 @@ More generally, | |||
| 760 | @end example | 769 | @end example |
| 761 | @end defun | 770 | @end defun |
| 762 | 771 | ||
| 763 | Any parameter whose name contains the name of a type (e.g., | 772 | Any argument whose name contains the name of a type (e.g., |
| 764 | @var{integer}, @var{integer1} or @var{buffer}) is expected to be of that | 773 | @var{integer}, @var{integer1} or @var{buffer}) is expected to be of that |
| 765 | type. A plural of a type (such as @var{buffers}) often means a list of | 774 | type. A plural of a type (such as @var{buffers}) often means a list of |
| 766 | objects of that type. Parameters named @var{object} may be of any type. | 775 | objects of that type. Arguments named @var{object} may be of any type. |
| 767 | (@xref{Lisp Data Types}, for a list of Emacs object types.) | 776 | (@xref{Lisp Data Types}, for a list of Emacs object types.) Arguments |
| 768 | Parameters with other sorts of names (e.g., @var{new-file}) are | 777 | with other sorts of names (e.g., @var{new-file}) are discussed |
| 769 | discussed specifically in the description of the function. In some | 778 | specifically in the description of the function. In some sections, |
| 770 | sections, features common to parameters of several functions are | 779 | features common to the arguments of several functions are described at |
| 771 | described at the beginning. | 780 | the beginning. |
| 772 | 781 | ||
| 773 | @xref{Lambda Expressions}, for a more complete description of optional | 782 | @xref{Lambda Expressions}, for a more complete description of optional |
| 774 | and rest arguments. | 783 | and rest arguments. |
| @@ -780,7 +789,7 @@ interactively; macros process their arguments differently from functions | |||
| 780 | (the arguments are not evaluated), but are presented the same way. | 789 | (the arguments are not evaluated), but are presented the same way. |
| 781 | 790 | ||
| 782 | Special form descriptions use a more complex notation to specify | 791 | Special form descriptions use a more complex notation to specify |
| 783 | optional and repeated parameters because they can break the argument | 792 | optional and repeated arguments because they can break the argument |
| 784 | list down into separate arguments in more complicated ways. | 793 | list down into separate arguments in more complicated ways. |
| 785 | @samp{@code{@r{[}@var{optional-arg}@r{]}}} means that @var{optional-arg} is | 794 | @samp{@code{@r{[}@var{optional-arg}@r{]}}} means that @var{optional-arg} is |
| 786 | optional and @samp{@var{repeated-args}@dots{}} stands for zero or more | 795 | optional and @samp{@var{repeated-args}@dots{}} stands for zero or more |
| @@ -798,7 +807,8 @@ if @var{var} equals @var{to}. Here is an example: | |||
| 798 | @example | 807 | @example |
| 799 | (count-loop (i 0 10) | 808 | (count-loop (i 0 10) |
| 800 | (prin1 i) (princ " ") | 809 | (prin1 i) (princ " ") |
| 801 | (prin1 (aref vector i)) (terpri)) | 810 | (prin1 (aref vector i)) |
| 811 | (terpri)) | ||
| 802 | @end example | 812 | @end example |
| 803 | 813 | ||
| 804 | If @var{from} and @var{to} are omitted, then @var{var} is bound to | 814 | If @var{from} and @var{to} are omitted, then @var{var} is bound to |
| @@ -842,6 +852,59 @@ have not yet thought about executing. | |||
| 842 | User option descriptions have the same format, but `Variable' is | 852 | User option descriptions have the same format, but `Variable' is |
| 843 | replaced by `User Option'. | 853 | replaced by `User Option'. |
| 844 | 854 | ||
| 855 | @node Version Info | ||
| 856 | @section Version Information | ||
| 857 | |||
| 858 | These functions and variables provide information about which | ||
| 859 | version of Emacs is in use. | ||
| 860 | |||
| 861 | @deffn Command emacs-version | ||
| 862 | This function returns a string describing the version of Emacs that is | ||
| 863 | running. It is useful to include this string in bug reports. | ||
| 864 | |||
| 865 | @example | ||
| 866 | @group | ||
| 867 | (emacs-version) | ||
| 868 | @result{} "GNU Emacs 20.3.5 (i486-pc-linux-gnulibc1, X toolkit) | ||
| 869 | of Sat Feb 14 1998 on psilocin.gnu.org" | ||
| 870 | @end group | ||
| 871 | @end example | ||
| 872 | |||
| 873 | Called interactively, the function prints the same information in the | ||
| 874 | echo area. | ||
| 875 | @end deffn | ||
| 876 | |||
| 877 | @defvar emacs-build-time | ||
| 878 | The value of this variable is the time at which Emacs was built at the | ||
| 879 | local site. | ||
| 880 | |||
| 881 | @example | ||
| 882 | @group | ||
| 883 | emacs-build-time | ||
| 884 | @result{} "Tue Jun 6 14:55:57 1995" | ||
| 885 | @end group | ||
| 886 | @end example | ||
| 887 | @end defvar | ||
| 888 | |||
| 889 | @defvar emacs-version | ||
| 890 | The value of this variable is the version of Emacs being run. It is a | ||
| 891 | string such as @code{"20.3.1"}. The last number in this string is not | ||
| 892 | really part of the Emacs release version number; it is incremented each | ||
| 893 | time you build Emacs in any given directory. | ||
| 894 | @end defvar | ||
| 895 | |||
| 896 | The following two variables have existed since Emacs version 19.23, | ||
| 897 | |||
| 898 | @defvar emacs-major-version | ||
| 899 | The major version number of Emacs, as an integer. For Emacs version | ||
| 900 | 20.3, the value is 20. | ||
| 901 | @end defvar | ||
| 902 | |||
| 903 | @defvar emacs-minor-version | ||
| 904 | The minor version number of Emacs, as an integer. For Emacs version | ||
| 905 | 20.3, the value is 3. | ||
| 906 | @end defvar | ||
| 907 | |||
| 845 | @node Acknowledgements | 908 | @node Acknowledgements |
| 846 | @section Acknowledgements | 909 | @section Acknowledgements |
| 847 | 910 | ||
diff --git a/lispref/keymaps.texi b/lispref/keymaps.texi index 35feb302f20..7e6cc59cecc 100644 --- a/lispref/keymaps.texi +++ b/lispref/keymaps.texi | |||
| @@ -44,9 +44,8 @@ found. The whole process is called @dfn{key lookup}. | |||
| 44 | A @dfn{keymap} is a table mapping event types to definitions (which | 44 | A @dfn{keymap} is a table mapping event types to definitions (which |
| 45 | can be any Lisp objects, though only certain types are meaningful for | 45 | can be any Lisp objects, though only certain types are meaningful for |
| 46 | execution by the command loop). Given an event (or an event type) and a | 46 | execution by the command loop). Given an event (or an event type) and a |
| 47 | keymap, Emacs can get the event's definition. Events include ordinary | 47 | keymap, Emacs can get the event's definition. Events include |
| 48 | @sc{ASCII} characters, function keys, and mouse actions (@pxref{Input | 48 | characters, function keys, and mouse actions (@pxref{Input Events}). |
| 49 | Events}). | ||
| 50 | 49 | ||
| 51 | A sequence of input events that form a unit is called a | 50 | A sequence of input events that form a unit is called a |
| 52 | @dfn{key sequence}, or @dfn{key} for short. A sequence of one event | 51 | @dfn{key sequence}, or @dfn{key} for short. A sequence of one event |
| @@ -125,19 +124,20 @@ completely masks any lower-precedence keymap. | |||
| 125 | 124 | ||
| 126 | @item @var{vector} | 125 | @item @var{vector} |
| 127 | If an element of a keymap is a vector, the vector counts as bindings for | 126 | If an element of a keymap is a vector, the vector counts as bindings for |
| 128 | all the @sc{ASCII} characters; vector element @var{n} is the binding for | 127 | all the @sc{ASCII} characters, codes 0 through 127; vector element |
| 129 | the character with code @var{n}. This is a compact way to record lots | 128 | @var{n} is the binding for the character with code @var{n}. This is a |
| 130 | of bindings. A keymap with such a vector is called a @dfn{full keymap}. | 129 | compact way to record lots of bindings. A keymap with such a vector is |
| 131 | Other keymaps are called @dfn{sparse keymaps}. | 130 | called a @dfn{full keymap}. Other keymaps are called @dfn{sparse |
| 131 | keymaps}. | ||
| 132 | 132 | ||
| 133 | When a keymap contains a vector, it always defines a binding for each | 133 | When a keymap contains a vector, it always defines a binding for each |
| 134 | @sc{ASCII} character, even if the vector contains @code{nil} for that | 134 | @sc{ASCII} character, even if the vector contains @code{nil} for that |
| 135 | character. Such a binding of @code{nil} overrides any default binding | 135 | character. Such a binding of @code{nil} overrides any default key |
| 136 | in the keymap. However, default bindings are still meaningful for | 136 | binding in the keymap. However, default bindings are still meaningful |
| 137 | events that are not @sc{ASCII} characters. A binding of @code{nil} does | 137 | for events that are not @sc{ASCII} characters. A binding of @code{nil} |
| 138 | @emph{not} override lower-precedence keymaps; thus, if the local map | 138 | does @emph{not} override lower-precedence keymaps; thus, if the local |
| 139 | gives a binding of @code{nil}, Emacs uses the binding from the global | 139 | map gives a binding of @code{nil}, Emacs uses the binding from the |
| 140 | map. | 140 | global map. |
| 141 | 141 | ||
| 142 | @item @var{string} | 142 | @item @var{string} |
| 143 | @cindex keymap prompt string | 143 | @cindex keymap prompt string |
| @@ -333,7 +333,7 @@ from @code{text-mode-map}: | |||
| 333 | @cindex prefix key | 333 | @cindex prefix key |
| 334 | 334 | ||
| 335 | A @dfn{prefix key} is a key sequence whose binding is a keymap. The | 335 | A @dfn{prefix key} is a key sequence whose binding is a keymap. The |
| 336 | keyamp defines what to do with key sequences that extend the prefix key. | 336 | keymap defines what to do with key sequences that extend the prefix key. |
| 337 | For example, @kbd{C-x} is a prefix key, and it uses a keymap that is | 337 | For example, @kbd{C-x} is a prefix key, and it uses a keymap that is |
| 338 | also stored in the variable @code{ctl-x-map}. This keymap defines | 338 | also stored in the variable @code{ctl-x-map}. This keymap defines |
| 339 | bindings for key sequences starting with @kbd{C-x}. | 339 | bindings for key sequences starting with @kbd{C-x}. |
| @@ -481,29 +481,27 @@ minor mode keymaps. | |||
| 481 | 481 | ||
| 482 | All the active keymaps are used together to determine what command to | 482 | All the active keymaps are used together to determine what command to |
| 483 | execute when a key is entered. Emacs searches these maps one by one, in | 483 | execute when a key is entered. Emacs searches these maps one by one, in |
| 484 | order of decreasing precedence, until it finds a binding in one of the maps. | 484 | order of decreasing precedence, until it finds a binding in one of the |
| 485 | maps. The procedure for searching a single keymap is called @dfn{key | ||
| 486 | lookup}; see @ref{Key Lookup}. | ||
| 485 | 487 | ||
| 486 | Normally, Emacs @emph{first} searches for the key in the minor mode | 488 | Normally, Emacs first searches for the key in the minor mode |
| 487 | maps (one map at a time); if they do not supply a binding for the key, | 489 | maps (one map at a time); if they do not supply a binding for the key, |
| 488 | Emacs searches the local map; if that too has no binding, Emacs then | 490 | Emacs searches the local map; if that too has no binding, Emacs then |
| 489 | searches the global map. However, if @code{overriding-local-map} is | 491 | searches the global map. However, if @code{overriding-local-map} is |
| 490 | non-@code{nil}, Emacs searches that map first, before the global map. | 492 | non-@code{nil}, Emacs searches that map first, before the global map. |
| 491 | 493 | ||
| 492 | The procedure for searching a single keymap is called | ||
| 493 | @dfn{key lookup}; see @ref{Key Lookup}. | ||
| 494 | |||
| 495 | @cindex major mode keymap | 494 | @cindex major mode keymap |
| 496 | Since every buffer that uses the same major mode normally uses the | 495 | Since every buffer that uses the same major mode normally uses the |
| 497 | same local keymap, you can think of the keymap as local to the mode. A | 496 | same local keymap, you can think of the keymap as local to the mode. A |
| 498 | change to the local keymap of a buffer (using @code{local-set-key}, for | 497 | change to the local keymap of a buffer (using @code{local-set-key}, for |
| 499 | example) is seen also in the other buffers that share that keymap. | 498 | example) is seen also in the other buffers that share that keymap. |
| 500 | 499 | ||
| 501 | The local keymaps that are used for Lisp mode, C mode, and several | 500 | The local keymaps that are used for Lisp mode and some other major |
| 502 | other major modes exist even if they have not yet been used. These | 501 | modes exist even if they have not yet been used. These local maps are |
| 503 | local maps are the values of the variables @code{lisp-mode-map}, | 502 | the values of variables such as @code{lisp-mode-map}. For most major |
| 504 | @code{c-mode-map}, and so on. For most other modes, which are less | 503 | modes, which are less frequently used, the local keymap is constructed |
| 505 | frequently used, the local keymap is constructed only when the mode is | 504 | only when the mode is used for the first time in a session. |
| 506 | used for the first time in a session. | ||
| 507 | 505 | ||
| 508 | The minibuffer has local keymaps, too; they contain various completion | 506 | The minibuffer has local keymaps, too; they contain various completion |
| 509 | and exit commands. @xref{Intro to Minibuffers}. | 507 | and exit commands. @xref{Intro to Minibuffers}. |
| @@ -593,11 +591,8 @@ enables or disables a minor mode. @xref{Keymaps and Minor Modes}. | |||
| 593 | Note that elements of @code{minor-mode-map-alist} do not have the same | 591 | Note that elements of @code{minor-mode-map-alist} do not have the same |
| 594 | structure as elements of @code{minor-mode-alist}. The map must be the | 592 | structure as elements of @code{minor-mode-alist}. The map must be the |
| 595 | @sc{cdr} of the element; a list with the map as the @sc{cadr} will not | 593 | @sc{cdr} of the element; a list with the map as the @sc{cadr} will not |
| 596 | do. | 594 | do. The @sc{cadr} can be either a keymap (a list) or a symbol |
| 597 | 595 | whose function definition is a keymap. | |
| 598 | What's more, the keymap itself must appear in the @sc{cdr}. It does not | ||
| 599 | work to store a variable in the @sc{cdr} and make the map the value of | ||
| 600 | that variable. | ||
| 601 | 596 | ||
| 602 | When more than one minor mode keymap is active, their order of priority | 597 | When more than one minor mode keymap is active, their order of priority |
| 603 | is the order of @code{minor-mode-map-alist}. But you should design | 598 | is the order of @code{minor-mode-map-alist}. But you should design |
| @@ -614,12 +609,12 @@ Lookup}). | |||
| 614 | This variable allows major modes to override the key bindings for | 609 | This variable allows major modes to override the key bindings for |
| 615 | particular minor modes. The elements of this alist look like the | 610 | particular minor modes. The elements of this alist look like the |
| 616 | elements of @code{minor-mode-map-alist}: @code{(@var{variable} | 611 | elements of @code{minor-mode-map-alist}: @code{(@var{variable} |
| 617 | . @var{keymap})}. If a variable has an element | 612 | . @var{keymap})}. If a variable appears an element |
| 618 | @code{minor-mode-overriding-map-alist}. that map overrides the one in | 613 | @code{minor-mode-overriding-map-alist}, that element overrides any |
| 619 | @code{minor-mode-map-alist}. | 614 | element for the same variable in @code{minor-mode-map-alist}. |
| 620 | 615 | ||
| 621 | @code{minor-mode-overriding-map-alist} is automatically local in all | 616 | @code{minor-mode-overriding-map-alist} is automatically buffer-local in |
| 622 | buffers. | 617 | all buffers. |
| 623 | @end defvar | 618 | @end defvar |
| 624 | 619 | ||
| 625 | @defvar overriding-local-map | 620 | @defvar overriding-local-map |
| @@ -688,10 +683,10 @@ keymap. | |||
| 688 | 683 | ||
| 689 | Let's use the term @dfn{keymap entry} to describe the value found by | 684 | Let's use the term @dfn{keymap entry} to describe the value found by |
| 690 | looking up an event type in a keymap. (This doesn't include the item | 685 | looking up an event type in a keymap. (This doesn't include the item |
| 691 | string and other extra elements in menu key bindings because | 686 | string and other extra elements in menu key bindings, because |
| 692 | @code{lookup-key} and other key lookup functions don't include them in | 687 | @code{lookup-key} and other key lookup functions don't include them in |
| 693 | the returned value.) While any Lisp object may be stored in a keymap as | 688 | the returned value.) While any Lisp object may be stored in a keymap as |
| 694 | a keymap entry, not all make sense for key lookup. Here is a list of | 689 | a keymap entry, not all make sense for key lookup. Here is a table of |
| 695 | the meaningful kinds of keymap entries: | 690 | the meaningful kinds of keymap entries: |
| 696 | 691 | ||
| 697 | @table @asis | 692 | @table @asis |
| @@ -702,11 +697,6 @@ undefined key. When a keymap fails to mention an event type at all, and | |||
| 702 | has no default binding, that is equivalent to a binding of @code{nil} | 697 | has no default binding, that is equivalent to a binding of @code{nil} |
| 703 | for that event type. | 698 | for that event type. |
| 704 | 699 | ||
| 705 | @item @var{keymap} | ||
| 706 | @cindex keymap in keymap | ||
| 707 | The events used so far in the lookup form a prefix key. The next | ||
| 708 | event of the key sequence is looked up in @var{keymap}. | ||
| 709 | |||
| 710 | @item @var{command} | 700 | @item @var{command} |
| 711 | @cindex command in keymap | 701 | @cindex command in keymap |
| 712 | The events used so far in the lookup form a complete key, | 702 | The events used so far in the lookup form a complete key, |
| @@ -718,6 +708,11 @@ The array (either a string or a vector) is a keyboard macro. The events | |||
| 718 | used so far in the lookup form a complete key, and the array is its | 708 | used so far in the lookup form a complete key, and the array is its |
| 719 | binding. See @ref{Keyboard Macros}, for more information. | 709 | binding. See @ref{Keyboard Macros}, for more information. |
| 720 | 710 | ||
| 711 | @item @var{keymap} | ||
| 712 | @cindex keymap in keymap | ||
| 713 | The events used so far in the lookup form a prefix key. The next | ||
| 714 | event of the key sequence is looked up in @var{keymap}. | ||
| 715 | |||
| 721 | @item @var{list} | 716 | @item @var{list} |
| 722 | @cindex list in keymap | 717 | @cindex list in keymap |
| 723 | The meaning of a list depends on the types of the elements of the list. | 718 | The meaning of a list depends on the types of the elements of the list. |
| @@ -807,23 +802,9 @@ of @code{emacs-lisp-mode-map}. Note that 9 is the code for @key{TAB}, | |||
| 807 | Here are the functions and variables pertaining to key lookup. | 802 | Here are the functions and variables pertaining to key lookup. |
| 808 | 803 | ||
| 809 | @defun lookup-key keymap key &optional accept-defaults | 804 | @defun lookup-key keymap key &optional accept-defaults |
| 810 | This function returns the definition of @var{key} in @var{keymap}. If | 805 | This function returns the definition of @var{key} in @var{keymap}. All |
| 811 | the string or vector @var{key} is not a valid key sequence according to | 806 | the other functions described in this chapter that look up keys use |
| 812 | the prefix keys specified in @var{keymap}, it must be ``too long'' and | 807 | @code{lookup-key}. Here are examples: |
| 813 | have extra events at the end that do not fit into a single key sequence. | ||
| 814 | Then the value is a number, the number of events at the front of | ||
| 815 | @var{key} that compose a complete key. | ||
| 816 | |||
| 817 | @c Emacs 19 feature | ||
| 818 | If @var{accept-defaults} is non-@code{nil}, then @code{lookup-key} | ||
| 819 | considers default bindings as well as bindings for the specific events | ||
| 820 | in @var{key}. Otherwise, @code{lookup-key} reports only bindings for | ||
| 821 | the specific sequence @var{key}, ignoring default bindings except when | ||
| 822 | you explicitly ask about them. (To do this, supply @code{t} as an | ||
| 823 | element of @var{key}; see @ref{Format of Keymaps}.) | ||
| 824 | |||
| 825 | All the other functions described in this chapter that look up keys use | ||
| 826 | @code{lookup-key}. | ||
| 827 | 808 | ||
| 828 | @example | 809 | @example |
| 829 | @group | 810 | @group |
| @@ -836,7 +817,21 @@ All the other functions described in this chapter that look up keys use | |||
| 836 | @end group | 817 | @end group |
| 837 | @end example | 818 | @end example |
| 838 | 819 | ||
| 839 | If @var{key} contains a meta character, that character is implicitly | 820 | If the string or vector @var{key} is not a valid key sequence according |
| 821 | to the prefix keys specified in @var{keymap}, it must be ``too long'' | ||
| 822 | and have extra events at the end that do not fit into a single key | ||
| 823 | sequence. Then the value is a number, the number of events at the front | ||
| 824 | of @var{key} that compose a complete key. | ||
| 825 | |||
| 826 | @c Emacs 19 feature | ||
| 827 | If @var{accept-defaults} is non-@code{nil}, then @code{lookup-key} | ||
| 828 | considers default bindings as well as bindings for the specific events | ||
| 829 | in @var{key}. Otherwise, @code{lookup-key} reports only bindings for | ||
| 830 | the specific sequence @var{key}, ignoring default bindings except when | ||
| 831 | you explicitly ask about them. (To do this, supply @code{t} as an | ||
| 832 | element of @var{key}; see @ref{Format of Keymaps}.) | ||
| 833 | |||
| 834 | If @var{key} contains a meta character, that character is implicitly | ||
| 840 | replaced by a two-character sequence: the value of | 835 | replaced by a two-character sequence: the value of |
| 841 | @code{meta-prefix-char}, followed by the corresponding non-meta | 836 | @code{meta-prefix-char}, followed by the corresponding non-meta |
| 842 | character. Thus, the first example below is handled by conversion into | 837 | character. Thus, the first example below is handled by conversion into |
| @@ -932,7 +927,7 @@ lookup translates @kbd{M-b} into @kbd{@key{ESC} b}, which is normally | |||
| 932 | defined as the @code{backward-word} command. However, if you set | 927 | defined as the @code{backward-word} command. However, if you set |
| 933 | @code{meta-prefix-char} to 24, the code for @kbd{C-x}, then Emacs will | 928 | @code{meta-prefix-char} to 24, the code for @kbd{C-x}, then Emacs will |
| 934 | translate @kbd{M-b} into @kbd{C-x b}, whose standard binding is the | 929 | translate @kbd{M-b} into @kbd{C-x b}, whose standard binding is the |
| 935 | @code{switch-to-buffer} command. | 930 | @code{switch-to-buffer} command. Here is an illustration: |
| 936 | 931 | ||
| 937 | @smallexample | 932 | @smallexample |
| 938 | @group | 933 | @group |
| @@ -995,11 +990,8 @@ event types in a key sequence that is a vector: you can use a list | |||
| 995 | containing modifier names plus one base event (a character or function | 990 | containing modifier names plus one base event (a character or function |
| 996 | key name). For example, @code{(control ?a)} is equivalent to | 991 | key name). For example, @code{(control ?a)} is equivalent to |
| 997 | @code{?\C-a} and @code{(hyper control left)} is equivalent to | 992 | @code{?\C-a} and @code{(hyper control left)} is equivalent to |
| 998 | @code{C-H-left}. | 993 | @code{C-H-left}. One advantage of such lists is that the precise |
| 999 | 994 | numeric codes for the modifier bits don't appear in compiled files. | |
| 1000 | One advantage of using a list to represent the event type is that the | ||
| 1001 | precise numeric codes for the modifier bits don't appear in compiled | ||
| 1002 | files. | ||
| 1003 | 995 | ||
| 1004 | For the functions below, an error is signaled if @var{keymap} is not a | 996 | For the functions below, an error is signaled if @var{keymap} is not a |
| 1005 | keymap or if @var{key} is not a string or vector representing a key | 997 | keymap or if @var{key} is not a string or vector representing a key |
| @@ -1016,12 +1008,10 @@ The value returned by @code{define-key} is @var{binding}. | |||
| 1016 | 1008 | ||
| 1017 | @cindex invalid prefix key error | 1009 | @cindex invalid prefix key error |
| 1018 | @cindex key sequence error | 1010 | @cindex key sequence error |
| 1019 | Every prefix of @var{key} must be a prefix key (i.e., bound to a | 1011 | Every prefix of @var{key} must be a prefix key (i.e., bound to a keymap) |
| 1020 | keymap) or undefined; otherwise an error is signaled. | 1012 | or undefined; otherwise an error is signaled. If some prefix of |
| 1021 | 1013 | @var{key} is undefined, then @code{define-key} defines it as a prefix | |
| 1022 | If some prefix of @var{key} is undefined, then @code{define-key} defines | 1014 | key so that the rest of @var{key} can be defined as specified. |
| 1023 | it as a prefix key so that the rest of @var{key} may be defined as | ||
| 1024 | specified. | ||
| 1025 | 1015 | ||
| 1026 | If there was previously no binding for @var{key} in @var{keymap}, the | 1016 | If there was previously no binding for @var{key} in @var{keymap}, the |
| 1027 | new binding is added at the beginning of @var{keymap}. The order of | 1017 | new binding is added at the beginning of @var{keymap}. The order of |
| @@ -1383,7 +1373,7 @@ of a window. | |||
| 1383 | @end smallexample | 1373 | @end smallexample |
| 1384 | 1374 | ||
| 1385 | @noindent | 1375 | @noindent |
| 1386 | These are not all the keymaps you would see in an actual case. | 1376 | These are not all the keymaps you would see in actuality. |
| 1387 | @end defun | 1377 | @end defun |
| 1388 | 1378 | ||
| 1389 | @defun where-is-internal command &optional keymap firstonly noindirect | 1379 | @defun where-is-internal command &optional keymap firstonly noindirect |
| @@ -1425,9 +1415,9 @@ an indirect definition itself. | |||
| 1425 | @end defun | 1415 | @end defun |
| 1426 | 1416 | ||
| 1427 | @deffn Command describe-bindings prefix | 1417 | @deffn Command describe-bindings prefix |
| 1428 | This function creates a listing of all defined keys and their | 1418 | This function creates a listing of all current key bindings, and |
| 1429 | definitions. It writes the listing in a buffer named @samp{*Help*} and | 1419 | displays it in a buffer named @samp{*Help*}. The text is grouped by |
| 1430 | displays it in a window. | 1420 | modes---minor modes first, then the major mode, then global bindings. |
| 1431 | 1421 | ||
| 1432 | If @var{prefix} is non-@code{nil}, it should be a prefix key; then the | 1422 | If @var{prefix} is non-@code{nil}, it should be a prefix key; then the |
| 1433 | listing includes only keys that start with @var{prefix}. | 1423 | listing includes only keys that start with @var{prefix}. |
| @@ -1484,21 +1474,29 @@ moving to the top, if you care about the order. When you add an item to | |||
| 1484 | an existing menu, you can specify its position in the menu using | 1474 | an existing menu, you can specify its position in the menu using |
| 1485 | @code{define-key-after} (@pxref{Modifying Menus}). | 1475 | @code{define-key-after} (@pxref{Modifying Menus}). |
| 1486 | 1476 | ||
| 1487 | The individual bindings in the menu keymap should have item | 1477 | @menu |
| 1488 | strings; these strings become the items displayed in the menu. A | 1478 | * Simple Menu Items:: |
| 1489 | binding with an item string looks like this: | 1479 | * Extended Menu Items:: |
| 1480 | @end menu | ||
| 1481 | |||
| 1482 | @node Simple Menu Items | ||
| 1483 | @subsubsection Simple Menu Items | ||
| 1484 | |||
| 1485 | The simpler and older way to define a menu keymap binding | ||
| 1486 | looks like this: | ||
| 1490 | 1487 | ||
| 1491 | @example | 1488 | @example |
| 1492 | (@var{string} . @var{real-binding}) | 1489 | (@var{item-string} . @var{real-binding}) |
| 1493 | @end example | 1490 | @end example |
| 1494 | 1491 | ||
| 1495 | The item string for a binding should be short---one or two words. It | 1492 | The @sc{car}, @var{item-string}, is the string to be displayed in the |
| 1496 | should describe the action of the command it corresponds to. | 1493 | menu. It should be short---preferably one to three words. It should |
| 1494 | describe the action of the command it corresponds to. | ||
| 1497 | 1495 | ||
| 1498 | You can also supply a second string, called the help string, as follows: | 1496 | You can also supply a second string, called the help string, as follows: |
| 1499 | 1497 | ||
| 1500 | @example | 1498 | @example |
| 1501 | (@var{string} @var{help-string} . @var{real-binding}) | 1499 | (@var{item-string} @var{help-string} . @var{real-binding}) |
| 1502 | @end example | 1500 | @end example |
| 1503 | 1501 | ||
| 1504 | Currently Emacs does not actually use @var{help-string}; it knows only | 1502 | Currently Emacs does not actually use @var{help-string}; it knows only |
| @@ -1506,13 +1504,13 @@ how to ignore @var{help-string} in order to extract @var{real-binding}. | |||
| 1506 | In the future we may use @var{help-string} as extended documentation for | 1504 | In the future we may use @var{help-string} as extended documentation for |
| 1507 | the menu item, available on request. | 1505 | the menu item, available on request. |
| 1508 | 1506 | ||
| 1509 | As far as @code{define-key} is concerned, @var{string} and | 1507 | As far as @code{define-key} is concerned, @var{item-string} and |
| 1510 | @var{help-string} are part of the event's binding. However, | 1508 | @var{help-string} are part of the event's binding. However, |
| 1511 | @code{lookup-key} returns just @var{real-binding}, and only | 1509 | @code{lookup-key} returns just @var{real-binding}, and only |
| 1512 | @var{real-binding} is used for executing the key. | 1510 | @var{real-binding} is used for executing the key. |
| 1513 | 1511 | ||
| 1514 | If @var{real-binding} is @code{nil}, then @var{string} appears in the | 1512 | If @var{real-binding} is @code{nil}, then @var{item-string} appears in |
| 1515 | menu but cannot be selected. | 1513 | the menu but cannot be selected. |
| 1516 | 1514 | ||
| 1517 | If @var{real-binding} is a symbol and has a non-@code{nil} | 1515 | If @var{real-binding} is a symbol and has a non-@code{nil} |
| 1518 | @code{menu-enable} property, that property is an expression that | 1516 | @code{menu-enable} property, that property is an expression that |
| @@ -1520,7 +1518,7 @@ controls whether the menu item is enabled. Every time the keymap is | |||
| 1520 | used to display a menu, Emacs evaluates the expression, and it enables | 1518 | used to display a menu, Emacs evaluates the expression, and it enables |
| 1521 | the menu item only if the expression's value is non-@code{nil}. When a | 1519 | the menu item only if the expression's value is non-@code{nil}. When a |
| 1522 | menu item is disabled, it is displayed in a ``fuzzy'' fashion, and | 1520 | menu item is disabled, it is displayed in a ``fuzzy'' fashion, and |
| 1523 | cannot be selected with the mouse. | 1521 | cannot be selected. |
| 1524 | 1522 | ||
| 1525 | The menu bar does not recalculate which items are enabled every time you | 1523 | The menu bar does not recalculate which items are enabled every time you |
| 1526 | look at a menu. This is because the X toolkit requires the whole tree | 1524 | look at a menu. This is because the X toolkit requires the whole tree |
| @@ -1534,12 +1532,13 @@ binding, like this: | |||
| 1534 | 1532 | ||
| 1535 | @c This line is not too long--rms. | 1533 | @c This line is not too long--rms. |
| 1536 | @example | 1534 | @example |
| 1537 | (@var{string} @r{[}@var{help-string}@r{]} (@var{key-binding-data}) . @var{real-binding}) | 1535 | (@var{item-string} @r{[}@var{help-string}@r{]} (@var{key-binding-data}) . @var{real-binding}) |
| 1538 | @end example | 1536 | @end example |
| 1539 | 1537 | ||
| 1538 | @noindent | ||
| 1540 | Don't put these sublists in the menu item yourself; menu display | 1539 | Don't put these sublists in the menu item yourself; menu display |
| 1541 | calculates them automatically. Don't add keyboard equivalents to the | 1540 | calculates them automatically. Don't mention keyboard equivalents in |
| 1542 | item strings in a mouse menu, since that is redundant. | 1541 | the item strings themselves, since that is redundant. |
| 1543 | 1542 | ||
| 1544 | Sometimes it is useful to make menu items that use the ``same'' command | 1543 | Sometimes it is useful to make menu items that use the ``same'' command |
| 1545 | but with different enable conditions. You can do this by defining alias | 1544 | but with different enable conditions. You can do this by defining alias |
| @@ -1568,23 +1567,82 @@ itself). To request this, give the alias symbol a non-@code{nil} | |||
| 1568 | causes menu items for @code{make-read-only} and @code{make-writable} to | 1567 | causes menu items for @code{make-read-only} and @code{make-writable} to |
| 1569 | show the keyboard bindings for @code{toggle-read-only}. | 1568 | show the keyboard bindings for @code{toggle-read-only}. |
| 1570 | 1569 | ||
| 1570 | @node Extended Menu Items | ||
| 1571 | @subsubsection Extended Menu Items | ||
| 1572 | |||
| 1573 | An extended-format menu item is a more flexible and also cleaner | ||
| 1574 | alternative to the simple format. It consists of a list that starts | ||
| 1575 | with the symbol @code{menu-item}. To define a non-selectable string, | ||
| 1576 | the item looks like this: | ||
| 1577 | |||
| 1578 | @example | ||
| 1579 | (menu-item @var{item-name}) | ||
| 1580 | @end example | ||
| 1581 | |||
| 1582 | @noindent | ||
| 1583 | where a string consisting of two or more dashes specifies a separator line. | ||
| 1584 | |||
| 1585 | To define a real menu item which can be selected, the extended format | ||
| 1586 | item looks like this: | ||
| 1587 | |||
| 1588 | @example | ||
| 1589 | (menu-item @var{item-name} @var{real-binding} | ||
| 1590 | . @var{item-property-list}) | ||
| 1591 | @end example | ||
| 1592 | |||
| 1593 | @noindent | ||
| 1594 | Here, @var{item-name} is an expression which evaluates to the menu item | ||
| 1595 | string. Thus, the string need not be a constant. The third element, | ||
| 1596 | @var{real-binding}, is the command to execute. The tail of the list, | ||
| 1597 | @var{item-property-list}, has the form of a property list which contains | ||
| 1598 | other information. Here is a table of the properties that are supported: | ||
| 1599 | |||
| 1600 | @table @code | ||
| 1601 | @item :enable FORM | ||
| 1602 | The result of evaluating @var{form} determines whether the item is | ||
| 1603 | enabled (non-@code{nil} means yes). | ||
| 1604 | |||
| 1605 | @item :visible FORM | ||
| 1606 | The result of evaluating @var{form} determines whether the item should | ||
| 1607 | actually appear in the menu (non-@code{nil} means yes). If the item | ||
| 1608 | does not appear, then the menu is displayed as if this item were | ||
| 1609 | not defined at all. | ||
| 1610 | |||
| 1611 | @item :help @var{help} | ||
| 1612 | The value of this property, @var{help}, is the extra help string (not | ||
| 1613 | currently used). | ||
| 1614 | |||
| 1615 | @item :button (@var{type} . @var{selected}) | ||
| 1616 | This property provides a way to define radio buttons and toggle buttons. | ||
| 1617 | The @sc{car}, @var{type}, says which: is should be @code{:toggle} or | ||
| 1618 | @code{:radio}. The @sc{cdr}, @var{selected}, should be a form; the | ||
| 1619 | result of evaluating it says whether this button is currently selected. | ||
| 1620 | |||
| 1621 | @item :filter @var{filter-fn} | ||
| 1622 | This property provides a way to compute the menu item dynamically. | ||
| 1623 | The property value @var{filter-fn} should be a function of one argument; | ||
| 1624 | when it is called, its argument will be @var{real-binding}. The | ||
| 1625 | function should return the binding to use instead. | ||
| 1626 | @end table | ||
| 1627 | |||
| 1571 | @node Mouse Menus | 1628 | @node Mouse Menus |
| 1572 | @subsection Menus and the Mouse | 1629 | @subsection Menus and the Mouse |
| 1573 | 1630 | ||
| 1574 | The way to make a menu keymap produce a menu is to make it the | 1631 | The usual way to make a menu keymap produce a menu is to make it the |
| 1575 | definition of a prefix key. | 1632 | definition of a prefix key. (A Lisp program can explicitly pop up a |
| 1633 | menu and receive the user's choice---see @ref{Pop-Up Menus}.) | ||
| 1576 | 1634 | ||
| 1577 | If the prefix key ends with a mouse event, Emacs handles the menu keymap | 1635 | If the prefix key ends with a mouse event, Emacs handles the menu keymap |
| 1578 | by popping up a visible menu, so that the user can select a choice with | 1636 | by popping up a visible menu, so that the user can select a choice with |
| 1579 | the mouse. When the user clicks on a menu item, the event generated is | 1637 | the mouse. When the user clicks on a menu item, the event generated is |
| 1580 | whatever character or symbol has the binding that brought about that | 1638 | whatever character or symbol has the binding that brought about that |
| 1581 | menu item. (A menu item may generate a series of events if the menu has | 1639 | menu item. (A menu item may generate a series of events if the menu has |
| 1582 | multiple levels or comes from the menu bar.) | 1640 | multiple levels or comes from the menu bar.) |
| 1583 | 1641 | ||
| 1584 | It's often best to use a button-down event to trigger the menu. Then | 1642 | It's often best to use a button-down event to trigger the menu. Then |
| 1585 | the user can select a menu item by releasing the button. | 1643 | the user can select a menu item by releasing the button. |
| 1586 | 1644 | ||
| 1587 | A single keymap can appear as multiple menu panes, if you explicitly | 1645 | A single keymap can appear as multiple menu panes, if you explicitly |
| 1588 | arrange for this. The way to do this is to make a keymap for each pane, | 1646 | arrange for this. The way to do this is to make a keymap for each pane, |
| 1589 | then create a binding for each of those maps in the main keymap of the | 1647 | then create a binding for each of those maps in the main keymap of the |
| 1590 | menu. Give each of these bindings an item string that starts with | 1648 | menu. Give each of these bindings an item string that starts with |
| @@ -1594,24 +1652,19 @@ bindings with @samp{@@}-less item strings are grouped into one pane, | |||
| 1594 | which appears along with the other panes explicitly created for the | 1652 | which appears along with the other panes explicitly created for the |
| 1595 | submaps. | 1653 | submaps. |
| 1596 | 1654 | ||
| 1597 | X toolkit menus don't have panes; instead, they can have submenus. | 1655 | X toolkit menus don't have panes; instead, they can have submenus. |
| 1598 | Every nested keymap becomes a submenu, whether the item string starts | 1656 | Every nested keymap becomes a submenu, whether the item string starts |
| 1599 | with @samp{@@} or not. In a toolkit version of Emacs, the only thing | 1657 | with @samp{@@} or not. In a toolkit version of Emacs, the only thing |
| 1600 | special about @samp{@@} at the beginning of an item string is that the | 1658 | special about @samp{@@} at the beginning of an item string is that the |
| 1601 | @samp{@@} doesn't appear in the menu item. | 1659 | @samp{@@} doesn't appear in the menu item. |
| 1602 | 1660 | ||
| 1603 | You can also get multiple panes from separate keymaps. The full | 1661 | You can also produce multiple panes or submenus from separate keymaps. |
| 1604 | definition of a prefix key always comes from merging the definitions | 1662 | The full definition of a prefix key always comes from merging the |
| 1605 | supplied by the various active keymaps (minor mode, local, and | 1663 | definitions supplied by the various active keymaps (minor mode, local, |
| 1606 | global). When more than one of these keymaps is a menu, each of them | 1664 | and global). When more than one of these keymaps is a menu, each of |
| 1607 | makes a separate pane or panes. @xref{Active Keymaps}. | 1665 | them makes a separate pane or panes (when Emacs does not use an |
| 1608 | 1666 | X-toolkit) or a separate submenu (when using an X-toolkit). | |
| 1609 | In toolkit versions of Emacs, menus don't have panes, so submenus are | 1667 | @xref{Active Keymaps}. |
| 1610 | used to represent the separate keymaps. Each keymap's contribution | ||
| 1611 | becomes one submenu. | ||
| 1612 | |||
| 1613 | A Lisp program can explicitly pop up a menu and receive the user's | ||
| 1614 | choice. You can use keymaps for this also. @xref{Pop-Up Menus}. | ||
| 1615 | 1668 | ||
| 1616 | @node Keyboard Menus | 1669 | @node Keyboard Menus |
| 1617 | @subsection Menus and the Keyboard | 1670 | @subsection Menus and the Keyboard |
| @@ -1661,7 +1714,8 @@ menu bar. First we create the keymap, and give it a name: | |||
| 1661 | (defvar menu-bar-print-menu (make-sparse-keymap "Print")) | 1714 | (defvar menu-bar-print-menu (make-sparse-keymap "Print")) |
| 1662 | @end example | 1715 | @end example |
| 1663 | 1716 | ||
| 1664 | Next we define the menu items: | 1717 | @noindent |
| 1718 | Next we define the menu items: | ||
| 1665 | 1719 | ||
| 1666 | @example | 1720 | @example |
| 1667 | (define-key menu-bar-print-menu [ps-print-region] | 1721 | (define-key menu-bar-print-menu [ps-print-region] |
| @@ -1714,7 +1768,7 @@ item would be meaningless because @code{menu-bar-print-menu} is not a | |||
| 1714 | command. | 1768 | command. |
| 1715 | 1769 | ||
| 1716 | If you wanted to attach the same print menu to a mouse click, you | 1770 | If you wanted to attach the same print menu to a mouse click, you |
| 1717 | might do it this way: | 1771 | can do it this way: |
| 1718 | 1772 | ||
| 1719 | @example | 1773 | @example |
| 1720 | (define-key global-map [C-S-down-mouse-1] menu-bar-print-menu) | 1774 | (define-key global-map [C-S-down-mouse-1] menu-bar-print-menu) |
| @@ -1736,9 +1790,9 @@ so that pressing a button on the menu bar item leads to another menu. | |||
| 1736 | 1790 | ||
| 1737 | When more than one active keymap defines the same fake function key | 1791 | When more than one active keymap defines the same fake function key |
| 1738 | for the menu bar, the item appears just once. If the user clicks on | 1792 | for the menu bar, the item appears just once. If the user clicks on |
| 1739 | that menu bar item, it brings up a single, combined submenu containing | 1793 | that menu bar item, it brings up a single, combined menu containing |
| 1740 | all the subcommands of that item---the global subcommands, the local | 1794 | all the subcommands of that item---the global subcommands, the local |
| 1741 | subcommands, and the minor mode subcommands, all together. | 1795 | subcommands, and the minor mode subcommands. |
| 1742 | 1796 | ||
| 1743 | The variable @code{overriding-local-map} is normally ignored when | 1797 | The variable @code{overriding-local-map} is normally ignored when |
| 1744 | determining the menu bar contents. That is, the menu bar is computed | 1798 | determining the menu bar contents. That is, the menu bar is computed |
| @@ -1749,7 +1803,7 @@ were @code{nil}. @xref{Active Keymaps}. | |||
| 1749 | parameter must be greater than zero. Emacs uses just one line for the | 1803 | parameter must be greater than zero. Emacs uses just one line for the |
| 1750 | menu bar itself; if you specify more than one line, the other lines | 1804 | menu bar itself; if you specify more than one line, the other lines |
| 1751 | serve to separate the menu bar from the windows in the frame. We | 1805 | serve to separate the menu bar from the windows in the frame. We |
| 1752 | recommend 1 or 2 as the value of @code{menu-bar-lines}. @xref{X Frame | 1806 | recommend 1 or 2 as the value of @code{menu-bar-lines}. @xref{Window Frame |
| 1753 | Parameters}. | 1807 | Parameters}. |
| 1754 | 1808 | ||
| 1755 | Here's an example of setting up a menu bar item: | 1809 | Here's an example of setting up a menu bar item: |
| @@ -1768,7 +1822,7 @@ Parameters}. | |||
| 1768 | @end group | 1822 | @end group |
| 1769 | 1823 | ||
| 1770 | @group | 1824 | @group |
| 1771 | ;; @r{Define specific subcommands in the item's menu.} | 1825 | ;; @r{Define specific subcommands in this menu.} |
| 1772 | (define-key global-map | 1826 | (define-key global-map |
| 1773 | [menu-bar words forward] | 1827 | [menu-bar words forward] |
| 1774 | '("Forward word" . forward-word)) | 1828 | '("Forward word" . forward-word)) |
| @@ -1800,7 +1854,7 @@ local maps. | |||
| 1800 | 1854 | ||
| 1801 | This variable holds a list of fake function keys for items to display at | 1855 | This variable holds a list of fake function keys for items to display at |
| 1802 | the end of the menu bar rather than in normal sequence. The default | 1856 | the end of the menu bar rather than in normal sequence. The default |
| 1803 | value is @code{(help)}; thus, the @samp{Help} menu item normally appears | 1857 | value is @code{(help-menu)}; thus, the @samp{Help} menu item normally appears |
| 1804 | at the end of the menu bar, following local menu items. | 1858 | at the end of the menu bar, following local menu items. |
| 1805 | @end defvar | 1859 | @end defvar |
| 1806 | 1860 | ||
| @@ -1823,9 +1877,12 @@ Define a binding in @var{map} for @var{key}, with value @var{binding}, | |||
| 1823 | just like @code{define-key}, but position the binding in @var{map} after | 1877 | just like @code{define-key}, but position the binding in @var{map} after |
| 1824 | the binding for the event @var{after}. The argument @var{key} should be | 1878 | the binding for the event @var{after}. The argument @var{key} should be |
| 1825 | of length one---a vector or string with just one element. But | 1879 | of length one---a vector or string with just one element. But |
| 1826 | @var{after} should be an event type---a symbol or a character. | 1880 | @var{after} should be a single event type---a symbol or a character, not |
| 1881 | a sequence. The new binding goes after the binding for @var{after}. If | ||
| 1882 | @var{after} is @code{t}, then the new binding goes last, at the end of | ||
| 1883 | the keymap. | ||
| 1827 | 1884 | ||
| 1828 | For example, | 1885 | Here is an example: |
| 1829 | 1886 | ||
| 1830 | @example | 1887 | @example |
| 1831 | (define-key-after my-menu [drink] | 1888 | (define-key-after my-menu [drink] |
| @@ -1833,11 +1890,8 @@ For example, | |||
| 1833 | @end example | 1890 | @end example |
| 1834 | 1891 | ||
| 1835 | @noindent | 1892 | @noindent |
| 1836 | makes a binding for the fake function key @key{drink} and puts it | 1893 | makes a binding for the fake function key @key{DRINK} and puts it |
| 1837 | right after the binding for @key{eat}. | 1894 | right after the binding for @key{EAT}. |
| 1838 | |||
| 1839 | If @var{after} is @code{t}, then the new binding goes last---at the end | ||
| 1840 | of the keymap. | ||
| 1841 | 1895 | ||
| 1842 | Here is how to insert an item called @samp{Work} in the @samp{Signals} | 1896 | Here is how to insert an item called @samp{Work} in the @samp{Signals} |
| 1843 | menu of Shell mode, after the item @code{break}: | 1897 | menu of Shell mode, after the item @code{break}: |
| @@ -1847,7 +1901,4 @@ menu of Shell mode, after the item @code{break}: | |||
| 1847 | (lookup-key shell-mode-map [menu-bar signals]) | 1901 | (lookup-key shell-mode-map [menu-bar signals]) |
| 1848 | [work] '("Work" . work-command) 'break) | 1902 | [work] '("Work" . work-command) 'break) |
| 1849 | @end example | 1903 | @end example |
| 1850 | |||
| 1851 | Note that @var{key} is a sequence containing just one event type, but | ||
| 1852 | @var{after} is just an event type (not a sequence). | ||
| 1853 | @end defun | 1904 | @end defun |
diff --git a/lispref/lists.texi b/lispref/lists.texi index 6334b4bdcd9..3f269dc9093 100644 --- a/lispref/lists.texi +++ b/lispref/lists.texi | |||
| @@ -92,8 +92,9 @@ like this: | |||
| 92 | 92 | ||
| 93 | @example | 93 | @example |
| 94 | @group | 94 | @group |
| 95 | ___ ___ ___ ___ | 95 | --- --- --- --- |
| 96 | |___|___|--> |___|___|--> nil | 96 | | | |--> | | |--> nil |
| 97 | --- --- --- --- | ||
| 97 | | | | 98 | | | |
| 98 | | | | 99 | | | |
| 99 | --> tulip --> lily | 100 | --> tulip --> lily |
| @@ -106,14 +107,16 @@ two-element list: | |||
| 106 | 107 | ||
| 107 | @example | 108 | @example |
| 108 | @group | 109 | @group |
| 109 | ___ ___ ___ ___ ___ ___ | 110 | --- --- --- --- --- --- |
| 110 | |___|___|--> |___|___|--> |___|___|--> nil | 111 | | | |--> | | |--> | | |--> nil |
| 112 | --- --- --- --- --- --- | ||
| 111 | | | | | 113 | | | | |
| 112 | | | | | 114 | | | | |
| 113 | | --> oak --> maple | 115 | | --> oak --> maple |
| 114 | | | 116 | | |
| 115 | | ___ ___ ___ ___ | 117 | | --- --- --- --- |
| 116 | --> |___|___|--> |___|___|--> nil | 118 | --> | | |--> | | |--> nil |
| 119 | --- --- --- --- | ||
| 117 | | | | 120 | | | |
| 118 | | | | 121 | | | |
| 119 | --> pine --> needles | 122 | --> pine --> needles |
| @@ -323,6 +326,10 @@ If @var{n} is negative, @code{nth} returns the first element of | |||
| 323 | (nth n x) @equiv{} (car (nthcdr n x)) | 326 | (nth n x) @equiv{} (car (nthcdr n x)) |
| 324 | @end group | 327 | @end group |
| 325 | @end example | 328 | @end example |
| 329 | |||
| 330 | The function @code{elt} is similar, but applies to any kind of sequence. | ||
| 331 | For historical reasons, it takes its arguments in the opposite order. | ||
| 332 | @xref{Sequence Functions}. | ||
| 326 | @end defun | 333 | @end defun |
| 327 | 334 | ||
| 328 | @defun nthcdr n list | 335 | @defun nthcdr n list |
| @@ -351,7 +358,7 @@ If @var{n} is zero or negative, @code{nthcdr} returns all of | |||
| 351 | @end defun | 358 | @end defun |
| 352 | 359 | ||
| 353 | @tindex safe-length | 360 | @tindex safe-length |
| 354 | @defun safe-length sequence | 361 | @defun safe-length list |
| 355 | This function returns the length of @var{list}, with no risk | 362 | This function returns the length of @var{list}, with no risk |
| 356 | of either an error or an infinite loop. | 363 | of either an error or an infinite loop. |
| 357 | 364 | ||
| @@ -360,26 +367,30 @@ If @var{list} is not really a list, @code{safe-length} returns 0. If | |||
| 360 | number of distinct elements. | 367 | number of distinct elements. |
| 361 | @end defun | 368 | @end defun |
| 362 | 369 | ||
| 370 | The most common way to compute the length of a list, when you are not | ||
| 371 | worried that it may be circular, is with @code{length}. @xref{Sequence | ||
| 372 | Functions}. | ||
| 373 | |||
| 363 | @tindex caar | 374 | @tindex caar |
| 364 | @defun caar list | 375 | @defun caar cons-cell |
| 365 | This is the same as @code{(car (car @var{list}))}. | 376 | This is the same as @code{(car (car @var{cons-cell}))}. |
| 366 | @end defun | 377 | @end defun |
| 367 | 378 | ||
| 368 | @tindex cadr | 379 | @tindex cadr |
| 369 | @defun cadr list | 380 | @defun cadr cons-cell |
| 370 | This is the same as @code{(car (cdr @var{list}))} | 381 | This is the same as @code{(car (cdr @var{cons-cell}))} |
| 371 | or @code{(nth 1 @var{list})}. | 382 | or @code{(nth 1 @var{cons-cell})}. |
| 372 | @end defun | 383 | @end defun |
| 373 | 384 | ||
| 374 | @tindex cdar | 385 | @tindex cdar |
| 375 | @defun cdar list | 386 | @defun cdar cons-cell |
| 376 | This is the same as @code{(cdr (car @var{list}))}. | 387 | This is the same as @code{(cdr (car @var{cons-cell}))}. |
| 377 | @end defun | 388 | @end defun |
| 378 | 389 | ||
| 379 | @tindex cddr | 390 | @tindex cddr |
| 380 | @defun cddr list | 391 | @defun cddr cons-cell |
| 381 | This is the same as @code{(cdr (cdr @var{list}))} | 392 | This is the same as @code{(cdr (cdr @var{cons-cell}))} |
| 382 | or @code{(nthcdr 2 @var{list})}. | 393 | or @code{(nthcdr 2 @var{cons-cell})}. |
| 383 | @end defun | 394 | @end defun |
| 384 | 395 | ||
| 385 | @node Building Lists | 396 | @node Building Lists |
| @@ -470,9 +481,11 @@ elements have the identical value @var{object}. Compare | |||
| 470 | @defun append &rest sequences | 481 | @defun append &rest sequences |
| 471 | @cindex copying lists | 482 | @cindex copying lists |
| 472 | This function returns a list containing all the elements of | 483 | This function returns a list containing all the elements of |
| 473 | @var{sequences}. The @var{sequences} may be lists, vectors, or strings, | 484 | @var{sequences}. The @var{sequences} may be lists, vectors, |
| 474 | but the last one should usually be a list. All arguments except the | 485 | bool-vectors, or strings, but the last one should usually be a list. |
| 475 | last one are copied, so none of the arguments is altered. | 486 | All arguments except the last one are copied, so none of the arguments |
| 487 | is altered. (See @code{nconc} in @ref{Rearrangement}, for a way to join | ||
| 488 | lists with no copying.) | ||
| 476 | 489 | ||
| 477 | More generally, the final argument to @code{append} may be any Lisp | 490 | More generally, the final argument to @code{append} may be any Lisp |
| 478 | object. The final argument is not copied or converted; it becomes the | 491 | object. The final argument is not copied or converted; it becomes the |
| @@ -482,9 +495,6 @@ result list. If the final element is not a list, the result is a | |||
| 482 | ``dotted list'' since its final @sc{cdr} is not @code{nil} as required | 495 | ``dotted list'' since its final @sc{cdr} is not @code{nil} as required |
| 483 | in a true list. | 496 | in a true list. |
| 484 | 497 | ||
| 485 | See @code{nconc} in @ref{Rearrangement}, for a way to join lists with no | ||
| 486 | copying. | ||
| 487 | |||
| 488 | Here is an example of using @code{append}: | 498 | Here is an example of using @code{append}: |
| 489 | 499 | ||
| 490 | @example | 500 | @example |
| @@ -517,8 +527,9 @@ original list: | |||
| 517 | @group | 527 | @group |
| 518 | more-trees trees | 528 | more-trees trees |
| 519 | | | | 529 | | | |
| 520 | | ___ ___ ___ ___ -> ___ ___ ___ ___ | 530 | | --- --- --- --- -> --- --- --- --- |
| 521 | --> |___|___|--> |___|___|--> |___|___|--> |___|___|--> nil | 531 | --> | | |--> | | |--> | | |--> | | |--> nil |
| 532 | --- --- --- --- --- --- --- --- | ||
| 522 | | | | | | 533 | | | | | |
| 523 | | | | | | 534 | | | | | |
| 524 | --> maple -->birch --> pine --> oak | 535 | --> maple -->birch --> pine --> oak |
| @@ -535,7 +546,7 @@ trees | |||
| 535 | @result{} (pine oak) | 546 | @result{} (pine oak) |
| 536 | @end group | 547 | @end group |
| 537 | @group | 548 | @group |
| 538 | (setq wood (append trees ())) | 549 | (setq wood (append trees nil)) |
| 539 | @result{} (pine oak) | 550 | @result{} (pine oak) |
| 540 | @end group | 551 | @end group |
| 541 | @group | 552 | @group |
| @@ -552,6 +563,15 @@ wood | |||
| 552 | This once was the usual way to copy a list, before the function | 563 | This once was the usual way to copy a list, before the function |
| 553 | @code{copy-sequence} was invented. @xref{Sequences Arrays Vectors}. | 564 | @code{copy-sequence} was invented. @xref{Sequences Arrays Vectors}. |
| 554 | 565 | ||
| 566 | Here we show the use of vectors and strings as arguments to @code{append}: | ||
| 567 | |||
| 568 | @example | ||
| 569 | @group | ||
| 570 | (append [a b] "cd" nil) | ||
| 571 | @result{} (a b 99 100) | ||
| 572 | @end group | ||
| 573 | @end example | ||
| 574 | |||
| 555 | With the help of @code{apply}, we can append all the lists in a list of | 575 | With the help of @code{apply}, we can append all the lists in a list of |
| 556 | lists: | 576 | lists: |
| 557 | 577 | ||
| @@ -707,14 +727,16 @@ changes them both: | |||
| 707 | 727 | ||
| 708 | @example | 728 | @example |
| 709 | @group | 729 | @group |
| 710 | ___ ___ ___ ___ ___ ___ | 730 | --- --- --- --- --- --- |
| 711 | x1---> |___|___|----> |___|___|--> |___|___|--> nil | 731 | x1---> | | |----> | | |--> | | |--> nil |
| 732 | --- --- --- --- --- --- | ||
| 712 | | --> | | | 733 | | --> | | |
| 713 | | | | | | 734 | | | | | |
| 714 | --> a | --> b --> c | 735 | --> a | --> b --> c |
| 715 | | | 736 | | |
| 716 | ___ ___ | | 737 | --- --- | |
| 717 | x2--> |___|___|-- | 738 | x2--> | | |-- |
| 739 | --- --- | ||
| 718 | | | 740 | | |
| 719 | | | 741 | | |
| 720 | --> z | 742 | --> z |
| @@ -904,6 +926,8 @@ x | |||
| 904 | @end group | 926 | @end group |
| 905 | @end example | 927 | @end example |
| 906 | 928 | ||
| 929 | However, the other arguments (all but the last) must be lists. | ||
| 930 | |||
| 907 | A common pitfall is to use a quoted constant list as a non-last | 931 | A common pitfall is to use a quoted constant list as a non-last |
| 908 | argument to @code{nconc}. If you do this, your program will change | 932 | argument to @code{nconc}. If you do this, your program will change |
| 909 | each time you run it! Here is what happens: | 933 | each time you run it! Here is what happens: |
| @@ -1157,7 +1181,8 @@ and the @code{(4)} in the @code{sample-list} are not @code{eq}: | |||
| 1157 | @end example | 1181 | @end example |
| 1158 | 1182 | ||
| 1159 | The following two functions are like @code{memq} and @code{delq} but use | 1183 | The following two functions are like @code{memq} and @code{delq} but use |
| 1160 | @code{equal} rather than @code{eq} to compare elements. | 1184 | @code{equal} rather than @code{eq} to compare elements. @xref{Equality |
| 1185 | Predicates}. | ||
| 1161 | 1186 | ||
| 1162 | @defun member object list | 1187 | @defun member object list |
| 1163 | The function @code{member} tests to see whether @var{object} is a member | 1188 | The function @code{member} tests to see whether @var{object} is a member |
diff --git a/lispref/loading.texi b/lispref/loading.texi index e3a72b3e318..44eac1cbe44 100644 --- a/lispref/loading.texi +++ b/lispref/loading.texi | |||
| @@ -88,6 +88,10 @@ If you get a warning that @file{foo.elc} is older than @file{foo.el}, it | |||
| 88 | means you should consider recompiling @file{foo.el}. @xref{Byte | 88 | means you should consider recompiling @file{foo.el}. @xref{Byte |
| 89 | Compilation}. | 89 | Compilation}. |
| 90 | 90 | ||
| 91 | When loading a source file (not compiled), @code{load} performs | ||
| 92 | character set translation just as Emacs would do when visiting the file. | ||
| 93 | @xref{Coding Systems}. | ||
| 94 | |||
| 91 | Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear | 95 | Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear |
| 92 | in the echo area during loading unless @var{nomessage} is | 96 | in the echo area during loading unless @var{nomessage} is |
| 93 | non-@code{nil}. | 97 | non-@code{nil}. |
| @@ -170,13 +174,6 @@ followed then by the @file{/user/bil/emacs} directory, the | |||
| 170 | @file{/usr/local/lisplib} directory, and the @file{~/emacs} directory, | 174 | @file{/usr/local/lisplib} directory, and the @file{~/emacs} directory, |
| 171 | which are then followed by the standard directories for Lisp code. | 175 | which are then followed by the standard directories for Lisp code. |
| 172 | 176 | ||
| 173 | The command line options @samp{-l} or @samp{-load} specify a Lisp | ||
| 174 | library to load as part of Emacs startup. Since this file might be in | ||
| 175 | the current directory, Emacs 18 temporarily adds the current directory | ||
| 176 | to the front of @code{load-path} so the file can be found there. Newer | ||
| 177 | Emacs versions also find such files in the current directory, but | ||
| 178 | without altering @code{load-path}. | ||
| 179 | |||
| 180 | Dumping Emacs uses a special value of @code{load-path}. If the value of | 177 | Dumping Emacs uses a special value of @code{load-path}. If the value of |
| 181 | @code{load-path} at the end of dumping is unchanged (that is, still the | 178 | @code{load-path} at the end of dumping is unchanged (that is, still the |
| 182 | same special value), the dumped Emacs switches to the ordinary | 179 | same special value), the dumped Emacs switches to the ordinary |
| @@ -233,7 +230,7 @@ Normally, the variable's value is @code{nil}, which means those | |||
| 233 | functions should use @code{read}. | 230 | functions should use @code{read}. |
| 234 | @end defvar | 231 | @end defvar |
| 235 | 232 | ||
| 236 | To learn how @code{load} is used to build Emacs, see @ref{Building Emacs}. | 233 | For how @code{load} is used to build Emacs, see @ref{Building Emacs}. |
| 237 | 234 | ||
| 238 | @deffn Command locate-library library &optional nosuffix path interactive-call | 235 | @deffn Command locate-library library &optional nosuffix path interactive-call |
| 239 | This command finds the precise file name for library @var{library}. It | 236 | This command finds the precise file name for library @var{library}. It |
| @@ -265,11 +262,11 @@ as if it had been loaded all along. | |||
| 265 | @code{autoload}, and by writing a special ``magic'' comment in the | 262 | @code{autoload}, and by writing a special ``magic'' comment in the |
| 266 | source before the real definition. @code{autoload} is the low-level | 263 | source before the real definition. @code{autoload} is the low-level |
| 267 | primitive for autoloading; any Lisp program can call @code{autoload} at | 264 | primitive for autoloading; any Lisp program can call @code{autoload} at |
| 268 | any time. Magic comments do nothing on their own; they serve as a guide | 265 | any time. Magic comments are the most convenient way to make a function |
| 269 | for the command @code{update-file-autoloads}, which constructs calls to | 266 | autoload, for packages installed along with Emacs. They do nothing on |
| 270 | @code{autoload} and arranges to execute them when Emacs is built. Magic | 267 | their own, but they serve as a guide for the command |
| 271 | comments are the most convenient way to make a function autoload, but | 268 | @code{update-file-autoloads}, which constructs calls to @code{autoload} |
| 272 | only for packages installed along with Emacs. | 269 | and arranges to execute them when Emacs is built. |
| 273 | 270 | ||
| 274 | @defun autoload function filename &optional docstring interactive type | 271 | @defun autoload function filename &optional docstring interactive type |
| 275 | This function defines the function (or macro) named @var{function} so as | 272 | This function defines the function (or macro) named @var{function} so as |
| @@ -287,10 +284,10 @@ in the function definition itself. Specifying the documentation string | |||
| 287 | in the call to @code{autoload} makes it possible to look at the | 284 | in the call to @code{autoload} makes it possible to look at the |
| 288 | documentation without loading the function's real definition. | 285 | documentation without loading the function's real definition. |
| 289 | 286 | ||
| 290 | If @var{interactive} is non-@code{nil}, then the function can be called | 287 | If @var{interactive} is non-@code{nil}, that says @var{function} can be |
| 291 | interactively. This lets completion in @kbd{M-x} work without loading | 288 | called interactively. This lets completion in @kbd{M-x} work without |
| 292 | the function's real definition. The complete interactive specification | 289 | loading its real definition. The complete interactive specification is |
| 293 | is not given here; it's not needed unless the user actually calls | 290 | not given here; it's not needed unless the user actually calls |
| 294 | @var{function}, and when that happens, it's time to load the real | 291 | @var{function}, and when that happens, it's time to load the real |
| 295 | definition. | 292 | definition. |
| 296 | 293 | ||
| @@ -365,8 +362,9 @@ function definition, it is copied verbatim. You can also use a magic | |||
| 365 | comment to execute a form at build time @emph{without} executing it when | 362 | comment to execute a form at build time @emph{without} executing it when |
| 366 | the file itself is loaded. To do this, write the form @emph{on the same | 363 | the file itself is loaded. To do this, write the form @emph{on the same |
| 367 | line} as the magic comment. Since it is in a comment, it does nothing | 364 | line} as the magic comment. Since it is in a comment, it does nothing |
| 368 | when you load the source file; but @code{update-file-autoloads} copies | 365 | when you load the source file; but @kbd{M-x update-file-autoloads} |
| 369 | it to @file{loaddefs.el}, where it is executed while building Emacs. | 366 | copies it to @file{loaddefs.el}, where it is executed while building |
| 367 | Emacs. | ||
| 370 | 368 | ||
| 371 | The following example shows how @code{doctor} is prepared for | 369 | The following example shows how @code{doctor} is prepared for |
| 372 | autoloading with a magic comment: | 370 | autoloading with a magic comment: |
| @@ -400,7 +398,7 @@ documentation string in the @file{etc/DOC} file. @xref{Building Emacs}. | |||
| 400 | @section Repeated Loading | 398 | @section Repeated Loading |
| 401 | @cindex repeated loading | 399 | @cindex repeated loading |
| 402 | 400 | ||
| 403 | You may load one file more than once in an Emacs session. For | 401 | You can load one file more than once in an Emacs session. For |
| 404 | example, after you have rewritten and reinstalled a function definition | 402 | example, after you have rewritten and reinstalled a function definition |
| 405 | by editing it in a buffer, you may wish to return to the original | 403 | by editing it in a buffer, you may wish to return to the original |
| 406 | version; you can do this by reloading the file it came from. | 404 | version; you can do this by reloading the file it came from. |
| @@ -411,8 +409,8 @@ rather than a non-compiled file of similar name. If you rewrite a file | |||
| 411 | that you intend to save and reinstall, you need to byte-compile the new | 409 | that you intend to save and reinstall, you need to byte-compile the new |
| 412 | version; otherwise Emacs will load the older, byte-compiled file instead | 410 | version; otherwise Emacs will load the older, byte-compiled file instead |
| 413 | of your newer, non-compiled file! If that happens, the message | 411 | of your newer, non-compiled file! If that happens, the message |
| 414 | displayed when loading the file says, ``(compiled; source is newer'', to | 412 | displayed when loading the file includes, @samp{(compiled; source is |
| 415 | remind you to recompile. | 413 | newer)}, to remind you to recompile it. |
| 416 | 414 | ||
| 417 | When writing the forms in a Lisp library file, keep in mind that the | 415 | When writing the forms in a Lisp library file, keep in mind that the |
| 418 | file might be loaded more than once. For example, think about whether | 416 | file might be loaded more than once. For example, think about whether |
| @@ -445,17 +443,17 @@ already been loaded. Here's one way to test, in a library, whether it | |||
| 445 | has been loaded before: | 443 | has been loaded before: |
| 446 | 444 | ||
| 447 | @example | 445 | @example |
| 448 | (defvar foo-was-loaded) | 446 | (defvar foo-was-loaded nil) |
| 449 | 447 | ||
| 450 | (if (not (boundp 'foo-was-loaded)) | 448 | (unless foo-was-loaded |
| 451 | @var{execute-first-time-only}) | 449 | @var{execute-first-time-only} |
| 452 | 450 | (setq foo-was-loaded t)) | |
| 453 | (setq foo-was-loaded t) | ||
| 454 | @end example | 451 | @end example |
| 455 | 452 | ||
| 456 | @noindent | 453 | @noindent |
| 457 | If the library uses @code{provide} to provide a named feature, you can | 454 | If the library uses @code{provide} to provide a named feature, you can |
| 458 | use @code{featurep} to test whether the library has been loaded. | 455 | use @code{featurep} earlier in the file to test whether the |
| 456 | @code{provide} call has been executed before. | ||
| 459 | @ifinfo | 457 | @ifinfo |
| 460 | @xref{Named Features}. | 458 | @xref{Named Features}. |
| 461 | @end ifinfo | 459 | @end ifinfo |
| @@ -486,9 +484,6 @@ file should call @code{provide} at the top level to add the feature to | |||
| 486 | @code{features}; if it fails to do so, @code{require} signals an error. | 484 | @code{features}; if it fails to do so, @code{require} signals an error. |
| 487 | @cindex load error with require | 485 | @cindex load error with require |
| 488 | 486 | ||
| 489 | Features are normally named after the files that provide them, so that | ||
| 490 | @code{require} need not be given the file name. | ||
| 491 | |||
| 492 | For example, in @file{emacs/lisp/prolog.el}, | 487 | For example, in @file{emacs/lisp/prolog.el}, |
| 493 | the definition for @code{run-prolog} includes the following code: | 488 | the definition for @code{run-prolog} includes the following code: |
| 494 | 489 | ||
| @@ -504,7 +499,8 @@ the definition for @code{run-prolog} includes the following code: | |||
| 504 | @noindent | 499 | @noindent |
| 505 | The expression @code{(require 'comint)} loads the file @file{comint.el} | 500 | The expression @code{(require 'comint)} loads the file @file{comint.el} |
| 506 | if it has not yet been loaded. This ensures that @code{make-comint} is | 501 | if it has not yet been loaded. This ensures that @code{make-comint} is |
| 507 | defined. | 502 | defined. Features are normally named after the files that provide them, |
| 503 | so that @code{require} need not be given the file name. | ||
| 508 | 504 | ||
| 509 | The @file{comint.el} file contains the following top-level expression: | 505 | The @file{comint.el} file contains the following top-level expression: |
| 510 | 506 | ||
| @@ -541,7 +537,7 @@ feature, as in the following example. | |||
| 541 | The compiler ignores the @code{provide}, then processes the | 537 | The compiler ignores the @code{provide}, then processes the |
| 542 | @code{require} by loading the file in question. Loading the file does | 538 | @code{require} by loading the file in question. Loading the file does |
| 543 | execute the @code{provide} call, so the subsequent @code{require} call | 539 | execute the @code{provide} call, so the subsequent @code{require} call |
| 544 | does nothing while loading. | 540 | does nothing when the file is loaded. |
| 545 | 541 | ||
| 546 | @defun provide feature | 542 | @defun provide feature |
| 547 | This function announces that @var{feature} is now loaded, or being | 543 | This function announces that @var{feature} is now loaded, or being |
| @@ -589,7 +585,7 @@ provided}. | |||
| 589 | 585 | ||
| 590 | @defun featurep feature | 586 | @defun featurep feature |
| 591 | This function returns @code{t} if @var{feature} has been provided in the | 587 | This function returns @code{t} if @var{feature} has been provided in the |
| 592 | current Emacs session (i.e., @var{feature} is a member of | 588 | current Emacs session (i.e., if @var{feature} is a member of |
| 593 | @code{features}.) | 589 | @code{features}.) |
| 594 | @end defun | 590 | @end defun |
| 595 | 591 | ||
| @@ -612,10 +608,10 @@ reclaim memory for other Lisp objects. To do this, use the function | |||
| 612 | @deffn Command unload-feature feature &optional force | 608 | @deffn Command unload-feature feature &optional force |
| 613 | This command unloads the library that provided feature @var{feature}. | 609 | This command unloads the library that provided feature @var{feature}. |
| 614 | It undefines all functions, macros, and variables defined in that | 610 | It undefines all functions, macros, and variables defined in that |
| 615 | library with @code{defconst}, @code{defvar}, @code{defun}, | 611 | library with @code{defun}, @code{defalias}, @code{defsubst}, |
| 616 | @code{defmacro}, @code{defsubst} and @code{defalias}. It then restores | 612 | @code{defmacro}, @code{defconst}, @code{defvar}, and @code{defcustom}. |
| 617 | any autoloads formerly associated with those symbols. (Loading | 613 | It then restores any autoloads formerly associated with those symbols. |
| 618 | saves these in the @code{autoload} property of the symbol.) | 614 | (Loading saves these in the @code{autoload} property of the symbol.) |
| 619 | 615 | ||
| 620 | Ordinarily, @code{unload-feature} refuses to unload a library on which | 616 | Ordinarily, @code{unload-feature} refuses to unload a library on which |
| 621 | other loaded libraries depend. (A library @var{a} depends on library | 617 | other loaded libraries depend. (A library @var{a} depends on library |
| @@ -686,9 +682,9 @@ do (1), you can do it immediately---there is no need to wait for when | |||
| 686 | the library is loaded. To do (2), you must load the library (preferably | 682 | the library is loaded. To do (2), you must load the library (preferably |
| 687 | with @code{require}). | 683 | with @code{require}). |
| 688 | 684 | ||
| 689 | But it is ok to use @code{eval-after-load} in your personal customizations | 685 | But it is OK to use @code{eval-after-load} in your personal |
| 690 | if you don't feel they must meet the design standards of programs to be | 686 | customizations if you don't feel they must meet the design standards for |
| 691 | released. | 687 | programs meant for wider use. |
| 692 | 688 | ||
| 693 | @defvar after-load-alist | 689 | @defvar after-load-alist |
| 694 | An alist of expressions to evaluate if and when particular libraries are | 690 | An alist of expressions to evaluate if and when particular libraries are |
diff --git a/lispref/locals.texi b/lispref/locals.texi index 86e6750248c..7a93b817647 100644 --- a/lispref/locals.texi +++ b/lispref/locals.texi | |||
| @@ -8,143 +8,151 @@ | |||
| 8 | @c The title "Standard Buffer-Local Variables" is too long for | 8 | @c The title "Standard Buffer-Local Variables" is too long for |
| 9 | @c smallbook. --rjc 30mar92 | 9 | @c smallbook. --rjc 30mar92 |
| 10 | 10 | ||
| 11 | The table below lists the general-purpose Emacs variables that are | 11 | The table below lists the general-purpose Emacs variables that |
| 12 | automatically local (when set) in each buffer. Many Lisp packages | 12 | automatically become buffer-local in each buffer. Most become |
| 13 | define such variables for their internal use; we don't list them here. | 13 | buffer-local only when set; a few of them are always local in every |
| 14 | buffer. Many Lisp packages define such variables for their internal | ||
| 15 | use, but we don't try to list them all here. | ||
| 14 | 16 | ||
| 15 | @table @code | 17 | @table @code |
| 16 | @item abbrev-mode | 18 | @item abbrev-mode |
| 17 | @pxref{Abbrevs} | 19 | @xref{Abbrevs}. |
| 18 | 20 | ||
| 19 | @item auto-fill-function | 21 | @item auto-fill-function |
| 20 | @pxref{Auto Filling} | 22 | @xref{Auto Filling}. |
| 21 | 23 | ||
| 22 | @item buffer-auto-save-file-name | 24 | @item buffer-auto-save-file-name |
| 23 | @pxref{Auto-Saving} | 25 | @xref{Auto-Saving}. |
| 24 | 26 | ||
| 25 | @item buffer-backed-up | 27 | @item buffer-backed-up |
| 26 | @pxref{Backup Files} | 28 | @xref{Backup Files}. |
| 29 | |||
| 30 | @item buffer-display-count | ||
| 31 | @xref{Displaying Buffers}. | ||
| 27 | 32 | ||
| 28 | @item buffer-display-table | 33 | @item buffer-display-table |
| 29 | @pxref{Display Tables} | 34 | @xref{Display Tables}. |
| 30 | 35 | ||
| 31 | @item buffer-file-format | 36 | @item buffer-file-format |
| 32 | @pxref{Format Conversion} | 37 | @xref{Format Conversion}. |
| 33 | 38 | ||
| 34 | @item buffer-file-name | 39 | @item buffer-file-name |
| 35 | @pxref{Buffer File Name} | 40 | @xref{Buffer File Name}. |
| 36 | 41 | ||
| 37 | @item buffer-file-number | 42 | @item buffer-file-number |
| 38 | @pxref{Buffer File Name} | 43 | @xref{Buffer File Name}. |
| 39 | 44 | ||
| 40 | @item buffer-file-truename | 45 | @item buffer-file-truename |
| 41 | @pxref{Buffer File Name} | 46 | @xref{Buffer File Name}. |
| 42 | 47 | ||
| 43 | @item buffer-file-type | 48 | @item buffer-file-type |
| 44 | @pxref{Files and MS-DOS} | 49 | @xref{MS-DOS File Types}. |
| 45 | 50 | ||
| 46 | @item buffer-invisibility-spec | 51 | @item buffer-invisibility-spec |
| 47 | @pxref{Invisible Text} | 52 | @xref{Invisible Text}. |
| 48 | 53 | ||
| 49 | @item buffer-offer-save | 54 | @item buffer-offer-save |
| 50 | @pxref{Saving Buffers} | 55 | @xref{Saving Buffers}. |
| 51 | 56 | ||
| 52 | @item buffer-read-only | 57 | @item buffer-read-only |
| 53 | @pxref{Read Only Buffers} | 58 | @xref{Read Only Buffers}. |
| 54 | 59 | ||
| 55 | @item buffer-saved-size | 60 | @item buffer-saved-size |
| 56 | @pxref{Point} | 61 | @xref{Point}. |
| 57 | 62 | ||
| 58 | @item buffer-undo-list | 63 | @item buffer-undo-list |
| 59 | @pxref{Undo} | 64 | @xref{Undo}. |
| 60 | 65 | ||
| 61 | @item cache-long-line-scans | 66 | @item cache-long-line-scans |
| 62 | @pxref{Text Lines} | 67 | @xref{Text Lines}. |
| 63 | 68 | ||
| 64 | @item case-fold-search | 69 | @item case-fold-search |
| 65 | @pxref{Searching and Case} | 70 | @xref{Searching and Case}. |
| 66 | 71 | ||
| 67 | @item ctl-arrow | 72 | @item ctl-arrow |
| 68 | @pxref{Usual Display} | 73 | @xref{Usual Display}. |
| 69 | 74 | ||
| 70 | @item comment-column | 75 | @item comment-column |
| 71 | @pxref{Comments,,, emacs, The GNU Emacs Manual} | 76 | @xref{Comments,,, emacs, The GNU Emacs Manual}. |
| 72 | 77 | ||
| 73 | @item default-directory | 78 | @item default-directory |
| 74 | @pxref{System Environment} | 79 | @xref{System Environment}. |
| 75 | 80 | ||
| 76 | @item defun-prompt-regexp | 81 | @item defun-prompt-regexp |
| 77 | @pxref{List Motion} | 82 | @xref{List Motion}. |
| 83 | |||
| 84 | @item enable-multibyte-characters | ||
| 85 | @ref{Non-ASCII Characters}. | ||
| 78 | 86 | ||
| 79 | @item fill-column | 87 | @item fill-column |
| 80 | @pxref{Auto Filling} | 88 | @xref{Auto Filling}. |
| 81 | 89 | ||
| 82 | @item goal-column | 90 | @item goal-column |
| 83 | @pxref{Moving Point,,, emacs, The GNU Emacs Manual} | 91 | @xref{Moving Point,,, emacs, The GNU Emacs Manual}. |
| 84 | 92 | ||
| 85 | @item left-margin | 93 | @item left-margin |
| 86 | @pxref{Indentation} | 94 | @xref{Indentation}. |
| 87 | 95 | ||
| 88 | @item local-abbrev-table | 96 | @item local-abbrev-table |
| 89 | @pxref{Abbrevs} | 97 | @xref{Abbrevs}. |
| 90 | 98 | ||
| 91 | @item local-write-file-hooks | 99 | @item local-write-file-hooks |
| 92 | @pxref{Saving Buffers} | 100 | @xref{Saving Buffers}. |
| 93 | 101 | ||
| 94 | @item major-mode | 102 | @item major-mode |
| 95 | @pxref{Mode Help} | 103 | @xref{Mode Help}. |
| 96 | 104 | ||
| 97 | @item mark-active | 105 | @item mark-active |
| 98 | @pxref{The Mark} | 106 | @xref{The Mark}. |
| 99 | 107 | ||
| 100 | @item mark-ring | 108 | @item mark-ring |
| 101 | @pxref{The Mark} | 109 | @xref{The Mark}. |
| 102 | 110 | ||
| 103 | @item minor-modes | 111 | @item minor-modes |
| 104 | @pxref{Minor Modes} | 112 | @xref{Minor Modes}. |
| 105 | 113 | ||
| 106 | @item mode-line-buffer-identification | 114 | @item mode-line-buffer-identification |
| 107 | @pxref{Mode Line Variables} | 115 | @xref{Mode Line Variables}. |
| 108 | 116 | ||
| 109 | @item mode-line-format | 117 | @item mode-line-format |
| 110 | @pxref{Mode Line Data} | 118 | @xref{Mode Line Data}. |
| 111 | 119 | ||
| 112 | @item mode-line-modified | 120 | @item mode-line-modified |
| 113 | @pxref{Mode Line Variables} | 121 | @xref{Mode Line Variables}. |
| 114 | 122 | ||
| 115 | @item mode-line-process | 123 | @item mode-line-process |
| 116 | @pxref{Mode Line Variables} | 124 | @xref{Mode Line Variables}. |
| 117 | 125 | ||
| 118 | @item mode-name | 126 | @item mode-name |
| 119 | @pxref{Mode Line Variables} | 127 | @xref{Mode Line Variables}. |
| 120 | 128 | ||
| 121 | @item overwrite-mode | 129 | @item overwrite-mode |
| 122 | @pxref{Insertion} | 130 | @xref{Insertion}. |
| 123 | 131 | ||
| 124 | @item paragraph-separate | 132 | @item paragraph-separate |
| 125 | @pxref{Standard Regexps} | 133 | @xref{Standard Regexps}. |
| 126 | 134 | ||
| 127 | @item paragraph-start | 135 | @item paragraph-start |
| 128 | @pxref{Standard Regexps} | 136 | @xref{Standard Regexps}. |
| 129 | 137 | ||
| 130 | @item point-before-scroll | 138 | @item point-before-scroll |
| 131 | Used for communication between mouse commands and scroll-bar commands. | 139 | Ued for communication between mouse commands and scroll-bar commands.. |
| 132 | 140 | ||
| 133 | @item require-final-newline | 141 | @item require-final-newline |
| 134 | @pxref{Insertion} | 142 | @xref{Insertion}. |
| 135 | 143 | ||
| 136 | @item selective-display | 144 | @item selective-display |
| 137 | @pxref{Selective Display} | 145 | @xref{Selective Display}. |
| 138 | 146 | ||
| 139 | @item selective-display-ellipses | 147 | @item selective-display-ellipses |
| 140 | @pxref{Selective Display} | 148 | @xref{Selective Display}. |
| 141 | 149 | ||
| 142 | @item tab-width | 150 | @item tab-width |
| 143 | @pxref{Usual Display} | 151 | @xref{Usual Display}. |
| 144 | 152 | ||
| 145 | @item truncate-lines | 153 | @item truncate-lines |
| 146 | @pxref{Truncation} | 154 | @xref{Truncation}. |
| 147 | 155 | ||
| 148 | @item vc-mode | 156 | @item vc-mode |
| 149 | @pxref{Mode Line Variables} | 157 | @xref{Mode Line Variables}. |
| 150 | @end table | 158 | @end table |
diff --git a/lispref/macros.texi b/lispref/macros.texi index 9ec72243562..b9e93bcf6d4 100644 --- a/lispref/macros.texi +++ b/lispref/macros.texi | |||
| @@ -48,11 +48,12 @@ Here's a macro definition that does the job: | |||
| 48 | @end group | 48 | @end group |
| 49 | @end example | 49 | @end example |
| 50 | 50 | ||
| 51 | When this is called with @code{(inc x)}, the argument @code{var} has | 51 | When this is called with @code{(inc x)}, the argument @var{var} is the |
| 52 | the value @code{x}---@emph{not} the @emph{value} of @code{x}. The body | 52 | symbol @code{x}---@emph{not} the @emph{value} of @code{x}, as it would |
| 53 | of the macro uses this to construct the expansion, which is @code{(setq | 53 | be in a function. The body of the macro uses this to construct the |
| 54 | x (1+ x))}. Once the macro definition returns this expansion, Lisp | 54 | expansion, which is @code{(setq x (1+ x))}. Once the macro definition |
| 55 | proceeds to evaluate it, thus incrementing @code{x}. | 55 | returns this expansion, Lisp proceeds to evaluate it, thus incrementing |
| 56 | @code{x}. | ||
| 56 | 57 | ||
| 57 | @node Expansion | 58 | @node Expansion |
| 58 | @section Expansion of a Macro Call | 59 | @section Expansion of a Macro Call |
| @@ -192,6 +193,7 @@ like this: | |||
| 192 | (macro lambda @var{argument-list} . @var{body-forms}) | 193 | (macro lambda @var{argument-list} . @var{body-forms}) |
| 193 | @end example | 194 | @end example |
| 194 | 195 | ||
| 196 | (Note that the @sc{cdr} of this list is a function---a lambda expression.) | ||
| 195 | This macro object is stored in the function cell of @var{name}. The | 197 | This macro object is stored in the function cell of @var{name}. The |
| 196 | value returned by evaluating the @code{defmacro} form is @var{name}, but | 198 | value returned by evaluating the @code{defmacro} form is @var{name}, but |
| 197 | usually we ignore this value. | 199 | usually we ignore this value. |
| @@ -210,8 +212,8 @@ called interactively. | |||
| 210 | @findex ` | 212 | @findex ` |
| 211 | 213 | ||
| 212 | Macros often need to construct large list structures from a mixture of | 214 | Macros often need to construct large list structures from a mixture of |
| 213 | constants and nonconstant parts. To make this easier, use the macro | 215 | constants and nonconstant parts. To make this easier, use the @samp{`} |
| 214 | @samp{`} (often called @dfn{backquote}). | 216 | syntax (usually called @dfn{backquote}). |
| 215 | 217 | ||
| 216 | Backquote allows you to quote a list, but selectively evaluate | 218 | Backquote allows you to quote a list, but selectively evaluate |
| 217 | elements of that list. In the simplest case, it is identical to the | 219 | elements of that list. In the simplest case, it is identical to the |
| @@ -299,18 +301,16 @@ Here are some examples: | |||
| 299 | @end group | 301 | @end group |
| 300 | @end example | 302 | @end example |
| 301 | 303 | ||
| 302 | @quotation | 304 | In old Emacs versions, before version 19.29, @samp{`} used a different |
| 303 | Before Emacs version 19.29, @samp{`} used a different syntax which | 305 | syntax which required an extra level of parentheses around the entire |
| 304 | required an extra level of parentheses around the entire backquote | 306 | backquote construct. Likewise, each @samp{,} or @samp{,@@} substitution |
| 305 | construct. Likewise, each @samp{,} or @samp{,@@} substition required an | 307 | required an extra level of parentheses surrounding both the @samp{,} or |
| 306 | extra level of parentheses surrounding both the @samp{,} or @samp{,@@} | 308 | @samp{,@@} and the following expression. The old syntax required |
| 307 | and the following expression. The old syntax required whitespace | 309 | whitespace between the @samp{`}, @samp{,} or @samp{,@@} and the |
| 308 | between the @samp{`}, @samp{,} or @samp{,@@} and the following | 310 | following expression. |
| 309 | expression. | ||
| 310 | 311 | ||
| 311 | This syntax is still accepted, for compatibility with old Emacs | 312 | This syntax is still accepted, for compatibility with old Emacs |
| 312 | versions, but we recommend not using it in new programs. | 313 | versions, but we recommend not using it in new programs. |
| 313 | @end quotation | ||
| 314 | 314 | ||
| 315 | @node Problems with Macros | 315 | @node Problems with Macros |
| 316 | @section Common Problems Using Macros | 316 | @section Common Problems Using Macros |
| @@ -371,10 +371,10 @@ For example, (for i from 1 to 10 do (print i))." | |||
| 371 | @end smallexample | 371 | @end smallexample |
| 372 | 372 | ||
| 373 | @noindent | 373 | @noindent |
| 374 | (The arguments @code{from}, @code{to}, and @code{do} in this macro are | 374 | The arguments @code{from}, @code{to}, and @code{do} in this macro are |
| 375 | ``syntactic sugar''; they are entirely ignored. The idea is that you | 375 | ``syntactic sugar''; they are entirely ignored. The idea is that you |
| 376 | will write noise words (such as @code{from}, @code{to}, and @code{do}) | 376 | will write noise words (such as @code{from}, @code{to}, and @code{do}) |
| 377 | in those positions in the macro call.) | 377 | in those positions in the macro call. |
| 378 | 378 | ||
| 379 | Here's an equivalent definition simplified through use of backquote: | 379 | Here's an equivalent definition simplified through use of backquote: |
| 380 | 380 | ||
| @@ -428,10 +428,8 @@ Here is a macro definition that creates this expansion: | |||
| 428 | @end group | 428 | @end group |
| 429 | @end smallexample | 429 | @end smallexample |
| 430 | 430 | ||
| 431 | Unfortunately, this introduces another problem. | 431 | Unfortunately, this fix introduces another problem, |
| 432 | @ifinfo | 432 | described in the following section. |
| 433 | Proceed to the following node. | ||
| 434 | @end ifinfo | ||
| 435 | 433 | ||
| 436 | @node Surprising Local Vars | 434 | @node Surprising Local Vars |
| 437 | @subsection Local Variables in Macro Expansions | 435 | @subsection Local Variables in Macro Expansions |
| @@ -536,17 +534,18 @@ it. Here is an example: | |||
| 536 | @code{x}, because @code{a} conflicts with the macro argument variable | 534 | @code{x}, because @code{a} conflicts with the macro argument variable |
| 537 | @code{a}. | 535 | @code{a}. |
| 538 | 536 | ||
| 539 | Another reason not to call @code{eval} in a macro definition is that | 537 | Another problem with calling @code{eval} in a macro definition is that |
| 540 | it probably won't do what you intend in a compiled program. The | 538 | it probably won't do what you intend in a compiled program. The |
| 541 | byte-compiler runs macro definitions while compiling the program, when | 539 | byte-compiler runs macro definitions while compiling the program, when |
| 542 | the program's own computations (which you might have wished to access | 540 | the program's own computations (which you might have wished to access |
| 543 | with @code{eval}) don't occur and its local variable bindings don't | 541 | with @code{eval}) don't occur and its local variable bindings don't |
| 544 | exist. | 542 | exist. |
| 545 | 543 | ||
| 546 | The safe way to work with the run-time value of an expression is to | 544 | To avoid these problems, @strong{don't evaluate an argument expression |
| 547 | put the expression into the macro expansion, so that its value is | 545 | while computing the macro expansion.} Instead, substitute the |
| 548 | computed as part of executing the expansion. This is what the other | 546 | expression into the macro expansion, so that its value will be computed |
| 549 | examples in this chapter do. | 547 | as part of executing the expansion. This is how the other examples in |
| 548 | this chapter work. | ||
| 550 | 549 | ||
| 551 | @node Repeated Expansion | 550 | @node Repeated Expansion |
| 552 | @subsection How Many Times is the Macro Expanded? | 551 | @subsection How Many Times is the Macro Expanded? |
| @@ -557,15 +556,25 @@ expanded only once (during compilation) for a compiled function. If the | |||
| 557 | macro definition has side effects, they will work differently depending | 556 | macro definition has side effects, they will work differently depending |
| 558 | on how many times the macro is expanded. | 557 | on how many times the macro is expanded. |
| 559 | 558 | ||
| 560 | In particular, constructing objects is a kind of side effect. If the | 559 | Therefore, you should avoid side effects in computation of the |
| 561 | macro is called once, then the objects are constructed only once. In | 560 | macro expansion, unless you really know what you are doing. |
| 562 | other words, the same structure of objects is used each time the macro | 561 | |
| 563 | call is executed. In interpreted operation, the macro is reexpanded | 562 | One special kind of side effect can't be avoided: constructing Lisp |
| 564 | each time, producing a fresh collection of objects each time. Usually | 563 | objects. Almost all macro expansions include constructed lists; that is |
| 565 | this does not matter---the objects have the same contents whether they | 564 | the whole point of most macros. This is usually safe; there is just one |
| 566 | are shared or not. But if the surrounding program does side effects | 565 | case where you must be careful: when the object you construct is part of a |
| 567 | on the objects, it makes a difference whether they are shared. Here is | 566 | quoted constant in the macro expansion. |
| 568 | an example: | 567 | |
| 568 | If the macro is expanded just once, in compilation, then the object is | ||
| 569 | constructed just once, during compilation. But in interpreted | ||
| 570 | execution, the macro is expanded each time the macro call runs, and this | ||
| 571 | means a new object is constructed each time. | ||
| 572 | |||
| 573 | In most clean Lisp code, this difference won't matter. It can matter | ||
| 574 | only if you perform side-effects on the objects constructed by the macro | ||
| 575 | definition. Thus, to avoid trouble, @strong{avoid side effects on | ||
| 576 | objects constructed by macro definitions}. Here is an example of how | ||
| 577 | such side effects can get you into trouble: | ||
| 569 | 578 | ||
| 570 | @lisp | 579 | @lisp |
| 571 | @group | 580 | @group |
diff --git a/lispref/maps.texi b/lispref/maps.texi index 77dc80001b9..78b5ceae979 100644 --- a/lispref/maps.texi +++ b/lispref/maps.texi | |||
| @@ -29,15 +29,12 @@ A sparse keymap used by C mode. | |||
| 29 | A full keymap used by Command History mode. | 29 | A full keymap used by Command History mode. |
| 30 | 30 | ||
| 31 | @item ctl-x-4-map | 31 | @item ctl-x-4-map |
| 32 | @vindex ctl-x-4-map | ||
| 33 | A sparse keymap for subcommands of the prefix @kbd{C-x 4}. | 32 | A sparse keymap for subcommands of the prefix @kbd{C-x 4}. |
| 34 | 33 | ||
| 35 | @item ctl-x-5-map | 34 | @item ctl-x-5-map |
| 36 | @vindex ctl-x-5-map | ||
| 37 | A sparse keymap for subcommands of the prefix @kbd{C-x 5}. | 35 | A sparse keymap for subcommands of the prefix @kbd{C-x 5}. |
| 38 | 36 | ||
| 39 | @item ctl-x-map | 37 | @item ctl-x-map |
| 40 | @vindex ctl-x-map | ||
| 41 | A full keymap for @kbd{C-x} commands. | 38 | A full keymap for @kbd{C-x} commands. |
| 42 | 39 | ||
| 43 | @item debugger-mode-map | 40 | @item debugger-mode-map |
| @@ -101,9 +98,9 @@ The keymap that displays the Special Props submenu of the Text | |||
| 101 | Properties menu. | 98 | Properties menu. |
| 102 | 99 | ||
| 103 | @item function-key-map | 100 | @item function-key-map |
| 104 | @vindex function-key-map | ||
| 105 | The keymap for translating keypad and function keys.@* | 101 | The keymap for translating keypad and function keys.@* |
| 106 | If there are none, then it contains an empty sparse keymap. | 102 | If there are none, then it contains an empty sparse keymap. |
| 103 | @xref{Translating Input}. | ||
| 107 | 104 | ||
| 108 | @item fundamental-mode-map | 105 | @item fundamental-mode-map |
| 109 | @vindex fundamental-mode-map | 106 | @vindex fundamental-mode-map |
| @@ -130,9 +127,8 @@ A keymap that defines the characters you can type within incremental | |||
| 130 | search. | 127 | search. |
| 131 | 128 | ||
| 132 | @item key-translation-map | 129 | @item key-translation-map |
| 133 | @vindex key-translation-map | ||
| 134 | A keymap for translating keys. This one overrides ordinary key | 130 | A keymap for translating keys. This one overrides ordinary key |
| 135 | bindings, unlike @code{function-key-map}. | 131 | bindings, unlike @code{function-key-map}. @xref{Translating Input}. |
| 136 | 132 | ||
| 137 | @item lisp-interaction-mode-map | 133 | @item lisp-interaction-mode-map |
| 138 | @vindex lisp-interaction-mode-map | 134 | @vindex lisp-interaction-mode-map |
| @@ -154,6 +150,11 @@ The keymap which displays the Files menu in the menu bar. | |||
| 154 | @vindex menu-bar-help-menu | 150 | @vindex menu-bar-help-menu |
| 155 | The keymap which displays the Help menu in the menu bar. | 151 | The keymap which displays the Help menu in the menu bar. |
| 156 | 152 | ||
| 153 | @tindex menu-bar-mule-menu | ||
| 154 | @item menu-bar-mule-menu | ||
| 155 | @vindex menu-bar-mule-menu | ||
| 156 | The keymap which displays the Mule menu in the menu bar. | ||
| 157 | |||
| 157 | @item menu-bar-search-menu | 158 | @item menu-bar-search-menu |
| 158 | @vindex menu-bar-search-menu | 159 | @vindex menu-bar-search-menu |
| 159 | The keymap which displays the Search menu in the menu bar. | 160 | The keymap which displays the Search menu in the menu bar. |
| @@ -163,7 +164,6 @@ The keymap which displays the Search menu in the menu bar. | |||
| 163 | The keymap which displays the Tools menu in the menu bar. | 164 | The keymap which displays the Tools menu in the menu bar. |
| 164 | 165 | ||
| 165 | @item mode-specific-map | 166 | @item mode-specific-map |
| 166 | @vindex mode-specific-map | ||
| 167 | The keymap for characters following @kbd{C-c}. Note, this is in the | 167 | The keymap for characters following @kbd{C-c}. Note, this is in the |
| 168 | global map. This map is not actually mode specific: its name was chosen | 168 | global map. This map is not actually mode specific: its name was chosen |
| 169 | to be informative for the user in @kbd{C-h b} (@code{display-bindings}), | 169 | to be informative for the user in @kbd{C-h b} (@code{display-bindings}), |
| @@ -174,7 +174,6 @@ where it describes the main use of the @kbd{C-c} prefix key. | |||
| 174 | A local keymap used by Occur mode. | 174 | A local keymap used by Occur mode. |
| 175 | 175 | ||
| 176 | @item query-replace-map | 176 | @item query-replace-map |
| 177 | @vindex query-replace-map | ||
| 178 | A local keymap used for responses in @code{query-replace} and related | 177 | A local keymap used for responses in @code{query-replace} and related |
| 179 | commands; also for @code{y-or-n-p} and @code{map-y-or-n-p}. The functions | 178 | commands; also for @code{y-or-n-p} and @code{map-y-or-n-p}. The functions |
| 180 | that use this map do not support prefix keys; they look up one event at a | 179 | that use this map do not support prefix keys; they look up one event at a |
diff --git a/lispref/markers.texi b/lispref/markers.texi index ecd0978a227..6a475b7a01e 100644 --- a/lispref/markers.texi +++ b/lispref/markers.texi | |||
| @@ -44,9 +44,10 @@ buffer. Relocation changes the integer equivalent of the marker. | |||
| 44 | @cindex marker relocation | 44 | @cindex marker relocation |
| 45 | Deleting text around a marker's position leaves the marker between the | 45 | Deleting text around a marker's position leaves the marker between the |
| 46 | characters immediately before and after the deleted text. Inserting | 46 | characters immediately before and after the deleted text. Inserting |
| 47 | text at the position of a marker normally leaves the marker in front of | 47 | text at the position of a marker normally leaves the marker either in |
| 48 | the new text---unless it is inserted with @code{insert-before-markers} | 48 | front of or after the new text, depending on the marker's @dfn{insertion |
| 49 | (@pxref{Insertion}). | 49 | type} (@pxref{Marker Insertion Types})---unless the insertion is done |
| 50 | with @code{insert-before-markers} (@pxref{Insertion}). | ||
| 50 | 51 | ||
| 51 | @cindex marker garbage collection | 52 | @cindex marker garbage collection |
| 52 | Insertion and deletion in a buffer must check all the markers and | 53 | Insertion and deletion in a buffer must check all the markers and |
| @@ -306,7 +307,9 @@ if they both point nowhere. | |||
| 306 | When you insert text directly at the place where a marker points, | 307 | When you insert text directly at the place where a marker points, |
| 307 | there are two possible ways to relocate that marker: it can point before | 308 | there are two possible ways to relocate that marker: it can point before |
| 308 | the inserted text, or point after it. You can specify which one a given | 309 | the inserted text, or point after it. You can specify which one a given |
| 309 | marker should do by setting its @dfn{insertion type}. | 310 | marker should do by setting its @dfn{insertion type}. Note that use of |
| 311 | @code{insert-before-markers} ignores markers' insertion types, always | ||
| 312 | relocating a marker to point after the inserted text. | ||
| 310 | 313 | ||
| 311 | @tindex set-marker-insertion-type | 314 | @tindex set-marker-insertion-type |
| 312 | @defun set-marker-insertion-type marker type | 315 | @defun set-marker-insertion-type marker type |
| @@ -396,11 +399,12 @@ absence of a mark in that buffer.'' | |||
| 396 | 399 | ||
| 397 | Once the mark ``exists'' in a buffer, it normally never ceases to | 400 | Once the mark ``exists'' in a buffer, it normally never ceases to |
| 398 | exist. However, it may become @dfn{inactive}, if Transient Mark mode is | 401 | exist. However, it may become @dfn{inactive}, if Transient Mark mode is |
| 399 | enabled. The variable @code{mark-active}, which is always local in all | 402 | enabled. The variable @code{mark-active}, which is always buffer-local |
| 400 | buffers, indicates whether the mark is active: non-@code{nil} means yes. | 403 | in all buffers, indicates whether the mark is active: non-@code{nil} |
| 401 | A command can request deactivation of the mark upon return to the editor | 404 | means yes. A command can request deactivation of the mark upon return |
| 402 | command loop by setting @code{deactivate-mark} to a non-@code{nil} value | 405 | to the editor command loop by setting @code{deactivate-mark} to a |
| 403 | (but this causes deactivation only if Transient Mark mode is enabled). | 406 | non-@code{nil} value (but this causes deactivation only if Transient |
| 407 | Mark mode is enabled). | ||
| 404 | 408 | ||
| 405 | The main motivation for using Transient Mark mode is that this mode | 409 | The main motivation for using Transient Mark mode is that this mode |
| 406 | also enables highlighting of the region when the mark is active. | 410 | also enables highlighting of the region when the mark is active. |
| @@ -529,20 +533,30 @@ consequence of this is that commands that modify the buffer normally | |||
| 529 | make the mark inactive. | 533 | make the mark inactive. |
| 530 | @end defopt | 534 | @end defopt |
| 531 | 535 | ||
| 536 | @defopt mark-even-if-inactive | ||
| 537 | If this is non-@code{nil}, Lisp programs and the Emacs user can use the | ||
| 538 | mark even when it is inactive. This option affects the behavior of | ||
| 539 | Transient Mark mode. When the option is non-@code{nil}, deactivation of | ||
| 540 | the mark turns off region highlighting, but commands that use the mark | ||
| 541 | behave as if the mark were still active. | ||
| 542 | @end defopt | ||
| 543 | |||
| 532 | @defvar deactivate-mark | 544 | @defvar deactivate-mark |
| 533 | If an editor command sets this variable non-@code{nil}, then the editor | 545 | If an editor command sets this variable non-@code{nil}, then the editor |
| 534 | command loop deactivates the mark after the command returns, but only if | 546 | command loop deactivates the mark after the command returns (if |
| 535 | Transient Mark mode is enabled. | 547 | Transient Mark mode is enabled). All the primitives that change the |
| 548 | buffer set @code{deactivate-mark}, to deactivate the mark when the | ||
| 549 | command is finished. | ||
| 536 | @end defvar | 550 | @end defvar |
| 537 | 551 | ||
| 538 | @defun deactivate-mark | 552 | @defun deactivate-mark |
| 539 | This function deactivates the mark, but only if Transient Mark mode | 553 | This function deactivates the mark, if Transient Mark mode is enabled. |
| 540 | is enabled. | 554 | Otherwise it does nothing. |
| 541 | @end defun | 555 | @end defun |
| 542 | 556 | ||
| 543 | @defvar mark-active | 557 | @defvar mark-active |
| 544 | The mark is active when this variable is non-@code{nil}. This variable | 558 | The mark is active when this variable is non-@code{nil}. This variable |
| 545 | is always local in each buffer. | 559 | is always buffer-local in each buffer. |
| 546 | @end defvar | 560 | @end defvar |
| 547 | 561 | ||
| 548 | @defvar activate-mark-hook | 562 | @defvar activate-mark-hook |
diff --git a/lispref/minibuf.texi b/lispref/minibuf.texi index 16d5f60d4e5..0ff8e79c1ca 100644 --- a/lispref/minibuf.texi +++ b/lispref/minibuf.texi | |||
| @@ -13,8 +13,8 @@ | |||
| 13 | arguments more complicated than the single numeric prefix argument. | 13 | arguments more complicated than the single numeric prefix argument. |
| 14 | These arguments include file names, buffer names, and command names (as | 14 | These arguments include file names, buffer names, and command names (as |
| 15 | in @kbd{M-x}). The minibuffer is displayed on the bottom line of the | 15 | in @kbd{M-x}). The minibuffer is displayed on the bottom line of the |
| 16 | screen, in the same place as the echo area, but only while it is in | 16 | frame, in the same place as the echo area, but only while it is in use |
| 17 | use for reading an argument. | 17 | for reading an argument. |
| 18 | 18 | ||
| 19 | @menu | 19 | @menu |
| 20 | * Intro to Minibuffers:: Basic information about minibuffers. | 20 | * Intro to Minibuffers:: Basic information about minibuffers. |
| @@ -100,26 +100,25 @@ string; however, if @var{read} is non-@code{nil}, then it uses | |||
| 100 | @code{read} to convert the text into a Lisp object (@pxref{Input | 100 | @code{read} to convert the text into a Lisp object (@pxref{Input |
| 101 | Functions}). | 101 | Functions}). |
| 102 | 102 | ||
| 103 | The first thing this function does is to activate a minibuffer and | 103 | The first thing this function does is to activate a minibuffer and |
| 104 | display it with @var{prompt-string} as the prompt. This value must be a | 104 | display it with @var{prompt-string} as the prompt. This value must be a |
| 105 | string. | 105 | string. Then the user can edit text in the minibuffer. |
| 106 | |||
| 107 | Then, if @var{initial-contents} is a string, @code{read-from-minibuffer} | ||
| 108 | inserts it into the minibuffer, leaving point at the end. The | ||
| 109 | minibuffer appears with this text as its contents. | ||
| 110 | 106 | ||
| 111 | @strong{Usage note:} The @var{initial-contents} argument and the | 107 | When the user types a command to exit the minibuffer, |
| 112 | @var{default} argument are two alternative features for the same job. | 108 | @code{read-from-minibuffer} constructs the return value from the text in |
| 113 | It usually does not make sense to use both at once. In most cases, you | 109 | the minibuffer. Normally it returns a string containing that text. |
| 114 | should use @var{default}, since this permits the user to insert the | 110 | However, if @var{read} is non-@code{nil}, @code{read-from-minibuffer} |
| 115 | default value but does not burden the user with deleting it from the | 111 | reads the text and returns the resulting Lisp object, unevaluated. |
| 116 | minibuffer. | 112 | (@xref{Input Functions}, for information about reading.) |
| 117 | 113 | ||
| 118 | @c Emacs 19 feature | 114 | The argument @var{default} specifies a default value to make available |
| 119 | The value of @var{initial-contents} may also be a cons cell of the form | 115 | through the history commands. It should be a string, or @code{nil}. If |
| 120 | @code{(@var{string} . @var{position})}. This means to insert | 116 | @var{read} is non-@code{nil}, then @var{default} is also used as the |
| 121 | @var{string} in the minibuffer but put point @var{position} characters | 117 | input to @code{read}, if the user enters empty input. However, in the |
| 122 | from the beginning, rather than at the end. | 118 | usual case (where @var{read} is @code{nil}, @code{read-from-minibuffer} |
| 119 | does not return @var{default} when the user enters empty input; it | ||
| 120 | returns an empty string, @code{""}. In this respect, it is different | ||
| 121 | from all the other minibuffer input functions in this chapter. | ||
| 123 | 122 | ||
| 124 | If @var{keymap} is non-@code{nil}, that keymap is the local keymap to | 123 | If @var{keymap} is non-@code{nil}, that keymap is the local keymap to |
| 125 | use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the | 124 | use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the |
| @@ -131,30 +130,33 @@ The argument @var{hist} specifies which history list variable to use | |||
| 131 | for saving the input and for history commands used in the minibuffer. | 130 | for saving the input and for history commands used in the minibuffer. |
| 132 | It defaults to @code{minibuffer-history}. @xref{Minibuffer History}. | 131 | It defaults to @code{minibuffer-history}. @xref{Minibuffer History}. |
| 133 | 132 | ||
| 134 | When the user types a command to exit the minibuffer, | ||
| 135 | @code{read-from-minibuffer} uses the text in the minibuffer to produce | ||
| 136 | its return value. Normally it simply makes a string containing that | ||
| 137 | text. However, if @var{read} is non-@code{nil}, | ||
| 138 | @code{read-from-minibuffer} reads the text and returns the resulting | ||
| 139 | Lisp object, unevaluated. (@xref{Input Functions}, for information | ||
| 140 | about reading.) | ||
| 141 | |||
| 142 | If the variable @code{minibuffer-allow-text-properties} is | 133 | If the variable @code{minibuffer-allow-text-properties} is |
| 143 | non-@code{nil}, then the string which is returned includes whatever text | 134 | non-@code{nil}, then the string which is returned includes whatever text |
| 144 | properties were present in the minibuffer. Otherwise all the text | 135 | properties were present in the minibuffer. Otherwise all the text |
| 145 | properties are stripped when the value is returned. | 136 | properties are stripped when the value is returned. |
| 146 | 137 | ||
| 147 | The argument @var{default} specifies a default value to make available | ||
| 148 | through the history list. It should be a string, or @code{nil}. If | ||
| 149 | @var{read} is non-@code{nil}, then @var{default} is passed through | ||
| 150 | @code{read}, just as ordinary user input would be. Unlike many other | ||
| 151 | minibuffer functions, this function does @emph{not} return @var{default} | ||
| 152 | if the user enters empty input. It returns @code{""} in that case. | ||
| 153 | |||
| 154 | If the argument @var{inherit-input-method} is non-@code{nil}, then the | 138 | If the argument @var{inherit-input-method} is non-@code{nil}, then the |
| 155 | minibuffer inherits the current input method and the setting of | 139 | minibuffer inherits the current input method and the setting of |
| 156 | @code{enable-multibyte-characters} from whichever buffer was current | 140 | @code{enable-multibyte-characters} from whichever buffer was current |
| 157 | before entering the minibuffer. | 141 | before entering the minibuffer. |
| 142 | |||
| 143 | If @var{initial-contents} is a string, @code{read-from-minibuffer} | ||
| 144 | inserts it into the minibuffer, leaving point at the end, before the | ||
| 145 | user starts to edit the text. The minibuffer appears with this text as | ||
| 146 | its initial contents. | ||
| 147 | |||
| 148 | Alternatively, @var{initial-contents} can be a cons cell of the form | ||
| 149 | @code{(@var{string} . @var{position})}. This means to insert | ||
| 150 | @var{string} in the minibuffer but put point @var{position} characters | ||
| 151 | from the beginning, rather than at the end. | ||
| 152 | |||
| 153 | @strong{Usage note:} The @var{initial-contents} argument and the | ||
| 154 | @var{default} argument are two alternative features for more or less the | ||
| 155 | same job. It does not make sense to use both features in a single call | ||
| 156 | to @code{read-from-minibuffer}. In general, we recommend using | ||
| 157 | @var{default}, since this permits the user to insert the default value | ||
| 158 | when it is wanted, but does not burden the user with deleting it from | ||
| 159 | the minibuffer on other occasions. | ||
| 158 | @end defun | 160 | @end defun |
| 159 | 161 | ||
| 160 | @defun read-string prompt &optional initial history default inherit-input-method | 162 | @defun read-string prompt &optional initial history default inherit-input-method |
| @@ -177,8 +179,12 @@ This function is a simplified interface to the | |||
| 177 | @group | 179 | @group |
| 178 | (read-string @var{prompt} @var{initial} @var{history} @var{default} @var{inherit}) | 180 | (read-string @var{prompt} @var{initial} @var{history} @var{default} @var{inherit}) |
| 179 | @equiv{} | 181 | @equiv{} |
| 180 | (read-from-minibuffer @var{prompt} @var{initial} nil nil | 182 | (let ((value |
| 181 | @var{history} @var{default} @var{inherit}) | 183 | (read-from-minibuffer @var{prompt} @var{initial} nil nil |
| 184 | @var{history} @var{default} @var{inherit}))) | ||
| 185 | (if (equal value "") | ||
| 186 | @var{default} | ||
| 187 | value)) | ||
| 182 | @end group | 188 | @end group |
| 183 | @end smallexample | 189 | @end smallexample |
| 184 | @end defun | 190 | @end defun |
| @@ -195,7 +201,7 @@ This is the default local keymap for reading from the minibuffer. By | |||
| 195 | default, it makes the following bindings: | 201 | default, it makes the following bindings: |
| 196 | 202 | ||
| 197 | @table @asis | 203 | @table @asis |
| 198 | @item @key{LFD} | 204 | @item @kbd{C-j} |
| 199 | @code{exit-minibuffer} | 205 | @code{exit-minibuffer} |
| 200 | 206 | ||
| 201 | @item @key{RET} | 207 | @item @key{RET} |
| @@ -368,16 +374,16 @@ expression, thus moving point forward one word. | |||
| 368 | @cindex minibuffer history | 374 | @cindex minibuffer history |
| 369 | @cindex history list | 375 | @cindex history list |
| 370 | 376 | ||
| 371 | A @dfn{minibuffer history list} records previous minibuffer inputs so | 377 | A @dfn{minibuffer history list} records previous minibuffer inputs so |
| 372 | the user can reuse them conveniently. A history list is actually a | 378 | the user can reuse them conveniently. A history list is actually a |
| 373 | symbol, not a list; it is a variable whose value is a list of strings | 379 | symbol, not a list; it is a variable whose value is a list of strings |
| 374 | (previous inputs), most recent first. | 380 | (previous inputs), most recent first. |
| 375 | 381 | ||
| 376 | There are many separate history lists, used for different kinds of | 382 | There are many separate history lists, used for different kinds of |
| 377 | inputs. It's the Lisp programmer's job to specify the right history | 383 | inputs. It's the Lisp programmer's job to specify the right history |
| 378 | list for each use of the minibuffer. | 384 | list for each use of the minibuffer. |
| 379 | 385 | ||
| 380 | The basic minibuffer input functions @code{read-from-minibuffer} and | 386 | The basic minibuffer input functions @code{read-from-minibuffer} and |
| 381 | @code{completing-read} both accept an optional argument named @var{hist} | 387 | @code{completing-read} both accept an optional argument named @var{hist} |
| 382 | which is how you specify the history list. Here are the possible | 388 | which is how you specify the history list. Here are the possible |
| 383 | values: | 389 | values: |
| @@ -395,18 +401,20 @@ If you specify @var{startpos}, then you should also specify that element | |||
| 395 | of the history as the initial minibuffer contents, for consistency. | 401 | of the history as the initial minibuffer contents, for consistency. |
| 396 | @end table | 402 | @end table |
| 397 | 403 | ||
| 398 | If you don't specify @var{hist}, then the default history list | 404 | If you don't specify @var{hist}, then the default history list |
| 399 | @code{minibuffer-history} is used. For other standard history lists, | 405 | @code{minibuffer-history} is used. For other standard history lists, |
| 400 | see below. You can also create your own history list variable; just | 406 | see below. You can also create your own history list variable; just |
| 401 | initialize it to @code{nil} before the first use. | 407 | initialize it to @code{nil} before the first use. |
| 402 | 408 | ||
| 403 | Both @code{read-from-minibuffer} and @code{completing-read} add new | 409 | Both @code{read-from-minibuffer} and @code{completing-read} add new |
| 404 | elements to the history list automatically, and provide commands to | 410 | elements to the history list automatically, and provide commands to |
| 405 | allow the user to reuse items on the list. The only thing your program | 411 | allow the user to reuse items on the list. The only thing your program |
| 406 | needs to do to use a history list is to initialize it and to pass its | 412 | needs to do to use a history list is to initialize it and to pass its |
| 407 | name to the input functions when you wish. But it is safe to modify the | 413 | name to the input functions when you wish. But it is safe to modify the |
| 408 | list by hand when the minibuffer input functions are not using it. | 414 | list by hand when the minibuffer input functions are not using it. |
| 409 | 415 | ||
| 416 | Here are some of the standard minibuffer history list variables: | ||
| 417 | |||
| 410 | @defvar minibuffer-history | 418 | @defvar minibuffer-history |
| 411 | The default history list for minibuffer history input. | 419 | The default history list for minibuffer history input. |
| 412 | @end defvar | 420 | @end defvar |
| @@ -580,7 +588,7 @@ too short). Both of those begin with the string @samp{foobar}. | |||
| 580 | 588 | ||
| 581 | @defun all-completions string collection &optional predicate nospace | 589 | @defun all-completions string collection &optional predicate nospace |
| 582 | This function returns a list of all possible completions of | 590 | This function returns a list of all possible completions of |
| 583 | @var{string}. The parameters to this function are the same as to | 591 | @var{string}. The arguments to this function are the same as those of |
| 584 | @code{try-completion}. | 592 | @code{try-completion}. |
| 585 | 593 | ||
| 586 | If @var{collection} is a function, it is called with three arguments: | 594 | If @var{collection} is a function, it is called with three arguments: |
| @@ -624,10 +632,7 @@ minibuffer with completion. | |||
| 624 | @defun completing-read prompt collection &optional predicate require-match initial hist default inherit-input-method | 632 | @defun completing-read prompt collection &optional predicate require-match initial hist default inherit-input-method |
| 625 | This function reads a string in the minibuffer, assisting the user by | 633 | This function reads a string in the minibuffer, assisting the user by |
| 626 | providing completion. It activates the minibuffer with prompt | 634 | providing completion. It activates the minibuffer with prompt |
| 627 | @var{prompt}, which must be a string. If @var{initial} is | 635 | @var{prompt}, which must be a string. |
| 628 | non-@code{nil}, @code{completing-read} inserts it into the minibuffer as | ||
| 629 | part of the input. Then it allows the user to edit the input, providing | ||
| 630 | several commands to attempt completion. | ||
| 631 | 636 | ||
| 632 | The actual completion is done by passing @var{collection} and | 637 | The actual completion is done by passing @var{collection} and |
| 633 | @var{predicate} to the function @code{try-completion}. This happens in | 638 | @var{predicate} to the function @code{try-completion}. This happens in |
| @@ -642,7 +647,8 @@ input already in the buffer matches an element of @var{collection}. | |||
| 642 | 647 | ||
| 643 | However, empty input is always permitted, regardless of the value of | 648 | However, empty input is always permitted, regardless of the value of |
| 644 | @var{require-match}; in that case, @code{completing-read} returns | 649 | @var{require-match}; in that case, @code{completing-read} returns |
| 645 | @var{default}. | 650 | @var{default}. The value of @var{default} (if non-@code{nil}) is also |
| 651 | available to the user through the history commands. | ||
| 646 | 652 | ||
| 647 | The user can exit with null input by typing @key{RET} with an empty | 653 | The user can exit with null input by typing @key{RET} with an empty |
| 648 | minibuffer. Then @code{completing-read} returns @code{""}. This is how | 654 | minibuffer. Then @code{completing-read} returns @code{""}. This is how |
| @@ -661,8 +667,10 @@ The argument @var{hist} specifies which history list variable to use for | |||
| 661 | saving the input and for minibuffer history commands. It defaults to | 667 | saving the input and for minibuffer history commands. It defaults to |
| 662 | @code{minibuffer-history}. @xref{Minibuffer History}. | 668 | @code{minibuffer-history}. @xref{Minibuffer History}. |
| 663 | 669 | ||
| 664 | The optional argument @var{default} specifies a default value to return | 670 | If @var{initial} is non-@code{nil}, @code{completing-read} inserts it |
| 665 | if the user enters null input; it should be a string. | 671 | into the minibuffer as part of the input. Then it allows the user to |
| 672 | edit the input, providing several commands to attempt completion. | ||
| 673 | In most cases, we recommend using @var{default}, and not @var{initial}. | ||
| 666 | 674 | ||
| 667 | If the argument @var{inherit-input-method} is non-@code{nil}, then the | 675 | If the argument @var{inherit-input-method} is non-@code{nil}, then the |
| 668 | minibuffer inherits the current input method and the setting of | 676 | minibuffer inherits the current input method and the setting of |
| @@ -750,7 +758,7 @@ bindings: | |||
| 750 | @item @key{TAB} | 758 | @item @key{TAB} |
| 751 | @code{minibuffer-complete} | 759 | @code{minibuffer-complete} |
| 752 | 760 | ||
| 753 | @item @key{LFD} | 761 | @item @kbd{C-j} |
| 754 | @code{minibuffer-complete-and-exit} | 762 | @code{minibuffer-complete-and-exit} |
| 755 | 763 | ||
| 756 | @item @key{RET} | 764 | @item @key{RET} |
| @@ -903,10 +911,10 @@ which @code{commandp} returns @code{t}, and a command name is a symbol | |||
| 903 | for which @code{commandp} returns @code{t}. @xref{Interactive Call}. | 911 | for which @code{commandp} returns @code{t}. @xref{Interactive Call}. |
| 904 | 912 | ||
| 905 | The argument @var{default} specifies what to return if the user enters | 913 | The argument @var{default} specifies what to return if the user enters |
| 906 | null input. It can be a symbol or a string, but the value returned by | 914 | null input. It can be a symbol or a string; if it is a string, |
| 907 | @code{read-command} is always a symbol. If @var{default} is @code{nil}, | 915 | @code{read-command} interns it before returning it. If @var{default} is |
| 908 | that means no default has been specified; then if the user enters null | 916 | @code{nil}, that means no default has been specified; then if the user |
| 909 | input, the return value is @code{nil}. | 917 | enters null input, the return value is @code{nil}. |
| 910 | 918 | ||
| 911 | @example | 919 | @example |
| 912 | (read-command "Command name? ") | 920 | (read-command "Command name? ") |
| @@ -948,10 +956,10 @@ This function reads the name of a user variable and returns it as a | |||
| 948 | symbol. | 956 | symbol. |
| 949 | 957 | ||
| 950 | The argument @var{default} specifies what to return if the user enters | 958 | The argument @var{default} specifies what to return if the user enters |
| 951 | null input. It can be a symbol or a string, but the value returned by | 959 | null input. It can be a symbol or a string; if it is a string, |
| 952 | @code{read-variable} is always a symbol. If @var{default} is | 960 | @code{read-variable} interns it before returning it. If @var{default} |
| 953 | @code{nil}, that means no default has been specified; then if the user | 961 | is @code{nil}, that means no default has been specified; then if the |
| 954 | enters null input, the return value is @code{nil}. | 962 | user enters null input, the return value is @code{nil}. |
| 955 | 963 | ||
| 956 | @example | 964 | @example |
| 957 | @group | 965 | @group |
| @@ -988,21 +996,8 @@ predicate @code{user-variable-p} instead of @code{commandp}: | |||
| 988 | @end example | 996 | @end example |
| 989 | @end defun | 997 | @end defun |
| 990 | 998 | ||
| 991 | @tindex read-coding-system | 999 | See also the functions @code{read-coding-system} and |
| 992 | @defun read-coding-system prompt default | 1000 | @code{read-non-nil-coding-system}, in @ref{Lisp and Coding Systems}. |
| 993 | This function reads a coding system using the minibuffer, prompting with | ||
| 994 | string @var{prompt}, and returns the coding system name as a symbol. If | ||
| 995 | the user tries to enter null input, it asks the user to try again. | ||
| 996 | @xref{Coding Systems}. | ||
| 997 | @end defun | ||
| 998 | |||
| 999 | @tindex read-non-nil-coding-system | ||
| 1000 | @defun read-non-nil-coding-system prompt | ||
| 1001 | This function reads a coding system using the minibuffer, prompting with | ||
| 1002 | string @var{prompt},and returns the coding system name as a symbol. If | ||
| 1003 | the user enters null input, it returns @var{default-coding-system}. | ||
| 1004 | which should be a symbol or a string. @xref{Coding Systems}. | ||
| 1005 | @end defun | ||
| 1006 | 1001 | ||
| 1007 | @node Reading File Names | 1002 | @node Reading File Names |
| 1008 | @subsection Reading File Names | 1003 | @subsection Reading File Names |
| @@ -1037,7 +1032,8 @@ If you specify @var{initial}, that is an initial file name to insert in | |||
| 1037 | the buffer (after with @var{directory}, if that is inserted). In this | 1032 | the buffer (after with @var{directory}, if that is inserted). In this |
| 1038 | case, point goes at the beginning of @var{initial}. The default for | 1033 | case, point goes at the beginning of @var{initial}. The default for |
| 1039 | @var{initial} is @code{nil}---don't insert any file name. To see what | 1034 | @var{initial} is @code{nil}---don't insert any file name. To see what |
| 1040 | @var{initial} does, try the command @kbd{C-x C-v}. | 1035 | @var{initial} does, try the command @kbd{C-x C-v}. @strong{Note:} we |
| 1036 | recommend using @var{default} rather than @var{initial} in most cases. | ||
| 1041 | 1037 | ||
| 1042 | Here is an example: | 1038 | Here is an example: |
| 1043 | 1039 | ||
| @@ -1153,7 +1149,7 @@ string is a unique and exact match already, or @code{nil} if the string | |||
| 1153 | matches no possibility. | 1149 | matches no possibility. |
| 1154 | 1150 | ||
| 1155 | If the string is an exact match for one possibility, but also matches | 1151 | If the string is an exact match for one possibility, but also matches |
| 1156 | other longer possibilities, the function shuold return the string, not | 1152 | other longer possibilities, the function should return the string, not |
| 1157 | @code{t}. | 1153 | @code{t}. |
| 1158 | 1154 | ||
| 1159 | @item | 1155 | @item |
| @@ -1533,15 +1529,14 @@ returns zero. | |||
| 1533 | 1529 | ||
| 1534 | @defopt enable-recursive-minibuffers | 1530 | @defopt enable-recursive-minibuffers |
| 1535 | If this variable is non-@code{nil}, you can invoke commands (such as | 1531 | If this variable is non-@code{nil}, you can invoke commands (such as |
| 1536 | @code{find-file}) that use minibuffers even while in the minibuffer | 1532 | @code{find-file}) that use minibuffers even while the minibuffer window |
| 1537 | window. Such invocation produces a recursive editing level for a new | 1533 | is active. Such invocation produces a recursive editing level for a new |
| 1538 | minibuffer. The outer-level minibuffer is invisible while you are | 1534 | minibuffer. The outer-level minibuffer is invisible while you are |
| 1539 | editing the inner one. | 1535 | editing the inner one. |
| 1540 | 1536 | ||
| 1541 | This variable only affects invoking the minibuffer while the | 1537 | If this variable is @code{nil}, you cannot invoke minibuffer |
| 1542 | minibuffer window is selected. If you switch windows while in the | 1538 | commands when the minibuffer window is active, not even if you switch to |
| 1543 | minibuffer, you can always invoke minibuffer commands while some other | 1539 | another window to do it. |
| 1544 | window is selected. | ||
| 1545 | @end defopt | 1540 | @end defopt |
| 1546 | 1541 | ||
| 1547 | @c Emacs 19 feature | 1542 | @c Emacs 19 feature |
diff --git a/lispref/modes.texi b/lispref/modes.texi index 2e2f1c3bb29..dbdefb5a2d3 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi | |||
| @@ -41,7 +41,7 @@ This mode has no mode-specific definitions or variable settings, so each | |||
| 41 | Emacs command behaves in its default manner, and each option is in its | 41 | Emacs command behaves in its default manner, and each option is in its |
| 42 | default state. All other major modes redefine various keys and options. | 42 | default state. All other major modes redefine various keys and options. |
| 43 | For example, Lisp Interaction mode provides special key bindings for | 43 | For example, Lisp Interaction mode provides special key bindings for |
| 44 | @key{LFD} (@code{eval-print-last-sexp}), @key{TAB} | 44 | @kbd{C-j} (@code{eval-print-last-sexp}), @key{TAB} |
| 45 | (@code{lisp-indent-line}), and other keys. | 45 | (@code{lisp-indent-line}), and other keys. |
| 46 | 46 | ||
| 47 | When you need to write several editing commands to help you perform a | 47 | When you need to write several editing commands to help you perform a |
| @@ -58,16 +58,16 @@ Modes}). For example, Rmail Edit mode, which is in | |||
| 58 | Text mode except that it provides three additional commands. Its | 58 | Text mode except that it provides three additional commands. Its |
| 59 | definition is distinct from that of Text mode, but was derived from it. | 59 | definition is distinct from that of Text mode, but was derived from it. |
| 60 | 60 | ||
| 61 | Rmail Edit mode is an example of a case where one piece of text is put | 61 | Rmail Edit mode offers an example of changing the major mode |
| 62 | temporarily into a different major mode so it can be edited in a | 62 | temporarily for a buffer, so it can be edited in a different way (with |
| 63 | different way (with ordinary Emacs commands rather than Rmail). In such | 63 | ordinary Emacs commands rather than Rmail). In such cases, the |
| 64 | cases, the temporary major mode usually has a command to switch back to | 64 | temporary major mode usually has a command to switch back to the |
| 65 | the buffer's usual mode (Rmail mode, in this case). You might be | 65 | buffer's usual mode (Rmail mode, in this case). You might be tempted to |
| 66 | tempted to present the temporary redefinitions inside a recursive edit | 66 | present the temporary redefinitions inside a recursive edit and restore |
| 67 | and restore the usual ones when the user exits; but this is a bad idea | 67 | the usual ones when the user exits; but this is a bad idea because it |
| 68 | because it constrains the user's options when it is done in more than | 68 | constrains the user's options when it is done in more than one buffer: |
| 69 | one buffer: recursive edits must be exited most-recently-entered first. | 69 | recursive edits must be exited most-recently-entered first. Using an |
| 70 | Using alternative major modes avoids this limitation. @xref{Recursive | 70 | alternative major mode avoids this limitation. @xref{Recursive |
| 71 | Editing}. | 71 | Editing}. |
| 72 | 72 | ||
| 73 | The standard GNU Emacs Lisp library directory contains the code for | 73 | The standard GNU Emacs Lisp library directory contains the code for |
| @@ -98,8 +98,8 @@ define a new major mode: | |||
| 98 | @item | 98 | @item |
| 99 | Define a command whose name ends in @samp{-mode}, with no arguments, | 99 | Define a command whose name ends in @samp{-mode}, with no arguments, |
| 100 | that switches to the new mode in the current buffer. This command | 100 | that switches to the new mode in the current buffer. This command |
| 101 | should set up the keymap, syntax table, and local variables in an | 101 | should set up the keymap, syntax table, and buffer-local variables in an |
| 102 | existing buffer without changing the buffer's text. | 102 | existing buffer, without changing the buffer's contents. |
| 103 | 103 | ||
| 104 | @item | 104 | @item |
| 105 | Write a documentation string for this command that describes the | 105 | Write a documentation string for this command that describes the |
| @@ -114,8 +114,8 @@ Documentation}. | |||
| 114 | 114 | ||
| 115 | @item | 115 | @item |
| 116 | The major mode command should start by calling | 116 | The major mode command should start by calling |
| 117 | @code{kill-all-local-variables}. This is what gets rid of the local | 117 | @code{kill-all-local-variables}. This is what gets rid of the |
| 118 | variables of the major mode previously in effect. | 118 | buffer-local variables of the major mode previously in effect. |
| 119 | 119 | ||
| 120 | @item | 120 | @item |
| 121 | The major mode command should set the variable @code{major-mode} to the | 121 | The major mode command should set the variable @code{major-mode} to the |
| @@ -124,8 +124,8 @@ which documentation to print. | |||
| 124 | 124 | ||
| 125 | @item | 125 | @item |
| 126 | The major mode command should set the variable @code{mode-name} to the | 126 | The major mode command should set the variable @code{mode-name} to the |
| 127 | ``pretty'' name of the mode, as a string. This appears in the mode | 127 | ``pretty'' name of the mode, as a string. This string appears in the |
| 128 | line. | 128 | mode line. |
| 129 | 129 | ||
| 130 | @item | 130 | @item |
| 131 | @cindex functions in modes | 131 | @cindex functions in modes |
| @@ -137,11 +137,11 @@ of it if the name is long). @xref{Coding Conventions}. | |||
| 137 | @item | 137 | @item |
| 138 | @cindex keymaps in modes | 138 | @cindex keymaps in modes |
| 139 | The major mode should usually have its own keymap, which is used as the | 139 | The major mode should usually have its own keymap, which is used as the |
| 140 | local keymap in all buffers in that mode. The major mode function | 140 | local keymap in all buffers in that mode. The major mode command should |
| 141 | should call @code{use-local-map} to install this local map. | 141 | call @code{use-local-map} to install this local map. @xref{Active |
| 142 | @xref{Active Keymaps}, for more information. | 142 | Keymaps}, for more information. |
| 143 | 143 | ||
| 144 | This keymap should be kept in a global variable named | 144 | This keymap should be stored permanently in a global variable named |
| 145 | @code{@var{modename}-mode-map}. Normally the library that defines the | 145 | @code{@var{modename}-mode-map}. Normally the library that defines the |
| 146 | mode sets this variable. | 146 | mode sets this variable. |
| 147 | 147 | ||
| @@ -150,7 +150,7 @@ up the mode's keymap variable. | |||
| 150 | 150 | ||
| 151 | @item | 151 | @item |
| 152 | The key sequences bound in a major mode keymap should usually start with | 152 | The key sequences bound in a major mode keymap should usually start with |
| 153 | @kbd{C-c}, followed by a control-character, a digit, or @kbd{@{}, | 153 | @kbd{C-c}, followed by a control character, a digit, or @kbd{@{}, |
| 154 | @kbd{@}}, @kbd{<}, @kbd{>}, @kbd{:} or @kbd{;}. The other punctuation | 154 | @kbd{@}}, @kbd{<}, @kbd{>}, @kbd{:} or @kbd{;}. The other punctuation |
| 155 | characters are reserved for minor modes, and ordinary letters are | 155 | characters are reserved for minor modes, and ordinary letters are |
| 156 | reserved for users. | 156 | reserved for users. |
| @@ -186,23 +186,20 @@ a variable named @code{@var{modename}-mode-abbrev-table}. @xref{Abbrev | |||
| 186 | Tables}. | 186 | Tables}. |
| 187 | 187 | ||
| 188 | @item | 188 | @item |
| 189 | @vindex font-lock-defaults | ||
| 190 | The mode should specify how to do highlighting for Font Lock mode, by | 189 | The mode should specify how to do highlighting for Font Lock mode, by |
| 191 | setting up a buffer-local value for the variable | 190 | setting up a buffer-local value for the variable |
| 192 | @code{font-lock-defaults}. | 191 | @code{font-lock-defaults} (@pxref{Font Lock Mode}). |
| 193 | 192 | ||
| 194 | @item | 193 | @item |
| 195 | @vindex imenu-generic-expression | ||
| 196 | @vindex imenu-create-index-function | ||
| 197 | The mode should specify how Imenu should find the definitions or | 194 | The mode should specify how Imenu should find the definitions or |
| 198 | sections of a buffer, by setting up a buffer-local value for the | 195 | sections of a buffer, by setting up a buffer-local value for the |
| 199 | variable @code{imenu-generic-expression} or | 196 | variable @code{imenu-generic-expression} or |
| 200 | @code{imenu-create-index-function}. | 197 | @code{imenu-create-index-function} (@pxref{Imenu}). |
| 201 | 198 | ||
| 202 | @item | 199 | @item |
| 203 | Use @code{defvar} to set mode-related variables, so that they are not | 200 | Use @code{defvar} or @code{defcustom} to set mode-related variables, so |
| 204 | reinitialized if they already have a value. (Such reinitialization | 201 | that they are not reinitialized if they already have a value. (Such |
| 205 | could discard customizations made by the user.) | 202 | reinitialization could discard customizations made by the user.) |
| 206 | 203 | ||
| 207 | @item | 204 | @item |
| 208 | @cindex buffer-local variables in modes | 205 | @cindex buffer-local variables in modes |
| @@ -213,7 +210,7 @@ variable local to every buffer in which it is subsequently set, which | |||
| 213 | would affect buffers that do not use this mode. It is undesirable for a | 210 | would affect buffers that do not use this mode. It is undesirable for a |
| 214 | mode to have such global effects. @xref{Buffer-Local Variables}. | 211 | mode to have such global effects. @xref{Buffer-Local Variables}. |
| 215 | 212 | ||
| 216 | It's ok to use @code{make-variable-buffer-local}, if you wish, for a | 213 | It's OK to use @code{make-variable-buffer-local}, if you wish, for a |
| 217 | variable used only within a single Lisp package. | 214 | variable used only within a single Lisp package. |
| 218 | 215 | ||
| 219 | @item | 216 | @item |
| @@ -234,7 +231,7 @@ or it may run them earlier. | |||
| 234 | @item | 231 | @item |
| 235 | If something special should be done if the user switches a buffer from | 232 | If something special should be done if the user switches a buffer from |
| 236 | this mode to any other major mode, this mode can set up a buffer-local | 233 | this mode to any other major mode, this mode can set up a buffer-local |
| 237 | value for @code{change-major-mode-hook} (see below). | 234 | value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}). |
| 238 | 235 | ||
| 239 | @item | 236 | @item |
| 240 | If this mode is appropriate only for specially-prepared text, then the | 237 | If this mode is appropriate only for specially-prepared text, then the |
| @@ -273,15 +270,6 @@ that they may be evaluated more than once without adverse consequences. | |||
| 273 | Even if you never load the file more than once, someone else will. | 270 | Even if you never load the file more than once, someone else will. |
| 274 | @end itemize | 271 | @end itemize |
| 275 | 272 | ||
| 276 | @defvar change-major-mode-hook | ||
| 277 | The function @code{kill-all-local-variables} runs this normal hook | ||
| 278 | before it does anything else. This gives major modes a way to arrange | ||
| 279 | for something special to be done if the user switches to a different | ||
| 280 | major mode. For best results, make this variable buffer-local, so that | ||
| 281 | it will disappear after doing its job and will not interfere with the | ||
| 282 | subsequent major mode. @xref{Hooks}. | ||
| 283 | @end defvar | ||
| 284 | |||
| 285 | @node Example Major Modes | 273 | @node Example Major Modes |
| 286 | @subsection Major Mode Examples | 274 | @subsection Major Mode Examples |
| 287 | 275 | ||
| @@ -328,21 +316,28 @@ the conventions listed above: | |||
| 328 | @smallexample | 316 | @smallexample |
| 329 | @group | 317 | @group |
| 330 | (defun text-mode () | 318 | (defun text-mode () |
| 331 | "Major mode for editing text intended for humans to read. | 319 | "Major mode for editing text intended for humans to read@enddots{} |
| 332 | Special commands: \\@{text-mode-map@} | 320 | Special commands: \\@{text-mode-map@} |
| 333 | @end group | 321 | @end group |
| 334 | @group | 322 | @group |
| 335 | Turning on text-mode runs the hook `text-mode-hook'." | 323 | Turning on text-mode runs the hook `text-mode-hook'." |
| 336 | (interactive) | 324 | (interactive) |
| 337 | (kill-all-local-variables) | 325 | (kill-all-local-variables) |
| 326 | (use-local-map text-mode-map) | ||
| 338 | @end group | 327 | @end group |
| 339 | @group | 328 | @group |
| 340 | (use-local-map text-mode-map) ; @r{This provides the local keymap.} | ||
| 341 | (setq mode-name "Text") ; @r{This name goes into the mode line.} | ||
| 342 | (setq major-mode 'text-mode) ; @r{This is how @code{describe-mode}} | ||
| 343 | ; @r{finds the doc string to print.} | ||
| 344 | (setq local-abbrev-table text-mode-abbrev-table) | 329 | (setq local-abbrev-table text-mode-abbrev-table) |
| 345 | (set-syntax-table text-mode-syntax-table) | 330 | (set-syntax-table text-mode-syntax-table) |
| 331 | @end group | ||
| 332 | @group | ||
| 333 | (make-local-variable 'paragraph-start) | ||
| 334 | (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter)) | ||
| 335 | (make-local-variable 'paragraph-separate) | ||
| 336 | (setq paragraph-separate paragraph-start) | ||
| 337 | @end group | ||
| 338 | @group | ||
| 339 | (setq mode-name "Text") | ||
| 340 | (setq major-mode 'text-mode) | ||
| 346 | (run-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to} | 341 | (run-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to} |
| 347 | ; @r{customize the mode with a hook.} | 342 | ; @r{customize the mode with a hook.} |
| 348 | @end group | 343 | @end group |
| @@ -401,27 +396,8 @@ mode functions: | |||
| 401 | @smallexample | 396 | @smallexample |
| 402 | @group | 397 | @group |
| 403 | (defun lisp-mode-variables (lisp-syntax) | 398 | (defun lisp-mode-variables (lisp-syntax) |
| 404 | ;; @r{The @code{lisp-syntax} argument is @code{nil} in Emacs Lisp mode,} | ||
| 405 | ;; @r{and @code{t} in the other two Lisp modes.} | ||
| 406 | (cond (lisp-syntax | 399 | (cond (lisp-syntax |
| 407 | (if (not lisp-mode-syntax-table) | 400 | (set-syntax-table lisp-mode-syntax-table))) |
| 408 | ;; @r{The Emacs Lisp mode syntax table always exists, but} | ||
| 409 | ;; @r{the Lisp Mode syntax table is created the first time a} | ||
| 410 | ;; @r{mode that needs it is called. This is to save space.} | ||
| 411 | @end group | ||
| 412 | @group | ||
| 413 | (progn (setq lisp-mode-syntax-table | ||
| 414 | (copy-syntax-table emacs-lisp-mode-syntax-table)) | ||
| 415 | ;; @r{Change some entries for Lisp mode.} | ||
| 416 | (modify-syntax-entry ?\| "\" " | ||
| 417 | lisp-mode-syntax-table) | ||
| 418 | (modify-syntax-entry ?\[ "_ " | ||
| 419 | lisp-mode-syntax-table) | ||
| 420 | (modify-syntax-entry ?\] "_ " | ||
| 421 | lisp-mode-syntax-table))) | ||
| 422 | @end group | ||
| 423 | @group | ||
| 424 | (set-syntax-table lisp-mode-syntax-table))) | ||
| 425 | (setq local-abbrev-table lisp-mode-abbrev-table) | 401 | (setq local-abbrev-table lisp-mode-abbrev-table) |
| 426 | @dots{}) | 402 | @dots{}) |
| 427 | @end group | 403 | @end group |
| @@ -438,9 +414,9 @@ rest of @code{lisp-mode-variables}. | |||
| 438 | @smallexample | 414 | @smallexample |
| 439 | @group | 415 | @group |
| 440 | (make-local-variable 'paragraph-start) | 416 | (make-local-variable 'paragraph-start) |
| 441 | ;; @r{Having @samp{^} is not clean, but @code{page-delimiter}} | 417 | (setq paragraph-start (concat page-delimiter "\\|$" )) |
| 442 | ;; @r{has them too, and removing those is a pain.} | 418 | (make-local-variable 'paragraph-separate) |
| 443 | (setq paragraph-start (concat "^$\\|" page-delimiter)) | 419 | (setq paragraph-separate paragraph-start) |
| 444 | @dots{} | 420 | @dots{} |
| 445 | @end group | 421 | @end group |
| 446 | @group | 422 | @group |
| @@ -452,35 +428,36 @@ rest of @code{lisp-mode-variables}. | |||
| 452 | Each of the different Lisp modes has a slightly different keymap. For | 428 | Each of the different Lisp modes has a slightly different keymap. For |
| 453 | example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other | 429 | example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other |
| 454 | Lisp modes do not. However, all Lisp modes have some commands in | 430 | Lisp modes do not. However, all Lisp modes have some commands in |
| 455 | common. The following function adds these common commands to a given | 431 | common. The following code sets up the common commands: |
| 456 | keymap. | ||
| 457 | 432 | ||
| 458 | @smallexample | 433 | @smallexample |
| 459 | @group | 434 | @group |
| 460 | (defun lisp-mode-commands (map) | 435 | (defvar shared-lisp-mode-map () |
| 461 | (define-key map "\e\C-q" 'indent-sexp) | 436 | "Keymap for commands shared by all sorts of Lisp modes.") |
| 462 | (define-key map "\177" 'backward-delete-char-untabify) | 437 | |
| 463 | (define-key map "\t" 'lisp-indent-line)) | 438 | (if shared-lisp-mode-map |
| 439 | () | ||
| 440 | (setq shared-lisp-mode-map (make-sparse-keymap)) | ||
| 441 | (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp) | ||
| 442 | (define-key shared-lisp-mode-map "\177" | ||
| 443 | 'backward-delete-char-untabify)) | ||
| 464 | @end group | 444 | @end group |
| 465 | @end smallexample | 445 | @end smallexample |
| 466 | 446 | ||
| 467 | Here is an example of using @code{lisp-mode-commands} to initialize a | 447 | @noindent |
| 468 | keymap, as part of the code for Emacs Lisp mode. First we declare a | 448 | And here is the code to set up the keymap for Lisp mode: |
| 469 | variable with @code{defvar} to hold the mode-specific keymap. When this | ||
| 470 | @code{defvar} executes, it sets the variable to @code{nil} if it was | ||
| 471 | void. Then we set up the keymap if the variable is @code{nil}. | ||
| 472 | |||
| 473 | This code avoids changing the keymap or the variable if it is already | ||
| 474 | set up. This lets the user customize the keymap. | ||
| 475 | 449 | ||
| 476 | @smallexample | 450 | @smallexample |
| 477 | @group | 451 | @group |
| 478 | (defvar emacs-lisp-mode-map () "") | 452 | (defvar lisp-mode-map () |
| 479 | (if emacs-lisp-mode-map | 453 | "Keymap for ordinary Lisp mode@enddots{}") |
| 454 | |||
| 455 | (if lisp-mode-map | ||
| 480 | () | 456 | () |
| 481 | (setq emacs-lisp-mode-map (make-sparse-keymap)) | 457 | (setq lisp-mode-map (make-sparse-keymap)) |
| 482 | (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun) | 458 | (set-keymap-parent lisp-mode-map shared-lisp-mode-map) |
| 483 | (lisp-mode-commands emacs-lisp-mode-map)) | 459 | (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun) |
| 460 | (define-key lisp-mode-map "\C-c\C-z" 'run-lisp)) | ||
| 484 | @end group | 461 | @end group |
| 485 | @end smallexample | 462 | @end smallexample |
| 486 | 463 | ||
| @@ -489,26 +466,33 @@ Emacs Lisp mode. | |||
| 489 | 466 | ||
| 490 | @smallexample | 467 | @smallexample |
| 491 | @group | 468 | @group |
| 492 | (defun emacs-lisp-mode () | 469 | (defun lisp-mode () |
| 493 | "Major mode for editing Lisp code to run in Emacs. | 470 | "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. |
| 494 | Commands: | 471 | Commands: |
| 495 | Delete converts tabs to spaces as it moves back. | 472 | Delete converts tabs to spaces as it moves back. |
| 496 | Blank lines separate paragraphs. Semicolons start comments. | 473 | Blank lines separate paragraphs. Semicolons start comments. |
| 497 | \\@{emacs-lisp-mode-map@} | 474 | \\@{lisp-mode-map@} |
| 475 | Note that `run-lisp' may be used either to start an inferior Lisp job | ||
| 476 | or to switch back to an existing one. | ||
| 498 | @end group | 477 | @end group |
| 478 | |||
| 499 | @group | 479 | @group |
| 500 | Entry to this mode runs the hook `emacs-lisp-mode-hook'." | 480 | Entry to this mode calls the value of `lisp-mode-hook' |
| 481 | if that value is non-nil." | ||
| 501 | (interactive) | 482 | (interactive) |
| 502 | (kill-all-local-variables) | 483 | (kill-all-local-variables) |
| 503 | (use-local-map emacs-lisp-mode-map) ; @r{This provides the local keymap.} | ||
| 504 | (set-syntax-table emacs-lisp-mode-syntax-table) | ||
| 505 | @end group | 484 | @end group |
| 506 | @group | 485 | @group |
| 507 | (setq major-mode 'emacs-lisp-mode) ; @r{This is how @code{describe-mode}} | 486 | (use-local-map lisp-mode-map) ; @r{Select the mode's keymap.} |
| 487 | (setq major-mode 'lisp-mode) ; @r{This is how @code{describe-mode}} | ||
| 508 | ; @r{finds out what to describe.} | 488 | ; @r{finds out what to describe.} |
| 509 | (setq mode-name "Emacs-Lisp") ; @r{This goes into the mode line.} | 489 | (setq mode-name "Lisp") ; @r{This goes into the mode line.} |
| 510 | (lisp-mode-variables nil) ; @r{This defines various variables.} | 490 | (lisp-mode-variables t) ; @r{This defines various variables.} |
| 511 | (run-hooks 'emacs-lisp-mode-hook)) ; @r{This permits the user to use a} | 491 | @end group |
| 492 | @group | ||
| 493 | (setq imenu-case-fold-search t) | ||
| 494 | (set-syntax-table lisp-mode-syntax-table) | ||
| 495 | (run-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a} | ||
| 512 | ; @r{hook to customize the mode.} | 496 | ; @r{hook to customize the mode.} |
| 513 | @end group | 497 | @end group |
| 514 | @end smallexample | 498 | @end smallexample |
| @@ -518,7 +502,7 @@ Entry to this mode runs the hook `emacs-lisp-mode-hook'." | |||
| 518 | 502 | ||
| 519 | Based on information in the file name or in the file itself, Emacs | 503 | Based on information in the file name or in the file itself, Emacs |
| 520 | automatically selects a major mode for the new buffer when a file is | 504 | automatically selects a major mode for the new buffer when a file is |
| 521 | visited. | 505 | visited. It also processes local variables specified in the file text. |
| 522 | 506 | ||
| 523 | @deffn Command fundamental-mode | 507 | @deffn Command fundamental-mode |
| 524 | Fundamental mode is a major mode that is not specialized for anything | 508 | Fundamental mode is a major mode that is not specialized for anything |
| @@ -531,22 +515,22 @@ state of Emacs.) | |||
| 531 | @end deffn | 515 | @end deffn |
| 532 | 516 | ||
| 533 | @deffn Command normal-mode &optional find-file | 517 | @deffn Command normal-mode &optional find-file |
| 534 | This function establishes the proper major mode and local variable | 518 | This function establishes the proper major mode and buffer-local variable |
| 535 | bindings for the current buffer. First it calls @code{set-auto-mode}, | 519 | bindings for the current buffer. First it calls @code{set-auto-mode}, |
| 536 | then it runs @code{hack-local-variables} to parse, and bind or | 520 | then it runs @code{hack-local-variables} to parse, and bind or |
| 537 | evaluate as appropriate, any local variables. | 521 | evaluate as appropriate, the file's local variables. |
| 538 | 522 | ||
| 539 | If the @var{find-file} argument to @code{normal-mode} is | 523 | If the @var{find-file} argument to @code{normal-mode} is non-@code{nil}, |
| 540 | non-@code{nil}, @code{normal-mode} assumes that the @code{find-file} | 524 | @code{normal-mode} assumes that the @code{find-file} function is calling |
| 541 | function is calling it. In this case, it may process a local variables | 525 | it. In this case, it may process a local variables list at the end of |
| 542 | list at the end of the file and in the @samp{-*-} line. The variable | 526 | the file and in the @samp{-*-} line. The variable |
| 543 | @code{enable-local-variables} controls whether to do so. | 527 | @code{enable-local-variables} controls whether to do so. @xref{File |
| 528 | variables, , Local Variables in Files, emacs, The GNU Emacs Manual}, for | ||
| 529 | the syntax of the local variables section of a file. | ||
| 544 | 530 | ||
| 545 | If you run @code{normal-mode} interactively, the argument | 531 | If you run @code{normal-mode} interactively, the argument |
| 546 | @var{find-file} is normally @code{nil}. In this case, | 532 | @var{find-file} is normally @code{nil}. In this case, |
| 547 | @code{normal-mode} unconditionally processes any local variables list. | 533 | @code{normal-mode} unconditionally processes any local variables list. |
| 548 | @xref{File variables, , Local Variables in Files, emacs, The GNU Emacs | ||
| 549 | Manual}, for the syntax of the local variables section of a file. | ||
| 550 | 534 | ||
| 551 | @cindex file mode specification error | 535 | @cindex file mode specification error |
| 552 | @code{normal-mode} uses @code{condition-case} around the call to the | 536 | @code{normal-mode} uses @code{condition-case} around the call to the |
| @@ -563,7 +547,7 @@ ask the user what to do for each file. The default value is @code{t}. | |||
| 563 | 547 | ||
| 564 | @defvar ignored-local-variables | 548 | @defvar ignored-local-variables |
| 565 | This variable holds a list of variables that should not be | 549 | This variable holds a list of variables that should not be |
| 566 | set by a local variables list. Any value specified | 550 | set by a file's local variables list. Any value specified |
| 567 | for one of these variables is ignored. | 551 | for one of these variables is ignored. |
| 568 | @end defvar | 552 | @end defvar |
| 569 | 553 | ||
| @@ -583,17 +567,17 @@ the user what to do for each file. The default value is @code{maybe}. | |||
| 583 | current buffer. It may base its decision on the value of the @w{@samp{-*-}} | 567 | current buffer. It may base its decision on the value of the @w{@samp{-*-}} |
| 584 | line, on the visited file name (using @code{auto-mode-alist}), on the | 568 | line, on the visited file name (using @code{auto-mode-alist}), on the |
| 585 | @w{@samp{#!}} line (using @code{interpreter-mode-alist}), or on the | 569 | @w{@samp{#!}} line (using @code{interpreter-mode-alist}), or on the |
| 586 | value of a local variable. However, this function does not look for | 570 | file's local variables list. However, this function does not look for |
| 587 | the @samp{mode:} local variable near the end of a file; the | 571 | the @samp{mode:} local variable near the end of a file; the |
| 588 | @code{hack-local-variables} function does that. @xref{Choosing Modes, , | 572 | @code{hack-local-variables} function does that. @xref{Choosing Modes, , |
| 589 | How Major Modes are Chosen, emacs, The GNU Emacs Manual}. | 573 | How Major Modes are Chosen, emacs, The GNU Emacs Manual}. |
| 590 | @end defun | 574 | @end defun |
| 591 | 575 | ||
| 592 | @defopt default-major-mode | 576 | @defopt default-major-mode |
| 593 | This variable holds the default major mode for new buffers. The | 577 | This variable holds the default major mode for new buffers. The |
| 594 | standard value is @code{fundamental-mode}. | 578 | standard value is @code{fundamental-mode}. |
| 595 | 579 | ||
| 596 | If the value of @code{default-major-mode} is @code{nil}, Emacs uses | 580 | If the value of @code{default-major-mode} is @code{nil}, Emacs uses |
| 597 | the (previously) current buffer's major mode for the major mode of a new | 581 | the (previously) current buffer's major mode for the major mode of a new |
| 598 | buffer. However, if that major mode symbol has a @code{mode-class} | 582 | buffer. However, if that major mode symbol has a @code{mode-class} |
| 599 | property with value @code{special}, then it is not used for new buffers; | 583 | property with value @code{special}, then it is not used for new buffers; |
| @@ -631,7 +615,7 @@ For example, | |||
| 631 | 615 | ||
| 632 | @smallexample | 616 | @smallexample |
| 633 | @group | 617 | @group |
| 634 | (("^/tmp/fol/" . text-mode) | 618 | (("\\`/tmp/fol/" . text-mode) |
| 635 | ("\\.texinfo\\'" . texinfo-mode) | 619 | ("\\.texinfo\\'" . texinfo-mode) |
| 636 | ("\\.texi\\'" . texinfo-mode) | 620 | ("\\.texi\\'" . texinfo-mode) |
| 637 | @end group | 621 | @end group |
| @@ -651,12 +635,10 @@ the proper major mode for most files. | |||
| 651 | If an element of @code{auto-mode-alist} has the form @code{(@var{regexp} | 635 | If an element of @code{auto-mode-alist} has the form @code{(@var{regexp} |
| 652 | @var{function} t)}, then after calling @var{function}, Emacs searches | 636 | @var{function} t)}, then after calling @var{function}, Emacs searches |
| 653 | @code{auto-mode-alist} again for a match against the portion of the file | 637 | @code{auto-mode-alist} again for a match against the portion of the file |
| 654 | name that did not match before. | 638 | name that did not match before. This feature is useful for |
| 655 | 639 | uncompression packages: an entry of the form @code{("\\.gz\\'" | |
| 656 | This match-again feature is useful for uncompression packages: an entry | 640 | @var{function} t)} can uncompress the file and then put the uncompressed |
| 657 | of the form @code{("\\.gz\\'" @var{function} t)} can uncompress the file | 641 | file in the proper mode according to the name sans @samp{.gz}. |
| 658 | and then put the uncompressed file in the proper mode according to the | ||
| 659 | name sans @samp{.gz}. | ||
| 660 | 642 | ||
| 661 | Here is an example of how to prepend several pattern pairs to | 643 | Here is an example of how to prepend several pattern pairs to |
| 662 | @code{auto-mode-alist}. (You might use this sort of expression in your | 644 | @code{auto-mode-alist}. (You might use this sort of expression in your |
| @@ -691,10 +673,10 @@ not indicate which major mode to use. | |||
| 691 | @end defvar | 673 | @end defvar |
| 692 | 674 | ||
| 693 | @defun hack-local-variables &optional force | 675 | @defun hack-local-variables &optional force |
| 694 | This function parses, and binds or evaluates as appropriate, any local | 676 | This function parses, and binds or evaluates as appropriate, any local |
| 695 | variables for the current buffer. | 677 | variables specified by the contents of the current buffer. |
| 696 | 678 | ||
| 697 | The handling of @code{enable-local-variables} documented for | 679 | The handling of @code{enable-local-variables} documented for |
| 698 | @code{normal-mode} actually takes place here. The argument @var{force} | 680 | @code{normal-mode} actually takes place here. The argument @var{force} |
| 699 | usually comes from the argument @var{find-file} given to | 681 | usually comes from the argument @var{find-file} given to |
| 700 | @code{normal-mode}. | 682 | @code{normal-mode}. |
| @@ -797,11 +779,11 @@ Here is a hypothetical example: | |||
| 797 | A @dfn{minor mode} provides features that users may enable or disable | 779 | A @dfn{minor mode} provides features that users may enable or disable |
| 798 | independently of the choice of major mode. Minor modes can be enabled | 780 | independently of the choice of major mode. Minor modes can be enabled |
| 799 | individually or in combination. Minor modes would be better named | 781 | individually or in combination. Minor modes would be better named |
| 800 | ``Generally available, optional feature modes'' except that such a name is | 782 | ``generally available, optional feature modes,'' except that such a name |
| 801 | unwieldy. | 783 | would be unwieldy. |
| 802 | 784 | ||
| 803 | A minor mode is not usually a modification of single major mode. For | 785 | A minor mode is not usually a modification of single major mode. For |
| 804 | example, Auto Fill mode may be used in any major mode that permits text | 786 | example, Auto Fill mode works with any major mode that permits text |
| 805 | insertion. To be general, a minor mode must be effectively independent | 787 | insertion. To be general, a minor mode must be effectively independent |
| 806 | of the things major modes do. | 788 | of the things major modes do. |
| 807 | 789 | ||
| @@ -838,10 +820,14 @@ minor modes. | |||
| 838 | @itemize @bullet | 820 | @itemize @bullet |
| 839 | @item | 821 | @item |
| 840 | @cindex mode variable | 822 | @cindex mode variable |
| 841 | Make a variable whose name ends in @samp{-mode} to represent the minor | 823 | Make a variable whose name ends in @samp{-mode} to control the minor |
| 842 | mode. Its value should enable or disable the mode (@code{nil} to | 824 | mode. We call this the @dfn{mode variable}. The minor mode command |
| 843 | disable; anything else to enable.) We call this the @dfn{mode | 825 | should set this variable (@code{nil} to disable; anything else to |
| 844 | variable}. | 826 | enable.) |
| 827 | |||
| 828 | If it is possible, implement the mode so that setting the variable | ||
| 829 | automatically enables or disables the mode. Then the minor mode command | ||
| 830 | does not need to do anything except the variable. | ||
| 845 | 831 | ||
| 846 | This variable is used in conjunction with the @code{minor-mode-alist} to | 832 | This variable is used in conjunction with the @code{minor-mode-alist} to |
| 847 | display the minor mode name in the mode line. It can also enable | 833 | display the minor mode name in the mode line. It can also enable |
| @@ -877,8 +863,8 @@ enable or disable the minor mode based on the raw prefix argument value. | |||
| 877 | 863 | ||
| 878 | @item | 864 | @item |
| 879 | Add an element to @code{minor-mode-alist} for each minor mode | 865 | Add an element to @code{minor-mode-alist} for each minor mode |
| 880 | (@pxref{Mode Line Variables}). This element should be a list of the | 866 | (@pxref{Mode Line Variables}), if you want to indicate the minor mode in |
| 881 | following form: | 867 | the mode line. This element should be a list of the following form: |
| 882 | 868 | ||
| 883 | @smallexample | 869 | @smallexample |
| 884 | (@var{mode-variable} @var{string}) | 870 | (@var{mode-variable} @var{string}) |
| @@ -956,9 +942,8 @@ specifying bindings in this form: | |||
| 956 | Here is an example of using @code{easy-mmode-define-minor-mode}: | 942 | Here is an example of using @code{easy-mmode-define-minor-mode}: |
| 957 | 943 | ||
| 958 | @smallexample | 944 | @smallexample |
| 959 | (easy-mmode-define-minor-mode | 945 | (easy-mmode-define-minor-mode hungry-mode |
| 960 | hungry-mode | 946 | "Toggle Hungry mode. |
| 961 | "Toggle Hungry mode. | ||
| 962 | With no argument, this command toggles the mode. | 947 | With no argument, this command toggles the mode. |
| 963 | Non-null prefix argument turns on the mode. | 948 | Non-null prefix argument turns on the mode. |
| 964 | Null prefix argument turns off the mode. | 949 | Null prefix argument turns off the mode. |
| @@ -986,11 +971,6 @@ which indicates whether the mode is enabled, and a variable named | |||
| 986 | mode is enabled. It initializes the keymap with key bindings for | 971 | mode is enabled. It initializes the keymap with key bindings for |
| 987 | @kbd{C-@key{DEL}} and @kbd{C-M-@key{DEL}}. | 972 | @kbd{C-@key{DEL}} and @kbd{C-M-@key{DEL}}. |
| 988 | 973 | ||
| 989 | The command @code{hungry-mode} also runs three hooks: | ||
| 990 | @code{hungry-mode-on-hook} when enabling Hungry mode, | ||
| 991 | @code{hungry-mode-off-hook} when disabling the mode, and | ||
| 992 | @code{hungry-mode-hook} in both of those cases. | ||
| 993 | |||
| 994 | @node Mode Line Format | 974 | @node Mode Line Format |
| 995 | @section Mode Line Format | 975 | @section Mode Line Format |
| 996 | @cindex mode line | 976 | @cindex mode line |
| @@ -1009,8 +989,8 @@ minor modes. | |||
| 1009 | @code{mode-line-format} is a buffer-local variable that holds a | 989 | @code{mode-line-format} is a buffer-local variable that holds a |
| 1010 | template used to display the mode line of the current buffer. All | 990 | template used to display the mode line of the current buffer. All |
| 1011 | windows for the same buffer use the same @code{mode-line-format} and | 991 | windows for the same buffer use the same @code{mode-line-format} and |
| 1012 | their mode lines appear the same (except for scrolling percentages and | 992 | their mode lines appear the same (except for scrolling percentages, and |
| 1013 | line numbers). | 993 | line and column numbers). |
| 1014 | 994 | ||
| 1015 | The mode line of a window is normally updated whenever a different | 995 | The mode line of a window is normally updated whenever a different |
| 1016 | buffer is shown in the window, or when the buffer's modified-status | 996 | buffer is shown in the window, or when the buffer's modified-status |
| @@ -1119,14 +1099,16 @@ modes) via changes to those variables remain effective. | |||
| 1119 | 1099 | ||
| 1120 | @cindex Shell mode @code{mode-line-format} | 1100 | @cindex Shell mode @code{mode-line-format} |
| 1121 | Here is an example of a @code{mode-line-format} that might be | 1101 | Here is an example of a @code{mode-line-format} that might be |
| 1122 | useful for @code{shell-mode}, since it contains the hostname and default | 1102 | useful for @code{shell-mode}, since it contains the host name and default |
| 1123 | directory. | 1103 | directory. |
| 1124 | 1104 | ||
| 1125 | @example | 1105 | @example |
| 1126 | @group | 1106 | @group |
| 1127 | (setq mode-line-format | 1107 | (setq mode-line-format |
| 1128 | (list "" | 1108 | (list "-" |
| 1109 | 'mode-line-mule-info | ||
| 1129 | 'mode-line-modified | 1110 | 'mode-line-modified |
| 1111 | 'mode-line-frame-identification | ||
| 1130 | "%b--" | 1112 | "%b--" |
| 1131 | @end group | 1113 | @end group |
| 1132 | @group | 1114 | @group |
| @@ -1143,9 +1125,11 @@ directory. | |||
| 1143 | 'mode-line-process | 1125 | 'mode-line-process |
| 1144 | 'minor-mode-alist | 1126 | 'minor-mode-alist |
| 1145 | "%n" | 1127 | "%n" |
| 1146 | ")%]----" | 1128 | ")%]--" |
| 1147 | @group | 1129 | @group |
| 1130 | '(which-func-mode ("" which-func-format "--")) | ||
| 1148 | '(line-number-mode "L%l--") | 1131 | '(line-number-mode "L%l--") |
| 1132 | '(column-number-mode "C%c--") | ||
| 1149 | '(-3 . "%p") | 1133 | '(-3 . "%p") |
| 1150 | "-%-")) | 1134 | "-%-")) |
| 1151 | @end group | 1135 | @end group |
| @@ -1160,22 +1144,38 @@ line. There is nothing inherently special about these variables; any | |||
| 1160 | other variables could have the same effects on the mode line if | 1144 | other variables could have the same effects on the mode line if |
| 1161 | @code{mode-line-format} were changed to use them. | 1145 | @code{mode-line-format} were changed to use them. |
| 1162 | 1146 | ||
| 1147 | @tindex mode-line-mule-info | ||
| 1148 | @defvar mode-line-mule-info | ||
| 1149 | This variable holds the value of the mode-line construct that displays | ||
| 1150 | information about the language environment, buffer coding system, and | ||
| 1151 | current input method. @xref{International,,, emacs, The GNU Emacs | ||
| 1152 | Manual}. | ||
| 1153 | @end defvar | ||
| 1154 | |||
| 1163 | @defvar mode-line-modified | 1155 | @defvar mode-line-modified |
| 1164 | This variable holds the value of the mode-line construct that displays | 1156 | This variable holds the value of the mode-line construct that displays |
| 1165 | whether the current buffer is modified. | 1157 | whether the current buffer is modified. |
| 1166 | 1158 | ||
| 1167 | The default value of @code{mode-line-modified} is @code{("--%1*%1+-")}. | 1159 | The default value of @code{mode-line-modified} is @code{("%1*%1+")}. |
| 1168 | This means that the mode line displays @samp{--**-} if the buffer is | 1160 | This means that the mode line displays @samp{**} if the buffer is |
| 1169 | modified, @samp{-----} if the buffer is not modified, @samp{--%%-} if | 1161 | modified, @samp{--} if the buffer is not modified, @samp{%%} if the |
| 1170 | the buffer is read only, and @samp{--%*--} if the buffer is read only | 1162 | buffer is read only, and @samp{%*} if the buffer is read only and |
| 1171 | and modified. | 1163 | modified. |
| 1172 | 1164 | ||
| 1173 | Changing this variable does not force an update of the mode line. | 1165 | Changing this variable does not force an update of the mode line. |
| 1174 | @end defvar | 1166 | @end defvar |
| 1175 | 1167 | ||
| 1168 | @tindex mode-line-frame-identification | ||
| 1169 | @defvar mode-line-frame-identification | ||
| 1170 | This variable identifies the current frame. The default value is | ||
| 1171 | @code{" "} if you are using a window system which can show multiple | ||
| 1172 | frames, or @code{"-%F "} on an ordinary terminal which shows only one | ||
| 1173 | frame at a time. | ||
| 1174 | @end defvar | ||
| 1175 | |||
| 1176 | @defvar mode-line-buffer-identification | 1176 | @defvar mode-line-buffer-identification |
| 1177 | This variable identifies the buffer being displayed in the window. Its | 1177 | This variable identifies the buffer being displayed in the window. Its |
| 1178 | default value is @code{("%F: %17b")}, which means that it usually | 1178 | default value is @code{("%12b")}, which means that it usually |
| 1179 | displays @samp{Emacs:} followed by seventeen characters of the buffer | 1179 | displays @samp{Emacs:} followed by seventeen characters of the buffer |
| 1180 | name. (In a terminal frame, it displays the frame name instead of | 1180 | name. (In a terminal frame, it displays the frame name instead of |
| 1181 | @samp{Emacs}; this has the effect of showing the frame number.) You may | 1181 | @samp{Emacs}; this has the effect of showing the frame number.) You may |
| @@ -1282,10 +1282,10 @@ The default value of @code{default-mode-line-format} is this list: | |||
| 1282 | @end defvar | 1282 | @end defvar |
| 1283 | 1283 | ||
| 1284 | @defvar vc-mode | 1284 | @defvar vc-mode |
| 1285 | The variable @code{vc-mode}, local in each buffer, records whether the | 1285 | The variable @code{vc-mode}, buffer-local in each buffer, records |
| 1286 | buffer's visited file is maintained with version control, and, if so, | 1286 | whether the buffer's visited file is maintained with version control, |
| 1287 | which kind. Its value is @code{nil} for no version control, or a string | 1287 | and, if so, which kind. Its value is @code{nil} for no version control, |
| 1288 | that appears in the mode line. | 1288 | or a string that appears in the mode line. |
| 1289 | @end defvar | 1289 | @end defvar |
| 1290 | 1290 | ||
| 1291 | @node %-Constructs | 1291 | @node %-Constructs |
| @@ -1305,7 +1305,8 @@ The visited file name, obtained with the @code{buffer-file-name} | |||
| 1305 | function. @xref{Buffer File Name}. | 1305 | function. @xref{Buffer File Name}. |
| 1306 | 1306 | ||
| 1307 | @item %F | 1307 | @item %F |
| 1308 | The name of the selected frame. | 1308 | The title (only on a window system) or the name of the selected frame. |
| 1309 | @xref{Window Frame Parameters}. | ||
| 1309 | 1310 | ||
| 1310 | @item %c | 1311 | @item %c |
| 1311 | The current column number of point. | 1312 | The current column number of point. |
| @@ -1383,12 +1384,15 @@ The value of @code{global-mode-string}. Currently, only | |||
| 1383 | @section Imenu | 1384 | @section Imenu |
| 1384 | 1385 | ||
| 1385 | @cindex Imenu | 1386 | @cindex Imenu |
| 1386 | @dfn{Imenu} is a feature that constructs a buffer index for a buffer. | 1387 | @dfn{Imenu} is a feature that lets users select a definition or |
| 1387 | The buffer index contains the names and positions of the definitions or | 1388 | section in the buffer, from a menu which lists all of them, to go |
| 1388 | portions of in the buffer, so the user can pick one of themand move to | 1389 | directly to that location in the buffer. Imenu works by constructing a |
| 1389 | it. This section explains how to customize Imenu for a major mode. The | 1390 | buffer index which lists the names and positions of the definitions or |
| 1390 | usual and simplest way is to set the variable | 1391 | portions of in the buffer, so the user can pick one of them to move to. |
| 1391 | @code{imenu-generic-expression}. | 1392 | This section explains how to customize Imenu for a major mode. |
| 1393 | |||
| 1394 | The usual and simplest way is to set the variable | ||
| 1395 | @code{imenu-generic-expression}: | ||
| 1392 | 1396 | ||
| 1393 | @defvar imenu-generic-expression | 1397 | @defvar imenu-generic-expression |
| 1394 | This variable, if non-@code{nil}, specifies regular expressions for | 1398 | This variable, if non-@code{nil}, specifies regular expressions for |
| @@ -1407,9 +1411,8 @@ in the top level of the buffer index. | |||
| 1407 | 1411 | ||
| 1408 | The second item in the list, @var{regexp}, is a regular expression | 1412 | The second item in the list, @var{regexp}, is a regular expression |
| 1409 | (@pxref{Regular Expressions}); wherever it matches, that is a definition | 1413 | (@pxref{Regular Expressions}); wherever it matches, that is a definition |
| 1410 | to be mentioned in the buffer index. The third item, @var{subexp}, | 1414 | to mention in the buffer index. The third item, @var{subexp}, indicates |
| 1411 | indicates which subexpression in @var{regexp} contains the name for the | 1415 | which subexpression in @var{regexp} matches the definition's name. |
| 1412 | definition. | ||
| 1413 | 1416 | ||
| 1414 | An element can also look like this: | 1417 | An element can also look like this: |
| 1415 | 1418 | ||
| @@ -1439,7 +1442,7 @@ For Emacs Lisp mode, @var{pattern} could look like this: | |||
| 1439 | @end group | 1442 | @end group |
| 1440 | @end example | 1443 | @end example |
| 1441 | 1444 | ||
| 1442 | This variable is local in all buffers, if it is set. | 1445 | Setting this variable makes it buffer-local in the current buffer. |
| 1443 | @end defvar | 1446 | @end defvar |
| 1444 | 1447 | ||
| 1445 | @defvar imenu-case-fold-search | 1448 | @defvar imenu-case-fold-search |
| @@ -1447,12 +1450,12 @@ This variable controls whether the regular expression matching for Imenu | |||
| 1447 | is case-sensitive: @code{t}, the default, means matching should ignore | 1450 | is case-sensitive: @code{t}, the default, means matching should ignore |
| 1448 | case. | 1451 | case. |
| 1449 | 1452 | ||
| 1450 | This variable is local in all buffers, if it is set. | 1453 | Setting this variable makes it buffer-local in the current buffer. |
| 1451 | @end defvar | 1454 | @end defvar |
| 1452 | 1455 | ||
| 1453 | Another way to customize Imenu for a major mode is to set the | 1456 | Another way to customize Imenu for a major mode is to set the |
| 1454 | variables @code{imenu-prev-index-position-function} and | 1457 | variables @code{imenu-prev-index-position-function} and |
| 1455 | @code{imenu-extract-index-name-function}. | 1458 | @code{imenu-extract-index-name-function}: |
| 1456 | 1459 | ||
| 1457 | @defvar imenu-prev-index-position-function | 1460 | @defvar imenu-prev-index-position-function |
| 1458 | If this variable is non-@code{nil}, its value should be a function for | 1461 | If this variable is non-@code{nil}, its value should be a function for |
| @@ -1460,19 +1463,23 @@ finding the next definition to mention in the buffer index, moving | |||
| 1460 | backwards in the file. | 1463 | backwards in the file. |
| 1461 | 1464 | ||
| 1462 | The function should leave point at the place to be connected to the | 1465 | The function should leave point at the place to be connected to the |
| 1463 | index item, and it should return @code{nil} when it doesn't find another | 1466 | index item; it should return @code{nil} if it doesn't find another item. |
| 1464 | item. | ||
| 1465 | 1467 | ||
| 1466 | This variable is local in all buffers, if it is set. | 1468 | Setting this variable makes it buffer-local in the current buffer. |
| 1467 | @end defvar | 1469 | @end defvar |
| 1468 | 1470 | ||
| 1469 | @defvar imenu-extract-index-name-function | 1471 | @defvar imenu-extract-index-name-function |
| 1470 | If this variable is non-@code{nil}, its value should be a function to | 1472 | If this variable is non-@code{nil}, its value should be a function to |
| 1471 | return the name for a definition, assuming point is at that definition. | 1473 | return the name for a definition, assuming point is in that definition |
| 1474 | as the @code{imenu-prev-index-position-function} function would leave | ||
| 1475 | it. | ||
| 1472 | 1476 | ||
| 1473 | This variable is local in all buffers, if it is set. | 1477 | Setting this variable makes it buffer-local in the current buffer. |
| 1474 | @end defvar | 1478 | @end defvar |
| 1475 | 1479 | ||
| 1480 | The last way to customize Imenu for a major mode is to set the | ||
| 1481 | variables @code{imenu-create-index-function}: | ||
| 1482 | |||
| 1476 | @defvar imenu-create-index-function | 1483 | @defvar imenu-create-index-function |
| 1477 | This variable specifies the function to use for creating a buffer index. | 1484 | This variable specifies the function to use for creating a buffer index. |
| 1478 | The function should take no arguments, and return an index for the | 1485 | The function should take no arguments, and return an index for the |
| @@ -1484,13 +1491,12 @@ The default value is a function that uses | |||
| 1484 | specify a different function, then @code{imenu-generic-expression} is | 1491 | specify a different function, then @code{imenu-generic-expression} is |
| 1485 | not used. | 1492 | not used. |
| 1486 | 1493 | ||
| 1487 | The variable @code{imenu-create-index-function} is local in all buffers, | 1494 | Setting this variable makes it buffer-local in the current buffer. |
| 1488 | if it is set. | ||
| 1489 | @end defvar | 1495 | @end defvar |
| 1490 | 1496 | ||
| 1491 | @defvar imenu-index-alist | 1497 | @defvar imenu-index-alist |
| 1492 | This variable holds the index alist for the current buffer. | 1498 | This variable holds the index alist for the current buffer. |
| 1493 | It is local in each buffer, once it is set. | 1499 | Setting it makes it buffer-local in the current buffer. |
| 1494 | 1500 | ||
| 1495 | Simple elements in the alist look like @code{(@var{index-name} | 1501 | Simple elements in the alist look like @code{(@var{index-name} |
| 1496 | . @var{index-position})}. Selecting a simple element has the effect of | 1502 | . @var{index-position})}. Selecting a simple element has the effect of |
| @@ -1515,17 +1521,16 @@ A nested sub-alist element looks like @code{(@var{index-name} | |||
| 1515 | @dfn{Font Lock mode} is a feature that automatically attaches | 1521 | @dfn{Font Lock mode} is a feature that automatically attaches |
| 1516 | @code{face} properties to certain parts of the buffer based on their | 1522 | @code{face} properties to certain parts of the buffer based on their |
| 1517 | syntactic role. How it parses the buffer depends on the major mode; | 1523 | syntactic role. How it parses the buffer depends on the major mode; |
| 1518 | most major modes define a set of syntactic criteria for which faces to | 1524 | most major modes define syntactic criteria for which faces to use, in |
| 1519 | use, in which contexts. This section explains how to customize Font | 1525 | which contexts. This section explains how to customize Font Lock for a |
| 1520 | Lock for a particular language---in other words, for a particular major | 1526 | particular language---in other words, for a particular major mode. |
| 1521 | mode. | ||
| 1522 | 1527 | ||
| 1523 | Font Lock mode finds text to highlight in two ways: through syntactic | 1528 | Font Lock mode finds text to highlight in two ways: through syntactic |
| 1524 | parsing based on the syntax table, and through searching (usually for | 1529 | parsing based on the syntax table, and through searching (usually for |
| 1525 | regular expressions). Syntactic fontification happens first; it finds | 1530 | regular expressions). Syntactic fontification happens first; it finds |
| 1526 | comments and string constants, and highlights them using | 1531 | comments and string constants, and highlights them using |
| 1527 | @code{font-lock-comment-face} and @code{font-lock-string-face} | 1532 | @code{font-lock-comment-face} and @code{font-lock-string-face} |
| 1528 | (@pxref{Faces for Font Lock}: Search-based fontification follows. | 1533 | (@pxref{Faces for Font Lock}); search-based fontification follows. |
| 1529 | 1534 | ||
| 1530 | @menu | 1535 | @menu |
| 1531 | * Font Lock Basics:: | 1536 | * Font Lock Basics:: |
| @@ -1533,6 +1538,7 @@ comments and string constants, and highlights them using | |||
| 1533 | * Other Font Lock Variables:: | 1538 | * Other Font Lock Variables:: |
| 1534 | * Levels of Font Lock:: | 1539 | * Levels of Font Lock:: |
| 1535 | * Faces for Font Lock:: | 1540 | * Faces for Font Lock:: |
| 1541 | * Syntactic Font Lock:: | ||
| 1536 | @end menu | 1542 | @end menu |
| 1537 | 1543 | ||
| 1538 | @node Font Lock Basics | 1544 | @node Font Lock Basics |
| @@ -1540,9 +1546,9 @@ comments and string constants, and highlights them using | |||
| 1540 | 1546 | ||
| 1541 | There are several variables that control how Font Lock mode highlights | 1547 | There are several variables that control how Font Lock mode highlights |
| 1542 | text. But major modes should not set any of these variables directly. | 1548 | text. But major modes should not set any of these variables directly. |
| 1543 | Instead, it should set @code{font-lock-defaults} as a local variable. | 1549 | Instead, it should set @code{font-lock-defaults} as a buffer-local |
| 1544 | The value assigned to this variable is used, if and when Font Lock mode | 1550 | variable. The value assigned to this variable is used, if and when Font |
| 1545 | is enabled, to set all the other variables. | 1551 | Lock mode is enabled, to set all the other variables. |
| 1546 | 1552 | ||
| 1547 | @defvar font-lock-defaults | 1553 | @defvar font-lock-defaults |
| 1548 | This variable is set by major modes, as a buffer-local variable, to | 1554 | This variable is set by major modes, as a buffer-local variable, to |
| @@ -1563,11 +1569,12 @@ symbol how to do level 2, and so on. | |||
| 1563 | 1569 | ||
| 1564 | The second element, @var{keywords-only}, specifies the value of the | 1570 | The second element, @var{keywords-only}, specifies the value of the |
| 1565 | variable @code{font-lock-keywords-only}. If this is is non-@code{nil}, | 1571 | variable @code{font-lock-keywords-only}. If this is is non-@code{nil}, |
| 1566 | syntactic fontification (strings and comments) is not performed. | 1572 | syntactic fontification (of strings and comments) is not performed. |
| 1567 | 1573 | ||
| 1568 | The third element, @var{case-fold}, specifies the value of | 1574 | The third element, @var{case-fold}, specifies the value of |
| 1569 | @code{font-lock-case-fold-search}. If it is non-@code{nil}, Font Lock | 1575 | @code{font-lock-case-fold-search}. If it is non-@code{nil}, Font Lock |
| 1570 | mode ignores case when obeying @code{font-lock-keywords}. | 1576 | mode ignores case when searching as directed by |
| 1577 | @code{font-lock-keywords}. | ||
| 1571 | 1578 | ||
| 1572 | If the fourth element, @var{syntax-alist}, is non-@code{nil}, it should be | 1579 | If the fourth element, @var{syntax-alist}, is non-@code{nil}, it should be |
| 1573 | a list of cons cells of the form @code{(@var{char-or-string} | 1580 | a list of cons cells of the form @code{(@var{char-or-string} |
| @@ -1576,8 +1583,7 @@ fontification (@pxref{Syntax Table Functions}). The resulting syntax | |||
| 1576 | table is stored in @code{font-lock-syntax-table}. | 1583 | table is stored in @code{font-lock-syntax-table}. |
| 1577 | 1584 | ||
| 1578 | The fifth element, @var{syntax-begin}, specifies the value of | 1585 | The fifth element, @var{syntax-begin}, specifies the value of |
| 1579 | @code{font-lock-beginning-of-syntax-function}. See below for an | 1586 | @code{font-lock-beginning-of-syntax-function} (see below). |
| 1580 | explanation of what this value means. | ||
| 1581 | 1587 | ||
| 1582 | Any further elements @var{other-vars} are have form | 1588 | Any further elements @var{other-vars} are have form |
| 1583 | @code{(@var{variable} . @var{value})}. This kind of element means to | 1589 | @code{(@var{variable} . @var{value})}. This kind of element means to |
| @@ -1594,13 +1600,20 @@ search-based fontification. | |||
| 1594 | 1600 | ||
| 1595 | @defvar font-lock-keywords | 1601 | @defvar font-lock-keywords |
| 1596 | This variable's value is a list of the keywords to highlight. Be | 1602 | This variable's value is a list of the keywords to highlight. Be |
| 1597 | careful when composing regexps for this list; a poorly written pattern | 1603 | careful when composing regular expressions for this list; a poorly |
| 1598 | can dramatically slow things down! | 1604 | written pattern can dramatically slow things down! |
| 1599 | @end defvar | 1605 | @end defvar |
| 1600 | 1606 | ||
| 1601 | Each element of @code{font-lock-keywords} specifies how to find | 1607 | Each element of @code{font-lock-keywords} specifies how to find |
| 1602 | certain cases of text, and how to highlight those cases. An element | 1608 | certain cases of text, and how to highlight those cases. Font Lock mode |
| 1603 | should have one of these forms: | 1609 | processes the elements of @code{font-lock-keywords} one by one, and for |
| 1610 | each element, it finds and handles all matches. Ordinarily, once | ||
| 1611 | part of the text has been fontified already, this cannot be overridden | ||
| 1612 | by a subsequent match in the same text; but you can specify different | ||
| 1613 | behavior using the @var{override} element of a @var{highlighter}. | ||
| 1614 | |||
| 1615 | Each element of @code{font-lock-keywords} should have one of these | ||
| 1616 | forms: | ||
| 1604 | 1617 | ||
| 1605 | @table @code | 1618 | @table @code |
| 1606 | @item @var{regexp} | 1619 | @item @var{regexp} |
| @@ -1613,9 +1626,9 @@ Highlight all matches for @var{regexp} using | |||
| 1613 | "\\<foo\\>" | 1626 | "\\<foo\\>" |
| 1614 | @end example | 1627 | @end example |
| 1615 | 1628 | ||
| 1616 | The function @code{regexp-opt} (@pxref{Syntax of Regexps}) is often | 1629 | The function @code{regexp-opt} (@pxref{Syntax of Regexps}) is useful for |
| 1617 | useful for calculating complex regular expressions to match a number of | 1630 | calculating optimal regular expressions to match a number of different |
| 1618 | different keywords. | 1631 | keywords. |
| 1619 | 1632 | ||
| 1620 | @item @var{function} | 1633 | @item @var{function} |
| 1621 | Find text by calling @var{function}, and highlight the matches | 1634 | Find text by calling @var{function}, and highlight the matches |
| @@ -1629,7 +1642,7 @@ match data to describe the match that was found. | |||
| 1629 | In this kind of element, @var{matcher} stands for either a regular | 1642 | In this kind of element, @var{matcher} stands for either a regular |
| 1630 | expression or a function, as described above. The @sc{cdr}, | 1643 | expression or a function, as described above. The @sc{cdr}, |
| 1631 | @var{match}, specifies which subexpression of @var{matcher} should be | 1644 | @var{match}, specifies which subexpression of @var{matcher} should be |
| 1632 | highlighted (instead of the entire text that matched @var{matcher}). | 1645 | highlighted (instead of the entire text that @var{matcher} matched). |
| 1633 | 1646 | ||
| 1634 | @example | 1647 | @example |
| 1635 | ;; @r{Highlight the @samp{bar} in each occurrences of @samp{fubar},} | 1648 | ;; @r{Highlight the @samp{bar} in each occurrences of @samp{fubar},} |
| @@ -1637,7 +1650,7 @@ highlighted (instead of the entire text that matched @var{matcher}). | |||
| 1637 | ("fu\\(bar\\)" . 1) | 1650 | ("fu\\(bar\\)" . 1) |
| 1638 | @end example | 1651 | @end example |
| 1639 | 1652 | ||
| 1640 | If you use @code{regexp-opt} to produce a regular expression for | 1653 | If you use @code{regexp-opt} to produce the regular expression |
| 1641 | @var{matcher}, then you can use @code{regexp-opt-depth} (@pxref{Syntax | 1654 | @var{matcher}, then you can use @code{regexp-opt-depth} (@pxref{Syntax |
| 1642 | of Regexps}) to calculate the value for @var{match}. | 1655 | of Regexps}) to calculate the value for @var{match}. |
| 1643 | 1656 | ||
| @@ -1661,8 +1674,8 @@ It has the form | |||
| 1661 | @end example | 1674 | @end example |
| 1662 | 1675 | ||
| 1663 | The @sc{car}, @var{subexp}, is an integer specifying which subexpression | 1676 | The @sc{car}, @var{subexp}, is an integer specifying which subexpression |
| 1664 | of the match to fontify (0 means the entire matching text). | 1677 | of the match to fontify (0 means the entire matching text). The second |
| 1665 | @var{facename}, specifies the face, as described above. | 1678 | subelement, @var{facename}, specifies the face, as described above. |
| 1666 | 1679 | ||
| 1667 | The last two values in @var{highlighter}, @var{override} and | 1680 | The last two values in @var{highlighter}, @var{override} and |
| 1668 | @var{laxmatch}, are flags. If @var{override} is @code{t}, this element | 1681 | @var{laxmatch}, are flags. If @var{override} is @code{t}, this element |
| @@ -1750,9 +1763,9 @@ line; in other words, the @var{submatcher} search should not span lines. | |||
| 1750 | @end ignore | 1763 | @end ignore |
| 1751 | 1764 | ||
| 1752 | @item (eval . @var{form}) | 1765 | @item (eval . @var{form}) |
| 1753 | Here @var{form} is an expression. to be evaluated the first time | 1766 | Here @var{form} is an expression to be evaluated the first time |
| 1754 | this value of @code{font-lock-keywords} is used in a buffer. | 1767 | this value of @code{font-lock-keywords} is used in a buffer. |
| 1755 | Its value should be another element of one of these forms. | 1768 | Its value should have one of the forms described in this table. |
| 1756 | @end table | 1769 | @end table |
| 1757 | 1770 | ||
| 1758 | @strong{Warning:} Do not design an element of @code{font-lock-keywords} | 1771 | @strong{Warning:} Do not design an element of @code{font-lock-keywords} |
| @@ -1761,33 +1774,6 @@ to match text which spans lines; this does not work reliably. While | |||
| 1761 | updating when you edit the buffer does not, since it considers text one | 1774 | updating when you edit the buffer does not, since it considers text one |
| 1762 | line at a time. | 1775 | line at a time. |
| 1763 | 1776 | ||
| 1764 | @defvar font-lock-syntactic-keywords | ||
| 1765 | Font Lock mode can be used to update @code{syntax-table} properties | ||
| 1766 | automatically. This is useful in languages for which a single | ||
| 1767 | syntax table by itself is not sufficient. | ||
| 1768 | |||
| 1769 | This variable enables and controls the feature. Its value should | ||
| 1770 | be a list of elements of this form: | ||
| 1771 | |||
| 1772 | @example | ||
| 1773 | (@var{matcher} @var{subexp} @var{syntax} @var{override} @var{laxmatch}) | ||
| 1774 | @end example | ||
| 1775 | |||
| 1776 | The parts of this element have the same meanings as in the corresponding | ||
| 1777 | sort of element of @code{font-lock-keywords}, | ||
| 1778 | |||
| 1779 | @example | ||
| 1780 | (@var{matcher} @var{subexp} @var{facename} @var{override} @var{laxmatch}) | ||
| 1781 | @end example | ||
| 1782 | |||
| 1783 | However, instead of specifying the value @var{facename} to use for the | ||
| 1784 | @code{face} property, it specifies the value @var{syntax} to use for the | ||
| 1785 | @code{syntax-table} property. Here, @var{syntax} can be a variable | ||
| 1786 | whose value is a syntax table, a syntax entry of the form | ||
| 1787 | @code{(@var{syntax-code} . @var{matching-char})}, or an expression whose | ||
| 1788 | value is one of those two types. | ||
| 1789 | @end defvar | ||
| 1790 | |||
| 1791 | @node Other Font Lock Variables | 1777 | @node Other Font Lock Variables |
| 1792 | @subsection Other Font Lock Variables | 1778 | @subsection Other Font Lock Variables |
| 1793 | 1779 | ||
| @@ -1796,7 +1782,8 @@ can set by means of @code{font-lock-defaults}. | |||
| 1796 | 1782 | ||
| 1797 | @defvar font-lock-keywords-only | 1783 | @defvar font-lock-keywords-only |
| 1798 | Non-@code{nil} means Font Lock should not fontify comments or strings | 1784 | Non-@code{nil} means Font Lock should not fontify comments or strings |
| 1799 | syntactictally; it should only fontify based on @code{font-lock-keywords}. | 1785 | syntactically; it should only fontify based on |
| 1786 | @code{font-lock-keywords}. | ||
| 1800 | @end defvar | 1787 | @end defvar |
| 1801 | 1788 | ||
| 1802 | @ignore | 1789 | @ignore |
| @@ -1807,17 +1794,20 @@ Other variables include those for buffer-specialised fontification functions, | |||
| 1807 | @end ignore | 1794 | @end ignore |
| 1808 | 1795 | ||
| 1809 | @defvar font-lock-keywords-case-fold-search | 1796 | @defvar font-lock-keywords-case-fold-search |
| 1810 | Non-@code{nil} means that regular expression matching for | 1797 | Non-@code{nil} means that regular expression matching for the sake of |
| 1811 | patterns in @code{font-lock-keywords} is case-insensitive. | 1798 | @code{font-lock-keywords} should be case-insensitive. |
| 1812 | @end defvar | 1799 | @end defvar |
| 1813 | 1800 | ||
| 1814 | @defvar font-lock-beginning-of-syntax-function | 1801 | @defvar font-lock-syntax-table |
| 1815 | If this variable is non-@code{nil}, it should be a function to use to | 1802 | This variable specifies the syntax table to use for fontification of |
| 1816 | move back outside of a syntactic block. | 1803 | comments and strings. |
| 1804 | @end defvar | ||
| 1817 | 1805 | ||
| 1818 | @c Simon, WHEN is this variable used? | 1806 | @defvar font-lock-beginning-of-syntax-function |
| 1819 | @c In what situation does Font Lock mode look for the | 1807 | If this variable is non-@code{nil}, it should be a function to move |
| 1820 | @c beginning of a syntactic block? | 1808 | point back to a position that is syntactically at ``top level'' and |
| 1809 | outside of strings or comments. Font Lock uses this when necessary | ||
| 1810 | to get the right results for syntactic fontification. | ||
| 1821 | 1811 | ||
| 1822 | This function is called with no arguments. It should leave point at the | 1812 | This function is called with no arguments. It should leave point at the |
| 1823 | beginning of any enclosing syntactic block. Typical values are | 1813 | beginning of any enclosing syntactic block. Typical values are |
| @@ -1827,30 +1817,21 @@ modes or @code{backward-paragraph} for textual modes (i.e., the | |||
| 1827 | mode-dependent function is known to move outside a syntactic block). | 1817 | mode-dependent function is known to move outside a syntactic block). |
| 1828 | 1818 | ||
| 1829 | If the value is @code{nil}, the beginning of the buffer is used as a | 1819 | If the value is @code{nil}, the beginning of the buffer is used as a |
| 1830 | position outside of a syntactic block, in the worst case. | 1820 | position outside of a syntactic block. This cannot be wrong, but it can |
| 1831 | @end defvar | 1821 | be slow. |
| 1832 | |||
| 1833 | @defvar font-lock-syntax-table | ||
| 1834 | This variable specifies the syntax table to use for fontification of | ||
| 1835 | comments and strings. | ||
| 1836 | @end defvar | 1822 | @end defvar |
| 1837 | 1823 | ||
| 1838 | @defvar font-lock-mark-block-function | 1824 | @defvar font-lock-mark-block-function |
| 1839 | If this variable is non-@code{nil}, it should be a function with no args | 1825 | If this variable is non-@code{nil}, it should be a function that is |
| 1840 | used to mark an enclosing range of text for refontification when the | 1826 | called with no arguments, to choose an enclosing range of text for |
| 1841 | text in the buffer changes. A good choice of this function chooses a | 1827 | refontification for the command @kbd{M-g M-g} |
| 1842 | range of text large enough to give proper results, but not too large so | 1828 | (@code{font-lock-fontify-block}). |
| 1843 | that refontification becomes slow. | 1829 | |
| 1844 | 1830 | The function should report its choice by placing the region around it. | |
| 1845 | Typical values are @code{mark-defun} for programming modes or | 1831 | A good choice is a range of text large enough to give proper results, |
| 1846 | @code{mark-paragraph} for textual modes (i.e., the mode-dependent | 1832 | but not too large so that refontification becomes slow. Typical values |
| 1847 | function is known to put point and mark around a text block relevant to | 1833 | are @code{mark-defun} for programming modes or @code{mark-paragraph} for |
| 1848 | that mode). | 1834 | textual modes. |
| 1849 | |||
| 1850 | @c Simon, WHEN is this variable used? | ||
| 1851 | @c In what situation does Font Lock mode look for the | ||
| 1852 | @c beginning of a syntactic block? | ||
| 1853 | |||
| 1854 | @end defvar | 1835 | @end defvar |
| 1855 | 1836 | ||
| 1856 | @node Levels of Font Lock | 1837 | @node Levels of Font Lock |
| @@ -1863,6 +1844,9 @@ fontification; it is up to the user to choose one of these levels. The | |||
| 1863 | chosen level's symbol value is used to initialize | 1844 | chosen level's symbol value is used to initialize |
| 1864 | @code{font-lock-keywords}. | 1845 | @code{font-lock-keywords}. |
| 1865 | 1846 | ||
| 1847 | Here are the conventions for how to define the levels of | ||
| 1848 | fontification: | ||
| 1849 | |||
| 1866 | @itemize @bullet | 1850 | @itemize @bullet |
| 1867 | @item | 1851 | @item |
| 1868 | Level 1: highlight function declarations, file directives (such as include or | 1852 | Level 1: highlight function declarations, file directives (such as include or |
| @@ -1870,17 +1854,15 @@ import directives), strings and comments. The idea is speed, so only | |||
| 1870 | the most important and top-level components are fontified. | 1854 | the most important and top-level components are fontified. |
| 1871 | 1855 | ||
| 1872 | @item | 1856 | @item |
| 1873 | Level 2: in addition to level 1, highlight all language keywords (with | 1857 | Level 2: in addition to level 1, highlight all language keywords, |
| 1874 | keyword-face) including type names (using type-face), constant values | 1858 | including type names that act like keywords, as well as named constant |
| 1875 | (with reference-face, e.g., "true" and "false" or case/switch | 1859 | values. The idea is that all keywords (either syntactic or semantic) |
| 1876 | constants). The idea is that all reserved words should be fontified | 1860 | should be fontified appropriately. |
| 1877 | appropriately. | ||
| 1878 | 1861 | ||
| 1879 | @item | 1862 | @item |
| 1880 | Level 3: in addition to level 2, highlight all symbols that are defined | 1863 | Level 3: in addition to level 2, highlight the symbols being defined in |
| 1881 | in function and variable declarations, and all builtin functions, | 1864 | function and variable declarations, and all builtin function names, |
| 1882 | wherever they appear. The idea is that all declared objects should be | 1865 | wherever they appear. |
| 1883 | fontified. | ||
| 1884 | @end itemize | 1866 | @end itemize |
| 1885 | 1867 | ||
| 1886 | @node Faces for Font Lock | 1868 | @node Faces for Font Lock |
| @@ -1948,6 +1930,36 @@ change the meaning of other text. For example, this is used for | |||
| 1948 | directives in C. | 1930 | directives in C. |
| 1949 | @end table | 1931 | @end table |
| 1950 | 1932 | ||
| 1933 | @node Syntactic Font Lock | ||
| 1934 | @subsection Syntactic Font Lock | ||
| 1935 | |||
| 1936 | Font Lock mode can be used to update @code{syntax-table} properties | ||
| 1937 | automatically. This is useful in languages for which a single syntax | ||
| 1938 | table by itself is not sufficient. | ||
| 1939 | |||
| 1940 | @defvar font-lock-syntactic-keywords | ||
| 1941 | This variable enables and controls syntactic Font Lock. Its value | ||
| 1942 | should be a list of elements of this form: | ||
| 1943 | |||
| 1944 | @example | ||
| 1945 | (@var{matcher} @var{subexp} @var{syntax} @var{override} @var{laxmatch}) | ||
| 1946 | @end example | ||
| 1947 | |||
| 1948 | The parts of this element have the same meanings as in the corresponding | ||
| 1949 | sort of element of @code{font-lock-keywords}, | ||
| 1950 | |||
| 1951 | @example | ||
| 1952 | (@var{matcher} @var{subexp} @var{facename} @var{override} @var{laxmatch}) | ||
| 1953 | @end example | ||
| 1954 | |||
| 1955 | However, instead of specifying the value @var{facename} to use for the | ||
| 1956 | @code{face} property, it specifies the value @var{syntax} to use for the | ||
| 1957 | @code{syntax-table} property. Here, @var{syntax} can be a variable | ||
| 1958 | whose value is a syntax table, a syntax entry of the form | ||
| 1959 | @code{(@var{syntax-code} . @var{matching-char})}, or an expression whose | ||
| 1960 | value is one of those two types. | ||
| 1961 | @end defvar | ||
| 1962 | |||
| 1951 | @node Hooks | 1963 | @node Hooks |
| 1952 | @section Hooks | 1964 | @section Hooks |
| 1953 | @cindex hooks | 1965 | @cindex hooks |
| @@ -1968,9 +1980,10 @@ a uniform way. | |||
| 1968 | Every major mode function is supposed to run a normal hook called the | 1980 | Every major mode function is supposed to run a normal hook called the |
| 1969 | @dfn{mode hook} as the last step of initialization. This makes it easy | 1981 | @dfn{mode hook} as the last step of initialization. This makes it easy |
| 1970 | for a user to customize the behavior of the mode, by overriding the | 1982 | for a user to customize the behavior of the mode, by overriding the |
| 1971 | local variable assignments already made by the mode. But hooks are used | 1983 | buffer-local variable assignments already made by the mode. But hooks |
| 1972 | in other contexts too. For example, the hook @code{suspend-hook} runs | 1984 | are used in other contexts too. For example, the hook |
| 1973 | just before Emacs suspends itself (@pxref{Suspending Emacs}). | 1985 | @code{suspend-hook} runs just before Emacs suspends itself |
| 1986 | (@pxref{Suspending Emacs}). | ||
| 1974 | 1987 | ||
| 1975 | The recommended way to add a hook function to a normal hook is by | 1988 | The recommended way to add a hook function to a normal hook is by |
| 1976 | calling @code{add-hook} (see below). The hook functions may be any of | 1989 | calling @code{add-hook} (see below). The hook functions may be any of |
| @@ -1994,36 +2007,13 @@ established the convention of using @samp{-hook} for them.) | |||
| 1994 | If the variable's name ends in @samp{-function}, then its value | 2007 | If the variable's name ends in @samp{-function}, then its value |
| 1995 | is just a single function, not a list of functions. | 2008 | is just a single function, not a list of functions. |
| 1996 | 2009 | ||
| 1997 | Here's an expression that uses a mode hook to turn on Auto Fill mode | 2010 | Here's an example that uses a mode hook to turn on Auto Fill mode when |
| 1998 | when in Lisp Interaction mode: | 2011 | in Lisp Interaction mode: |
| 1999 | 2012 | ||
| 2000 | @example | 2013 | @example |
| 2001 | (add-hook 'lisp-interaction-mode-hook 'turn-on-auto-fill) | 2014 | (add-hook 'lisp-interaction-mode-hook 'turn-on-auto-fill) |
| 2002 | @end example | 2015 | @end example |
| 2003 | 2016 | ||
| 2004 | The next example shows how to use a hook to customize the way Emacs | ||
| 2005 | formats C code. (People often have strong personal preferences for one | ||
| 2006 | format or another.) Here the hook function is an anonymous lambda | ||
| 2007 | expression. | ||
| 2008 | |||
| 2009 | @cindex lambda expression in hook | ||
| 2010 | @example | ||
| 2011 | @group | ||
| 2012 | (add-hook 'c-mode-hook | ||
| 2013 | (function (lambda () | ||
| 2014 | (setq c-indent-level 4 | ||
| 2015 | c-argdecl-indent 0 | ||
| 2016 | c-label-offset -4 | ||
| 2017 | @end group | ||
| 2018 | @group | ||
| 2019 | c-continued-statement-indent 0 | ||
| 2020 | c-brace-offset 0 | ||
| 2021 | comment-column 40)))) | ||
| 2022 | |||
| 2023 | (setq c++-mode-hook c-mode-hook) | ||
| 2024 | @end group | ||
| 2025 | @end example | ||
| 2026 | |||
| 2027 | At the appropriate time, Emacs uses the @code{run-hooks} function to | 2017 | At the appropriate time, Emacs uses the @code{run-hooks} function to |
| 2028 | run particular hooks. This function calls the hook functions that have | 2018 | run particular hooks. This function calls the hook functions that have |
| 2029 | been added with @code{add-hook}. | 2019 | been added with @code{add-hook}. |
| @@ -2068,13 +2058,12 @@ It is best to design your hook functions so that the order in which they | |||
| 2068 | are executed does not matter. Any dependence on the order is ``asking | 2058 | are executed does not matter. Any dependence on the order is ``asking |
| 2069 | for trouble.'' However, the order is predictable: normally, | 2059 | for trouble.'' However, the order is predictable: normally, |
| 2070 | @var{function} goes at the front of the hook list, so it will be | 2060 | @var{function} goes at the front of the hook list, so it will be |
| 2071 | executed first (barring another @code{add-hook} call). | 2061 | executed first (barring another @code{add-hook} call). If the optional |
| 2072 | 2062 | argument @var{append} is non-@code{nil}, the new hook function goes at | |
| 2073 | If the optional argument @var{append} is non-@code{nil}, the new hook | 2063 | the end of the hook list and will be executed last. |
| 2074 | function goes at the end of the hook list and will be executed last. | ||
| 2075 | 2064 | ||
| 2076 | If @var{local} is non-@code{nil}, that says to make the new hook | 2065 | If @var{local} is non-@code{nil}, that says to make the new hook |
| 2077 | function local to the current buffer. Before you can do this, you must | 2066 | function buffer-local in the current buffer. Before you can do this, you must |
| 2078 | make the hook itself buffer-local by calling @code{make-local-hook} | 2067 | make the hook itself buffer-local by calling @code{make-local-hook} |
| 2079 | (@strong{not} @code{make-local-variable}). If the hook itself is not | 2068 | (@strong{not} @code{make-local-variable}). If the hook itself is not |
| 2080 | buffer-local, then the value of @var{local} makes no difference---the | 2069 | buffer-local, then the value of @var{local} makes no difference---the |
| @@ -2085,22 +2074,24 @@ hook function is always global. | |||
| 2085 | This function removes @var{function} from the hook variable @var{hook}. | 2074 | This function removes @var{function} from the hook variable @var{hook}. |
| 2086 | 2075 | ||
| 2087 | If @var{local} is non-@code{nil}, that says to remove @var{function} | 2076 | If @var{local} is non-@code{nil}, that says to remove @var{function} |
| 2088 | from the local hook list instead of from the global hook list. If the | 2077 | from the buffer-local hook list instead of from the global hook list. |
| 2089 | hook itself is not buffer-local, then the value of @var{local} makes no | 2078 | If the hook variable itself is not buffer-local, then the value of |
| 2090 | difference. | 2079 | @var{local} makes no difference. |
| 2091 | @end defun | 2080 | @end defun |
| 2092 | 2081 | ||
| 2093 | @defun make-local-hook hook | 2082 | @defun make-local-hook hook |
| 2094 | This function makes the hook variable @code{hook} local to the current | 2083 | This function makes the hook variable @code{hook} buffer-local in the |
| 2095 | buffer. When a hook variable is local, it can have local and global | 2084 | current buffer. When a hook variable is buffer-local, it can have |
| 2096 | hook functions, and @code{run-hooks} runs all of them. | 2085 | buffer-local and global hook functions, and @code{run-hooks} runs all of |
| 2086 | them. | ||
| 2097 | 2087 | ||
| 2098 | This function works by making @code{t} an element of the buffer-local | 2088 | This function works by making @code{t} an element of the buffer-local |
| 2099 | value. That serves as a flag to use the hook functions in the default | 2089 | value. That serves as a flag to use the hook functions in the default |
| 2100 | value of the hook variable as well as those in the local value. Since | 2090 | value of the hook variable as well as those in the buffer-local value. |
| 2101 | @code{run-hooks} understands this flag, @code{make-local-hook} works | 2091 | Since @code{run-hooks} understands this flag, @code{make-local-hook} |
| 2102 | with all normal hooks. It works for only some non-normal hooks---those | 2092 | works with all normal hooks. It works for only some non-normal |
| 2103 | whose callers have been updated to understand this meaning of @code{t}. | 2093 | hooks---those whose callers have been updated to understand this meaning |
| 2094 | of @code{t}. | ||
| 2104 | 2095 | ||
| 2105 | Do not use @code{make-local-variable} directly for hook variables; it is | 2096 | Do not use @code{make-local-variable} directly for hook variables; it is |
| 2106 | not sufficient. | 2097 | not sufficient. |
diff --git a/lispref/nonascii.texi b/lispref/nonascii.texi index 16a22f2c443..f75900d6818 100644 --- a/lispref/nonascii.texi +++ b/lispref/nonascii.texi | |||
| @@ -20,9 +20,12 @@ characters and how they are stored in strings and buffers. | |||
| 20 | * Scanning Charsets:: | 20 | * Scanning Charsets:: |
| 21 | * Chars and Bytes:: | 21 | * Chars and Bytes:: |
| 22 | * Coding Systems:: | 22 | * Coding Systems:: |
| 23 | * Lisp and Coding System:: | ||
| 23 | * Default Coding Systems:: | 24 | * Default Coding Systems:: |
| 24 | * Specifying Coding Systems:: | 25 | * Specifying Coding Systems:: |
| 25 | * Explicit Encoding:: | 26 | * Explicit Encoding:: |
| 27 | * MS-DOS File Types:: | ||
| 28 | * MS-DOS Subprocesses:: | ||
| 26 | @end menu | 29 | @end menu |
| 27 | 30 | ||
| 28 | @node Text Representations | 31 | @node Text Representations |
| @@ -41,8 +44,8 @@ attention to the difference. | |||
| 41 | In unibyte representation, each character occupies one byte and | 44 | In unibyte representation, each character occupies one byte and |
| 42 | therefore the possible character codes range from 0 to 255. Codes 0 | 45 | therefore the possible character codes range from 0 to 255. Codes 0 |
| 43 | through 127 are @sc{ASCII} characters; the codes from 128 through 255 | 46 | through 127 are @sc{ASCII} characters; the codes from 128 through 255 |
| 44 | are used for one non-@sc{ASCII} character set (you can choose which one | 47 | are used for one non-@sc{ASCII} character set (you can choose which |
| 45 | by setting the variable @code{nonascii-insert-offset}). | 48 | character set by setting the variable @code{nonascii-insert-offset}). |
| 46 | 49 | ||
| 47 | @cindex leading code | 50 | @cindex leading code |
| 48 | @cindex multibyte text | 51 | @cindex multibyte text |
| @@ -67,9 +70,8 @@ This variable specifies the current buffer's text representation. | |||
| 67 | If it is non-@code{nil}, the buffer contains multibyte text; otherwise, | 70 | If it is non-@code{nil}, the buffer contains multibyte text; otherwise, |
| 68 | it contains unibyte text. | 71 | it contains unibyte text. |
| 69 | 72 | ||
| 70 | @strong{Warning:} do not set this variable directly; instead, use the | 73 | You cannot set this variable directly; instead, use the function |
| 71 | function @code{set-buffer-multibyte} to change a buffer's | 74 | @code{set-buffer-multibyte} to change a buffer's representation. |
| 72 | representation. | ||
| 73 | @end defvar | 75 | @end defvar |
| 74 | 76 | ||
| 75 | @tindex default-enable-multibyte-characters | 77 | @tindex default-enable-multibyte-characters |
| @@ -112,17 +114,17 @@ to unibyte, even though this conversion cannot in general preserve all | |||
| 112 | the characters that might be in the multibyte text. The other natural | 114 | the characters that might be in the multibyte text. The other natural |
| 113 | alternative, to convert the buffer contents to multibyte, is not | 115 | alternative, to convert the buffer contents to multibyte, is not |
| 114 | acceptable because the buffer's representation is a choice made by the | 116 | acceptable because the buffer's representation is a choice made by the |
| 115 | user that cannot simply be overrided. | 117 | user that cannot be overridden automatically. |
| 116 | 118 | ||
| 117 | Converting unibyte text to multibyte text leaves @sc{ASCII} characters | 119 | Converting unibyte text to multibyte text leaves @sc{ASCII} characters |
| 118 | unchanged. It converts the non-@sc{ASCII} codes 128 through 255 by | 120 | unchanged, and likewise 128 through 159. It converts the non-@sc{ASCII} |
| 119 | adding the value @code{nonascii-insert-offset} to each character code. | 121 | codes 160 through 255 by adding the value @code{nonascii-insert-offset} |
| 120 | By setting this variable, you specify which character set the unibyte | 122 | to each character code. By setting this variable, you specify which |
| 121 | characters correspond to. For example, if @code{nonascii-insert-offset} | 123 | character set the unibyte characters correspond to. For example, if |
| 122 | is 2048, which is @code{(- (make-char 'latin-iso8859-1 0) 128)}, then | 124 | @code{nonascii-insert-offset} is 2048, which is @code{(- (make-char |
| 123 | the unibyte non-@sc{ASCII} characters correspond to Latin 1. If it is | 125 | 'latin-iso8859-1 0) 128)}, then the unibyte non-@sc{ASCII} characters |
| 124 | 2688, which is @code{(- (make-char 'greek-iso8859-7 0) 128)}, then they | 126 | correspond to Latin 1. If it is 2688, which is @code{(- (make-char |
| 125 | correspond to Greek letters. | 127 | 'greek-iso8859-7 0) 128)}, then they correspond to Greek letters. |
| 126 | 128 | ||
| 127 | Converting multibyte text to unibyte is simpler: it performs | 129 | Converting multibyte text to unibyte is simpler: it performs |
| 128 | logical-and of each character code with 255. If | 130 | logical-and of each character code with 255. If |
| @@ -150,22 +152,21 @@ This variable provides a more general alternative to | |||
| 150 | @code{nonascii-insert-offset}. You can use it to specify independently | 152 | @code{nonascii-insert-offset}. You can use it to specify independently |
| 151 | how to translate each code in the range of 128 through 255 into a | 153 | how to translate each code in the range of 128 through 255 into a |
| 152 | multibyte character. The value should be a vector, or @code{nil}. | 154 | multibyte character. The value should be a vector, or @code{nil}. |
| 155 | If this is non-@code{nil}, it overrides @code{nonascii-insert-offset}. | ||
| 153 | @end defvar | 156 | @end defvar |
| 154 | 157 | ||
| 155 | @tindex string-make-unibyte | 158 | @tindex string-make-unibyte |
| 156 | @defun string-make-unibyte string | 159 | @defun string-make-unibyte string |
| 157 | This function converts the text of @var{string} to unibyte | 160 | This function converts the text of @var{string} to unibyte |
| 158 | representation, if it isn't already, and return the result. If | 161 | representation, if it isn't already, and return the result. If |
| 159 | conversion does not change the contents, the value may be @var{string} | 162 | @var{string} is a unibyte string, it is returned unchanged. |
| 160 | itself. | ||
| 161 | @end defun | 163 | @end defun |
| 162 | 164 | ||
| 163 | @tindex string-make-multibyte | 165 | @tindex string-make-multibyte |
| 164 | @defun string-make-multibyte string | 166 | @defun string-make-multibyte string |
| 165 | This function converts the text of @var{string} to multibyte | 167 | This function converts the text of @var{string} to multibyte |
| 166 | representation, if it isn't already, and return the result. If | 168 | representation, if it isn't already, and return the result. If |
| 167 | conversion does not change the contents, the value may be @var{string} | 169 | @var{string} is a multibyte string, it is returned unchanged. |
| 168 | itself. | ||
| 169 | @end defun | 170 | @end defun |
| 170 | 171 | ||
| 171 | @node Selecting a Representation | 172 | @node Selecting a Representation |
| @@ -188,8 +189,8 @@ representation. | |||
| 188 | 189 | ||
| 189 | This function sets @code{enable-multibyte-characters} to record which | 190 | This function sets @code{enable-multibyte-characters} to record which |
| 190 | representation is in use. It also adjusts various data in the buffer | 191 | representation is in use. It also adjusts various data in the buffer |
| 191 | (including its overlays, text properties and markers) so that they | 192 | (including overlays, text properties and markers) so that they cover the |
| 192 | cover or fall between the same text as they did before. | 193 | same text as they did before. |
| 193 | @end defun | 194 | @end defun |
| 194 | 195 | ||
| 195 | @tindex string-as-unibyte | 196 | @tindex string-as-unibyte |
| @@ -198,7 +199,7 @@ This function returns a string with the same bytes as @var{string} but | |||
| 198 | treating each byte as a character. This means that the value may have | 199 | treating each byte as a character. This means that the value may have |
| 199 | more characters than @var{string} has. | 200 | more characters than @var{string} has. |
| 200 | 201 | ||
| 201 | If @var{string} is unibyte already, then the value may be @var{string} | 202 | If @var{string} is unibyte already, then the value is @var{string} |
| 202 | itself. | 203 | itself. |
| 203 | @end defun | 204 | @end defun |
| 204 | 205 | ||
| @@ -208,7 +209,7 @@ This function returns a string with the same bytes as @var{string} but | |||
| 208 | treating each multibyte sequence as one character. This means that the | 209 | treating each multibyte sequence as one character. This means that the |
| 209 | value may have fewer characters than @var{string} has. | 210 | value may have fewer characters than @var{string} has. |
| 210 | 211 | ||
| 211 | If @var{string} is multibyte already, then the value may be @var{string} | 212 | If @var{string} is multibyte already, then the value is @var{string} |
| 212 | itself. | 213 | itself. |
| 213 | @end defun | 214 | @end defun |
| 214 | 215 | ||
| @@ -221,8 +222,9 @@ codes. The valid character codes for unibyte representation range from | |||
| 221 | 0 to 255---the values that can fit in one byte. The valid character | 222 | 0 to 255---the values that can fit in one byte. The valid character |
| 222 | codes for multibyte representation range from 0 to 524287, but not all | 223 | codes for multibyte representation range from 0 to 524287, but not all |
| 223 | values in that range are valid. In particular, the values 128 through | 224 | values in that range are valid. In particular, the values 128 through |
| 224 | 255 are not valid in multibyte text. Only the @sc{ASCII} codes 0 | 225 | 255 are not legitimate in multibyte text (though they can occur in ``raw |
| 225 | through 127 are used in both representations. | 226 | bytes''; @pxref{Explicit Encoding}). Only the @sc{ASCII} codes 0 |
| 227 | through 127 are fully legitimate in both representations. | ||
| 226 | 228 | ||
| 227 | @defun char-valid-p charcode | 229 | @defun char-valid-p charcode |
| 228 | This returns @code{t} if @var{charcode} is valid for either one of the two | 230 | This returns @code{t} if @var{charcode} is valid for either one of the two |
| @@ -249,11 +251,11 @@ only one character set. | |||
| 249 | In general, there is one character set for each distinct script. For | 251 | In general, there is one character set for each distinct script. For |
| 250 | example, @code{latin-iso8859-1} is one character set, | 252 | example, @code{latin-iso8859-1} is one character set, |
| 251 | @code{greek-iso8859-7} is another, and @code{ascii} is another. An | 253 | @code{greek-iso8859-7} is another, and @code{ascii} is another. An |
| 252 | Emacs character set can hold at most 9025 characters; therefore. in some | 254 | Emacs character set can hold at most 9025 characters; therefore, in some |
| 253 | cases, a set of characters that would logically be grouped together are | 255 | cases, characters that would logically be grouped together are split |
| 254 | split into several character sets. For example, one set of Chinese | 256 | into several character sets. For example, one set of Chinese characters |
| 255 | characters is divided into eight Emacs character sets, | 257 | is divided into eight Emacs character sets, @code{chinese-cns11643-1} |
| 256 | @code{chinese-cns11643-1} through @code{chinese-cns11643-7}. | 258 | through @code{chinese-cns11643-7}. |
| 257 | 259 | ||
| 258 | @tindex charsetp | 260 | @tindex charsetp |
| 259 | @defun charsetp object | 261 | @defun charsetp object |
| @@ -299,14 +301,17 @@ that appear in the string @var{string}. | |||
| 299 | 301 | ||
| 300 | In multibyte representation, each character occupies one or more | 302 | In multibyte representation, each character occupies one or more |
| 301 | bytes. The functions in this section convert between characters and the | 303 | bytes. The functions in this section convert between characters and the |
| 302 | byte values used to represent them. | 304 | byte values used to represent them. For most purposes, there is no need |
| 305 | to be concerned with the number of bytes used to represent a character | ||
| 306 | because Emacs translates automatically when necessary. | ||
| 303 | 307 | ||
| 304 | @tindex char-bytes | 308 | @tindex char-bytes |
| 305 | @defun char-bytes character | 309 | @defun char-bytes character |
| 306 | This function returns the number of bytes used to represent the | 310 | This function returns the number of bytes used to represent the |
| 307 | character @var{character}. In most cases, this is the same as | 311 | character @var{character}. In most cases, this is the same as |
| 308 | @code{(length (split-char @var{character}))}; the only exception is for | 312 | @code{(length (split-char @var{character}))}; the only exception is for |
| 309 | ASCII characters, which use just one byte. | 313 | ASCII characters and the codes used in unibyte text, which use just one |
| 314 | byte. | ||
| 310 | 315 | ||
| 311 | @example | 316 | @example |
| 312 | (char-bytes 2248) | 317 | (char-bytes 2248) |
| @@ -378,17 +383,18 @@ cases, Emacs supports several alternative encodings for the same | |||
| 378 | characters; for example, there are three coding systems for the Cyrillic | 383 | characters; for example, there are three coding systems for the Cyrillic |
| 379 | (Russian) alphabet: ISO, Alternativnyj, and KOI8. | 384 | (Russian) alphabet: ISO, Alternativnyj, and KOI8. |
| 380 | 385 | ||
| 381 | @cindex end of line conversion | ||
| 382 | @dfn{End of line conversion} handles three different conventions used | ||
| 383 | on various systems for end of line. The Unix convention is to use the | ||
| 384 | linefeed character (also called newline). The DOS convention is to use | ||
| 385 | the two character sequence, carriage-return linefeed, at the end of a | ||
| 386 | line. The Mac convention is to use just carriage-return. | ||
| 387 | |||
| 388 | Most coding systems specify a particular character code for | 386 | Most coding systems specify a particular character code for |
| 389 | conversion, but some of them leave this unspecified---to be chosen | 387 | conversion, but some of them leave this unspecified---to be chosen |
| 390 | heuristically based on the data. | 388 | heuristically based on the data. |
| 391 | 389 | ||
| 390 | @cindex end of line conversion | ||
| 391 | @dfn{End of line conversion} handles three different conventions used | ||
| 392 | on various systems for representing end of line in files. The Unix | ||
| 393 | convention is to use the linefeed character (also called newline). The | ||
| 394 | DOS convention is to use the two character sequence, carriage-return | ||
| 395 | linefeed, at the end of a line. The Mac convention is to use just | ||
| 396 | carriage-return. | ||
| 397 | |||
| 392 | @cindex base coding system | 398 | @cindex base coding system |
| 393 | @cindex variant coding system | 399 | @cindex variant coding system |
| 394 | @dfn{Base coding systems} such as @code{latin-1} leave the end-of-line | 400 | @dfn{Base coding systems} such as @code{latin-1} leave the end-of-line |
| @@ -398,6 +404,9 @@ coding systems} such as @code{latin-1-unix}, @code{latin-1-dos} and | |||
| 398 | well. Each base coding system has three corresponding variants whose | 404 | well. Each base coding system has three corresponding variants whose |
| 399 | names are formed by adding @samp{-unix}, @samp{-dos} and @samp{-mac}. | 405 | names are formed by adding @samp{-unix}, @samp{-dos} and @samp{-mac}. |
| 400 | 406 | ||
| 407 | @node Lisp and Coding Systems | ||
| 408 | @subsection Coding Systems in Lisp | ||
| 409 | |||
| 401 | Here are Lisp facilities for working with coding systems; | 410 | Here are Lisp facilities for working with coding systems; |
| 402 | 411 | ||
| 403 | @tindex coding-system-list | 412 | @tindex coding-system-list |
| @@ -420,11 +429,21 @@ If that is valid, it returns @var{coding-system}. | |||
| 420 | Otherwise it signals an error with condition @code{coding-system-error}. | 429 | Otherwise it signals an error with condition @code{coding-system-error}. |
| 421 | @end defun | 430 | @end defun |
| 422 | 431 | ||
| 432 | @tindex find-safe-coding-system | ||
| 433 | @defun find-safe-coding-system from to | ||
| 434 | Return a list of proper coding systems to encode a text between | ||
| 435 | @var{from} and @var{to}. All coding systems in the list can safely | ||
| 436 | encode any multibyte characters in the text. | ||
| 437 | |||
| 438 | If the text contains no multibyte characters, return a list of a single | ||
| 439 | element @code{undecided}. | ||
| 440 | @end defun | ||
| 441 | |||
| 423 | @tindex detect-coding-region | 442 | @tindex detect-coding-region |
| 424 | @defun detect-coding-region start end highest | 443 | @defun detect-coding-region start end highest |
| 425 | This function chooses a plausible coding system for decoding the text | 444 | This function chooses a plausible coding system for decoding the text |
| 426 | from @var{start} to @var{end}. This text should be ``raw bytes'' | 445 | from @var{start} to @var{end}. This text should be ``raw bytes'' |
| 427 | (@pxref{Specifying Coding Systems}). | 446 | (@pxref{Explicit Encoding}). |
| 428 | 447 | ||
| 429 | Normally this function returns is a list of coding systems that could | 448 | Normally this function returns is a list of coding systems that could |
| 430 | handle decoding the text that was scanned. They are listed in order of | 449 | handle decoding the text that was scanned. They are listed in order of |
| @@ -473,6 +492,25 @@ This function looks up the target in @code{file-coding-system-alist}, | |||
| 473 | @xref{Default Coding Systems}. | 492 | @xref{Default Coding Systems}. |
| 474 | @end defun | 493 | @end defun |
| 475 | 494 | ||
| 495 | Here are two functions you can use to let the user specify a coding | ||
| 496 | system, with completion. @xref{Completion}. | ||
| 497 | |||
| 498 | @tindex read-coding-system | ||
| 499 | @defun read-coding-system prompt default | ||
| 500 | This function reads a coding system using the minibuffer, prompting with | ||
| 501 | string @var{prompt}, and returns the coding system name as a symbol. If | ||
| 502 | the user enters null input, @var{default} specifies which coding system | ||
| 503 | to return. It should be a symbol or a string. | ||
| 504 | @end defun | ||
| 505 | |||
| 506 | @tindex read-non-nil-coding-system | ||
| 507 | @defun read-non-nil-coding-system prompt | ||
| 508 | This function reads a coding system using the minibuffer, prompting with | ||
| 509 | string @var{prompt},and returns the coding system name as a symbol. If | ||
| 510 | the user tries to enter null input, it asks the user to try again. | ||
| 511 | @xref{Coding Systems}. | ||
| 512 | @end defun | ||
| 513 | |||
| 476 | @node Default Coding Systems | 514 | @node Default Coding Systems |
| 477 | @section Default Coding Systems | 515 | @section Default Coding Systems |
| 478 | 516 | ||
| @@ -480,9 +518,9 @@ This function looks up the target in @code{file-coding-system-alist}, | |||
| 480 | certain files or when running certain subprograms. The idea of these | 518 | certain files or when running certain subprograms. The idea of these |
| 481 | variables is that you set them once and for all to the defaults you | 519 | variables is that you set them once and for all to the defaults you |
| 482 | want, and then do not change them again. To specify a particular coding | 520 | want, and then do not change them again. To specify a particular coding |
| 483 | system for a particular operation, don't change these variables; | 521 | system for a particular operation in a Lisp program, don't change these |
| 484 | instead, override them using @code{coding-system-for-read} and | 522 | variables; instead, override them using @code{coding-system-for-read} |
| 485 | @code{coding-system-for-write} (@pxref{Specifying Coding Systems}). | 523 | and @code{coding-system-for-write} (@pxref{Specifying Coding Systems}). |
| 486 | 524 | ||
| 487 | @tindex file-coding-system-alist | 525 | @tindex file-coding-system-alist |
| 488 | @defvar file-coding-system-alist | 526 | @defvar file-coding-system-alist |
| @@ -519,7 +557,7 @@ other coding systems later using @code{set-process-coding-system}. | |||
| 519 | @defvar network-coding-system-alist | 557 | @defvar network-coding-system-alist |
| 520 | This variable is an alist that specifies the coding system to use for | 558 | This variable is an alist that specifies the coding system to use for |
| 521 | network streams. It works much like @code{file-coding-system-alist}, | 559 | network streams. It works much like @code{file-coding-system-alist}, |
| 522 | with the difference that the @var{pattern} in an elemetn may be either a | 560 | with the difference that the @var{pattern} in an element may be either a |
| 523 | port number or a regular expression. If it is a regular expression, it | 561 | port number or a regular expression. If it is a regular expression, it |
| 524 | is matched against the network service name used to open the network | 562 | is matched against the network service name used to open the network |
| 525 | stream. | 563 | stream. |
| @@ -561,7 +599,7 @@ of the right way to use the variable: | |||
| 561 | 599 | ||
| 562 | @example | 600 | @example |
| 563 | ;; @r{Read the file with no character code conversion.} | 601 | ;; @r{Read the file with no character code conversion.} |
| 564 | ;; @r{Assume CRLF represents end-of-line.} | 602 | ;; @r{Assume @sc{crlf} represents end-of-line.} |
| 565 | (let ((coding-system-for-write 'emacs-mule-dos)) | 603 | (let ((coding-system-for-write 'emacs-mule-dos)) |
| 566 | (insert-file-contents filename)) | 604 | (insert-file-contents filename)) |
| 567 | @end example | 605 | @end example |
| @@ -587,7 +625,7 @@ affect it. | |||
| 587 | 625 | ||
| 588 | @tindex last-coding-system-used | 626 | @tindex last-coding-system-used |
| 589 | @defvar last-coding-system-used | 627 | @defvar last-coding-system-used |
| 590 | All operations that use a coding system set this variable | 628 | All I/O operations that use a coding system set this variable |
| 591 | to the coding system name that was used. | 629 | to the coding system name that was used. |
| 592 | @end defvar | 630 | @end defvar |
| 593 | 631 | ||
| @@ -646,32 +684,34 @@ text. They are ``raw bytes''---bytes that represent text in the same | |||
| 646 | way that an external file would. When a buffer contains raw bytes, it | 684 | way that an external file would. When a buffer contains raw bytes, it |
| 647 | is most natural to mark that buffer as using unibyte representation, | 685 | is most natural to mark that buffer as using unibyte representation, |
| 648 | using @code{set-buffer-multibyte} (@pxref{Selecting a Representation}), | 686 | using @code{set-buffer-multibyte} (@pxref{Selecting a Representation}), |
| 649 | but this is not required. | 687 | but this is not required. If the buffer's contents are only temporarily |
| 688 | raw, leave the buffer multibyte, which will be correct after you decode | ||
| 689 | them. | ||
| 650 | 690 | ||
| 651 | The usual way to get raw bytes in a buffer, for explicit decoding, is | 691 | The usual way to get raw bytes in a buffer, for explicit decoding, is |
| 652 | to read them with from a file with @code{insert-file-contents-literally} | 692 | to read them from a file with @code{insert-file-contents-literally} |
| 653 | (@pxref{Reading from Files}) or specify a non-@code{nil} @var{rawfile} | 693 | (@pxref{Reading from Files}) or specify a non-@code{nil} @var{rawfile} |
| 654 | arguments when visiting a file with @code{find-file-noselect}. | 694 | argument when visiting a file with @code{find-file-noselect}. |
| 655 | 695 | ||
| 656 | The usual way to use the raw bytes that result from explicitly | 696 | The usual way to use the raw bytes that result from explicitly |
| 657 | encoding text is to copy them to a file or process---for example, to | 697 | encoding text is to copy them to a file or process---for example, to |
| 658 | write it with @code{write-region} (@pxref{Writing to Files}), and | 698 | write them with @code{write-region} (@pxref{Writing to Files}), and |
| 659 | suppress encoding for that @code{write-region} call by binding | 699 | suppress encoding for that @code{write-region} call by binding |
| 660 | @code{coding-system-for-write} to @code{no-conversion}. | 700 | @code{coding-system-for-write} to @code{no-conversion}. |
| 661 | 701 | ||
| 662 | @tindex encode-coding-region | 702 | @tindex encode-coding-region |
| 663 | @defun encode-coding-region start end coding-system | 703 | @defun encode-coding-region start end coding-system |
| 664 | This function encodes the text from @var{start} to @var{end} according | 704 | This function encodes the text from @var{start} to @var{end} according |
| 665 | to coding system @var{coding-system}. The encoded text replaces | 705 | to coding system @var{coding-system}. The encoded text replaces the |
| 666 | the original text in the buffer. The result of encoding is | 706 | original text in the buffer. The result of encoding is ``raw bytes,'' |
| 667 | ``raw bytes.'' | 707 | but the buffer remains multibyte if it was multibyte before. |
| 668 | @end defun | 708 | @end defun |
| 669 | 709 | ||
| 670 | @tindex encode-coding-string | 710 | @tindex encode-coding-string |
| 671 | @defun encode-coding-string string coding-system | 711 | @defun encode-coding-string string coding-system |
| 672 | This function encodes the text in @var{string} according to coding | 712 | This function encodes the text in @var{string} according to coding |
| 673 | system @var{coding-system}. It returns a new string containing the | 713 | system @var{coding-system}. It returns a new string containing the |
| 674 | encoded text. The result of encoding is ``raw bytes.'' | 714 | encoded text. The result of encoding is a unibyte string of ``raw bytes.'' |
| 675 | @end defun | 715 | @end defun |
| 676 | 716 | ||
| 677 | @tindex decode-coding-region | 717 | @tindex decode-coding-region |
| @@ -689,3 +729,72 @@ system @var{coding-system}. It returns a new string containing the | |||
| 689 | decoded text. To make explicit decoding useful, the contents of | 729 | decoded text. To make explicit decoding useful, the contents of |
| 690 | @var{string} ought to be ``raw bytes.'' | 730 | @var{string} ought to be ``raw bytes.'' |
| 691 | @end defun | 731 | @end defun |
| 732 | |||
| 733 | @node MS-DOS File Types | ||
| 734 | @section MS-DOS File Types | ||
| 735 | @cindex DOS file types | ||
| 736 | @cindex MS-DOS file types | ||
| 737 | @cindex Windows file types | ||
| 738 | @cindex file types on MS-DOS and Windows | ||
| 739 | @cindex text files and binary files | ||
| 740 | @cindex binary files and text files | ||
| 741 | |||
| 742 | Emacs on MS-DOS and on MS-Windows recognizes certain file names as | ||
| 743 | text files or binary files. For a text file, Emacs always uses DOS | ||
| 744 | end-of-line conversion. For a binary file, Emacs does no end-of-line | ||
| 745 | conversion and no character code conversion. | ||
| 746 | |||
| 747 | @defvar buffer-file-type | ||
| 748 | This variable, automatically buffer-local in each buffer, records the | ||
| 749 | file type of the buffer's visited file. The value is @code{nil} for | ||
| 750 | text, @code{t} for binary. When a buffer does not specify a coding | ||
| 751 | system with @code{buffer-file-coding-system}, this variable is used by | ||
| 752 | the function @code{find-buffer-file-type-coding-system} to determine | ||
| 753 | which coding system to use when writing the contents of the buffer. | ||
| 754 | @end defvar | ||
| 755 | |||
| 756 | @defopt file-name-buffer-file-type-alist | ||
| 757 | This variable holds an alist for recognizing text and binary files. | ||
| 758 | Each element has the form (@var{regexp} . @var{type}), where | ||
| 759 | @var{regexp} is matched against the file name, and @var{type} may be | ||
| 760 | @code{nil} for text, @code{t} for binary, or a function to call to | ||
| 761 | compute which. If it is a function, then it is called with a single | ||
| 762 | argument (the file name) and should return @code{t} or @code{nil}. | ||
| 763 | |||
| 764 | Emacs when running on MS-DOS or MS-Windows checks this alist to decide | ||
| 765 | which coding system to use when reading a file. For a text file, | ||
| 766 | @code{undecided-dos} is used. For a binary file, @code{no-conversion} | ||
| 767 | is used. | ||
| 768 | |||
| 769 | If no element in this alist matches a given file name, then | ||
| 770 | @code{default-buffer-file-type} says how to treat the file. | ||
| 771 | @end defopt | ||
| 772 | |||
| 773 | @defopt default-buffer-file-type | ||
| 774 | This variable says how to handle files for which | ||
| 775 | @code{file-name-buffer-file-type-alist} says nothing about the type. | ||
| 776 | |||
| 777 | If this variable is non-@code{nil}, then these files are treated as | ||
| 778 | binary. Otherwise, nothing special is done for them---the coding system | ||
| 779 | is deduced solely from the file contents, in the usual Emacs fashion. | ||
| 780 | @end defopt | ||
| 781 | |||
| 782 | @node MS-DOS Subprocesses | ||
| 783 | @section MS-DOS Subprocesses | ||
| 784 | |||
| 785 | On Microsoft operating systems, these variables provide an alternative | ||
| 786 | way to specify the kind of end-of-line conversion to use for input and | ||
| 787 | output. The variable @code{binary-process-input} applies to input sent | ||
| 788 | to the subprocess, and @code{binary-process-output} applies to output | ||
| 789 | received from it. A non-@code{nil} value means the data is ``binary,'' | ||
| 790 | and @code{nil} means the data is text. | ||
| 791 | |||
| 792 | @defvar binary-process-input | ||
| 793 | If this variable is @code{nil}, convert newlines to @sc{crlf} sequences in | ||
| 794 | the input to a synchronous subprocess. | ||
| 795 | @end defvar | ||
| 796 | |||
| 797 | @defvar binary-process-output | ||
| 798 | If this variable is @code{nil}, convert @sc{crlf} sequences to newlines in | ||
| 799 | the output from a synchronous subprocess. | ||
| 800 | @end defvar | ||
diff --git a/lispref/numbers.texi b/lispref/numbers.texi index ab03d384b7e..daee3890e77 100644 --- a/lispref/numbers.texi +++ b/lispref/numbers.texi | |||
| @@ -12,9 +12,9 @@ | |||
| 12 | @dfn{floating point numbers}. Integers are whole numbers such as | 12 | @dfn{floating point numbers}. Integers are whole numbers such as |
| 13 | @minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point | 13 | @minus{}3, 0, 7, 13, and 511. Their values are exact. Floating point |
| 14 | numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or | 14 | numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or |
| 15 | 2.71828. They can also be expressed in exponential notation: | 15 | 2.71828. They can also be expressed in exponential notation: 1.5e2 |
| 16 | 1.5e2 equals 150; in this example, @samp{e2} stands for ten to the | 16 | equals 150; in this example, @samp{e2} stands for ten to the second |
| 17 | second power, and is multiplied by 1.5. Floating point values are not | 17 | power, and that is multiplied by 1.5. Floating point values are not |
| 18 | exact; they have a fixed, limited amount of precision. | 18 | exact; they have a fixed, limited amount of precision. |
| 19 | 19 | ||
| 20 | @menu | 20 | @menu |
| @@ -149,9 +149,9 @@ values. It also provides for a class of values called NaN or | |||
| 149 | there is no correct answer. For example, @code{(sqrt -1.0)} returns a | 149 | there is no correct answer. For example, @code{(sqrt -1.0)} returns a |
| 150 | NaN. For practical purposes, there's no significant difference between | 150 | NaN. For practical purposes, there's no significant difference between |
| 151 | different NaN values in Emacs Lisp, and there's no rule for precisely | 151 | different NaN values in Emacs Lisp, and there's no rule for precisely |
| 152 | which NaN value should be used in a particular case, so this manual | 152 | which NaN value should be used in a particular case, so Emacs Lisp |
| 153 | doesn't try to distinguish them. Here are the read syntaxes for | 153 | doesn't try to distinguish them. Here are the read syntaxes for |
| 154 | these numbers: | 154 | these special floating point values: |
| 155 | 155 | ||
| 156 | @table @asis | 156 | @table @asis |
| 157 | @item positive infinity | 157 | @item positive infinity |
| @@ -162,6 +162,10 @@ these numbers: | |||
| 162 | @samp{0.0e+NaN}. | 162 | @samp{0.0e+NaN}. |
| 163 | @end table | 163 | @end table |
| 164 | 164 | ||
| 165 | In addition, the value @code{-0.0} is distinguishable from ordinary | ||
| 166 | zero in IEEE floating point (although @code{equal} and @code{=} consider | ||
| 167 | them equal values). | ||
| 168 | |||
| 165 | You can use @code{logb} to extract the binary exponent of a floating | 169 | You can use @code{logb} to extract the binary exponent of a floating |
| 166 | point number (or estimate the logarithm of an integer): | 170 | point number (or estimate the logarithm of an integer): |
| 167 | 171 | ||
| @@ -323,6 +327,10 @@ This function returns the smallest of its arguments. | |||
| 323 | @end example | 327 | @end example |
| 324 | @end defun | 328 | @end defun |
| 325 | 329 | ||
| 330 | @defun abs number | ||
| 331 | This returns the absolute value of @var{number}. | ||
| 332 | @end defun | ||
| 333 | |||
| 326 | @node Numeric Conversions | 334 | @node Numeric Conversions |
| 327 | @section Numeric Conversions | 335 | @section Numeric Conversions |
| 328 | @cindex rounding in conversions | 336 | @cindex rounding in conversions |
| @@ -378,7 +386,7 @@ commonly used. | |||
| 378 | All of these functions except @code{%} return a floating point value | 386 | All of these functions except @code{%} return a floating point value |
| 379 | if any argument is floating. | 387 | if any argument is floating. |
| 380 | 388 | ||
| 381 | It is important to note that in GNU Emacs Lisp, arithmetic functions | 389 | It is important to note that in Emacs Lisp, arithmetic functions |
| 382 | do not check for overflow. Thus @code{(1+ 134217727)} may evaluate to | 390 | do not check for overflow. Thus @code{(1+ 134217727)} may evaluate to |
| 383 | @minus{}134217728, depending on your hardware. | 391 | @minus{}134217728, depending on your hardware. |
| 384 | 392 | ||
| @@ -414,10 +422,6 @@ like this: | |||
| 414 | This function returns @var{number-or-marker} minus 1. | 422 | This function returns @var{number-or-marker} minus 1. |
| 415 | @end defun | 423 | @end defun |
| 416 | 424 | ||
| 417 | @defun abs number | ||
| 418 | This returns the absolute value of @var{number}. | ||
| 419 | @end defun | ||
| 420 | |||
| 421 | @defun + &rest numbers-or-markers | 425 | @defun + &rest numbers-or-markers |
| 422 | This function adds its arguments together. When given no arguments, | 426 | This function adds its arguments together. When given no arguments, |
| 423 | @code{+} returns 0. | 427 | @code{+} returns 0. |
| @@ -478,8 +482,10 @@ permits machine-dependent rounding. As a practical matter, all known | |||
| 478 | machines round in the standard fashion. | 482 | machines round in the standard fashion. |
| 479 | 483 | ||
| 480 | @cindex @code{arith-error} in division | 484 | @cindex @code{arith-error} in division |
| 481 | If you divide by 0, an @code{arith-error} error is signaled. | 485 | If you divide an integer by 0, an @code{arith-error} error is signaled. |
| 482 | (@xref{Errors}.) | 486 | (@xref{Errors}.) Floating point division by zero returns either |
| 487 | infinity or a NaN if your machine supports IEEE floating point; | ||
| 488 | otherwise, it signals an @code{arith-error} error. | ||
| 483 | 489 | ||
| 484 | @example | 490 | @example |
| 485 | @group | 491 | @group |
| @@ -488,6 +494,12 @@ If you divide by 0, an @code{arith-error} error is signaled. | |||
| 488 | @end group | 494 | @end group |
| 489 | (/ 5 2) | 495 | (/ 5 2) |
| 490 | @result{} 2 | 496 | @result{} 2 |
| 497 | (/ 5.0 2) | ||
| 498 | @result{} 2.5 | ||
| 499 | (/ 5 2.0) | ||
| 500 | @result{} 2.5 | ||
| 501 | (/ 5.0 2.0) | ||
| 502 | @result{} 2.5 | ||
| 491 | (/ 25 3 2) | 503 | (/ 25 3 2) |
| 492 | @result{} 4 | 504 | @result{} 4 |
| 493 | (/ -17 6) | 505 | (/ -17 6) |
| @@ -925,9 +937,8 @@ bit is one in the result if, and only if, the @var{n}th bit is zero in | |||
| 925 | @cindex transcendental functions | 937 | @cindex transcendental functions |
| 926 | @cindex mathematical functions | 938 | @cindex mathematical functions |
| 927 | 939 | ||
| 928 | These mathematical functions are available if floating point is | 940 | These mathematical functions allow integers as well as floating point |
| 929 | supported. They allow integers as well as floating point numbers | 941 | numbers as arguments. |
| 930 | as arguments. | ||
| 931 | 942 | ||
| 932 | @defun sin arg | 943 | @defun sin arg |
| 933 | @defunx cos arg | 944 | @defunx cos arg |
diff --git a/lispref/objects.texi b/lispref/objects.texi index 66734920de9..ea1e8fb1632 100644 --- a/lispref/objects.texi +++ b/lispref/objects.texi | |||
| @@ -25,7 +25,7 @@ but not for ``the'' type of an object. | |||
| 25 | which all other types are constructed, are called @dfn{primitive | 25 | which all other types are constructed, are called @dfn{primitive |
| 26 | types}. Each object belongs to one and only one primitive type. These | 26 | types}. Each object belongs to one and only one primitive type. These |
| 27 | types include @dfn{integer}, @dfn{float}, @dfn{cons}, @dfn{symbol}, | 27 | types include @dfn{integer}, @dfn{float}, @dfn{cons}, @dfn{symbol}, |
| 28 | @dfn{string}, @dfn{vector}, @dfn{subr}, @dfn{byte-code function}, and | 28 | @dfn{string}, @dfn{vector}, @dfn{subr}, @dfn{byte-code function}, plus |
| 29 | several special types, such as @dfn{buffer}, that are related to | 29 | several special types, such as @dfn{buffer}, that are related to |
| 30 | editing. (@xref{Editing Types}.) | 30 | editing. (@xref{Editing Types}.) |
| 31 | 31 | ||
| @@ -69,8 +69,9 @@ input accepted by the Lisp reader (the function @code{read}) for that | |||
| 69 | object. @xref{Read and Print}. | 69 | object. @xref{Read and Print}. |
| 70 | 70 | ||
| 71 | Most objects have more than one possible read syntax. Some types of | 71 | Most objects have more than one possible read syntax. Some types of |
| 72 | object have no read syntax; except for these cases, the printed | 72 | object have no read syntax, since it may not make sense to enter objects |
| 73 | representation of an object is also a read syntax for it. | 73 | of these types directly in a Lisp program. Except for these cases, the |
| 74 | printed representation of an object is also a read syntax for it. | ||
| 74 | 75 | ||
| 75 | In other languages, an expression is text; it has no other form. In | 76 | In other languages, an expression is text; it has no other form. In |
| 76 | Lisp, an expression is primarily a Lisp object and only secondarily the | 77 | Lisp, an expression is primarily a Lisp object and only secondarily the |
| @@ -80,14 +81,12 @@ mind, or you will occasionally be very confused. | |||
| 80 | 81 | ||
| 81 | @cindex hash notation | 82 | @cindex hash notation |
| 82 | Every type has a printed representation. Some types have no read | 83 | Every type has a printed representation. Some types have no read |
| 83 | syntax, since it may not make sense to enter objects of these types | 84 | syntax---for example, the buffer type has none. Objects of these types |
| 84 | directly in a Lisp program. For example, the buffer type does not have | 85 | are printed in @dfn{hash notation}: the characters @samp{#<} followed by |
| 85 | a read syntax. Objects of these types are printed in @dfn{hash | 86 | a descriptive string (typically the type name followed by the name of |
| 86 | notation}: the characters @samp{#<} followed by a descriptive string | 87 | the object), and closed with a matching @samp{>}. Hash notation cannot |
| 87 | (typically the type name followed by the name of the object), and closed | 88 | be read at all, so the Lisp reader signals the error |
| 88 | with a matching @samp{>}. Hash notation cannot be read at all, so the | 89 | @code{invalid-read-syntax} whenever it encounters @samp{#<}. |
| 89 | Lisp reader signals the error @code{invalid-read-syntax} whenever it | ||
| 90 | encounters @samp{#<}. | ||
| 91 | @kindex invalid-read-syntax | 90 | @kindex invalid-read-syntax |
| 92 | 91 | ||
| 93 | @example | 92 | @example |
| @@ -190,8 +189,7 @@ leading @samp{+} or a final @samp{.}. | |||
| 190 | 1 ; @r{The integer 1.} | 189 | 1 ; @r{The integer 1.} |
| 191 | 1. ; @r{Also The integer 1.} | 190 | 1. ; @r{Also The integer 1.} |
| 192 | +1 ; @r{Also the integer 1.} | 191 | +1 ; @r{Also the integer 1.} |
| 193 | 268435457 ; @r{Also the integer 1!} | 192 | 268435457 ; @r{Also the integer 1 on a 28-bit implementation.} |
| 194 | ; @r{ (on a 28-bit implementation)} | ||
| 195 | @end group | 193 | @end group |
| 196 | @end example | 194 | @end example |
| 197 | 195 | ||
| @@ -226,9 +224,10 @@ characters. @xref{String Type}. | |||
| 226 | 224 | ||
| 227 | Characters in strings, buffers, and files are currently limited to the | 225 | Characters in strings, buffers, and files are currently limited to the |
| 228 | range of 0 to 524287---nineteen bits. But not all values in that range | 226 | range of 0 to 524287---nineteen bits. But not all values in that range |
| 229 | are valid character codes. Characters that represent keyboard input | 227 | are valid character codes. Codes 0 through 127 are ASCII codes; the |
| 230 | have a much wider range, so they can modifier keys such as Control, Meta | 228 | rest are non-ASCII (@pxref{Non-ASCII Characters}). Characters that represent |
| 231 | and Shift. | 229 | keyboard input have a much wider range, to encode modifier keys such as |
| 230 | Control, Meta and Shift. | ||
| 232 | 231 | ||
| 233 | @cindex read syntax for characters | 232 | @cindex read syntax for characters |
| 234 | @cindex printed representation for characters | 233 | @cindex printed representation for characters |
| @@ -283,7 +282,7 @@ respectively. Thus, | |||
| 283 | ?\a @result{} 7 ; @r{@kbd{C-g}} | 282 | ?\a @result{} 7 ; @r{@kbd{C-g}} |
| 284 | ?\b @result{} 8 ; @r{backspace, @key{BS}, @kbd{C-h}} | 283 | ?\b @result{} 8 ; @r{backspace, @key{BS}, @kbd{C-h}} |
| 285 | ?\t @result{} 9 ; @r{tab, @key{TAB}, @kbd{C-i}} | 284 | ?\t @result{} 9 ; @r{tab, @key{TAB}, @kbd{C-i}} |
| 286 | ?\n @result{} 10 ; @r{newline, @key{LFD}, @kbd{C-j}} | 285 | ?\n @result{} 10 ; @r{newline, @kbd{C-j}} |
| 287 | ?\v @result{} 11 ; @r{vertical tab, @kbd{C-k}} | 286 | ?\v @result{} 11 ; @r{vertical tab, @kbd{C-k}} |
| 288 | ?\f @result{} 12 ; @r{formfeed character, @kbd{C-l}} | 287 | ?\f @result{} 12 ; @r{formfeed character, @kbd{C-l}} |
| 289 | ?\r @result{} 13 ; @r{carriage return, @key{RET}, @kbd{C-m}} | 288 | ?\r @result{} 13 ; @r{carriage return, @key{RET}, @kbd{C-m}} |
| @@ -314,9 +313,9 @@ equivalent to @samp{?\^I} and to @samp{?\^i}: | |||
| 314 | that exist in @sc{ASCII}; but for keyboard input purposes, you can turn | 313 | that exist in @sc{ASCII}; but for keyboard input purposes, you can turn |
| 315 | any character into a control character with @samp{C-}. The character | 314 | any character into a control character with @samp{C-}. The character |
| 316 | codes for these non-@sc{ASCII} control characters include the | 315 | codes for these non-@sc{ASCII} control characters include the |
| 317 | @iftex | 316 | @tex |
| 318 | $2^{26}$ | 317 | $2^{26}$ |
| 319 | @end iftex | 318 | @end tex |
| 320 | @ifinfo | 319 | @ifinfo |
| 321 | 2**26 | 320 | 2**26 |
| 322 | @end ifinfo | 321 | @end ifinfo |
| @@ -334,21 +333,22 @@ the control equivalent of @kbd{?}: | |||
| 334 | 333 | ||
| 335 | @noindent | 334 | @noindent |
| 336 | As a result, it is currently not possible to represent the character | 335 | As a result, it is currently not possible to represent the character |
| 337 | @kbd{Control-?}, which is a meaningful input character under X. It is | 336 | @kbd{Control-?}, which is a meaningful input character under X, using |
| 338 | not easy to change this as various Lisp files refer to @key{DEL} in this | 337 | @samp{\C-}. It is not easy to change this, as various Lisp files refer |
| 339 | way. | 338 | to @key{DEL} in this way. |
| 340 | 339 | ||
| 341 | For representing control characters to be found in files or strings, | 340 | For representing control characters to be found in files or strings, |
| 342 | we recommend the @samp{^} syntax; for control characters in keyboard | 341 | we recommend the @samp{^} syntax; for control characters in keyboard |
| 343 | input, we prefer the @samp{C-} syntax. This does not affect the meaning | 342 | input, we prefer the @samp{C-} syntax. Which one you use does not |
| 344 | of the program, but may guide the understanding of people who read it. | 343 | affect the meaning of the program, but may guide the understanding of |
| 344 | people who read it. | ||
| 345 | 345 | ||
| 346 | @cindex meta characters | 346 | @cindex meta characters |
| 347 | A @dfn{meta character} is a character typed with the @key{META} | 347 | A @dfn{meta character} is a character typed with the @key{META} |
| 348 | modifier key. The integer that represents such a character has the | 348 | modifier key. The integer that represents such a character has the |
| 349 | @iftex | 349 | @tex |
| 350 | $2^{27}$ | 350 | $2^{27}$ |
| 351 | @end iftex | 351 | @end tex |
| 352 | @ifinfo | 352 | @ifinfo |
| 353 | 2**27 | 353 | 2**27 |
| 354 | @end ifinfo | 354 | @end ifinfo |
| @@ -357,9 +357,9 @@ use high bits for this and other modifiers to make possible a wide range | |||
| 357 | of basic character codes. | 357 | of basic character codes. |
| 358 | 358 | ||
| 359 | In a string, the | 359 | In a string, the |
| 360 | @iftex | 360 | @tex |
| 361 | $2^{7}$ | 361 | $2^{7}$ |
| 362 | @end iftex | 362 | @end tex |
| 363 | @ifinfo | 363 | @ifinfo |
| 364 | 2**7 | 364 | 2**7 |
| 365 | @end ifinfo | 365 | @end ifinfo |
| @@ -380,15 +380,15 @@ or as @samp{?\M-\101}. Likewise, you can write @kbd{C-M-b} as | |||
| 380 | for example, @sc{ASCII} distinguishes between the characters @samp{a} | 380 | for example, @sc{ASCII} distinguishes between the characters @samp{a} |
| 381 | and @samp{A}. But @sc{ASCII} has no way to represent whether a control | 381 | and @samp{A}. But @sc{ASCII} has no way to represent whether a control |
| 382 | character is upper case or lower case. Emacs uses the | 382 | character is upper case or lower case. Emacs uses the |
| 383 | @iftex | 383 | @tex |
| 384 | $2^{25}$ | 384 | $2^{25}$ |
| 385 | @end iftex | 385 | @end tex |
| 386 | @ifinfo | 386 | @ifinfo |
| 387 | 2**25 | 387 | 2**25 |
| 388 | @end ifinfo | 388 | @end ifinfo |
| 389 | bit to indicate that the shift key was used for typing a control | 389 | bit to indicate that the shift key was used in typing a control |
| 390 | character. This distinction is possible only when you use X terminals | 390 | character. This distinction is possible only when you use X terminals |
| 391 | or other special terminals; ordinary terminals do not indicate the | 391 | or other special terminals; ordinary terminals do not report the |
| 392 | distinction to the computer in any way. | 392 | distinction to the computer in any way. |
| 393 | 393 | ||
| 394 | @cindex hyper characters | 394 | @cindex hyper characters |
| @@ -398,10 +398,10 @@ distinction to the computer in any way. | |||
| 398 | in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes | 398 | in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes |
| 399 | for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, | 399 | for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, |
| 400 | @samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}. | 400 | @samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}. |
| 401 | @iftex | 401 | @tex |
| 402 | Numerically, the | 402 | Numerically, the |
| 403 | bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. | 403 | bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. |
| 404 | @end iftex | 404 | @end tex |
| 405 | @ifinfo | 405 | @ifinfo |
| 406 | Numerically, the | 406 | Numerically, the |
| 407 | bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. | 407 | bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. |
| @@ -434,7 +434,7 @@ digits, so you can represent any character code in this way. | |||
| 434 | Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the | 434 | Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the |
| 435 | character @kbd{C-a}, and @code{?\x8c0} for the character | 435 | character @kbd{C-a}, and @code{?\x8c0} for the character |
| 436 | @iftex | 436 | @iftex |
| 437 | @`a. | 437 | @samp{@`a}. |
| 438 | @end iftex | 438 | @end iftex |
| 439 | @ifinfo | 439 | @ifinfo |
| 440 | @samp{a} with grave accent. | 440 | @samp{a} with grave accent. |
| @@ -478,7 +478,7 @@ backslash. In contrast to its use in strings, however, a backslash in | |||
| 478 | the name of a symbol simply quotes the single character that follows the | 478 | the name of a symbol simply quotes the single character that follows the |
| 479 | backslash. For example, in a string, @samp{\t} represents a tab | 479 | backslash. For example, in a string, @samp{\t} represents a tab |
| 480 | character; in the name of a symbol, however, @samp{\t} merely quotes the | 480 | character; in the name of a symbol, however, @samp{\t} merely quotes the |
| 481 | letter @kbd{t}. To have a symbol with a tab character in its name, you | 481 | letter @samp{t}. To have a symbol with a tab character in its name, you |
| 482 | must actually use a tab (preceded with a backslash). But it's rare to | 482 | must actually use a tab (preceded with a backslash). But it's rare to |
| 483 | do such a thing. | 483 | do such a thing. |
| 484 | 484 | ||
| @@ -525,26 +525,28 @@ elements. There are two kinds of sequence in Emacs Lisp, lists and | |||
| 525 | arrays. Thus, an object of type list or of type array is also | 525 | arrays. Thus, an object of type list or of type array is also |
| 526 | considered a sequence. | 526 | considered a sequence. |
| 527 | 527 | ||
| 528 | Arrays are further subdivided into strings and vectors. Vectors can | 528 | Arrays are further subdivided into strings, vectors, char-tables and |
| 529 | hold elements of any type, but string elements must be characters in the | 529 | bool-vectors. Vectors can hold elements of any type, but string |
| 530 | range from 0 to 255. However, the characters in a string can have text | 530 | elements must be characters, and bool-vector elements must be @code{t} |
| 531 | properties like characters in a buffer (@pxref{Text Properties}); | 531 | or @code{nil}. The characters in a string can have text properties like |
| 532 | vectors do not support text properties even when their elements happen | 532 | characters in a buffer (@pxref{Text Properties}); vectors and |
| 533 | to be characters. | 533 | bool-vectors do not support text properties even when their elements |
| 534 | 534 | happen to be characters. Char-tables are like vectors except that they | |
| 535 | Lists, strings and vectors are different, but they have important | 535 | are indexed by any valid character code. |
| 536 | similarities. For example, all have a length @var{l}, and all have | 536 | |
| 537 | elements which can be indexed from zero to @var{l} minus one. Also, | 537 | Lists, strings and the other array types are different, but they have |
| 538 | several functions, called sequence functions, accept any kind of | 538 | important similarities. For example, all have a length @var{l}, and all |
| 539 | have elements which can be indexed from zero to @var{l} minus one. | ||
| 540 | Several functions, called sequence functions, accept any kind of | ||
| 539 | sequence. For example, the function @code{elt} can be used to extract | 541 | sequence. For example, the function @code{elt} can be used to extract |
| 540 | an element of a sequence, given its index. @xref{Sequences Arrays | 542 | an element of a sequence, given its index. @xref{Sequences Arrays |
| 541 | Vectors}. | 543 | Vectors}. |
| 542 | 544 | ||
| 543 | It is impossible to read the same sequence twice, since sequences are | 545 | It is generally impossible to read the same sequence twice, since |
| 544 | always created anew upon reading. If you read the read syntax for a | 546 | sequences are always created anew upon reading. If you read the read |
| 545 | sequence twice, you get two sequences with equal contents. There is one | 547 | syntax for a sequence twice, you get two sequences with equal contents. |
| 546 | exception: the empty list @code{()} always stands for the same object, | 548 | There is one exception: the empty list @code{()} always stands for the |
| 547 | @code{nil}. | 549 | same object, @code{nil}. |
| 548 | 550 | ||
| 549 | @node Cons Cell Type | 551 | @node Cons Cell Type |
| 550 | @subsection Cons Cell and List Types | 552 | @subsection Cons Cell and List Types |
| @@ -596,8 +598,9 @@ violet buttercup)}: | |||
| 596 | 598 | ||
| 597 | @example | 599 | @example |
| 598 | @group | 600 | @group |
| 599 | ___ ___ ___ ___ ___ ___ | 601 | --- --- --- --- --- --- |
| 600 | |___|___|--> |___|___|--> |___|___|--> nil | 602 | | | |--> | | |--> | | |--> nil |
| 603 | --- --- --- --- --- --- | ||
| 601 | | | | | 604 | | | | |
| 602 | | | | | 605 | | | | |
| 603 | --> rose --> violet --> buttercup | 606 | --> rose --> violet --> buttercup |
| @@ -653,8 +656,9 @@ depicted with boxes and arrows: | |||
| 653 | 656 | ||
| 654 | @example | 657 | @example |
| 655 | @group | 658 | @group |
| 656 | ___ ___ ___ ___ | 659 | --- --- --- --- |
| 657 | |___|___|--> |___|___|--> nil | 660 | | | |--> | | |--> nil |
| 661 | --- --- --- --- | ||
| 658 | | | | 662 | | | |
| 659 | | | | 663 | | | |
| 660 | --> A --> nil | 664 | --> A --> nil |
| @@ -688,8 +692,9 @@ shows the pair @code{(rose . violet)}: | |||
| 688 | 692 | ||
| 689 | @example | 693 | @example |
| 690 | @group | 694 | @group |
| 691 | ___ ___ | 695 | --- --- |
| 692 | |___|___|--> violet | 696 | | | |--> violet |
| 697 | --- --- | ||
| 693 | | | 698 | | |
| 694 | | | 699 | | |
| 695 | --> rose | 700 | --> rose |
| @@ -703,8 +708,9 @@ chain of cons cells with a non-@code{nil} final @sc{cdr}. For example, | |||
| 703 | 708 | ||
| 704 | @example | 709 | @example |
| 705 | @group | 710 | @group |
| 706 | ___ ___ ___ ___ | 711 | --- --- --- --- |
| 707 | |___|___|--> |___|___|--> buttercup | 712 | | | |--> | | |--> buttercup |
| 713 | --- --- --- --- | ||
| 708 | | | | 714 | | | |
| 709 | | | | 715 | | | |
| 710 | --> rose --> violet | 716 | --> rose --> violet |
| @@ -720,8 +726,9 @@ and looks like this: | |||
| 720 | 726 | ||
| 721 | @example | 727 | @example |
| 722 | @group | 728 | @group |
| 723 | ___ ___ ___ ___ | 729 | --- --- --- --- |
| 724 | |___|___|--> |___|___|--> nil | 730 | | | |--> | | |--> nil |
| 731 | --- --- --- --- | ||
| 725 | | | | 732 | | | |
| 726 | | | | 733 | | | |
| 727 | --> rose --> violet | 734 | --> rose --> violet |
| @@ -735,8 +742,9 @@ It looks like this: | |||
| 735 | 742 | ||
| 736 | @example | 743 | @example |
| 737 | @group | 744 | @group |
| 738 | ___ ___ ___ ___ ___ ___ | 745 | --- --- --- --- --- --- |
| 739 | |___|___|--> |___|___|--> |___|___|--> nil | 746 | | | |--> | | |--> | | |--> nil |
| 747 | --- --- --- --- --- --- | ||
| 740 | | | | | 748 | | | | |
| 741 | | | | | 749 | | | | |
| 742 | --> rose --> violet --> buttercup | 750 | --> rose --> violet --> buttercup |
| @@ -775,27 +783,35 @@ functions that work on alists. | |||
| 775 | 783 | ||
| 776 | An @dfn{array} is composed of an arbitrary number of slots for | 784 | An @dfn{array} is composed of an arbitrary number of slots for |
| 777 | referring to other Lisp objects, arranged in a contiguous block of | 785 | referring to other Lisp objects, arranged in a contiguous block of |
| 778 | memory. Accessing any element of an array takes the same amount of | 786 | memory. Accessing any element of an array takes approximately the same |
| 779 | time. In contrast, accessing an element of a list requires time | 787 | amount of time. In contrast, accessing an element of a list requires |
| 780 | proportional to the position of the element in the list. (Elements at | 788 | time proportional to the position of the element in the list. (Elements |
| 781 | the end of a list take longer to access than elements at the beginning | 789 | at the end of a list take longer to access than elements at the |
| 782 | of a list.) | 790 | beginning of a list.) |
| 783 | 791 | ||
| 784 | Emacs defines two types of array, strings and vectors. A string is an | 792 | Emacs defines four types of array: strings, vectors, bool-vectors, and |
| 785 | array of characters and a vector is an array of arbitrary objects. Both | 793 | char-tables. |
| 786 | are one-dimensional. (Most other programming languages support | 794 | |
| 787 | multidimensional arrays, but they are not essential; you can get the | 795 | A string is an array of characters and a vector is an array of |
| 788 | same effect with an array of arrays.) Each type of array has its own | 796 | arbitrary objects. A bool-vector can hold only @code{t} or @code{nil}. |
| 789 | read syntax; see @ref{String Type}, and @ref{Vector Type}. | 797 | These kinds of array may have any length up to the largest integer. |
| 790 | 798 | Char-tables are sparse arrays indexed by any valid character code; they | |
| 791 | An array may have any length up to the largest integer; but once | 799 | can hold arbitrary objects. |
| 792 | created, it has a fixed size. The first element of an array has index | 800 | |
| 793 | zero, the second element has index 1, and so on. This is called | 801 | The first element of an array has index zero, the second element has |
| 794 | @dfn{zero-origin} indexing. For example, an array of four elements has | 802 | index 1, and so on. This is called @dfn{zero-origin} indexing. For |
| 795 | indices 0, 1, 2, @w{and 3}. | 803 | example, an array of four elements has indices 0, 1, 2, @w{and 3}. The |
| 796 | 804 | largest possible index value is one less than the length of the array. | |
| 797 | The array type is contained in the sequence type and contains both the | 805 | Once an array is created, its length is fixed. |
| 798 | string type and the vector type. | 806 | |
| 807 | All Emacs Lisp arrays are one-dimensional. (Most other programming | ||
| 808 | languages support multidimensional arrays, but they are not essential; | ||
| 809 | you can get the same effect with an array of arrays.) Each type of | ||
| 810 | array has its own read syntax; see the following sections for details. | ||
| 811 | |||
| 812 | The array type is contained in the sequence type and | ||
| 813 | contains the string type, the vector type, the bool-vector type, and the | ||
| 814 | char-table type. | ||
| 799 | 815 | ||
| 800 | @node String Type | 816 | @node String Type |
| 801 | @subsection String Type | 817 | @subsection String Type |
| @@ -854,10 +870,13 @@ but the newline is ignored if escaped." | |||
| 854 | constant by writing it literally. There are two text representations | 870 | constant by writing it literally. There are two text representations |
| 855 | for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte | 871 | for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte |
| 856 | and multibyte. If the string constant is read from a multibyte source, | 872 | and multibyte. If the string constant is read from a multibyte source, |
| 857 | then the character is read as a multibyte character, and that makes the | 873 | such as a multibyte buffer or string, or a file that would be visited as |
| 858 | string multibyte. If the string constant is read from a unibyte source, | 874 | multibyte, then the character is read as a multibyte character, and that |
| 859 | then the character is read as unibyte and that makes the string unibyte. | 875 | makes the string multibyte. If the string constant is read from a |
| 876 | unibyte source, then the character is read as unibyte and that makes the | ||
| 877 | string unibyte. | ||
| 860 | 878 | ||
| 879 | @c ??? Change this? | ||
| 861 | You can also represent a multibyte non-@sc{ASCII} character with its | 880 | You can also represent a multibyte non-@sc{ASCII} character with its |
| 862 | character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many | 881 | character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many |
| 863 | digits as necessary. (Multibyte non-@sc{ASCII} character codes are all | 882 | digits as necessary. (Multibyte non-@sc{ASCII} character codes are all |
| @@ -895,9 +914,9 @@ characters. | |||
| 895 | 914 | ||
| 896 | If you use the @samp{\M-} syntax to indicate a meta character in a | 915 | If you use the @samp{\M-} syntax to indicate a meta character in a |
| 897 | string constant, this sets the | 916 | string constant, this sets the |
| 898 | @iftex | 917 | @tex |
| 899 | $2^{7}$ | 918 | $2^{7}$ |
| 900 | @end iftex | 919 | @end tex |
| 901 | @ifinfo | 920 | @ifinfo |
| 902 | 2**7 | 921 | 2**7 |
| 903 | @end ifinfo | 922 | @end ifinfo |
| @@ -975,9 +994,24 @@ special purposes. A char-table can also specify a single value for | |||
| 975 | a whole character set. | 994 | a whole character set. |
| 976 | 995 | ||
| 977 | The printed representation of a char-table is like a vector | 996 | The printed representation of a char-table is like a vector |
| 978 | except that there is an extra @samp{#} at the beginning. | 997 | except that there is an extra @samp{#^} at the beginning. |
| 979 | 998 | ||
| 980 | @xref{Char-Tables}, for special functions to operate on char-tables. | 999 | @xref{Char-Tables}, for special functions to operate on char-tables. |
| 1000 | Uses of char-tables include: | ||
| 1001 | |||
| 1002 | @itemize @bullet | ||
| 1003 | @item | ||
| 1004 | Case tables (@pxref{Case Tables}). | ||
| 1005 | |||
| 1006 | @item | ||
| 1007 | Character category tables (@pxref{Categories}). | ||
| 1008 | |||
| 1009 | @item | ||
| 1010 | Display Tables (@pxref{Display Tables}). | ||
| 1011 | |||
| 1012 | @item | ||
| 1013 | Syntax tables (@pxref{Syntax Tables}). | ||
| 1014 | @end itemize | ||
| 981 | 1015 | ||
| 982 | @node Bool-Vector Type | 1016 | @node Bool-Vector Type |
| 983 | @subsection Bool-Vector Type | 1017 | @subsection Bool-Vector Type |
| @@ -999,6 +1033,9 @@ make no difference. | |||
| 999 | @result{} #&3"\377" | 1033 | @result{} #&3"\377" |
| 1000 | (make-bool-vector 3 nil) | 1034 | (make-bool-vector 3 nil) |
| 1001 | @result{} #&3"\0"" | 1035 | @result{} #&3"\0"" |
| 1036 | ;; @r{These are equal since only the first 3 bits are used.} | ||
| 1037 | (equal #&3"\377" #&3"\340") | ||
| 1038 | @result{} t | ||
| 1002 | @end example | 1039 | @end example |
| 1003 | 1040 | ||
| 1004 | @node Function Type | 1041 | @node Function Type |
| @@ -1027,7 +1064,7 @@ functions @code{funcall} and @code{apply}. @xref{Calling Functions}. | |||
| 1027 | 1064 | ||
| 1028 | A @dfn{Lisp macro} is a user-defined construct that extends the Lisp | 1065 | A @dfn{Lisp macro} is a user-defined construct that extends the Lisp |
| 1029 | language. It is represented as an object much like a function, but with | 1066 | language. It is represented as an object much like a function, but with |
| 1030 | different parameter-passing semantics. A Lisp macro has the form of a | 1067 | different argument-passing semantics. A Lisp macro has the form of a |
| 1031 | list whose first element is the symbol @code{macro} and whose @sc{cdr} | 1068 | list whose first element is the symbol @code{macro} and whose @sc{cdr} |
| 1032 | is a Lisp function object, including the @code{lambda} symbol. | 1069 | is a Lisp function object, including the @code{lambda} symbol. |
| 1033 | 1070 | ||
| @@ -1053,12 +1090,12 @@ not evaluate all its arguments is called a @dfn{special form} | |||
| 1053 | (@pxref{Special Forms}).@refill | 1090 | (@pxref{Special Forms}).@refill |
| 1054 | 1091 | ||
| 1055 | It does not matter to the caller of a function whether the function is | 1092 | It does not matter to the caller of a function whether the function is |
| 1056 | primitive. However, this does matter if you try to substitute a | 1093 | primitive. However, this does matter if you try to redefine a primitive |
| 1057 | function written in Lisp for a primitive of the same name. The reason | 1094 | with a function written in Lisp. The reason is that the primitive |
| 1058 | is that the primitive function may be called directly from C code. | 1095 | function may be called directly from C code. Calls to the redefined |
| 1059 | Calls to the redefined function from Lisp will use the new definition, | 1096 | function from Lisp will use the new definition, but calls from C code |
| 1060 | but calls from C code may still use the built-in definition. Therefore, | 1097 | may still use the built-in definition. Therefore, @strong{we discourage |
| 1061 | @strong{we discourage redefinition of primitive functions}. | 1098 | redefinition of primitive functions}. |
| 1062 | 1099 | ||
| 1063 | The term @dfn{function} refers to all Emacs functions, whether written | 1100 | The term @dfn{function} refers to all Emacs functions, whether written |
| 1064 | in Lisp or C. @xref{Function Type}, for information about the | 1101 | in Lisp or C. @xref{Function Type}, for information about the |
| @@ -1114,9 +1151,10 @@ symbol. @xref{Autoload}, for more details. | |||
| 1114 | @section Editing Types | 1151 | @section Editing Types |
| 1115 | @cindex editing types | 1152 | @cindex editing types |
| 1116 | 1153 | ||
| 1117 | The types in the previous section are common to many Lisp dialects. | 1154 | The types in the previous section used for general programming |
| 1118 | Emacs Lisp provides several additional data types for purposes connected | 1155 | purposes, and most of them are common to most Lisp dialects. Emacs Lisp |
| 1119 | with editing. | 1156 | provides several additional data types for purposes connected with |
| 1157 | editing. | ||
| 1120 | 1158 | ||
| 1121 | @menu | 1159 | @menu |
| 1122 | * Buffer Type:: The basic object of editing. | 1160 | * Buffer Type:: The basic object of editing. |
| @@ -1124,11 +1162,10 @@ with editing. | |||
| 1124 | * Window Type:: Buffers are displayed in windows. | 1162 | * Window Type:: Buffers are displayed in windows. |
| 1125 | * Frame Type:: Windows subdivide frames. | 1163 | * Frame Type:: Windows subdivide frames. |
| 1126 | * Window Configuration Type:: Recording the way a frame is subdivided. | 1164 | * Window Configuration Type:: Recording the way a frame is subdivided. |
| 1165 | * Frame Configuration Type:: Recording the status of all frames. | ||
| 1127 | * Process Type:: A process running on the underlying OS. | 1166 | * Process Type:: A process running on the underlying OS. |
| 1128 | * Stream Type:: Receive or send characters. | 1167 | * Stream Type:: Receive or send characters. |
| 1129 | * Keymap Type:: What function a keystroke invokes. | 1168 | * Keymap Type:: What function a keystroke invokes. |
| 1130 | * Syntax Table Type:: What a character means. | ||
| 1131 | * Display Table Type:: How display tables are represented. | ||
| 1132 | * Overlay Type:: How an overlay is represented. | 1169 | * Overlay Type:: How an overlay is represented. |
| 1133 | @end menu | 1170 | @end menu |
| 1134 | 1171 | ||
| @@ -1144,8 +1181,8 @@ buffer need not be displayed in any window. | |||
| 1144 | 1181 | ||
| 1145 | The contents of a buffer are much like a string, but buffers are not | 1182 | The contents of a buffer are much like a string, but buffers are not |
| 1146 | used like strings in Emacs Lisp, and the available operations are | 1183 | used like strings in Emacs Lisp, and the available operations are |
| 1147 | different. For example, insertion of text into a buffer is very | 1184 | different. For example, you can insert text efficiently into an |
| 1148 | efficient, whereas ``inserting'' text into a string requires | 1185 | existing buffer, whereas ``inserting'' text into a string requires |
| 1149 | concatenating substrings, and the result is an entirely new string | 1186 | concatenating substrings, and the result is an entirely new string |
| 1150 | object. | 1187 | object. |
| 1151 | 1188 | ||
| @@ -1167,10 +1204,10 @@ a local syntax table (@pxref{Syntax Tables}); | |||
| 1167 | a local keymap (@pxref{Keymaps}); and, | 1204 | a local keymap (@pxref{Keymaps}); and, |
| 1168 | 1205 | ||
| 1169 | @item | 1206 | @item |
| 1170 | a local variable binding list (@pxref{Buffer-Local Variables}). | 1207 | a list of buffer-local variable bindings (@pxref{Buffer-Local Variables}). |
| 1171 | 1208 | ||
| 1172 | @item | 1209 | @item |
| 1173 | a list of overlays (@pxref{Overlays}). | 1210 | overlays (@pxref{Overlays}). |
| 1174 | 1211 | ||
| 1175 | @item | 1212 | @item |
| 1176 | text properties for the text in the buffer (@pxref{Text Properties}). | 1213 | text properties for the text in the buffer (@pxref{Text Properties}). |
| @@ -1183,7 +1220,7 @@ behavior of programs in different buffers, without actually changing the | |||
| 1183 | programs. | 1220 | programs. |
| 1184 | 1221 | ||
| 1185 | A buffer may be @dfn{indirect}, which means it shares the text | 1222 | A buffer may be @dfn{indirect}, which means it shares the text |
| 1186 | of another buffer. @xref{Indirect Buffers}. | 1223 | of another buffer, but presents it differently. @xref{Indirect Buffers}. |
| 1187 | 1224 | ||
| 1188 | Buffers have no read syntax. They print in hash notation, showing the | 1225 | Buffers have no read syntax. They print in hash notation, showing the |
| 1189 | buffer name. | 1226 | buffer name. |
| @@ -1263,7 +1300,7 @@ uniquely). | |||
| 1263 | @example | 1300 | @example |
| 1264 | @group | 1301 | @group |
| 1265 | (selected-frame) | 1302 | (selected-frame) |
| 1266 | @result{} #<frame xemacs@@mole.gnu.ai.mit.edu 0xdac80> | 1303 | @result{} #<frame emacs@@mole.gnu.ai.mit.edu 0xdac80> |
| 1267 | @end group | 1304 | @end group |
| 1268 | @end example | 1305 | @end example |
| 1269 | 1306 | ||
| @@ -1282,6 +1319,19 @@ looks like @samp{#<window-configuration>}. @xref{Window | |||
| 1282 | Configurations}, for a description of several functions related to | 1319 | Configurations}, for a description of several functions related to |
| 1283 | window configurations. | 1320 | window configurations. |
| 1284 | 1321 | ||
| 1322 | @node Frame Configuration Type | ||
| 1323 | @subsection Frame Configuration Type | ||
| 1324 | @cindex screen layout | ||
| 1325 | |||
| 1326 | A @dfn{frame configuration} stores information about the positions, | ||
| 1327 | sizes, and contents of the windows in all frames. It is actually | ||
| 1328 | a list whose @sc{car} is @code{frame-configuration} and whose | ||
| 1329 | @sc{cdr} is an alist. Each alist element describes one frame, | ||
| 1330 | which appears as the @sc{car} of that element. | ||
| 1331 | |||
| 1332 | @xref{Frame Configurations}, for a description of several functions | ||
| 1333 | related to frame configurations. | ||
| 1334 | |||
| 1285 | @node Process Type | 1335 | @node Process Type |
| 1286 | @subsection Process Type | 1336 | @subsection Process Type |
| 1287 | 1337 | ||
| @@ -1343,36 +1393,6 @@ a list whose @sc{car} is the symbol @code{keymap}. | |||
| 1343 | @xref{Keymaps}, for information about creating keymaps, handling prefix | 1393 | @xref{Keymaps}, for information about creating keymaps, handling prefix |
| 1344 | keys, local as well as global keymaps, and changing key bindings. | 1394 | keys, local as well as global keymaps, and changing key bindings. |
| 1345 | 1395 | ||
| 1346 | @node Syntax Table Type | ||
| 1347 | @subsection Syntax Table Type | ||
| 1348 | |||
| 1349 | A @dfn{syntax table} is a char-table which specifies the syntax of | ||
| 1350 | each character, for word and list parsing. Each element of the syntax | ||
| 1351 | table defines how one character is interpreted when it appears in a | ||
| 1352 | buffer. For example, in C mode (@pxref{Major Modes}), the @samp{+} | ||
| 1353 | character is punctuation, but in Lisp mode it is a valid character in a | ||
| 1354 | symbol. These modes specify different interpretations by changing the | ||
| 1355 | syntax table entry for @samp{+}, at index 43 in the syntax table. | ||
| 1356 | |||
| 1357 | Syntax tables are used only to control primitives that scan text in | ||
| 1358 | buffers, not for reading Lisp expressions. The syntax that the Lisp | ||
| 1359 | interpreter uses to read expressions is built into the Emacs source code | ||
| 1360 | and cannot be changed; thus, to change the list delimiters to be | ||
| 1361 | @samp{@{} and @samp{@}} instead of @samp{(} and @samp{)} would be | ||
| 1362 | impossible. (Some Lisp systems provide ways to redefine the read | ||
| 1363 | syntax, but we decided to leave this feature out of Emacs Lisp for | ||
| 1364 | simplicity.) | ||
| 1365 | |||
| 1366 | @xref{Syntax Tables}, for details about syntax classes and how to make | ||
| 1367 | and modify syntax tables. | ||
| 1368 | |||
| 1369 | @node Display Table Type | ||
| 1370 | @subsection Display Table Type | ||
| 1371 | |||
| 1372 | A @dfn{display table} specifies how to display each character code. | ||
| 1373 | Each buffer and each window can have its own display table. A display | ||
| 1374 | table is actually a char-table. @xref{Display Tables}. | ||
| 1375 | |||
| 1376 | @node Overlay Type | 1396 | @node Overlay Type |
| 1377 | @subsection Overlay Type | 1397 | @subsection Overlay Type |
| 1378 | 1398 | ||
| @@ -1437,7 +1457,7 @@ a list and @code{symbolp} to check for a symbol. | |||
| 1437 | (setq list (append x list))) | 1457 | (setq list (append x list))) |
| 1438 | @need 3000 | 1458 | @need 3000 |
| 1439 | (t | 1459 | (t |
| 1440 | ;; We only handle symbols and lists. | 1460 | ;; We handle only symbols and lists. |
| 1441 | (error "Invalid argument %s in add-on" x)))) | 1461 | (error "Invalid argument %s in add-on" x)))) |
| 1442 | @end example | 1462 | @end example |
| 1443 | 1463 | ||
| @@ -1451,6 +1471,9 @@ with references to further information. | |||
| 1451 | @item arrayp | 1471 | @item arrayp |
| 1452 | @xref{Array Functions, arrayp}. | 1472 | @xref{Array Functions, arrayp}. |
| 1453 | 1473 | ||
| 1474 | @item bool-vector-p | ||
| 1475 | @xref{Bool-Vectors, bool-vector-p}. | ||
| 1476 | |||
| 1454 | @item bufferp | 1477 | @item bufferp |
| 1455 | @xref{Buffer Basics, bufferp}. | 1478 | @xref{Buffer Basics, bufferp}. |
| 1456 | 1479 | ||
| @@ -1458,20 +1481,29 @@ with references to further information. | |||
| 1458 | @xref{Byte-Code Type, byte-code-function-p}. | 1481 | @xref{Byte-Code Type, byte-code-function-p}. |
| 1459 | 1482 | ||
| 1460 | @item case-table-p | 1483 | @item case-table-p |
| 1461 | @xref{Case Table, case-table-p}. | 1484 | @xref{Case Tables, case-table-p}. |
| 1462 | 1485 | ||
| 1463 | @item char-or-string-p | 1486 | @item char-or-string-p |
| 1464 | @xref{Predicates for Strings, char-or-string-p}. | 1487 | @xref{Predicates for Strings, char-or-string-p}. |
| 1465 | 1488 | ||
| 1489 | @item char-table-p | ||
| 1490 | @xref{Char-Tables, char-table-p}. | ||
| 1491 | |||
| 1466 | @item commandp | 1492 | @item commandp |
| 1467 | @xref{Interactive Call, commandp}. | 1493 | @xref{Interactive Call, commandp}. |
| 1468 | 1494 | ||
| 1469 | @item consp | 1495 | @item consp |
| 1470 | @xref{List-related Predicates, consp}. | 1496 | @xref{List-related Predicates, consp}. |
| 1471 | 1497 | ||
| 1498 | @item display-table-p | ||
| 1499 | @xref{Display Tables, display-table-p}. | ||
| 1500 | |||
| 1472 | @item floatp | 1501 | @item floatp |
| 1473 | @xref{Predicates on Numbers, floatp}. | 1502 | @xref{Predicates on Numbers, floatp}. |
| 1474 | 1503 | ||
| 1504 | @item frame-configuration-p | ||
| 1505 | @xref{Frame Configurations, frame-configuration-p}. | ||
| 1506 | |||
| 1475 | @item frame-live-p | 1507 | @item frame-live-p |
| 1476 | @xref{Deleting Frames, frame-live-p}. | 1508 | @xref{Deleting Frames, frame-live-p}. |
| 1477 | 1509 | ||
| @@ -1556,8 +1588,9 @@ types. In most cases, it is more convenient to use type predicates than | |||
| 1556 | This function returns a symbol naming the primitive type of | 1588 | This function returns a symbol naming the primitive type of |
| 1557 | @var{object}. The value is one of the symbols @code{symbol}, | 1589 | @var{object}. The value is one of the symbols @code{symbol}, |
| 1558 | @code{integer}, @code{float}, @code{string}, @code{cons}, @code{vector}, | 1590 | @code{integer}, @code{float}, @code{string}, @code{cons}, @code{vector}, |
| 1559 | @code{marker}, @code{overlay}, @code{window}, @code{buffer}, | 1591 | @code{char-table}, @code{bool-vector}, @code{subr}, |
| 1560 | @code{subr}, @code{compiled-function}, @code{process}, or | 1592 | @code{compiled-function}, @code{marker}, @code{overlay}, @code{window}, |
| 1593 | @code{buffer}, @code{frame}, @code{process}, or | ||
| 1561 | @code{window-configuration}. | 1594 | @code{window-configuration}. |
| 1562 | 1595 | ||
| 1563 | @example | 1596 | @example |
| @@ -1594,11 +1627,6 @@ arguments with the same contents or elements are not necessarily | |||
| 1594 | @code{eq} to each other: they are @code{eq} only if they are the same | 1627 | @code{eq} to each other: they are @code{eq} only if they are the same |
| 1595 | object. | 1628 | object. |
| 1596 | 1629 | ||
| 1597 | (The @code{make-symbol} function returns an uninterned symbol that is | ||
| 1598 | not interned in the standard @code{obarray}. When uninterned symbols | ||
| 1599 | are in use, symbol names are no longer unique. Distinct symbols with | ||
| 1600 | the same name are not @code{eq}. @xref{Creating Symbols}.) | ||
| 1601 | |||
| 1602 | @example | 1630 | @example |
| 1603 | @group | 1631 | @group |
| 1604 | (eq 'foo 'foo) | 1632 | (eq 'foo 'foo) |
| @@ -1640,6 +1668,17 @@ the same name are not @code{eq}. @xref{Creating Symbols}.) | |||
| 1640 | @end group | 1668 | @end group |
| 1641 | @end example | 1669 | @end example |
| 1642 | 1670 | ||
| 1671 | (The @code{make-symbol} function returns an uninterned symbol that is | ||
| 1672 | not interned in the standard @code{obarray}. When uninterned symbols | ||
| 1673 | are in use, symbol names are no longer unique. Distinct symbols with | ||
| 1674 | the same name are not @code{eq}. @xref{Creating Symbols}.) | ||
| 1675 | |||
| 1676 | @example | ||
| 1677 | @group | ||
| 1678 | (eq (make-symbol "foo") 'foo) | ||
| 1679 | @result{} nil | ||
| 1680 | @end group | ||
| 1681 | @end example | ||
| 1643 | @end defun | 1682 | @end defun |
| 1644 | 1683 | ||
| 1645 | @defun equal object1 object2 | 1684 | @defun equal object1 object2 |
diff --git a/lispref/os.texi b/lispref/os.texi index bea390582d7..a9d58c55aef 100644 --- a/lispref/os.texi +++ b/lispref/os.texi | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/os | 5 | @setfilename ../info/os |
| 6 | @node System Interface, Display, Processes, Top | 6 | @node System Interface, Tips, Calendar, Top |
| 7 | @chapter Operating System Interface | 7 | @chapter Operating System Interface |
| 8 | 8 | ||
| 9 | This chapter is about starting and getting out of Emacs, access to | 9 | This chapter is about starting and getting out of Emacs, access to |
| @@ -64,7 +64,7 @@ It processes the initial options. (Some of them are handled | |||
| 64 | even earlier than this.) | 64 | even earlier than this.) |
| 65 | 65 | ||
| 66 | @item | 66 | @item |
| 67 | It initializes the X window frame and faces, if appropriate. | 67 | It initializes the window frame and faces, if appropriate. |
| 68 | 68 | ||
| 69 | @item | 69 | @item |
| 70 | It runs the normal hook @code{before-init-hook}. | 70 | It runs the normal hook @code{before-init-hook}. |
| @@ -76,13 +76,13 @@ It loads the library @file{site-start}, unless the option | |||
| 76 | @cindex @file{site-start.el} | 76 | @cindex @file{site-start.el} |
| 77 | 77 | ||
| 78 | @item | 78 | @item |
| 79 | It loads the file @file{~/.emacs} unless @samp{-q} was specified on | 79 | It loads the file @file{~/.emacs}, unless @samp{-q} was specified on the |
| 80 | the command line. (This is not done in @samp{-batch} mode.) The @samp{-u} | 80 | command line. (This is not done in @samp{-batch} mode.) The @samp{-u} |
| 81 | option can specify the user name whose home directory should be used | 81 | option can specify another user name whose home directory should be used |
| 82 | instead of @file{~}. | 82 | instead of @file{~}. |
| 83 | 83 | ||
| 84 | @item | 84 | @item |
| 85 | It loads the library @file{default} unless @code{inhibit-default-init} | 85 | It loads the library @file{default}, unless @code{inhibit-default-init} |
| 86 | is non-@code{nil}. (This is not done in @samp{-batch} mode or if | 86 | is non-@code{nil}. (This is not done in @samp{-batch} mode or if |
| 87 | @samp{-q} was specified on the command line.) The library's file name | 87 | @samp{-q} was specified on the command line.) The library's file name |
| 88 | is usually @file{default.el}. | 88 | is usually @file{default.el}. |
| @@ -461,11 +461,11 @@ likely @code{fg}. | |||
| 461 | systems, ``suspension'' actually creates a new shell temporarily as a | 461 | systems, ``suspension'' actually creates a new shell temporarily as a |
| 462 | subprocess of Emacs. Then you would exit the shell to return to Emacs. | 462 | subprocess of Emacs. Then you would exit the shell to return to Emacs. |
| 463 | 463 | ||
| 464 | Suspension is not useful with window systems such as X, because the | 464 | Suspension is not useful with window systems, because the Emacs job |
| 465 | Emacs job may not have a parent that can resume it again, and in any | 465 | may not have a parent that can resume it again, and in any case you can |
| 466 | case you can give input to some other job such as a shell merely by | 466 | give input to some other job such as a shell merely by moving to a |
| 467 | moving to a different window. Therefore, suspending is not allowed | 467 | different window. Therefore, suspending is not allowed when Emacs is using |
| 468 | when Emacs is an X client. | 468 | a window system. |
| 469 | 469 | ||
| 470 | @defun suspend-emacs string | 470 | @defun suspend-emacs string |
| 471 | This function stops Emacs and returns control to the superior process. | 471 | This function stops Emacs and returns control to the superior process. |
| @@ -478,10 +478,7 @@ as terminal input by Emacs's superior shell. The characters in | |||
| 478 | appear. | 478 | appear. |
| 479 | 479 | ||
| 480 | Before suspending, @code{suspend-emacs} runs the normal hook | 480 | Before suspending, @code{suspend-emacs} runs the normal hook |
| 481 | @code{suspend-hook}. In Emacs version 18, @code{suspend-hook} was not a | 481 | @code{suspend-hook}. |
| 482 | normal hook; its value was a single function, and if its value was | ||
| 483 | non-@code{nil}, then @code{suspend-emacs} returned immediately without | ||
| 484 | actually suspending anything. | ||
| 485 | 482 | ||
| 486 | After the user resumes Emacs, @code{suspend-emacs} runs the normal hook | 483 | After the user resumes Emacs, @code{suspend-emacs} runs the normal hook |
| 487 | @code{suspend-resume-hook}. @xref{Hooks}. | 484 | @code{suspend-resume-hook}. @xref{Hooks}. |
| @@ -553,6 +550,12 @@ This variable is a normal hook run after suspending. | |||
| 553 | through various functions. These variables include the name of the | 550 | through various functions. These variables include the name of the |
| 554 | system, the user's @sc{uid}, and so on. | 551 | system, the user's @sc{uid}, and so on. |
| 555 | 552 | ||
| 553 | @defvar system-configuration | ||
| 554 | This variable holds the GNU configuration name for the hardware/software | ||
| 555 | configuration of your system, as a string. The convenient way to test | ||
| 556 | parts of this string is with @code{string-match}. | ||
| 557 | @end defvar | ||
| 558 | |||
| 556 | @defvar system-type | 559 | @defvar system-type |
| 557 | The value of this variable is a symbol indicating the type of operating | 560 | The value of this variable is a symbol indicating the type of operating |
| 558 | system Emacs is operating on. Here is a table of the possible values: | 561 | system Emacs is operating on. Here is a table of the possible values: |
| @@ -568,10 +571,12 @@ Berkeley BSD. | |||
| 568 | Data General DGUX operating system. | 571 | Data General DGUX operating system. |
| 569 | 572 | ||
| 570 | @item gnu | 573 | @item gnu |
| 571 | A GNU system (using the GNU kernel, which consists of the HURD and Mach). | 574 | the GNU system (using the GNU kernel, which consists of the HURD and Mach). |
| 572 | 575 | ||
| 573 | @item gnu/linux | 576 | @item gnu/linux |
| 574 | A variant GNU system using the Linux kernel. | 577 | A GNU/Linux system---that is, a variant GNU system, using the Linux |
| 578 | kernel. (These systems are the ones people often call ``Linux,'' but | ||
| 579 | actually Linux is just the kernel, not the whole system.) | ||
| 575 | 580 | ||
| 576 | @item hpux | 581 | @item hpux |
| 577 | Hewlett-Packard HPUX operating system. | 582 | Hewlett-Packard HPUX operating system. |
| @@ -611,12 +616,6 @@ alternatives in the future. We recommend using | |||
| 611 | systems. | 616 | systems. |
| 612 | @end defvar | 617 | @end defvar |
| 613 | 618 | ||
| 614 | @defvar system-configuration | ||
| 615 | This variable holds the GNU configuration name for the hardware/software | ||
| 616 | configuration of your system, as a string. The convenient way to test | ||
| 617 | parts of this string is with @code{string-match}. | ||
| 618 | @end defvar | ||
| 619 | |||
| 620 | @defun system-name | 619 | @defun system-name |
| 621 | This function returns the name of the machine you are running on. | 620 | This function returns the name of the machine you are running on. |
| 622 | @example | 621 | @example |
| @@ -944,7 +943,7 @@ in the past or future. | |||
| 944 | Time conversion functions always use the Gregorian calendar, even for | 943 | Time conversion functions always use the Gregorian calendar, even for |
| 945 | dates before the Gregorian calendar was introduced. Year numbers count | 944 | dates before the Gregorian calendar was introduced. Year numbers count |
| 946 | the number of years since the year 1 B.C., and do not skip zero as | 945 | the number of years since the year 1 B.C., and do not skip zero as |
| 947 | traditional Gregorian years do; for example, the year number -37 | 946 | traditional Gregorian years do; for example, the year number @minus{}37 |
| 948 | represents the Gregorian year 38 B.C@. | 947 | represents the Gregorian year 38 B.C@. |
| 949 | 948 | ||
| 950 | @defun format-time-string format-string time | 949 | @defun format-time-string format-string time |
| @@ -1012,11 +1011,11 @@ This stands for the numeric day of week (0-6). Sunday is day 0. | |||
| 1012 | This stands for the week of the year (01-52), assuming that weeks | 1011 | This stands for the week of the year (01-52), assuming that weeks |
| 1013 | start on Monday. | 1012 | start on Monday. |
| 1014 | @item %x | 1013 | @item %x |
| 1015 | This has a locale-specific meaning. In the default locale (named C), it | 1014 | This has a locale-specific meaning. In the default locale (named |
| 1016 | is equivalent to @samp{%D}. | 1015 | @samp{C}), it is equivalent to @samp{%D}. |
| 1017 | @item %X | 1016 | @item %X |
| 1018 | This has a locale-specific meaning. In the default locale (named C), it | 1017 | This has a locale-specific meaning. In the default locale (named |
| 1019 | is equivalent to @samp{%T}. | 1018 | @samp{C}), it is equivalent to @samp{%T}. |
| 1020 | @item %y | 1019 | @item %y |
| 1021 | This stands for the year without century (00-99). | 1020 | This stands for the year without century (00-99). |
| 1022 | @item %Y | 1021 | @item %Y |
| @@ -1026,8 +1025,8 @@ This stands for the time zone abbreviation. | |||
| 1026 | @end table | 1025 | @end table |
| 1027 | 1026 | ||
| 1028 | You can also specify the field width and type of padding for any of | 1027 | You can also specify the field width and type of padding for any of |
| 1029 | these @samp{%}-constructs. This works as in @code{printf}: you write | 1028 | these @samp{%}-sequences. This works as in @code{printf}: you write |
| 1030 | the field width as digits in the middle of a @samp{%}-construct. If you | 1029 | the field width as digits in the middle of a @samp{%}-sequences. If you |
| 1031 | start the field width with 0, it means to pad with zeros. | 1030 | start the field width with 0, it means to pad with zeros. |
| 1032 | 1031 | ||
| 1033 | For example, @samp{%S} specifies the number of seconds since the minute; | 1032 | For example, @samp{%S} specifies the number of seconds since the minute; |
| @@ -1069,8 +1068,8 @@ An integer indicating the time zone, as the number of seconds east of | |||
| 1069 | Greenwich. | 1068 | Greenwich. |
| 1070 | @end table | 1069 | @end table |
| 1071 | 1070 | ||
| 1072 | Note that Common Lisp has different meanings for @var{dow} and | 1071 | @strong{Common Lisp Note:} Common Lisp has different meanings for |
| 1073 | @var{zone}. | 1072 | @var{dow} and @var{zone}. |
| 1074 | @end defun | 1073 | @end defun |
| 1075 | 1074 | ||
| 1076 | @defun encode-time seconds minutes hour day month year &optional @dots{}zone | 1075 | @defun encode-time seconds minutes hour day month year &optional @dots{}zone |
| @@ -1111,7 +1110,7 @@ arguments; for example, day 0 means the day preceding the given month. | |||
| 1111 | You can set up a @dfn{timer} to call a function at a specified future time or | 1110 | You can set up a @dfn{timer} to call a function at a specified future time or |
| 1112 | after a certain length of idleness. | 1111 | after a certain length of idleness. |
| 1113 | 1112 | ||
| 1114 | Emacs cannot run a timer at any arbitrary point in a Lisp program; it | 1113 | Emacs cannot run timers at any arbitrary point in a Lisp program; it |
| 1115 | can run them only when Emacs could accept output from a subprocess: | 1114 | can run them only when Emacs could accept output from a subprocess: |
| 1116 | namely, while waiting or inside certain primitive functions such as | 1115 | namely, while waiting or inside certain primitive functions such as |
| 1117 | @code{sit-for} or @code{read-char} which @emph{can} wait. Therefore, a | 1116 | @code{sit-for} or @code{read-char} which @emph{can} wait. Therefore, a |
| @@ -1124,10 +1123,11 @@ at time @var{time}. The argument @var{function} is a function to call | |||
| 1124 | later, and @var{args} are the arguments to give it when it is called. | 1123 | later, and @var{args} are the arguments to give it when it is called. |
| 1125 | The time @var{time} is specified as a string. | 1124 | The time @var{time} is specified as a string. |
| 1126 | 1125 | ||
| 1127 | Absolute times may be specified in a variety of formats; The form | 1126 | Absolute times may be specified in a wide variety of formats, and tries |
| 1127 | to accept all common date formats. One valid format is | ||
| 1128 | @samp{@var{hour}:@var{min}:@var{sec} @var{timezone} | 1128 | @samp{@var{hour}:@var{min}:@var{sec} @var{timezone} |
| 1129 | @var{month}/@var{day}/@var{year}}, where all fields are numbers, works; | 1129 | @var{month}/@var{day}/@var{year}}, where all fields are numbers; the |
| 1130 | the format that @code{current-time-string} returns is also allowed. | 1130 | format that @code{current-time-string} returns is also allowed. |
| 1131 | 1131 | ||
| 1132 | To specify a relative time, use numbers followed by units. | 1132 | To specify a relative time, use numbers followed by units. |
| 1133 | For example: | 1133 | For example: |
| @@ -1208,12 +1208,12 @@ idleness will continue to increase and will not go down to five seconds | |||
| 1208 | again. | 1208 | again. |
| 1209 | 1209 | ||
| 1210 | Emacs can do various things while idle: garbage collect, autosave or | 1210 | Emacs can do various things while idle: garbage collect, autosave or |
| 1211 | handle data from a subprocess. But these interludes during idleness | 1211 | handle data from a subprocess. But these interludes during idleness do |
| 1212 | have little effect on idle timers. An idle timer set for 600 seconds | 1212 | not interfere with idle timers, because they do not reset the clock of |
| 1213 | will run when ten minutes have elapsed since the last user command was | 1213 | idleness to zero. An idle timer set for 600 seconds will run when ten |
| 1214 | finished, even if subprocess output has been accepted thousands of times | 1214 | minutes have elapsed since the last user command was finished, even if |
| 1215 | within those ten minutes, even if there have been garbage collections | 1215 | subprocess output has been accepted thousands of times within those ten |
| 1216 | and autosaves. | 1216 | minutes, even if there have been garbage collections and autosaves. |
| 1217 | 1217 | ||
| 1218 | When the user supplies input, Emacs becomes non-idle while executing the | 1218 | When the user supplies input, Emacs becomes non-idle while executing the |
| 1219 | input. Then it becomes idle again, and all the idle timers that are | 1219 | input. Then it becomes idle again, and all the idle timers that are |
| @@ -1249,16 +1249,16 @@ functions. | |||
| 1249 | @defun set-input-mode interrupt flow meta quit-char | 1249 | @defun set-input-mode interrupt flow meta quit-char |
| 1250 | This function sets the mode for reading keyboard input. If | 1250 | This function sets the mode for reading keyboard input. If |
| 1251 | @var{interrupt} is non-null, then Emacs uses input interrupts. If it is | 1251 | @var{interrupt} is non-null, then Emacs uses input interrupts. If it is |
| 1252 | @code{nil}, then it uses @sc{cbreak} mode. When Emacs communicates | 1252 | @code{nil}, then it uses @sc{cbreak} mode. The default setting is |
| 1253 | directly with X, it ignores this argument and uses interrupts if that is | 1253 | system dependent. Some systems always use @sc{cbreak} mode regardless |
| 1254 | the way it knows how to communicate. | 1254 | of what is specified. |
| 1255 | 1255 | ||
| 1256 | If @var{flow} is non-@code{nil}, then Emacs uses @sc{xon/xoff} (@kbd{C-q}, | 1256 | When Emacs communicates directly with X, it ignores this argument and |
| 1257 | @kbd{C-s}) flow control for output to the terminal. This has no effect except | 1257 | uses interrupts if that is the way it knows how to communicate. |
| 1258 | in @sc{cbreak} mode. @xref{Flow Control}. | ||
| 1259 | 1258 | ||
| 1260 | The default setting is system dependent. Some systems always use | 1259 | If @var{flow} is non-@code{nil}, then Emacs uses @sc{xon/xoff} |
| 1261 | @sc{cbreak} mode regardless of what is specified. | 1260 | (@kbd{C-q}, @kbd{C-s}) flow control for output to the terminal. This |
| 1261 | has no effect except in @sc{cbreak} mode. @xref{Flow Control}. | ||
| 1262 | 1262 | ||
| 1263 | @c Emacs 19 feature | 1263 | @c Emacs 19 feature |
| 1264 | The argument @var{meta} controls support for input character codes | 1264 | The argument @var{meta} controls support for input character codes |
| @@ -1267,7 +1267,7 @@ the 8th bit set into Meta characters. If @var{meta} is @code{nil}, | |||
| 1267 | Emacs disregards the 8th bit; this is necessary when the terminal uses | 1267 | Emacs disregards the 8th bit; this is necessary when the terminal uses |
| 1268 | it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil}, | 1268 | it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil}, |
| 1269 | Emacs uses all 8 bits of input unchanged. This is good for terminals | 1269 | Emacs uses all 8 bits of input unchanged. This is good for terminals |
| 1270 | using European 8-bit character sets. | 1270 | that use 8-bit character sets. |
| 1271 | 1271 | ||
| 1272 | @c Emacs 19 feature | 1272 | @c Emacs 19 feature |
| 1273 | If @var{quit-char} is non-@code{nil}, it specifies the character to | 1273 | If @var{quit-char} is non-@code{nil}, it specifies the character to |
| @@ -1290,8 +1290,8 @@ is non-@code{nil} when Emacs is using interrupt-driven input. If | |||
| 1290 | @code{nil}, Emacs is using @sc{cbreak} mode. | 1290 | @code{nil}, Emacs is using @sc{cbreak} mode. |
| 1291 | @item flow | 1291 | @item flow |
| 1292 | is non-@code{nil} if Emacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s}) | 1292 | is non-@code{nil} if Emacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s}) |
| 1293 | flow control for output to the terminal. This value has no effect | 1293 | flow control for output to the terminal. This value has effect when |
| 1294 | unless @var{interrupt} is non-@code{nil}. | 1294 | unless @var{interrupt} is @code{nil}. |
| 1295 | @item meta | 1295 | @item meta |
| 1296 | is @code{t} if Emacs treats the eighth bit of input characters as | 1296 | is @code{t} if Emacs treats the eighth bit of input characters as |
| 1297 | the meta bit; @code{nil} means Emacs clears the eighth bit of every | 1297 | the meta bit; @code{nil} means Emacs clears the eighth bit of every |
| @@ -1310,10 +1310,11 @@ is the character Emacs currently uses for quitting, usually @kbd{C-g}. | |||
| 1310 | other input events before they become part of key sequences. These | 1310 | other input events before they become part of key sequences. These |
| 1311 | features apply to each event in the order they are described here: each | 1311 | features apply to each event in the order they are described here: each |
| 1312 | event is first modified according to @code{extra-keyboard-modifiers}, | 1312 | event is first modified according to @code{extra-keyboard-modifiers}, |
| 1313 | then translated through @code{keyboard-translate-table} (if applicable). | 1313 | then translated through @code{keyboard-translate-table} (if applicable), |
| 1314 | If it is being read as part of a key sequence, it is then added to the | 1314 | and finally decoded with the specified keyboard coding system. If it is |
| 1315 | sequece being read; then subsequences containing it are checked first | 1315 | being read as part of a key sequence, it is then added to the sequence |
| 1316 | with @code{function-key-map} and then with @code{key-translation-map}. | 1316 | being read; then subsequences containing it are checked first with |
| 1317 | @code{function-key-map} and then with @code{key-translation-map}. | ||
| 1317 | 1318 | ||
| 1318 | @c Emacs 19 feature | 1319 | @c Emacs 19 feature |
| 1319 | @defvar extra-keyboard-modifiers | 1320 | @defvar extra-keyboard-modifiers |
| @@ -1334,9 +1335,9 @@ The @key{META} key. | |||
| 1334 | Each time the user types a keyboard key, it is altered as if the | 1335 | Each time the user types a keyboard key, it is altered as if the |
| 1335 | modifier keys specified in the bit mask were held down. | 1336 | modifier keys specified in the bit mask were held down. |
| 1336 | 1337 | ||
| 1337 | When using X windows, the program can ``press'' any of the modifier | 1338 | When using a window system, the program can ``press'' any of the |
| 1338 | keys in this way. Otherwise, only the @key{CTL} and @key{META} keys can | 1339 | modifier keys in this way. Otherwise, only the @key{CTL} and @key{META} |
| 1339 | be virtually pressed. | 1340 | keys can be virtually pressed. |
| 1340 | @end defvar | 1341 | @end defvar |
| 1341 | 1342 | ||
| 1342 | @defvar keyboard-translate-table | 1343 | @defvar keyboard-translate-table |
| @@ -1392,7 +1393,7 @@ the keyboard translate table if necessary. | |||
| 1392 | 1393 | ||
| 1393 | The remaining translation features translate subsequences of key | 1394 | The remaining translation features translate subsequences of key |
| 1394 | sequences being read. They are implemented in @code{read-key-sequence} | 1395 | sequences being read. They are implemented in @code{read-key-sequence} |
| 1395 | and have no effect on @code{read-char}. | 1396 | and have no effect on input read with @code{read-event}. |
| 1396 | 1397 | ||
| 1397 | @defvar function-key-map | 1398 | @defvar function-key-map |
| 1398 | This variable holds a keymap that describes the character sequences sent | 1399 | This variable holds a keymap that describes the character sequences sent |
| @@ -1406,7 +1407,7 @@ If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | |||
| 1406 | key sequence, it is replaced with the events in @var{v}. | 1407 | key sequence, it is replaced with the events in @var{v}. |
| 1407 | 1408 | ||
| 1408 | For example, VT100 terminals send @kbd{@key{ESC} O P} when the | 1409 | For example, VT100 terminals send @kbd{@key{ESC} O P} when the |
| 1409 | keypad PF1 key is pressed. Therefore, we want Emacs to translate | 1410 | keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate |
| 1410 | that sequence of events into the single event @code{pf1}. We accomplish | 1411 | that sequence of events into the single event @code{pf1}. We accomplish |
| 1411 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in | 1412 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in |
| 1412 | @code{function-key-map}, when using a VT100. | 1413 | @code{function-key-map}, when using a VT100. |
| @@ -1419,7 +1420,8 @@ this back into @kbd{C-c @key{PF1}}, which it returns as the vector | |||
| 1419 | Entries in @code{function-key-map} are ignored if they conflict with | 1420 | Entries in @code{function-key-map} are ignored if they conflict with |
| 1420 | bindings made in the minor mode, local, or global keymaps. The intent | 1421 | bindings made in the minor mode, local, or global keymaps. The intent |
| 1421 | is that the character sequences that function keys send should not have | 1422 | is that the character sequences that function keys send should not have |
| 1422 | command bindings in their own right. | 1423 | command bindings in their own right---but if they do, the ordinary |
| 1424 | bindings take priority. | ||
| 1423 | 1425 | ||
| 1424 | The value of @code{function-key-map} is usually set up automatically | 1426 | The value of @code{function-key-map} is usually set up automatically |
| 1425 | according to the terminal's Terminfo or Termcap entry, but sometimes | 1427 | according to the terminal's Terminfo or Termcap entry, but sometimes |
| @@ -1427,9 +1429,6 @@ those need help from terminal-specific Lisp files. Emacs comes with | |||
| 1427 | terminal-specific files for many common terminals; their main purpose is | 1429 | terminal-specific files for many common terminals; their main purpose is |
| 1428 | to make entries in @code{function-key-map} beyond those that can be | 1430 | to make entries in @code{function-key-map} beyond those that can be |
| 1429 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. | 1431 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. |
| 1430 | |||
| 1431 | Emacs versions 18 and earlier used totally different means of detecting | ||
| 1432 | the character sequences that represent function keys. | ||
| 1433 | @end defvar | 1432 | @end defvar |
| 1434 | 1433 | ||
| 1435 | @defvar key-translation-map | 1434 | @defvar key-translation-map |
| @@ -1494,21 +1493,21 @@ to turn the character that follows into a Hyper character: | |||
| 1494 | @end group | 1493 | @end group |
| 1495 | @end example | 1494 | @end example |
| 1496 | 1495 | ||
| 1497 | @pindex iso-transl | 1496 | Finally, if you have enabled keyboard character set decoding using |
| 1498 | @cindex Latin-1 character set (input) | 1497 | @code{set-keyboard-coding-system}, decoding is done after the |
| 1499 | @cindex ISO Latin-1 characters (input) | 1498 | translations listed above. @xref{Specifying Coding Systems}. In future |
| 1500 | The @file{iso-transl} library uses this feature to provide a way of | 1499 | Emacs versions, character set decoding may be done before the other |
| 1501 | inputting non-ASCII Latin-1 characters. | 1500 | translations. |
| 1502 | 1501 | ||
| 1503 | @node Recording Input | 1502 | @node Recording Input |
| 1504 | @subsection Recording Input | 1503 | @subsection Recording Input |
| 1505 | 1504 | ||
| 1506 | @defun recent-keys | 1505 | @defun recent-keys |
| 1507 | This function returns a vector containing the last 100 input events | 1506 | This function returns a vector containing the last 100 input events from |
| 1508 | from the keyboard or mouse. All input events are included, whether or | 1507 | the keyboard or mouse. All input events are included, whether or not |
| 1509 | not they were used as parts of key sequences. Thus, you always get the | 1508 | they were used as parts of key sequences. Thus, you always get the last |
| 1510 | last 100 inputs, not counting keyboard macros. (Events from keyboard | 1509 | 100 input events, not counting events generated by keyboard macros. |
| 1511 | macros are excluded because they are less interesting for debugging; it | 1510 | (These are excluded because they are less interesting for debugging; it |
| 1512 | should be enough to see the events that invoked the macros.) | 1511 | should be enough to see the events that invoked the macros.) |
| 1513 | @end defun | 1512 | @end defun |
| 1514 | 1513 | ||
| @@ -1565,9 +1564,8 @@ not. If Emacs has the wrong value, it makes decisions that are less | |||
| 1565 | than optimal. To fix the problem, set @code{baud-rate}. | 1564 | than optimal. To fix the problem, set @code{baud-rate}. |
| 1566 | 1565 | ||
| 1567 | @defun baud-rate | 1566 | @defun baud-rate |
| 1568 | This function returns the value of the variable @code{baud-rate}. In | 1567 | This obsolete function returns the value of the variable |
| 1569 | Emacs versions 18 and earlier, this was the only way to find out the | 1568 | @code{baud-rate}. |
| 1570 | terminal speed. | ||
| 1571 | @end defun | 1569 | @end defun |
| 1572 | 1570 | ||
| 1573 | @defun send-string-to-terminal string | 1571 | @defun send-string-to-terminal string |
| @@ -1619,15 +1617,28 @@ To define system-specific X11 keysyms, set the variable | |||
| 1619 | This variable's value should be an alist with one element for each | 1617 | This variable's value should be an alist with one element for each |
| 1620 | system-specific keysym. An element has this form: @code{(@var{code} | 1618 | system-specific keysym. An element has this form: @code{(@var{code} |
| 1621 | . @var{symbol})}, where @var{code} is the numeric keysym code (not | 1619 | . @var{symbol})}, where @var{code} is the numeric keysym code (not |
| 1622 | including the ``vendor specific'' bit, 1 << 28), and @var{symbol} is the | 1620 | including the ``vendor specific'' bit, |
| 1623 | name for the function key. | 1621 | @ifinfo |
| 1622 | -2**28, | ||
| 1623 | @end ifinfo | ||
| 1624 | @tex | ||
| 1625 | $-2^{28}$, | ||
| 1626 | @end tex | ||
| 1627 | and @var{symbol} is the name for the function key. | ||
| 1624 | 1628 | ||
| 1625 | For example @code{(168 . mute-acute)} defines a system-specific key used | 1629 | For example @code{(168 . mute-acute)} defines a system-specific key used |
| 1626 | by HP X servers whose numeric code is (1 << 28) + 168. | 1630 | by HP X servers whose numeric code is |
| 1631 | @ifinfo | ||
| 1632 | -2**28 | ||
| 1633 | @end ifinfo | ||
| 1634 | @tex | ||
| 1635 | $-2^{28}$ | ||
| 1636 | @end tex | ||
| 1637 | + 168. | ||
| 1627 | 1638 | ||
| 1628 | It is not a problem if the alist defines keysyms for other X servers, as | 1639 | It is not crucial to exclude from the alist the keysyms of other X |
| 1629 | long as they don't conflict with the ones used by the X server actually | 1640 | servers; those do no harm, as long as they don't conflict with the ones |
| 1630 | in use. | 1641 | used by the X server actually in use. |
| 1631 | 1642 | ||
| 1632 | The variable is always local to the current X terminal and cannot be | 1643 | The variable is always local to the current X terminal and cannot be |
| 1633 | buffer-local. @xref{Multiple Displays}. | 1644 | buffer-local. @xref{Multiple Displays}. |
| @@ -1637,9 +1648,9 @@ buffer-local. @xref{Multiple Displays}. | |||
| 1637 | @section Flow Control | 1648 | @section Flow Control |
| 1638 | @cindex flow control characters | 1649 | @cindex flow control characters |
| 1639 | 1650 | ||
| 1640 | This section attempts to answer the question ``Why does Emacs choose | 1651 | This section attempts to answer the question ``Why does Emacs use |
| 1641 | to use flow-control characters in its command character set?'' For a | 1652 | flow-control characters in its command character set?'' For a second |
| 1642 | second view on this issue, read the comments on flow control in the | 1653 | view on this issue, read the comments on flow control in the |
| 1643 | @file{emacs/INSTALL} file from the distribution; for help with Termcap | 1654 | @file{emacs/INSTALL} file from the distribution; for help with Termcap |
| 1644 | entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}. | 1655 | entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}. |
| 1645 | 1656 | ||
| @@ -1647,20 +1658,20 @@ entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}. | |||
| 1647 | @cindex @kbd{C-q} | 1658 | @cindex @kbd{C-q} |
| 1648 | At one time, most terminals did not need flow control, and none used | 1659 | At one time, most terminals did not need flow control, and none used |
| 1649 | @code{C-s} and @kbd{C-q} for flow control. Therefore, the choice of | 1660 | @code{C-s} and @kbd{C-q} for flow control. Therefore, the choice of |
| 1650 | @kbd{C-s} and @kbd{C-q} as command characters was uncontroversial. | 1661 | @kbd{C-s} and @kbd{C-q} as command characters for searching and quoting |
| 1651 | Emacs, for economy of keystrokes and portability, used nearly all the | 1662 | was natural and uncontroversial. With so many commands needing key |
| 1652 | @sc{ASCII} control characters, with mnemonic meanings when possible; | 1663 | assignments. of course we assigned meanings to nearly all @sc{ASCII} |
| 1653 | thus, @kbd{C-s} for search and @kbd{C-q} for quote. | 1664 | control characters. |
| 1654 | 1665 | ||
| 1655 | Later, some terminals were introduced which required these characters | 1666 | Later, some terminals were introduced which required these characters |
| 1656 | for flow control. They were not very good terminals for full-screen | 1667 | for flow control. They were not very good terminals for full-screen |
| 1657 | editing, so Emacs maintainers did not pay attention. In later years, | 1668 | editing, so Emacs maintainers ignored them. In later years, flow |
| 1658 | flow control with @kbd{C-s} and @kbd{C-q} became widespread among | 1669 | control with @kbd{C-s} and @kbd{C-q} became widespread among terminals, |
| 1659 | terminals, but by this time it was usually an option. And the majority | 1670 | but by this time it was usually an option. And the majority of Emacs |
| 1660 | of users, who can turn flow control off, were unwilling to switch to | 1671 | users, who can turn flow control off, did not want to switch to less |
| 1661 | less mnemonic key bindings for the sake of flow control. | 1672 | mnemonic key bindings for the sake of flow control. |
| 1662 | 1673 | ||
| 1663 | So which usage is ``right'', Emacs's or that of some terminal and | 1674 | So which usage is ``right''---Emacs's or that of some terminal and |
| 1664 | concentrator manufacturers? This question has no simple answer. | 1675 | concentrator manufacturers? This question has no simple answer. |
| 1665 | 1676 | ||
| 1666 | One reason why we are reluctant to cater to the problems caused by | 1677 | One reason why we are reluctant to cater to the problems caused by |
| @@ -1668,13 +1679,13 @@ concentrator manufacturers? This question has no simple answer. | |||
| 1668 | techniques (albeit less common in practice) for flow control that | 1679 | techniques (albeit less common in practice) for flow control that |
| 1669 | preserve transparency of the character stream. Note also that their use | 1680 | preserve transparency of the character stream. Note also that their use |
| 1670 | for flow control is not an official standard. Interestingly, on the | 1681 | for flow control is not an official standard. Interestingly, on the |
| 1671 | model 33 teletype with a paper tape punch (which is very old), @kbd{C-s} | 1682 | model 33 teletype with a paper tape punch (around 1970), @kbd{C-s} and |
| 1672 | and @kbd{C-q} were sent by the computer to turn the punch on and off! | 1683 | @kbd{C-q} were sent by the computer to turn the punch on and off! |
| 1673 | 1684 | ||
| 1674 | As X servers and other window systems replace character-only | 1685 | As window systems and PC terminal emulators replace character-only |
| 1675 | terminals, this problem is gradually being cured. For the mean time, | 1686 | terminals, the flow control problem is gradually disappearing. For the |
| 1676 | Emacs provides a convenient way of enabling flow control if you want it: | 1687 | mean time, Emacs provides a convenient way of enabling flow control if |
| 1677 | call the function @code{enable-flow-control}. | 1688 | you want it: call the function @code{enable-flow-control}. |
| 1678 | 1689 | ||
| 1679 | @deffn Command enable-flow-control | 1690 | @deffn Command enable-flow-control |
| 1680 | This function enables use of @kbd{C-s} and @kbd{C-q} for output flow | 1691 | This function enables use of @kbd{C-s} and @kbd{C-q} for output flow |
diff --git a/lispref/positions.texi b/lispref/positions.texi index b2cb47efabb..a414abb5dc7 100644 --- a/lispref/positions.texi +++ b/lispref/positions.texi | |||
| @@ -241,7 +241,7 @@ puts point @var{n} tenths of the way from the beginning of the buffer. | |||
| 241 | In an interactive call, @var{n} is the numeric prefix argument, | 241 | In an interactive call, @var{n} is the numeric prefix argument, |
| 242 | if provided; otherwise @var{n} defaults to @code{nil}. | 242 | if provided; otherwise @var{n} defaults to @code{nil}. |
| 243 | 243 | ||
| 244 | Don't use this function in Lisp programs! | 244 | @strong{Warning:} Don't use this function in Lisp programs! |
| 245 | @end deffn | 245 | @end deffn |
| 246 | 246 | ||
| 247 | @deffn Command end-of-buffer &optional n | 247 | @deffn Command end-of-buffer &optional n |
| @@ -253,7 +253,7 @@ point @var{n} tenths of the way from the end of the buffer. | |||
| 253 | In an interactive call, @var{n} is the numeric prefix argument, | 253 | In an interactive call, @var{n} is the numeric prefix argument, |
| 254 | if provided; otherwise @var{n} defaults to @code{nil}. | 254 | if provided; otherwise @var{n} defaults to @code{nil}. |
| 255 | 255 | ||
| 256 | Don't use this function in Lisp programs! | 256 | @strong{Warning:} Don't use this function in Lisp programs! |
| 257 | @end deffn | 257 | @end deffn |
| 258 | 258 | ||
| 259 | @node Text Lines | 259 | @node Text Lines |
| @@ -759,6 +759,11 @@ The value returned by @code{save-excursion} is the result of the last of | |||
| 759 | @end example | 759 | @end example |
| 760 | @end defspec | 760 | @end defspec |
| 761 | 761 | ||
| 762 | Although @code{save-excursion} saves the location of the mark, it does | ||
| 763 | not prevent functions which modify the buffer from setting | ||
| 764 | @code{deactivate-mark}, and thus causing the deactivation of the mark | ||
| 765 | after the command finishes. @xref{The Mark}. | ||
| 766 | |||
| 762 | @node Narrowing | 767 | @node Narrowing |
| 763 | @section Narrowing | 768 | @section Narrowing |
| 764 | @cindex narrowing | 769 | @cindex narrowing |
diff --git a/lispref/processes.texi b/lispref/processes.texi index e9106f3a768..94b8e61bdf3 100644 --- a/lispref/processes.texi +++ b/lispref/processes.texi | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/processes | 5 | @setfilename ../info/processes |
| 6 | @node Processes, System Interface, Abbrevs, Top | 6 | @node Processes, Display, Abbrevs, Top |
| 7 | @chapter Processes | 7 | @chapter Processes |
| 8 | @cindex child process | 8 | @cindex child process |
| 9 | @cindex parent process | 9 | @cindex parent process |
| @@ -35,8 +35,6 @@ This function returns @code{t} if @var{object} is a process, | |||
| 35 | @menu | 35 | @menu |
| 36 | * Subprocess Creation:: Functions that start subprocesses. | 36 | * Subprocess Creation:: Functions that start subprocesses. |
| 37 | * Synchronous Processes:: Details of using synchronous subprocesses. | 37 | * Synchronous Processes:: Details of using synchronous subprocesses. |
| 38 | * MS-DOS Subprocesses:: On MS-DOS, you must indicate text vs binary | ||
| 39 | for data sent to and from a subprocess. | ||
| 40 | * Asynchronous Processes:: Starting up an asynchronous subprocess. | 38 | * Asynchronous Processes:: Starting up an asynchronous subprocess. |
| 41 | * Deleting Processes:: Eliminating an asynchronous subprocess. | 39 | * Deleting Processes:: Eliminating an asynchronous subprocess. |
| 42 | * Process Information:: Accessing run-status and other attributes. | 40 | * Process Information:: Accessing run-status and other attributes. |
| @@ -127,6 +125,46 @@ The value of @code{exec-path} is used by @code{call-process} and | |||
| 127 | file name. | 125 | file name. |
| 128 | @end defopt | 126 | @end defopt |
| 129 | 127 | ||
| 128 | @node Shell Arguments | ||
| 129 | @section Shell Arguments | ||
| 130 | |||
| 131 | Lisp programs sometimes need to run a shell and give it a command | ||
| 132 | which contains file names that were specified by the user. These | ||
| 133 | programs ought to be able to support any valid file name. But the shell | ||
| 134 | gives special treatment to certain characters, and if these characters | ||
| 135 | occur in the file name, they will confuse the shell. To handle these | ||
| 136 | characters, use the function @code{shell-quote-argument}: | ||
| 137 | |||
| 138 | @defun shell-quote-argument argument | ||
| 139 | This function returns a string which represents, in shell syntax, | ||
| 140 | an argument whose actual contents are @var{argument}. It should | ||
| 141 | work reliably to concatenate the return value into a shell command | ||
| 142 | and then pass it to a shell for execution. | ||
| 143 | |||
| 144 | Precisely what this function does depends on your operating system. The | ||
| 145 | function is designed to work with the usual shell syntax; if you use an | ||
| 146 | unusual shell, you will need to redefine this function. On MS-DOS, the | ||
| 147 | function returns @var{argument} unchanged; while this is not really | ||
| 148 | correct, it is the best one can do, since the MS-DOS shell has no | ||
| 149 | quoting features. | ||
| 150 | |||
| 151 | @example | ||
| 152 | ;; @r{This example shows the behavior on GNU and Unix systems.} | ||
| 153 | (shell-quote-argument "foo > bar") | ||
| 154 | @result{} "foo\\ \\>\\ bar" | ||
| 155 | @end example | ||
| 156 | |||
| 157 | Here's an example of using @code{shell-quote-argument} to construct | ||
| 158 | a shell command: | ||
| 159 | |||
| 160 | @example | ||
| 161 | (concat "diff -c " | ||
| 162 | (shell-quote-argument oldfile) | ||
| 163 | " " | ||
| 164 | (shell-quote-argument newfile)) | ||
| 165 | @end example | ||
| 166 | @end defun | ||
| 167 | |||
| 130 | @node Synchronous Processes | 168 | @node Synchronous Processes |
| 131 | @section Creating a Synchronous Process | 169 | @section Creating a Synchronous Process |
| 132 | @cindex synchronous subprocess | 170 | @cindex synchronous subprocess |
| @@ -145,13 +183,15 @@ subprocess actually terminates before quitting. If during that time the | |||
| 145 | user types another @kbd{C-g}, that kills the subprocess instantly with | 183 | user types another @kbd{C-g}, that kills the subprocess instantly with |
| 146 | @code{SIGKILL} and quits immediately. @xref{Quitting}. | 184 | @code{SIGKILL} and quits immediately. @xref{Quitting}. |
| 147 | 185 | ||
| 148 | The synchronous subprocess functions returned @code{nil} in version | 186 | The synchronous subprocess functions return an indication of how the |
| 149 | 18. Now they return an indication of how the process terminated. | 187 | process terminated. |
| 150 | 188 | ||
| 151 | The output from a synchronous subprocess is generally decoded using a | 189 | The output from a synchronous subprocess is generally decoded using a |
| 152 | coding system, much like text read from a file. The input sent to a | 190 | coding system, much like text read from a file. The input sent to a |
| 153 | subprocess by @code{call-process-region} is encoded using a coding | 191 | subprocess by @code{call-process-region} is encoded using a coding |
| 154 | system, much like text written into a file. @xref{Coding Systems}. | 192 | system, much like text written into a file. @xref{Coding Systems}. |
| 193 | On Microsoft operating systems, additional variables control | ||
| 194 | the conversion for end-of-line (@pxref{MS-DOS Subprocesses}). | ||
| 155 | 195 | ||
| 156 | @defun call-process program &optional infile destination display &rest args | 196 | @defun call-process program &optional infile destination display &rest args |
| 157 | This function calls @var{program} in a separate process and waits for | 197 | This function calls @var{program} in a separate process and waits for |
| @@ -168,8 +208,7 @@ Insert the output in that buffer, before point. This includes both the | |||
| 168 | standard output stream and the standard error stream of the process. | 208 | standard output stream and the standard error stream of the process. |
| 169 | 209 | ||
| 170 | @item a string | 210 | @item a string |
| 171 | Find the buffer with that name, then insert the output in that buffer, | 211 | Insert the output in a buffer with that name, before point. |
| 172 | before point. | ||
| 173 | 212 | ||
| 174 | @item @code{t} | 213 | @item @code{t} |
| 175 | Insert the output in the current buffer, before point. | 214 | Insert the output in the current buffer, before point. |
| @@ -190,9 +229,9 @@ function returns. | |||
| 190 | Keep the standard output stream separate from the standard error stream; | 229 | Keep the standard output stream separate from the standard error stream; |
| 191 | deal with the ordinary output as specified by @var{real-destination}, | 230 | deal with the ordinary output as specified by @var{real-destination}, |
| 192 | and dispose of the error output according to @var{error-destination}. | 231 | and dispose of the error output according to @var{error-destination}. |
| 193 | The value @code{nil} means discard it, @code{t} means mix it with the | 232 | If @var{error-destination} is @code{nil}, that means to discard the |
| 194 | ordinary output, and a string specifies a file name to redirect error | 233 | error output, @code{t} means mix it with the ordinary output, and a |
| 195 | output into. | 234 | string specifies a file name to redirect error output into. |
| 196 | 235 | ||
| 197 | You can't directly specify a buffer to put the error output in; that is | 236 | You can't directly specify a buffer to put the error output in; that is |
| 198 | too difficult to implement. But you can achieve this result by sending | 237 | too difficult to implement. But you can achieve this result by sending |
| @@ -237,12 +276,12 @@ lewis:5LTsHm66CSWKg:398:21:Bil Lewis:/user/lewis:/bin/csh | |||
| 237 | @end group | 276 | @end group |
| 238 | @end smallexample | 277 | @end smallexample |
| 239 | 278 | ||
| 240 | The @code{insert-directory} function contains a good example of the use | 279 | Here is a good example of the use of @code{call-process}, which used to |
| 241 | of @code{call-process}: | 280 | be found in the definition of @code{insert-directory}: |
| 242 | 281 | ||
| 243 | @smallexample | 282 | @smallexample |
| 244 | @group | 283 | @group |
| 245 | (call-process insert-directory-program nil t nil switches | 284 | (call-process insert-directory-program nil t nil @var{switches} |
| 246 | (if full-directory-p | 285 | (if full-directory-p |
| 247 | (concat (file-name-as-directory file) ".") | 286 | (concat (file-name-as-directory file) ".") |
| 248 | file)) | 287 | file)) |
| @@ -318,32 +357,6 @@ This function executes @var{command} (a string) as a shell command, | |||
| 318 | then returns the command's output as a string. | 357 | then returns the command's output as a string. |
| 319 | @end defun | 358 | @end defun |
| 320 | 359 | ||
| 321 | @node MS-DOS Subprocesses | ||
| 322 | @section MS-DOS Subprocesses | ||
| 323 | |||
| 324 | On MS-DOS, you must indicate whether the data going to and from | ||
| 325 | a synchronous subprocess are text or binary. Text data requires | ||
| 326 | translation between the end-of-line convention used within Emacs | ||
| 327 | (a single newline character) and the convention used outside Emacs | ||
| 328 | (the two-character sequence, @sc{crlf}). | ||
| 329 | |||
| 330 | The variable @code{binary-process-input} applies to input sent to the | ||
| 331 | subprocess, and @code{binary-process-output} applies to output received | ||
| 332 | from it. A non-@code{nil} value means the data is non-text; @code{nil} | ||
| 333 | means the data is text, and calls for conversion. | ||
| 334 | |||
| 335 | @defvar binary-process-input | ||
| 336 | If this variable is @code{nil}, convert newlines to @sc{crlf} sequences in | ||
| 337 | the input to a synchronous subprocess. | ||
| 338 | @end defvar | ||
| 339 | |||
| 340 | @defvar binary-process-output | ||
| 341 | If this variable is @code{nil}, convert @sc{crlf} sequences to newlines in | ||
| 342 | the output from a synchronous subprocess. | ||
| 343 | @end defvar | ||
| 344 | |||
| 345 | @xref{Files and MS-DOS}, for related information. | ||
| 346 | |||
| 347 | @node Asynchronous Processes | 360 | @node Asynchronous Processes |
| 348 | @section Creating an Asynchronous Process | 361 | @section Creating an Asynchronous Process |
| 349 | @cindex asynchronous subprocess | 362 | @cindex asynchronous subprocess |
| @@ -403,6 +416,14 @@ to execute the specified command. The argument @var{command} is a shell | |||
| 403 | command name, and @var{command-args} are the arguments for the shell | 416 | command name, and @var{command-args} are the arguments for the shell |
| 404 | command. The variable @code{shell-file-name} specifies which shell to | 417 | command. The variable @code{shell-file-name} specifies which shell to |
| 405 | use. | 418 | use. |
| 419 | |||
| 420 | The point of running a program through the shell, rather than directly | ||
| 421 | with @code{start-process}, is so that you can employ shell features such | ||
| 422 | as wildcards in the arguments. It follows that if you include an | ||
| 423 | arbitrary user-specified filename in the command, you should quote it | ||
| 424 | with @code{shell-quote-argument} first, so that any special shell | ||
| 425 | characters in the file name do @emph{not} have their special shell | ||
| 426 | meanings. @xref{Shell Arguments}. | ||
| 406 | @end defun | 427 | @end defun |
| 407 | 428 | ||
| 408 | @defvar process-connection-type | 429 | @defvar process-connection-type |
| @@ -602,9 +623,6 @@ x | |||
| 602 | For a network connection, @code{process-status} returns one of the symbols | 623 | For a network connection, @code{process-status} returns one of the symbols |
| 603 | @code{open} or @code{closed}. The latter means that the other side | 624 | @code{open} or @code{closed}. The latter means that the other side |
| 604 | closed the connection, or Emacs did @code{delete-process}. | 625 | closed the connection, or Emacs did @code{delete-process}. |
| 605 | |||
| 606 | In Emacs version 18, the status of a network connection was @code{run} | ||
| 607 | if open, and @code{exit} if closed. | ||
| 608 | @end defun | 626 | @end defun |
| 609 | 627 | ||
| 610 | @defun process-exit-status process | 628 | @defun process-exit-status process |
| @@ -628,8 +646,7 @@ for decoding output from @var{process} and for encoding input to | |||
| 628 | @var{process} (@pxref{Coding Systems}). The value has this form: | 646 | @var{process} (@pxref{Coding Systems}). The value has this form: |
| 629 | 647 | ||
| 630 | @example | 648 | @example |
| 631 | (@var{coding-system-for-decoding} | 649 | (@var{coding-system-for-decoding} . @var{coding-system-for-encoding}) |
| 632 | . @var{coding-system-for-encoding}) | ||
| 633 | @end example | 650 | @end example |
| 634 | @end defun | 651 | @end defun |
| 635 | 652 | ||
| @@ -789,7 +806,7 @@ This function stops the process @var{process-name} by sending the | |||
| 789 | signal @code{SIGTSTP}. Use @code{continue-process} to resume its | 806 | signal @code{SIGTSTP}. Use @code{continue-process} to resume its |
| 790 | execution. | 807 | execution. |
| 791 | 808 | ||
| 792 | On systems with job control, outside of Emacs)\, the ``stop character'' | 809 | Outside of Emacs, on systems with job control, the ``stop character'' |
| 793 | (usually @kbd{C-z}) normally sends this signal. When | 810 | (usually @kbd{C-z}) normally sends this signal. When |
| 794 | @var{current-group} is non-@code{nil}, you can think of this function as | 811 | @var{current-group} is non-@code{nil}, you can think of this function as |
| 795 | ``typing @kbd{C-z}'' on the terminal Emacs uses to communicate with the | 812 | ``typing @kbd{C-z}'' on the terminal Emacs uses to communicate with the |
diff --git a/lispref/searching.texi b/lispref/searching.texi index 7722b9b1c7f..336865c5642 100644 --- a/lispref/searching.texi +++ b/lispref/searching.texi | |||
| @@ -199,15 +199,15 @@ the string @samp{fo}. Still trivial. To do something more powerful, you | |||
| 199 | need to use one of the special characters. Here is a list of them: | 199 | need to use one of the special characters. Here is a list of them: |
| 200 | 200 | ||
| 201 | @need 1200 | 201 | @need 1200 |
| 202 | @table @kbd | 202 | @table @asis |
| 203 | @item .@: @r{(Period)} | 203 | @item @samp{.}@: @r{(Period)} |
| 204 | @cindex @samp{.} in regexp | 204 | @cindex @samp{.} in regexp |
| 205 | is a special character that matches any single character except a newline. | 205 | is a special character that matches any single character except a newline. |
| 206 | Using concatenation, we can make regular expressions like @samp{a.b}, which | 206 | Using concatenation, we can make regular expressions like @samp{a.b}, which |
| 207 | matches any three-character string that begins with @samp{a} and ends with | 207 | matches any three-character string that begins with @samp{a} and ends with |
| 208 | @samp{b}.@refill | 208 | @samp{b}.@refill |
| 209 | 209 | ||
| 210 | @item * | 210 | @item @samp{*} |
| 211 | @cindex @samp{*} in regexp | 211 | @cindex @samp{*} in regexp |
| 212 | is not a construct by itself; it is a postfix operator that means to | 212 | is not a construct by itself; it is a postfix operator that means to |
| 213 | match the preceding regular expression repetitively as many times as | 213 | match the preceding regular expression repetitively as many times as |
| @@ -237,35 +237,35 @@ Emacs must try each imaginable way of grouping the 35 @samp{x}'s before | |||
| 237 | concluding that none of them can work. To make sure your regular | 237 | concluding that none of them can work. To make sure your regular |
| 238 | expressions run fast, check nested repetitions carefully. | 238 | expressions run fast, check nested repetitions carefully. |
| 239 | 239 | ||
| 240 | @item + | 240 | @item @samp{+} |
| 241 | @cindex @samp{+} in regexp | 241 | @cindex @samp{+} in regexp |
| 242 | is a postfix operator, similar to @samp{*} except that it must match | 242 | is a postfix operator, similar to @samp{*} except that it must match |
| 243 | the preceding expression at least once. So, for example, @samp{ca+r} | 243 | the preceding expression at least once. So, for example, @samp{ca+r} |
| 244 | matches the strings @samp{car} and @samp{caaaar} but not the string | 244 | matches the strings @samp{car} and @samp{caaaar} but not the string |
| 245 | @samp{cr}, whereas @samp{ca*r} matches all three strings. | 245 | @samp{cr}, whereas @samp{ca*r} matches all three strings. |
| 246 | 246 | ||
| 247 | @item ? | 247 | @item @samp{?} |
| 248 | @cindex @samp{?} in regexp | 248 | @cindex @samp{?} in regexp |
| 249 | is a postfix operator, similar to @samp{*} except that it must match the | 249 | is a postfix operator, similar to @samp{*} except that it must match the |
| 250 | preceding expression either once or not at all. For example, | 250 | preceding expression either once or not at all. For example, |
| 251 | @samp{ca?r} matches @samp{car} or @samp{cr}; nothing else. | 251 | @samp{ca?r} matches @samp{car} or @samp{cr}; nothing else. |
| 252 | 252 | ||
| 253 | @item [ @dots{} ] | 253 | @item @samp{[ @dots{} ]} |
| 254 | @cindex character set (in regexp) | 254 | @cindex character alternative (in regexp) |
| 255 | @cindex @samp{[} in regexp | 255 | @cindex @samp{[} in regexp |
| 256 | @cindex @samp{]} in regexp | 256 | @cindex @samp{]} in regexp |
| 257 | is a @dfn{character set}, which begins with @samp{[} and is terminated | 257 | is a @dfn{character alternative}, which begins with @samp{[} and is |
| 258 | by @samp{]}. In the simplest case, the characters between the two | 258 | terminated by @samp{]}. In the simplest case, the characters between |
| 259 | brackets are what this set can match. | 259 | the two brackets are what this character alternative can match. |
| 260 | 260 | ||
| 261 | Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and | 261 | Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and |
| 262 | @samp{[ad]*} matches any string composed of just @samp{a}s and @samp{d}s | 262 | @samp{[ad]*} matches any string composed of just @samp{a}s and @samp{d}s |
| 263 | (including the empty string), from which it follows that @samp{c[ad]*r} | 263 | (including the empty string), from which it follows that @samp{c[ad]*r} |
| 264 | matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc. | 264 | matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc. |
| 265 | 265 | ||
| 266 | You can also include character ranges in a character set, by writing the | 266 | You can also include character ranges in a character alternative, by |
| 267 | starting and ending characters with a @samp{-} between them. Thus, | 267 | writing the starting and ending characters with a @samp{-} between them. |
| 268 | @samp{[a-z]} matches any lower-case ASCII letter. Ranges may be | 268 | Thus, @samp{[a-z]} matches any lower-case ASCII letter. Ranges may be |
| 269 | intermixed freely with individual characters, as in @samp{[a-z$%.]}, | 269 | intermixed freely with individual characters, as in @samp{[a-z$%.]}, |
| 270 | which matches any lower case ASCII letter or @samp{$}, @samp{%} or | 270 | which matches any lower case ASCII letter or @samp{$}, @samp{%} or |
| 271 | period. | 271 | period. |
| @@ -284,33 +284,33 @@ The beginning and end of a range must be in the same character set | |||
| 284 | (@samp{a} with grave accent) is in the Latin-1 character set. | 284 | (@samp{a} with grave accent) is in the Latin-1 character set. |
| 285 | 285 | ||
| 286 | Note that the usual regexp special characters are not special inside a | 286 | Note that the usual regexp special characters are not special inside a |
| 287 | character set. A completely different set of special characters exists | 287 | character alternative. A completely different set of characters are |
| 288 | inside character sets: @samp{]}, @samp{-} and @samp{^}. | 288 | special inside character alternatives: @samp{]}, @samp{-} and @samp{^}. |
| 289 | 289 | ||
| 290 | To include a @samp{]} in a character set, you must make it the first | 290 | To include a @samp{]} in a character alternative, you must make it the |
| 291 | character. For example, @samp{[]a]} matches @samp{]} or @samp{a}. To | 291 | first character. For example, @samp{[]a]} matches @samp{]} or @samp{a}. |
| 292 | include a @samp{-}, write @samp{-} as the first or last character of the | 292 | To include a @samp{-}, write @samp{-} as the first or last character of |
| 293 | set, or put it after a range. Thus, @samp{[]-]} matches both @samp{]} | 293 | the character alternative, or put it after a range. Thus, @samp{[]-]} |
| 294 | and @samp{-}. | 294 | matches both @samp{]} and @samp{-}. |
| 295 | 295 | ||
| 296 | To include @samp{^} in a set, put it anywhere but at the beginning of | 296 | To include @samp{^} in a character alternative, put it anywhere but at |
| 297 | the set. | 297 | the beginning. |
| 298 | 298 | ||
| 299 | @item [^ @dots{} ] | 299 | @item @samp{[^ @dots{} ]} |
| 300 | @cindex @samp{^} in regexp | 300 | @cindex @samp{^} in regexp |
| 301 | @samp{[^} begins a @dfn{complemented character set}, which matches any | 301 | @samp{[^} begins a @dfn{complemented character alternative}, which matches any |
| 302 | character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches | 302 | character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches |
| 303 | all characters @emph{except} letters and digits. | 303 | all characters @emph{except} letters and digits. |
| 304 | 304 | ||
| 305 | @samp{^} is not special in a character set unless it is the first | 305 | @samp{^} is not special in a character alternative unless it is the first |
| 306 | character. The character following the @samp{^} is treated as if it | 306 | character. The character following the @samp{^} is treated as if it |
| 307 | were first (in other words, @samp{-} and @samp{]} are not special there). | 307 | were first (in other words, @samp{-} and @samp{]} are not special there). |
| 308 | 308 | ||
| 309 | A complemented character set can match a newline, unless newline is | 309 | A complemented character alternative can match a newline, unless newline is |
| 310 | mentioned as one of the characters not to match. This is in contrast to | 310 | mentioned as one of the characters not to match. This is in contrast to |
| 311 | the handling of regexps in programs such as @code{grep}. | 311 | the handling of regexps in programs such as @code{grep}. |
| 312 | 312 | ||
| 313 | @item ^ | 313 | @item @samp{^} |
| 314 | @cindex @samp{^} in regexp | 314 | @cindex @samp{^} in regexp |
| 315 | @cindex beginning of line in regexp | 315 | @cindex beginning of line in regexp |
| 316 | is a special character that matches the empty string, but only at the | 316 | is a special character that matches the empty string, but only at the |
| @@ -321,7 +321,7 @@ the beginning of a line. | |||
| 321 | When matching a string instead of a buffer, @samp{^} matches at the | 321 | When matching a string instead of a buffer, @samp{^} matches at the |
| 322 | beginning of the string or after a newline character @samp{\n}. | 322 | beginning of the string or after a newline character @samp{\n}. |
| 323 | 323 | ||
| 324 | @item $ | 324 | @item @samp{$} |
| 325 | @cindex @samp{$} in regexp | 325 | @cindex @samp{$} in regexp |
| 326 | is similar to @samp{^} but matches only at the end of a line. Thus, | 326 | is similar to @samp{^} but matches only at the end of a line. Thus, |
| 327 | @samp{x+$} matches a string of one @samp{x} or more at the end of a line. | 327 | @samp{x+$} matches a string of one @samp{x} or more at the end of a line. |
| @@ -329,7 +329,7 @@ is similar to @samp{^} but matches only at the end of a line. Thus, | |||
| 329 | When matching a string instead of a buffer, @samp{$} matches at the end | 329 | When matching a string instead of a buffer, @samp{$} matches at the end |
| 330 | of the string or before a newline character @samp{\n}. | 330 | of the string or before a newline character @samp{\n}. |
| 331 | 331 | ||
| 332 | @item \ | 332 | @item @samp{\} |
| 333 | @cindex @samp{\} in regexp | 333 | @cindex @samp{\} in regexp |
| 334 | has two functions: it quotes the special characters (including | 334 | has two functions: it quotes the special characters (including |
| 335 | @samp{\}), and it introduces additional special constructs. | 335 | @samp{\}), and it introduces additional special constructs. |
| @@ -360,7 +360,7 @@ sequences starting with @samp{\} which have special meanings. The | |||
| 360 | second character in the sequence is always an ordinary character on | 360 | second character in the sequence is always an ordinary character on |
| 361 | their own. Here is a table of @samp{\} constructs. | 361 | their own. Here is a table of @samp{\} constructs. |
| 362 | 362 | ||
| 363 | @table @kbd | 363 | @table @samp |
| 364 | @item \| | 364 | @item \| |
| 365 | @cindex @samp{|} in regexp | 365 | @cindex @samp{|} in regexp |
| 366 | @cindex regexp alternative | 366 | @cindex regexp alternative |
| @@ -454,7 +454,7 @@ matches any character whose syntax is not @var{code}. | |||
| 454 | they don't use up any characters---but whether they match depends on the | 454 | they don't use up any characters---but whether they match depends on the |
| 455 | context. | 455 | context. |
| 456 | 456 | ||
| 457 | @table @kbd | 457 | @table @samp |
| 458 | @item \` | 458 | @item \` |
| 459 | @cindex @samp{\`} in regexp | 459 | @cindex @samp{\`} in regexp |
| 460 | matches the empty string, but only at the beginning | 460 | matches the empty string, but only at the beginning |
| @@ -519,7 +519,7 @@ string match when calling a function that wants a regular expression. | |||
| 519 | 519 | ||
| 520 | One use of @code{regexp-quote} is to combine an exact string match with | 520 | One use of @code{regexp-quote} is to combine an exact string match with |
| 521 | context described as a regular expression. For example, this searches | 521 | context described as a regular expression. For example, this searches |
| 522 | for the string that is the value of @code{string}, surrounded by | 522 | for the string that is the value of @var{string}, surrounded by |
| 523 | whitespace: | 523 | whitespace: |
| 524 | 524 | ||
| 525 | @example | 525 | @example |
| @@ -558,7 +558,7 @@ regular expression which is equivalent to the actual value | |||
| 558 | @tindex regexp-opt-depth | 558 | @tindex regexp-opt-depth |
| 559 | @defun regexp-opt-depth regexp | 559 | @defun regexp-opt-depth regexp |
| 560 | This function returns the total number of grouping constructs | 560 | This function returns the total number of grouping constructs |
| 561 | (parenthesised expressions) in @var{regexp}. | 561 | (parenthesized expressions) in @var{regexp}. |
| 562 | @end defun | 562 | @end defun |
| 563 | 563 | ||
| 564 | @node Regexp Example | 564 | @node Regexp Example |
| @@ -579,14 +579,14 @@ tab and @samp{\n} for a newline. | |||
| 579 | "[.?!][]\"')@}]*\\($\\| $\\|\t\\| \\)[ \t\n]*" | 579 | "[.?!][]\"')@}]*\\($\\| $\\|\t\\| \\)[ \t\n]*" |
| 580 | @end example | 580 | @end example |
| 581 | 581 | ||
| 582 | In contrast, if you evaluate the variable @code{sentence-end}, you | 582 | @noindent |
| 583 | In contrast, if you evaluate the variable @code{sentence-end}, you | ||
| 583 | will see the following: | 584 | will see the following: |
| 584 | 585 | ||
| 585 | @example | 586 | @example |
| 586 | @group | 587 | @group |
| 587 | sentence-end | 588 | sentence-end |
| 588 | @result{} | 589 | @result{} "[.?!][]\"')@}]*\\($\\| $\\| \\| \\)[ |
| 589 | "[.?!][]\"')@}]*\\($\\| $\\| \\| \\)[ | ||
| 590 | ]*" | 590 | ]*" |
| 591 | @end group | 591 | @end group |
| 592 | @end example | 592 | @end example |
| @@ -599,16 +599,16 @@ deciphered as follows: | |||
| 599 | 599 | ||
| 600 | @table @code | 600 | @table @code |
| 601 | @item [.?!] | 601 | @item [.?!] |
| 602 | The first part of the pattern is a character set that matches any one of | 602 | The first part of the pattern is a character alternative that matches |
| 603 | three characters: period, question mark, and exclamation mark. The | 603 | any one of three characters: period, question mark, and exclamation |
| 604 | match must begin with one of these three characters. | 604 | mark. The match must begin with one of these three characters. |
| 605 | 605 | ||
| 606 | @item []\"')@}]* | 606 | @item []\"')@}]* |
| 607 | The second part of the pattern matches any closing braces and quotation | 607 | The second part of the pattern matches any closing braces and quotation |
| 608 | marks, zero or more of them, that may follow the period, question mark | 608 | marks, zero or more of them, that may follow the period, question mark |
| 609 | or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in | 609 | or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in |
| 610 | a string. The @samp{*} at the end indicates that the immediately | 610 | a string. The @samp{*} at the end indicates that the immediately |
| 611 | preceding regular expression (a character set, in this case) may be | 611 | preceding regular expression (a character alternative, in this case) may be |
| 612 | repeated zero or more times. | 612 | repeated zero or more times. |
| 613 | 613 | ||
| 614 | @item \\($\\|@ $\\|\t\\|@ @ \\) | 614 | @item \\($\\|@ $\\|\t\\|@ @ \\) |
| @@ -630,11 +630,11 @@ beyond the minimum needed to end a sentence. | |||
| 630 | @cindex regexp searching | 630 | @cindex regexp searching |
| 631 | @cindex searching for regexp | 631 | @cindex searching for regexp |
| 632 | 632 | ||
| 633 | In GNU Emacs, you can search for the next match for a regexp either | 633 | In GNU Emacs, you can search for the next match for a regular |
| 634 | incrementally or not. For incremental search commands, see @ref{Regexp | 634 | expression either incrementally or not. For incremental search |
| 635 | Search, , Regular Expression Search, emacs, The GNU Emacs Manual}. Here | 635 | commands, see @ref{Regexp Search, , Regular Expression Search, emacs, |
| 636 | we describe only the search functions useful in programs. The principal | 636 | The GNU Emacs Manual}. Here we describe only the search functions |
| 637 | one is @code{re-search-forward}. | 637 | useful in programs. The principal one is @code{re-search-forward}. |
| 638 | 638 | ||
| 639 | These search functions convert the regular expression to multibyte if | 639 | These search functions convert the regular expression to multibyte if |
| 640 | the buffer is multibyte; they convert the regular expression to unibyte | 640 | the buffer is multibyte; they convert the regular expression to unibyte |
| @@ -704,8 +704,8 @@ matching a regular expression at a given spot always works from | |||
| 704 | beginning to end, and starts at a specified beginning position. | 704 | beginning to end, and starts at a specified beginning position. |
| 705 | 705 | ||
| 706 | A true mirror-image of @code{re-search-forward} would require a special | 706 | A true mirror-image of @code{re-search-forward} would require a special |
| 707 | feature for matching regexps from end to beginning. It's not worth the | 707 | feature for matching regular expressions from end to beginning. It's |
| 708 | trouble of implementing that. | 708 | not worth the trouble of implementing that. |
| 709 | @end deffn | 709 | @end deffn |
| 710 | 710 | ||
| 711 | @defun string-match regexp string &optional start | 711 | @defun string-match regexp string &optional start |
| @@ -1001,13 +1001,76 @@ can't avoid another intervening search, you must save and restore the | |||
| 1001 | match data around it, to prevent it from being overwritten. | 1001 | match data around it, to prevent it from being overwritten. |
| 1002 | 1002 | ||
| 1003 | @menu | 1003 | @menu |
| 1004 | * Replacing Match:: Replacing a substring that was matched. | ||
| 1004 | * Simple Match Data:: Accessing single items of match data, | 1005 | * Simple Match Data:: Accessing single items of match data, |
| 1005 | such as where a particular subexpression started. | 1006 | such as where a particular subexpression started. |
| 1006 | * Replacing Match:: Replacing a substring that was matched. | ||
| 1007 | * Entire Match Data:: Accessing the entire match data at once, as a list. | 1007 | * Entire Match Data:: Accessing the entire match data at once, as a list. |
| 1008 | * Saving Match Data:: Saving and restoring the match data. | 1008 | * Saving Match Data:: Saving and restoring the match data. |
| 1009 | @end menu | 1009 | @end menu |
| 1010 | 1010 | ||
| 1011 | @node Replacing Match | ||
| 1012 | @subsection Replacing the Text That Matched | ||
| 1013 | |||
| 1014 | This function replaces the text matched by the last search with | ||
| 1015 | @var{replacement}. | ||
| 1016 | |||
| 1017 | @cindex case in replacements | ||
| 1018 | @defun replace-match replacement &optional fixedcase literal string subexp | ||
| 1019 | This function replaces the text in the buffer (or in @var{string}) that | ||
| 1020 | was matched by the last search. It replaces that text with | ||
| 1021 | @var{replacement}. | ||
| 1022 | |||
| 1023 | If you did the last search in a buffer, you should specify @code{nil} | ||
| 1024 | for @var{string}. Then @code{replace-match} does the replacement by | ||
| 1025 | editing the buffer; it leaves point at the end of the replacement text, | ||
| 1026 | and returns @code{t}. | ||
| 1027 | |||
| 1028 | If you did the search in a string, pass the same string as @var{string}. | ||
| 1029 | Then @code{replace-match} does the replacement by constructing and | ||
| 1030 | returning a new string. | ||
| 1031 | |||
| 1032 | If @var{fixedcase} is non-@code{nil}, then the case of the replacement | ||
| 1033 | text is not changed; otherwise, the replacement text is converted to a | ||
| 1034 | different case depending upon the capitalization of the text to be | ||
| 1035 | replaced. If the original text is all upper case, the replacement text | ||
| 1036 | is converted to upper case. If the first word of the original text is | ||
| 1037 | capitalized, then the first word of the replacement text is capitalized. | ||
| 1038 | If the original text contains just one word, and that word is a capital | ||
| 1039 | letter, @code{replace-match} considers this a capitalized first word | ||
| 1040 | rather than all upper case. | ||
| 1041 | |||
| 1042 | If @code{case-replace} is @code{nil}, then case conversion is not done, | ||
| 1043 | regardless of the value of @var{fixed-case}. @xref{Searching and Case}. | ||
| 1044 | |||
| 1045 | If @var{literal} is non-@code{nil}, then @var{replacement} is inserted | ||
| 1046 | exactly as it is, the only alterations being case changes as needed. | ||
| 1047 | If it is @code{nil} (the default), then the character @samp{\} is treated | ||
| 1048 | specially. If a @samp{\} appears in @var{replacement}, then it must be | ||
| 1049 | part of one of the following sequences: | ||
| 1050 | |||
| 1051 | @table @asis | ||
| 1052 | @item @samp{\&} | ||
| 1053 | @cindex @samp{&} in replacement | ||
| 1054 | @samp{\&} stands for the entire text being replaced. | ||
| 1055 | |||
| 1056 | @item @samp{\@var{n}} | ||
| 1057 | @cindex @samp{\@var{n}} in replacement | ||
| 1058 | @samp{\@var{n}}, where @var{n} is a digit, stands for the text that | ||
| 1059 | matched the @var{n}th subexpression in the original regexp. | ||
| 1060 | Subexpressions are those expressions grouped inside @samp{\(@dots{}\)}. | ||
| 1061 | |||
| 1062 | @item @samp{\\} | ||
| 1063 | @cindex @samp{\} in replacement | ||
| 1064 | @samp{\\} stands for a single @samp{\} in the replacement text. | ||
| 1065 | @end table | ||
| 1066 | |||
| 1067 | If @var{subexp} is non-@code{nil}, that says to replace just | ||
| 1068 | subexpression number @var{subexp} of the regexp that was matched, not | ||
| 1069 | the entire match. For example, after matching @samp{foo \(ba*r\)}, | ||
| 1070 | calling @code{replace-match} with 1 as @var{subexp} means to replace | ||
| 1071 | just the text that matched @samp{\(ba*r\)}. | ||
| 1072 | @end defun | ||
| 1073 | |||
| 1011 | @node Simple Match Data | 1074 | @node Simple Match Data |
| 1012 | @subsection Simple Match Data Access | 1075 | @subsection Simple Match Data Access |
| 1013 | 1076 | ||
| @@ -1038,7 +1101,7 @@ range, or if that subexpression didn't match anything, the value is | |||
| 1038 | 1101 | ||
| 1039 | If the last such operation was done against a string with | 1102 | If the last such operation was done against a string with |
| 1040 | @code{string-match}, then you should pass the same string as the | 1103 | @code{string-match}, then you should pass the same string as the |
| 1041 | argument @var{in-string}. Otherwise, after a buffer search or match, | 1104 | argument @var{in-string}. After a buffer search or match, |
| 1042 | you should omit @var{in-string} or pass @code{nil} for it; but you | 1105 | you should omit @var{in-string} or pass @code{nil} for it; but you |
| 1043 | should make sure that the current buffer when you call | 1106 | should make sure that the current buffer when you call |
| 1044 | @code{match-string} is the one in which you did the searching or | 1107 | @code{match-string} is the one in which you did the searching or |
| @@ -1056,7 +1119,7 @@ last regular expression searched for, or a subexpression of it. | |||
| 1056 | 1119 | ||
| 1057 | If @var{count} is zero, then the value is the position of the start of | 1120 | If @var{count} is zero, then the value is the position of the start of |
| 1058 | the entire match. Otherwise, @var{count} specifies a subexpression in | 1121 | the entire match. Otherwise, @var{count} specifies a subexpression in |
| 1059 | the regular expresion, and the value of the function is the starting | 1122 | the regular expression, and the value of the function is the starting |
| 1060 | position of the match for that subexpression. | 1123 | position of the match for that subexpression. |
| 1061 | 1124 | ||
| 1062 | The value is @code{nil} for a subexpression inside a @samp{\|} | 1125 | The value is @code{nil} for a subexpression inside a @samp{\|} |
| @@ -1136,69 +1199,6 @@ I read "The cat @point{}in the hat comes back" twice. | |||
| 1136 | (In this case, the index returned is a buffer position; the first | 1199 | (In this case, the index returned is a buffer position; the first |
| 1137 | character of the buffer counts as 1.) | 1200 | character of the buffer counts as 1.) |
| 1138 | 1201 | ||
| 1139 | @node Replacing Match | ||
| 1140 | @subsection Replacing the Text That Matched | ||
| 1141 | |||
| 1142 | This function replaces the text matched by the last search with | ||
| 1143 | @var{replacement}. | ||
| 1144 | |||
| 1145 | @cindex case in replacements | ||
| 1146 | @defun replace-match replacement &optional fixedcase literal string subexp | ||
| 1147 | This function replaces the text in the buffer (or in @var{string}) that | ||
| 1148 | was matched by the last search. It replaces that text with | ||
| 1149 | @var{replacement}. | ||
| 1150 | |||
| 1151 | If you did the last search in a buffer, you should specify @code{nil} | ||
| 1152 | for @var{string}. Then @code{replace-match} does the replacement by | ||
| 1153 | editing the buffer; it leaves point at the end of the replacement text, | ||
| 1154 | and returns @code{t}. | ||
| 1155 | |||
| 1156 | If you did the search in a string, pass the same string as @var{string}. | ||
| 1157 | Then @code{replace-match} does the replacement by constructing and | ||
| 1158 | returning a new string. | ||
| 1159 | |||
| 1160 | If @var{fixedcase} is non-@code{nil}, then the case of the replacement | ||
| 1161 | text is not changed; otherwise, the replacement text is converted to a | ||
| 1162 | different case depending upon the capitalization of the text to be | ||
| 1163 | replaced. If the original text is all upper case, the replacement text | ||
| 1164 | is converted to upper case. If the first word of the original text is | ||
| 1165 | capitalized, then the first word of the replacement text is capitalized. | ||
| 1166 | If the original text contains just one word, and that word is a capital | ||
| 1167 | letter, @code{replace-match} considers this a capitalized first word | ||
| 1168 | rather than all upper case. | ||
| 1169 | |||
| 1170 | If @code{case-replace} is @code{nil}, then case conversion is not done, | ||
| 1171 | regardless of the value of @var{fixed-case}. @xref{Searching and Case}. | ||
| 1172 | |||
| 1173 | If @var{literal} is non-@code{nil}, then @var{replacement} is inserted | ||
| 1174 | exactly as it is, the only alterations being case changes as needed. | ||
| 1175 | If it is @code{nil} (the default), then the character @samp{\} is treated | ||
| 1176 | specially. If a @samp{\} appears in @var{replacement}, then it must be | ||
| 1177 | part of one of the following sequences: | ||
| 1178 | |||
| 1179 | @table @asis | ||
| 1180 | @item @samp{\&} | ||
| 1181 | @cindex @samp{&} in replacement | ||
| 1182 | @samp{\&} stands for the entire text being replaced. | ||
| 1183 | |||
| 1184 | @item @samp{\@var{n}} | ||
| 1185 | @cindex @samp{\@var{n}} in replacement | ||
| 1186 | @samp{\@var{n}}, where @var{n} is a digit, stands for the text that | ||
| 1187 | matched the @var{n}th subexpression in the original regexp. | ||
| 1188 | Subexpressions are those expressions grouped inside @samp{\(@dots{}\)}. | ||
| 1189 | |||
| 1190 | @item @samp{\\} | ||
| 1191 | @cindex @samp{\} in replacement | ||
| 1192 | @samp{\\} stands for a single @samp{\} in the replacement text. | ||
| 1193 | @end table | ||
| 1194 | |||
| 1195 | If @var{subexp} is non-@code{nil}, that says to replace just | ||
| 1196 | subexpression number @var{subexp} of the regexp that was matched, not | ||
| 1197 | the entire match. For example, after matching @samp{foo \(ba*r\)}, | ||
| 1198 | calling @code{replace-match} with 1 as @var{subexp} means to replace | ||
| 1199 | just the text that matched @samp{\(ba*r\)}. | ||
| 1200 | @end defun | ||
| 1201 | |||
| 1202 | @node Entire Match Data | 1202 | @node Entire Match Data |
| 1203 | @subsection Accessing the Entire Match Data | 1203 | @subsection Accessing the Entire Match Data |
| 1204 | 1204 | ||
| @@ -1230,9 +1230,7 @@ corresponds to @code{(match-end @var{n})}. | |||
| 1230 | 1230 | ||
| 1231 | All the elements are markers or @code{nil} if matching was done on a | 1231 | All the elements are markers or @code{nil} if matching was done on a |
| 1232 | buffer, and all are integers or @code{nil} if matching was done on a | 1232 | buffer, and all are integers or @code{nil} if matching was done on a |
| 1233 | string with @code{string-match}. (In Emacs 18 and earlier versions, | 1233 | string with @code{string-match}. |
| 1234 | markers were used even for matching on a string, except in the case | ||
| 1235 | of the integer 0.) | ||
| 1236 | 1234 | ||
| 1237 | As always, there must be no possibility of intervening searches between | 1235 | As always, there must be no possibility of intervening searches between |
| 1238 | the call to a search function and the call to @code{match-data} that is | 1236 | the call to a search function and the call to @code{match-data} that is |
| @@ -1258,7 +1256,7 @@ If @var{match-list} refers to a buffer that doesn't exist, you don't get | |||
| 1258 | an error; that sets the match data in a meaningless but harmless way. | 1256 | an error; that sets the match data in a meaningless but harmless way. |
| 1259 | 1257 | ||
| 1260 | @findex store-match-data | 1258 | @findex store-match-data |
| 1261 | @code{store-match-data} is an alias for @code{set-match-data}. | 1259 | @code{store-match-data} is a semi-obsolete alias for @code{set-match-data}. |
| 1262 | @end defun | 1260 | @end defun |
| 1263 | 1261 | ||
| 1264 | @node Saving Match Data | 1262 | @node Saving Match Data |
| @@ -1287,9 +1285,9 @@ This special form executes @var{body}, saving and restoring the match | |||
| 1287 | data around it. | 1285 | data around it. |
| 1288 | @end defmac | 1286 | @end defmac |
| 1289 | 1287 | ||
| 1290 | You can use @code{set-match-data} together with @code{match-data} to | 1288 | You could use @code{set-match-data} together with @code{match-data} to |
| 1291 | imitate the effect of the special form @code{save-match-data}. This is | 1289 | imitate the effect of the special form @code{save-match-data}. Here is |
| 1292 | useful for writing code that can run in Emacs 18. Here is how: | 1290 | how: |
| 1293 | 1291 | ||
| 1294 | @example | 1292 | @example |
| 1295 | @group | 1293 | @group |
| @@ -1384,9 +1382,10 @@ same as @code{(default-value 'case-fold-search)}. | |||
| 1384 | used for certain purposes in editing: | 1382 | used for certain purposes in editing: |
| 1385 | 1383 | ||
| 1386 | @defvar page-delimiter | 1384 | @defvar page-delimiter |
| 1387 | This is the regexp describing line-beginnings that separate pages. The | 1385 | This is the regular expression describing line-beginnings that separate |
| 1388 | default value is @code{"^\014"} (i.e., @code{"^^L"} or @code{"^\C-l"}); | 1386 | pages. The default value is @code{"^\014"} (i.e., @code{"^^L"} or |
| 1389 | this matches a line that starts with a formfeed character. | 1387 | @code{"^\C-l"}); this matches a line that starts with a formfeed |
| 1388 | character. | ||
| 1390 | @end defvar | 1389 | @end defvar |
| 1391 | 1390 | ||
| 1392 | The following two regular expressions should @emph{not} assume the | 1391 | The following two regular expressions should @emph{not} assume the |
diff --git a/lispref/sequences.texi b/lispref/sequences.texi index 3227eb35ae9..8f19d6f9a1b 100644 --- a/lispref/sequences.texi +++ b/lispref/sequences.texi | |||
| @@ -7,16 +7,15 @@ | |||
| 7 | @chapter Sequences, Arrays, and Vectors | 7 | @chapter Sequences, Arrays, and Vectors |
| 8 | @cindex sequence | 8 | @cindex sequence |
| 9 | 9 | ||
| 10 | Recall that the @dfn{sequence} type is the union of three other Lisp | 10 | Recall that the @dfn{sequence} type is the union of two other Lisp |
| 11 | types: lists, vectors, and strings. In other words, any list is a | 11 | types: lists and arrays. In other words, any list is a sequence, and |
| 12 | sequence, any vector is a sequence, and any string is a sequence. The | 12 | any array is a sequence. The common property that all sequences have is |
| 13 | common property that all sequences have is that each is an ordered | 13 | that each is an ordered collection of elements. |
| 14 | collection of elements. | ||
| 15 | 14 | ||
| 16 | An @dfn{array} is a single primitive object that has a slot for each | 15 | An @dfn{array} is a single primitive object that has a slot for each |
| 17 | elements. All the elements are accessible in constant time, but the | 16 | of its elements. All the elements are accessible in constant time, but |
| 18 | length of an existing array cannot be changed. Strings and vectors are | 17 | the length of an existing array cannot be changed. Strings, vectors, |
| 19 | the two types of arrays. | 18 | char-tables and bool-vectors are the four types of arrays. |
| 20 | 19 | ||
| 21 | A list is a sequence of elements, but it is not a single primitive | 20 | A list is a sequence of elements, but it is not a single primitive |
| 22 | object; it is made of cons cells, one cell per element. Finding the | 21 | object; it is made of cons cells, one cell per element. Finding the |
| @@ -28,18 +27,22 @@ But it is possible to add elements to the list, or remove elements. | |||
| 28 | 27 | ||
| 29 | @example | 28 | @example |
| 30 | @group | 29 | @group |
| 31 | ___________________________________ | 30 | _____________________________________________ |
| 32 | | | | 31 | | | |
| 33 | | Sequence | | 32 | | Sequence | |
| 34 | | ______ ______________________ | | 33 | | ______ ________________________________ | |
| 35 | | | | | | | | 34 | | | | | | | |
| 36 | | | List | | Array | | | 35 | | | List | | Array | | |
| 37 | | | | | ________ _______ | | | 36 | | | | | ________ ________ | | |
| 38 | | |______| | | | | | | | | 37 | | |______| | | | | | | | |
| 39 | | | | Vector | | String| | | | 38 | | | | Vector | | String | | | |
| 40 | | | |________| |_______| | | | 39 | | | |________| |________| | | |
| 41 | | |______________________| | | 40 | | | ____________ _____________ | | |
| 42 | |___________________________________| | 41 | | | | | | | | | |
| 42 | | | | Char-table | | Bool-vector | | | | ||
| 43 | | | |____________| |_____________| | | | ||
| 44 | | |________________________________| | | ||
| 45 | |_____________________________________________| | ||
| 43 | @end group | 46 | @end group |
| 44 | @end example | 47 | @end example |
| 45 | 48 | ||
| @@ -59,16 +62,88 @@ elements of strings are all characters. | |||
| 59 | @node Sequence Functions | 62 | @node Sequence Functions |
| 60 | @section Sequences | 63 | @section Sequences |
| 61 | 64 | ||
| 62 | In Emacs Lisp, a @dfn{sequence} is either a list, a vector or a | 65 | In Emacs Lisp, a @dfn{sequence} is either a list or an array. The |
| 63 | string. The common property that all sequences have is that each is an | 66 | common property of all sequences is that they are ordered collections of |
| 64 | ordered collection of elements. This section describes functions that | 67 | elements. This section describes functions that accept any kind of |
| 65 | accept any kind of sequence. | 68 | sequence. |
| 66 | 69 | ||
| 67 | @defun sequencep object | 70 | @defun sequencep object |
| 68 | Returns @code{t} if @var{object} is a list, vector, or | 71 | Returns @code{t} if @var{object} is a list, vector, or |
| 69 | string, @code{nil} otherwise. | 72 | string, @code{nil} otherwise. |
| 70 | @end defun | 73 | @end defun |
| 71 | 74 | ||
| 75 | @defun length sequence | ||
| 76 | @cindex string length | ||
| 77 | @cindex list length | ||
| 78 | @cindex vector length | ||
| 79 | @cindex sequence length | ||
| 80 | This function returns the number of elements in @var{sequence}. If | ||
| 81 | @var{sequence} is a cons cell that is not a list (because the final | ||
| 82 | @sc{cdr} is not @code{nil}), a @code{wrong-type-argument} error is | ||
| 83 | signaled. | ||
| 84 | |||
| 85 | @xref{List Elements}, for the related function @code{safe-list}. | ||
| 86 | |||
| 87 | @example | ||
| 88 | @group | ||
| 89 | (length '(1 2 3)) | ||
| 90 | @result{} 3 | ||
| 91 | @end group | ||
| 92 | @group | ||
| 93 | (length ()) | ||
| 94 | @result{} 0 | ||
| 95 | @end group | ||
| 96 | @group | ||
| 97 | (length "foobar") | ||
| 98 | @result{} 6 | ||
| 99 | @end group | ||
| 100 | @group | ||
| 101 | (length [1 2 3]) | ||
| 102 | @result{} 3 | ||
| 103 | @end group | ||
| 104 | @group | ||
| 105 | (length (make-bool-vector 5 nil)) | ||
| 106 | @result{} 5 | ||
| 107 | @end group | ||
| 108 | @end example | ||
| 109 | @end defun | ||
| 110 | |||
| 111 | @defun elt sequence index | ||
| 112 | @cindex elements of sequences | ||
| 113 | This function returns the element of @var{sequence} indexed by | ||
| 114 | @var{index}. Legitimate values of @var{index} are integers ranging from | ||
| 115 | 0 up to one less than the length of @var{sequence}. If @var{sequence} | ||
| 116 | is a list, then out-of-range values of @var{index} return @code{nil}; | ||
| 117 | otherwise, they trigger an @code{args-out-of-range} error. | ||
| 118 | |||
| 119 | @example | ||
| 120 | @group | ||
| 121 | (elt [1 2 3 4] 2) | ||
| 122 | @result{} 3 | ||
| 123 | @end group | ||
| 124 | @group | ||
| 125 | (elt '(1 2 3 4) 2) | ||
| 126 | @result{} 3 | ||
| 127 | @end group | ||
| 128 | @group | ||
| 129 | ;; @r{We use @code{string} to show clearly which character @code{elt} returns.} | ||
| 130 | (string (elt "1234" 2)) | ||
| 131 | @result{} "3" | ||
| 132 | @end group | ||
| 133 | @group | ||
| 134 | (elt [1 2 3 4] 4) | ||
| 135 | @error{}Args out of range: [1 2 3 4], 4 | ||
| 136 | @end group | ||
| 137 | @group | ||
| 138 | (elt [1 2 3 4] -1) | ||
| 139 | @error{}Args out of range: [1 2 3 4], -1 | ||
| 140 | @end group | ||
| 141 | @end example | ||
| 142 | |||
| 143 | This function generalizes @code{aref} (@pxref{Array Functions}) and | ||
| 144 | @code{nth} (@pxref{List Elements}). | ||
| 145 | @end defun | ||
| 146 | |||
| 72 | @defun copy-sequence sequence | 147 | @defun copy-sequence sequence |
| 73 | @cindex copying sequences | 148 | @cindex copying sequences |
| 74 | Returns a copy of @var{sequence}. The copy is the same type of object | 149 | Returns a copy of @var{sequence}. The copy is the same type of object |
| @@ -133,72 +208,6 @@ y @result{} [foo (69 2)] | |||
| 133 | @end example | 208 | @end example |
| 134 | @end defun | 209 | @end defun |
| 135 | 210 | ||
| 136 | @defun length sequence | ||
| 137 | @cindex string length | ||
| 138 | @cindex list length | ||
| 139 | @cindex vector length | ||
| 140 | @cindex sequence length | ||
| 141 | Returns the number of elements in @var{sequence}. If @var{sequence} is | ||
| 142 | a cons cell that is not a list (because the final @sc{cdr} is not | ||
| 143 | @code{nil}), a @code{wrong-type-argument} error is signaled. | ||
| 144 | |||
| 145 | @xref{List Elements}, for the related function @code{safe-list}. | ||
| 146 | |||
| 147 | @example | ||
| 148 | @group | ||
| 149 | (length '(1 2 3)) | ||
| 150 | @result{} 3 | ||
| 151 | @end group | ||
| 152 | @group | ||
| 153 | (length ()) | ||
| 154 | @result{} 0 | ||
| 155 | @end group | ||
| 156 | @group | ||
| 157 | (length "foobar") | ||
| 158 | @result{} 6 | ||
| 159 | @end group | ||
| 160 | @group | ||
| 161 | (length [1 2 3]) | ||
| 162 | @result{} 3 | ||
| 163 | @end group | ||
| 164 | @end example | ||
| 165 | @end defun | ||
| 166 | |||
| 167 | @defun elt sequence index | ||
| 168 | @cindex elements of sequences | ||
| 169 | This function returns the element of @var{sequence} indexed by | ||
| 170 | @var{index}. Legitimate values of @var{index} are integers ranging from | ||
| 171 | 0 up to one less than the length of @var{sequence}. If @var{sequence} | ||
| 172 | is a list, then out-of-range values of @var{index} return @code{nil}; | ||
| 173 | otherwise, they trigger an @code{args-out-of-range} error. | ||
| 174 | |||
| 175 | @example | ||
| 176 | @group | ||
| 177 | (elt [1 2 3 4] 2) | ||
| 178 | @result{} 3 | ||
| 179 | @end group | ||
| 180 | @group | ||
| 181 | (elt '(1 2 3 4) 2) | ||
| 182 | @result{} 3 | ||
| 183 | @end group | ||
| 184 | @group | ||
| 185 | (char-to-string (elt "1234" 2)) | ||
| 186 | @result{} "3" | ||
| 187 | @end group | ||
| 188 | @group | ||
| 189 | (elt [1 2 3 4] 4) | ||
| 190 | @error{}Args out of range: [1 2 3 4], 4 | ||
| 191 | @end group | ||
| 192 | @group | ||
| 193 | (elt [1 2 3 4] -1) | ||
| 194 | @error{}Args out of range: [1 2 3 4], -1 | ||
| 195 | @end group | ||
| 196 | @end example | ||
| 197 | |||
| 198 | This function generalizes @code{aref} (@pxref{Array Functions}) and | ||
| 199 | @code{nth} (@pxref{List Elements}). | ||
| 200 | @end defun | ||
| 201 | |||
| 202 | @node Arrays | 211 | @node Arrays |
| 203 | @section Arrays | 212 | @section Arrays |
| 204 | @cindex array | 213 | @cindex array |
| @@ -209,20 +218,14 @@ be accessed in constant time. In contrast, an element of a list | |||
| 209 | requires access time that is proportional to the position of the element | 218 | requires access time that is proportional to the position of the element |
| 210 | in the list. | 219 | in the list. |
| 211 | 220 | ||
| 212 | When you create an array, you must specify how many elements it has. | 221 | Emacs defines four types of array, both of which are one-dimensional: |
| 213 | The amount of space allocated depends on the number of elements. | 222 | @dfn{strings}, @dfn{vectors}, @dfn{bool-vectors} and @dfn{char-tables}. |
| 214 | Therefore, it is impossible to change the size of an array once it is | 223 | A vector is a general array; its elements can be any Lisp objects. A |
| 215 | created; you cannot add or remove elements. However, you can replace an | 224 | string is a specialized array; its elements must be characters (i.e., |
| 216 | element with a different value. | 225 | integers between 0 and 255). Each type of array has its own read |
| 217 | 226 | syntax. @xref{String Type}, and @ref{Vector Type}. | |
| 218 | Emacs defines two types of array, both of which are one-dimensional: | ||
| 219 | @dfn{strings} and @dfn{vectors}. A vector is a general array; its | ||
| 220 | elements can be any Lisp objects. A string is a specialized array; its | ||
| 221 | elements must be characters (i.e., integers between 0 and 255). Each | ||
| 222 | type of array has its own read syntax. @xref{String Type}, and | ||
| 223 | @ref{Vector Type}. | ||
| 224 | 227 | ||
| 225 | Both kinds of array share these characteristics: | 228 | All four kinds of array share these characteristics: |
| 226 | 229 | ||
| 227 | @itemize @bullet | 230 | @itemize @bullet |
| 228 | @item | 231 | @item |
| @@ -231,13 +234,25 @@ index 1, and so on. This is called @dfn{zero-origin} indexing. For | |||
| 231 | example, an array of four elements has indices 0, 1, 2, @w{and 3}. | 234 | example, an array of four elements has indices 0, 1, 2, @w{and 3}. |
| 232 | 235 | ||
| 233 | @item | 236 | @item |
| 237 | The length of the array is fixed once you create it; you cannot | ||
| 238 | change the length of an existing array. | ||
| 239 | |||
| 240 | @item | ||
| 241 | The array is a constant, for evaluation---in other words, it evaluates | ||
| 242 | to itself. | ||
| 243 | |||
| 244 | @item | ||
| 234 | The elements of an array may be referenced or changed with the functions | 245 | The elements of an array may be referenced or changed with the functions |
| 235 | @code{aref} and @code{aset}, respectively (@pxref{Array Functions}). | 246 | @code{aref} and @code{aset}, respectively (@pxref{Array Functions}). |
| 236 | @end itemize | 247 | @end itemize |
| 237 | 248 | ||
| 238 | In principle, if you wish to have an array of text characters, you | 249 | When you create an array, other than a char-table, you must specify |
| 239 | could use either a string or a vector. In practice, we always choose | 250 | its length. You cannot specify the length of a char-table, because that |
| 240 | strings for such applications, for four reasons: | 251 | is determined by the range of character codes. |
| 252 | |||
| 253 | In principle, if you want an array of text characters, you could use | ||
| 254 | either a string or a vector. In practice, we always choose strings for | ||
| 255 | such applications, for four reasons: | ||
| 241 | 256 | ||
| 242 | @itemize @bullet | 257 | @itemize @bullet |
| 243 | @item | 258 | @item |
| @@ -274,9 +289,11 @@ vector, a string, a bool-vector or a char-table). | |||
| 274 | @example | 289 | @example |
| 275 | @group | 290 | @group |
| 276 | (arrayp [a]) | 291 | (arrayp [a]) |
| 277 | @result{} t | 292 | @result{} t |
| 278 | (arrayp "asdf") | 293 | (arrayp "asdf") |
| 279 | @result{} t | 294 | @result{} t |
| 295 | (arrayp (syntax-table)) ;; @r{A char-table.} | ||
| 296 | @result{} t | ||
| 280 | @end group | 297 | @end group |
| 281 | @end example | 298 | @end example |
| 282 | @end defun | 299 | @end defun |
| @@ -292,10 +309,7 @@ first element is at index zero. | |||
| 292 | @result{} [2 3 5 7 11 13] | 309 | @result{} [2 3 5 7 11 13] |
| 293 | (aref primes 4) | 310 | (aref primes 4) |
| 294 | @result{} 11 | 311 | @result{} 11 |
| 295 | (elt primes 4) | ||
| 296 | @result{} 11 | ||
| 297 | @end group | 312 | @end group |
| 298 | |||
| 299 | @group | 313 | @group |
| 300 | (aref "abcdefg" 1) | 314 | (aref "abcdefg" 1) |
| 301 | @result{} 98 ; @r{@samp{b} is @sc{ASCII} code 98.} | 315 | @result{} 98 ; @r{@samp{b} is @sc{ASCII} code 98.} |
| @@ -371,11 +385,11 @@ are often useful for objects known to be arrays. @xref{Sequence Functions}. | |||
| 371 | 385 | ||
| 372 | Arrays in Lisp, like arrays in most languages, are blocks of memory | 386 | Arrays in Lisp, like arrays in most languages, are blocks of memory |
| 373 | whose elements can be accessed in constant time. A @dfn{vector} is a | 387 | whose elements can be accessed in constant time. A @dfn{vector} is a |
| 374 | general-purpose array; its elements can be any Lisp objects. (By | 388 | general-purpose array of specified length; its elements can be any Lisp |
| 375 | contrast, a string can hold only characters as elements.) Vectors in | 389 | objects. (By contrast, a string can hold only characters as elements.) |
| 376 | Emacs are used for obarrays (vectors of symbols), and as part of keymaps | 390 | Vectors in Emacs are used for obarrays (vectors of symbols), and as part |
| 377 | (vectors of commands). They are also used internally as part of the | 391 | of keymaps (vectors of commands). They are also used internally as part |
| 378 | representation of a byte-compiled function; if you print such a | 392 | of the representation of a byte-compiled function; if you print such a |
| 379 | function, you will see a vector in it. | 393 | function, you will see a vector in it. |
| 380 | 394 | ||
| 381 | In Emacs Lisp, the indices of the elements of a vector start from zero | 395 | In Emacs Lisp, the indices of the elements of a vector start from zero |
| @@ -405,7 +419,7 @@ not evaluate or even examine the elements of the vector. | |||
| 405 | @end example | 419 | @end example |
| 406 | 420 | ||
| 407 | @node Vector Functions | 421 | @node Vector Functions |
| 408 | @section Functions That Operate on Vectors | 422 | @section Functions for Vectors |
| 409 | 423 | ||
| 410 | Here are some functions that relate to vectors: | 424 | Here are some functions that relate to vectors: |
| 411 | 425 | ||
| @@ -473,6 +487,10 @@ existing vector. | |||
| 473 | @end group | 487 | @end group |
| 474 | @end example | 488 | @end example |
| 475 | 489 | ||
| 490 | The @code{vconcat} function also allows byte-code function objects as | ||
| 491 | arguments. This is a special feature to make it easy to access the entire | ||
| 492 | contents of a byte-code function object. @xref{Byte-Code Objects}. | ||
| 493 | |||
| 476 | The @code{vconcat} function also allows integers as arguments. It | 494 | The @code{vconcat} function also allows integers as arguments. It |
| 477 | converts them to strings of digits, making up the decimal print | 495 | converts them to strings of digits, making up the decimal print |
| 478 | representation of the integer, and then uses the strings instead of the | 496 | representation of the integer, and then uses the strings instead of the |
| @@ -505,8 +523,9 @@ list with the same elements (@pxref{Building Lists}): | |||
| 505 | 523 | ||
| 506 | A char-table is much like a vector, except that it is indexed by | 524 | A char-table is much like a vector, except that it is indexed by |
| 507 | character codes. Any valid character code, without modifiers, can be | 525 | character codes. Any valid character code, without modifiers, can be |
| 508 | used as an index in a char-table. You can access a char-table with | 526 | used as an index in a char-table. You can access a char-table's |
| 509 | @code{aref} and @code{aset}, just like a vector. | 527 | elements with @code{aref} and @code{aset}, as with any array. |
| 528 | Char-tables are constants when evaluated. | ||
| 510 | 529 | ||
| 511 | @cindex extra slots of char-table | 530 | @cindex extra slots of char-table |
| 512 | @cindex subtype of char-table | 531 | @cindex subtype of char-table |
| @@ -534,11 +553,14 @@ Return a newly created char-table, with subtype @var{subtype}. Each | |||
| 534 | element is initialized to @var{init}, which defaults to @code{nil}. You | 553 | element is initialized to @var{init}, which defaults to @code{nil}. You |
| 535 | cannot alter the subtype of a char-table after the char-table is | 554 | cannot alter the subtype of a char-table after the char-table is |
| 536 | created. | 555 | created. |
| 556 | |||
| 557 | There is no argument to specify the length of the char-table, because | ||
| 558 | all char-tables have room for any valid character code as an index. | ||
| 537 | @end defun | 559 | @end defun |
| 538 | 560 | ||
| 539 | @tindex char-table-p | 561 | @tindex char-table-p |
| 540 | @defun char-table-p object | 562 | @defun char-table-p object |
| 541 | This function returns @code{t} if @code{object} is a char-table, | 563 | This function returns @code{t} if @var{object} is a char-table, |
| 542 | otherwise @code{nil}. | 564 | otherwise @code{nil}. |
| 543 | @end defun | 565 | @end defun |
| 544 | 566 | ||
| @@ -628,9 +650,9 @@ This function calls @var{function} for each element of @var{char-table}. | |||
| 628 | @var{function} is called with two arguments, a key and a value. The key | 650 | @var{function} is called with two arguments, a key and a value. The key |
| 629 | is a possible @var{range} argument for @code{char-table-range}, and the | 651 | is a possible @var{range} argument for @code{char-table-range}, and the |
| 630 | value is @code{(char-table-range @var{char-table} @var{key})}. Invalid | 652 | value is @code{(char-table-range @var{char-table} @var{key})}. Invalid |
| 631 | character codes are never used as the key. | 653 | character codes are never used as @var{key}. |
| 632 | 654 | ||
| 633 | Overall, the keys-value pairs passed to @var{function} describe all the | 655 | Overall, the key-value pairs passed to @var{function} describe all the |
| 634 | values stored in @var{char-table}. | 656 | values stored in @var{char-table}. |
| 635 | @end defun | 657 | @end defun |
| 636 | 658 | ||
| @@ -640,8 +662,10 @@ values stored in @var{char-table}. | |||
| 640 | 662 | ||
| 641 | A bool-vector is much like a vector, except that it stores only the | 663 | A bool-vector is much like a vector, except that it stores only the |
| 642 | values @code{t} and @code{nil}. If you try to store any non-@code{nil} | 664 | values @code{t} and @code{nil}. If you try to store any non-@code{nil} |
| 643 | value into an element of the bool-vector, that actually stores @code{t} | 665 | value into an element of the bool-vector, the effect is to store |
| 644 | there. | 666 | @code{t} there. As with all arrays, bool-vector indices start from 0, |
| 667 | and the length cannot be changed once the bool-vector is created. | ||
| 668 | Bool-vectors are constants when evaluated. | ||
| 645 | 669 | ||
| 646 | There are two special functions for working with bool-vectors; aside | 670 | There are two special functions for working with bool-vectors; aside |
| 647 | from that, you manipulate them with same functions used for other kinds | 671 | from that, you manipulate them with same functions used for other kinds |
diff --git a/lispref/streams.texi b/lispref/streams.texi index 4e19308fbf6..945e550fc0a 100644 --- a/lispref/streams.texi +++ b/lispref/streams.texi | |||
| @@ -103,17 +103,21 @@ character in the string and using as many characters as required. | |||
| 103 | 103 | ||
| 104 | @item @var{function} | 104 | @item @var{function} |
| 105 | @cindex function input stream | 105 | @cindex function input stream |
| 106 | The input characters are generated by @var{function}, one character per | 106 | The input characters are generated by @var{function}, which must support |
| 107 | call. Normally @var{function} is called with no arguments, and should | 107 | two kinds of calls: |
| 108 | return a character. | 108 | |
| 109 | 109 | @itemize @bullet | |
| 110 | @cindex unreading | 110 | @item |
| 111 | Occasionally @var{function} is called with one argument (always a | 111 | When it is called with no arguments, it should return the next character. |
| 112 | character). When that happens, @var{function} should save the argument | 112 | |
| 113 | and arrange to return it on the next call. This is called | 113 | @item |
| 114 | @dfn{unreading} the character; it happens when the Lisp reader reads one | 114 | When it is called with one argument (always a character), @var{function} |
| 115 | character too many and wants to ``put it back where it came from''. | 115 | should save the argument and arrange to return it on the next call. |
| 116 | In this case, it makes no difference what value @var{function} returns. | 116 | This is called @dfn{unreading} the character; it happens when the Lisp |
| 117 | reader reads one character too many and wants to ``put it back where it | ||
| 118 | came from''. In this case, it makes no difference what value | ||
| 119 | @var{function} returns. | ||
| 120 | @end itemize | ||
| 117 | 121 | ||
| 118 | @item @code{t} | 122 | @item @code{t} |
| 119 | @cindex @code{t} input stream | 123 | @cindex @code{t} input stream |
| @@ -163,13 +167,6 @@ This is the@point{} contents of foo. | |||
| 163 | Note that the first read skips a space. Reading skips any amount of | 167 | Note that the first read skips a space. Reading skips any amount of |
| 164 | whitespace preceding the significant text. | 168 | whitespace preceding the significant text. |
| 165 | 169 | ||
| 166 | In Emacs 18, reading a symbol discarded the delimiter terminating the | ||
| 167 | symbol. Thus, point would end up at the beginning of @samp{contents} | ||
| 168 | rather than after @samp{the}. The current behavior is superior because | ||
| 169 | it correctly handles input such as @samp{bar(foo)}, where the | ||
| 170 | open-parenthesis that ends one object is needed as the beginning of | ||
| 171 | another object. | ||
| 172 | |||
| 173 | Here is an example of reading from a stream that is a marker, | 170 | Here is an example of reading from a stream that is a marker, |
| 174 | initially positioned at the beginning of the buffer shown. The value | 171 | initially positioned at the beginning of the buffer shown. The value |
| 175 | read is the symbol @code{This}. | 172 | read is the symbol @code{This}. |
| @@ -296,9 +293,9 @@ and whose @sc{cdr} is an integer giving the position of the next | |||
| 296 | remaining character in the string (i.e., the first one not read). | 293 | remaining character in the string (i.e., the first one not read). |
| 297 | 294 | ||
| 298 | If @var{start} is supplied, then reading begins at index @var{start} in | 295 | If @var{start} is supplied, then reading begins at index @var{start} in |
| 299 | the string (where the first character is at index 0). If @var{end} is | 296 | the string (where the first character is at index 0). If you specify |
| 300 | also supplied, then reading stops just before that index, as if the rest | 297 | @var{end}, then reading is forced to stop just before that index, as if |
| 301 | of the string were not there. | 298 | the rest of the string were not there. |
| 302 | 299 | ||
| 303 | For example: | 300 | For example: |
| 304 | 301 | ||
| @@ -381,8 +378,8 @@ definition (if any). | |||
| 381 | @end table | 378 | @end table |
| 382 | 379 | ||
| 383 | Many of the valid output streams are also valid as input streams. The | 380 | Many of the valid output streams are also valid as input streams. The |
| 384 | difference between input and output streams is therefore mostly one of | 381 | difference between input and output streams is therefore more a matter |
| 385 | how you use a Lisp object, not a distinction of types of object. | 382 | of how you use a Lisp object, than of different types of object. |
| 386 | 383 | ||
| 387 | Here is an example of a buffer used as an output stream. Point is | 384 | Here is an example of a buffer used as an output stream. Point is |
| 388 | initially located as shown immediately before the @samp{h} in | 385 | initially located as shown immediately before the @samp{h} in |
| @@ -532,18 +529,18 @@ being taken as delimiters when reading. @xref{Printed Representation}, | |||
| 532 | for full details. You specify quoting or no quoting by the choice of | 529 | for full details. You specify quoting or no quoting by the choice of |
| 533 | printing function. | 530 | printing function. |
| 534 | 531 | ||
| 535 | If the text is to be read back into Lisp, then it is best to print | 532 | If the text is to be read back into Lisp, then you should print with |
| 536 | with quoting characters to avoid ambiguity. Likewise, if the purpose is | 533 | quoting characters to avoid ambiguity. Likewise, if the purpose is to |
| 537 | to describe a Lisp object clearly for a Lisp programmer. However, if | 534 | describe a Lisp object clearly for a Lisp programmer. However, if the |
| 538 | the purpose of the output is to look nice for humans, then it is better | 535 | purpose of the output is to look nice for humans, then it is usually |
| 539 | to print without quoting. | 536 | better to print without quoting. |
| 540 | 537 | ||
| 541 | Printing a self-referent Lisp object requires an infinite amount of | 538 | Printing a self-referent Lisp object in the normal way would require |
| 542 | text. In certain cases, trying to produce this text leads to a stack | 539 | an infinite amount of text, and could even result in stack overflow. |
| 543 | overflow. Emacs detects such recursion and prints @samp{#@var{level}} | 540 | Emacs detects such recursion and prints @samp{#@var{level}} instead of |
| 544 | instead of recursively printing an object already being printed. For | 541 | recursively printing an object already being printed. For example, here |
| 545 | example, here @samp{#0} indicates a recursive reference to the object at | 542 | @samp{#0} indicates a recursive reference to the object at level 0 of |
| 546 | level 0 of the current print operation: | 543 | the current print operation: |
| 547 | 544 | ||
| 548 | @example | 545 | @example |
| 549 | (setq foo (list nil)) | 546 | (setq foo (list nil)) |
| @@ -696,9 +693,9 @@ If this variable is non-@code{nil}, then newline characters in strings | |||
| 696 | are printed as @samp{\n} and formfeeds are printed as @samp{\f}. | 693 | are printed as @samp{\n} and formfeeds are printed as @samp{\f}. |
| 697 | Normally these characters are printed as actual newlines and formfeeds. | 694 | Normally these characters are printed as actual newlines and formfeeds. |
| 698 | 695 | ||
| 699 | This variable affects the print functions @code{prin1} and @code{print}, | 696 | This variable affects the print functions @code{prin1} and @code{print} |
| 700 | as well as everything that uses them. It does not affect @code{princ}. | 697 | that print with quoting. It does not affect @code{princ}. Here is an |
| 701 | Here is an example using @code{prin1}: | 698 | example using @code{prin1}: |
| 702 | 699 | ||
| 703 | @example | 700 | @example |
| 704 | @group | 701 | @group |
diff --git a/lispref/strings.texi b/lispref/strings.texi index b6ffa8ffee4..71300010f37 100644 --- a/lispref/strings.texi +++ b/lispref/strings.texi | |||
| @@ -29,8 +29,8 @@ keyboard character events. | |||
| 29 | * Text Comparison:: Comparing characters or strings. | 29 | * Text Comparison:: Comparing characters or strings. |
| 30 | * String Conversion:: Converting characters or strings and vice versa. | 30 | * String Conversion:: Converting characters or strings and vice versa. |
| 31 | * Formatting Strings:: @code{format}: Emacs's analog of @code{printf}. | 31 | * Formatting Strings:: @code{format}: Emacs's analog of @code{printf}. |
| 32 | * Character Case:: Case conversion functions. | 32 | * Case Conversion:: Case conversion functions. |
| 33 | * Case Table:: Customizing case conversion. | 33 | * Case Tables:: Customizing case conversion. |
| 34 | @end menu | 34 | @end menu |
| 35 | 35 | ||
| 36 | @node String Basics | 36 | @node String Basics |
| @@ -38,19 +38,19 @@ keyboard character events. | |||
| 38 | 38 | ||
| 39 | Strings in Emacs Lisp are arrays that contain an ordered sequence of | 39 | Strings in Emacs Lisp are arrays that contain an ordered sequence of |
| 40 | characters. Characters are represented in Emacs Lisp as integers; | 40 | characters. Characters are represented in Emacs Lisp as integers; |
| 41 | whether an integer was intended as a character or not is determined only | 41 | whether an integer is a character or not is determined only by how it is |
| 42 | by how it is used. Thus, strings really contain integers. | 42 | used. Thus, strings really contain integers. |
| 43 | 43 | ||
| 44 | The length of a string (like any array) is fixed, and cannot be | 44 | The length of a string (like any array) is fixed, and cannot be |
| 45 | altered once the string exists. Strings in Lisp are @emph{not} | 45 | altered once the string exists. Strings in Lisp are @emph{not} |
| 46 | terminated by a distinguished character code. (By contrast, strings in | 46 | terminated by a distinguished character code. (By contrast, strings in |
| 47 | C are terminated by a character with @sc{ASCII} code 0.) | 47 | C are terminated by a character with @sc{ASCII} code 0.) |
| 48 | 48 | ||
| 49 | Since strings are considered arrays, you can operate on them with the | 49 | Since strings are arrays, and therefore sequences as well, you can |
| 50 | general array functions. (@xref{Sequences Arrays Vectors}.) For | 50 | operate on them with the general array and sequence functions. |
| 51 | example, you can access or change individual characters in a string | 51 | (@xref{Sequences Arrays Vectors}.) For example, you can access or |
| 52 | using the functions @code{aref} and @code{aset} (@pxref{Array | 52 | change individual characters in a string using the functions @code{aref} |
| 53 | Functions}). | 53 | and @code{aset} (@pxref{Array Functions}). |
| 54 | 54 | ||
| 55 | There are two text representations for non-@sc{ASCII} characters in | 55 | There are two text representations for non-@sc{ASCII} characters in |
| 56 | Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text | 56 | Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text |
| @@ -62,8 +62,8 @@ representations. | |||
| 62 | 62 | ||
| 63 | Sometimes key sequences are represented as strings. When a string is | 63 | Sometimes key sequences are represented as strings. When a string is |
| 64 | a key sequence, string elements in the range 128 to 255 represent meta | 64 | a key sequence, string elements in the range 128 to 255 represent meta |
| 65 | characters (which are extremely large integers) rather than keyboard | 65 | characters (which are extremely large integers) rather than character |
| 66 | events in the range 128 to 255. | 66 | codes in the range 128 to 255. |
| 67 | 67 | ||
| 68 | Strings cannot hold characters that have the hyper, super or alt | 68 | Strings cannot hold characters that have the hyper, super or alt |
| 69 | modifiers; they can hold @sc{ASCII} control characters, but no other | 69 | modifiers; they can hold @sc{ASCII} control characters, but no other |
| @@ -201,14 +201,19 @@ Functions}). | |||
| 201 | If the characters copied from @var{string} have text properties, the | 201 | If the characters copied from @var{string} have text properties, the |
| 202 | properties are copied into the new string also. @xref{Text Properties}. | 202 | properties are copied into the new string also. @xref{Text Properties}. |
| 203 | 203 | ||
| 204 | @code{substring} also allows vectors for the first argument. | ||
| 205 | For example: | ||
| 206 | |||
| 207 | @example | ||
| 208 | (substring [a b (c) "d"] 1 3) | ||
| 209 | @result{} [b (c)] | ||
| 210 | @end example | ||
| 211 | |||
| 204 | A @code{wrong-type-argument} error is signaled if either @var{start} or | 212 | A @code{wrong-type-argument} error is signaled if either @var{start} or |
| 205 | @var{end} is not an integer or @code{nil}. An @code{args-out-of-range} | 213 | @var{end} is not an integer or @code{nil}. An @code{args-out-of-range} |
| 206 | error is signaled if @var{start} indicates a character following | 214 | error is signaled if @var{start} indicates a character following |
| 207 | @var{end}, or if either integer is out of range for @var{string}. | 215 | @var{end}, or if either integer is out of range for @var{string}. |
| 208 | 216 | ||
| 209 | @code{substring} actually allows vectors as well as strings for | ||
| 210 | the first argument. | ||
| 211 | |||
| 212 | Contrast this function with @code{buffer-substring} (@pxref{Buffer | 217 | Contrast this function with @code{buffer-substring} (@pxref{Buffer |
| 213 | Contents}), which returns a string containing a portion of the text in | 218 | Contents}), which returns a string containing a portion of the text in |
| 214 | the current buffer. The beginning of a string is at index 0, but the | 219 | the current buffer. The beginning of a string is at index 0, but the |
| @@ -313,7 +318,7 @@ Empty matches do count, when not adjacent to another match: | |||
| 313 | @var{idx} @var{char})} stores @var{char} into @var{string} at index | 318 | @var{idx} @var{char})} stores @var{char} into @var{string} at index |
| 314 | @var{idx}. Each character occupies one or more bytes, and if @var{char} | 319 | @var{idx}. Each character occupies one or more bytes, and if @var{char} |
| 315 | needs a different number of bytes from the character already present at | 320 | needs a different number of bytes from the character already present at |
| 316 | that index, @code{aset} gets an error. | 321 | that index, @code{aset} signals an error. |
| 317 | 322 | ||
| 318 | A more powerful function is @code{store-substring}: | 323 | A more powerful function is @code{store-substring}: |
| 319 | 324 | ||
| @@ -325,8 +330,8 @@ may be either a character or a (smaller) string. | |||
| 325 | 330 | ||
| 326 | Since it is impossible to change the length of an existing string, it is | 331 | Since it is impossible to change the length of an existing string, it is |
| 327 | an error if @var{obj} doesn't fit within @var{string}'s actual length, | 332 | an error if @var{obj} doesn't fit within @var{string}'s actual length, |
| 328 | or if it requires a different number of bytes from the characters | 333 | of if any new character requires a different number of bytes from the |
| 329 | currently present at that point in @var{string}. | 334 | character currently present at that point in @var{string}. |
| 330 | @end defun | 335 | @end defun |
| 331 | 336 | ||
| 332 | @need 2000 | 337 | @need 2000 |
| @@ -365,7 +370,7 @@ The function @code{string=} ignores the text properties of the two | |||
| 365 | strings. When @code{equal} (@pxref{Equality Predicates}) compares two | 370 | strings. When @code{equal} (@pxref{Equality Predicates}) compares two |
| 366 | strings, it uses @code{string=}. | 371 | strings, it uses @code{string=}. |
| 367 | 372 | ||
| 368 | If the arguments contain non-@sc{ASCII} characters, and one is unibyte | 373 | If the strings contain non-@sc{ASCII} characters, and one is unibyte |
| 369 | while the other is multibyte, then they cannot be equal. @xref{Text | 374 | while the other is multibyte, then they cannot be equal. @xref{Text |
| 370 | Representations}. | 375 | Representations}. |
| 371 | @end defun | 376 | @end defun |
| @@ -385,11 +390,12 @@ function returns @code{t}. If the lesser character is the one from | |||
| 385 | @var{string2}, then @var{string1} is greater, and this function returns | 390 | @var{string2}, then @var{string1} is greater, and this function returns |
| 386 | @code{nil}. If the two strings match entirely, the value is @code{nil}. | 391 | @code{nil}. If the two strings match entirely, the value is @code{nil}. |
| 387 | 392 | ||
| 388 | Pairs of characters are compared by their @sc{ASCII} codes. Keep in | 393 | Pairs of characters are compared according to their character codes. |
| 389 | mind that lower case letters have higher numeric values in the | 394 | Keep in mind that lower case letters have higher numeric values in the |
| 390 | @sc{ASCII} character set than their upper case counterparts; numbers and | 395 | @sc{ASCII} character set than their upper case counterparts; digits and |
| 391 | many punctuation characters have a lower numeric value than upper case | 396 | many punctuation characters have a lower numeric value than upper case |
| 392 | letters. A unibyte non-@sc{ASCII} character is always less than any | 397 | letters. An @sc{ASCII} character is less than any non-@sc{ASCII} |
| 398 | character; a unibyte non-@sc{ASCII} character is always less than any | ||
| 393 | multibyte non-@sc{ASCII} character (@pxref{Text Representations}). | 399 | multibyte non-@sc{ASCII} character (@pxref{Text Representations}). |
| 394 | 400 | ||
| 395 | @example | 401 | @example |
| @@ -453,23 +459,9 @@ functions are used primarily for making help messages. | |||
| 453 | 459 | ||
| 454 | @defun char-to-string character | 460 | @defun char-to-string character |
| 455 | @cindex character to string | 461 | @cindex character to string |
| 456 | This function returns a new string with a length of one character. | 462 | This function returns a new string containing one character, |
| 457 | The value of @var{character}, modulo 256, is used to initialize the | 463 | @var{character}. This function is semi-obsolete because the function |
| 458 | element of the string. | 464 | @code{string} is more general. @xref{Creating Strings}. |
| 459 | |||
| 460 | This function is similar to @code{make-string} with an integer argument | ||
| 461 | of 1. (@xref{Creating Strings}.) This conversion can also be done with | ||
| 462 | @code{format} using the @samp{%c} format specification. | ||
| 463 | (@xref{Formatting Strings}.) | ||
| 464 | |||
| 465 | @example | ||
| 466 | (char-to-string ?x) | ||
| 467 | @result{} "x" | ||
| 468 | (char-to-string (+ 256 ?x)) | ||
| 469 | @result{} "x" | ||
| 470 | (make-string 1 ?x) | ||
| 471 | @result{} "x" | ||
| 472 | @end example | ||
| 473 | @end defun | 465 | @end defun |
| 474 | 466 | ||
| 475 | @defun string-to-char string | 467 | @defun string-to-char string |
| @@ -579,7 +571,7 @@ formatting feature described here; they differ from @code{format} only | |||
| 579 | in how they use the result of formatting. | 571 | in how they use the result of formatting. |
| 580 | 572 | ||
| 581 | @defun format string &rest objects | 573 | @defun format string &rest objects |
| 582 | This function returns a new string that is made by copying | 574 | This function returns a new string that is made by copying |
| 583 | @var{string} and then replacing any format specification | 575 | @var{string} and then replacing any format specification |
| 584 | in the copy with encodings of the corresponding @var{objects}. The | 576 | in the copy with encodings of the corresponding @var{objects}. The |
| 585 | arguments @var{objects} are the computed values to be formatted. | 577 | arguments @var{objects} are the computed values to be formatted. |
| @@ -619,7 +611,7 @@ meaningless. | |||
| 619 | @item %s | 611 | @item %s |
| 620 | Replace the specification with the printed representation of the object, | 612 | Replace the specification with the printed representation of the object, |
| 621 | made without quoting (that is, using @code{princ}, not | 613 | made without quoting (that is, using @code{princ}, not |
| 622 | @code{print}---@pxref{Output Functions}). Thus, strings are represented | 614 | @code{prin1}---@pxref{Output Functions}). Thus, strings are represented |
| 623 | by their contents alone, with no @samp{"} characters, and symbols appear | 615 | by their contents alone, with no @samp{"} characters, and symbols appear |
| 624 | without @samp{\} characters. | 616 | without @samp{\} characters. |
| 625 | 617 | ||
| @@ -740,12 +732,13 @@ not truncated. In the third case, the padding is on the right. | |||
| 740 | @end group | 732 | @end group |
| 741 | @end smallexample | 733 | @end smallexample |
| 742 | 734 | ||
| 743 | @node Character Case | 735 | @node Case Conversion |
| 744 | @comment node-name, next, previous, up | 736 | @comment node-name, next, previous, up |
| 745 | @section Character Case | 737 | @section Case Conversion in Lisp |
| 746 | @cindex upper case | 738 | @cindex upper case |
| 747 | @cindex lower case | 739 | @cindex lower case |
| 748 | @cindex character case | 740 | @cindex character case |
| 741 | @cindex case conversion in Lisp | ||
| 749 | 742 | ||
| 750 | The character case functions change the case of single characters or | 743 | The character case functions change the case of single characters or |
| 751 | of the contents of strings. The functions convert only alphabetic | 744 | of the contents of strings. The functions convert only alphabetic |
| @@ -827,18 +820,39 @@ has the same result as @code{upcase}. | |||
| 827 | @end example | 820 | @end example |
| 828 | @end defun | 821 | @end defun |
| 829 | 822 | ||
| 830 | @node Case Table | 823 | @defun upcase-initials string |
| 824 | This function capitalizes the initials of the words in @var{string}. | ||
| 825 | without altering any letters other than the initials. It returns a new | ||
| 826 | string whose contents are a copy of @var{string-or-char}, in which each | ||
| 827 | word has been converted to upper case. | ||
| 828 | |||
| 829 | The definition of a word is any sequence of consecutive characters that | ||
| 830 | are assigned to the word constituent syntax class in the current syntax | ||
| 831 | table (@xref{Syntax Class Table}). | ||
| 832 | |||
| 833 | @example | ||
| 834 | @group | ||
| 835 | (upcase-initials "The CAT in the hAt") | ||
| 836 | @result{} "The CAT In The HAt" | ||
| 837 | @end group | ||
| 838 | @end example | ||
| 839 | @end defun | ||
| 840 | |||
| 841 | @node Case Tables | ||
| 831 | @section The Case Table | 842 | @section The Case Table |
| 832 | 843 | ||
| 833 | You can customize case conversion by installing a special @dfn{case | 844 | You can customize case conversion by installing a special @dfn{case |
| 834 | table}. A case table specifies the mapping between upper case and lower | 845 | table}. A case table specifies the mapping between upper case and lower |
| 835 | case letters. It affects both the string and character case conversion | 846 | case letters. It affects both the case conversion functions for Lisp |
| 836 | functions (see the previous section) and those that apply to text in the | 847 | objects (see the previous section) and those that apply to text in the |
| 837 | buffer (@pxref{Case Changes}). | 848 | buffer (@pxref{Case Changes}). Each buffer has a case table; there is |
| 849 | also a standard case table which is used to initialize the case table | ||
| 850 | of new buffers. | ||
| 838 | 851 | ||
| 839 | A case table is a char-table whose subtype is @code{case-table}. This | 852 | A case table is a char-table (@pxref{Char-Tables}) whose subtype is |
| 840 | char-table maps each character into the corresponding lower case | 853 | @code{case-table}. This char-table maps each character into the |
| 841 | character It has three extra slots, which are related tables: | 854 | corresponding lower case character. It has three extra slots, which |
| 855 | hold related tables: | ||
| 842 | 856 | ||
| 843 | @table @var | 857 | @table @var |
| 844 | @item upcase | 858 | @item upcase |
| @@ -874,17 +888,13 @@ equivalent). (For ordinary @sc{ASCII}, this would map @samp{a} into | |||
| 874 | equivalent characters.) | 888 | equivalent characters.) |
| 875 | 889 | ||
| 876 | When you construct a case table, you can provide @code{nil} for | 890 | When you construct a case table, you can provide @code{nil} for |
| 877 | @var{canonicalize}; then Emacs fills in this string from the lower case | 891 | @var{canonicalize}; then Emacs fills in this slot from the lower case |
| 878 | and upper case mappings. You can also provide @code{nil} for | 892 | and upper case mappings. You can also provide @code{nil} for |
| 879 | @var{equivalences}; then Emacs fills in this string from | 893 | @var{equivalences}; then Emacs fills in this slot from |
| 880 | @var{canonicalize}. In a case table that is actually in use, those | 894 | @var{canonicalize}. In a case table that is actually in use, those |
| 881 | components are non-@code{nil}. Do not try to specify @var{equivalences} | 895 | components are non-@code{nil}. Do not try to specify @var{equivalences} |
| 882 | without also specifying @var{canonicalize}. | 896 | without also specifying @var{canonicalize}. |
| 883 | 897 | ||
| 884 | Each buffer has a case table. Emacs also has a @dfn{standard case | ||
| 885 | table} which is copied into each buffer when you create the buffer. | ||
| 886 | Changing the standard case table doesn't affect any existing buffers. | ||
| 887 | |||
| 888 | Here are the functions for working with case tables: | 898 | Here are the functions for working with case tables: |
| 889 | 899 | ||
| 890 | @defun case-table-p object | 900 | @defun case-table-p object |
| @@ -894,7 +904,7 @@ table. | |||
| 894 | 904 | ||
| 895 | @defun set-standard-case-table table | 905 | @defun set-standard-case-table table |
| 896 | This function makes @var{table} the standard case table, so that it will | 906 | This function makes @var{table} the standard case table, so that it will |
| 897 | apply to any buffers created subsequently. | 907 | be used in any buffers created subsequently. |
| 898 | @end defun | 908 | @end defun |
| 899 | 909 | ||
| 900 | @defun standard-case-table | 910 | @defun standard-case-table |
| @@ -912,7 +922,8 @@ This sets the current buffer's case table to @var{table}. | |||
| 912 | The following three functions are convenient subroutines for packages | 922 | The following three functions are convenient subroutines for packages |
| 913 | that define non-@sc{ASCII} character sets. They modify the specified | 923 | that define non-@sc{ASCII} character sets. They modify the specified |
| 914 | case table @var{case-table}; they also modify the standard syntax table. | 924 | case table @var{case-table}; they also modify the standard syntax table. |
| 915 | @xref{Syntax Tables}. | 925 | @xref{Syntax Tables}. Normally you would use these functions to change |
| 926 | the standard case table. | ||
| 916 | 927 | ||
| 917 | @defun set-case-syntax-pair uc lc case-table | 928 | @defun set-case-syntax-pair uc lc case-table |
| 918 | This function specifies a pair of corresponding letters, one upper case | 929 | This function specifies a pair of corresponding letters, one upper case |
diff --git a/lispref/symbols.texi b/lispref/symbols.texi index 6472d0a40d2..9f52fc0e5be 100644 --- a/lispref/symbols.texi +++ b/lispref/symbols.texi | |||
| @@ -145,7 +145,8 @@ variable. | |||
| 145 | 145 | ||
| 146 | @code{defvar} and @code{defconst} are special forms that define a | 146 | @code{defvar} and @code{defconst} are special forms that define a |
| 147 | symbol as a global variable. They are documented in detail in | 147 | symbol as a global variable. They are documented in detail in |
| 148 | @ref{Defining Variables}. | 148 | @ref{Defining Variables}. For defining user option variables that can |
| 149 | be customized, use @code{defcustom} (@pxref{Customization}). | ||
| 149 | 150 | ||
| 150 | @code{defun} defines a symbol as a function, creating a lambda | 151 | @code{defun} defines a symbol as a function, creating a lambda |
| 151 | expression and storing it in the function cell of the symbol. This | 152 | expression and storing it in the function cell of the symbol. This |
| @@ -229,11 +230,6 @@ valid way to create an obarray.} Prime numbers as lengths tend | |||
| 229 | to result in good hashing; lengths one less than a power of two are also | 230 | to result in good hashing; lengths one less than a power of two are also |
| 230 | good. | 231 | good. |
| 231 | 232 | ||
| 232 | It is possible for two different symbols to have the same name in | ||
| 233 | different obarrays; these symbols are not @code{eq} or @code{equal}. | ||
| 234 | However, this normally happens only as part of the abbrev mechanism | ||
| 235 | (@pxref{Abbrevs}). | ||
| 236 | |||
| 237 | @strong{Do not try to put symbols in an obarray yourself.} This does | 233 | @strong{Do not try to put symbols in an obarray yourself.} This does |
| 238 | not work---only @code{intern} can enter a symbol in an obarray properly. | 234 | not work---only @code{intern} can enter a symbol in an obarray properly. |
| 239 | 235 | ||
| @@ -440,10 +436,10 @@ an association list than to update a property. All properties for a | |||
| 440 | symbol are stored in the same property list, so there is a possibility | 436 | symbol are stored in the same property list, so there is a possibility |
| 441 | of a conflict between different uses of a property name. (For this | 437 | of a conflict between different uses of a property name. (For this |
| 442 | reason, it is a good idea to choose property names that are probably | 438 | reason, it is a good idea to choose property names that are probably |
| 443 | unique, such as by including the name of the library in the property | 439 | unique, such as by beginning the property name with the program's usual |
| 444 | name.) An association list may be used like a stack where associations | 440 | name-prefix for variables and functions.) An association list may be |
| 445 | are pushed on the front of the list and later discarded; this is not | 441 | used like a stack where associations are pushed on the front of the list |
| 446 | possible with a property list. | 442 | and later discarded; this is not possible with a property list. |
| 447 | 443 | ||
| 448 | @node Symbol Plists | 444 | @node Symbol Plists |
| 449 | @subsection Property List Functions for Symbols | 445 | @subsection Property List Functions for Symbols |
| @@ -532,3 +528,10 @@ in the place where you got @var{plist}. For example, | |||
| 532 | @end example | 528 | @end example |
| 533 | @end defun | 529 | @end defun |
| 534 | 530 | ||
| 531 | You could define @code{put} in terms of @code{plist-put} as follows: | ||
| 532 | |||
| 533 | @example | ||
| 534 | (defun put (symbol prop value) | ||
| 535 | (setplist symbol | ||
| 536 | (plist-put (symbol-plist symbol) prop value))) | ||
| 537 | @end example | ||
diff --git a/lispref/syntax.texi b/lispref/syntax.texi index 77fe0c46cfe..3200c40ac83 100644 --- a/lispref/syntax.texi +++ b/lispref/syntax.texi | |||
| @@ -44,12 +44,16 @@ list motion functions (@pxref{List Motion}) as well as the functions in | |||
| 44 | this chapter. | 44 | this chapter. |
| 45 | @end ifinfo | 45 | @end ifinfo |
| 46 | 46 | ||
| 47 | A syntax table is a char-table (@pxref{Char-Tables}). Each element is | 47 | A syntax table is a char-table (@pxref{Char-Tables}). The element at |
| 48 | a list that encodes the syntax of the character in question. | 48 | index @var{c} describes the character with code @var{c}. The element's |
| 49 | value should be a list that encodes the syntax of the character in | ||
| 50 | question. | ||
| 49 | 51 | ||
| 50 | Syntax tables are used only for moving across text, not for the Emacs | 52 | Syntax tables are used only for moving across text, not for the Emacs |
| 51 | Lisp reader. Emacs Lisp uses built-in syntactic rules when reading Lisp | 53 | Lisp reader. Emacs Lisp uses built-in syntactic rules when reading Lisp |
| 52 | expressions, and these rules cannot be changed. | 54 | expressions, and these rules cannot be changed. (Some Lisp systems |
| 55 | provide ways to redefine the read syntax, but we decided to leave this | ||
| 56 | feature out of Emacs Lisp for simplicity.) | ||
| 53 | 57 | ||
| 54 | Each buffer has its own major mode, and each major mode has its own | 58 | Each buffer has its own major mode, and each major mode has its own |
| 55 | idea of the syntactic class of various characters. For example, in Lisp | 59 | idea of the syntactic class of various characters. For example, in Lisp |
| @@ -80,12 +84,11 @@ This function returns @code{t} if @var{object} is a syntax table. | |||
| 80 | This section describes the syntax classes and flags that denote the | 84 | This section describes the syntax classes and flags that denote the |
| 81 | syntax of a character, and how they are represented as a @dfn{syntax | 85 | syntax of a character, and how they are represented as a @dfn{syntax |
| 82 | descriptor}, which is a Lisp string that you pass to | 86 | descriptor}, which is a Lisp string that you pass to |
| 83 | @code{modify-syntax-entry} to specify the desired syntax. | 87 | @code{modify-syntax-entry} to specify the syntax you want. |
| 84 | 88 | ||
| 85 | Emacs defines a number of @dfn{syntax classes}. Each syntax table | 89 | The syntax table specifies a syntax class for each character. There |
| 86 | puts each character into one class. There is no necessary relationship | 90 | is no necessary relationship between the class of a character in one |
| 87 | between the class of a character in one syntax table and its class in | 91 | syntax table and its class in any other table. |
| 88 | any other table. | ||
| 89 | 92 | ||
| 90 | Each class is designated by a mnemonic character, which serves as the | 93 | Each class is designated by a mnemonic character, which serves as the |
| 91 | name of the class when you need to specify a class. Usually the | 94 | name of the class when you need to specify a class. Usually the |
| @@ -124,7 +127,8 @@ their meanings, and examples of their use. | |||
| 124 | separate symbols and words from each other. Typically, whitespace | 127 | separate symbols and words from each other. Typically, whitespace |
| 125 | characters have no other syntactic significance, and multiple whitespace | 128 | characters have no other syntactic significance, and multiple whitespace |
| 126 | characters are syntactically equivalent to a single one. Space, tab, | 129 | characters are syntactically equivalent to a single one. Space, tab, |
| 127 | newline and formfeed are almost always classified as whitespace. | 130 | newline and formfeed are classified as whitespace in almost all major |
| 131 | modes. | ||
| 128 | @end deffn | 132 | @end deffn |
| 129 | 133 | ||
| 130 | @deffn {Syntax class} @w{word constituent} | 134 | @deffn {Syntax class} @w{word constituent} |
| @@ -384,9 +388,9 @@ prefix (@samp{'}). @xref{Motion and Syntax}. | |||
| 384 | altering syntax tables. | 388 | altering syntax tables. |
| 385 | 389 | ||
| 386 | @defun make-syntax-table | 390 | @defun make-syntax-table |
| 387 | This function creates a new syntax table. Character codes 32 through | 391 | This function creates a new syntax table. It inherits the syntax for |
| 388 | 127 are set up by copying the syntax from the standard syntax table. | 392 | letters and control characters from the standard syntax table. For |
| 389 | All other codes are set up to inherit from the standard syntax table. | 393 | other characters, the syntax is copied from the standard syntax table. |
| 390 | 394 | ||
| 391 | Most major mode syntax tables are created in this way. | 395 | Most major mode syntax tables are created in this way. |
| 392 | @end defun | 396 | @end defun |
| @@ -465,20 +469,23 @@ character, @samp{)}. | |||
| 465 | 469 | ||
| 466 | @example | 470 | @example |
| 467 | @group | 471 | @group |
| 468 | (char-to-string (char-syntax ?\ )) | 472 | (string (char-syntax ?\ )) |
| 469 | @result{} " " | 473 | @result{} " " |
| 470 | @end group | 474 | @end group |
| 471 | 475 | ||
| 472 | @group | 476 | @group |
| 473 | (char-to-string (char-syntax ?/)) | 477 | (string (char-syntax ?/)) |
| 474 | @result{} "." | 478 | @result{} "." |
| 475 | @end group | 479 | @end group |
| 476 | 480 | ||
| 477 | @group | 481 | @group |
| 478 | (char-to-string (char-syntax ?\()) | 482 | (string (char-syntax ?\()) |
| 479 | @result{} "(" | 483 | @result{} "(" |
| 480 | @end group | 484 | @end group |
| 481 | @end example | 485 | @end example |
| 486 | |||
| 487 | We use @code{string} to make it easier to see the character returned by | ||
| 488 | @code{char-syntax}. | ||
| 482 | @end defun | 489 | @end defun |
| 483 | 490 | ||
| 484 | @defun set-syntax-table table | 491 | @defun set-syntax-table table |
| @@ -500,7 +507,7 @@ language, you can use @code{syntax-table} text properties to override | |||
| 500 | the syntax table for specific character occurrences in the buffer. | 507 | the syntax table for specific character occurrences in the buffer. |
| 501 | @xref{Text Properties}. | 508 | @xref{Text Properties}. |
| 502 | 509 | ||
| 503 | The valid values of @code{syntax-table} text property are | 510 | The valid values of @code{syntax-table} text property are: |
| 504 | 511 | ||
| 505 | @table @asis | 512 | @table @asis |
| 506 | @item @var{syntax-table} | 513 | @item @var{syntax-table} |
| @@ -527,9 +534,8 @@ table. | |||
| 527 | @node Motion and Syntax | 534 | @node Motion and Syntax |
| 528 | @section Motion and Syntax | 535 | @section Motion and Syntax |
| 529 | 536 | ||
| 530 | This section describes functions for moving across characters in | 537 | This section describes functions for moving across characters that |
| 531 | certain syntax classes. None of these functions exists in Emacs | 538 | have certain syntax classes. |
| 532 | version 18 or earlier. | ||
| 533 | 539 | ||
| 534 | @defun skip-syntax-forward syntaxes &optional limit | 540 | @defun skip-syntax-forward syntaxes &optional limit |
| 535 | This function moves point forward across characters having syntax classes | 541 | This function moves point forward across characters having syntax classes |
| @@ -596,7 +602,7 @@ string, or the of a comment or a string, whichever comes first. | |||
| 596 | 602 | ||
| 597 | @cindex parse state | 603 | @cindex parse state |
| 598 | The fifth argument @var{state} is a nine-element list of the same form | 604 | The fifth argument @var{state} is a nine-element list of the same form |
| 599 | as the value of this function, described below. (It is ok to omit the | 605 | as the value of this function, described below. (It is OK to omit the |
| 600 | last element of the nine.) The return value of one call may be used to | 606 | last element of the nine.) The return value of one call may be used to |
| 601 | initialize the state of the parse on another call to | 607 | initialize the state of the parse on another call to |
| 602 | @code{parse-partial-sexp}. | 608 | @code{parse-partial-sexp}. |
| @@ -758,42 +764,46 @@ a character to match was specified. | |||
| 758 | This table gives the value of @var{syntax-code} which corresponds | 764 | This table gives the value of @var{syntax-code} which corresponds |
| 759 | to each syntactic type. | 765 | to each syntactic type. |
| 760 | 766 | ||
| 761 | @table @asis | 767 | @multitable @columnfractions .05 .3 .3 .3 |
| 762 | @item @i{Integer} | 768 | @item@tab |
| 763 | @i{Class} | 769 | @i{Integer} @i{Class} |
| 764 | @item 0 | 770 | @tab |
| 765 | whitespace | 771 | @i{Integer} @i{Class} |
| 766 | @item 1 | 772 | @tab |
| 767 | punctuation | 773 | @i{Integer} @i{Class} |
| 768 | @item 2 | 774 | @item@tab |
| 769 | word | 775 | 0 @ @ whitespace |
| 770 | @item 3 | 776 | @tab |
| 771 | symbol | 777 | 5 @ @ close parenthesis |
| 772 | @item 4 | 778 | @tab |
| 773 | open parenthesis | 779 | 10 @ @ character quote |
| 774 | @item 5 | 780 | @item@tab |
| 775 | close parenthesis | 781 | 1 @ @ punctuation |
| 776 | @item 6 | 782 | @tab |
| 777 | expression prefix | 783 | 6 @ @ expression prefix |
| 778 | @item 7 | 784 | @tab |
| 779 | string quote | 785 | 11 @ @ comment-start |
| 780 | @item 8 | 786 | @item@tab |
| 781 | paired delimiter | 787 | 2 @ @ word |
| 782 | @item 9 | 788 | @tab |
| 783 | escape | 789 | 7 @ @ string quote |
| 784 | @item 10 | 790 | @tab |
| 785 | character quote | 791 | 12 @ @ comment-end |
| 786 | @item 11 | 792 | @item@tab |
| 787 | comment-start | 793 | 3 @ @ symbol |
| 788 | @item 12 | 794 | @tab |
| 789 | comment-end | 795 | 8 @ @ paired delimiter |
| 790 | @item 13 | 796 | @tab |
| 791 | inherit | 797 | 13 @ @ inherit |
| 792 | @item 14 | 798 | @item@tab |
| 793 | comment-fence | 799 | 4 @ @ open parenthesis |
| 794 | @item 15 | 800 | @tab |
| 795 | string-fence | 801 | 9 @ @ escape |
| 796 | @end table | 802 | @tab |
| 803 | 14 @ @ comment-fence | ||
| 804 | @item@tab | ||
| 805 | 15 @ string-fence | ||
| 806 | @end multitable | ||
| 797 | 807 | ||
| 798 | For example, the usual syntax value for @samp{(} is @code{(4 . 41)}. | 808 | For example, the usual syntax value for @samp{(} is @code{(4 . 41)}. |
| 799 | (41 is the character code for @samp{)}.) | 809 | (41 is the character code for @samp{)}.) |
| @@ -802,39 +812,46 @@ string-fence | |||
| 802 | least significant bit. This table gives the power of two which | 812 | least significant bit. This table gives the power of two which |
| 803 | corresponds to each syntax flag. | 813 | corresponds to each syntax flag. |
| 804 | 814 | ||
| 805 | @table @samp | 815 | @multitable @columnfractions .05 .3 .3 .3 |
| 806 | @item @i{Flag} | 816 | @item@tab |
| 807 | @i{Bit value} | 817 | @i{Prefix} @i{Flag} |
| 808 | @item 1 | 818 | @tab |
| 809 | @code{(lsh 1 16)} | 819 | @i{Prefix} @i{Flag} |
| 810 | @item 2 | 820 | @tab |
| 811 | @code{(lsh 1 17)} | 821 | @i{Prefix} @i{Flag} |
| 812 | @item 3 | 822 | @item@tab |
| 813 | @code{(lsh 1 18)} | 823 | @samp{1} @ @ @code{(lsh 1 16)} |
| 814 | @item 4 | 824 | @tab |
| 815 | @code{(lsh 1 19)} | 825 | @samp{3} @ @ @code{(lsh 1 18)} |
| 816 | @item p | 826 | @tab |
| 817 | @code{(lsh 1 20)} | 827 | @samp{p} @ @ @code{(lsh 1 20)} |
| 818 | @item b | 828 | @item@tab |
| 819 | @code{(lsh 1 21)} | 829 | @samp{2} @ @ @code{(lsh 1 17)} |
| 820 | @end table | 830 | @tab |
| 831 | @samp{4} @ @ @code{(lsh 1 19)} | ||
| 832 | @tab | ||
| 833 | @samp{b} @ @ @code{(lsh 1 21)} | ||
| 834 | @end multitable | ||
| 821 | 835 | ||
| 822 | @node Categories | 836 | @node Categories |
| 823 | @section Categories | 837 | @section Categories |
| 824 | @cindex categories of characters | 838 | @cindex categories of characters |
| 825 | 839 | ||
| 826 | @dfn{Categories} provide an alternate way of classifying characters | 840 | @dfn{Categories} provide an alternate way of classifying characters |
| 827 | syntactically. You can define a large number of categories, and then | 841 | syntactically. You can define several categories as needed, then |
| 828 | independently assign each character to one or more of them. Unlike | 842 | independently assign each character to one or more categories. Unlike |
| 829 | syntax classes, categories are not mutually exclusive; it is normal for | 843 | syntax classes, categories are not mutually exclusive; it is normal for |
| 830 | one character to belong to several categories. | 844 | one character to belong to several categories. |
| 831 | 845 | ||
| 832 | Each buffer has a @dfn{category table} which records which categories | 846 | Each buffer has a @dfn{category table} which records which categories |
| 833 | are defined and also which characters belong to each category. Each | 847 | are defined and also which characters belong to each category. Each |
| 834 | category table defines its own categories. Each category has a name, | 848 | category table defines its own categories, but normally these are |
| 835 | which is an @sc{ASCII} printing character in the range @w{@samp{ }} to | 849 | initialized by copying from the standard categories table, so that the |
| 836 | @samp{~}. You specify the name of a category when you define it with | 850 | standard categories are available in all modes. |
| 837 | @code{define-category}. | 851 | |
| 852 | Each category has a name, which is an @sc{ASCII} printing character in | ||
| 853 | the range @w{@samp{ }} to @samp{~}. You specify the name of a category | ||
| 854 | when you define it with @code{define-category}. | ||
| 838 | 855 | ||
| 839 | The category table is actually a char-table (@pxref{Char-Tables}). | 856 | The category table is actually a char-table (@pxref{Char-Tables}). |
| 840 | The element of the category table at index @var{c} is a @dfn{category | 857 | The element of the category table at index @var{c} is a @dfn{category |
| @@ -865,8 +882,8 @@ in category table @var{table}. | |||
| 865 | 882 | ||
| 866 | @defun get-unused-category table | 883 | @defun get-unused-category table |
| 867 | This function returns a category name (a character) which is not | 884 | This function returns a category name (a character) which is not |
| 868 | currently defined in @var{table}. If none is still available, it | 885 | currently defined in @var{table}. If all possible categories are in use |
| 869 | returns @code{nil}, | 886 | in @var{table}, it returns @code{nil}, |
| 870 | @end defun | 887 | @end defun |
| 871 | 888 | ||
| 872 | @defun category-table | 889 | @defun category-table |
diff --git a/lispref/text.texi b/lispref/text.texi index f1ab809c96b..96b527d23fa 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -79,6 +79,13 @@ buffer is @samp{@@}: | |||
| 79 | @end example | 79 | @end example |
| 80 | @end defun | 80 | @end defun |
| 81 | 81 | ||
| 82 | @defun char-before position | ||
| 83 | This function returns the character in the current buffer immediately | ||
| 84 | before position @var{position}. If @var{position} is out of range for | ||
| 85 | this purpose, either before the beginning of the buffer, or at or beyond | ||
| 86 | the end, then the value is @code{nil}. | ||
| 87 | @end defun | ||
| 88 | |||
| 82 | @defun following-char | 89 | @defun following-char |
| 83 | This function returns the character following point in the current | 90 | This function returns the character following point in the current |
| 84 | buffer. This is similar to @code{(char-after (point))}. However, if | 91 | buffer. This is similar to @code{(char-after (point))}. However, if |
| @@ -185,19 +192,6 @@ This is the contents of buffer foo | |||
| 185 | @defun buffer-substring-no-properties start end | 192 | @defun buffer-substring-no-properties start end |
| 186 | This is like @code{buffer-substring}, except that it does not copy text | 193 | This is like @code{buffer-substring}, except that it does not copy text |
| 187 | properties, just the characters themselves. @xref{Text Properties}. | 194 | properties, just the characters themselves. @xref{Text Properties}. |
| 188 | Here's an example of using this function to get a word to look up in an | ||
| 189 | alist: | ||
| 190 | |||
| 191 | @example | ||
| 192 | (setq flammable | ||
| 193 | (assoc (buffer-substring-no-properties start end) | ||
| 194 | '(("wood" . t) ("paper" . t) | ||
| 195 | ("steel" . nil) ("asbestos" . nil)))) | ||
| 196 | @end example | ||
| 197 | |||
| 198 | If this were written using @code{buffer-substring} instead, it would not | ||
| 199 | work reliably; any text properties that happened to be in the word | ||
| 200 | copied from the buffer would make the comparisons fail. | ||
| 201 | @end defun | 195 | @end defun |
| 202 | 196 | ||
| 203 | @defun buffer-string | 197 | @defun buffer-string |
| @@ -282,23 +276,22 @@ at the second character. | |||
| 282 | @cindex insertion of text | 276 | @cindex insertion of text |
| 283 | @cindex text insertion | 277 | @cindex text insertion |
| 284 | 278 | ||
| 279 | @cindex insertion before point | ||
| 280 | @cindex before point, insertion | ||
| 285 | @dfn{Insertion} means adding new text to a buffer. The inserted text | 281 | @dfn{Insertion} means adding new text to a buffer. The inserted text |
| 286 | goes at point---between the character before point and the character | 282 | goes at point---between the character before point and the character |
| 287 | after point. | 283 | after point. Some insertion functions leave point before the inserted |
| 284 | text, while other functions leave it after. We call the former | ||
| 285 | insertion @dfn{after point} and the latter insertion @dfn{before point}. | ||
| 288 | 286 | ||
| 289 | Insertion relocates markers that point at positions after the | 287 | Insertion relocates markers that point at positions after the |
| 290 | insertion point, so that they stay with the surrounding text | 288 | insertion point, so that they stay with the surrounding text |
| 291 | (@pxref{Markers}). When a marker points at the place of insertion, | 289 | (@pxref{Markers}). When a marker points at the place of insertion, |
| 292 | insertion normally doesn't relocate the marker, so that it points to the | 290 | insertion may or may not relocate the marker, depending on the marker's |
| 293 | beginning of the inserted text; however, certain special functions such | 291 | insertion type (@pxref{Marker Insertion Types}). Certain special |
| 294 | as @code{insert-before-markers} relocate such markers to point after the | 292 | functions such as @code{insert-before-markers} relocate all such markers |
| 295 | inserted text. | 293 | to point after the inserted text, regardless of the markers' insertion |
| 296 | 294 | type. | |
| 297 | @cindex insertion before point | ||
| 298 | @cindex before point, insertion | ||
| 299 | Some insertion functions leave point before the inserted text, while | ||
| 300 | other functions leave it after. We call the former insertion @dfn{after | ||
| 301 | point} and the latter insertion @dfn{before point}. | ||
| 302 | 295 | ||
| 303 | Insertion functions signal an error if the current buffer is | 296 | Insertion functions signal an error if the current buffer is |
| 304 | read-only. | 297 | read-only. |
| @@ -329,11 +322,11 @@ inserted text falls outside the overlay; if a nonempty overlay ends at | |||
| 329 | the insertion point, the inserted text falls inside that overlay. | 322 | the insertion point, the inserted text falls inside that overlay. |
| 330 | @end defun | 323 | @end defun |
| 331 | 324 | ||
| 332 | @defun insert-char character count &optional inherit | 325 | @defun insert-char character &optional count inherit |
| 333 | This function inserts @var{count} instances of @var{character} into the | 326 | This function inserts @var{count} instances of @var{character} into the |
| 334 | current buffer before point. The argument @var{count} must be a number, | 327 | current buffer before point. The argument @var{count} should be a |
| 335 | and @var{character} must be a character. The value is @code{nil}. | 328 | number (@code{nil} means 1), and @var{character} must be a character. |
| 336 | @c It's unfortunate that count comes second. Not like make-string, etc. | 329 | The value is @code{nil}. |
| 337 | 330 | ||
| 338 | If @var{inherit} is non-@code{nil}, then the inserted characters inherit | 331 | If @var{inherit} is non-@code{nil}, then the inserted characters inherit |
| 339 | sticky text properties from the two characters before and after the | 332 | sticky text properties from the two characters before and after the |
| @@ -531,6 +524,16 @@ the kill ring. | |||
| 531 | The value returned is always @code{nil}. | 524 | The value returned is always @code{nil}. |
| 532 | @end deffn | 525 | @end deffn |
| 533 | 526 | ||
| 527 | @tindex backward-delete-char-untabify-method | ||
| 528 | @defopt backward-delete-char-untabify-method | ||
| 529 | This option specifies how @code{backward-delete-char-untabify} should | ||
| 530 | deal with whitespace. Possible values include @code{untabify}, the | ||
| 531 | default, meaning convert a tab to many spaces and delete one; | ||
| 532 | @code{hungry}, meaning delete all the whitespace characters before point | ||
| 533 | with one command, and @code{nil}, meaning do nothing special for | ||
| 534 | whitespace characters. | ||
| 535 | @end defopt | ||
| 536 | |||
| 534 | @node User-Level Deletion | 537 | @node User-Level Deletion |
| 535 | @section User-Level Deletion Commands | 538 | @section User-Level Deletion Commands |
| 536 | 539 | ||
| @@ -668,7 +671,7 @@ A blank line is defined as a line containing only tabs and spaces. | |||
| 668 | @section The Kill Ring | 671 | @section The Kill Ring |
| 669 | @cindex kill ring | 672 | @cindex kill ring |
| 670 | 673 | ||
| 671 | @dfn{Kill} functions delete text like the deletion functions, but save | 674 | @dfn{Kill functions} delete text like the deletion functions, but save |
| 672 | it so that the user can reinsert it by @dfn{yanking}. Most of these | 675 | it so that the user can reinsert it by @dfn{yanking}. Most of these |
| 673 | functions have @samp{kill-} in their name. By contrast, the functions | 676 | functions have @samp{kill-} in their name. By contrast, the functions |
| 674 | whose names start with @samp{delete-} normally do not save text for | 677 | whose names start with @samp{delete-} normally do not save text for |
| @@ -828,10 +831,10 @@ The value is always @code{nil}. | |||
| 828 | @node Low-Level Kill Ring | 831 | @node Low-Level Kill Ring |
| 829 | @subsection Low-Level Kill Ring | 832 | @subsection Low-Level Kill Ring |
| 830 | 833 | ||
| 831 | These functions and variables provide access to the kill ring at a lower | 834 | These functions and variables provide access to the kill ring at a |
| 832 | level, but still convenient for use in Lisp programs. They take care of | 835 | lower level, but still convenient for use in Lisp programs, because they |
| 833 | interaction with X Window selections. They do not exist in Emacs | 836 | take care of interaction with window system selections |
| 834 | version 18. | 837 | (@pxref{Window System Selections}). |
| 835 | 838 | ||
| 836 | @defun current-kill n &optional do-not-move | 839 | @defun current-kill n &optional do-not-move |
| 837 | The function @code{current-kill} rotates the yanking pointer which | 840 | The function @code{current-kill} rotates the yanking pointer which |
| @@ -873,9 +876,9 @@ If the value is a function, @code{current-kill} calls it to get the | |||
| 873 | then that value is used as the ``most recent kill''. If it returns | 876 | then that value is used as the ``most recent kill''. If it returns |
| 874 | @code{nil}, then the first element of @code{kill-ring} is used. | 877 | @code{nil}, then the first element of @code{kill-ring} is used. |
| 875 | 878 | ||
| 876 | The normal use of this hook is to get the X server's primary selection | 879 | The normal use of this hook is to get the window system's primary |
| 877 | as the most recent kill, even if the selection belongs to another X | 880 | selection as the most recent kill, even if the selection belongs to |
| 878 | client. @xref{X Selections}. | 881 | another application. @xref{Window System Selections}. |
| 879 | @end defvar | 882 | @end defvar |
| 880 | 883 | ||
| 881 | @defvar interprogram-cut-function | 884 | @defvar interprogram-cut-function |
| @@ -886,8 +889,8 @@ programs, when you are using a window system. Its value should be | |||
| 886 | If the value is a function, @code{kill-new} and @code{kill-append} call | 889 | If the value is a function, @code{kill-new} and @code{kill-append} call |
| 887 | it with the new first element of the kill ring as an argument. | 890 | it with the new first element of the kill ring as an argument. |
| 888 | 891 | ||
| 889 | The normal use of this hook is to set the X server's primary selection | 892 | The normal use of this hook is to set the window system's primary |
| 890 | from the newly killed text. | 893 | selection from the newly killed text. @xref{Window System Selections}. |
| 891 | @end defvar | 894 | @end defvar |
| 892 | 895 | ||
| 893 | @node Internals of Kill Ring | 896 | @node Internals of Kill Ring |
| @@ -925,10 +928,12 @@ different piece of text" "yet older text")}. | |||
| 925 | 928 | ||
| 926 | @example | 929 | @example |
| 927 | @group | 930 | @group |
| 928 | kill-ring kill-ring-yank-pointer | 931 | kill-ring ---- kill-ring-yank-pointer |
| 929 | | | | 932 | | | |
| 930 | | ___ ___ ---> ___ ___ ___ ___ | 933 | | v |
| 931 | --> |___|___|------> |___|___|--> |___|___|--> nil | 934 | | --- --- --- --- --- --- |
| 935 | --> | | |------> | | |--> | | |--> nil | ||
| 936 | --- --- --- --- --- --- | ||
| 932 | | | | | 937 | | | | |
| 933 | | | | | 938 | | | | |
| 934 | | | -->"yet older text" | 939 | | | -->"yet older text" |
| @@ -1103,8 +1108,7 @@ has no effect. | |||
| 1103 | This function returns @code{nil}. It cannot be called interactively. | 1108 | This function returns @code{nil}. It cannot be called interactively. |
| 1104 | 1109 | ||
| 1105 | The name @code{buffer-flush-undo} is not considered obsolete, but the | 1110 | The name @code{buffer-flush-undo} is not considered obsolete, but the |
| 1106 | preferred name @code{buffer-disable-undo} is new as of Emacs versions | 1111 | preferred name is @code{buffer-disable-undo}. |
| 1107 | 19. | ||
| 1108 | @end defun | 1112 | @end defun |
| 1109 | 1113 | ||
| 1110 | As editing continues, undo lists get longer and longer. To prevent | 1114 | As editing continues, undo lists get longer and longer. To prevent |
| @@ -1153,7 +1157,8 @@ If it is non-@code{nil}, that requests some kind of justification. It | |||
| 1153 | can be @code{left}, @code{right}, @code{full}, or @code{center}, to | 1157 | can be @code{left}, @code{right}, @code{full}, or @code{center}, to |
| 1154 | request a specific style of justification. If it is @code{t}, that | 1158 | request a specific style of justification. If it is @code{t}, that |
| 1155 | means to use the current justification style for this part of the text | 1159 | means to use the current justification style for this part of the text |
| 1156 | (see @code{current-justification}, below). | 1160 | (see @code{current-justification}, below). Any other value is treated |
| 1161 | as @code{full}. | ||
| 1157 | 1162 | ||
| 1158 | When you call the filling functions interactively, using a prefix | 1163 | When you call the filling functions interactively, using a prefix |
| 1159 | argument implies the value @code{full} for @var{justify}. | 1164 | argument implies the value @code{full} for @var{justify}. |
| @@ -1358,10 +1363,19 @@ whitespace. | |||
| 1358 | 1363 | ||
| 1359 | @defvar left-margin | 1364 | @defvar left-margin |
| 1360 | This variable specifies the base left margin column. In Fundamental | 1365 | This variable specifies the base left margin column. In Fundamental |
| 1361 | mode, @key{LFD} indents to this column. This variable automatically | 1366 | mode, @kbd{C-j} indents to this column. This variable automatically |
| 1362 | becomes buffer-local when set in any fashion. | 1367 | becomes buffer-local when set in any fashion. |
| 1363 | @end defvar | 1368 | @end defvar |
| 1364 | 1369 | ||
| 1370 | @tindex fill-nobreak-predicate | ||
| 1371 | @defvar fill-nobreak-predicate | ||
| 1372 | This variable gives major modes a way to specify not to break a line at | ||
| 1373 | certain places. Its value should be a function. This function is | ||
| 1374 | called during filling, with no arguments and with point located at the | ||
| 1375 | place where a break is being considered. If the function returns | ||
| 1376 | non-@code{nil}, then the line won't be broken there. | ||
| 1377 | @end defvar | ||
| 1378 | |||
| 1365 | @node Auto Filling | 1379 | @node Auto Filling |
| 1366 | @comment node-name, next, previous, up | 1380 | @comment node-name, next, previous, up |
| 1367 | @section Auto Filling | 1381 | @section Auto Filling |
| @@ -1395,7 +1409,8 @@ was renamed to @code{auto-fill-function} in version 19. | |||
| 1395 | @defvar normal-auto-fill-function | 1409 | @defvar normal-auto-fill-function |
| 1396 | This variable specifies the function to use for | 1410 | This variable specifies the function to use for |
| 1397 | @code{auto-fill-function}, if and when Auto Fill is turned on. Major | 1411 | @code{auto-fill-function}, if and when Auto Fill is turned on. Major |
| 1398 | modes can set this locally to alter how Auto Fill works. | 1412 | modes can set buffer-local values for this variable to alter how Auto |
| 1413 | Fill works. | ||
| 1399 | @end defvar | 1414 | @end defvar |
| 1400 | 1415 | ||
| 1401 | @node Sorting | 1416 | @node Sorting |
| @@ -1485,9 +1500,7 @@ the sort order. | |||
| 1485 | (save-restriction | 1500 | (save-restriction |
| 1486 | (narrow-to-region beg end) | 1501 | (narrow-to-region beg end) |
| 1487 | (goto-char (point-min)) | 1502 | (goto-char (point-min)) |
| 1488 | (sort-subr reverse | 1503 | (sort-subr reverse 'forward-line 'end-of-line))) |
| 1489 | 'forward-line | ||
| 1490 | 'end-of-line))) | ||
| 1491 | @end group | 1504 | @end group |
| 1492 | @end example | 1505 | @end example |
| 1493 | 1506 | ||
| @@ -1503,8 +1516,7 @@ its @code{sort-subr} call looks like this: | |||
| 1503 | @group | 1516 | @group |
| 1504 | (sort-subr reverse | 1517 | (sort-subr reverse |
| 1505 | (function | 1518 | (function |
| 1506 | (lambda () | 1519 | (lambda () (skip-chars-forward "\n \t\f"))) |
| 1507 | (skip-chars-forward "\n \t\f"))) | ||
| 1508 | 'forward-paragraph) | 1520 | 'forward-paragraph) |
| 1509 | @end group | 1521 | @end group |
| 1510 | @end example | 1522 | @end example |
| @@ -1630,7 +1642,7 @@ containing position @var{beg}, and the entire line containing position | |||
| 1630 | 1642 | ||
| 1631 | Note that @code{sort-columns} uses the @code{sort} utility program, | 1643 | Note that @code{sort-columns} uses the @code{sort} utility program, |
| 1632 | and so cannot work properly on text containing tab characters. Use | 1644 | and so cannot work properly on text containing tab characters. Use |
| 1633 | @kbd{M-x @code{untabify}} to convert tabs to spaces before sorting. | 1645 | @kbd{M-x untabify} to convert tabs to spaces before sorting. |
| 1634 | @end deffn | 1646 | @end deffn |
| 1635 | 1647 | ||
| 1636 | @node Columns | 1648 | @node Columns |
| @@ -1715,7 +1727,7 @@ count from zero at the left margin. | |||
| 1715 | 1727 | ||
| 1716 | This section describes the primitive functions used to count and | 1728 | This section describes the primitive functions used to count and |
| 1717 | insert indentation. The functions in the following sections use these | 1729 | insert indentation. The functions in the following sections use these |
| 1718 | primitives. | 1730 | primitives. @xref{Width}, for related functions. |
| 1719 | 1731 | ||
| 1720 | @defun current-indentation | 1732 | @defun current-indentation |
| 1721 | @comment !!Type Primitive Function | 1733 | @comment !!Type Primitive Function |
| @@ -1745,7 +1757,7 @@ Properties}. | |||
| 1745 | @comment !!SourceFile indent.c | 1757 | @comment !!SourceFile indent.c |
| 1746 | If this variable is non-@code{nil}, indentation functions can insert | 1758 | If this variable is non-@code{nil}, indentation functions can insert |
| 1747 | tabs as well as spaces. Otherwise, they insert only spaces. Setting | 1759 | tabs as well as spaces. Otherwise, they insert only spaces. Setting |
| 1748 | this variable automatically makes it local to the current buffer. | 1760 | this variable automatically makes it buffer-local in the current buffer. |
| 1749 | @end defopt | 1761 | @end defopt |
| 1750 | 1762 | ||
| 1751 | @node Mode-Specific Indent | 1763 | @node Mode-Specific Indent |
| @@ -2009,11 +2021,11 @@ nonblank character on that line. It returns @code{nil}. | |||
| 2009 | @node Case Changes | 2021 | @node Case Changes |
| 2010 | @comment node-name, next, previous, up | 2022 | @comment node-name, next, previous, up |
| 2011 | @section Case Changes | 2023 | @section Case Changes |
| 2012 | @cindex case changes | 2024 | @cindex case conversion in buffers |
| 2013 | 2025 | ||
| 2014 | The case change commands described here work on text in the current | 2026 | The case change commands described here work on text in the current |
| 2015 | buffer. @xref{Character Case}, for case conversion commands that work | 2027 | buffer. @xref{Case Conversion}, for case conversion functions that work |
| 2016 | on strings and characters. @xref{Case Table}, for how to customize | 2028 | on strings and characters. @xref{Case Tables}, for how to customize |
| 2017 | which characters are upper or lower case and how to convert them. | 2029 | which characters are upper or lower case and how to convert them. |
| 2018 | 2030 | ||
| 2019 | @deffn Command capitalize-region start end | 2031 | @deffn Command capitalize-region start end |
| @@ -2417,9 +2429,9 @@ for @var{object} is the current buffer. | |||
| 2417 | @subsection Properties with Special Meanings | 2429 | @subsection Properties with Special Meanings |
| 2418 | 2430 | ||
| 2419 | Here is a table of text property names that have special built-in | 2431 | Here is a table of text property names that have special built-in |
| 2420 | meanings. The following section lists a few more special property names | 2432 | meanings. The following sections list a few additional special property |
| 2421 | that are used to control filling. All other names have no standard | 2433 | names that control filling and property inheritance. All other names |
| 2422 | meaning, and you can use them as you like. | 2434 | have no standard meaning, and you can use them as you like. |
| 2423 | 2435 | ||
| 2424 | @table @code | 2436 | @table @code |
| 2425 | @cindex category of text character | 2437 | @cindex category of text character |
| @@ -2813,8 +2825,8 @@ is done by the command definition. Here is how Dired does it: | |||
| 2813 | (save-excursion | 2825 | (save-excursion |
| 2814 | (set-buffer (window-buffer (posn-window (event-end event)))) | 2826 | (set-buffer (window-buffer (posn-window (event-end event)))) |
| 2815 | (save-excursion | 2827 | (save-excursion |
| 2816 | (goto-char (posn-point (event-end event))) | 2828 | (goto-char (posn-point (event-end event))) |
| 2817 | (setq file (dired-get-filename)))) | 2829 | (setq file (dired-get-filename)))) |
| 2818 | (select-window (posn-window (event-end event))) | 2830 | (select-window (posn-window (event-end event))) |
| 2819 | (find-file-other-window (file-name-sans-versions file t)))) | 2831 | (find-file-other-window (file-name-sans-versions file t)))) |
| 2820 | @end smallexample | 2832 | @end smallexample |
| @@ -2955,15 +2967,11 @@ translation table. | |||
| 2955 | @cindex registers | 2967 | @cindex registers |
| 2956 | 2968 | ||
| 2957 | A register is a sort of variable used in Emacs editing that can hold a | 2969 | A register is a sort of variable used in Emacs editing that can hold a |
| 2958 | marker, a string, a rectangle, a window configuration (of one frame), or | 2970 | variety of different kinds of values. Each register is named by a |
| 2959 | a frame configuration (of all frames). Each register is named by a | 2971 | single character. All ASCII characters and their meta variants (but |
| 2960 | single character. All characters, including control and meta characters | 2972 | with the exception of @kbd{C-g}) can be used to name registers. Thus, |
| 2961 | (but with the exception of @kbd{C-g}), can be used to name registers. | 2973 | there are 255 possible registers. A register is designated in Emacs |
| 2962 | Thus, there are 255 possible registers. A register is designated in | 2974 | Lisp by the character that is its name. |
| 2963 | Emacs Lisp by a character that is its name. | ||
| 2964 | |||
| 2965 | The functions in this section return unpredictable values unless | ||
| 2966 | otherwise stated. | ||
| 2967 | 2975 | ||
| 2968 | @defvar register-alist | 2976 | @defvar register-alist |
| 2969 | This variable is an alist of elements of the form @code{(@var{name} . | 2977 | This variable is an alist of elements of the form @code{(@var{name} . |
| @@ -2971,13 +2979,47 @@ This variable is an alist of elements of the form @code{(@var{name} . | |||
| 2971 | register that has been used. | 2979 | register that has been used. |
| 2972 | 2980 | ||
| 2973 | The object @var{name} is a character (an integer) identifying the | 2981 | The object @var{name} is a character (an integer) identifying the |
| 2974 | register. The object @var{contents} is a string, marker, window | 2982 | register. |
| 2975 | configuration, frame configuration, or list representing the register | ||
| 2976 | contents. A string represents text stored in the register. A marker | ||
| 2977 | represents a position. A list represents a rectangle; its elements are | ||
| 2978 | strings, one per line of the rectangle. | ||
| 2979 | @end defvar | 2983 | @end defvar |
| 2980 | 2984 | ||
| 2985 | The @var{contents} of a register can have several possible types: | ||
| 2986 | |||
| 2987 | @table @asis | ||
| 2988 | @item a number | ||
| 2989 | A number stands for itself. If @code{insert-register} finds a number | ||
| 2990 | in the register, it converts the number to decimal. | ||
| 2991 | |||
| 2992 | @item a marker | ||
| 2993 | A marker represents a buffer position to jump to. | ||
| 2994 | |||
| 2995 | @item a string | ||
| 2996 | A string is text saved in the register. | ||
| 2997 | |||
| 2998 | @item a rectangle | ||
| 2999 | A rectangle is represented by a list of strings. | ||
| 3000 | |||
| 3001 | @item @code{(@var{window-configuration} @var{position})} | ||
| 3002 | This represents a window configuration to restore in one frame, and a | ||
| 3003 | position to jump to in the current buffer. | ||
| 3004 | |||
| 3005 | @item @code{(@var{frame-configuration} @var{position})} | ||
| 3006 | This represents a frame configuration to restore, and a position | ||
| 3007 | to jump to in the current buffer. | ||
| 3008 | |||
| 3009 | @item (file @var{filename}) | ||
| 3010 | This represents a file to visit; jumping to this value visits file | ||
| 3011 | @var{filename}. | ||
| 3012 | |||
| 3013 | @item (file-query @var{filename} @var{position}) | ||
| 3014 | This represents a file to visit and a position in it; jumping to this | ||
| 3015 | value visits file @var{filename} and goes to buffer position | ||
| 3016 | @var{position}. Restoring this type of position asks the user for | ||
| 3017 | confirmation first. | ||
| 3018 | @end table | ||
| 3019 | |||
| 3020 | The functions in this section return unpredictable values unless | ||
| 3021 | otherwise stated. | ||
| 3022 | |||
| 2981 | @defun get-register reg | 3023 | @defun get-register reg |
| 2982 | This function returns the contents of the register | 3024 | This function returns the contents of the register |
| 2983 | @var{reg}, or @code{nil} if it has no contents. | 3025 | @var{reg}, or @code{nil} if it has no contents. |
| @@ -3136,11 +3178,18 @@ that seems safe. | |||
| 3136 | If a program makes several text changes in the same area of the buffer, | 3178 | If a program makes several text changes in the same area of the buffer, |
| 3137 | using the macro @code{combine-after-change-calls} around that part of | 3179 | using the macro @code{combine-after-change-calls} around that part of |
| 3138 | the program can make it run considerably faster when after-change hooks | 3180 | the program can make it run considerably faster when after-change hooks |
| 3139 | are in use. | 3181 | are in use. When the after-change hooks are ultimately called, the |
| 3182 | arguments specify a portion of the buffer including all of the changes | ||
| 3183 | made within the @code{combine-after-change-calls} body. | ||
| 3140 | 3184 | ||
| 3141 | @strong{Warning:} You must not alter the values of | 3185 | @strong{Warning:} You must not alter the values of |
| 3142 | @code{after-change-functions} and @code{after-change-function} within | 3186 | @code{after-change-functions} and @code{after-change-function} within |
| 3143 | the body of a @code{combine-after-change-calls} form. | 3187 | the body of a @code{combine-after-change-calls} form. |
| 3188 | |||
| 3189 | @strong{Note:} If the changes you combine occur in widely scattered | ||
| 3190 | parts of the buffer, this will still work, but it is not advisable, | ||
| 3191 | because it may lead to inefficient behavior for some change hook | ||
| 3192 | functions. | ||
| 3144 | @end defmac | 3193 | @end defmac |
| 3145 | 3194 | ||
| 3146 | @defvar before-change-function | 3195 | @defvar before-change-function |
| @@ -3177,8 +3226,11 @@ to call. Here is an example: | |||
| 3177 | (while list | 3226 | (while list |
| 3178 | (funcall (car list) beg end len) | 3227 | (funcall (car list) beg end len) |
| 3179 | (setq list (cdr list))))) | 3228 | (setq list (cdr list))))) |
| 3229 | |||
| 3230 | @group | ||
| 3180 | (add-hooks 'after-change-functions | 3231 | (add-hooks 'after-change-functions |
| 3181 | 'indirect-after-change-function) | 3232 | 'indirect-after-change-function) |
| 3233 | @end group | ||
| 3182 | @end example | 3234 | @end example |
| 3183 | 3235 | ||
| 3184 | @defvar first-change-hook | 3236 | @defvar first-change-hook |
diff --git a/lispref/tips.texi b/lispref/tips.texi index e5a7bb24631..11522391a3f 100644 --- a/lispref/tips.texi +++ b/lispref/tips.texi | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1995, 1998 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1995, 1998 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/tips | 5 | @setfilename ../info/tips |
| 6 | @node Tips, GNU Emacs Internals, Calendar, Top | 6 | @node Tips, GNU Emacs Internals, System Interface, Top |
| 7 | @appendix Tips and Conventions | 7 | @appendix Tips and Conventions |
| 8 | @cindex tips | 8 | @cindex tips |
| 9 | @cindex standards of coding style | 9 | @cindex standards of coding style |
| @@ -37,10 +37,11 @@ names of all global variables, constants, and functions with the chosen | |||
| 37 | prefix. This helps avoid name conflicts. | 37 | prefix. This helps avoid name conflicts. |
| 38 | 38 | ||
| 39 | This recommendation applies even to names for traditional Lisp | 39 | This recommendation applies even to names for traditional Lisp |
| 40 | primitives that are not primitives in Emacs Lisp---even to @code{cadr}. | 40 | primitives that are not primitives in Emacs Lisp---even to |
| 41 | Believe it or not, there is more than one plausible way to define | 41 | @code{copy-list}. Believe it or not, there is more than one plausible |
| 42 | @code{cadr}. Play it safe; append your name prefix to produce a name | 42 | way to define @code{copy-list}. Play it safe; append your name prefix |
| 43 | like @code{foo-cadr} or @code{mylib-cadr} instead. | 43 | to produce a name like @code{foo-copy-list} or @code{mylib-copy-list} |
| 44 | instead. | ||
| 44 | 45 | ||
| 45 | If you write a function that you think ought to be added to Emacs under | 46 | If you write a function that you think ought to be added to Emacs under |
| 46 | a certain name, such as @code{twiddle-files}, don't call it by that name | 47 | a certain name, such as @code{twiddle-files}, don't call it by that name |
| @@ -75,11 +76,11 @@ macro: | |||
| 75 | @end example | 76 | @end example |
| 76 | 77 | ||
| 77 | @noindent | 78 | @noindent |
| 78 | (And @var{bar} should contain @code{(provide '@var{bar})}, to make the | 79 | (And the library @var{bar} should contain @code{(provide '@var{bar})}, |
| 79 | @code{require} work.) This will cause @var{bar} to be loaded when you | 80 | to make the @code{require} work.) This will cause @var{bar} to be |
| 80 | byte-compile @var{foo}. Otherwise, you risk compiling @var{foo} without | 81 | loaded when you byte-compile @var{foo}. Otherwise, you risk compiling |
| 81 | the necessary macro loaded, and that would produce compiled code that | 82 | @var{foo} without the necessary macro loaded, and that would produce |
| 82 | won't work right. @xref{Compiling Macros}. | 83 | compiled code that won't work right. @xref{Compiling Macros}. |
| 83 | 84 | ||
| 84 | Using @code{eval-when-compile} avoids loading @var{bar} when | 85 | Using @code{eval-when-compile} avoids loading @var{bar} when |
| 85 | the compiled version of @var{foo} is @emph{used}. | 86 | the compiled version of @var{foo} is @emph{used}. |
| @@ -111,9 +112,9 @@ Instead, define sequences consisting of @kbd{C-c} followed by a control | |||
| 111 | character, a digit, or certain punctuation characters. These sequences | 112 | character, a digit, or certain punctuation characters. These sequences |
| 112 | are reserved for major modes. | 113 | are reserved for major modes. |
| 113 | 114 | ||
| 114 | Changing all the major modes in Emacs 18 so they would follow this | 115 | Changing all the Emacs major modes to follow this convention was a lot |
| 115 | convention was a lot of work. Abandoning this convention would make | 116 | of work. Abandoning this convention would make that work go to waste, |
| 116 | that work go to waste, and inconvenience users. | 117 | and inconvenience users. |
| 117 | 118 | ||
| 118 | @item | 119 | @item |
| 119 | Sequences consisting of @kbd{C-c} followed by @kbd{@{}, @kbd{@}}, | 120 | Sequences consisting of @kbd{C-c} followed by @kbd{@{}, @kbd{@}}, |
| @@ -136,7 +137,7 @@ as a help character for listing the subcommands of the prefix character. | |||
| 136 | 137 | ||
| 137 | @item | 138 | @item |
| 138 | Do not bind a key sequence ending in @key{ESC} except following | 139 | Do not bind a key sequence ending in @key{ESC} except following |
| 139 | another @key{ESC}. (That is, it is ok to bind a sequence ending in | 140 | another @key{ESC}. (That is, it is OK to bind a sequence ending in |
| 140 | @kbd{@key{ESC} @key{ESC}}.) | 141 | @kbd{@key{ESC} @key{ESC}}.) |
| 141 | 142 | ||
| 142 | The reason for this rule is that a non-prefix binding for @key{ESC} in | 143 | The reason for this rule is that a non-prefix binding for @key{ESC} in |
| @@ -251,7 +252,7 @@ user switch back at will. @xref{Recursive Editing}. | |||
| 251 | In some other systems there is a convention of choosing variable names | 252 | In some other systems there is a convention of choosing variable names |
| 252 | that begin and end with @samp{*}. We don't use that convention in Emacs | 253 | that begin and end with @samp{*}. We don't use that convention in Emacs |
| 253 | Lisp, so please don't use it in your programs. (Emacs uses such names | 254 | Lisp, so please don't use it in your programs. (Emacs uses such names |
| 254 | only for program-generated buffers.) The users will find Emacs more | 255 | only for special-purpose buffers.) The users will find Emacs more |
| 255 | coherent if all libraries use the same conventions. | 256 | coherent if all libraries use the same conventions. |
| 256 | 257 | ||
| 257 | @item | 258 | @item |
| @@ -273,7 +274,7 @@ default indentation parameters. | |||
| 273 | Don't make a habit of putting close-parentheses on lines by themselves; | 274 | Don't make a habit of putting close-parentheses on lines by themselves; |
| 274 | Lisp programmers find this disconcerting. Once in a while, when there | 275 | Lisp programmers find this disconcerting. Once in a while, when there |
| 275 | is a sequence of many consecutive close-parentheses, it may make sense | 276 | is a sequence of many consecutive close-parentheses, it may make sense |
| 276 | to split them in one or two significant places. | 277 | to split the sequence in one or two significant places. |
| 277 | 278 | ||
| 278 | @item | 279 | @item |
| 279 | Please put a copyright notice on the file if you give copies to anyone. | 280 | Please put a copyright notice on the file if you give copies to anyone. |
| @@ -366,7 +367,11 @@ the speed. @xref{Inline Functions}. | |||
| 366 | @node Documentation Tips | 367 | @node Documentation Tips |
| 367 | @section Tips for Documentation Strings | 368 | @section Tips for Documentation Strings |
| 368 | 369 | ||
| 369 | Here are some tips for the writing of documentation strings. | 370 | @tindex checkdoc-minor-mode |
| 371 | @findex checkdoc-minor-mode | ||
| 372 | Here are some tips and conventions for the writing of documentation | ||
| 373 | strings. You can check many of these conventions by running the command | ||
| 374 | @kbd{M-x checkdoc-minor-mode}. | ||
| 370 | 375 | ||
| 371 | @itemize @bullet | 376 | @itemize @bullet |
| 372 | @item | 377 | @item |
| @@ -471,10 +476,18 @@ write @code{t} and @code{nil} without single-quotes. | |||
| 471 | When a documentation string refers to a Lisp symbol, write it as it | 476 | When a documentation string refers to a Lisp symbol, write it as it |
| 472 | would be printed (which usually means in lower case), with single-quotes | 477 | would be printed (which usually means in lower case), with single-quotes |
| 473 | around it. For example: @samp{lambda}. There are two exceptions: write | 478 | around it. For example: @samp{lambda}. There are two exceptions: write |
| 474 | t and nil without single-quotes. (In this manual, we normally do use | 479 | t and nil without single-quotes. (In this manual, we use a different |
| 475 | single-quotes for those symbols.) | 480 | convention, with single-quotes for all symbols.) |
| 476 | @end ifinfo | 481 | @end ifinfo |
| 477 | 482 | ||
| 483 | For example: | ||
| 484 | |||
| 485 | @example | ||
| 486 | The value of `swim-speed' specifies how fast to swim. | ||
| 487 | Possible values are t for high speed, nil for low speed, | ||
| 488 | and `medium' for medium speed. | ||
| 489 | @end example | ||
| 490 | |||
| 478 | @item | 491 | @item |
| 479 | Don't write key sequences directly in documentation strings. Instead, | 492 | Don't write key sequences directly in documentation strings. Instead, |
| 480 | use the @samp{\\[@dots{}]} construct to stand for them. For example, | 493 | use the @samp{\\[@dots{}]} construct to stand for them. For example, |
| @@ -541,11 +554,12 @@ at that point. For example: | |||
| 541 | @end group | 554 | @end group |
| 542 | @end smallexample | 555 | @end smallexample |
| 543 | 556 | ||
| 544 | Every function that has no documentation string (because it is use only | 557 | Every function that has no documentation string (presumably one that is |
| 545 | internally within the package it belongs to), should have instead a | 558 | used only internally within the package it belongs to), should have |
| 546 | two-semicolon comment right before the function, explaining what the | 559 | instead a two-semicolon comment right before the function, explaining |
| 547 | function does and how to call it properly. Explain precisely what each | 560 | what the function does and how to call it properly. Explain precisely |
| 548 | argument means and how the function interprets its possible values. | 561 | what each argument means and how the function interprets its possible |
| 562 | values. | ||
| 549 | 563 | ||
| 550 | @item ;;; | 564 | @item ;;; |
| 551 | Comments that start with three semicolons, @samp{;;;}, should start at | 565 | Comments that start with three semicolons, @samp{;;;}, should start at |
| @@ -584,7 +598,7 @@ program. For example: | |||
| 584 | 598 | ||
| 585 | @noindent | 599 | @noindent |
| 586 | The indentation commands of the Lisp modes in Emacs, such as @kbd{M-;} | 600 | The indentation commands of the Lisp modes in Emacs, such as @kbd{M-;} |
| 587 | (@code{indent-for-comment}) and @key{TAB} (@code{lisp-indent-line}) | 601 | (@code{indent-for-comment}) and @key{TAB} (@code{lisp-indent-line}), |
| 588 | automatically indent comments according to these conventions, | 602 | automatically indent comments according to these conventions, |
| 589 | depending on the number of semicolons. @xref{Comments,, | 603 | depending on the number of semicolons. @xref{Comments,, |
| 590 | Manipulating Comments, emacs, The GNU Emacs Manual}. | 604 | Manipulating Comments, emacs, The GNU Emacs Manual}. |
| @@ -613,7 +627,9 @@ them. This section explains these conventions. First, an example: | |||
| 613 | ;; Keywords: docs | 627 | ;; Keywords: docs |
| 614 | 628 | ||
| 615 | ;; This file is part of GNU Emacs. | 629 | ;; This file is part of GNU Emacs. |
| 616 | @var{copying permissions}@dots{} | 630 | @dots{} |
| 631 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 632 | ;; Boston, MA 02111-1307, USA. | ||
| 617 | @end group | 633 | @end group |
| 618 | @end smallexample | 634 | @end smallexample |
| 619 | 635 | ||
diff --git a/lispref/variables.texi b/lispref/variables.texi index 765753d2794..4517d6bb02f 100644 --- a/lispref/variables.texi +++ b/lispref/variables.texi | |||
| @@ -38,6 +38,8 @@ variable. | |||
| 38 | * Setting Variables:: Storing new values in variables. | 38 | * Setting Variables:: Storing new values in variables. |
| 39 | * Variable Scoping:: How Lisp chooses among local and global values. | 39 | * Variable Scoping:: How Lisp chooses among local and global values. |
| 40 | * Buffer-Local Variables:: Variable values in effect only in one buffer. | 40 | * Buffer-Local Variables:: Variable values in effect only in one buffer. |
| 41 | * Frame-Local Variables:: Variable values in effect only in one frame. | ||
| 42 | * Future Local Variables:: New kinds of local values we might add some day. | ||
| 41 | @end menu | 43 | @end menu |
| 42 | 44 | ||
| 43 | @node Global Variables | 45 | @node Global Variables |
| @@ -73,7 +75,8 @@ x @result{} (a b) | |||
| 73 | @noindent | 75 | @noindent |
| 74 | assuming the @code{setq} form shown above has already been executed. | 76 | assuming the @code{setq} form shown above has already been executed. |
| 75 | 77 | ||
| 76 | If you do another @code{setq}, the new value replaces the old one: | 78 | If you do set the same variable again, the new value replaces the old |
| 79 | one: | ||
| 77 | 80 | ||
| 78 | @example | 81 | @example |
| 79 | @group | 82 | @group |
| @@ -96,14 +99,13 @@ x | |||
| 96 | @vindex t | 99 | @vindex t |
| 97 | @kindex setting-constant | 100 | @kindex setting-constant |
| 98 | 101 | ||
| 99 | In Emacs Lisp, certain symbols normally evaluate to themselves. | 102 | In Emacs Lisp, certain symbols normally evaluate to themselves. These |
| 100 | These include @code{nil} and @code{t}, as well as any symbol whose | 103 | include @code{nil} and @code{t}, as well as any symbol whose name starts |
| 101 | name starts with @samp{:}. | 104 | with @samp{:}. These symbols cannot be rebound, nor can their values be |
| 102 | 105 | changed. Any attempt to set or bind @code{nil} or @code{t} signals a | |
| 103 | The symbols @code{nil} and @code{t} @emph{always} evaluate to | 106 | @code{setting-constant} error. The same is true for a symbol whose name |
| 104 | themselves. These symbols cannot be rebound, nor can their values be | 107 | starts with @samp{:}, except that you are allowed to set such symbol to |
| 105 | changed. Any attempt to change the value of @code{nil} or @code{t} | 108 | itself. |
| 106 | signals a @code{setting-constant} error. | ||
| 107 | 109 | ||
| 108 | @example | 110 | @example |
| 109 | @group | 111 | @group |
| @@ -116,6 +118,13 @@ nil @equiv{} 'nil | |||
| 116 | @end group | 118 | @end group |
| 117 | @end example | 119 | @end example |
| 118 | 120 | ||
| 121 | @tindex keyword-symbols-constant-flag | ||
| 122 | @defvar keyword-symbols-constant-flag | ||
| 123 | If this variable is @code{nil}, you are allowed to set and bind symbols | ||
| 124 | whose names start with @samp{:} as you wish. This is to make it | ||
| 125 | possible to run old Lisp programs which do that. | ||
| 126 | @end defvar | ||
| 127 | |||
| 119 | @node Local Variables | 128 | @node Local Variables |
| 120 | @section Local Variables | 129 | @section Local Variables |
| 121 | @cindex binding local variables | 130 | @cindex binding local variables |
| @@ -125,7 +134,7 @@ nil @equiv{} 'nil | |||
| 125 | 134 | ||
| 126 | Global variables have values that last until explicitly superseded | 135 | Global variables have values that last until explicitly superseded |
| 127 | with new values. Sometimes it is useful to create variable values that | 136 | with new values. Sometimes it is useful to create variable values that |
| 128 | exist temporarily---only while within a certain part of the program. | 137 | exist temporarily---only until a certain part of the program finishes. |
| 129 | These values are called @dfn{local}, and the variables so used are | 138 | These values are called @dfn{local}, and the variables so used are |
| 130 | called @dfn{local variables}. | 139 | called @dfn{local variables}. |
| 131 | 140 | ||
| @@ -143,7 +152,7 @@ local values may be shadowed (@pxref{Scope}). | |||
| 143 | 152 | ||
| 144 | If you set a variable (such as with @code{setq}) while it is local, | 153 | If you set a variable (such as with @code{setq}) while it is local, |
| 145 | this replaces the local value; it does not alter the global value, or | 154 | this replaces the local value; it does not alter the global value, or |
| 146 | previous local values that are shadowed. To model this behavior, we | 155 | previous local values, that are shadowed. To model this behavior, we |
| 147 | speak of a @dfn{local binding} of the variable as well as a local value. | 156 | speak of a @dfn{local binding} of the variable as well as a local value. |
| 148 | 157 | ||
| 149 | The local binding is a conceptual place that holds a local value. | 158 | The local binding is a conceptual place that holds a local value. |
| @@ -161,12 +170,12 @@ not create a new binding. | |||
| 161 | A variable can have more than one local binding at a time (for | 170 | A variable can have more than one local binding at a time (for |
| 162 | example, if there are nested @code{let} forms that bind it). In such a | 171 | example, if there are nested @code{let} forms that bind it). In such a |
| 163 | case, the most recently created local binding that still exists is the | 172 | case, the most recently created local binding that still exists is the |
| 164 | @dfn{current binding} of the variable. (This is called @dfn{dynamic | 173 | @dfn{current binding} of the variable. (This rule is called |
| 165 | scoping}; see @ref{Variable Scoping}.) If there are no local bindings, | 174 | @dfn{dynamic scoping}; see @ref{Variable Scoping}.) If there are no |
| 166 | the variable's global binding is its current binding. We also call the | 175 | local bindings, the variable's global binding is its current binding. |
| 167 | current binding the @dfn{most-local existing binding}, for emphasis. | 176 | We sometimes call the current binding the @dfn{most-local existing |
| 168 | Ordinary evaluation of a symbol always returns the value of its current | 177 | binding}, for emphasis. Ordinary evaluation of a symbol always returns |
| 169 | binding. | 178 | the value of its current binding. |
| 170 | 179 | ||
| 171 | The special forms @code{let} and @code{let*} exist to create | 180 | The special forms @code{let} and @code{let*} exist to create |
| 172 | local bindings. | 181 | local bindings. |
| @@ -289,8 +298,7 @@ the error @code{void-variable}, unless and until you set it again. | |||
| 289 | 298 | ||
| 290 | @example | 299 | @example |
| 291 | @group | 300 | @group |
| 292 | (makunbound 'x) ; @r{Make the global value} | 301 | (makunbound 'x) ; @r{Make the global value of @code{x} void.} |
| 293 | ; @r{of @code{x} void.} | ||
| 294 | @result{} x | 302 | @result{} x |
| 295 | @end group | 303 | @end group |
| 296 | @group | 304 | @group |
| @@ -304,9 +312,9 @@ local existing binding. This is the only way a symbol can have a void | |||
| 304 | local binding, since all the constructs that create local bindings | 312 | local binding, since all the constructs that create local bindings |
| 305 | create them with values. In this case, the voidness lasts at most as | 313 | create them with values. In this case, the voidness lasts at most as |
| 306 | long as the binding does; when the binding is removed due to exit from | 314 | long as the binding does; when the binding is removed due to exit from |
| 307 | the construct that made it, the previous or global binding is reexposed | 315 | the construct that made it, the previous local or global binding is |
| 308 | as usual, and the variable is no longer void unless the newly reexposed | 316 | reexposed as usual, and the variable is no longer void unless the newly |
| 309 | binding was void all along. | 317 | reexposed binding was void all along. |
| 310 | 318 | ||
| 311 | @smallexample | 319 | @smallexample |
| 312 | @group | 320 | @group |
| @@ -439,9 +447,9 @@ Emacs help functions (@pxref{Documentation}) look for this property. | |||
| 439 | 447 | ||
| 440 | If the first character of @var{doc-string} is @samp{*}, it means that | 448 | If the first character of @var{doc-string} is @samp{*}, it means that |
| 441 | this variable is considered a user option. This lets users set the | 449 | this variable is considered a user option. This lets users set the |
| 442 | variable conventiently using the commands @code{set-variable} and | 450 | variable conveniently using the commands @code{set-variable} and |
| 443 | @code{edit-options}. However, it is better to use @code{defcustom} | 451 | @code{edit-options}. However, it is better to use @code{defcustom} |
| 444 | instead of @code{defvar}, for user option variables, to specify | 452 | instead of @code{defvar} for user option variables, so you can specify |
| 445 | customization information. @xref{Customization}. | 453 | customization information. @xref{Customization}. |
| 446 | 454 | ||
| 447 | Here are some examples. This form defines @code{foo} but does not | 455 | Here are some examples. This form defines @code{foo} but does not |
| @@ -580,7 +588,7 @@ entire computation of the value into the @code{defvar}, like this: | |||
| 580 | @noindent | 588 | @noindent |
| 581 | This method has several benefits. First, if the user quits while | 589 | This method has several benefits. First, if the user quits while |
| 582 | loading the file, the variable is either still uninitialized or | 590 | loading the file, the variable is either still uninitialized or |
| 583 | initialized properly, never in-between. If it is uninitialized, | 591 | initialized properly, never in-between. If it is still uninitialized, |
| 584 | reloading the file will initialize it properly. Second, reloading the | 592 | reloading the file will initialize it properly. Second, reloading the |
| 585 | file once the variable is initialized will not alter it; that is | 593 | file once the variable is initialized will not alter it; that is |
| 586 | important if the user has run hooks to alter part of the contents (such | 594 | important if the user has run hooks to alter part of the contents (such |
| @@ -620,11 +628,11 @@ each form, if you do want to reinitialize the variable. | |||
| 620 | @end example | 628 | @end example |
| 621 | 629 | ||
| 622 | @noindent | 630 | @noindent |
| 623 | This code sets the variable, then alters it, but only if the variable | 631 | This code sets the variable, then alters it, but it does so in more than |
| 624 | had been @code{ni}. If the user quits just after the @code{setq}, that | 632 | one step. If the user quits just after the @code{setq}, that leaves the |
| 625 | leaves the variable neither correctly initialized nor void nor | 633 | variable neither correctly initialized nor void nor @code{nil}. Once |
| 626 | @code{nil}. Once that happens, reloading the file will not initialize | 634 | that happens, reloading the file will not initialize the variable; it |
| 627 | the variable; it will remain incomplete. | 635 | will remain incomplete. |
| 628 | 636 | ||
| 629 | @node Accessing Variables | 637 | @node Accessing Variables |
| 630 | @section Accessing Variable Values | 638 | @section Accessing Variable Values |
| @@ -673,8 +681,8 @@ has no local bindings. | |||
| 673 | @end group | 681 | @end group |
| 674 | @end example | 682 | @end example |
| 675 | 683 | ||
| 676 | A @code{void-variable} error is signaled if @var{symbol} has neither a | 684 | A @code{void-variable} error is signaled if the current binding of |
| 677 | local binding nor a global one. | 685 | @var{symbol} is void. |
| 678 | @end defun | 686 | @end defun |
| 679 | 687 | ||
| 680 | @node Setting Variables | 688 | @node Setting Variables |
| @@ -803,6 +811,7 @@ value of @var{symbol} had better be a list already before the call. | |||
| 803 | The argument @var{symbol} is not implicitly quoted; @code{add-to-list} | 811 | The argument @var{symbol} is not implicitly quoted; @code{add-to-list} |
| 804 | is an ordinary function, like @code{set} and unlike @code{setq}. Quote | 812 | is an ordinary function, like @code{set} and unlike @code{setq}. Quote |
| 805 | the argument yourself if that is what you want. | 813 | the argument yourself if that is what you want. |
| 814 | @end defun | ||
| 806 | 815 | ||
| 807 | Here's a scenario showing how to use @code{add-to-list}: | 816 | Here's a scenario showing how to use @code{add-to-list}: |
| 808 | 817 | ||
| @@ -819,7 +828,6 @@ Here's a scenario showing how to use @code{add-to-list}: | |||
| 819 | foo ;; @r{@code{foo} was changed.} | 828 | foo ;; @r{@code{foo} was changed.} |
| 820 | @result{} (c a b) | 829 | @result{} (c a b) |
| 821 | @end example | 830 | @end example |
| 822 | @end defun | ||
| 823 | 831 | ||
| 824 | An equivalent expression for @code{(add-to-list '@var{var} | 832 | An equivalent expression for @code{(add-to-list '@var{var} |
| 825 | @var{value})} is this: | 833 | @var{value})} is this: |
| @@ -979,10 +987,11 @@ closures. | |||
| 979 | works) may help you understand dynamic binding. This technique is | 987 | works) may help you understand dynamic binding. This technique is |
| 980 | called @dfn{deep binding} and was used in early Lisp systems. | 988 | called @dfn{deep binding} and was used in early Lisp systems. |
| 981 | 989 | ||
| 982 | Suppose there is a stack of bindings: variable-value pairs. At entry | 990 | Suppose there is a stack of bindings, which are variable-value pairs. |
| 983 | to a function or to a @code{let} form, we can push bindings onto the stack | 991 | At entry to a function or to a @code{let} form, we can push bindings |
| 984 | for the arguments or local variables created there. We can pop those | 992 | onto the stack for the arguments or local variables created there. We |
| 985 | bindings from the stack at exit from the binding construct. | 993 | can pop those bindings from the stack at exit from the binding |
| 994 | construct. | ||
| 986 | 995 | ||
| 987 | We can find the value of a variable by searching the stack from top to | 996 | We can find the value of a variable by searching the stack from top to |
| 988 | bottom for a binding for that variable; the value from that binding is | 997 | bottom for a binding for that variable; the value from that binding is |
| @@ -1052,18 +1061,22 @@ use short names like @code{x}. | |||
| 1052 | @cindex buffer-local variables | 1061 | @cindex buffer-local variables |
| 1053 | 1062 | ||
| 1054 | Global and local variable bindings are found in most programming | 1063 | Global and local variable bindings are found in most programming |
| 1055 | languages in one form or another. Emacs also supports another, unusual | 1064 | languages in one form or another. Emacs also supports additional, |
| 1056 | kind of variable binding: @dfn{buffer-local} bindings, which apply only | 1065 | unusual kinds of variable binding: @dfn{buffer-local} bindings, which |
| 1057 | to one buffer. Emacs Lisp is meant for programming editing commands, | 1066 | apply only in one buffer, and frame-local bindings, which apply only in |
| 1058 | and having different values for a variable in different buffers is an | 1067 | one frame. Having different values for a variable in different buffers |
| 1059 | important customization method. (A few variables have bindings that | 1068 | and/or frames is an important customization method. |
| 1060 | are local to a given X terminal; see @ref{Multiple Displays}.) | 1069 | |
| 1070 | This section describes buffer-local bindings; for frame-local | ||
| 1071 | bindings, see the following section, @ref{Frame-Local Variables}. (A few | ||
| 1072 | variables have bindings that are local to a X terminal; see | ||
| 1073 | @ref{Multiple Displays}.) | ||
| 1061 | 1074 | ||
| 1062 | @menu | 1075 | @menu |
| 1063 | * Intro to Buffer-Local:: Introduction and concepts. | 1076 | * Intro to Buffer-Local:: Introduction and concepts. |
| 1064 | * Creating Buffer-Local:: Creating and destroying buffer-local bindings. | 1077 | * Creating Buffer-Local:: Creating and destroying buffer-local bindings. |
| 1065 | * Default Value:: The default value is seen in buffers | 1078 | * Default Value:: The default value is seen in buffers |
| 1066 | that don't have their own local values. | 1079 | that don't have their own buffer-local values. |
| 1067 | @end menu | 1080 | @end menu |
| 1068 | 1081 | ||
| 1069 | @node Intro to Buffer-Local | 1082 | @node Intro to Buffer-Local |
| @@ -1082,22 +1095,25 @@ this is the global binding. | |||
| 1082 | 1095 | ||
| 1083 | A variable can have buffer-local bindings in some buffers but not in | 1096 | A variable can have buffer-local bindings in some buffers but not in |
| 1084 | other buffers. The default binding is shared by all the buffers that | 1097 | other buffers. The default binding is shared by all the buffers that |
| 1085 | don't have their own bindings for the variable. If you set the variable | 1098 | don't have their own bindings for the variable. (This includes all |
| 1086 | in a buffer that does not have a buffer-local binding for it, this sets | 1099 | newly created buffers.) If you set the variable in a buffer that does |
| 1087 | the default binding, so the new value is visible in all the buffers that | 1100 | not have a buffer-local binding for it, this sets the default binding |
| 1088 | see the default binding. | 1101 | (assuming there are no frame-local bindings to complicate the matter), |
| 1102 | so the new value is visible in all the buffers that see the default | ||
| 1103 | binding. | ||
| 1089 | 1104 | ||
| 1090 | The most common use of buffer-local bindings is for major modes to change | 1105 | The most common use of buffer-local bindings is for major modes to change |
| 1091 | variables that control the behavior of commands. For example, C mode and | 1106 | variables that control the behavior of commands. For example, C mode and |
| 1092 | Lisp mode both set the variable @code{paragraph-start} to specify that only | 1107 | Lisp mode both set the variable @code{paragraph-start} to specify that only |
| 1093 | blank lines separate paragraphs. They do this by making the variable | 1108 | blank lines separate paragraphs. They do this by making the variable |
| 1094 | buffer-local in the buffer that is being put into C mode or Lisp mode, and | 1109 | buffer-local in the buffer that is being put into C mode or Lisp mode, and |
| 1095 | then setting it to the new value for that mode. | 1110 | then setting it to the new value for that mode. @xref{Major Modes}. |
| 1096 | 1111 | ||
| 1097 | The usual way to make a buffer-local binding is with | 1112 | The usual way to make a buffer-local binding is with |
| 1098 | @code{make-local-variable}, which is what major mode commands use. This | 1113 | @code{make-local-variable}, which is what major mode commands typically |
| 1099 | affects just the current buffer; all other buffers (including those yet to | 1114 | use. This affects just the current buffer; all other buffers (including |
| 1100 | be created) continue to share the default value. | 1115 | those yet to be created) will continue to share the default value unless |
| 1116 | they are explicitly given their own buffer-local bindings. | ||
| 1101 | 1117 | ||
| 1102 | @cindex automatically buffer-local | 1118 | @cindex automatically buffer-local |
| 1103 | A more powerful operation is to mark the variable as | 1119 | A more powerful operation is to mark the variable as |
| @@ -1107,11 +1123,11 @@ variable local in all buffers, even those yet to be created. More | |||
| 1107 | precisely, the effect is that setting the variable automatically makes | 1123 | precisely, the effect is that setting the variable automatically makes |
| 1108 | the variable local to the current buffer if it is not already so. All | 1124 | the variable local to the current buffer if it is not already so. All |
| 1109 | buffers start out by sharing the default value of the variable as usual, | 1125 | buffers start out by sharing the default value of the variable as usual, |
| 1110 | but any @code{setq} creates a buffer-local binding for the current | 1126 | but setting the variable creates a buffer-local binding for the current |
| 1111 | buffer. The new value is stored in the buffer-local binding, leaving | 1127 | buffer. The new value is stored in the buffer-local binding, leaving |
| 1112 | the default binding untouched. The default value can no longer be | 1128 | the default binding untouched. This means that the default value cannot |
| 1113 | changed with @code{setq} in this buffer; you need to use | 1129 | be changed with @code{setq} in any buffer; the only way to change it is |
| 1114 | @code{setq-default} to do that. | 1130 | with @code{setq-default}. |
| 1115 | 1131 | ||
| 1116 | @strong{Warning:} When a variable has buffer-local values in one or | 1132 | @strong{Warning:} When a variable has buffer-local values in one or |
| 1117 | more buffers, you can get Emacs very confused by binding the variable | 1133 | more buffers, you can get Emacs very confused by binding the variable |
| @@ -1161,7 +1177,8 @@ But @code{save-excursion} as shown here avoids the problem: | |||
| 1161 | buffer-local binding of buffer @samp{b}. | 1177 | buffer-local binding of buffer @samp{b}. |
| 1162 | 1178 | ||
| 1163 | When a file specifies local variable values, these become buffer-local | 1179 | When a file specifies local variable values, these become buffer-local |
| 1164 | values when you visit the file. @xref{Auto Major Mode}. | 1180 | values when you visit the file. @xref{File Variables,,, emacs, The |
| 1181 | GNU Emacs Manual}. | ||
| 1165 | 1182 | ||
| 1166 | @node Creating Buffer-Local | 1183 | @node Creating Buffer-Local |
| 1167 | @subsection Creating and Deleting Buffer-Local Bindings | 1184 | @subsection Creating and Deleting Buffer-Local Bindings |
| @@ -1209,9 +1226,10 @@ foo | |||
| 1209 | @end example | 1226 | @end example |
| 1210 | 1227 | ||
| 1211 | Making a variable buffer-local within a @code{let}-binding for that | 1228 | Making a variable buffer-local within a @code{let}-binding for that |
| 1212 | variable does not work. This is because @code{let} does not distinguish | 1229 | variable does not work reliably, unless the buffer in which you do this |
| 1213 | between different kinds of bindings; it knows only which variable the | 1230 | is not current either on entry to or exit from the @code{let}. This is |
| 1214 | binding was made for. | 1231 | because @code{let} does not distinguish between different kinds of |
| 1232 | bindings; it knows only which variable the binding was made for. | ||
| 1215 | 1233 | ||
| 1216 | If the variable is terminal-local, this function signals an error. Such | 1234 | If the variable is terminal-local, this function signals an error. Such |
| 1217 | variables cannot have buffer-local bindings as well. @xref{Multiple | 1235 | variables cannot have buffer-local bindings as well. @xref{Multiple |
| @@ -1226,16 +1244,24 @@ This function marks @var{variable} (a symbol) automatically | |||
| 1226 | buffer-local, so that any subsequent attempt to set it will make it | 1244 | buffer-local, so that any subsequent attempt to set it will make it |
| 1227 | local to the current buffer at the time. | 1245 | local to the current buffer at the time. |
| 1228 | 1246 | ||
| 1229 | The value returned is @var{variable}. | 1247 | A peculiar wrinkle of this feature is that binding the variable (with |
| 1248 | @code{let} or other binding constructs) does not create a buffer-local | ||
| 1249 | binding for it. Only setting the variable (with @code{set} or | ||
| 1250 | @code{setq}) does so. | ||
| 1230 | 1251 | ||
| 1231 | @strong{Note:} It is a mistake to use @code{make-variable-buffer-local} | 1252 | The value returned is @var{variable}. |
| 1232 | for user-option variables, simply because users @emph{might} want to | ||
| 1233 | customize them differently in different buffers. Users can make any | ||
| 1234 | variable local, when they wish to. | ||
| 1235 | 1253 | ||
| 1236 | The main use of @code{make-variable-buffer-local} is when a variable is | 1254 | @strong{Warning:} Don't assume that you should use |
| 1237 | used for internal purposes, and the Lisp program depends on having | 1255 | @code{make-variable-buffer-local} for user-option variables, simply |
| 1238 | separate values in separate buffers. | 1256 | because users @emph{might} want to customize them differently in |
| 1257 | different buffers. Users can make any variable local, when they wish | ||
| 1258 | to. It is better to leave the choice to them. | ||
| 1259 | |||
| 1260 | The time to use @code{make-variable-buffer-local} is when it is crucial | ||
| 1261 | that no two buffers ever share the same binding. For example, when a | ||
| 1262 | variable is used for internal purposes in a Lisp program which depends | ||
| 1263 | on having separate values in separate buffers, then using | ||
| 1264 | @code{make-variable-buffer-local} can be the best solution. | ||
| 1239 | @end deffn | 1265 | @end deffn |
| 1240 | 1266 | ||
| 1241 | @defun local-variable-p variable &optional buffer | 1267 | @defun local-variable-p variable &optional buffer |
| @@ -1246,11 +1272,11 @@ This returns @code{t} if @var{variable} is buffer-local in buffer | |||
| 1246 | 1272 | ||
| 1247 | @defun buffer-local-variables &optional buffer | 1273 | @defun buffer-local-variables &optional buffer |
| 1248 | This function returns a list describing the buffer-local variables in | 1274 | This function returns a list describing the buffer-local variables in |
| 1249 | buffer @var{buffer}. It returns an association list (@pxref{Association | 1275 | buffer @var{buffer}. (If @var{buffer} is omitted, the current buffer is |
| 1250 | Lists}) in which each association contains one buffer-local variable and | 1276 | used.) It returns an association list (@pxref{Association Lists}) in |
| 1251 | its value. When a buffer-local variable is void in @var{buffer}, then | 1277 | which each element contains one buffer-local variable and its value. |
| 1252 | it appears directly in the resulting list. If @var{buffer} is omitted, | 1278 | However, when a variable's buffer-local binding in @var{buffer} is void, |
| 1253 | the current buffer is used. | 1279 | then the variable appears directly in the resulting list. |
| 1254 | 1280 | ||
| 1255 | @example | 1281 | @example |
| 1256 | @group | 1282 | @group |
| @@ -1309,7 +1335,7 @@ value of @code{standard-syntax-table}, and the abbrev table to the value | |||
| 1309 | of @code{fundamental-mode-abbrev-table}. | 1335 | of @code{fundamental-mode-abbrev-table}. |
| 1310 | 1336 | ||
| 1311 | The very first thing this function does is run the normal hook | 1337 | The very first thing this function does is run the normal hook |
| 1312 | @code{change-major-mode-hook} (@pxref{Major Mode Conventions}). | 1338 | @code{change-major-mode-hook} (see below). |
| 1313 | 1339 | ||
| 1314 | Every major mode command begins by calling this function, which has the | 1340 | Every major mode command begins by calling this function, which has the |
| 1315 | effect of switching to Fundamental mode and erasing most of the effects | 1341 | effect of switching to Fundamental mode and erasing most of the effects |
| @@ -1319,6 +1345,15 @@ variables that major modes set should not be marked permanent. | |||
| 1319 | @code{kill-all-local-variables} returns @code{nil}. | 1345 | @code{kill-all-local-variables} returns @code{nil}. |
| 1320 | @end defun | 1346 | @end defun |
| 1321 | 1347 | ||
| 1348 | @defvar change-major-mode-hook | ||
| 1349 | The function @code{kill-all-local-variables} runs this normal hook | ||
| 1350 | before it does anything else. This gives major modes a way to arrange | ||
| 1351 | for something special to be done if the user switches to a different | ||
| 1352 | major mode. For best results, make this variable buffer-local, so that | ||
| 1353 | it will disappear after doing its job and will not interfere with the | ||
| 1354 | subsequent major mode. @xref{Hooks}. | ||
| 1355 | @end defvar | ||
| 1356 | |||
| 1322 | @c Emacs 19 feature | 1357 | @c Emacs 19 feature |
| 1323 | @cindex permanent local variable | 1358 | @cindex permanent local variable |
| 1324 | A buffer-local variable is @dfn{permanent} if the variable name (a | 1359 | A buffer-local variable is @dfn{permanent} if the variable name (a |
| @@ -1332,7 +1367,8 @@ came from or how to save it, rather than with how to edit the contents. | |||
| 1332 | 1367 | ||
| 1333 | The global value of a variable with buffer-local bindings is also | 1368 | The global value of a variable with buffer-local bindings is also |
| 1334 | called the @dfn{default} value, because it is the value that is in | 1369 | called the @dfn{default} value, because it is the value that is in |
| 1335 | effect except when specifically overridden. | 1370 | effect whenever neither the current buffer nor the selected frame has |
| 1371 | its own binding for the variable. | ||
| 1336 | 1372 | ||
| 1337 | The functions @code{default-value} and @code{setq-default} access and | 1373 | The functions @code{default-value} and @code{setq-default} access and |
| 1338 | change a variable's default value regardless of whether the current | 1374 | change a variable's default value regardless of whether the current |
| @@ -1345,13 +1381,13 @@ this variable. | |||
| 1345 | @c Emacs 19 feature | 1381 | @c Emacs 19 feature |
| 1346 | The special forms @code{defvar} and @code{defconst} also set the | 1382 | The special forms @code{defvar} and @code{defconst} also set the |
| 1347 | default value (if they set the variable at all), rather than any | 1383 | default value (if they set the variable at all), rather than any |
| 1348 | buffer-local value. | 1384 | buffer-local or frame-local value. |
| 1349 | 1385 | ||
| 1350 | @defun default-value symbol | 1386 | @defun default-value symbol |
| 1351 | This function returns @var{symbol}'s default value. This is the value | 1387 | This function returns @var{symbol}'s default value. This is the value |
| 1352 | that is seen in buffers that do not have their own values for this | 1388 | that is seen in buffers and frames that do not have their own values for |
| 1353 | variable. If @var{symbol} is not buffer-local, this is equivalent to | 1389 | this variable. If @var{symbol} is not buffer-local, this is equivalent |
| 1354 | @code{symbol-value} (@pxref{Accessing Variables}). | 1390 | to @code{symbol-value} (@pxref{Accessing Variables}). |
| 1355 | @end defun | 1391 | @end defun |
| 1356 | 1392 | ||
| 1357 | @c Emacs 19 feature | 1393 | @c Emacs 19 feature |
| @@ -1379,49 +1415,49 @@ current buffer sees. | |||
| 1379 | @example | 1415 | @example |
| 1380 | @group | 1416 | @group |
| 1381 | ;; @r{In buffer @samp{foo}:} | 1417 | ;; @r{In buffer @samp{foo}:} |
| 1382 | (make-local-variable 'local) | 1418 | (make-local-variable 'buffer-local) |
| 1383 | @result{} local | 1419 | @result{} buffer-local |
| 1384 | @end group | 1420 | @end group |
| 1385 | @group | 1421 | @group |
| 1386 | (setq local 'value-in-foo) | 1422 | (setq buffer-local 'value-in-foo) |
| 1387 | @result{} value-in-foo | 1423 | @result{} value-in-foo |
| 1388 | @end group | 1424 | @end group |
| 1389 | @group | 1425 | @group |
| 1390 | (setq-default local 'new-default) | 1426 | (setq-default buffer-local 'new-default) |
| 1391 | @result{} new-default | 1427 | @result{} new-default |
| 1392 | @end group | 1428 | @end group |
| 1393 | @group | 1429 | @group |
| 1394 | local | 1430 | buffer-local |
| 1395 | @result{} value-in-foo | 1431 | @result{} value-in-foo |
| 1396 | @end group | 1432 | @end group |
| 1397 | @group | 1433 | @group |
| 1398 | (default-value 'local) | 1434 | (default-value 'buffer-local) |
| 1399 | @result{} new-default | 1435 | @result{} new-default |
| 1400 | @end group | 1436 | @end group |
| 1401 | 1437 | ||
| 1402 | @group | 1438 | @group |
| 1403 | ;; @r{In (the new) buffer @samp{bar}:} | 1439 | ;; @r{In (the new) buffer @samp{bar}:} |
| 1404 | local | 1440 | buffer-local |
| 1405 | @result{} new-default | 1441 | @result{} new-default |
| 1406 | @end group | 1442 | @end group |
| 1407 | @group | 1443 | @group |
| 1408 | (default-value 'local) | 1444 | (default-value 'buffer-local) |
| 1409 | @result{} new-default | 1445 | @result{} new-default |
| 1410 | @end group | 1446 | @end group |
| 1411 | @group | 1447 | @group |
| 1412 | (setq local 'another-default) | 1448 | (setq buffer-local 'another-default) |
| 1413 | @result{} another-default | 1449 | @result{} another-default |
| 1414 | @end group | 1450 | @end group |
| 1415 | @group | 1451 | @group |
| 1416 | (default-value 'local) | 1452 | (default-value 'buffer-local) |
| 1417 | @result{} another-default | 1453 | @result{} another-default |
| 1418 | @end group | 1454 | @end group |
| 1419 | 1455 | ||
| 1420 | @group | 1456 | @group |
| 1421 | ;; @r{Back in buffer @samp{foo}:} | 1457 | ;; @r{Back in buffer @samp{foo}:} |
| 1422 | local | 1458 | buffer-local |
| 1423 | @result{} value-in-foo | 1459 | @result{} value-in-foo |
| 1424 | (default-value 'local) | 1460 | (default-value 'buffer-local) |
| 1425 | @result{} another-default | 1461 | @result{} another-default |
| 1426 | @end group | 1462 | @end group |
| 1427 | @end example | 1463 | @end example |
| @@ -1442,3 +1478,123 @@ an ordinary evaluated argument. | |||
| 1442 | @end group | 1478 | @end group |
| 1443 | @end example | 1479 | @end example |
| 1444 | @end defun | 1480 | @end defun |
| 1481 | |||
| 1482 | @node Frame-Local Variables | ||
| 1483 | @section Frame-Local Variables | ||
| 1484 | |||
| 1485 | Just as variables can have buffer-local bindings, they can also have | ||
| 1486 | frame-local bindings. These bindings belong to one frame, and are in | ||
| 1487 | effect when that frame is selected. Frame-local bindings are actually | ||
| 1488 | frame parameters: you create a frame-local binding in a specific frame | ||
| 1489 | by calling @code{modify-frame-parameters} and specifying the variable | ||
| 1490 | name as the parameter name. | ||
| 1491 | |||
| 1492 | To enable frame-local bindings for a certain variable, call the function | ||
| 1493 | @code{make-variable-frame-local}. | ||
| 1494 | |||
| 1495 | @defun make-variable-frame-local variable | ||
| 1496 | Enable the use of frame-local bindings for @var{variable}. This does | ||
| 1497 | not in itself create any frame-local bindings for the variable; however, | ||
| 1498 | if some frame already has a value for @var{variable} as a frame | ||
| 1499 | parameter, that value automatically becomes a frame-local binding. | ||
| 1500 | |||
| 1501 | If the variable is terminal-local, this function signals an error. Such | ||
| 1502 | variables cannot have buffer-local bindings as well. @xref{Multiple | ||
| 1503 | Displays}. A few variables that are implemented specially in Emacs | ||
| 1504 | can be (and usually are) buffer-local, but can never be frame-local. | ||
| 1505 | @end defun | ||
| 1506 | |||
| 1507 | Buffer-local bindings take precedence over frame-local bindings. Thus, | ||
| 1508 | consider a variable @code{foo}: if the current buffer has a buffer-local | ||
| 1509 | binding for @code{foo}, that binding is active; otherwise, if the | ||
| 1510 | selected frame has a frame-local binding for @code{foo}, that binding is | ||
| 1511 | active; otherwise, the default binding of @code{foo} is active. | ||
| 1512 | |||
| 1513 | Here is an example. First we prepare a few bindings for @code{foo}: | ||
| 1514 | |||
| 1515 | @example | ||
| 1516 | (setq f1 (selected-frame)) | ||
| 1517 | (make-variable-frame-local 'foo) | ||
| 1518 | |||
| 1519 | ;; @r{Make a buffer-local binding for @code{foo} in @samp{b1}.} | ||
| 1520 | (set-buffer (get-buffer-create "b1")) | ||
| 1521 | (make-local-variable 'foo) | ||
| 1522 | (setq foo '(b 1)) | ||
| 1523 | |||
| 1524 | ;; @r{Make a frame-local binding for @code{foo} in a new frame.} | ||
| 1525 | ;; @r{Store that frame in @code{f2}.} | ||
| 1526 | (setq f2 (make-frame)) | ||
| 1527 | (modify-frame-parameters f2 '((foo . (f 2)))) | ||
| 1528 | @end example | ||
| 1529 | |||
| 1530 | Now we examine @code{foo} in various contexts. Whenever the | ||
| 1531 | buffer @samp{b1} is current, its buffer-local binding is in effect, | ||
| 1532 | regardless of the selected frame: | ||
| 1533 | |||
| 1534 | @example | ||
| 1535 | (select-frame f1) | ||
| 1536 | (set-buffer (get-buffer-create "b1")) | ||
| 1537 | foo | ||
| 1538 | @result{} (b 1) | ||
| 1539 | |||
| 1540 | (select-frame f2) | ||
| 1541 | (set-buffer (get-buffer-create "b1")) | ||
| 1542 | foo | ||
| 1543 | @result{} (b 1) | ||
| 1544 | @end example | ||
| 1545 | |||
| 1546 | @noindent | ||
| 1547 | Otherwise, the frame gets a chance to provide the binding; when frame | ||
| 1548 | @code{f2} is selected, its frame-local binding is in effect: | ||
| 1549 | |||
| 1550 | @example | ||
| 1551 | (select-frame f2) | ||
| 1552 | (set-buffer (get-buffer "*scratch*")) | ||
| 1553 | foo | ||
| 1554 | @result{} (f 2) | ||
| 1555 | @end example | ||
| 1556 | |||
| 1557 | @noindent | ||
| 1558 | When neither the current buffer nor the selected frame provides | ||
| 1559 | a binding, the default binding is used: | ||
| 1560 | |||
| 1561 | @example | ||
| 1562 | (select-frame f1) | ||
| 1563 | (set-buffer (get-buffer "*scratch*")) | ||
| 1564 | foo | ||
| 1565 | @result{} nil | ||
| 1566 | @end example | ||
| 1567 | |||
| 1568 | @noindent | ||
| 1569 | When the active binding of a variable is a frame-local binding, setting | ||
| 1570 | the variable changes that binding. You can observe the result with | ||
| 1571 | @code{frame-parameters}: | ||
| 1572 | |||
| 1573 | @example | ||
| 1574 | (select-frame f2) | ||
| 1575 | (set-buffer (get-buffer "*scratch*")) | ||
| 1576 | (setq foo 'nobody) | ||
| 1577 | (assq 'foo (frame-parameters f2)) | ||
| 1578 | @result{} (foo . nobody) | ||
| 1579 | @end example | ||
| 1580 | |||
| 1581 | @node Future Local Variables | ||
| 1582 | @section Possible Future Local Variables | ||
| 1583 | |||
| 1584 | We have considered the idea of bindings that are local to a category | ||
| 1585 | of frames---for example, all color frames, or all frames with dark | ||
| 1586 | backgrounds. We have not implemented them because it is not clear that | ||
| 1587 | this feature is really useful. You can get more or less the same | ||
| 1588 | results by adding a function to @code{after-make-frame-hook}, set up to | ||
| 1589 | define a particular frame parameter according to the appropriate | ||
| 1590 | conditions for each frame. | ||
| 1591 | |||
| 1592 | It would also be possible to implement window-local bindings. We | ||
| 1593 | don't know of many situations where they would be useful, and it seems | ||
| 1594 | that indirect buffers (@pxref{Indirect Buffers}) with buffer-local | ||
| 1595 | bindings offer a way to handle these situations more robustly. | ||
| 1596 | |||
| 1597 | If sufficient application is found for either of these two kinds of | ||
| 1598 | local bindings, we will provide it in a subsequent Emacs version. | ||
| 1599 | |||
| 1600 | |||
diff --git a/lispref/windows.texi b/lispref/windows.texi index 6e983113f51..9199ff0f8d2 100644 --- a/lispref/windows.texi +++ b/lispref/windows.texi | |||
| @@ -246,7 +246,7 @@ Now, the screen looks like this: | |||
| 246 | @end smallexample | 246 | @end smallexample |
| 247 | 247 | ||
| 248 | Normally, Emacs indicates the border between two side-by-side windows | 248 | Normally, Emacs indicates the border between two side-by-side windows |
| 249 | with a scroll bar (@pxref{X Frame Parameters,Scroll Bars}) or @samp{|} | 249 | with a scroll bar (@pxref{Window Frame Parameters,Scroll Bars}) or @samp{|} |
| 250 | characters. The display table can specify alternative border | 250 | characters. The display table can specify alternative border |
| 251 | characters; see @ref{Display Tables}. | 251 | characters; see @ref{Display Tables}. |
| 252 | @end deffn | 252 | @end deffn |
| @@ -328,8 +328,7 @@ of a window aside from restoring a saved window configuration | |||
| 328 | deletes any windows that aren't part of that configuration. | 328 | deletes any windows that aren't part of that configuration. |
| 329 | 329 | ||
| 330 | When you delete a window, the space it took up is given to one | 330 | When you delete a window, the space it took up is given to one |
| 331 | adjacent sibling. (In Emacs version 18, the space was divided evenly | 331 | adjacent sibling. |
| 332 | among all the siblings.) | ||
| 333 | 332 | ||
| 334 | @c Emacs 19 feature | 333 | @c Emacs 19 feature |
| 335 | @defun window-live-p window | 334 | @defun window-live-p window |
| @@ -341,14 +340,10 @@ using a deleted window as if it were live. | |||
| 341 | @end defun | 340 | @end defun |
| 342 | 341 | ||
| 343 | @deffn Command delete-window &optional window | 342 | @deffn Command delete-window &optional window |
| 344 | This function removes @var{window} from the display. If @var{window} | 343 | This function removes @var{window} from display, and returns @code{nil}. |
| 345 | is omitted, then the selected window is deleted. An error is signaled | 344 | If @var{window} is omitted, then the selected window is deleted. An |
| 346 | if there is only one window when @code{delete-window} is called. | 345 | error is signaled if there is only one window when @code{delete-window} |
| 347 | 346 | is called. | |
| 348 | This function returns @code{nil}. | ||
| 349 | |||
| 350 | When @code{delete-window} is called interactively, @var{window} | ||
| 351 | defaults to the selected window. | ||
| 352 | @end deffn | 347 | @end deffn |
| 353 | 348 | ||
| 354 | @deffn Command delete-other-windows &optional window | 349 | @deffn Command delete-other-windows &optional window |
| @@ -356,7 +351,7 @@ This function makes @var{window} the only window on its frame, by | |||
| 356 | deleting the other windows in that frame. If @var{window} is omitted or | 351 | deleting the other windows in that frame. If @var{window} is omitted or |
| 357 | @code{nil}, then the selected window is used by default. | 352 | @code{nil}, then the selected window is used by default. |
| 358 | 353 | ||
| 359 | The result is @code{nil}. | 354 | The return value is @code{nil}. |
| 360 | @end deffn | 355 | @end deffn |
| 361 | 356 | ||
| 362 | @deffn Command delete-windows-on buffer &optional frame | 357 | @deffn Command delete-windows-on buffer &optional frame |
| @@ -426,7 +421,7 @@ or contents of windows; therefore, if the @var{forms} change them, | |||
| 426 | the change persists. | 421 | the change persists. |
| 427 | 422 | ||
| 428 | Each frame, at any time, has a window selected within the frame. This | 423 | Each frame, at any time, has a window selected within the frame. This |
| 429 | macro only saves @emph{the} selected window; it does not save anything | 424 | macro saves only @emph{the} selected window; it does not save anything |
| 430 | about other frames. If the @var{forms} select some other frame and | 425 | about other frames. If the @var{forms} select some other frame and |
| 431 | alter the window selected within it, the change persists. | 426 | alter the window selected within it, the change persists. |
| 432 | @end defmac | 427 | @end defmac |
| @@ -565,8 +560,8 @@ include in the cycle, as in @code{next-window}. | |||
| 565 | 560 | ||
| 566 | @deffn Command other-window count | 561 | @deffn Command other-window count |
| 567 | This function selects the @var{count}th following window in the cyclic | 562 | This function selects the @var{count}th following window in the cyclic |
| 568 | order. If count is negative, then it selects the @minus{}@var{count}th | 563 | order. If count is negative, then it moves back @minus{}@var{count} |
| 569 | preceding window. It returns @code{nil}. | 564 | windows in the cycle, rather than forward. It returns @code{nil}. |
| 570 | 565 | ||
| 571 | In an interactive call, @var{count} is the numeric prefix argument. | 566 | In an interactive call, @var{count} is the numeric prefix argument. |
| 572 | @end deffn | 567 | @end deffn |
| @@ -695,7 +690,7 @@ low-level functions that give you more precise control. | |||
| 695 | Do not use the functions in this section in order to make a buffer | 690 | Do not use the functions in this section in order to make a buffer |
| 696 | current so that a Lisp program can access or modify it; they are too | 691 | current so that a Lisp program can access or modify it; they are too |
| 697 | drastic for that purpose, since they change the display of buffers in | 692 | drastic for that purpose, since they change the display of buffers in |
| 698 | windows, which is gratuitous and will surprise the user. Instead, use | 693 | windows, which would be gratuitous and surprise the user. Instead, use |
| 699 | @code{set-buffer} (@pxref{Current Buffer}) and @code{save-excursion} | 694 | @code{set-buffer} (@pxref{Current Buffer}) and @code{save-excursion} |
| 700 | (@pxref{Excursions}), which designate buffers as current for programmed | 695 | (@pxref{Excursions}), which designate buffers as current for programmed |
| 701 | access without affecting the display of buffers in windows. | 696 | access without affecting the display of buffers in windows. |
| @@ -713,8 +708,9 @@ buffer by that name is created. The major mode for the new buffer is | |||
| 713 | set according to the variable @code{default-major-mode}. @xref{Auto | 708 | set according to the variable @code{default-major-mode}. @xref{Auto |
| 714 | Major Mode}. | 709 | Major Mode}. |
| 715 | 710 | ||
| 716 | Normally the specified buffer is put at the front of the buffer list. | 711 | Normally the specified buffer is put at the front of the buffer list |
| 717 | This affects the operation of @code{other-buffer}. However, if | 712 | (both the selected frame's buffer list and the frame-independent buffer |
| 713 | list). This affects the operation of @code{other-buffer}. However, if | ||
| 718 | @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer | 714 | @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer |
| 719 | List}. | 715 | List}. |
| 720 | 716 | ||
| @@ -792,7 +788,7 @@ This function returns @code{nil}. | |||
| 792 | 788 | ||
| 793 | @tindex buffer-display-count | 789 | @tindex buffer-display-count |
| 794 | @defvar buffer-display-count | 790 | @defvar buffer-display-count |
| 795 | This variable is always local in each buffer. When the buffer is | 791 | This variable is always buffer-local in each buffer. When the buffer is |
| 796 | created, @code{buffer-display-count} has value 0. Each time the buffer | 792 | created, @code{buffer-display-count} has value 0. Each time the buffer |
| 797 | is displayed in a window, that increments the value of | 793 | is displayed in a window, that increments the value of |
| 798 | @code{buffer-display-count}. | 794 | @code{buffer-display-count}. |
| @@ -965,7 +961,8 @@ described above. | |||
| 965 | @c Emacs 19 feature | 961 | @c Emacs 19 feature |
| 966 | @cindex dedicated window | 962 | @cindex dedicated window |
| 967 | A window can be marked as ``dedicated'' to its buffer. Then | 963 | A window can be marked as ``dedicated'' to its buffer. Then |
| 968 | @code{display-buffer} does not try to use that window. | 964 | @code{display-buffer} will not try to use that window to display any |
| 965 | other buffer. | ||
| 969 | 966 | ||
| 970 | @defun window-dedicated-p window | 967 | @defun window-dedicated-p window |
| 971 | This function returns @code{t} if @var{window} is marked as dedicated; | 968 | This function returns @code{t} if @var{window} is marked as dedicated; |
| @@ -1069,32 +1066,23 @@ For a realistic example of using @code{window-start}, see the | |||
| 1069 | description of @code{count-lines} in @ref{Text Lines}. | 1066 | description of @code{count-lines} in @ref{Text Lines}. |
| 1070 | @end defun | 1067 | @end defun |
| 1071 | 1068 | ||
| 1072 | @defun window-end &optional window | 1069 | @defun window-end &optional window update |
| 1073 | This function returns the position of the end of the display in window | 1070 | This function returns the position of the end of the display in window |
| 1074 | @var{window}. If @var{window} is @code{nil}, the selected window is | 1071 | @var{window}. If @var{window} is @code{nil}, the selected window is |
| 1075 | used. | 1072 | used. |
| 1076 | 1073 | ||
| 1077 | Simply changing the buffer text or moving point does not update the | 1074 | Simply changing the buffer text or moving point does not update the |
| 1078 | value that @code{window-end} returns. The value is updated only when | 1075 | value that @code{window-end} returns. The value is updated only when |
| 1079 | Emacs redisplays and redisplay actually finishes. | 1076 | Emacs redisplays and redisplay completes without being preempted. |
| 1080 | 1077 | ||
| 1081 | If the last redisplay of @var{window} was preempted, and did not finish, | 1078 | If the last redisplay of @var{window} was preempted, and did not finish, |
| 1082 | Emacs does not know the position of the end of display in that window. | 1079 | Emacs does not know the position of the end of display in that window. |
| 1083 | In that case, this function returns a value that is not correct. In a | 1080 | In that case, this function returns @code{nil}. |
| 1084 | future version, @code{window-end} will return @code{nil} in that case. | ||
| 1085 | @ignore | ||
| 1086 | in that case, this function returns @code{nil}. You can compute where | ||
| 1087 | the end of the window @emph{would} have been, if redisplay had finished, | ||
| 1088 | like this: | ||
| 1089 | 1081 | ||
| 1090 | @example | 1082 | If you @var{update} is non-@code{nil}, @code{window-end} always returns |
| 1091 | (save-excursion | 1083 | an up-to-date value for where the window ends. If the saved value is |
| 1092 | (goto-char (window-start window)) | 1084 | valid, @code{window-end} returns that; otherwise it computes the correct |
| 1093 | (vertical-motion (1- (window-height window)) | 1085 | value by scanning the buffer text. |
| 1094 | window) | ||
| 1095 | (point)) | ||
| 1096 | @end example | ||
| 1097 | @end ignore | ||
| 1098 | @end defun | 1086 | @end defun |
| 1099 | 1087 | ||
| 1100 | @defun set-window-start window position &optional noforce | 1088 | @defun set-window-start window position &optional noforce |
| @@ -1428,10 +1416,10 @@ characters that separates side-by-side windows. | |||
| 1428 | The following three functions return size information about a window: | 1416 | The following three functions return size information about a window: |
| 1429 | 1417 | ||
| 1430 | @defun window-height &optional window | 1418 | @defun window-height &optional window |
| 1431 | This function returns the number of lines in @var{window}, including | 1419 | This function returns the number of lines in @var{window}, including its |
| 1432 | its mode line. If @var{window} fills its entire frame, this is one less | 1420 | mode line. If @var{window} fills its entire frame, this is typically |
| 1433 | than the value of @code{frame-height} on that frame (since the last line | 1421 | one less than the value of @code{frame-height} on that frame (since the |
| 1434 | is always reserved for the minibuffer). | 1422 | last line is always reserved for the minibuffer). |
| 1435 | 1423 | ||
| 1436 | If @var{window} is @code{nil}, the function uses the selected window. | 1424 | If @var{window} is @code{nil}, the function uses the selected window. |
| 1437 | 1425 | ||
| @@ -1654,16 +1642,9 @@ If you omit @var{frame}, the selected frame is used. | |||
| 1654 | This function checks whether a particular frame position falls within | 1642 | This function checks whether a particular frame position falls within |
| 1655 | the window @var{window}. | 1643 | the window @var{window}. |
| 1656 | 1644 | ||
| 1657 | @need 3000 | 1645 | The argument @var{coordinates} is a cons cell of the form @code{(@var{x} |
| 1658 | The argument @var{coordinates} is a cons cell of this form: | 1646 | . @var{y})}. The coordinates @var{x} and @var{y} are measured in |
| 1659 | 1647 | characters, and count from the top left corner of the screen or frame. | |
| 1660 | @example | ||
| 1661 | (@var{x} . @var{y}) | ||
| 1662 | @end example | ||
| 1663 | |||
| 1664 | @noindent | ||
| 1665 | The coordinates @var{x} and @var{y} are measured in characters, and | ||
| 1666 | count from the top left corner of the screen or frame. | ||
| 1667 | 1648 | ||
| 1668 | The value returned by @code{coordinates-in-window-p} is non-@code{nil} | 1649 | The value returned by @code{coordinates-in-window-p} is non-@code{nil} |
| 1669 | if the coordinates are inside @var{window}. The value also indicates | 1650 | if the coordinates are inside @var{window}. The value also indicates |
| @@ -1713,7 +1694,9 @@ This function returns a new object representing the selected frame's | |||
| 1713 | current window configuration, including the number of windows, their | 1694 | current window configuration, including the number of windows, their |
| 1714 | sizes and current buffers, which window is the selected window, and for | 1695 | sizes and current buffers, which window is the selected window, and for |
| 1715 | each window the displayed buffer, the display-start position, and the | 1696 | each window the displayed buffer, the display-start position, and the |
| 1716 | positions of point and the mark. An exception is made for point in the | 1697 | positions of point and the mark. It also includes the values of |
| 1698 | @code{window-min-height}, @code{window-min-width} and | ||
| 1699 | @code{minibuffer-scroll-window}. An exception is made for point in the | ||
| 1717 | current buffer, whose value is not saved. | 1700 | current buffer, whose value is not saved. |
| 1718 | @end defun | 1701 | @end defun |
| 1719 | 1702 | ||
| @@ -1721,14 +1704,17 @@ current buffer, whose value is not saved. | |||
| 1721 | This function restores the configuration of windows and buffers as | 1704 | This function restores the configuration of windows and buffers as |
| 1722 | specified by @var{configuration}. The argument @var{configuration} must | 1705 | specified by @var{configuration}. The argument @var{configuration} must |
| 1723 | be a value that was previously returned by | 1706 | be a value that was previously returned by |
| 1724 | @code{current-window-configuration}. This function operates on the | 1707 | @code{current-window-configuration}. This configuration is restored in |
| 1725 | frame for which @var{configuration} was made, whether that frame is | 1708 | the frame from which @var{configuration} was made, whether that frame is |
| 1726 | selected or not. | 1709 | selected or not. This always counts as a window size change and |
| 1727 | 1710 | triggers execution of the @code{window-size-change-functions} | |
| 1728 | This function always counts as a window size change and triggers | 1711 | (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't |
| 1729 | execution of the @code{window-size-change-functions}. (It doesn't know | 1712 | know how to tell whether the new configuration actually differs from the |
| 1730 | how to tell whether the new configuration actually differs from the old | 1713 | old one. |
| 1731 | one.) | 1714 | |
| 1715 | If the frame which @var{configuration} was saved from is dead, all this | ||
| 1716 | function does is restore the three variables @code{window-min-height}, | ||
| 1717 | @code{window-min-width} and @code{minibuffer-scroll-window}. | ||
| 1732 | 1718 | ||
| 1733 | Here is a way of using this function to get the same effect | 1719 | Here is a way of using this function to get the same effect |
| 1734 | as @code{save-window-excursion}: | 1720 | as @code{save-window-excursion}: |
| @@ -1786,6 +1772,17 @@ For example: | |||
| 1786 | This function returns @code{t} if @var{object} is a window configuration. | 1772 | This function returns @code{t} if @var{object} is a window configuration. |
| 1787 | @end defun | 1773 | @end defun |
| 1788 | 1774 | ||
| 1775 | @defun compare-window-configurations config1 config2 | ||
| 1776 | This function compares two window configurations as regards the | ||
| 1777 | structure of windows, but ignores the values of point and mark and the | ||
| 1778 | saved scrolling positions---it can return @code{t} even if those | ||
| 1779 | aspects differ. | ||
| 1780 | |||
| 1781 | The function @code{equal} can also compare two window configurations; it | ||
| 1782 | regards configurations as unequal if they differ in any respect, even a | ||
| 1783 | saved point or mark. | ||
| 1784 | @end defun | ||
| 1785 | |||
| 1789 | Primitives to look inside of window configurations would make sense, | 1786 | Primitives to look inside of window configurations would make sense, |
| 1790 | but none are implemented. It is not clear they are useful enough to be | 1787 | but none are implemented. It is not clear they are useful enough to be |
| 1791 | worth implementing. | 1788 | worth implementing. |
| @@ -1799,8 +1796,8 @@ There are three actions that can change this: scrolling the window, | |||
| 1799 | switching buffers in the window, and changing the size of the window. | 1796 | switching buffers in the window, and changing the size of the window. |
| 1800 | The first two actions run @code{window-scroll-functions}; the last runs | 1797 | The first two actions run @code{window-scroll-functions}; the last runs |
| 1801 | @code{window-size-change-functions}. The paradigmatic use of these | 1798 | @code{window-size-change-functions}. The paradigmatic use of these |
| 1802 | hooks is Lazy Lock mode; see @ref{Support Modes, Lazy Lock, Font Lock | 1799 | hooks is in the implementation of Lazy Lock mode; see @ref{Support |
| 1803 | Support Modes, emacs, The GNU Emacs Manual}. | 1800 | Modes, Lazy Lock, Font Lock Support Modes, emacs, The GNU Emacs Manual}. |
| 1804 | 1801 | ||
| 1805 | @defvar window-scroll-functions | 1802 | @defvar window-scroll-functions |
| 1806 | This variable holds a list of functions that Emacs should call before | 1803 | This variable holds a list of functions that Emacs should call before |