aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-20 17:43:57 +0000
committerRichard M. Stallman1998-04-20 17:43:57 +0000
commit969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch)
tree5d7d0399caf410b5c4849aa9d43352b18f68d4c9
parentb933f645ac70a31659f364cabf7da730d27eb244 (diff)
downloademacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz
emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip
*** empty log message ***
-rw-r--r--lispref/abbrevs.texi6
-rw-r--r--lispref/anti.texi5
-rw-r--r--lispref/backups.texi8
-rw-r--r--lispref/buffers.texi59
-rw-r--r--lispref/calendar.texi2
-rw-r--r--lispref/commands.texi290
-rw-r--r--lispref/compile.texi99
-rw-r--r--lispref/control.texi46
-rw-r--r--lispref/customize.texi342
-rw-r--r--lispref/debugging.texi86
-rw-r--r--lispref/display.texi281
-rw-r--r--lispref/edebug.texi164
-rw-r--r--lispref/errors.texi29
-rw-r--r--lispref/eval.texi20
-rw-r--r--lispref/files.texi203
-rw-r--r--lispref/frames.texi246
-rw-r--r--lispref/functions.texi92
-rw-r--r--lispref/help.texi94
-rw-r--r--lispref/internals.texi228
-rw-r--r--lispref/intro.texi109
-rw-r--r--lispref/keymaps.texi301
-rw-r--r--lispref/lists.texi87
-rw-r--r--lispref/loading.texi78
-rw-r--r--lispref/locals.texi104
-rw-r--r--lispref/macros.texi81
-rw-r--r--lispref/maps.texi15
-rw-r--r--lispref/markers.texi42
-rw-r--r--lispref/minibuf.texi159
-rw-r--r--lispref/modes.texi609
-rw-r--r--lispref/nonascii.texi215
-rw-r--r--lispref/numbers.texi41
-rw-r--r--lispref/objects.texi335
-rw-r--r--lispref/os.texi219
-rw-r--r--lispref/positions.texi9
-rw-r--r--lispref/processes.texi107
-rw-r--r--lispref/searching.texi245
-rw-r--r--lispref/sequences.texi272
-rw-r--r--lispref/streams.texi71
-rw-r--r--lispref/strings.texi127
-rw-r--r--lispref/symbols.texi23
-rw-r--r--lispref/syntax.texi177
-rw-r--r--lispref/text.texi208
-rw-r--r--lispref/tips.texi68
-rw-r--r--lispref/variables.texi338
-rw-r--r--lispref/windows.texi119
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.
54If the value is @code{nil}, abbrevs may be defined, but they are not 54If the value is @code{nil}, abbrevs may be defined, but they are not
55expanded automatically. 55expanded automatically.
56 56
57This variable automatically becomes local when set in any fashion. 57This 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.
337This is the local abbrev table used in Text mode. 337This is the local abbrev table used in Text mode.
338@end defvar 338@end defvar
339 339
340@defvar c-mode-abbrev-table
341This 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
345This is the local abbrev table used in Lisp mode and Emacs Lisp mode. 341This 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,
144the minibuffer value really will contain text properties. 144the minibuffer value really will contain text properties.
145 145
146@item 146@item
147Only the simple menu item format is supported (@pxref{Simple Menu Items}).
148
149@item
147You can still bind @code{x-resource-class} around a call to 150You 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
225know. 228know.
226 229
227@item 230@item
228You can't do date arithmentic with @code{encode-time} any more. 231You can't do date arithmetic with @code{encode-time} any more.
229 232
230@item 233@item
231The functions @code{command-execute} and @code{call-interactively} no 234The 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 \
445of current buffer. 444of 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
550used to detect a substantial decrease in size, and turn off auto-saving 548used to detect a substantial decrease in size, and turn off auto-saving
551in response. 549in response.
552 550
553If it is -1, that means auto-saving is temporarily shut off in this 551If it is @minus{}1, that means auto-saving is temporarily shut off in this
554buffer due to a substantial deletion. Explicitly saving the buffer 552buffer due to a substantial deletion. Explicitly saving the buffer
555stores a positive value in this variable, thus reenabling auto-saving. 553stores a positive value in this variable, thus reenabling auto-saving.
556Turning auto-save mode off or on also alters this variable. 554Turning 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
133This function binds a local variable to the current buffer, and then 133This function binds a local variable to record the current buffer, and
134@code{save-current-buffer} records which buffer that was. Next, 134then @code{save-current-buffer} arranges to make it current again.
135@code{set-buffer} makes another buffer current. Finally, 135Next, @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
137current buffer to the new current buffer. 137current 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,
140the next redisplay will show how its text has changed. Otherwise, you 140the 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...
206The @code{save-current-buffer} macro saves the identity of the current 206The @code{save-current-buffer} macro saves the identity of the current
207buffer, evaluates the @var{body} forms, and finally restores the buffer. 207buffer, evaluates the @var{body} forms, and finally restores that buffer
208The return value is the value of the last form in @var{body}. The 208as current. The return value is the value of the last form in
209current 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}). 210exit via @code{throw} or error (@pxref{Nonlocal Exits}).
211 211
212If the buffer that used to be current has been killed by the time of 212If the buffer that used to be current has been killed by the time of
213exit from @code{save-current-buffer}, then it is not made current again, 213exit 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
385It is risky to change this variable's value without doing various other 385It is risky to change this variable's value without doing various other
386things. See the definition of @code{set-visited-file-name} in 386things. 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 387below); some of the things done there, such as changing the buffer name,
388buffer name, are not strictly necessary, but others are essential to 388are not strictly necessary, but others are essential to avoid confusing
389avoid confusing Emacs. 389Emacs.
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}.
399This buffer-local variable holds the file number and directory device 399This buffer-local variable holds the file number and directory device
400number of the file visited in the current buffer, or @code{nil} if no 400number of the file visited in the current buffer, or @code{nil} if no
401file or a nonexistent file is visited. It is a permanent local, 401file or a nonexistent file is visited. It is a permanent local,
402unaffected by @code{kill-local-variables}. @xref{Truenames}. 402unaffected by @code{kill-local-variables}.
403 403
404The value is normally a list of the form @code{(@var{filenum} 404The 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
444When the function @code{set-visited-file-name} is called interactively, it 444When the function @code{set-visited-file-name} is called interactively, it
445prompts for @var{filename} in the minibuffer. 445prompts for @var{filename} in the minibuffer.
446
447See 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
670user also follows this order. 667user 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
673This function returns a list of all buffers, including those whose names 670own version of the buffer list, in which the buffers that have been
674begin with a space. The elements are actual buffers, not their names. 671selected in that frame come first, starting with the buffers most
672recently selected @emph{in that frame}. (This order is recorded in
673@var{frame}'s @code{buffer-list} frame parameter; see @ref{Window Frame
674Parameters}.) The buffers that were never selected in @var{frame} come
675afterward, ordered according to the fundamental Emacs buffer list.
675 676
676If @var{frame} is @code{nil}, all the buffers appear in order of most 677@defun buffer-list &optional frame
677recent selection, regardless of which frames they were selected in. 678This function returns the buffer list, including all buffers, even those
679whose names begin with a space. The elements are actual buffers, not
680their names.
678 681
679If @var{frame} is a frame, then the buffers that have been selected in 682If @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:
681selection in @var{frame}. (This order is recorded in @var{frame}'s 684all the buffers appear in order of most recent selection, regardless of
682@code{buffer-list} frame parameter; see @ref{X Frame Parameters}.) The 685which frames they were selected in.
683buffers that were never selected in @var{frame} come afterward, ordered
684according 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.
735If the selected frame has a non-@code{nil} @code{buffer-predicate} 736If the selected frame has a non-@code{nil} @code{buffer-predicate}
736parameter, then @code{other-buffer} uses that predicate to decide which 737parameter, then @code{other-buffer} uses that predicate to decide which
737buffers to consider. It calls the predicate once for each buffer, and 738buffers to consider. It calls the predicate once for each buffer, and
738if the value is @code{nil}, that buffer is ignored. @xref{X Frame 739if the value is @code{nil}, that buffer is ignored. @xref{Window Frame
739Parameters}. 740Parameters}.
740 741
741@c Emacs 19 feature 742@c Emacs 19 feature
@@ -946,7 +947,7 @@ themselves.
946completely separate. They have different names, different values of 947completely separate. They have different names, different values of
947point, different narrowing, different markers and overlays (though 948point, different narrowing, different markers and overlays (though
948inserting or deleting text in either buffer relocates the markers and 949inserting or deleting text in either buffer relocates the markers and
949overlays for both), different major modes, and different local 950overlays for both), different major modes, and different buffer-local
950variables. 951variables.
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
386Arbitrary text, read in the minibuffer and returned as a string 386Arbitrary 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
389these characters in the input.) Prompt. 389these 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
403A Lisp object, specified with its read syntax, terminated with a 403A 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
405Minibuffer}. Prompt. 405Minibuffer}. 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
483primitive functions. 483primitive functions.
484 484
485A symbol is @code{commandp} if its function definition is 485A symbol satisfies @code{commandp} if its function definition satisfies
486@code{commandp}. 486@code{commandp}.
487 487
488Keys and keymaps are not commands. Rather, they are used to look up 488Keys 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
507an argument. @xref{Command History}. 507an argument. @xref{Command History}.
508 508
509The argument @var{keys}, if given, specifies the sequence of events to 509The argument @var{keys}, if given, specifies the sequence of events to
510use if the command inquires which events were used to invoke it. 510supply 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
527rechecking the definition of the symbol. 527rechecking the definition of the symbol.
528 528
529The argument @var{keys}, if given, specifies the sequence of events to 529The argument @var{keys}, if given, specifies the sequence of events to
530use if the command inquires which events were used to invoke it. 530supply 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
571directly from the editor command loop.) If the containing function was 571directly from the editor command loop.) If the containing function was
572called by Lisp evaluation (or with @code{apply} or @code{funcall}), then 572called by Lisp evaluation (or with @code{apply} or @code{funcall}), then
573it was not called interactively. 573it was not called interactively.
574@end defun
574 575
575The 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
576print an informative message. As a special exception, 577print 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
578being run. This is to suppress the informative messages and speed 579being run. This is to suppress the informative messages and speed
579execution of the macro. 580execution of the macro.
580 581
581For 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
617argument @code{print-message} which should be non-@code{nil} in an
618interactive call, and use the @code{interactive} spec to make sure it is
619non-@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
705Like @code{this-command-keys}, except that it always returns
706the events in a vector, so you do never need to deal with the complexities
707of storing input events in a string (@pxref{Strings of Events}).
708@end defun
709
690@defvar last-nonmenu-event 710@defvar last-nonmenu-event
691This variable holds the last input event read as part of a key 711This variable holds the last input event read as part of a key sequence,
692sequence, not counting events resulting from mouse menus. 712not counting events resulting from mouse menus.
693 713
694One use of this variable is for telling @code{x-popup-menu} where to pop 714One use of this variable is for telling @code{x-popup-menu} where to pop
695up a menu. 715up 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
766There are two kinds of input you can get from the keyboard: ordinary 787There are two kinds of input you can get from the keyboard: ordinary
767keys, and function keys. Ordinary keys correspond to characters; the 788keys, and function keys. Ordinary keys correspond to characters; the
768events they generate are represented in Lisp as characters. In Emacs 789events they generate are represented in Lisp as characters. The event
769versions 18 and earlier, characters were the only events. The event 790type of a character event is the character itself (an integer); see
770type of a character event is the character itself (an integer); 791@ref{Classifying Events}.
771see @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
780The 800The
781@iftex 801@tex
782$2^{27}$ 802$2^{27}$
783@end iftex 803@end tex
784@ifinfo 804@ifinfo
7852**27 8052**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
791The 811The
792@iftex 812@tex
793$2^{26}$ 813$2^{26}$
794@end iftex 814@end tex
795@ifinfo 815@ifinfo
7962**26 8162**26
797@end ifinfo 817@end ifinfo
@@ -805,9 +825,9 @@ Thus, the code for @kbd{C-a} is just 1.
805But if you type a control combination not in @sc{ASCII}, such as 825But 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
807for @kbd{%} plus 827for @kbd{%} plus
808@iftex 828@tex
809$2^{26}$ 829$2^{26}$
810@end iftex 830@end tex
811@ifinfo 831@ifinfo
8122**26 8322**26
813@end ifinfo 833@end ifinfo
@@ -816,9 +836,9 @@ control characters).
816 836
817@item shift 837@item shift
818The 838The
819@iftex 839@tex
820$2^{25}$ 840$2^{25}$
821@end iftex 841@end tex
822@ifinfo 842@ifinfo
8232**25 8432**25
824@end ifinfo 844@end ifinfo
@@ -829,9 +849,9 @@ For letters, the basic code itself indicates upper versus lower case;
829for digits and punctuation, the shift key selects an entirely different 849for digits and punctuation, the shift key selects an entirely different
830character with a different basic code. In order to keep within the 850character 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
8362**25 8562**25
837@end ifinfo 857@end ifinfo
@@ -839,9 +859,9 @@ bit for those characters.
839 859
840However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from 860However, @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
8462**25 8662**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
852The 872The
853@iftex 873@tex
854$2^{24}$ 874$2^{24}$
855@end iftex 875@end tex
856@ifinfo 876@ifinfo
8572**24 8772**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
863The 883The
864@iftex 884@tex
865$2^{23}$ 885$2^{23}$
866@end iftex 886@end tex
867@ifinfo 887@ifinfo
8682**23 8882**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
874The 894The
875@iftex 895@tex
876$2^{22}$ 896$2^{22}$
877@end iftex 897@end tex
878@ifinfo 898@ifinfo
8792**22 8992**22
880@end ifinfo 900@end ifinfo
@@ -1119,12 +1139,13 @@ events (@pxref{Click Events}), except that the @var{event-type} symbol
1119name contains the prefix @samp{down-}. The @samp{down-} prefix follows 1139name contains the prefix @samp{down-}. The @samp{down-} prefix follows
1120modifier key prefixes such as @samp{C-} and @samp{M-}. 1140modifier key prefixes such as @samp{C-} and @samp{M-}.
1121 1141
1122The function @code{read-key-sequence}, and therefore the Emacs command 1142The function @code{read-key-sequence} ignores any button-down events
1123loop as well, ignore any button-down events that don't have command 1143that don't have command bindings; therefore, the Emacs command loop
1124bindings. This means that you need not worry about defining button-down 1144ignores them too. This means that you need not worry about defining
1125events unless you want them to do something. The usual reason to define 1145button-down events unless you want them to do something. The usual
1126a button-down event is so that you can track mouse motion (by reading 1146reason to define a button-down event is so that you can track mouse
1127motion events) until the button is released. @xref{Motion Events}. 1147motion (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
1220represented by lists that look like this: 1241represented 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
1227The second element of the list describes the current position of the 1247The 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}).
1230The special form @code{track-mouse} enables generation of motion events 1250The special form @code{track-mouse} enables generation of motion events
1231within its body. Outside of @code{track-mouse} forms, Emacs does not 1251within its body. Outside of @code{track-mouse} forms, Emacs does not
1232generate events for mere motion of the mouse, and these events do not 1252generate events for mere motion of the mouse, and these events do not
1233appear. 1253appear. @xref{Mouse Tracking}.
1234
1235@defspec track-mouse body@dots{}
1236This special form executes @var{body}, with generation of mouse motion
1237events enabled. Typically @var{body} would use @code{read-event}
1238to read the motion events and modify the display accordingly.
1239
1240When the user releases the button, that generates a click event.
1241Typically, @var{body} should return when it sees the click event, and
1242discard 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,
1454a mouse button or motion event. 1464a 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
1457mouse-button event. The position is a list of this form: 1467mouse-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
1477position such events have. 1487position 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
1481various parts of it. 1491return various parts of it.
1482 1492
1483@defun posn-window position 1493@defun posn-window position
1484Return the window that @var{position} is in. 1494Return the window that @var{position} is in.
@@ -1503,6 +1513,8 @@ a cons cell @code{(@var{col} . @var{row})}. These are computed from the
1503Return the timestamp in @var{position}. 1513Return 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
1507This function returns the fractional vertical position of a scroll bar 1519This function returns the fractional vertical position of a scroll bar
1508event within the scroll bar. The value is a cons cell 1520event within the scroll bar. The value is a cons cell
@@ -1537,28 +1549,59 @@ of a pair of x and y coordinates.
1537string as containing text characters---the same kind of characters found 1549string as containing text characters---the same kind of characters found
1538in buffers or files. Occasionally Lisp programs use strings that 1550in buffers or files. Occasionally Lisp programs use strings that
1539conceptually contain keyboard characters; for example, they may be key 1551conceptually contain keyboard characters; for example, they may be key
1540sequences or keyboard macro definitions. There are special rules for 1552sequences or keyboard macro definitions. However, storing keyboard
1541how to put keyboard characters into a string, because they are not 1553characters in a string is a complex matter, for reasons of historical
1542limited to the range of 0 to 255 as text characters are. 1554compatibility, and it is not always possible.
1555
1556 We recommend that new programs avoid dealing with these complexities
1557by not storing keyboard events in strings. Here is how to do that:
1558
1559@itemize @bullet
1560@item
1561Use vectors instead of strings for key sequences, when you plan to use
1562them 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
1568Use vectors to write key sequence constants containing meta characters,
1569even when passing them directly to @code{define-key}.
1570
1571@item
1572When you have to look at the contents of a key sequence that might be a
1573string, use @code{listify-key-sequence} (@pxref{Event Input Misc})
1574first, 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 1578characters can include. Aside from the Meta modifier, none of these
1546@iftex 1579modifier bits can be included in a string, and the Meta modifier is
1580allowed only in special cases.
1581
1582 The earliest GNU Emacs versions represented meta characters as codes
1583in the range of 128 to 255. At that time, the basic character codes
1584ranged from 0 to 127, so all keyboard character codes did fit in a
1585string. Many Lisp programs used @samp{\M-} in string constants to stand
1586for meta characters, especially in arguments to @code{define-key} and
1587similar functions, and key sequences and sequences of events were always
1588represented as strings.
1589
1590 When we added support for larger basic character codes beyond 127, and
1591additional modifier bits, we had to change the representation of meta
1592characters. Now the flag that represents the Meta modifier in a
1593character is
1594@tex
1547$2^{27}$ 1595$2^{27}$
1548@end iftex 1596@end tex
1549@ifinfo 1597@ifinfo
15502**27 15982**27
1551@end ifinfo 1599@end ifinfo
1552bit; it does not even come close to fitting in a string. However, 1600and such numbers cannot be included in a string.
1553earlier Emacs versions used a different representation for these
1554characters, which gave them codes in the range of 128 to 255. That did
1555fit in a string, and many Lisp programs contain string constants that
1556use @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
1560rules for how to put a keyboard character event in a string. Here are 1603special rules for including certain meta characters in a string.
1561the rules: 1604Here 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
1569The meta variants of those characters, with codes in the range of 1612The 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
15742**27 16172**27
1575@end ifinfo 1618@end ifinfo
1576to 1619to
1577@iftex 1620@tex
1578$2^{27} + 127$, 1621$2^{27} + 127$,
1579@end iftex 1622@end tex
1580@ifinfo 1623@ifinfo
15812**27+127, 16242**27+127,
1582@end ifinfo 1625@end ifinfo
1583can also go in the string, but you must change their 1626can also go in the string, but you must change their
1584numeric values. You must set the 1627numeric 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
15892**7 16322**7
1590@end ifinfo 1633@end ifinfo
1591bit instead of the 1634bit instead of the
1592@iftex 1635@tex
1593$2^{27}$ 1636$2^{27}$
1594@end iftex 1637@end tex
1595@ifinfo 1638@ifinfo
15962**27 16392**27
1597@end ifinfo 1640@end ifinfo
1598bit, 1641bit, resulting in a value between 128 and 255. Only a unibyte string
1599resulting in a value between 128 and 255. 1642can include these codes.
1643
1644@item
1645Non-@sc{ASCII} characters above 256 can be included in a multibyte string.
1600 1646
1601@item 1647@item
1602Other keyboard character events cannot fit in a string. This includes 1648Other 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,
1613meta events in strings work consistently regardless of how they get into 1659meta events in strings work consistently regardless of how they get into
1614the strings. 1660the 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
1617keyboard events is to make room for basic character codes beyond 127, 1663following the recommendations at the beginning of this section.
1618and support meta variants of such larger character codes.
1619
1620 New programs can avoid dealing with these special compatibility rules
1621by using vectors instead of strings for key sequences when there is any
1622possibility 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
1626This function converts the string or vector @var{key} to a list of
1627events, which you can put in @code{unread-command-events}. Converting a
1628vector is simple, but converting a string is tricky because of the
1629special 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
1637functions for keyboard input are also available for use in Lisp 1670functions for event input are also available for use in Lisp programs.
1638programs. See also @code{momentary-string-display} in @ref{Temporary 1671See also @code{momentary-string-display} in @ref{Temporary Displays},
1639Displays}, and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, 1672and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for
1640for functions and variables for controlling terminal input modes and 1673functions and variables for controlling terminal input modes and
1641debugging terminal input. @xref{Translating Input}, for features you 1674debugging terminal input. @xref{Translating Input}, for features you
1642can use for translating or modifying input events while reading them. 1675can 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
1671events---characters, symbols, and lists. The elements of the string or 1704events---characters, symbols, and lists. The elements of the string or
1672vector are the events in the key sequence. 1705vector are the events in the key sequence.
1673 1706
1674The function @code{read-key-sequence} suppresses quitting: @kbd{C-g}
1675typed while reading with this function works like any other character,
1676and does not set @code{quit-flag}. @xref{Quitting}.
1677
1678The argument @var{prompt} is either a string to be displayed in the echo 1707The argument @var{prompt} is either a string to be displayed in the echo
1679area as a prompt, or @code{nil}, meaning not to display a prompt. 1708area 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
1725The function @code{read-key-sequence} suppresses quitting: @kbd{C-g}
1726typed while reading with this function works like any other character,
1727and does not set @code{quit-flag}. @xref{Quitting}.
1728@end defun
1729
1730@defun read-key-sequence-vector prompt
1731This is like @code{read-key-sequence} except that it always
1732returns 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
1821This function is like @code{read-char}, except that if the first 1860This function is like @code{read-char}, except that if the first
1822character read is an octal digit (0-7), it reads up to two more octal digits 1861character 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 1862digits (but stopping if a non-octal digit is found), and returns the
1824character represented by those digits in octal. 1863character represented by that numeric character code.
1825 1864
1826Quitting is suppressed when the first character is read, so that the 1865Quitting is suppressed when the first character is read, so that the
1827user can enter a @kbd{C-g}. @xref{Quitting}. 1866user 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
1882most recently unread will be reread first. 1921most recently unread will be reread first.
1883@end defvar 1922@end defvar
1884 1923
1924@defun listify-key-sequence key
1925This function converts the string or vector @var{key} to a list of
1926individual events, which you can put in @code{unread-command-events}.
1927@end defun
1928
1885@defvar unread-command-char 1929@defvar unread-command-char
1886This variable holds a character to be read as command input. 1930This variable holds a character to be read as command input.
1887A value of -1 means ``empty''. 1931A 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
1903This variable records the last terminal input event read, whether 1948This variable records the last terminal input event read, whether
1904as part of a command or explicitly by a Lisp program. 1949as 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
1923The alias @code{last-input-char} exists for compatibility with 1967The alias @code{last-input-char} exists for compatibility with
1924Emacs version 18. 1968Emacs version 18.
1925@end defvar 1969@end defvar
@@ -2049,9 +2093,9 @@ innermost active command loop.
2049does not cause a quit; it acts as an ordinary input character. In the 2093does not cause a quit; it acts as an ordinary input character. In the
2050simplest case, you cannot tell the difference, because @kbd{C-g} 2094simplest case, you cannot tell the difference, because @kbd{C-g}
2051normally runs the command @code{keyboard-quit}, whose effect is to quit. 2095normally runs the command @code{keyboard-quit}, whose effect is to quit.
2052However, when @kbd{C-g} follows a prefix key, the result is an undefined 2096However, when @kbd{C-g} follows a prefix key, they combine to form an
2053key. The effect is to cancel the prefix key as well as any prefix 2097undefined key. The effect is to cancel the prefix key as well as any
2054argument. 2098prefix 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
2057of the minibuffer. This means, in effect, that it exits the minibuffer 2101of 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
12in Lisp into a special representation called @dfn{byte-code} that can be 12in Lisp into a special representation called @dfn{byte-code} that can be
13executed more efficiently. The compiler replaces Lisp function 13executed more efficiently. The compiler replaces Lisp function
14definitions with byte-code. When a byte-code function is called, its 14definitions 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,
21however, as fast as true compiled code. 21however, 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
24by recent earlier versions of Emacs, but the reverse is not true. In 24by recent earlier versions of Emacs, but the reverse is not true. A
25particular, if you compile a program with Emacs 19.29, the compiled 25major incompatible change was introduced in Emacs version 19.29, and
26code does not run in earlier versions. 26files compiled with versions since that one will definitely not run
27in 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
30Files compiled in versions before 19.29 may not work in 19.29 if they 31In addition, the modifier bits in keyboard characters were renumbered in
31contain character constants with modifier bits, because the bits were 32Emacs 19.29; as a result, files compiled in versions before 19.29 will
32renumbered in Emacs 19.29. 33not work in subsequent versions if they contain character constants with
34modifier 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
35byte compilation. 37byte compilation.
@@ -99,9 +101,10 @@ in a buffer called @samp{*Compile-Log*}. These report things in your
99program that suggest a problem but are not necessarily erroneous. 101program 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
103expanded when they are compiled, so the macros must already be defined 105byte-compile. Macro calls are expanded when they are compiled, so the
104for proper compilation. For more details, see @ref{Compiling Macros}. 106macros must already be defined for proper compilation. For more
107details, 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
107load the file. But it does execute any @code{require} calls at top 110load 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
200needs recompilation. A file needs recompilation if a @samp{.elc} file 203needs recompilation. A file needs recompilation if a @samp{.elc} file
201exists but is older than the @samp{.el} file. 204exists but is older than the @samp{.el} file.
202 205
203When a @samp{.el} file has no corresponding @samp{.elc} file, then 206When 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 207says what to do. If it is @code{nil}, these files are ignored. If it
205ignored. If it is non-@code{nil}, the user is asked whether to compile 208is non-@code{nil}, the user is asked whether to compile each such file.
206each such file.
207 209
208The returned value of this command is unpredictable. 210The 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
226This function actually interprets byte-code. A byte-compiled function 228This function actually interprets byte-code. A byte-compiled function
227is actually defined with a body that calls @code{byte-code}. Don't call 229is actually defined with a body that calls @code{byte-code}. Don't call
228this function yourself. Only the byte compiler knows how to generate 230this function yourself---only the byte compiler knows how to generate
229valid calls to this function. 231valid calls to this function.
230 232
231In newer Emacs versions (19 and up), byte-code is usually executed as 233In Emacs version 18, byte-code was always executed by way of a call to
232part of a byte-code function object, and only rarely due to an explicit 234the function @code{byte-code}. Nowadays, byte-code is usually executed
233call to @code{byte-code}. 235as part of a byte-code function object, and only rarely through an
236explicit 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
269occasionally if you edit and recompile Lisp files. When it happens, you 272occasionally if you edit and recompile Lisp files. When it happens, you
270can cure the problem by reloading the file after recompiling it. 273can 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)
273versions because the older versions don't support this feature. You can 276will not load into older versions because the older versions don't
274turn off this feature by setting @code{byte-compile-dynamic-docstrings} 277support this feature. You can turn off this feature at compile time by
275to @code{nil}. Once this is done, you can compile files that will load 278setting @code{byte-compile-dynamic-docstrings} to @code{nil}; then you
276into older Emacs versions. You can do this globally, or for one source 279can compile files that will load into older Emacs versions. You can do
277file by specifying a file-local binding for the variable. Here's one 280this globally, or for one source file by specifying a file-local binding
278way to do that: 281for the variable. One way to do that is by adding this string to the
282file'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.
292use a special Lisp reader construct, @samp{#@@@var{count}}. This 296use a special Lisp reader construct, @samp{#@@@var{count}}. This
293construct skips the next @var{count} characters. It also uses the 297construct 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
295string.'' It is best not to use these constructs in Lisp source files. 299string.'' It is usually best not to use these constructs in Lisp source
300files, since they are not designed to be clear to humans reading the
301file.
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
311becomes much faster. This is a good thing for a file which contains 317becomes much faster. This is a good thing for a file which contains
312many separate commands, provided that using one of them does not imply 318many separate user-callable functions, if using one of them does not
313you will soon (or ever) use the rest. A specialized mode which provides 319imply you will probably also use the rest. A specialized mode which
314many keyboard commands often has that usage pattern: a user may invoke 320provides many keyboard commands often has that usage pattern: a user may
315the mode, but use only a few of the commands it provides. 321invoke 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
325If you alter the compiled file (such as by compiling a new version), 331If you alter the compiled file (such as by compiling a new version),
326then trying to load any function not already loaded will get nonsense 332then trying to load any function not already loaded will yield nonsense
327results. 333results.
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
331immediately load the new compiled file. That will prevent any future 337installed Emacs files. But they are quite likely to happen with Lisp
332problems. 338files that you are changing. The easiest way to prevent these problems
339is 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
335variable @code{byte-compile-dynamic} is non-@code{nil} at compilation 342variable @code{byte-compile-dynamic} is non-@code{nil} at compilation
336time. Do not set this variable globally, since dynamic loading is 343time. Do not set this variable globally, since dynamic loading is
337desirable only for certain files. Instead, enable the feature for 344desirable only for certain files. Instead, enable the feature for
338specific source files with file-local variable bindings, like this: 345specific source files with file-local variable bindings. For example,
346you 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
363containing code and when you run it (whether compiled or not). 371containing code and when you run it (whether compiled or not).
364 372
365You can get a similar result by putting @var{body} in a separate file 373You can get a similar result by putting @var{body} in a separate file
366and referring to that file with @code{require}. Using @code{require} is 374and referring to that file with @code{require}. That method is
367preferable if there is a substantial amount of code to be executed in 375preferable when @var{body} is large.
368this 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
375you load the source file, rather than compiling it, @var{body} is 382you load the source file, rather than compiling it, @var{body} is
376evaluated normally. 383evaluated normally.
377 384
378At 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 386Lisp idiom @code{(eval-when (compile eval) @dots{})}. Elsewhere, the
380@samp{#.} reader macro (but not when interpreting) is closer to what 387Common Lisp @samp{#.} reader macro (but not when interpreting) is closer
381@code{eval-when-compile} does. 388to 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
395function object is like that for a vector, with an additional @samp{#} 402function object is like that for a vector, with an additional @samp{#}
396before the opening @samp{[}. 403before the opening @samp{[}.
397 404
398 In Emacs version 18, there was no byte-code function object data type;
399compiled functions used the function @code{byte-code} to run the byte
400code.
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
403no maximum number, but only the first six elements are actually used. 406no maximum number, but only the first six elements have any normal use.
404They are: 407They 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
462This moves forward one line and continues moving by lines until it 462This moves forward one line and continues moving by lines until it
463reaches an empty. It is unusual in that the @code{while} has no body, 463reaches an empty line. It is peculiar in that the @code{while} has no
464just the end test (which also does the real work of moving point). 464body, 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
753The number and significance of the objects in @var{data} depends on 751The 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,
755there are two objects in the list: a predicate that describes the type 753there should be two objects in the list: a predicate that describes the type
756that was expected, and the object that failed to fit that type. 754that 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
876bindings that were made within the protected form. All it can do is 874bindings that were made within the protected form. All it can do is
877clean up and proceed. 875clean 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
880predictable, such as failure to open a file in a call to 878are 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
882totally unpredictable, such as when the program evaluates an expression 880totally unpredictable, such as when the program evaluates an expression
883read from the user. 881read from the user.
@@ -1159,7 +1157,12 @@ You might think that we could just as well write @code{(kill-buffer
1159However, the way shown above is safer, if @var{body} happens to get an 1157However, the way shown above is safer, if @var{body} happens to get an
1160error after switching to a different buffer! (Alternatively, you could 1158error after switching to a different buffer! (Alternatively, you could
1161write another @code{save-excursion} around the body, to ensure that the 1159write another @code{save-excursion} around the body, to ensure that the
1162temporary buffer becomes current in time to kill it.) 1160temporary buffer becomes current again in time to kill it.)
1161
1162 Emacs includes a standard macro called @code{with-temp-buffer} which
1163expands into more or less the code shown above (@pxref{Current Buffer}).
1164Several of the macros defined in this manual use @code{unwind-protect}
1165in 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
1189set, the process will not be killed. There is no easy way to fix this bug, 1192set, the process will not be killed. There is no easy way to fix this bug,
1190but at least it is very unlikely. 1193but at least it is very unlikely.
1191
1192 Here is another example which uses @code{unwind-protect} to make sure
1193to 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
9This chapter describes how to declare customization groups, variables, 9 This chapter describes how to declare user options for customization,
10and faces. We use the term @dfn{customization item} to include all 10and also customization groups for classifying them. We use the term
11three 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. 12definitions---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
25All three kinds of customization declarations (for groups, variables, 24 All kinds of customization declarations (for variables and groups, and
26and faces) accept keyword arguments for specifying various information. 25for faces) accept keyword arguments for specifying various information.
27This section describes some keywords that apply to all three. 26This section describes some keywords that apply to all kinds.
28 27
29All 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
30a given item. Each use of the keyword has an independent effect. The 29in a given item. Each use of the keyword has an independent effect.
31keyword @code{:tag} is an exception because any given item can only 30The keyword @code{:tag} is an exception because any given item can only
32display one name item. 31display 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.
49There are three alternatives you can use for @var{link-data}: 48There are three alternatives you can use for @var{link-data}:
50 49
51@table @code 50@table @code
51@item :tag @var{name}
52Use @var{name}, a string, instead of the item's name, to label the item
53in customization menus and buffers.
54
52@item (custom-manual @var{info-node}) 55@item (custom-manual @var{info-node})
53Link to an Info node; @var{info-node} is a string which specifies the 56Link to an Info node; @var{info-node} is a string which specifies the
54node name, as in @code{"(emacs)Top"}. The link appears as 57node name, as in @code{"(emacs)Top"}. The link appears as
@@ -59,8 +62,8 @@ Like @code{custom-manual} except that the link appears
59in the customization buffer with the Info node name. 62in the customization buffer with the Info node name.
60 63
61@item (url-link @var{url}) 64@item (url-link @var{url})
62Link to a web page; @var{url} is a string which specifies the URL. The 65Link to a web page; @var{url} is a string which specifies the @sc{url}.
63link appears in the customization buffer as @var{url}. 66The link appears in the customization buffer as @var{url}.
64@end table 67@end table
65 68
66You can specify the text to use in the customization buffer by adding 69You can specify the text to use in the customization buffer by adding
@@ -84,30 +87,27 @@ feature. This is done by calling @code{require}.
84The most common reason to use @code{:require} is when a variable enables 87The most common reason to use @code{:require} is when a variable enables
85a feature such as a minor mode, and just setting the variable won't have 88a feature such as a minor mode, and just setting the variable won't have
86any effect unless the code which implements the mode is loaded. 89any effect unless the code which implements the mode is loaded.
87
88@item :tag @var{name}
89Use @var{name}, a string, instead of the item's name, to label the item
90in 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
96Each Emacs Lisp package should have one main customization group which 95 Each Emacs Lisp package should have one main customization group which
97contains all the options, faces and other groups in the package. If the 96contains all the options, faces and other groups in the package. If the
98package has a small number of options and faces, use just one group and 97package has a small number of options and faces, use just one group and
99put everything in it. When there are more than twelve or so options and 98put everything in it. When there are more than twelve or so options and
100faces, then you should structure them into subgroups, and put the 99faces, then you should structure them into subgroups, and put the
101subgroups under the package's main customization group. It is ok to 100subgroups under the package's main customization group. It is OK to
102have some of the options and faces in the package's main group alongside 101put some of the options and faces in the package's main group alongside
103the subgroups. 102the subgroups.
104 103
105The 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
106the standard customization groups. Type press @kbd{C-h p} to display a 105the standard customization groups. (To display the full list of them,
107list of finder keywords; them choose some of them add your group to each 106use @kbd{M-x customize}.) Choose one or more of them (but not too
108of them, using the @code{:group} keyword. 107many), and add your group to each of them using the @code{:group}
108keyword.
109 109
110The 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
116the documentation string for the group. 116the documentation string for the group.
117 117
118The arguments @var{members} can be an alist whose elements specify 118The arguments @var{members} can be an alist whose elements specify
119members of the group; however, normally @var{members} is @code{nil}, and 119customization items to be members of the group; however, normally
120you 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
121defining those members. 121using 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
142The @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 143that @code{:prefix} currently has no effect. We did this because we
144that discarding the specified prefixes often led to confusing names for 144found that discarding the specified prefixes often led to confusing
145options. This happened because the people who wrote the @code{defgroup} 145names for options. This happened because the people who wrote the
146definitions for various groups added @code{:prefix} keywords whenever 146@code{defgroup} definitions for various groups added @code{:prefix}
147they make logical sense---that is, whenever they say that there was a 147keywords whenever they make logical sense---that is, whenever the
148common prefix for the option names in a library. 148variables in the library have a common prefix.
149 149
150In 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
151check the specific effects of discarding a particular prefix, given the 151necessary to check the specific effects of discarding a particular
152specific items in a group and their names and documentation. If the 152prefix, given the specific items in a group and their names and
153resulting text is not clear, then @code{:prefix} should not be used in 153documentation. If the resulting text is not clear, then @code{:prefix}
154that case. 154should not be used in that case.
155 155
156It should be possible to recheck all the customization groups, delete 156 It should be possible to recheck all the customization groups, delete
157the @code{:prefix} specifications which give unclear results, and then 157the @code{:prefix} specifications which give unclear results, and then
158turn this feature back on, if someone would like to do the work. 158turn 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]...
167Declare @var{option} as a customizable user option variable that 167Declare @var{option} as a customizable user option variable. Do not
168defaults to @var{value}. Do not quote @var{option}. @var{value} should 168quote @var{option}. The argument @var{doc} specifies the documentation
169be an expression to compute the value; it will be be evaluated on more 169string for the variable.
170
171If @var{option} is void, @code{defcustom} initializes it to
172@var{default}. @var{default} should be an expression to compute the
173value; be careful in writing it, because it can be be evaluated on more
170than one occasion. 174than one occasion.
171 175
172If @var{option} is void, @code{defcustom} initializes it to @var{value}.
173
174The argument @var{doc} specifies the documentation string for the variable.
175
176The following additional keywords are defined: 176The 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.
185Specify @var{list} as the list of reasonable values for use in this 185Specify @var{list} as the list of reasonable values for use in this
186option. 186option.
187 187
188Currently this is meaningful only when type is @code{hook}. The 188Currently this is meaningful only when the type is @code{hook}. In that
189elements of @var{list} are functions that you might likely want to use 189case, the elements of @var{list} should be functions that are useful as
190as elements of the hook value. The user is not actually restricted to 190elements of the hook value. The user is not restricted to using only
191using only these functions, but they are offered as convenient 191these functions, but they are offered as convenient alternatives.
192alternatives.
193 192
194@item :version @var{version} 193@item :version @var{version}
195This option specifies that the variable's default value was changed in 194This 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
229Use the variable's @code{:set} function to initialize the variable. Do 228Use the variable's @code{:set} function to initialize the variable, but
230not reinitialize it if it is already non-void. This is the default 229do 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
234Always use @code{set-default} to initialize the variable, even if some 233Like @code{custom-initialize-set}, but use the function
235other @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,
237defining the variable will not call the minor mode function, but
238customizing the variable will do so.
236 239
237@item custom-initialize-reset 240@item custom-initialize-reset
238Even if the variable is already non-void, reset it by calling the 241Always use the @code{:set} function to initialize the variable. If the
239@code{:set} function using the current value (returned by the 242variable is already non-void, reset it by calling the @code{:set}
240@code{:get} method). 243function using the current value (returned by the @code{:get} method).
241 244
242@item custom-initialize-changed 245@item custom-initialize-changed
243Like @code{custom-initialize-reset}, except use @code{set-default} 246Use the @code{:set} function to initialize the variable, if it is
244(rather than the @code{:set} function) to initialize the variable if it 247already set or has been customized; otherwise, just use
245is 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
249If the user saves a customized value for this item, them Emacs should do
250@code{(require @var{feature})} after installing the saved value.
251
252The place to use this feature is for an option that turns on the
253operation of a certain feature. Assuming that the package is coded to 254operation of a certain feature. Assuming that the package is coded to
254check the value of the option, you still need to arrange for the package 255check the value of the option, you still need to arrange for the package
255to be loaded. That is what @code{:require} is for. 256to be loaded. You can do that with @code{:require}. @xref{Common
256@end table 257Keywords}. 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
260Use @code{custom-add-option} to specify that a specific function is 271Use @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
274customization buffer. The @code{saved-value} property is actually a 285customization buffer. The @code{saved-value} property is actually a
275list whose car is an expression which evaluates to the value. 286list whose car is an expression which evaluates to the value.
276 287
277@node Face Definitions
278@section Defining Faces
279
280Faces are declared with @code{defface}.
281
282@tindex defface
283@defmac defface face spec doc [keyword value]...
284Declare @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}
291executes, it defines the face according to @var{spec}, then uses any
292customizations saved in the @file{.emacs} file to override that
293specification.
294
295In each element of @var{spec}, @var{atts} is a list of face attributes
296and their values. The possible attributes are defined in the variable
297@code{custom-face-attributes}.
298
299The @var{display} part of an element of @var{spec} determines which
300frames the element applies to. If more than one element of @var{spec}
301matches a given frame, the first matching element is the only one used
302for that frame.
303
304If @var{display} is @code{t} in a @var{spec} element, that element
305matches all frames. (This means that any subsequent elements of
306@var{spec} are never used.)
307
308Alternatively, @var{display} can be an alist whose elements have the
309form @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
312apply to. Here are the possible values of @var{characteristic}:
313
314@table @code
315@item type
316The 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
321What kinds of colors the frame supports---either @code{color},
322@code{grayscale}, or @code{mono}.
323
324@item background
325The kind of background--- either @code{light} or @code{dark}.
326@end table
327
328If an element of @var{display} specifies more than one
329@var{value} for a given @var{characteristic}, any of those values
330is acceptable. If an element of @var{display} has elements for
331more than one @var{characteristic}, then @var{each} characteristic
332of the frame must match one of the values specified for it.
333@end defmac
334
335Internally, @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
338with the customization buffer, and @code{face-documentation} for the
339documentation 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
345its @dfn{customization type}. That is a Lisp object which indictaes (1) 292its @dfn{customization type}. That is a Lisp object which describes (1)
346which values are legitimate and (2) how to display the value in the 293which values are legitimate and (2) how to display the value in the
347customization buffer for editing. 294customization 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
351types that vary at run time are rarely useful, normally it is a quoted 298types that vary at run time are rarely useful, normally you use a quoted
352constant. For example: 299constant. 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
362is a symbol, one of the customization type names defined in the 309symbol, one of the customization type names defined in the following
363following sections. After this symbol come a number of arguments, 310sections. After this symbol come a number of arguments, depending on
364depending on the symbol. Some of the type symbols do not use any 311the symbol. Between the type symbol and its arguments, you can
365arguments; those are called @dfn{simple types}. 312optionally write keyword-value pairs (@pxref{Type Keywords}).
366
367 In between the type symbol and its arguments, you can optionally
368write 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
371omit the parentheses around the type symbol. The above example does 315@dfn{simple types}. For a simple type, if you do not use any
372this, using just @code{string} as the customization type. 316keyword-value pairs, you can omit the parentheses around the type
373But @code{(string)} would mean the same thing. 317symbol. For example just @code{string} as a customization type is
318equivalent 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
402The value must be a string, and the customization buffer shows just the 347The value must be a string, and the customization buffer shows just the
403contents, with no @samp{"} characters or quoting with @samp{\}. 348contents, with no delimiting @samp{"} characters and no quoting with
349@samp{\}.
404 350
405@item regexp 351@item regexp
406The value must be a string which is a valid regular expression. 352Like @code{string} except that the string must be a valid regular
353expression.
407 354
408@item character 355@item character
409The value must be a character code. A character code is actually an 356The 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
438The value is boolean---either @code{nil} or @code{t}. 385The value is boolean---either @code{nil} or @code{t}. Note that by
386using @code{choice} and @code{const} together (see the next section),
387you can specify that the value must be @code{nil} or @code{t}, but also
388specify the text to describe each value in a way that fits the specific
389meaning 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
445types, which build from simple types. Here are several ways of doing 396types, which build new types from other types. Here are several ways of
446that: 397doing 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
461A quoted constant---that is, @code{'@var{object}}. This means that 412A 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
465For example, 416For example,
@@ -480,7 +431,7 @@ its @sc{cdr} must fit @var{cdr-type}. For example, @code{(const string
480symbol)} is a customization type which matches values such as 431symbol)} is a customization type which matches values such as
481@code{("foo" . foo)}. 432@code{("foo" . foo)}.
482 433
483In the customization buffeer, the @sc{car} and the @sc{cdr} are 434In the customization buffer, the @sc{car} and the @sc{cdr} are
484displayed and edited separately, each according to the type 435displayed and edited separately, each according to the type
485that you specify for it. 436that you specify for it.
486 437
@@ -493,7 +444,7 @@ For example, @code{(list integer string function)} describes a list of
493three elements; the first element must be an integer, the second a 444three elements; the first element must be an integer, the second a
494string, and the third a function. 445string, and the third a function.
495 446
496In the customization buffeer, the each element is displayed and edited 447In the customization buffer, the each element is displayed and edited
497separately, according to the type specified for it. 448separately, 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
524so that the menu offers @samp{Number of spaces} and @samp{Literal Text}. 475so that the menu offers @samp{Number of spaces} and @samp{Literal Text}.
525 476
477In any alternative for which @code{nil} is not a valid value, other than
478a @code{const}, you should specify a valid default for that alternative
479using the @code{:value} keyword. @xref{Type Keywords}.
480
526@item (const @var{value}) 481@item (const @var{value})
527The value must be @var{value}---nothing else is allowed. 482The value must be @var{value}---nothing else is allowed.
528 483
529The main use of @code{const} is inside of @code{choice}. For example, 484The 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}.
489For 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})
534Like @code{const}, but used for values which are functions. This 498Like @code{const}, but used for values which are functions. This
535displays the documentation string of the function @var{function} 499displays the documentation string as well as the function name.
536as well as its name. 500The 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})
539Like @code{const}, but used for values which are variable names. This 504Like @code{const}, but used for values which are variable names. This
540displays the documentation string of the variable @var{variable} as well 505displays the documentation string as well as the variable name. The
541as its name. 506documentation 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{})
544The value must be a list and each element of the list must be one of the 510The 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}
613This is used for a type that appears as an alternative inside of 579This 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
615when the user selects this alternative with the menu in the 581when the user selects this alternative with the menu in the
616customization buffer. 582customization buffer.
617 583
618Of course, if the actual value of the option fits this alternative, it 584Of course, if the actual value of the option fits this alternative, it
619will appear showing the actual value, not @var{default}. 585will appear showing the actual value, not @var{default}.
620 586
587If @code{nil} is not a valid value for the alternative, then it is
588essential to specify a valid default with @code{:value}.
589
621@item :format @var{format-string} 590@item :format @var{format-string}
622This string will be inserted in the buffer to represent the value 591This string will be inserted in the buffer to represent the value
623corresponding to the type. The following @samp{%} escapes are available 592corresponding to the type. The following @samp{%} escapes are available
624for use in @var{format-string}: 593for use in @var{format-string}:
625 594
626@table @samp 595@table @samp
627@ignore
628@item %[@var{button}%] 596@item %[@var{button}%]
629Display the text @var{button} marked as a button. The @code{:action} 597Display the text @var{button} marked as a button. The @code{:action}
630attribute specifies what the button will do if the user invokes it; 598attribute 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
632the button appears in, and the event. 600the button appears in, and the event.
633 601
634There is no way to specify two different buttons with different 602There is no way to specify two different buttons with different
635actions; but perhaps there is no need for one. 603actions.
636@end ignore
637 604
638@item %@{@var{sample}%@} 605@item %@{@var{sample}%@}
639Show @var{sample} in a special face specified by @code{:sample-face}. 606Show @var{sample} in a special face specified by @code{:sample-face}.
@@ -658,11 +625,15 @@ keyword.
658Display a literal @samp{%}. 625Display a literal @samp{%}.
659@end table 626@end table
660 627
628@item :action @var{action}
629Perform @var{action} if the user clicks on a button.
630
661@item :button-face @var{face} 631@item :button-face @var{face}
662Use face @var{face} for text displayed with @samp{%[@dots{}%]}. 632Use the face @var{face} (a face name or a list of face names) for button
633text 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}
666These specify the text to display before and after a button. 637These specify the text to display before and after a button.
667Each can be: 638Each can be:
668 639
@@ -677,11 +648,19 @@ The string is inserted literally.
677The symbol's value is used. 648The symbol's value is used.
678@end table 649@end table
679 650
651@item :tag @var{tag}
652Use @var{tag} (a string) as the tag for the value (or part of the value)
653that corresponds to this type.
654
680@item :doc @var{doc} 655@item :doc @var{doc}
681Use @var{doc} as the documentation string for this item. 656Use @var{doc} as the documentation string for this value (or part of the
657value) that corresponds to this type. In order for this to work, you
658must specify a value for @code{:format}, and use @samp{%d} or @samp{%h}
659in that value.
682 660
683@item :tag @var{tag} 661The usual reason to specify a documentation string for a type is to
684Use @var{tag} (a string) as the tag for this item. 662provide 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}
687When you move to this item with @code{widget-forward} or 666When 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
689in the echo area. 668in the echo area.
690 669
691@item :match @var{function} 670@item :match @var{function}
692Specify how to decide whether a value matches the type. @var{function} 671Specify how to decide whether a value matches the type. The
693should be a function that accepts two arguments, a widget and a value; 672corresponding value, @var{function}, should be a function that accepts
694it should return non-@code{nil} if the value is acceptable. 673two arguments, a widget and a value; it should return non-@code{nil} if
674the 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
106The normal value of this variable lists several errors that happen often 106The normal value of this variable lists several errors that happen often
107during editing but rarely result from bugs in Lisp programs. 107during editing but rarely result from bugs in Lisp programs. However,
108``rarely'' is not ``never''; if your program fails with an error that
109matches this list, you will need to change this list in order to debug
110the 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
111Normally, errors that are caught by @code{condition-case} never run the 115Normally, errors that are caught by @code{condition-case} never run the
112debugger, even if @code{debug-on-error} is non-@code{nil}. In other 116debugger, even if @code{debug-on-error} is non-@code{nil}. In other
113words, @code{condition-case} gets a chance to catch the error before the 117words, @code{condition-case} gets a chance to handle the error before
114debugger gets a chance. 118the debugger gets a chance.
115 119
116If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets 120If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets
117first chance at every error; an error will invoke the debugger 121first 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
119specified by the values of @code{debug-on-error} and 123specified 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
123Emacs handle errors in the normal course of affairs, and you may not 127Emacs handle errors in the normal course of affairs, and you may not
124even realize that errors happen there. If you set 128even 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}
133file, use the option @samp{-debug-init}, which binds 137file, 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
135inhibits use of @code{condition-case} to catch init file errors. 139inhibits 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
138not last past the end of loading @file{.emacs}. (This is an undesirable 142not 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
190function, and then step through its caller. 194function, 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 197This function requests @var{function-name} to invoke the debugger each time
194it is called. It works by inserting the form @code{(debug 'debug)} into 198it is called. It works by inserting the form @code{(debug 'debug)} into
195the function definition as the first form. 199the function definition as the first form.
196 200
197 Any function defined as Lisp code may be set to break on entry, 201Any function defined as Lisp code may be set to break on entry,
198regardless of whether it is interpreted code or compiled code. If the 202regardless of whether it is interpreted code or compiled code. If the
199function is a command, it will enter the debugger when called from Lisp 203function is a command, it will enter the debugger when called from Lisp
200and when called interactively (after the reading of the arguments). You 204and when called interactively (after the reading of the arguments). You
201can't debug primitive functions (i.e., those written in C) this way. 205can'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 207When @code{debug-on-entry} is called interactively, it prompts for
204for @var{function-name} in the minibuffer. 208@var{function-name} in the minibuffer. If the function is already set
209up 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 214by the redefinition. In effect, redefining the function cancels
209 @strong{Note:} if you redefine a function after using 215the 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:
252This function undoes the effect of @code{debug-on-entry} on 255This 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
259functions.
256 260
257If @code{cancel-debug-on-entry} is called more than once on the same 261Calling @code{cancel-debug-on-entry} does nothing to a function which is
258function, the second call does nothing. @code{cancel-debug-on-entry} 262not currently set up to break on entry. It always returns
259returns @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
326through the control structures of an interpreted function, but cannot do 330through the control structures of an interpreted function, but cannot do
327so in a byte-compiled function. If you would like to step through a 331so in a byte-compiled function. If you would like to step through a
328byte-compiled function, replace it with an interpreted definition of the 332byte-compiled function, replace it with an interpreted definition of the
329same function. (To do this, visit the source file for the function and 333same function. (To do this, visit the source for the function and type
330type @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
362Don't enter the debugger when the current frame is exited. This 366Don't enter the debugger when the current frame is exited. This
363cancels a @kbd{b} command on that frame. 367cancels a @kbd{b} command on that frame. The visible effect is to
368remove the star from the line in the backtrace buffer.
364 369
365@item e 370@item e
366Read a Lisp expression in the minibuffer, evaluate it, and print the 371Read 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
372variable values within the debugger. 377variable values within the debugger.
373 378
379@item R
380Like @kbd{e}, but also save the result of evaluation in the
381buffer @samp{*Debugger-record*}.
382
374@item q 383@item q
375Terminate the program being debugged; return to top-level Emacs 384Terminate the program being debugged; return to top-level Emacs
376command execution. 385command execution.
@@ -383,11 +392,11 @@ Return a value from the debugger. The value is computed by reading an
383expression with the minibuffer and evaluating it. 392expression with the minibuffer and evaluating it.
384 393
385The @kbd{r} command is useful when the debugger was invoked due to exit 394The @kbd{r} command is useful when the debugger was invoked due to exit
386from a Lisp call frame (as requested with @kbd{b}); then the value 395from a Lisp call frame (as requested with @kbd{b} or by entering the
387specified in the @kbd{r} command is used as the value of that frame. It 396frame with @kbd{d}); then the value specified in the @kbd{r} command is
388is also useful if you call @code{debug} and use its return value. 397used as the value of that frame. It is also useful if you call
389Otherwise, @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
390return value does not matter. 399effect as @kbd{c}, and the specified return value does not matter.
391 400
392You can't use @kbd{r} when the debugger was entered due to an error. 401You 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
451When the first argument is @code{exit}, it indicates the exit of a 460When the first argument is @code{exit}, it indicates the exit of a stack
452stack frame previously marked to invoke the debugger on exit. The 461frame previously marked to invoke the debugger on exit. The second
453second argument given to @code{debug} in this case is the value being 462argument given to @code{debug} in this case is the value being returned
454returned from the frame. The debugger displays @samp{Return value:} on 463from the frame. The debugger displays @samp{Return value:} in the top
455the top line of the buffer, followed by the value being returned. 464line 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
605information for future debugger invocations during the same command 614information for future debugger invocations during the same command
606invocation. 615invocation.
607 616
608The advantage, for the debugger, of using this variable rather than 617The advantage, for the debugger, of using this variable rather than an
609another global variable is that the data will never carry over to a 618ordinary global variable is that the data will never carry over to a
610subsequent command invocation. 619subsequent command invocation.
611@end defvar 620@end defvar
612 621
@@ -671,7 +680,8 @@ close parenthesis, and finally return to the mark.)
671way to be sure of this except by studying the program, but often the 680way to be sure of this except by studying the program, but often the
672existing indentation is a clue to where the parentheses should have 681existing indentation is a clue to where the parentheses should have
673been. The easiest way to use this clue is to reindent with @kbd{C-M-q} 682been. The easiest way to use this clue is to reindent with @kbd{C-M-q}
674and see what moves. 683and see what moves. @strong{But don't do this yet!} Keep reading,
684first.
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.
677Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest 687Otherwise, @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
702insertion of the open parenthesis, and finally return to the mark.) 712insertion 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}
705at the beginning of the defun. This will leave you somewhere short of 715at the beginning of that defun. This will leave you somewhere short of
706the place where the defun ought to end. It is possible that you will 716the place where the defun ought to end. It is possible that you will
707find a spurious close parenthesis in that vicinity. 717find 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})
63This variable controls whether Emacs redraws the entire screen after it 63This variable controls whether Emacs redraws the entire screen after it
64has been suspended and resumed. Non-@code{nil} means there is no need 64has been suspended and resumed. Non-@code{nil} means there is no need
65to redraw, @code{nil} means redrawing is needed. 65to 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
136one screen line. The additional screen lines used to display a long 136one screen line. The additional screen lines used to display a long
137text line are called @dfn{continuation} lines. Normally, a @samp{$} in 137text line are called @dfn{continuation} lines. Normally, a @samp{$} in
138the rightmost column of the window indicates truncation; a @samp{\} on 138the rightmost column of the window indicates truncation; a @samp{\} on
139the rightmost column indicates a line that ``wraps'' or is continued 139the rightmost column indicates a line that ``wraps'' onto the next line,
140onto the next line. (The display table can specify alternative 140which is also called @dfn{continuing} the line. (The display table can
141indicators; see @ref{Display Tables}.) 141specify 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
144on the screen only, not in the buffer contents, and it breaks a line 144on 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
159This variable is the default value for @code{truncate-lines}, for 159This variable is the default value for @code{truncate-lines}, for
160buffers that do not have local values for it. 160buffers 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
185Turning on the cache slows down processing of short lines somewhat. 185Turning on the cache slows down processing of short lines somewhat.
186 186
187This variable is automatically local in every buffer. 187This 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
242echo area, or @code{nil} if there is none. 242echo area, or @code{nil} if there is none.
243@end defun 243@end defun
244 244
245@defvar cursor-in-echo-area
246This variable controls where the cursor appears when a message is
247displayed in the echo area. If it is non-@code{nil}, then the cursor
248appears at the end of the message. Otherwise, the cursor appears at
249point---not in the echo area at all.
250
251The value is normally @code{nil}; Lisp programs bind it to @code{t}
252for 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
247This normal hook is run whenever the echo area is cleared---either by 257This 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.
274If the value is zero, then command input is not echoed. 284If the value is zero, then command input is not echoed.
275@end defvar 285@end defvar
276 286
277@defvar cursor-in-echo-area
278This variable controls where the cursor appears when a message is
279displayed in the echo area. If it is non-@code{nil}, then the cursor
280appears at the end of the message. Otherwise, the cursor appears at
281point---not in the echo area at all.
282
283The value is normally @code{nil}; Lisp programs bind it to @code{t}
284for 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.
295In the simplest case, any non-@code{nil} @code{invisible} property makes 295In the simplest case, any non-@code{nil} @code{invisible} property makes
296a character invisible. This is the default case---if you don't alter 296a character invisible. This is the default case---if you don't alter
297the default value of @code{buffer-invisibility-spec}, this is how the 297the 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.
299display (@pxref{Selective Display}), but more general and cleaner.
300 299
301More generally, you can use the variable @code{buffer-invisibility-spec} 300More generally, you can use the variable @code{buffer-invisibility-spec}
302to control which values of the @code{invisible} property make text 301to control which values of the @code{invisible} property make text
@@ -322,17 +321,17 @@ A character is invisible if its @code{invisible} property is
322non-@code{nil}. This is the default. 321non-@code{nil}. This is the default.
323 322
324@item a list 323@item a list
325Each element of the list makes certain characters invisible. 324Each element of the list specifies a criterion for invisibility; if a
326Ultimately, a character is invisible if any of the elements of this list 325character's @code{invisible} property fits any one of these criteria,
327applies to it. The list can have two kinds of elements: 326the 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}
331A character is invisible if its @code{invisible} propery value 330A character is invisible if its @code{invisible} property value
332is @var{atom} or if it is a list with @var{atom} as a member. 331is @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)
335A character is invisible if its @code{invisible} propery value 334A character is invisible if its @code{invisible} property value
336is @var{atom} or if it is a list with @var{atom} as a member. 335is @var{atom} or if it is a list with @var{atom} as a member.
337Moreover, if this character is at the end of a line and is followed 336Moreover, if this character is at the end of a line and is followed
338by a visible newline, it displays an ellipsis. 337by 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
360property: 359property:
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
405lines on the screen. 404hiding 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
408a Lisp program. The program controls which lines are hidden by altering 407a Lisp program: it controls which lines are hidden by altering the text.
409the text. Outline mode has traditionally used this variant. It has 408The invisible text feature (@pxref{Invisible Text}) has partially
410been partially replaced by the invisible text feature (@pxref{Invisible 409replaced this feature.
411Text}); 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
414automatically based on indentation. This variant is designed to be a 412automatically 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
443If the value of @code{selective-display} is @code{t}, then any portion 441If the value of @code{selective-display} is @code{t}, then any portion
444of a line that follows a control-m is not displayed. 442of a line that follows a control-m is not displayed. This is explicit
443selective display.
445 444
446@item 445@item
447If the value of @code{selective-display} is a positive integer, then 446If 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
553and then present it to the user for perusal rather than for editing. 552buffer and then present it to the user for perusal rather than for
554Many of the help commands use this feature. 553editing. 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{}
557This function executes @var{forms} while arranging to insert any 556This function executes @var{forms} while arranging to insert any
@@ -599,9 +598,6 @@ The value of the last form in @var{forms} is returned.
599If this variable is non-@code{nil}, @code{with-output-to-temp-buffer} 598If this variable is non-@code{nil}, @code{with-output-to-temp-buffer}
600calls it as a function to do the job of displaying a help buffer. The 599calls it as a function to do the job of displaying a help buffer. The
601function gets one argument, which is the buffer it should display. 600function gets one argument, which is the buffer it should display.
602
603In 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
620The return value of @code{momentary-string-display} is not meaningful. 616The return value of @code{momentary-string-display} is not meaningful.
621 617
622If the string @var{string} does not contain control characters, you can 618If the string @var{string} does not contain control characters, you can
623do the same job in a more general way by creating an overlay with a 619do the same job in a more general way by creating (and then subsequently
624@code{before-string} property. @xref{Overlay Properties}. 620deleting) an overlay with a @code{before-string} property.
621@xref{Overlay Properties}.
625 622
626If @var{message} is non-@code{nil}, it is displayed in the echo area 623If @var{message} is non-@code{nil}, it is displayed in the echo area
627while @var{string} is displayed in the buffer. If it is @code{nil}, a 624while @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
685and strings preserves text properties, but does not try to preserve 682and strings preserves text properties, but does not try to preserve
686overlays. Changing a buffer's text properties marks the buffer as 683overlays. Changing a buffer's text properties marks the buffer as
687modified, while moving an overlay or changing its properties does not. 684modified, while moving an overlay or changing its properties does not.
688Unlike text propery changes, overlay changes are not recorded in the 685Unlike text property changes, overlay changes are not recorded in the
689buffer's undo list. 686buffer'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
803if it ever becomes empty (i.e., if it spans no characters). 800if 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)}
808If this property is non-@code{nil}, it specifies a keymap for a portion 805If this property is non-@code{nil}, it specifies a keymap for a portion
809of the text. The property's value replaces the buffer's local map, when 806of the text. The property's value replaces the buffer's local map, when
810the character after point is within the overlay. @xref{Active Keymaps}. 807the 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
914Since not all characters have the same width, these functions let you 911Since not all characters have the same width, these functions let you
915check the width of a character. @ref{Primitive Indent} 912check the width of a character. @xref{Primitive Indent}, and
916 913@ref{Screen Lines}, for related functions.
917@xref{Screen Lines}, for related
918functions.
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
970control the display of text on the screen. 965control the display of text on the screen.
971 966
972@cindex face id 967@cindex face id
973Each face has its own @dfn{face id number} which distinguishes faces at 968Each face has its own @dfn{face number}, which distinguishes faces at
974low levels within Emacs. However, for most purposes, you can refer to 969low levels within Emacs. However, for most purposes, you can refer to
975faces in Lisp programs by their names. 970faces 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
1036one. 1032one.
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
1039kind of customization item (@pxref{Customization}) which the user can
1040customize using the Customization buffer (@pxref{Easy Customization,,,
1041emacs, The GNU Emacs Manual}).
1042
1043@tindex defface
1044@defmac defface face spec doc [keyword value]...
1045Declare @var{face} as a customizable face that defaults according to
1046@var{spec}. Do not quote the symbol @var{face}. The argument @var{doc}
1047specifies the face documentation.
1048
1049When @code{defface} executes, it defines the face according to
1050@var{spec}, then uses any customizations saved in the @file{.emacs} file
1051to override that specification.
1052
1053The purpose of @var{spec} is to specify how the face should appear on
1054different kinds of terminals. It should be an alist whose elements have
1055the 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
1058what the face should look like on that kind of terminal. The possible
1059attributes are defined in the value of @code{custom-face-attributes}.
1060
1061The @var{display} part of an element of @var{spec} determines which
1062frames the element applies to. If more than one element of @var{spec}
1063matches a given frame, the first matching element is the only one used
1064for that frame. There are two possibilities for @var{display}:
1065
1066@table @asis
1067@item @code{t}
1068This element of @var{spec} matches all frames. Therefore, any
1069subsequent 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
1073If @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
1077apply to. Here are the possible values of @var{characteristic}:
1078
1079@table @code
1080@item type
1081The 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
1086What kinds of colors the frame supports---either @code{color},
1087@code{grayscale}, or @code{mono}.
1088
1089@item background
1090The kind of background--- either @code{light} or @code{dark}.
1091@end table
1092
1093If an element of @var{display} specifies more than one @var{value} for a
1094given @var{characteristic}, any of those values is acceptable. If
1095@var{display} has more than one element, each element should specify a
1096different @var{characteristic}; then @emph{each} characteristic of the
1097frame 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
1103with @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
1116with the customization buffer, and @code{face-documentation} for the
1117documentation 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
1046With defaults. Each frame has a @dfn{default face}, whose id number is 1126With defaults. Each frame has a @dfn{default face}, which is used for
1047zero, which is used for all text that doesn't somehow specify another 1127all text that doesn't somehow specify another face. (We may change this
1048face. 1128in a forthcoming Emacs version to serve as a default for all text.)
1049 1129
1050@item 1130@item
1051With text properties. A character may have a @code{face} property; if so, 1131With 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
1064highlighted with a particular face (see @code{region-face}, below). 1144highlighted with a particular face (see @code{region-face}, below).
1065 1145
1066@item 1146@item
1067With special glyphs. Each glyph can specify a particular face id 1147With special glyphs. Each glyph can specify a particular face
1068number. @xref{Glyphs}. 1148number. @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
1147that you specified is always used. 1227that you specified is always used.
1148@end defun 1228@end defun
1149 1229
1150@defun set-face-underline-p face underline-p &optional frame
1151This function sets the underline attribute of face @var{face}.
1152Non-@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
1157This function sets the bold attribute of face @var{face}. 1232This function sets the bold attribute of face @var{face}.
@@ -1164,6 +1239,11 @@ This function sets the italic attribute of face @var{face}.
1164Non-@code{nil} means italic; @code{nil} means non-italic. 1239Non-@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
1243This function sets the underline attribute of face @var{face}.
1244Non-@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
1168Swap the foreground and background colors of face @var{face}. If the 1248Swap the foreground and background colors of face @var{face}. If the
1169face doesn't specify both foreground and background, then its foreground 1249face 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
1189This function returns the name of the font of face @var{face}. 1269This 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
1193This 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
1198This function returns the bold attribute of face @var{face}. 1274This function returns the bold attribute of face @var{face}.
@@ -1203,8 +1279,12 @@ This function returns the bold attribute of face @var{face}.
1203This function returns the italic attribute of face @var{face}. 1279This 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
1283This function returns the underline attribute of face @var{face}.
1284@end defun
1285
1206@defun face-id face 1286@defun face-id face
1207This function returns the face id number of face @var{face}. 1287This 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
1229This variable's value specifies the face id to use to display characters 1309This variable's value specifies the face number to use to display characters
1230in the region when it is active (in Transient Mark mode only). The face 1310in the region when it is active (in Transient Mark mode only). The face
1231thus specified takes precedence over all faces that come from text 1311thus specified takes precedence over all faces that come from text
1232properties and overlays, for characters in the region. @xref{The Mark}, 1312properties and overlays, for characters in the region. @xref{The Mark},
1233for more information about Transient Mark mode. 1313for more information about Transient Mark mode.
1234 1314
1235Normally, the value is the id number of the face named @code{region}. 1315Normally, 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
1246open parenthesis when the user inserts a close parenthesis. 1326open 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
1250The value of this variable should be a function (of no arguments) to 1329The value of this variable should be a function (of no arguments) to
1251be called whenever a character with close parenthesis syntax is inserted. 1330be called whenever a character with close parenthesis syntax is inserted.
1252The value of @code{blink-paren-function} may be @code{nil}, in which 1331The value of @code{blink-paren-function} may be @code{nil}, in which
1253case nothing is done. 1332case nothing is done.
1254
1255@quotation
1256@strong{Please note:} This variable was named @code{blink-paren-hook} in
1257older Emacs versions, but since it is not called with the standard
1258convention for hooks, it was renamed to @code{blink-paren-function} in
1259version 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.
1321Otherwise, mode lines are displayed normally, just like text. The 1393Otherwise, mode lines are displayed normally, just like text. The
1322default is @code{t}. 1394default is @code{t}.
1323 1395
1324For X window frames, this displays mode lines using the face named 1396For 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
1326unless you change it. 1398unless 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
1357Character codes 128 through 255 map to sequences of four glyphs, where 1429Character codes 128 through 255 map to sequences of four glyphs, where
1358the first glyph is the @sc{ASCII} code for @samp{\}, and the others are 1430the first glyph is the @sc{ASCII} code for @samp{\}, and the others are
1359digit characters representing the code in octal. (A display table can 1431digit characters representing the charatcer code in octal. (A display
1360specify a glyph to use instead of @samp{\}.) 1432table can specify a glyph to use instead of @samp{\}.)
1433
1434@item
1435Multibyte character codes above 256 are displayed as themselves, or as a
1436question mark or empty box if the terminal cannot display that
1437character.
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
1364table, for any character whose entry in the active display table is 1441table, 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
1366specify the characters for which you want unusual behavior. 1443specify 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
1369screen. Since they change the number of columns the characters occupy, 1446screen. 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
1400You can use the @dfn{display table} feature to control how all 256 1477You can use the @dfn{display table} feature to control how all possible
1401possible character codes display on the screen. This is useful for 1478character codes display on the screen. This is useful for displaying
1402displaying European languages that have letters not in the @sc{ASCII} 1479European languages that have letters not in the @sc{ASCII} character
1403character set. 1480set.
1404 1481
1405The display table maps each character code into a sequence of 1482The 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
1438characters, the whole buffer will be displayed as one long ``line.'' 1515characters, 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
1441purposes. Here is a table of their meanings; @code{nil} means to use 1518purposes. Here is a table of their meanings; @code{nil} in any slot
1442the default stated below. 1519means 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
1517This variable is automatically local in all buffers; its value in a 1594This variable is automatically buffer-local in all buffers; its value in
1518particular buffer is the display table for that buffer, or @code{nil} if 1595a particular buffer specifies the display table for that buffer. If it
1519the buffer does not have an assigned display table. 1596is @code{nil}, that means the buffer does not have an assigned display
1597table.
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
1557Send the characters in @var{string} to the terminal to output 1635Send the characters in @var{string} to the terminal to output
1558this glyph. This alternative is available on character terminals, 1636this glyph. This alternative is available on character terminals,
1559but not under X. 1637but not under a window system.
1560 1638
1561@item integer 1639@item integer
1562Define this glyph code as an alias for code @var{integer}. You can use 1640Define this glyph code as an alias for glyph code @var{integer}. You
1563an alias to specify a face code for the glyph; see below. 1641can use an alias to specify a face code for the glyph; see below.
1564 1642
1565@item @code{nil} 1643@item @code{nil}
1566This glyph is simple. On an ordinary terminal, the glyph code mod 524288 1644This glyph is simple. On an ordinary terminal, the glyph code mod
1567is the character to output. With X, the glyph code mod 524288 is the 1645524288 is the character to output. In a window system, the glyph code
1568character to output, and the glyph code divided by 524288 specifies the 1646mod 524288 is the character to output, and the glyph code divided by
1569@dfn{face id number} to use while outputting it. (524288 is 1647524288 specifies the face number (@pxref{Face Functions}) to use while
1648outputting it. (524288 is
1570@ifinfo 1649@ifinfo
15712**19. 16502**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
1605This variable determines whether Emacs should flash the screen to 1684This variable determines whether Emacs should flash the screen to
1606represent a bell. Non-@code{nil} means yes, @code{nil} means no. This 1685represent a bell. Non-@code{nil} means yes, @code{nil} means no. This
1607is effective under X windows, and on a character-only terminal provided 1686is effective on a window system, and on a character-only terminal
1608the terminal's Termcap entry defines the visible bell capability 1687provided the terminal's Termcap entry defines the visible bell
1609(@samp{vb}). 1688capability (@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
167edebug-all-defs} toggles the value of the variable 169edebug-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}
175also instrument any definitions they evaluate. Similarly, 176also instrument any definitions they evaluate. Similarly,
@@ -179,16 +180,11 @@ to loading or evaluations in the minibuffer. The command @kbd{M-x
179edebug-all-forms} toggles this option. 180edebug-all-forms} toggles this option.
180 181
181@findex edebug-eval-top-level-form 182@findex edebug-eval-top-level-form
182Another 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
183instrument any top-level form regardless of the values of 184instrument 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
186When Edebug is about to instrument code for the first time in a session, 187 While Edebug is active, the command @kbd{I}
187it runs the hook @code{edebug-setup-hook}, then sets it to @code{nil}.
188You can use this to load up Edebug specifications associated with a
189package you are using, but only when you also use Edebug.
190
191While 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
193function or macro called by the list form after point, if is not already 189function or macro called by the list form after point, if is not already
194instrumented. This is possible only if Edebug knows where to find the 190instrumented. 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
207interactive form with an expression argument, anonymous lambda 203interactive form with an expression argument, anonymous lambda
@@ -209,7 +205,13 @@ expressions, and other defining forms. Edebug cannot know what a
209user-defined macro will do with the arguments of a macro call, so you 205user-defined macro will do with the arguments of a macro call, so you
210must tell it; @xref{Instrumenting Macro Calls}, for details. 206must 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
209session, 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
212using, 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
214definition in a way that does not instrument. There are two ways of 216definition in a way that does not instrument. There are two ways of
215evaluating forms that never instrument them: from a file with 217evaluating forms that never instrument them: from a file with
@@ -472,7 +474,7 @@ stop point that has a previously established conditional breakpoint puts
472the previous condition expression in the minibuffer so you can edit it. 474the previous condition expression in the minibuffer so you can edit it.
473 475
474You can make a conditional or unconditional breakpoint 476You 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
476breakpoint. When a temporary breakpoint stops the program, it is 478breakpoint. When a temporary breakpoint stops the program, it is
477automatically unset. 479automatically unset.
478 480
@@ -504,7 +506,6 @@ depending on the execution mode, as if a breakpoint had been hit. If
504evaluating the condition gets an error, execution does not stop. 506evaluating 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
510using the @kbd{X} command (@code{edebug-set-global-break-condition}). 511using 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
536When the @code{fac} definition is instrumented and the function is 537 When the @code{fac} definition is instrumented and the function is
537called, the call to @code{edebug} acts as a breakpoint. Depending on 538called, the call to @code{edebug} acts as a breakpoint. Depending on
538the execution mode, Edebug stops or pauses there. 539the execution mode, Edebug stops or pauses there.
539 540
540If no instrumented code is being executed when @code{edebug} is called, 541 If no instrumented code is being executed when @code{edebug} is called,
541that function calls @code{debug}. 542that 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
547Emacs normally displays an error message when an error is signaled and 548 Emacs normally displays an error message when an error is signaled and
548not handled with @code{condition-case}. While Edebug is active, it 549not handled with @code{condition-case}. While Edebug is active and
549normally responds to all unhandled errors. You can customize this with 550executing instrumented code, it normally responds to all unhandled
550the options @code{edebug-on-error} and @code{edebug-on-quit}; see 551errors. You can customize this with the options @code{edebug-on-error}
551@ref{Edebug Options}. 552and @code{edebug-on-quit}; see @ref{Edebug Options}.
552 553
553When Edebug responds to an error, it shows the last stop point 554 When Edebug responds to an error, it shows the last stop point
554encountered before the error. This may be the location of a call to a 555encountered before the error. This may be the location of a call to a
555function which was not instrumented, within which the error actually 556function which was not instrumented, within which the error actually
556occurred. For an unbound variable error, the last known stop point 557occurred. 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
558case you might want to display a full backtrace (@pxref{Edebug Misc}). 559case 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
561If 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
562Edebug is active, these changes will be forgotten when Edebug becomes 563Edebug is active, these changes will be forgotten when Edebug becomes
563inactive. Furthermore, during Edebug's recursive edit, these variables 564inactive. Furthermore, during Edebug's recursive edit, these variables
564are bound to the values they had outside of Edebug. 565are 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
569These Edebug commands let you view aspects of the buffer and window 570 These Edebug commands let you view aspects of the buffer and window
570status that obtained before entry to Edebug. The outside window 571status that obtained before entry to Edebug. The outside window
571configuration is the collection of windows and contents that were in 572configuration is the collection of windows and contents that were in
572effect outside of Edebug. 573effect outside of Edebug.
@@ -597,12 +598,12 @@ the selected window. To specify a window that is not displaying the
597source code buffer, you must use @kbd{C-x X W} from the global keymap. 598source code buffer, you must use @kbd{C-x X W} from the global keymap.
598@end table 599@end table
599 600
600You can view the outside window configuration with @kbd{v} or just 601 You can view the outside window configuration with @kbd{v} or just
601bounce to the point in the current buffer with @kbd{p}, even if 602bounce to the point in the current buffer with @kbd{p}, even if
602it is not normally displayed. After moving point, you may wish to jump 603it is not normally displayed. After moving point, you may wish to jump
603back to the stop point with @kbd{w} from a source code buffer. 604back to the stop point with @kbd{w} from a source code buffer.
604 605
605Each 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
606saved outside window configuration---so that even if you turn saving 607saved outside window configuration---so that even if you turn saving
607back @emph{on}, the current window configuration remains unchanged when 608back @emph{on}, the current window configuration remains unchanged when
608you next exit Edebug (by continuing the program). However, the 609you 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
616While within Edebug, you can evaluate expressions ``as if'' Edebug were 617 While within Edebug, you can evaluate expressions ``as if'' Edebug were
617not running. Edebug tries to be invisible to the expression's 618not running. Edebug tries to be invisible to the expression's
618evaluation and printing. Evaluation of expressions that cause side 619evaluation and printing. Evaluation of expressions that cause side
619effects will work as expected except for things that Edebug explicitly 620effects 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)
638Edebug supports evaluation of expressions containing references to 639 Edebug supports evaluation of expressions containing references to
639lexically bound symbols created by the following constructs in 640lexically 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
647You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to 647 You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to
648evaluate expressions interactively. You can also set up the 648evaluate 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
650time Edebug updates the display. 650time 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
658In the @samp{*edebug*} buffer you can use the commands of Lisp 658 In the @samp{*edebug*} buffer you can use the commands of Lisp
659Interaction mode (@pxref{Lisp Interaction,,, emacs, The GNU Emacs 659Interaction mode (@pxref{Lisp Interaction,,, emacs, The GNU Emacs
660Manual}) as well as these special commands: 660Manual}) as well as these special commands:
661 661
662@table @kbd 662@table @kbd
663@item LFD 663@item C-j
664Evaluate the expression before point, in the outside context, and insert 664Evaluate the expression before point, in the outside context, and insert
665the value in the buffer (@code{edebug-eval-print-last-sexp}). 665the 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
684You 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*};
686but they are evaluated in the context outside of Edebug. 686but they are evaluated in the context outside of Edebug.
687 687
688The expressions you enter interactively (and their results) are lost 688 The expressions you enter interactively (and their results) are lost
689when you continue execution; but you can set up an @dfn{evaluation list} 689when you continue execution; but you can set up an @dfn{evaluation list}
690consisting of expressions to be evaluated each time execution stops. 690consisting of expressions to be evaluated each time execution stops.
691 691
692@cindex evaluation list group 692@cindex evaluation list group
693To 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
694evaluation list buffer. An evaluation list group consists of one or 694evaluation list buffer. An evaluation list group consists of one or
695more Lisp expressions. Groups are separated by comment lines. 695more Lisp expressions. Groups are separated by comment lines.
696 696
697The 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
698evaluation list, scanning the buffer and using the first expression of 698evaluation list, scanning the buffer and using the first expression of
699each group. (The idea is that the second expression of the group is the 699each group. (The idea is that the second expression of the group is the
700value previously computed and displayed.) 700value previously computed and displayed.)
701 701
702Be careful not to add expressions that execute instrumented code since 702 Each entry to Edebug redisplays the evaluation list by inserting each
703that would cause an infinite loop.
704@c There ought to be a way to fix this.
705
706Each entry to Edebug redisplays the evaluation list by inserting each
707expression in the buffer, followed by its current value. It also 703expression in the buffer, followed by its current value. It also
708inserts comment lines so that each expression becomes its own group. 704inserts comment lines so that each expression becomes its own group.
709Thus, if you type @kbd{C-c C-u} again without changing the buffer text, 705Thus, if you type @kbd{C-c C-u} again without changing the buffer text,
710the evaluation list is effectively unchanged. 706the evaluation list is effectively unchanged.
711 707
712If an error occurs during an evaluation from the evaluation list, the 708 If an error occurs during an evaluation from the evaluation list, the
713error message is displayed in a string as if it were the result. 709error message is displayed in a string as if it were the result.
714Therefore, expressions that use variables not currently valid do not 710Therefore, expressions that use variables not currently valid do not
715interrupt your debugging. 711interrupt your debugging.
716 712
717Here 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
718several expressions have been added to it: 714several 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
760list structure, you may get an error when Edebug attempts to print it. 756list 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}
765or @code{print-level} to truncate the printing. Edebug does this for 759or @code{print-level} to truncate the printing. Edebug does this for
766you; it binds @code{print-length} and @code{print-level} to 50 if they 760you; 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}
768and @code{edebug-print-level} specify the values to use within Edebug.) 762and @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
766If non-@code{nil}, bind @code{print-length} to this while printing
767results in Edebug. The default value is @code{50}.
768@xref{Printing in Edebug}.
769@end defopt
770
771@defopt edebug-print-level
772If non-@code{nil}, bind @code{print-level} to this while printing
773results 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
772elements more informatively by using the @file{cust-print} package. 777elements 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
790structure. This notation is used for any shared elements of lists or 795structure. This notation is used for any shared elements of lists or
791vectors. 796vectors.
792 797
798@defopt edebug-print-circle
799If non-@code{nil}, bind @code{print-circle} to this while printing
800results 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}
794for details. 804for details.
795 805
@@ -850,7 +860,7 @@ Edebug provides rudimentary coverage testing and display of execution
850frequency. All execution of an instrumented function accumulates 860frequency. All execution of an instrumented function accumulates
851frequency counts, both before and after evaluation of each instrumented 861frequency counts, both before and after evaluation of each instrumented
852expression, even if the execution mode is Go-nonstop. Coverage testing 862expression, even if the execution mode is Go-nonstop. Coverage testing
853is more expensive, so it is only done if @code{edebug-test-coverage} is 863is more expensive, so it is done only if @code{edebug-test-coverage} is
854non-@code{nil}. The command @kbd{M-x edebug-display-freq-count} 864non-@code{nil}. The command @kbd{M-x edebug-display-freq-count}
855displays both the frequency data and the coverage data (if recorded). 865displays 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).
858This command displays the frequency count data for each line of the 868This command displays the frequency count data for each line of the
859current definition. 869current definition.
860 870
861The frequency counts appear as comment lines after each line of code, and 871The frequency counts appear as comment lines after each line of code,
862you can undo all insertions with one @code{undo} command. The counts 872and you can undo all insertions with one @code{undo} command. The
863appear under the @kbd{(} before an expression or the @kbd{)} after 873counts appear under the @samp{(} before an expression or the @samp{)}
864an expression, or on the last character of a symbol. Values do not appear if 874after an expression, or on the last character of a symbol. Values do
865they are equal to the previous count on the same line. 875not appear if they are equal to the previous count on the same line.
866 876
867The character @samp{=} following the count for an expression says that 877The character @samp{=} following the count for an expression says that
868the expression has returned the same value each time it was evaluated 878the 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
1038When Edebug instruments an expression that calls a Lisp macro, it needs 1048 When Edebug instruments an expression that calls a Lisp macro, it needs
1039additional advice to do the job properly. This is because there is no 1049additional information about the macro to do the job properly. This is
1040way to tell which subexpressions of the macro call are forms to be 1050because there is no a-priori way to tell which subexpressions of the
1041evaluated. (Evaluation may occur explicitly in the macro body, or when 1051macro call are forms to be evaluated. (Evaluation may occur explicitly
1042the resulting expansion is evaluated, or any time later.) You must 1052in the macro body, or when the resulting expansion is evaluated, or any
1043explain the format of calls to each macro to enable Edebug to handle it. 1053time later.)
1044To do this, use @code{def-edebug-spec} to define the format of 1054
1045calls to a given macro. 1055 Therefore, you must define an Edebug specification for each macro that
1056Edebug will encounter, to explain the format of calls to that macro. To
1057do this, use @code{def-edebug-spec}.
1046 1058
1047@deffn Macro def-edebug-spec macro specification 1059@deffn Macro def-edebug-spec macro specification
1048Specify which expressions of a call to macro @var{macro} are forms to be 1060Specify 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
1050similar to the formal argument list of the macro definition, but 1062similar to the formal argument list of the macro definition, but
1051specifications are much more general than macro arguments. 1063specifications are much more general than macro arguments.
1052 1064
1053The @var{macro} argument may actually be any symbol, not just a macro 1065The @var{macro} argument can actually be any symbol, not just a macro
1054name. 1066name.
1055@end deffn 1067@end deffn
1056 1068
@@ -1108,7 +1120,7 @@ as @code{&optional}).
1108A specification list may contain sublists which match arguments that are 1120A specification list may contain sublists which match arguments that are
1109themselves lists, or it may contain vectors used for grouping. Sublists 1121themselves lists, or it may contain vectors used for grouping. Sublists
1110and groups thus subdivide the specification list into a hierarchy of 1122and groups thus subdivide the specification list into a hierarchy of
1111levels. Specification keywords only apply to the remainder of the 1123levels. Specification keywords apply only to the remainder of the
1112sublist or group they are contained in. 1124sublist or group they are contained in.
1113 1125
1114When a specification list involves alternatives or repetition, matching 1126When 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
1265Here is a list of additional specifications that may only appear after 1277Here 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
1478Non-@code{nil} means display a trace of function entry and exit. 1488Non-@code{nil} means display a trace of function entry and exit.
1479Tracing output is displayed in a buffer named @samp{*edebug-trace*}, one 1489Tracing output is displayed in a buffer named @samp{*edebug-trace*}, one
1480function entry or exit per line, indented by the recursion level. 1490function 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
1508If non-@code{nil}, bind @code{print-length} to this while printing
1509results in Edebug. The default value is @code{50}.
1510@xref{Printing in Edebug}.
1511@end defopt
1512
1513@defopt edebug-print-level
1514If non-@code{nil}, bind @code{print-level} to this while printing
1515results in Edebug. The default value is @code{50}.
1516@end defopt
1517
1518@defopt edebug-print-circle
1519If non-@code{nil}, bind @code{print-circle} to this while printing
1520results in Edebug. The default value is @code{nil}.
1521@end defopt
1522
1523@defopt edebug-on-error 1517@defopt edebug-on-error
1524Edebug binds @code{debug-on-error} to this value, if 1518Edebug 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"}@*
59loop"}@*
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"}@*
68This is not a @code{file-error}.@* 67Note that this is not a @code{file-error}
68because 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
72This is a @code{file-error}.@*
73@xref{Writing to Files}.
74
71@item file-date-error 75@item file-date-error
72This is a subcategory of @code{file-error}. It occurs when 76This 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.@*
83This is a @code{file-error}.@* 87This is a @code{file-error}.@*
84@xref{File Locks}. 88@xref{File Locks}.
85 89
86@item file-already-exists
87This is a @code{file-error}.@*
88@xref{Writing to Files}.
89
90@item file-supersession 90@item file-supersession
91This is a @code{file-error}.@* 91This 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"}@*
116This happens when certain syntax-parsing functions
117find 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"}@*
116The values of the symbols @code{nil} and @code{t} 126The values of the symbols @code{nil} and @code{t},
127and any symbols that start with @samp{:},
117may not be changed.@* 128may 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
143mathematical functions. 154mathematical 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
210always @code{t}; you cannot set or bind them to any other values. Thus, 210always @code{t}; you cannot set or bind them to any other values. Thus,
211these two symbols act like self-evaluating forms, even though 211these 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
213starts with @samp{:} also self-evaluates in the same way. 213starts with @samp{:} also self-evaluates in the same way; likewise,
214its 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
647This variable defines the maximum depth allowed in calls to @code{eval}, 648This 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
649message @code{"Lisp nesting exceeds max-lisp-eval-depth"}). This counts 650message @code{"Lisp nesting exceeds max-lisp-eval-depth"}). This limit,
650internal uses of those functions, such as for calling the functions 651with the associated error when it is exceeded, is one way that Lisp
651mentioned in Lisp expressions, and recursive evaluation of function call 652avoids infinite recursion on an ill-defined function.
652arguments and function body forms.
653
654This limit, with the associated error when it is exceeded, is one way
655that Lisp avoids infinite recursion on an ill-defined function.
656@cindex Lisp nesting error 653@cindex Lisp nesting error
657 654
655The depth limit counts internal uses of @code{eval}, @code{apply}, and
656@code{funcall}, such as for calling the functions mentioned in Lisp
657expressions, and recursive evaluation of function call arguments and
658function body forms, as well as explicit calls in Lisp code.
659
658The default value of this variable is 200. If you set it to a value 660The default value of this variable is 200. If you set it to a value
659less than 100, Lisp will reset it to 100 if the given value is reached. 661less 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
116the user whether to reread the changed file. If the user says 115the 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
119If @code{find-file-noselect} needs to create a buffer, and there is no
120file named @var{filename}, it displays the message @samp{New file} in
121the echo area, and leaves the buffer empty.
122
123This function displays warning or advisory messages in various peculiar 118This function displays warning or advisory messages in various peculiar
124cases, unless the optional argument @var{nowarn} is non-@code{nil}. 119cases, unless the optional argument @var{nowarn} is non-@code{nil}. For
120example, 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
122area, and leaves the buffer empty.
125 123
126The @code{find-file-noselect} function normally calls 124The @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
298The optional @var{exiting} argument, if non-@code{nil}, requests this 296The optional @var{exiting} argument, if non-@code{nil}, requests this
299function to offer also to save certain other buffers that are not 297function to offer also to save certain other buffers that are not
300visiting files. These are buffers that have a non-@code{nil} local 298visiting files. These are buffers that have a non-@code{nil}
301value of @code{buffer-offer-save}. (A user who says yes to saving one 299buffer-local value of @code{buffer-offer-save}. (A user who says yes to
302of these is asked to specify a file name to use.) The 300saving 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
304for this argument. 302for this argument.
305@end deffn 303@end deffn
306 304
307@defvar buffer-offer-save
308When this variable is non-@code{nil} in a buffer, Emacs offers to save
309the buffer on exit even if the buffer is not visiting a file. The
310variable 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
315This function writes the current buffer into file @var{filename}, makes 306This function writes the current buffer into file @var{filename}, makes
316the buffer visit that file, and marks it not modified. Then it renames 307the buffer visit that file, and marks it not modified. Then it renames
317the buffer based on @var{filename}, appending a string like @samp{<2>} 308the buffer based on @var{filename}, appending a string like @samp{<2>}
318if necessary to make a unique buffer name. It does most of this work by 309if necessary to make a unique buffer name. It does most of this work by
319calling @code{set-visited-file-name} and @code{save-buffer}. 310calling @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
354This works just like @code{write-file-hooks}, but it is intended to be 346This works just like @code{write-file-hooks}, but it is intended to be
355made local to particular buffers, and used for hooks that pertain to the 347made buffer-local in particular buffers, and used for hooks that pertain
356file name or the way the buffer contents were obtained. 348to the file name or the way the buffer contents were obtained.
357 349
358The variable is marked as a permanent local, so that changing the major 350The variable is marked as a permanent local, so that changing the major
359mode does not alter a buffer-local value. This is convenient for 351mode 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;
372switching to a new major mode always resets this variable. When you use 364switching 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}
374specify a non-@code{nil} @var{local} argument, since this variable is 366specify a non-@code{nil} @var{local} argument, since this variable is
375used @emph{only} locally. 367used @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
392or Copy}. Yet, at the same time, saving a precious file always breaks 384or Copy}. Yet, at the same time, saving a precious file always breaks
393all hard links between the file you save and other file names. 385all hard links between the file you save and other file names.
394 386
395Some modes set this variable non-@code{nil} locally in particular 387Some modes give this variable non-@code{nil} buffer-local value
396buffers. 388in 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
410major modes set it to @code{t} in particular buffers. 402major 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
414This function changes the visited file name of the current buffer to 406Name}).
415@var{filename}. It also renames the buffer based on @var{filename},
416appending a string like @samp{<2>} if necessary to make a unique buffer
417name. 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
420If the specified file already exists, @code{set-visited-file-name}
421asks 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...
545The @code{with-temp-file} macro evaluates the @var{body} forms 529The @code{with-temp-file} macro evaluates the @var{body} forms with a
546with a temporary buffer as the current buffer; then, at the end, it 530temporary buffer as the current buffer; then, at the end, it writes the
547writes the buffer contents into file @var{file}. It kills the temporary 531buffer contents into file @var{file}. It kills the temporary buffer
548buffer when finished, restoring the buffer that was current before the 532when 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 534in @var{body}.
551The return value is the value of the last form in @var{body}. You can
552return the contents of the temporary buffer by using
553@code{(buffer-string)} as the last form.
554 535
555The current buffer is restored even in case of an abnormal exit via 536The 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.
568Emacs can then detect the first attempt to modify a buffer visiting a 549Emacs can then detect the first attempt to modify a buffer visiting a
569file that is locked by another Emacs job, and ask the user what to do. 550file 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
572file systems, such as with NFS. Perhaps a better file locking system 553share file systems. When file locks do not work, it is possible for two
573will be implemented in the future. When file locks do not work, it is 554users to make changes simultaneously, but Emacs can still warn the user
574possible for two users to make changes simultaneously, but Emacs can 555who saves second. Also, the detection of modification of a buffer
575still warn the user who saves second. Also, the detection of 556visiting a file changed on disk catches some cases of simultaneous
576modification of a buffer visiting a file changed on disk catches some 557editing; see @ref{Modification Time}.
577cases 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
1615The value of this buffer-local variable is the default directory for the 1589The value of this buffer-local variable is the default directory for the
1616current buffer. It should be an absolute directory name; it may start 1590current buffer. It should be an absolute directory name; it may start
1617with @samp{~}. This variable is local in every buffer. 1591with @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
1620argument is @code{nil}. 1594argument 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
1654If a @samp{~} or a @samp{/} appears following a @samp{/}, after 1628After substitution, if a @samp{~} or a @samp{/} appears following a
1655substitution, 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
2028Handlers for @code{insert-file-contents} typically need to clear the 2006Handlers for @code{insert-file-contents} typically need to clear the
2029buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the 2007buffer'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
2140this format. 2118this format.
2141 2119
2142@item from-fn 2120@item from-fn
2143A function or shell command to decode data in this format (to convert 2121A shell command or function to decode data in this format (to convert
2144file data into the usual Emacs data representation). 2122file data into the usual Emacs data representation).
2145 2123
2146If @var{from-fn} is a function, it is called with two args, @var{begin} 2124A shell command is represented as a string; Emacs runs the command as a
2125filter to perform the conversion.
2126
2127If @var{from-fn} is a function, it is called with two arguments, @var{begin}
2147and @var{end}, which specify the part of the buffer it should convert. 2128and @var{end}, which specify the part of the buffer it should convert.
2148It should convert the text by editing it in place. Since this can 2129It should convert the text by editing it in place. Since this can
2149change the length of the text, @var{from-fn} should return the modified 2130change 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
2153of the file no longer matches @var{regexp}. Otherwise it is likely to 2134of the file no longer matches @var{regexp}. Otherwise it is likely to
2154get called again. 2135get called again.
2155 2136
2156If @var{from-fn} is a string, it is a shell command; Emacs runs the
2157command as a filter to perform the conversion.
2158
2159@item to-fn 2137@item to-fn
2160A function or shell command to encode data in this format (to convert 2138A shell command or function to encode data in this format---that is, to
2161the usual Emacs data representation into this format). 2139convert the usual Emacs data representation into this format.
2162 2140
2163If @var{to-fn} is a string, it is a shell command; Emacs runs the 2141If @var{to-fn} is a string, it is a shell command; Emacs runs the
2164command as a filter to perform the conversion. 2142command as a filter to perform the conversion.
2165 2143
2166If @var{to-fn} is a function, it is called with two args, @var{begin} 2144If @var{to-fn} is a function, it is called with two arguments, @var{begin}
2167and @var{end}, which specify the part of the buffer it should convert. 2145and @var{end}, which specify the part of the buffer it should convert.
2168There are two ways it can do the conversion: 2146There 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
2210This variable states the format of the visited file. More precisely, 2188This variable states the format of the visited file. More precisely,
2211this is a list of the file format names that were decoded in the course 2189this is a list of the file format names that were decoded in the course
2212of visiting the current buffer's file. It is always local in all 2190of visiting the current buffer's file. It is always buffer-local in all
2213buffers. 2191buffers.
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
2238This command inserts the contents of file @var{file}, converting it 2216This command inserts the contents of file @var{file}, converting it
2239according to format @var{format}. If @var{beg} and @var{end} are 2217according to format @var{format}. If @var{beg} and @var{end} are
2240non-@code{nil}, they specify which part of the file to read, as in 2218non-@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
2254a list of format names, just like the value of 2232a 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
2257is always local in all buffers. 2235is 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
2271text files and binary files. This is necessary because ordinary text
2272files on MS-DOS use a two character sequence between lines:
2273carriage-return and linefeed (@sc{crlf}). Emacs expects just a newline
2274character (a linefeed) between lines. When Emacs reads or writes a text
2275file on MS-DOS, it needs to convert the line separators. This means it
2276needs to know which files are text files and which are binary. It makes
2277this decision when visiting a file, and records the decision in the
2278variable @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
2283This variable, automatically local in each buffer, records the file type
2284of 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
2289This function determines whether file @var{filename} is a text file
2290or 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
2294This variable holds an alist for distinguishing text files from binary
2295files. 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
2298compute which. If it is a function, then it is called with a single
2299argument (the file name) and should return @code{t} or @code{nil}.
2300@end defopt
2301
2302@defopt default-buffer-file-type
2303This variable specifies the default file type for files whose names
2304don't indicate anything in particular. Its value should be @code{nil}
2305for text, or @code{t} for binary.
2306@end defopt
2307
2308@deffn Command find-file-text filename
2309Like @code{find-file}, but treat the file as text regardless of its name.
2310@end deffn
2311
2312@deffn Command find-file-binary filename
2313Like @code{find-file}, but treat the file as binary regardless of its
2314name.
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
19one and only one at any given time---on the terminal screen, of course. 19one 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
22terminal frame; instead, it starts with a single @dfn{X window frame}. 22as X Windows, it does not have a terminal frame; instead, it starts with
23It can display multiple X window frames at the same time, each in its 23a single @dfn{window frame}, but you can create more, and Emacs can
24own X window. 24display several such frames at once as is usual for window systems.
25 25
26@defun framep object 26@defun framep object
27This predicate returns @code{t} if @var{object} is a frame, and 27This 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
63To create a new frame, call the function @code{make-frame}. 63To create a new frame, call the function @code{make-frame}.
64 64
65@defun make-frame &optional alist 65@defun make-frame &optional alist
66This function creates a new frame. If you are using X, it makes 66This function creates a new frame. If you are using a supported window
67an X window frame; otherwise, it makes a terminal frame. 67system, it makes a window frame; otherwise, it makes a terminal frame.
68 68
69The argument is an alist specifying frame parameters. Any parameters 69The argument is an alist specifying frame parameters. Any parameters
70not mentioned in @var{alist} default according to the value of the 70not mentioned in @var{alist} default according to the value of the
71variable @code{default-frame-alist}; parameters not specified even there 71variable @code{default-frame-alist}; parameters not specified even there
72default from the standard X defaults file and X resources. 72default from the standard X resources or whatever is used instead on
73your system.
73 74
74The set of possible parameters depends in principle on what kind of 75The set of possible parameters depends in principle on what kind of
75window system Emacs uses to display its frames. @xref{X Frame 76window system Emacs uses to display its frames. @xref{Window Frame
76Parameters}, for documentation of individual parameters you can specify. 77Parameters}, 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.
99Initially, Emacs uses just one display---the one chosen with the 100Initially, 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
108corresponding to the currently selected frame): these are 109corresponding 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
111always terminal-local and can never be buffer-local. 112always 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
164Frame parameters exist for the sake of window systems. A terminal frame 166Frame parameters exist for the sake of window systems. A terminal frame
165has a few parameters, mostly for compatibility's sake; only the height, 167has a few parameters, mostly for compatibility's sake; only the height,
166width and @code{buffer-predicate} parameters really do something. 168width, @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
201This variable's value is an alist of parameter values used when creating 204This variable's value is an alist of parameter values used when creating
202the initial X window frame. You can set this variable to specify the 205the initial window frame. You can set this variable to specify the
203appearance of the initial frame without altering subsequent frames. 206appearance of the initial frame without altering subsequent frames.
204Each element has the form: 207Each 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
241This is an alist specifying default values of frame parameters for all 244This is an alist specifying default values of frame parameters for all
242Emacs frames---the first frame, and subsequent frames. In many cases, 245Emacs frames---the first frame, and subsequent frames. When using the X
243you can get the same results by means of X resources. 246Window System, you can get the same results by means of X resources
247in many cases.
244@end defvar 248@end defvar
245 249
246See also @code{special-display-frame-alist}, in @ref{Choosing Window}. 250See 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,
252The GNU Emacs Manual}. 256The 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
257Just what parameters a frame has depends on what display mechanism it 261Just what parameters a frame has depends on what display mechanism it
258uses. Here is a table of the parameters of an X window frame; of these, 262uses. Here is a table of the parameters that have special meanings in a
259@code{name}, @code{height}, @code{width}, and @code{buffer-predicate} 263window frame; of these, @code{name}, @code{title}, @code{height},
260provide meaningful information in non-X frames. 264@code{width}, @code{buffer-list} and @code{buffer-predicate} provide
265meaningful information in terminal frames.
261 266
262@table @code 267@table @code
268@item title
269If a frame has a non-@code{nil} title, it appears in the window system's
270border for the frame, and also in the mode line of windows in that frame
271if @code{mode-line-frame-identification} uses @samp{%F}
272(@pxref{%-Constructs}). This is normally the case when Emacs is not
273using a window system, and can only display one frame at a time.
274@xref{Frame Titles}.
275
263@item name 276@item name
264The name of the frame. Most window managers display the frame's name in 277The name of the frame. The frame name serves as a default for the frame
265the frame's border, at the top of the frame. If you don't specify a 278title, if the @code{title} parameter is unspecified or @code{nil}. If
266name, and you have more than one frame, Emacs sets the frame name based 279you don't specify a name, Emacs sets the frame name automatically
267on the buffer displayed in the frame's selected window. 280(@pxref{Frame Titles}).
268 281
269If you specify the frame name explicitly when you create the frame, the 282If you specify the frame name explicitly when you create the frame, the
270name is also used (instead of the name of the Emacs executable) when 283name is also used (instead of the name of the Emacs executable) when
271looking up X resources for the frame. 284looking up X resources for the frame.
272 285
273Since a non-window terminal can display only one frame at a time, the
274frame name appears in the mode line.
275
276@item display 286@item display
277The display on which to open this frame. It should be a string of the 287The display on which to open this frame. It should be a string of the
278form @code{"@var{host}:@var{dpy}.@var{screen}"}, just like the 288form @code{"@var{host}:@var{dpy}.@var{screen}"}, just like the
@@ -287,8 +297,9 @@ negative @var{pos} value.
287A negative number @minus{}@var{pos}, or a list of the form @code{(- 297A 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
289window with respect to the right edge of the screen. A positive value 299window with respect to the right edge of the screen. A positive value
290of @var{pos} counts toward the left. If the parameter is a negative 300of @var{pos} counts toward the left. @strong{Reminder:} if the
291integer @minus{}@var{pos} then @var{pos} is positive! 301parameter is a negative integer @minus{}@var{pos}, then @var{pos} is
302positive.
292 303
293Some window managers ignore program-specified positions. If you want to 304Some window managers ignore program-specified positions. If you want to
294be sure the position you specify is not ignored, specify a 305be sure the position you specify is not ignored, specify a
@@ -303,8 +314,9 @@ negative @var{pos} value.
303A negative number @minus{}@var{pos}, or a list of the form @code{(- 314A 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
305window with respect to the bottom edge of the screen. A positive value 316window with respect to the bottom edge of the screen. A positive value
306of @var{pos} counts toward the top. If the parameter is a negative 317of @var{pos} counts toward the top. @strong{Reminder:} if the
307integer @minus{}@var{pos} then @var{pos} is positive! 318parameter is a negative integer @minus{}@var{pos}, then @var{pos} is
319positive.
308 320
309Some window managers ignore program-specified positions. If you want to 321Some window managers ignore program-specified positions. If you want to
310be sure the position you specify is not ignored, specify a 322be 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
348pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.) 360pixels, call @code{frame-pixel-width}; see @ref{Size and Position}.)
349 361
350@item window-id 362@item window-id
351The number of the X window for the frame. 363The number of the window-system window used by the frame.
352 364
353@item minibuffer 365@item minibuffer
354Whether this frame has its own minibuffer. The value @code{t} means 366Whether this frame has its own minibuffer. The value @code{t} means
@@ -360,12 +372,13 @@ the new frame uses that minibuffer.
360The buffer-predicate function for this frame. The function 372The 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
362decide which buffers it should consider, if the predicate is not 374decide 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
364each buffer; if the predicate returns a non-@code{nil} value, it 376each buffer; if the predicate returns a non-@code{nil} value, it
365considers that buffer. 377considers that buffer.
366 378
367@item buffer-list 379@item buffer-list
368A list of buffers recently selected in this frame. 380A list of buffers that have been selected in this frame,
381ordered most-recently-selected first.
369 382
370@item font 383@item font
371The name of the font for displaying text in the frame. This is a 384The 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
401appears. If this is @code{nil}, the frame's title is used. 414appears. If this is @code{nil}, the frame's title is used.
402 415
403@item foreground-color 416@item foreground-color
404The color to use for the image of a character. This is a string; the X 417The color to use for the image of a character. This is a string; the
405server defines the meaningful color names. 418window system defines the meaningful color names.
406 419
407@item background-color 420@item background-color
408The color to use for the background of characters. 421The 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
510The function @code{x-parse-geometry} converts a standard X windows 523The function @code{x-parse-geometry} converts a standard X Windows
511geometry string to an alist that you can use as part of the argument to 524geometry 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
563Every 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
564the top of the frame. You can specify an explicit title with the 577for the frame title which window systems typically display at the top of
565@code{name} frame property. But normally you don't specify this 578the frame. You can specify a name explicitly by setting the @code{name}
566explicitly, and Emacs computes the title automatically. 579frame property.
567 580
568Emacs computes the frame title based on a template stored in the 581 Normally you don't specify the name explicitly, and Emacs computes the
569variable @code{frame-title-format}. 582frame name automatically based on a template stored in the variable
583@code{frame-title-format}. Emacs recomputes the name each time the
584frame is redisplayed.
570 585
571@defvar frame-title-format 586@defvar frame-title-format
572This variable specifies how to compute a title for a frame 587This variable specifies how to compute a name for a frame when you have
573when you have not explicitly specified one. 588not explicitly specified one. The variable's value is actually a mode
574 589line construct, just like @code{mode-line-format}. @xref{Mode Line
575The variable's value is actually a mode line construct, just like 590Data}.
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
580This variable specifies how to compute the title for an iconified frame, 594This variable specifies how to compute the name for an iconified frame,
581when you have not explicitly specified the frame title. This title 595when you have not explicitly specified the frame title. This title
582appears in the icon itself. 596appears 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
697Conversely, selecting a window for Emacs with @code{select-window} also 711 Conversely, selecting a window for Emacs with @code{select-window} also
698makes that window selected within its frame. @xref{Selecting Windows}. 712makes that window selected within its frame. @xref{Selecting Windows}.
699 713
700Another 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}. 715frame 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.
736This function returns the selected frame. 750This function returns the selected frame.
737@end defun 751@end defun
738 752
739The X server normally directs keyboard input to the X window that the 753Some window systems and window managers direct keyboard input to the
740mouse is in. Some window managers use mouse clicks or keyboard events 754window object that the mouse is in; others require explicit clicks or
741to @dfn{shift the focus} to various X windows, overriding the normal 755commands to @dfn{shift the focus} to various window objects. Either
742behavior of the server. 756way, Emacs automatically keeps track of which frame has the focus.
743 757
744Lisp programs can switch frames ``temporarily'' by calling 758Lisp programs can also switch frames ``temporarily'' by calling the
745the function @code{select-frame}. This does not override the window 759function @code{select-frame}. This does not alter the window system's
746manager; rather, it escapes from the window manager's control until 760concept of focus; rather, it escapes from the window manager's control
747that control is somehow reasserted. 761until that control is somehow reasserted.
748 762
749When using a text-only terminal, there is no window manager; therefore, 763When 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 764actually displayed on the terminal. @code{switch-frame} is the only way
751lasts until overridden by a subsequent call to @code{switch-frame}. 765to switch frames, and the change lasts until overridden by a subsequent
752Only the selected terminal frame is actually displayed on the terminal. 766call to @code{switch-frame}. Each terminal screen except for the
753Each terminal screen except for the initial one has a number, and the 767initial one has a number, and the number of the selected frame appears
754number of the selected frame appears in the mode line after the word 768in the mode line after the word @samp{Emacs} (@pxref{Mode Line
755@samp{Emacs} (@pxref{Mode Line Variables}). 769Variables}).
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
762until the next time this function is called. 776until the next time this function is called.
763@end defun 777@end defun
764 778
765Emacs cooperates with the X server and the window managers by arranging 779Emacs cooperates with the window system by arranging to select frames as
766to select frames according to what the server and window manager ask 780the server and window manager request. It does so by generating a
767for. It does so by generating a special kind of input event, called a 781special kind of input event, called a @dfn{focus} event, when
768@dfn{focus} event. The command loop handles a focus event by calling 782appropriate. 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
806change it. 820change it.
807@end defun 821@end defun
808 822
823@tindex focus-follows-mouse
824@defopt focus-follows-mouse
825This option is how you inform Emacs whether the window manager transfers
826focus when the user moves the mouse. Non-@code{nil} says that it does.
827When this is so, the command @code{other-frame} moves the mouse to a
828position 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
816An X window frame may be @dfn{visible}, @dfn{invisible}, or 838A 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
818iconified, the frame's contents do not appear on the screen, but an icon 840iconified, the frame's contents do not appear on the screen, but an icon
819does. If the frame is invisible, it doesn't show on the screen, not 841does. 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
847parameter. You can read or change it as such. @xref{X Frame 869parameter. You can read or change it as such. @xref{Window Frame
848Parameters}. 870Parameters}.
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
859the idea that windows are stacked in a notional third dimension 881the idea that windows are stacked in a notional third dimension
860perpendicular to the screen surface, and thus ordered from ``highest'' 882perpendicular to the screen surface, and thus ordered from ``highest''
861to ``lowest''. Where two X windows overlap, the one higher up covers 883to ``lowest''. Where two windows overlap, the one higher up covers
862the one underneath. Even an X window at the bottom of the stack can be 884the one underneath. Even a window at the bottom of the stack can be
863seen if no other X window overlaps it. 885seen 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
868to change the order frequently. @dfn{Raising} an X window means moving 890to change the order frequently. @dfn{Raising} a window means moving
869it ``up'', to the top of the stack. @dfn{Lowering} an X window means 891it ``up'', to the top of the stack. @dfn{Lowering} a window means
870moving it to the bottom of the stack. This motion is in the notional 892moving it to the bottom of the stack. This motion is in the notional
871third dimension only, and does not change the position of the X window 893third dimension only, and does not change the position of the window
872on the screen. 894on the screen.
873 895
874You 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
877This function raises frame @var{frame}. 899This function raises frame @var{frame}.
@@ -888,7 +910,7 @@ that the minibuffer window is in.
888 910
889You can also enable auto-raise (raising automatically when a frame is 911You can also enable auto-raise (raising automatically when a frame is
890selected) or auto-lower (lowering automatically when it is deselected) 912selected) or auto-lower (lowering automatically when it is deselected)
891for any frame using frame parameters. @xref{X Frame Parameters}. 913for 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,
898all their properties, and the window configuration of each one. 920all 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
901This function returns a frame configuration list that describes 924This 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
925button. 948button.
926 949
927@defspec track-mouse body@dots{} 950@defspec track-mouse body@dots{}
928Execute @var{body}, meanwhile generating input events for mouse motion. 951This special form executes @var{body}, with generation of mouse motion
929The code in @var{body} can read these events with @code{read-event} or 952events enabled. Typically @var{body} would use @code{read-event} to
930@code{read-key-sequence}. @xref{Motion Events}, for the format of mouse 953read the motion events and modify the display accordingly. @xref{Motion
931motion events. 954Events}, for the format of mouse motion events.
932 955
933The value of @code{track-mouse} is that of the last form in @var{body}. 956The value of @code{track-mouse} is that of the last form in @var{body}.
957You should design @var{body} to return when it sees the up-event that
958indicates the release of the button, or whatever kind of event means
959it is time to stop tracking.
934@end defspec 960@end defspec
935 961
936The usual purpose of tracking mouse motion is to indicate on the screen 962The usual purpose of tracking mouse motion is to indicate on the screen
@@ -947,7 +973,7 @@ Lisp-level mouse tracking.
947 973
948These functions change the screen appearance instantaneously. The 974These functions change the screen appearance instantaneously. The
949effect is transient, only until the next ordinary Emacs redisplay. That 975effect is transient, only until the next ordinary Emacs redisplay. That
950is ok for mouse tracking, since it doesn't make sense for mouse tracking 976is OK for mouse tracking, since it doesn't make sense for mouse tracking
951to change the text, and the body of @code{track-mouse} normally reads 977to change the text, and the body of @code{track-mouse} normally reads
952the events itself and does not do redisplay. 978the 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
1019user can choose from with the mouse. 1045the user can choose an alternative with the mouse.
1020 1046
1021@defun x-popup-menu position menu 1047@defun x-popup-menu position menu
1022This function displays a pop-up menu and returns an indication of 1048This 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
1087different (if Emacs uses an X toolkit), it always appears in the center 1113different, it always appears in the center of a frame, and it has just
1088of a frame, and it has just one level and one pane. The main use of 1114one level and one pane. The main use of dialog boxes is for asking
1089dialog boxes is for asking questions that the user can answer with 1115questions that the user can answer with ``yes'', ``no'', and a few other
1090``yes'', ``no'', and a few other alternatives. The functions 1116alternatives. 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 1117dialog boxes instead of the keyboard, when called from commands invoked
1092keyboard, when called from commands invoked by mouse clicks. 1118by mouse clicks.
1093 1119
1094@defun x-popup-dialog position contents 1120@defun x-popup-dialog position contents
1095This function displays a pop-up dialog box and returns an indication of 1121This 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
1122frame matters. 1148frame matters.
1123 1149
1124If your Emacs executable does not use an X toolkit, then it cannot 1150In some configurations, Emacs cannot display a real dialog box; so
1125display a real dialog box; so instead it displays the same items in a 1151instead it displays the same items in a pop-up menu in the center of the
1126pop-up menu in the center of the frame. 1152frame.
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
1135various situations: 1161various 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
1150affect existing frames; however, if you set the mouse color of a frame, 1176affect existing frames; however, if you set the mouse color of a frame,
1151that also updates its pointer shapes based on the current values of 1177that also updates its pointer shapes based on the current values of
1152these variables. @xref{X Frame Parameters}. 1178these 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
1155defined in the file @file{lisp/term/x-win.el}. Use @kbd{M-x apropos 1181defined 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
1162The X server records a set of @dfn{selections} which permit transfer of 1188The 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
1223This function returns a list of available font names that match 1249This 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
1225then the list is limited to fonts that are the same size as @var{face} 1251specified, then the list is limited to fonts that are the same size as
1226currently is on @var{frame}. 1252@var{face} currently is on @var{frame}.
1227 1253
1228The argument @var{pattern} should be a string, perhaps with wildcard 1254The argument @var{pattern} should be a string, perhaps with wildcard
1229characters: the @samp{*} character matches any substring, and the 1255characters: 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
115This function returns @code{t} if @var{object} is any kind of function; 115This function returns @code{t} if @var{object} is any kind of function,
116that is, anything that could be called as a function. 116or 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
386accessed. 386accessed.
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
389functions in your program, even those that are only called from within 389functions in your program, even those that are called only from within
390your program. Documentation strings are like comments, except that they 390your program. Documentation strings are like comments, except that they
391are easier to access. 391are 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
420function without a name is nonsensical. In Lisp, a function in the 420function without a name is nonsensical. In Lisp, a function in the
421strictest sense has no name. It is simply a list whose first element is 421strictest 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
425when you put the function in the symbol's @dfn{function cell} 425when 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
580which function to call, and how many arguments to give it, when you 580which function to call, and how many arguments to give it, when you
581write the program. Usually that's just what you want. Occasionally you 581write the program. Usually that's just what you want. Occasionally you
582need to compute at run time which function to call. To do that, use the 582need to compute at run time which function to call. To do that, use the
583functions @code{funcall} and @code{apply}. 583function @code{funcall}. When you also need to determine at run time
584how 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}.
690list or other collection. Emacs Lisp has several such functions; 691list 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
692here. @xref{Creating Symbols}, for the function @code{mapatoms} which 693here. @xref{Creating Symbols}, for the function @code{mapatoms} which
693maps over the symbols in an obarray. @xref{Char-Tables}, for the 694maps over the symbols in an obarray.
694function @code{map-char-table}, which maps over the elements in a 695
695char-table. 696 These mapping functions do not allow char-tables because a char-table
697is a sparse array whose nominal range of indices is very large. To map
698over a char-table in a way that deals properly with its sparse nature,
699use 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}
699in turn, and returns a list of the results. 703in turn, and returns a list of the results.
700 704
701The argument @var{sequence} may be a list, a vector, or a string. The 705The argument @var{sequence} can be any kind of sequence except a
706char-table; that is, a list, a vector, a bool-vector, or a string. The
702result is always a list. The length of the result is the same as the 707result is always a list. The length of the result is the same as the
703length of @var{sequence}. 708length 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.
725Return the list of results." 730Return 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
747other suitable punctuation. 752other suitable punctuation.
748 753
749The argument @var{function} must be a function that can take one 754The argument @var{function} must be a function that can take one
750argument and return a string. 755argument and return a string. The argument @var{sequence} can be any
756kind of sequence except a char-table; that is, a list, a vector, a
757bool-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
825Here we define a function that uses @code{change-property}, 832Here we define a function that uses @code{change-property},
826passing a function that doubles its argument: 833passing 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
981Copying one symbol's function definition to another. (In other words, 988Copying one symbol's function definition to another---in other words,
982making an alternate name for a function.) 989making an alternate name for a function. (If you think of this as the
990definition of the new name, you should use @code{defalias} instead of
991@code{fset}; see @ref{Defining Functions}.)
983 992
984@item 993@item
985Giving a symbol a function definition that is not a list and therefore 994Giving a symbol a function definition that is not a list and therefore
986cannot be made with @code{defun}. For example, you can use @code{fset} 995cannot be made with @code{defun}. For example, you can use @code{fset}
987to give a symbol @code{s1} a function definition which is another symbol 996to 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
992In constructs for defining or altering functions. If @code{defun} 1002In 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
997Here are examples of the first two uses: 1007Here 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
1035See also the related function @code{defalias}, in @ref{Defining 1040@group
1036Functions}. 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
1058file is loaded before moving aside the old definition of @code{foo}. 1068file 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
1061redefine a function defined elsewhere. 1071redefine a function defined elsewhere. It is cleaner to use the advice
1072facility (@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
1083generally should not make large functions inline. 1094generally should not make large functions inline.
1084 1095
1085It's possible to define a macro to expand into the same code that an 1096It's possible to define a macro to expand into the same code that an
1086inline function would execute. But the macro would have a limitation: 1097inline function would execute. (@xref{Macros}.) But the macro would be
1087you can use it only explicitly---a macro cannot be called with 1098limited 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
1089convert an ordinary function into a macro. (@xref{Macros}.) To convert 1100convert an ordinary function into a macro. To convert it into an inline
1090it into an inline function is very easy; simply replace @code{defun} 1101function is very easy; simply replace @code{defun} with @code{defsubst}.
1091with @code{defsubst}. Since each argument of an inline function is 1102Since each argument of an inline function is evaluated exactly once, you
1092evaluated exactly once, you needn't worry about how many times the 1103needn't worry about how many times the body uses the arguments, as you
1093body uses the arguments, as you do for macros. (@xref{Argument 1104do for macros. (@xref{Argument Evaluation}.)
1094Evaluation}.)
1095 1105
1096Inline functions can be used and open-coded later on in the same file, 1106Inline functions can be used and open-coded later on in the same file,
1097following the definition, just like macros. 1107following the definition, just like macros.
@@ -1127,6 +1137,9 @@ See @ref{Eval}.
1127@item funcall 1137@item funcall
1128See @ref{Calling Functions}. 1138See @ref{Calling Functions}.
1129 1139
1140@item function
1141See @ref{Anonymous Functions}.
1142
1130@item ignore 1143@item ignore
1131See @ref{Calling Functions}. 1144See @ref{Calling Functions}.
1132 1145
@@ -1145,6 +1158,9 @@ See @ref{Creating Symbols}.
1145@item mapcar 1158@item mapcar
1146See @ref{Mapping Functions}. 1159See @ref{Mapping Functions}.
1147 1160
1161@item map-char-table
1162See @ref{Char-Tables}.
1163
1148@item mapconcat 1164@item mapconcat
1149See @ref{Mapping Functions}. 1165See @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.
50sentence (or two complete sentences) since some commands, such as 50sentence (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
52string. Also, you should not indent the second line of a documentation 52string. Also, you should not indent the second line of a documentation
53string, if you have one, because that looks odd when you use @kbd{C-h f} 53string, 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}. 55view 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
58stand for key bindings to be looked up in the current keymaps when the 58stand for key bindings to be looked up in the current keymaps when the
59documentation is displayed. This allows documentation strings to refer 59documentation is displayed. This allows documentation strings to refer
60to the keys for related commands and be accurate even when a user 60to 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
132value containing the actual (current) key bindings. 132value containing the actual (current) key bindings.
133 133
134The function @code{documentation} signals a @code{void-function} error 134The function @code{documentation} signals a @code{void-function} error
135if @var{function} has no function definition. However, it is ok if 135if @var{function} has no function definition. However, it is OK if
136the function definition has no documentation string. In that case, 136the 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
258This variable holds the name of the directory which should contion the 258This variable holds the name of the directory which should contain the
259file @code{"DOC-@var{version}"} that contains documentation strings for 259file @code{"DOC-@var{version}"} that contains documentation strings for
260built-in and preloaded functions and variables. 260built-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}@}
291stands for a summary of the value of @var{mapvar}. The value should be 291stands for a summary of the keymap which is the value of the variable
292a 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}>
295stands for no text itself. It is used only for a side effect: it 295stands for no text itself. It is used only for a side effect: it
296specifies @var{mapvar} as the keymap for any following 296specifies @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
332SPC minibuffer-complete-word 332SPC minibuffer-complete-word
333TAB minibuffer-complete 333TAB minibuffer-complete
334LFD minibuffer-complete-and-exit 334C-j minibuffer-complete-and-exit
335RET minibuffer-complete-and-exit 335RET minibuffer-complete-and-exit
336C-g abort-recursive-edit 336C-g abort-recursive-edit
337" 337"
@@ -372,7 +372,7 @@ This function returns a string describing @var{event} in the standard
372Emacs notation for keyboard input. A normal printing character appears 372Emacs notation for keyboard input. A normal printing character appears
373as itself, but a control character turns into a string starting with 373as 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-},
375and space, linefeed, etc.@: appear as @samp{SPC}, @samp{LFD}, etc. A 375and space, tab, etc.@: appear as @samp{SPC}, @samp{TAB}, etc. A
376function key symbol appears as itself. An event that is a list appears 376function key symbol appears as itself. An event that is a list appears
377as the name of the symbol in the @sc{car} of the list. 377as 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
423about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here 423about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here
424we describe some program-level interfaces to the same information. 424we 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
427This function finds all symbols whose names contain a match for the 427This function finds all symbols whose names contain a match for the
428regular expression @var{regexp}, and returns a list of them 428regular 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.
434If @var{do-all} is non-@code{nil}, then @code{apropos} also shows 434If @var{do-all} is non-@code{nil}, then @code{apropos} also shows
435key bindings for the functions that are found. 435key bindings for the functions that are found.
436 436
437If @var{predicate} is non-@code{nil}, it should be a function to be
438called on each symbol that has matched @var{regexp}. Only symbols for
439which @var{predicate} returns a non-@code{nil} value are listed or
440displayed.
441
442In the first of the following examples, @code{apropos} finds all the 437In the first of the following examples, @code{apropos} finds all the
443symbols with names containing @samp{exec}. In the second example, it 438symbols with names containing @samp{exec}. (We don't show here the
444finds and returns only those symbols that are also commands. (We don't 439output that results in the @samp{*Help*} buffer.)
445show 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* ----------
462Buffer-menu-execute
463 Function: Save and/or delete buffers marked with
464 M-x Buffer-menu-save or M-x Buffer-menu-delete commands.
465execute-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
473The command @kbd{C-h a} (@code{command-apropos}) calls @code{apropos},
474but specifies a @var{predicate} that restricts the output to symbols
475that 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
484This function differs from @code{apropos} in that it searches
485documentation strings as well as symbol names for matches for
486@var{regexp}. By default, it searches the documentation strings for
487preloaded functions and variables only. If @var{do-all} is
488non-@code{nil}, it scans the names and documentation strings of all
489functions 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
524The value of this variable is the help character---the character that 483The value of this variable is the help character---the character that
525Emacs recognizes as meaning Help. By default, it is 8, which is 484Emacs 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
527non-@code{nil} Lisp expression, it evaluates that expression, and 486non-@code{nil} Lisp expression, it evaluates that expression, and
528displays the result in a window if it is a string. 487displays the result in a window if it is a string.
@@ -539,6 +498,13 @@ binding as a subcommand of the prefix key, it runs
539subcommands of the prefix key. 498subcommands of the prefix key.
540@end defvar 499@end defvar
541 500
501@tindex help-event-list
502@defvar help-event-list
503The value of this variable is a list of event types that serve as
504alternative ``help characters.'' These events are handled just like the
505event specified by @code{help-char}.
506@end defvar
507
542@defvar help-form 508@defvar help-form
543If this variable is non-@code{nil}, its value is a form to evaluate 509If this variable is non-@code{nil}, its value is a form to evaluate
544whenever the character @code{help-char} is read. If evaluating the form 510whenever the character @code{help-char} is read. If evaluating the form
@@ -546,19 +512,19 @@ produces a string, that string is displayed.
546 512
547A command that calls @code{read-event} or @code{read-char} probably 513A command that calls @code{read-event} or @code{read-char} probably
548should bind @code{help-form} to a non-@code{nil} expression while it 514should bind @code{help-form} to a non-@code{nil} expression while it
549does input. (The exception is when @kbd{C-h} is meaningful input.) 515does input. (The time when you should not do this is when @kbd{C-h} has
550Evaluating this expression should result in a string that explains what 516some other meaning.) Evaluating this expression should result in a
551the input is for and how to enter it properly. 517string that explains what the input is for and how to enter it properly.
552 518
553Entry to the minibuffer binds this variable to the value of 519Entry 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
558This variable holds a function to print help for a prefix character. 524This variable holds a function to print help for a prefix key. The
559The function is called when the user types a prefix key followed by the 525function is called when the user types a prefix key followed by the help
560help character, and the help character has no binding after that prefix. 526character, and the help character has no binding after that prefix. The
561The variable's default value is @code{describe-prefix-bindings}. 527variable'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
12internal aspects of GNU Emacs that may be of interest to C programmers. 12internal 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,
118you must run Emacs with @samp{-batch}. 119you 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
123running. 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
133Called interactively, the function prints the same information in the
134echo area.
135@end deffn
136
137@defvar emacs-build-time
138The value of this variable is the time at which Emacs was built at the
139local site.
140
141@example
142@group
143emacs-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
150The value of this variable is the version of Emacs being run. It is a
151string such as @code{"20.3.1"}. The last number in this string is not
152really part of the Emacs release version number; it is incremented each
153time 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
159The major version number of Emacs, as an integer. For Emacs version
16020.2, the value is 20.
161@end defvar
162
163@defvar emacs-minor-version
164The minor version number of Emacs, as an integer. For Emacs version
16520.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.
221You should not change this flag in a running Emacs. 175You 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
255Here 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.
321The number of symbols for which space has been obtained from the 280The number of symbols for which space has been obtained from the
322operating system, but that are not currently being used. 281operating system, but that are not currently being used.
323 282
324@item used-markers 283@item used-miscs
325The number of markers in use. 284The number of miscellaneous objects in use. These include markers and
285overlays, plus certain objects not visible to users.
326 286
327@item free-markers 287@item free-miscs
328The number of markers for which space has been obtained from the 288The number of miscellaneous objects for which space has been obtained
329operating system, but that are not currently being used. 289from the operating system, but that are not currently being used.
330 290
331@item used-string-chars 291@item used-string-chars
332The total size of all strings, in characters. 292The 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
337memory used by Lisp data, broken down by data type. By contrast, the
338function @code{memory-limit} provides information on the total amount of
339memory Emacs is currently using.
340
376@c Emacs 19 feature 341@c Emacs 19 feature
377@defun memory-limit 342@defun memory-limit
378This function returns the address of the last byte Emacs has allocated, 343This 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
383memory usage. 348memory 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
355of memory allocation that Emacs has done, broken down by data type.
356Note the difference between these and the values returned by
357@code{(garbage-collect)}; those count objects that currently exist, but
358these count the number or size of all allocations, including those for
359objects that have since been freed.
360
361@defvar cons-cells-consed
362The total number of cons cells that have been allocated so far
363in this Emacs session.
364@end defvar
365
366@defvar floats-consed
367The total number of floats that have been allocated so far
368in this Emacs session.
369@end defvar
370
371@defvar vector-cells-consed
372The total number of vector cells that have been allocated so far
373in this Emacs session.
374@end defvar
375
376@defvar symbols-consed
377The total number of symbols that have been allocated so far
378in this Emacs session.
379@end defvar
380
381@defvar string-chars-consed
382The total number of string characters that have been allocated so far
383in this Emacs session.
384@end defvar
385
386@defvar misc-objects-consed
387The total number of miscellaneous objects that have been allocated so
388far in this Emacs session. These include markers and overlays, plus
389certain objects not visible to users.
390@end defvar
391
392@defvar intervals-consed
393The total number of intervals that have been allocated so far
394in 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
577with a value that is either @code{t} or @code{nil}. 588with 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},
591you must protect it for garbage-collection by calling @code{staticpro}
592in @code{syms_of_@var{filename}}, like this:
593
594@example
595staticpro (&@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.
580This comes from the code for the X Window System, and it demonstrates 599This comes from the code in @file{window.c}, and it demonstrates the use
581the use of macros and functions to manipulate Lisp objects. 600of macros and functions to manipulate Lisp objects.
582 601
583@smallexample 602@smallexample
584@group 603@group
585DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 604DEFUN ("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\ 608COORDINATES 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\ 612If 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
651functions. 674functions.
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
719This field contains the conversion table for converting text to lower case. 742This 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
723This field contains the conversion table for converting text to upper case. 746This 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
727This field contains the conversion table for canonicalizing text for 750This field contains the conversion table for canonicalizing text for
728case-folding search. @xref{Case Table}. 751case-folding search. @xref{Case Tables}.
729 752
730@item case_eqv_table 753@item case_eqv_table
731This field contains the equivalence table for case-folding search. 754This 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
735This field contains the buffer's display table, or @code{nil} if it doesn't 758This 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}.
753This field is non-@code{nil} if the buffer's mark is active. 776This field is non-@code{nil} if the buffer's mark is active.
754 777
755@item local_var_alist 778@item local_var_alist
756This field contains the association list describing the variables local 779This field contains the association list describing the buffer-local
757in this buffer, and their values, with the exception of local variables 780variable bindings of this buffer, not including the built-in
758that have special slots in the buffer object. (Those slots are omitted 781buffer-local bindings that that have special slots in the buffer object.
759from this table.) @xref{Buffer-Local Variables}. 782(Those slots are omitted from this table.) @xref{Buffer-Local
783Variables}.
760 784
761@item base_buffer 785@item base_buffer
762This field holds the buffer's base buffer (if it is an indirect buffer), 786This field holds the buffer's base buffer (if it is an indirect buffer),
@@ -777,9 +801,13 @@ decreasing end position.
777This field holds a list of the overlays in this buffer that end after 801This field holds a list of the overlays in this buffer that end after
778the current overlay center position. They are sorted in order of 802the current overlay center position. They are sorted in order of
779increasing beginning position. 803increasing beginning position.
804
805@item enable_multibyte_characters
806This 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,
886this field is @code{nil}. 914this 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.
504with its own idiosyncrasies. Many of them were inspired by Maclisp, 504with its own idiosyncrasies. Many of them were inspired by Maclisp,
505which was written in the 1960's at MIT's Project MAC. Eventually the 505which was written in the 1960's at MIT's Project MAC. Eventually the
506implementors of the descendants of Maclisp came together and developed a 506implementors of the descendants of Maclisp came together and developed a
507standard for Lisp systems, called Common Lisp. 507standard for Lisp systems, called Common Lisp. In the mean time, Gerry
508Sussman and Guy Steele at MIT developed a simplified but very powerful
509dialect 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
510Lisp. If you know Common Lisp, you will notice many similarities. 512Lisp. 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
515Lisp differs from Common Lisp. If you don't know Common Lisp, don't 517Lisp differs from Common Lisp. If you don't know Common Lisp, don't
516worry about it; this manual is self-contained. 518worry about it; this manual is self-contained.
517 519
520 Emacs Lisp is not at all influenced by Scheme; but the GNU project has
521an implementation of Scheme, called Guile. We use Guile for
522extensibility 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
5473)}. Names that represent arguments or metasyntactic variables appear 5543)}. Names that represent metasyntactic variables, or arguments to a
548in this font or form: @var{first-number}. 555function 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
588evaluate to themselves. This is so that you do not need to quote them 596evaluate to themselves. This is so that you do not need to quote them
589to use them as constants in a program. An attempt to change their 597to use them as constants in a program. An attempt to change their
590values results in a @code{setting-constant} error. @xref{Accessing 598values results in a @code{setting-constant} error. The same is true of
599any symbol whose name starts with a colon (@samp{:}). @xref{Constant
591Variables}. 600Variables}.
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
675name. In addition, @samp{@point{}} indicates the location of point. 684name. 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;
677it indicates the place @emph{between} two characters where point is 686it indicates the place @emph{between} two characters where point is
678located.) 687currently 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
726appears first. It is followed on the same line by a list of parameters. 735appears first. It is followed on the same line by a list of argument
727The names used for the parameters are also used in the body of the 736names. These names are also used in the body of the description, to
728description. 737stand 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
731indicates that the arguments for subsequent parameters may be omitted 740indicates that the subsequent arguments may be omitted (omitted
732(omitted parameters default to @code{nil}). Do not write 741arguments default to @code{nil}). Do not write @code{&optional} when
733@code{&optional} when you call the function. 742you 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
736parameter) indicates that any number of arguments can follow. The value 745argument name) indicates that any number of arguments can follow. The value
737of the single following parameter will be a list of all these arguments. 746of the single following arguments name will be a list of all these arguments.
738Do not write @code{&rest} when you call the function. 747Do 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
765type. A plural of a type (such as @var{buffers}) often means a list of 774type. A plural of a type (such as @var{buffers}) often means a list of
766objects of that type. Parameters named @var{object} may be of any type. 775objects 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
768Parameters with other sorts of names (e.g., @var{new-file}) are 777with other sorts of names (e.g., @var{new-file}) are discussed
769discussed specifically in the description of the function. In some 778specifically in the description of the function. In some sections,
770sections, features common to parameters of several functions are 779features common to the arguments of several functions are described at
771described at the beginning. 780the 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
774and rest arguments. 783and 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
783optional and repeated parameters because they can break the argument 792optional and repeated arguments because they can break the argument
784list down into separate arguments in more complicated ways. 793list 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
786optional and @samp{@var{repeated-args}@dots{}} stands for zero or more 795optional 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
804If @var{from} and @var{to} are omitted, then @var{var} is bound to 814If @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
843replaced by `User Option'. 853replaced by `User Option'.
844 854
855@node Version Info
856@section Version Information
857
858 These functions and variables provide information about which
859version of Emacs is in use.
860
861@deffn Command emacs-version
862This function returns a string describing the version of Emacs that is
863running. 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
873Called interactively, the function prints the same information in the
874echo area.
875@end deffn
876
877@defvar emacs-build-time
878The value of this variable is the time at which Emacs was built at the
879local site.
880
881@example
882@group
883emacs-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
890The value of this variable is the version of Emacs being run. It is a
891string such as @code{"20.3.1"}. The last number in this string is not
892really part of the Emacs release version number; it is incremented each
893time 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
899The major version number of Emacs, as an integer. For Emacs version
90020.3, the value is 20.
901@end defvar
902
903@defvar emacs-minor-version
904The minor version number of Emacs, as an integer. For Emacs version
90520.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
45can be any Lisp objects, though only certain types are meaningful for 45can be any Lisp objects, though only certain types are meaningful for
46execution by the command loop). Given an event (or an event type) and a 46execution by the command loop). Given an event (or an event type) and a
47keymap, Emacs can get the event's definition. Events include ordinary 47keymap, Emacs can get the event's definition. Events include
48@sc{ASCII} characters, function keys, and mouse actions (@pxref{Input 48characters, function keys, and mouse actions (@pxref{Input Events}).
49Events}).
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}
127If an element of a keymap is a vector, the vector counts as bindings for 126If an element of a keymap is a vector, the vector counts as bindings for
128all the @sc{ASCII} characters; vector element @var{n} is the binding for 127all the @sc{ASCII} characters, codes 0 through 127; vector element
129the 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
130of bindings. A keymap with such a vector is called a @dfn{full keymap}. 129compact way to record lots of bindings. A keymap with such a vector is
131Other keymaps are called @dfn{sparse keymaps}. 130called a @dfn{full keymap}. Other keymaps are called @dfn{sparse
131keymaps}.
132 132
133When a keymap contains a vector, it always defines a binding for each 133When 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
135character. Such a binding of @code{nil} overrides any default binding 135character. Such a binding of @code{nil} overrides any default key
136in the keymap. However, default bindings are still meaningful for 136binding in the keymap. However, default bindings are still meaningful
137events that are not @sc{ASCII} characters. A binding of @code{nil} does 137for events that are not @sc{ASCII} characters. A binding of @code{nil}
138@emph{not} override lower-precedence keymaps; thus, if the local map 138does @emph{not} override lower-precedence keymaps; thus, if the local
139gives a binding of @code{nil}, Emacs uses the binding from the global 139map gives a binding of @code{nil}, Emacs uses the binding from the
140map. 140global 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
336keyamp defines what to do with key sequences that extend the prefix key. 336keymap defines what to do with key sequences that extend the prefix key.
337For example, @kbd{C-x} is a prefix key, and it uses a keymap that is 337For example, @kbd{C-x} is a prefix key, and it uses a keymap that is
338also stored in the variable @code{ctl-x-map}. This keymap defines 338also stored in the variable @code{ctl-x-map}. This keymap defines
339bindings for key sequences starting with @kbd{C-x}. 339bindings 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
483execute when a key is entered. Emacs searches these maps one by one, in 483execute when a key is entered. Emacs searches these maps one by one, in
484order of decreasing precedence, until it finds a binding in one of the maps. 484order of decreasing precedence, until it finds a binding in one of the
485maps. The procedure for searching a single keymap is called @dfn{key
486lookup}; see @ref{Key Lookup}.
485 487
486 Normally, Emacs @emph{first} searches for the key in the minor mode 488Normally, Emacs first searches for the key in the minor mode
487maps (one map at a time); if they do not supply a binding for the key, 489maps (one map at a time); if they do not supply a binding for the key,
488Emacs searches the local map; if that too has no binding, Emacs then 490Emacs searches the local map; if that too has no binding, Emacs then
489searches the global map. However, if @code{overriding-local-map} is 491searches the global map. However, if @code{overriding-local-map} is
490non-@code{nil}, Emacs searches that map first, before the global map. 492non-@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
497same local keymap, you can think of the keymap as local to the mode. A 496same local keymap, you can think of the keymap as local to the mode. A
498change to the local keymap of a buffer (using @code{local-set-key}, for 497change to the local keymap of a buffer (using @code{local-set-key}, for
499example) is seen also in the other buffers that share that keymap. 498example) 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
502other major modes exist even if they have not yet been used. These 501modes exist even if they have not yet been used. These local maps are
503local maps are the values of the variables @code{lisp-mode-map}, 502the 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 503modes, which are less frequently used, the local keymap is constructed
505frequently used, the local keymap is constructed only when the mode is 504only when the mode is used for the first time in a session.
506used 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
509and exit commands. @xref{Intro to Minibuffers}. 507and exit commands. @xref{Intro to Minibuffers}.
@@ -593,11 +591,8 @@ enables or disables a minor mode. @xref{Keymaps and Minor Modes}.
593Note that elements of @code{minor-mode-map-alist} do not have the same 591Note that elements of @code{minor-mode-map-alist} do not have the same
594structure as elements of @code{minor-mode-alist}. The map must be the 592structure 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
596do. 594do. The @sc{cadr} can be either a keymap (a list) or a symbol
597 595whose function definition is a keymap.
598What's more, the keymap itself must appear in the @sc{cdr}. It does not
599work to store a variable in the @sc{cdr} and make the map the value of
600that variable.
601 596
602When more than one minor mode keymap is active, their order of priority 597When more than one minor mode keymap is active, their order of priority
603is the order of @code{minor-mode-map-alist}. But you should design 598is the order of @code{minor-mode-map-alist}. But you should design
@@ -614,12 +609,12 @@ Lookup}).
614This variable allows major modes to override the key bindings for 609This variable allows major modes to override the key bindings for
615particular minor modes. The elements of this alist look like the 610particular minor modes. The elements of this alist look like the
616elements of @code{minor-mode-map-alist}: @code{(@var{variable} 611elements 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}. 614element 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
622buffers. 617all 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
690looking up an event type in a keymap. (This doesn't include the item 685looking up an event type in a keymap. (This doesn't include the item
691string and other extra elements in menu key bindings because 686string 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
693the returned value.) While any Lisp object may be stored in a keymap as 688the returned value.) While any Lisp object may be stored in a keymap as
694a keymap entry, not all make sense for key lookup. Here is a list of 689a keymap entry, not all make sense for key lookup. Here is a table of
695the meaningful kinds of keymap entries: 690the 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
702has no default binding, that is equivalent to a binding of @code{nil} 697has no default binding, that is equivalent to a binding of @code{nil}
703for that event type. 698for that event type.
704 699
705@item @var{keymap}
706@cindex keymap in keymap
707The events used so far in the lookup form a prefix key. The next
708event 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
712The events used so far in the lookup form a complete key, 702The 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
718used so far in the lookup form a complete key, and the array is its 708used so far in the lookup form a complete key, and the array is its
719binding. See @ref{Keyboard Macros}, for more information. 709binding. See @ref{Keyboard Macros}, for more information.
720 710
711@item @var{keymap}
712@cindex keymap in keymap
713The events used so far in the lookup form a prefix key. The next
714event 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
723The meaning of a list depends on the types of the elements of the list. 718The 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
810This function returns the definition of @var{key} in @var{keymap}. If 805This function returns the definition of @var{key} in @var{keymap}. All
811the string or vector @var{key} is not a valid key sequence according to 806the other functions described in this chapter that look up keys use
812the prefix keys specified in @var{keymap}, it must be ``too long'' and 807@code{lookup-key}. Here are examples:
813have extra events at the end that do not fit into a single key sequence.
814Then 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
818If @var{accept-defaults} is non-@code{nil}, then @code{lookup-key}
819considers default bindings as well as bindings for the specific events
820in @var{key}. Otherwise, @code{lookup-key} reports only bindings for
821the specific sequence @var{key}, ignoring default bindings except when
822you explicitly ask about them. (To do this, supply @code{t} as an
823element of @var{key}; see @ref{Format of Keymaps}.)
824
825All 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 820If the string or vector @var{key} is not a valid key sequence according
821to the prefix keys specified in @var{keymap}, it must be ``too long''
822and have extra events at the end that do not fit into a single key
823sequence. Then the value is a number, the number of events at the front
824of @var{key} that compose a complete key.
825
826@c Emacs 19 feature
827If @var{accept-defaults} is non-@code{nil}, then @code{lookup-key}
828considers default bindings as well as bindings for the specific events
829in @var{key}. Otherwise, @code{lookup-key} reports only bindings for
830the specific sequence @var{key}, ignoring default bindings except when
831you explicitly ask about them. (To do this, supply @code{t} as an
832element of @var{key}; see @ref{Format of Keymaps}.)
833
834If @var{key} contains a meta character, that character is implicitly
840replaced by a two-character sequence: the value of 835replaced 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
842character. Thus, the first example below is handled by conversion into 837character. 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
932defined as the @code{backward-word} command. However, if you set 927defined 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
934translate @kbd{M-b} into @kbd{C-x b}, whose standard binding is the 929translate @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
995containing modifier names plus one base event (a character or function 990containing modifier names plus one base event (a character or function
996key name). For example, @code{(control ?a)} is equivalent to 991key 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 994numeric 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
1001precise numeric codes for the modifier bits don't appear in compiled
1002files.
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
1005keymap or if @var{key} is not a string or vector representing a key 997keymap 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
1019Every prefix of @var{key} must be a prefix key (i.e., bound to a 1011Every prefix of @var{key} must be a prefix key (i.e., bound to a keymap)
1020keymap) or undefined; otherwise an error is signaled. 1012or 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
1022If some prefix of @var{key} is undefined, then @code{define-key} defines 1014key so that the rest of @var{key} can be defined as specified.
1023it as a prefix key so that the rest of @var{key} may be defined as
1024specified.
1025 1015
1026If there was previously no binding for @var{key} in @var{keymap}, the 1016If there was previously no binding for @var{key} in @var{keymap}, the
1027new binding is added at the beginning of @var{keymap}. The order of 1017new 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
1386These are not all the keymaps you would see in an actual case. 1376These 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
1428This function creates a listing of all defined keys and their 1418This function creates a listing of all current key bindings, and
1429definitions. It writes the listing in a buffer named @samp{*Help*} and 1419displays it in a buffer named @samp{*Help*}. The text is grouped by
1430displays it in a window. 1420modes---minor modes first, then the major mode, then global bindings.
1431 1421
1432If @var{prefix} is non-@code{nil}, it should be a prefix key; then the 1422If @var{prefix} is non-@code{nil}, it should be a prefix key; then the
1433listing includes only keys that start with @var{prefix}. 1423listing 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
1484an existing menu, you can specify its position in the menu using 1474an 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
1487The individual bindings in the menu keymap should have item 1477@menu
1488strings; these strings become the items displayed in the menu. A 1478* Simple Menu Items::
1489binding 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
1486looks 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
1495The item string for a binding should be short---one or two words. It 1492The @sc{car}, @var{item-string}, is the string to be displayed in the
1496should describe the action of the command it corresponds to. 1493menu. It should be short---preferably one to three words. It should
1494describe the action of the command it corresponds to.
1497 1495
1498You can also supply a second string, called the help string, as follows: 1496You 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
1504Currently Emacs does not actually use @var{help-string}; it knows only 1502Currently 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}.
1506In the future we may use @var{help-string} as extended documentation for 1504In the future we may use @var{help-string} as extended documentation for
1507the menu item, available on request. 1505the menu item, available on request.
1508 1506
1509As far as @code{define-key} is concerned, @var{string} and 1507As 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
1514If @var{real-binding} is @code{nil}, then @var{string} appears in the 1512If @var{real-binding} is @code{nil}, then @var{item-string} appears in
1515menu but cannot be selected. 1513the menu but cannot be selected.
1516 1514
1517If @var{real-binding} is a symbol and has a non-@code{nil} 1515If @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
1520used to display a menu, Emacs evaluates the expression, and it enables 1518used to display a menu, Emacs evaluates the expression, and it enables
1521the menu item only if the expression's value is non-@code{nil}. When a 1519the menu item only if the expression's value is non-@code{nil}. When a
1522menu item is disabled, it is displayed in a ``fuzzy'' fashion, and 1520menu item is disabled, it is displayed in a ``fuzzy'' fashion, and
1523cannot be selected with the mouse. 1521cannot be selected.
1524 1522
1525The menu bar does not recalculate which items are enabled every time you 1523The menu bar does not recalculate which items are enabled every time you
1526look at a menu. This is because the X toolkit requires the whole tree 1524look 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
1540Don't put these sublists in the menu item yourself; menu display 1539Don't put these sublists in the menu item yourself; menu display
1541calculates them automatically. Don't add keyboard equivalents to the 1540calculates them automatically. Don't mention keyboard equivalents in
1542item strings in a mouse menu, since that is redundant. 1541the item strings themselves, since that is redundant.
1543 1542
1544Sometimes it is useful to make menu items that use the ``same'' command 1543Sometimes it is useful to make menu items that use the ``same'' command
1545but with different enable conditions. You can do this by defining alias 1544but 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}
1568causes menu items for @code{make-read-only} and @code{make-writable} to 1567causes menu items for @code{make-read-only} and @code{make-writable} to
1569show the keyboard bindings for @code{toggle-read-only}. 1568show 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
1574alternative to the simple format. It consists of a list that starts
1575with the symbol @code{menu-item}. To define a non-selectable string,
1576the item looks like this:
1577
1578@example
1579(menu-item @var{item-name})
1580@end example
1581
1582@noindent
1583where 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
1586item 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
1594Here, @var{item-name} is an expression which evaluates to the menu item
1595string. 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
1598other information. Here is a table of the properties that are supported:
1599
1600@table @code
1601@item :enable FORM
1602The result of evaluating @var{form} determines whether the item is
1603enabled (non-@code{nil} means yes).
1604
1605@item :visible FORM
1606The result of evaluating @var{form} determines whether the item should
1607actually appear in the menu (non-@code{nil} means yes). If the item
1608does not appear, then the menu is displayed as if this item were
1609not defined at all.
1610
1611@item :help @var{help}
1612The value of this property, @var{help}, is the extra help string (not
1613currently used).
1614
1615@item :button (@var{type} . @var{selected})
1616This property provides a way to define radio buttons and toggle buttons.
1617The @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
1619result of evaluating it says whether this button is currently selected.
1620
1621@item :filter @var{filter-fn}
1622This property provides a way to compute the menu item dynamically.
1623The property value @var{filter-fn} should be a function of one argument;
1624when it is called, its argument will be @var{real-binding}. The
1625function 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
1574The 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
1575definition of a prefix key. 1632definition of a prefix key. (A Lisp program can explicitly pop up a
1633menu and receive the user's choice---see @ref{Pop-Up Menus}.)
1576 1634
1577If 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
1578by popping up a visible menu, so that the user can select a choice with 1636by popping up a visible menu, so that the user can select a choice with
1579the mouse. When the user clicks on a menu item, the event generated is 1637the mouse. When the user clicks on a menu item, the event generated is
1580whatever character or symbol has the binding that brought about that 1638whatever character or symbol has the binding that brought about that
1581menu item. (A menu item may generate a series of events if the menu has 1639menu item. (A menu item may generate a series of events if the menu has
1582multiple levels or comes from the menu bar.) 1640multiple levels or comes from the menu bar.)
1583 1641
1584It'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
1585the user can select a menu item by releasing the button. 1643the user can select a menu item by releasing the button.
1586 1644
1587A single keymap can appear as multiple menu panes, if you explicitly 1645 A single keymap can appear as multiple menu panes, if you explicitly
1588arrange for this. The way to do this is to make a keymap for each pane, 1646arrange for this. The way to do this is to make a keymap for each pane,
1589then create a binding for each of those maps in the main keymap of the 1647then create a binding for each of those maps in the main keymap of the
1590menu. Give each of these bindings an item string that starts with 1648menu. 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,
1594which appears along with the other panes explicitly created for the 1652which appears along with the other panes explicitly created for the
1595submaps. 1653submaps.
1596 1654
1597X toolkit menus don't have panes; instead, they can have submenus. 1655 X toolkit menus don't have panes; instead, they can have submenus.
1598Every nested keymap becomes a submenu, whether the item string starts 1656Every nested keymap becomes a submenu, whether the item string starts
1599with @samp{@@} or not. In a toolkit version of Emacs, the only thing 1657with @samp{@@} or not. In a toolkit version of Emacs, the only thing
1600special about @samp{@@} at the beginning of an item string is that the 1658special 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
1603You can also get multiple panes from separate keymaps. The full 1661 You can also produce multiple panes or submenus from separate keymaps.
1604definition of a prefix key always comes from merging the definitions 1662The full definition of a prefix key always comes from merging the
1605supplied by the various active keymaps (minor mode, local, and 1663definitions supplied by the various active keymaps (minor mode, local,
1606global). When more than one of these keymaps is a menu, each of them 1664and global). When more than one of these keymaps is a menu, each of
1607makes a separate pane or panes. @xref{Active Keymaps}. 1665them makes a separate pane or panes (when Emacs does not use an
1608 1666X-toolkit) or a separate submenu (when using an X-toolkit).
1609In toolkit versions of Emacs, menus don't have panes, so submenus are 1667@xref{Active Keymaps}.
1610used to represent the separate keymaps. Each keymap's contribution
1611becomes one submenu.
1612
1613A Lisp program can explicitly pop up a menu and receive the user's
1614choice. 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
1718Next 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
1714command. 1768command.
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
1717might do it this way: 1771can 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
1738for the menu bar, the item appears just once. If the user clicks on 1792for the menu bar, the item appears just once. If the user clicks on
1739that menu bar item, it brings up a single, combined submenu containing 1793that menu bar item, it brings up a single, combined menu containing
1740all the subcommands of that item---the global subcommands, the local 1794all the subcommands of that item---the global subcommands, the local
1741subcommands, and the minor mode subcommands, all together. 1795subcommands, 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
1744determining the menu bar contents. That is, the menu bar is computed 1798determining the menu bar contents. That is, the menu bar is computed
@@ -1749,7 +1803,7 @@ were @code{nil}. @xref{Active Keymaps}.
1749parameter must be greater than zero. Emacs uses just one line for the 1803parameter must be greater than zero. Emacs uses just one line for the
1750menu bar itself; if you specify more than one line, the other lines 1804menu bar itself; if you specify more than one line, the other lines
1751serve to separate the menu bar from the windows in the frame. We 1805serve to separate the menu bar from the windows in the frame. We
1752recommend 1 or 2 as the value of @code{menu-bar-lines}. @xref{X Frame 1806recommend 1 or 2 as the value of @code{menu-bar-lines}. @xref{Window Frame
1753Parameters}. 1807Parameters}.
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
1801This variable holds a list of fake function keys for items to display at 1855This variable holds a list of fake function keys for items to display at
1802the end of the menu bar rather than in normal sequence. The default 1856the end of the menu bar rather than in normal sequence. The default
1803value is @code{(help)}; thus, the @samp{Help} menu item normally appears 1857value is @code{(help-menu)}; thus, the @samp{Help} menu item normally appears
1804at the end of the menu bar, following local menu items. 1858at 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},
1823just like @code{define-key}, but position the binding in @var{map} after 1877just like @code{define-key}, but position the binding in @var{map} after
1824the binding for the event @var{after}. The argument @var{key} should be 1878the binding for the event @var{after}. The argument @var{key} should be
1825of length one---a vector or string with just one element. But 1879of 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
1881a 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
1883the keymap.
1827 1884
1828For example, 1885Here 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
1836makes a binding for the fake function key @key{drink} and puts it 1893makes a binding for the fake function key @key{DRINK} and puts it
1837right after the binding for @key{eat}. 1894right after the binding for @key{EAT}.
1838
1839If @var{after} is @code{t}, then the new binding goes last---at the end
1840of the keymap.
1841 1895
1842Here is how to insert an item called @samp{Work} in the @samp{Signals} 1896Here is how to insert an item called @samp{Work} in the @samp{Signals}
1843menu of Shell mode, after the item @code{break}: 1897menu 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
1851Note 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
330The function @code{elt} is similar, but applies to any kind of sequence.
331For 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
355This function returns the length of @var{list}, with no risk 362This function returns the length of @var{list}, with no risk
356of either an error or an infinite loop. 363of 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
360number of distinct elements. 367number 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
371worried that it may be circular, is with @code{length}. @xref{Sequence
372Functions}.
373
363@tindex caar 374@tindex caar
364@defun caar list 375@defun caar cons-cell
365This is the same as @code{(car (car @var{list}))}. 376This 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
370This is the same as @code{(car (cdr @var{list}))} 381This is the same as @code{(car (cdr @var{cons-cell}))}
371or @code{(nth 1 @var{list})}. 382or @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
376This is the same as @code{(cdr (car @var{list}))}. 387This 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
381This is the same as @code{(cdr (cdr @var{list}))} 392This is the same as @code{(cdr (cdr @var{cons-cell}))}
382or @code{(nthcdr 2 @var{list})}. 393or @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
472This function returns a list containing all the elements of 483This 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,
474but the last one should usually be a list. All arguments except the 485bool-vectors, or strings, but the last one should usually be a list.
475last one are copied, so none of the arguments is altered. 486All arguments except the last one are copied, so none of the arguments
487is altered. (See @code{nconc} in @ref{Rearrangement}, for a way to join
488lists with no copying.)
476 489
477More generally, the final argument to @code{append} may be any Lisp 490More generally, the final argument to @code{append} may be any Lisp
478object. The final argument is not copied or converted; it becomes the 491object. 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
483in a true list. 496in a true list.
484 497
485See @code{nconc} in @ref{Rearrangement}, for a way to join lists with no
486copying.
487
488Here is an example of using @code{append}: 498Here is an example of using @code{append}:
489 499
490@example 500@example
@@ -517,8 +527,9 @@ original list:
517@group 527@group
518more-trees trees 528more-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
552This once was the usual way to copy a list, before the function 563This 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
566Here 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
555With the help of @code{apply}, we can append all the lists in a list of 575With the help of @code{apply}, we can append all the lists in a list of
556lists: 576lists:
557 577
@@ -707,14 +727,16 @@ changes them both:
707 727
708@example 728@example
709@group 729@group
710 ___ ___ ___ ___ ___ ___ 730 --- --- --- --- --- ---
711x1---> |___|___|----> |___|___|--> |___|___|--> nil 731x1---> | | |----> | | |--> | | |--> nil
732 --- --- --- --- --- ---
712 | --> | | 733 | --> | |
713 | | | | 734 | | | |
714 --> a | --> b --> c 735 --> a | --> b --> c
715 | 736 |
716 ___ ___ | 737 --- --- |
717x2--> |___|___|-- 738x2--> | | |--
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
929However, the other arguments (all but the last) must be lists.
930
907A common pitfall is to use a quoted constant list as a non-last 931A common pitfall is to use a quoted constant list as a non-last
908argument to @code{nconc}. If you do this, your program will change 932argument to @code{nconc}. If you do this, your program will change
909each time you run it! Here is what happens: 933each 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
1159The following two functions are like @code{memq} and @code{delq} but use 1183The 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
1185Predicates}.
1161 1186
1162@defun member object list 1187@defun member object list
1163The function @code{member} tests to see whether @var{object} is a member 1188The 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
88means you should consider recompiling @file{foo.el}. @xref{Byte 88means you should consider recompiling @file{foo.el}. @xref{Byte
89Compilation}. 89Compilation}.
90 90
91When loading a source file (not compiled), @code{load} performs
92character set translation just as Emacs would do when visiting the file.
93@xref{Coding Systems}.
94
91Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear 95Messages like @samp{Loading foo...} and @samp{Loading foo...done} appear
92in the echo area during loading unless @var{nomessage} is 96in the echo area during loading unless @var{nomessage} is
93non-@code{nil}. 97non-@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,
171which are then followed by the standard directories for Lisp code. 175which are then followed by the standard directories for Lisp code.
172 176
173The command line options @samp{-l} or @samp{-load} specify a Lisp
174library to load as part of Emacs startup. Since this file might be in
175the current directory, Emacs 18 temporarily adds the current directory
176to the front of @code{load-path} so the file can be found there. Newer
177Emacs versions also find such files in the current directory, but
178without altering @code{load-path}.
179
180Dumping Emacs uses a special value of @code{load-path}. If the value of 177Dumping 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
182same special value), the dumped Emacs switches to the ordinary 179same special value), the dumped Emacs switches to the ordinary
@@ -233,7 +230,7 @@ Normally, the variable's value is @code{nil}, which means those
233functions should use @code{read}. 230functions 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
239This command finds the precise file name for library @var{library}. It 236This 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
266source before the real definition. @code{autoload} is the low-level 263source before the real definition. @code{autoload} is the low-level
267primitive for autoloading; any Lisp program can call @code{autoload} at 264primitive for autoloading; any Lisp program can call @code{autoload} at
268any time. Magic comments do nothing on their own; they serve as a guide 265any time. Magic comments are the most convenient way to make a function
269for the command @code{update-file-autoloads}, which constructs calls to 266autoload, for packages installed along with Emacs. They do nothing on
270@code{autoload} and arranges to execute them when Emacs is built. Magic 267their own, but they serve as a guide for the command
271comments are the most convenient way to make a function autoload, but 268@code{update-file-autoloads}, which constructs calls to @code{autoload}
272only for packages installed along with Emacs. 269and 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
275This function defines the function (or macro) named @var{function} so as 272This function defines the function (or macro) named @var{function} so as
@@ -287,10 +284,10 @@ in the function definition itself. Specifying the documentation string
287in the call to @code{autoload} makes it possible to look at the 284in the call to @code{autoload} makes it possible to look at the
288documentation without loading the function's real definition. 285documentation without loading the function's real definition.
289 286
290If @var{interactive} is non-@code{nil}, then the function can be called 287If @var{interactive} is non-@code{nil}, that says @var{function} can be
291interactively. This lets completion in @kbd{M-x} work without loading 288called interactively. This lets completion in @kbd{M-x} work without
292the function's real definition. The complete interactive specification 289loading its real definition. The complete interactive specification is
293is not given here; it's not needed unless the user actually calls 290not 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
295definition. 292definition.
296 293
@@ -365,8 +362,9 @@ function definition, it is copied verbatim. You can also use a magic
365comment to execute a form at build time @emph{without} executing it when 362comment to execute a form at build time @emph{without} executing it when
366the file itself is loaded. To do this, write the form @emph{on the same 363the file itself is loaded. To do this, write the form @emph{on the same
367line} as the magic comment. Since it is in a comment, it does nothing 364line} as the magic comment. Since it is in a comment, it does nothing
368when you load the source file; but @code{update-file-autoloads} copies 365when you load the source file; but @kbd{M-x update-file-autoloads}
369it to @file{loaddefs.el}, where it is executed while building Emacs. 366copies it to @file{loaddefs.el}, where it is executed while building
367Emacs.
370 368
371 The following example shows how @code{doctor} is prepared for 369 The following example shows how @code{doctor} is prepared for
372autoloading with a magic comment: 370autoloading 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
404example, after you have rewritten and reinstalled a function definition 402example, after you have rewritten and reinstalled a function definition
405by editing it in a buffer, you may wish to return to the original 403by editing it in a buffer, you may wish to return to the original
406version; you can do this by reloading the file it came from. 404version; 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
411that you intend to save and reinstall, you need to byte-compile the new 409that you intend to save and reinstall, you need to byte-compile the new
412version; otherwise Emacs will load the older, byte-compiled file instead 410version; otherwise Emacs will load the older, byte-compiled file instead
413of your newer, non-compiled file! If that happens, the message 411of your newer, non-compiled file! If that happens, the message
414displayed when loading the file says, ``(compiled; source is newer'', to 412displayed when loading the file includes, @samp{(compiled; source is
415remind you to recompile. 413newer)}, 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
418file might be loaded more than once. For example, think about whether 416file 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
445has been loaded before: 443has 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
457If the library uses @code{provide} to provide a named feature, you can 454If the library uses @code{provide} to provide a named feature, you can
458use @code{featurep} to test whether the library has been loaded. 455use @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},
493the definition for @code{run-prolog} includes the following code: 488the 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
505The expression @code{(require 'comint)} loads the file @file{comint.el} 500The expression @code{(require 'comint)} loads the file @file{comint.el}
506if it has not yet been loaded. This ensures that @code{make-comint} is 501if it has not yet been loaded. This ensures that @code{make-comint} is
507defined. 502defined. Features are normally named after the files that provide them,
503so that @code{require} need not be given the file name.
508 504
509The @file{comint.el} file contains the following top-level expression: 505The @file{comint.el} file contains the following top-level expression:
510 506
@@ -541,7 +537,7 @@ feature, as in the following example.
541The compiler ignores the @code{provide}, then processes the 537The 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
543execute the @code{provide} call, so the subsequent @code{require} call 539execute the @code{provide} call, so the subsequent @code{require} call
544does nothing while loading. 540does nothing when the file is loaded.
545 541
546@defun provide feature 542@defun provide feature
547This function announces that @var{feature} is now loaded, or being 543This 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
591This function returns @code{t} if @var{feature} has been provided in the 587This function returns @code{t} if @var{feature} has been provided in the
592current Emacs session (i.e., @var{feature} is a member of 588current 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
613This command unloads the library that provided feature @var{feature}. 609This command unloads the library that provided feature @var{feature}.
614It undefines all functions, macros, and variables defined in that 610It undefines all functions, macros, and variables defined in that
615library with @code{defconst}, @code{defvar}, @code{defun}, 611library 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}.
617any autoloads formerly associated with those symbols. (Loading 613It then restores any autoloads formerly associated with those symbols.
618saves these in the @code{autoload} property of the symbol.) 614(Loading saves these in the @code{autoload} property of the symbol.)
619 615
620Ordinarily, @code{unload-feature} refuses to unload a library on which 616Ordinarily, @code{unload-feature} refuses to unload a library on which
621other loaded libraries depend. (A library @var{a} depends on library 617other 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
686the library is loaded. To do (2), you must load the library (preferably 682the library is loaded. To do (2), you must load the library (preferably
687with @code{require}). 683with @code{require}).
688 684
689But it is ok to use @code{eval-after-load} in your personal customizations 685But it is OK to use @code{eval-after-load} in your personal
690if you don't feel they must meet the design standards of programs to be 686customizations if you don't feel they must meet the design standards for
691released. 687programs meant for wider use.
692 688
693@defvar after-load-alist 689@defvar after-load-alist
694An alist of expressions to evaluate if and when particular libraries are 690An 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
12automatically local (when set) in each buffer. Many Lisp packages 12automatically become buffer-local in each buffer. Most become
13define such variables for their internal use; we don't list them here. 13buffer-local only when set; a few of them are always local in every
14buffer. Many Lisp packages define such variables for their internal
15use, 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
131Used for communication between mouse commands and scroll-bar commands. 139Ued 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
52the value @code{x}---@emph{not} the @emph{value} of @code{x}. The body 52symbol @code{x}---@emph{not} the @emph{value} of @code{x}, as it would
53of the macro uses this to construct the expansion, which is @code{(setq 53be in a function. The body of the macro uses this to construct the
54x (1+ x))}. Once the macro definition returns this expansion, Lisp 54expansion, which is @code{(setq x (1+ x))}. Once the macro definition
55proceeds to evaluate it, thus incrementing @code{x}. 55returns 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.)
195This macro object is stored in the function cell of @var{name}. The 197This macro object is stored in the function cell of @var{name}. The
196value returned by evaluating the @code{defmacro} form is @var{name}, but 198value returned by evaluating the @code{defmacro} form is @var{name}, but
197usually we ignore this value. 199usually 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
213constants and nonconstant parts. To make this easier, use the macro 215constants and nonconstant parts. To make this easier, use the @samp{`}
214@samp{`} (often called @dfn{backquote}). 216syntax (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
217elements of that list. In the simplest case, it is identical to the 219elements 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 304In old Emacs versions, before version 19.29, @samp{`} used a different
303Before Emacs version 19.29, @samp{`} used a different syntax which 305syntax which required an extra level of parentheses around the entire
304required an extra level of parentheses around the entire backquote 306backquote construct. Likewise, each @samp{,} or @samp{,@@} substitution
305construct. Likewise, each @samp{,} or @samp{,@@} substition required an 307required an extra level of parentheses surrounding both the @samp{,} or
306extra level of parentheses surrounding both the @samp{,} or @samp{,@@} 308@samp{,@@} and the following expression. The old syntax required
307and the following expression. The old syntax required whitespace 309whitespace between the @samp{`}, @samp{,} or @samp{,@@} and the
308between the @samp{`}, @samp{,} or @samp{,@@} and the following 310following expression.
309expression.
310 311
311This syntax is still accepted, for compatibility with old Emacs 312This syntax is still accepted, for compatibility with old Emacs
312versions, but we recommend not using it in new programs. 313versions, 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 374The 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
376will write noise words (such as @code{from}, @code{to}, and @code{do}) 376will write noise words (such as @code{from}, @code{to}, and @code{do})
377in those positions in the macro call.) 377in those positions in the macro call.
378 378
379Here's an equivalent definition simplified through use of backquote: 379Here'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 432described in the following section.
433Proceed 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
540it probably won't do what you intend in a compiled program. The 538it probably won't do what you intend in a compiled program. The
541byte-compiler runs macro definitions while compiling the program, when 539byte-compiler runs macro definitions while compiling the program, when
542the program's own computations (which you might have wished to access 540the program's own computations (which you might have wished to access
543with @code{eval}) don't occur and its local variable bindings don't 541with @code{eval}) don't occur and its local variable bindings don't
544exist. 542exist.
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
547put the expression into the macro expansion, so that its value is 545while computing the macro expansion.} Instead, substitute the
548computed as part of executing the expansion. This is what the other 546expression into the macro expansion, so that its value will be computed
549examples in this chapter do. 547as part of executing the expansion. This is how the other examples in
548this 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
557macro definition has side effects, they will work differently depending 556macro definition has side effects, they will work differently depending
558on how many times the macro is expanded. 557on 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
561macro is called once, then the objects are constructed only once. In 560macro expansion, unless you really know what you are doing.
562other words, the same structure of objects is used each time the macro 561
563call is executed. In interpreted operation, the macro is reexpanded 562 One special kind of side effect can't be avoided: constructing Lisp
564each time, producing a fresh collection of objects each time. Usually 563objects. Almost all macro expansions include constructed lists; that is
565this does not matter---the objects have the same contents whether they 564the whole point of most macros. This is usually safe; there is just one
566are shared or not. But if the surrounding program does side effects 565case where you must be careful: when the object you construct is part of a
567on the objects, it makes a difference whether they are shared. Here is 566quoted constant in the macro expansion.
568an example: 567
568 If the macro is expanded just once, in compilation, then the object is
569constructed just once, during compilation. But in interpreted
570execution, the macro is expanded each time the macro call runs, and this
571means a new object is constructed each time.
572
573 In most clean Lisp code, this difference won't matter. It can matter
574only if you perform side-effects on the objects constructed by the macro
575definition. Thus, to avoid trouble, @strong{avoid side effects on
576objects constructed by macro definitions}. Here is an example of how
577such 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.
29A full keymap used by Command History mode. 29A 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
33A sparse keymap for subcommands of the prefix @kbd{C-x 4}. 32A 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
37A sparse keymap for subcommands of the prefix @kbd{C-x 5}. 35A 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
41A full keymap for @kbd{C-x} commands. 38A 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
101Properties menu. 98Properties menu.
102 99
103@item function-key-map 100@item function-key-map
104@vindex function-key-map
105The keymap for translating keypad and function keys.@* 101The keymap for translating keypad and function keys.@*
106If there are none, then it contains an empty sparse keymap. 102If 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
130search. 127search.
131 128
132@item key-translation-map 129@item key-translation-map
133@vindex key-translation-map
134A keymap for translating keys. This one overrides ordinary key 130A keymap for translating keys. This one overrides ordinary key
135bindings, unlike @code{function-key-map}. 131bindings, 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
155The keymap which displays the Help menu in the menu bar. 151The 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
156The 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
159The keymap which displays the Search menu in the menu bar. 160The 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.
163The keymap which displays the Tools menu in the menu bar. 164The 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
167The keymap for characters following @kbd{C-c}. Note, this is in the 167The keymap for characters following @kbd{C-c}. Note, this is in the
168global map. This map is not actually mode specific: its name was chosen 168global map. This map is not actually mode specific: its name was chosen
169to be informative for the user in @kbd{C-h b} (@code{display-bindings}), 169to 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.
174A local keymap used by Occur mode. 174A local keymap used by Occur mode.
175 175
176@item query-replace-map 176@item query-replace-map
177@vindex query-replace-map
178A local keymap used for responses in @code{query-replace} and related 177A local keymap used for responses in @code{query-replace} and related
179commands; also for @code{y-or-n-p} and @code{map-y-or-n-p}. The functions 178commands; also for @code{y-or-n-p} and @code{map-y-or-n-p}. The functions
180that use this map do not support prefix keys; they look up one event at a 179that 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
46characters immediately before and after the deleted text. Inserting 46characters immediately before and after the deleted text. Inserting
47text at the position of a marker normally leaves the marker in front of 47text at the position of a marker normally leaves the marker either in
48the new text---unless it is inserted with @code{insert-before-markers} 48front of or after the new text, depending on the marker's @dfn{insertion
49(@pxref{Insertion}). 49type} (@pxref{Marker Insertion Types})---unless the insertion is done
50with @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,
307there are two possible ways to relocate that marker: it can point before 308there are two possible ways to relocate that marker: it can point before
308the inserted text, or point after it. You can specify which one a given 309the inserted text, or point after it. You can specify which one a given
309marker should do by setting its @dfn{insertion type}. 310marker should do by setting its @dfn{insertion type}. Note that use of
311@code{insert-before-markers} ignores markers' insertion types, always
312relocating 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
398exist. However, it may become @dfn{inactive}, if Transient Mark mode is 401exist. However, it may become @dfn{inactive}, if Transient Mark mode is
399enabled. The variable @code{mark-active}, which is always local in all 402enabled. The variable @code{mark-active}, which is always buffer-local
400buffers, indicates whether the mark is active: non-@code{nil} means yes. 403in all buffers, indicates whether the mark is active: non-@code{nil}
401A command can request deactivation of the mark upon return to the editor 404means yes. A command can request deactivation of the mark upon return
402command loop by setting @code{deactivate-mark} to a non-@code{nil} value 405to the editor command loop by setting @code{deactivate-mark} to a
403(but this causes deactivation only if Transient Mark mode is enabled). 406non-@code{nil} value (but this causes deactivation only if Transient
407Mark 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
406also enables highlighting of the region when the mark is active. 410also 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
529make the mark inactive. 533make the mark inactive.
530@end defopt 534@end defopt
531 535
536@defopt mark-even-if-inactive
537If this is non-@code{nil}, Lisp programs and the Emacs user can use the
538mark even when it is inactive. This option affects the behavior of
539Transient Mark mode. When the option is non-@code{nil}, deactivation of
540the mark turns off region highlighting, but commands that use the mark
541behave as if the mark were still active.
542@end defopt
543
532@defvar deactivate-mark 544@defvar deactivate-mark
533If an editor command sets this variable non-@code{nil}, then the editor 545If an editor command sets this variable non-@code{nil}, then the editor
534command loop deactivates the mark after the command returns, but only if 546command loop deactivates the mark after the command returns (if
535Transient Mark mode is enabled. 547Transient Mark mode is enabled). All the primitives that change the
548buffer set @code{deactivate-mark}, to deactivate the mark when the
549command is finished.
536@end defvar 550@end defvar
537 551
538@defun deactivate-mark 552@defun deactivate-mark
539This function deactivates the mark, but only if Transient Mark mode 553This function deactivates the mark, if Transient Mark mode is enabled.
540is enabled. 554Otherwise it does nothing.
541@end defun 555@end defun
542 556
543@defvar mark-active 557@defvar mark-active
544The mark is active when this variable is non-@code{nil}. This variable 558The mark is active when this variable is non-@code{nil}. This variable
545is always local in each buffer. 559is 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 @@
13arguments more complicated than the single numeric prefix argument. 13arguments more complicated than the single numeric prefix argument.
14These arguments include file names, buffer names, and command names (as 14These arguments include file names, buffer names, and command names (as
15in @kbd{M-x}). The minibuffer is displayed on the bottom line of the 15in @kbd{M-x}). The minibuffer is displayed on the bottom line of the
16screen, in the same place as the echo area, but only while it is in 16frame, in the same place as the echo area, but only while it is in use
17use for reading an argument. 17for 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
101Functions}). 101Functions}).
102 102
103The first thing this function does is to activate a minibuffer and 103The first thing this function does is to activate a minibuffer and
104display it with @var{prompt-string} as the prompt. This value must be a 104display it with @var{prompt-string} as the prompt. This value must be a
105string. 105string. Then the user can edit text in the minibuffer.
106
107Then, if @var{initial-contents} is a string, @code{read-from-minibuffer}
108inserts it into the minibuffer, leaving point at the end. The
109minibuffer appears with this text as its contents.
110 106
111@strong{Usage note:} The @var{initial-contents} argument and the 107When 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
113It usually does not make sense to use both at once. In most cases, you 109the minibuffer. Normally it returns a string containing that text.
114should use @var{default}, since this permits the user to insert the 110However, if @var{read} is non-@code{nil}, @code{read-from-minibuffer}
115default value but does not burden the user with deleting it from the 111reads the text and returns the resulting Lisp object, unevaluated.
116minibuffer. 112(@xref{Input Functions}, for information about reading.)
117 113
118@c Emacs 19 feature 114The argument @var{default} specifies a default value to make available
119The value of @var{initial-contents} may also be a cons cell of the form 115through 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 117input to @code{read}, if the user enters empty input. However, in the
122from the beginning, rather than at the end. 118usual case (where @var{read} is @code{nil}, @code{read-from-minibuffer}
119does not return @var{default} when the user enters empty input; it
120returns an empty string, @code{""}. In this respect, it is different
121from all the other minibuffer input functions in this chapter.
123 122
124If @var{keymap} is non-@code{nil}, that keymap is the local keymap to 123If @var{keymap} is non-@code{nil}, that keymap is the local keymap to
125use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the 124use 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
131for saving the input and for history commands used in the minibuffer. 130for saving the input and for history commands used in the minibuffer.
132It defaults to @code{minibuffer-history}. @xref{Minibuffer History}. 131It defaults to @code{minibuffer-history}. @xref{Minibuffer History}.
133 132
134When the user types a command to exit the minibuffer,
135@code{read-from-minibuffer} uses the text in the minibuffer to produce
136its return value. Normally it simply makes a string containing that
137text. However, if @var{read} is non-@code{nil},
138@code{read-from-minibuffer} reads the text and returns the resulting
139Lisp object, unevaluated. (@xref{Input Functions}, for information
140about reading.)
141
142If the variable @code{minibuffer-allow-text-properties} is 133If the variable @code{minibuffer-allow-text-properties} is
143non-@code{nil}, then the string which is returned includes whatever text 134non-@code{nil}, then the string which is returned includes whatever text
144properties were present in the minibuffer. Otherwise all the text 135properties were present in the minibuffer. Otherwise all the text
145properties are stripped when the value is returned. 136properties are stripped when the value is returned.
146 137
147The argument @var{default} specifies a default value to make available
148through 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
151minibuffer functions, this function does @emph{not} return @var{default}
152if the user enters empty input. It returns @code{""} in that case.
153
154If the argument @var{inherit-input-method} is non-@code{nil}, then the 138If the argument @var{inherit-input-method} is non-@code{nil}, then the
155minibuffer inherits the current input method and the setting of 139minibuffer 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
157before entering the minibuffer. 141before entering the minibuffer.
142
143If @var{initial-contents} is a string, @code{read-from-minibuffer}
144inserts it into the minibuffer, leaving point at the end, before the
145user starts to edit the text. The minibuffer appears with this text as
146its initial contents.
147
148Alternatively, @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
151from 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
155same job. It does not make sense to use both features in a single call
156to @code{read-from-minibuffer}. In general, we recommend using
157@var{default}, since this permits the user to insert the default value
158when it is wanted, but does not burden the user with deleting it from
159the 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
195default, it makes the following bindings: 201default, 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
371A @dfn{minibuffer history list} records previous minibuffer inputs so 377 A @dfn{minibuffer history list} records previous minibuffer inputs so
372the user can reuse them conveniently. A history list is actually a 378the user can reuse them conveniently. A history list is actually a
373symbol, not a list; it is a variable whose value is a list of strings 379symbol, 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
376There are many separate history lists, used for different kinds of 382 There are many separate history lists, used for different kinds of
377inputs. It's the Lisp programmer's job to specify the right history 383inputs. It's the Lisp programmer's job to specify the right history
378list for each use of the minibuffer. 384list for each use of the minibuffer.
379 385
380The 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}
382which is how you specify the history list. Here are the possible 388which is how you specify the history list. Here are the possible
383values: 389values:
@@ -395,18 +401,20 @@ If you specify @var{startpos}, then you should also specify that element
395of the history as the initial minibuffer contents, for consistency. 401of the history as the initial minibuffer contents, for consistency.
396@end table 402@end table
397 403
398If 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,
400see below. You can also create your own history list variable; just 406see below. You can also create your own history list variable; just
401initialize it to @code{nil} before the first use. 407initialize it to @code{nil} before the first use.
402 408
403Both @code{read-from-minibuffer} and @code{completing-read} add new 409 Both @code{read-from-minibuffer} and @code{completing-read} add new
404elements to the history list automatically, and provide commands to 410elements to the history list automatically, and provide commands to
405allow the user to reuse items on the list. The only thing your program 411allow the user to reuse items on the list. The only thing your program
406needs to do to use a history list is to initialize it and to pass its 412needs to do to use a history list is to initialize it and to pass its
407name to the input functions when you wish. But it is safe to modify the 413name to the input functions when you wish. But it is safe to modify the
408list by hand when the minibuffer input functions are not using it. 414list 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
411The default history list for minibuffer history input. 419The 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
582This function returns a list of all possible completions of 590This 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
586If @var{collection} is a function, it is called with three arguments: 594If @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
625This function reads a string in the minibuffer, assisting the user by 633This function reads a string in the minibuffer, assisting the user by
626providing completion. It activates the minibuffer with prompt 634providing 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.
628non-@code{nil}, @code{completing-read} inserts it into the minibuffer as
629part of the input. Then it allows the user to edit the input, providing
630several commands to attempt completion.
631 636
632The actual completion is done by passing @var{collection} and 637The 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
643However, empty input is always permitted, regardless of the value of 648However, 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
651available to the user through the history commands.
646 652
647The user can exit with null input by typing @key{RET} with an empty 653The user can exit with null input by typing @key{RET} with an empty
648minibuffer. Then @code{completing-read} returns @code{""}. This is how 654minibuffer. 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
661saving the input and for minibuffer history commands. It defaults to 667saving 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
664The optional argument @var{default} specifies a default value to return 670If @var{initial} is non-@code{nil}, @code{completing-read} inserts it
665if the user enters null input; it should be a string. 671into the minibuffer as part of the input. Then it allows the user to
672edit the input, providing several commands to attempt completion.
673In most cases, we recommend using @var{default}, and not @var{initial}.
666 674
667If the argument @var{inherit-input-method} is non-@code{nil}, then the 675If the argument @var{inherit-input-method} is non-@code{nil}, then the
668minibuffer inherits the current input method and the setting of 676minibuffer 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
903for which @code{commandp} returns @code{t}. @xref{Interactive Call}. 911for which @code{commandp} returns @code{t}. @xref{Interactive Call}.
904 912
905The argument @var{default} specifies what to return if the user enters 913The argument @var{default} specifies what to return if the user enters
906null input. It can be a symbol or a string, but the value returned by 914null 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
908that 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
909input, the return value is @code{nil}. 917enters 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
948symbol. 956symbol.
949 957
950The argument @var{default} specifies what to return if the user enters 958The argument @var{default} specifies what to return if the user enters
951null input. It can be a symbol or a string, but the value returned by 959null 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 961is @code{nil}, that means no default has been specified; then if the
954enters null input, the return value is @code{nil}. 962user 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}.
993This function reads a coding system using the minibuffer, prompting with
994string @var{prompt}, and returns the coding system name as a symbol. If
995the 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
1001This function reads a coding system using the minibuffer, prompting with
1002string @var{prompt},and returns the coding system name as a symbol. If
1003the user enters null input, it returns @var{default-coding-system}.
1004which 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
1037the buffer (after with @var{directory}, if that is inserted). In this 1032the buffer (after with @var{directory}, if that is inserted). In this
1038case, point goes at the beginning of @var{initial}. The default for 1033case, 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
1036recommend using @var{default} rather than @var{initial} in most cases.
1041 1037
1042Here is an example: 1038Here is an example:
1043 1039
@@ -1153,7 +1149,7 @@ string is a unique and exact match already, or @code{nil} if the string
1153matches no possibility. 1149matches no possibility.
1154 1150
1155If the string is an exact match for one possibility, but also matches 1151If the string is an exact match for one possibility, but also matches
1156other longer possibilities, the function shuold return the string, not 1152other 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
1535If this variable is non-@code{nil}, you can invoke commands (such as 1531If 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
1537window. Such invocation produces a recursive editing level for a new 1533is active. Such invocation produces a recursive editing level for a new
1538minibuffer. The outer-level minibuffer is invisible while you are 1534minibuffer. The outer-level minibuffer is invisible while you are
1539editing the inner one. 1535editing the inner one.
1540 1536
1541This variable only affects invoking the minibuffer while the 1537If this variable is @code{nil}, you cannot invoke minibuffer
1542minibuffer window is selected. If you switch windows while in the 1538commands when the minibuffer window is active, not even if you switch to
1543minibuffer, you can always invoke minibuffer commands while some other 1539another window to do it.
1544window 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
41Emacs command behaves in its default manner, and each option is in its 41Emacs command behaves in its default manner, and each option is in its
42default state. All other major modes redefine various keys and options. 42default state. All other major modes redefine various keys and options.
43For example, Lisp Interaction mode provides special key bindings for 43For 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
58Text mode except that it provides three additional commands. Its 58Text mode except that it provides three additional commands. Its
59definition is distinct from that of Text mode, but was derived from it. 59definition 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
62temporarily into a different major mode so it can be edited in a 62temporarily for a buffer, so it can be edited in a different way (with
63different way (with ordinary Emacs commands rather than Rmail). In such 63ordinary Emacs commands rather than Rmail). In such cases, the
64cases, the temporary major mode usually has a command to switch back to 64temporary major mode usually has a command to switch back to the
65the buffer's usual mode (Rmail mode, in this case). You might be 65buffer's usual mode (Rmail mode, in this case). You might be tempted to
66tempted to present the temporary redefinitions inside a recursive edit 66present the temporary redefinitions inside a recursive edit and restore
67and restore the usual ones when the user exits; but this is a bad idea 67the usual ones when the user exits; but this is a bad idea because it
68because it constrains the user's options when it is done in more than 68constrains the user's options when it is done in more than one buffer:
69one buffer: recursive edits must be exited most-recently-entered first. 69recursive edits must be exited most-recently-entered first. Using an
70Using alternative major modes avoids this limitation. @xref{Recursive 70alternative major mode avoids this limitation. @xref{Recursive
71Editing}. 71Editing}.
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
99Define a command whose name ends in @samp{-mode}, with no arguments, 99Define a command whose name ends in @samp{-mode}, with no arguments,
100that switches to the new mode in the current buffer. This command 100that switches to the new mode in the current buffer. This command
101should set up the keymap, syntax table, and local variables in an 101should set up the keymap, syntax table, and buffer-local variables in an
102existing buffer without changing the buffer's text. 102existing buffer, without changing the buffer's contents.
103 103
104@item 104@item
105Write a documentation string for this command that describes the 105Write a documentation string for this command that describes the
@@ -114,8 +114,8 @@ Documentation}.
114 114
115@item 115@item
116The major mode command should start by calling 116The 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
118variables of the major mode previously in effect. 118buffer-local variables of the major mode previously in effect.
119 119
120@item 120@item
121The major mode command should set the variable @code{major-mode} to the 121The 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
126The major mode command should set the variable @code{mode-name} to the 126The 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
128line. 128mode 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
139The major mode should usually have its own keymap, which is used as the 139The major mode should usually have its own keymap, which is used as the
140local keymap in all buffers in that mode. The major mode function 140local keymap in all buffers in that mode. The major mode command should
141should call @code{use-local-map} to install this local map. 141call @code{use-local-map} to install this local map. @xref{Active
142@xref{Active Keymaps}, for more information. 142Keymaps}, for more information.
143 143
144This keymap should be kept in a global variable named 144This 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
146mode sets this variable. 146mode sets this variable.
147 147
@@ -150,7 +150,7 @@ up the mode's keymap variable.
150 150
151@item 151@item
152The key sequences bound in a major mode keymap should usually start with 152The 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
155characters are reserved for minor modes, and ordinary letters are 155characters are reserved for minor modes, and ordinary letters are
156reserved for users. 156reserved for users.
@@ -186,23 +186,20 @@ a variable named @code{@var{modename}-mode-abbrev-table}. @xref{Abbrev
186Tables}. 186Tables}.
187 187
188@item 188@item
189@vindex font-lock-defaults
190The mode should specify how to do highlighting for Font Lock mode, by 189The mode should specify how to do highlighting for Font Lock mode, by
191setting up a buffer-local value for the variable 190setting 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
197The mode should specify how Imenu should find the definitions or 194The mode should specify how Imenu should find the definitions or
198sections of a buffer, by setting up a buffer-local value for the 195sections of a buffer, by setting up a buffer-local value for the
199variable @code{imenu-generic-expression} or 196variable @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
203Use @code{defvar} to set mode-related variables, so that they are not 200Use @code{defvar} or @code{defcustom} to set mode-related variables, so
204reinitialized if they already have a value. (Such reinitialization 201that they are not reinitialized if they already have a value. (Such
205could discard customizations made by the user.) 202reinitialization 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
213would affect buffers that do not use this mode. It is undesirable for a 210would affect buffers that do not use this mode. It is undesirable for a
214mode to have such global effects. @xref{Buffer-Local Variables}. 211mode to have such global effects. @xref{Buffer-Local Variables}.
215 212
216It's ok to use @code{make-variable-buffer-local}, if you wish, for a 213It's OK to use @code{make-variable-buffer-local}, if you wish, for a
217variable used only within a single Lisp package. 214variable 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
235If something special should be done if the user switches a buffer from 232If something special should be done if the user switches a buffer from
236this mode to any other major mode, this mode can set up a buffer-local 233this mode to any other major mode, this mode can set up a buffer-local
237value for @code{change-major-mode-hook} (see below). 234value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}).
238 235
239@item 236@item
240If this mode is appropriate only for specially-prepared text, then the 237If 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.
273Even if you never load the file more than once, someone else will. 270Even 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
277The function @code{kill-all-local-variables} runs this normal hook
278before it does anything else. This gives major modes a way to arrange
279for something special to be done if the user switches to a different
280major mode. For best results, make this variable buffer-local, so that
281it will disappear after doing its job and will not interfere with the
282subsequent 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
335Turning on text-mode runs the hook `text-mode-hook'." 323Turning 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
453example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other 429example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other
454Lisp modes do not. However, all Lisp modes have some commands in 430Lisp modes do not. However, all Lisp modes have some commands in
455common. The following function adds these common commands to a given 431common. The following code sets up the common commands:
456keymap.
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
468keymap, as part of the code for Emacs Lisp mode. First we declare a 448And here is the code to set up the keymap for Lisp mode:
469variable 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
471void. 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
474set 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.
494Commands: 471Commands:
495Delete converts tabs to spaces as it moves back. 472Delete converts tabs to spaces as it moves back.
496Blank lines separate paragraphs. Semicolons start comments. 473Blank lines separate paragraphs. Semicolons start comments.
497\\@{emacs-lisp-mode-map@} 474\\@{lisp-mode-map@}
475Note that `run-lisp' may be used either to start an inferior Lisp job
476or to switch back to an existing one.
498@end group 477@end group
478
499@group 479@group
500Entry to this mode runs the hook `emacs-lisp-mode-hook'." 480Entry to this mode calls the value of `lisp-mode-hook'
481if 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
520automatically selects a major mode for the new buffer when a file is 504automatically selects a major mode for the new buffer when a file is
521visited. 505visited. 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
534This function establishes the proper major mode and local variable 518This function establishes the proper major mode and buffer-local variable
535bindings for the current buffer. First it calls @code{set-auto-mode}, 519bindings for the current buffer. First it calls @code{set-auto-mode},
536then it runs @code{hack-local-variables} to parse, and bind or 520then it runs @code{hack-local-variables} to parse, and bind or
537evaluate as appropriate, any local variables. 521evaluate as appropriate, the file's local variables.
538 522
539If the @var{find-file} argument to @code{normal-mode} is 523If the @var{find-file} argument to @code{normal-mode} is non-@code{nil},
540non-@code{nil}, @code{normal-mode} assumes that the @code{find-file} 524@code{normal-mode} assumes that the @code{find-file} function is calling
541function is calling it. In this case, it may process a local variables 525it. In this case, it may process a local variables list at the end of
542list at the end of the file and in the @samp{-*-} line. The variable 526the 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
528variables, , Local Variables in Files, emacs, The GNU Emacs Manual}, for
529the syntax of the local variables section of a file.
544 530
545If you run @code{normal-mode} interactively, the argument 531If 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
549Manual}, 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
565This variable holds a list of variables that should not be 549This variable holds a list of variables that should not be
566set by a local variables list. Any value specified 550set by a file's local variables list. Any value specified
567for one of these variables is ignored. 551for 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}.
583current buffer. It may base its decision on the value of the @w{@samp{-*-}} 567current buffer. It may base its decision on the value of the @w{@samp{-*-}}
584line, on the visited file name (using @code{auto-mode-alist}), on the 568line, 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
586value of a local variable. However, this function does not look for 570file's local variables list. However, this function does not look for
587the @samp{mode:} local variable near the end of a file; the 571the @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, ,
589How Major Modes are Chosen, emacs, The GNU Emacs Manual}. 573How 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 577This variable holds the default major mode for new buffers. The
594standard value is @code{fundamental-mode}. 578standard value is @code{fundamental-mode}.
595 579
596 If the value of @code{default-major-mode} is @code{nil}, Emacs uses 580If the value of @code{default-major-mode} is @code{nil}, Emacs uses
597the (previously) current buffer's major mode for the major mode of a new 581the (previously) current buffer's major mode for the major mode of a new
598buffer. However, if that major mode symbol has a @code{mode-class} 582buffer. However, if that major mode symbol has a @code{mode-class}
599property with value @code{special}, then it is not used for new buffers; 583property 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.
651If an element of @code{auto-mode-alist} has the form @code{(@var{regexp} 635If 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
654name that did not match before. 638name that did not match before. This feature is useful for
655 639uncompression packages: an entry of the form @code{("\\.gz\\'"
656This match-again feature is useful for uncompression packages: an entry 640@var{function} t)} can uncompress the file and then put the uncompressed
657of the form @code{("\\.gz\\'" @var{function} t)} can uncompress the file 641file in the proper mode according to the name sans @samp{.gz}.
658and then put the uncompressed file in the proper mode according to the
659name sans @samp{.gz}.
660 642
661Here is an example of how to prepend several pattern pairs to 643Here 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 676This function parses, and binds or evaluates as appropriate, any local
695variables for the current buffer. 677variables specified by the contents of the current buffer.
696 678
697 The handling of @code{enable-local-variables} documented for 679The 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}
699usually comes from the argument @var{find-file} given to 681usually 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
798independently of the choice of major mode. Minor modes can be enabled 780independently of the choice of major mode. Minor modes can be enabled
799individually or in combination. Minor modes would be better named 781individually 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
801unwieldy. 783would 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
804example, Auto Fill mode may be used in any major mode that permits text 786example, Auto Fill mode works with any major mode that permits text
805insertion. To be general, a minor mode must be effectively independent 787insertion. To be general, a minor mode must be effectively independent
806of the things major modes do. 788of 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
841Make a variable whose name ends in @samp{-mode} to represent the minor 823Make a variable whose name ends in @samp{-mode} to control the minor
842mode. Its value should enable or disable the mode (@code{nil} to 824mode. We call this the @dfn{mode variable}. The minor mode command
843disable; anything else to enable.) We call this the @dfn{mode 825should set this variable (@code{nil} to disable; anything else to
844variable}. 826enable.)
827
828If it is possible, implement the mode so that setting the variable
829automatically enables or disables the mode. Then the minor mode command
830does not need to do anything except the variable.
845 831
846This variable is used in conjunction with the @code{minor-mode-alist} to 832This variable is used in conjunction with the @code{minor-mode-alist} to
847display the minor mode name in the mode line. It can also enable 833display 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
879Add an element to @code{minor-mode-alist} for each minor mode 865Add 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
881following form: 867the 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.
962With no argument, this command toggles the mode. 947With no argument, this command toggles the mode.
963Non-null prefix argument turns on the mode. 948Non-null prefix argument turns on the mode.
964Null prefix argument turns off the mode. 949Null prefix argument turns off the mode.
@@ -986,11 +971,6 @@ which indicates whether the mode is enabled, and a variable named
986mode is enabled. It initializes the keymap with key bindings for 971mode 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
1010template used to display the mode line of the current buffer. All 990template used to display the mode line of the current buffer. All
1011windows for the same buffer use the same @code{mode-line-format} and 991windows for the same buffer use the same @code{mode-line-format} and
1012their mode lines appear the same (except for scrolling percentages and 992their mode lines appear the same (except for scrolling percentages, and
1013line numbers). 993line 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
1016buffer is shown in the window, or when the buffer's modified-status 996buffer 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
1122useful for @code{shell-mode}, since it contains the hostname and default 1102useful for @code{shell-mode}, since it contains the host name and default
1123directory. 1103directory.
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
1160other variables could have the same effects on the mode line if 1144other 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
1149This variable holds the value of the mode-line construct that displays
1150information about the language environment, buffer coding system, and
1151current input method. @xref{International,,, emacs, The GNU Emacs
1152Manual}.
1153@end defvar
1154
1163@defvar mode-line-modified 1155@defvar mode-line-modified
1164This variable holds the value of the mode-line construct that displays 1156This variable holds the value of the mode-line construct that displays
1165whether the current buffer is modified. 1157whether the current buffer is modified.
1166 1158
1167The default value of @code{mode-line-modified} is @code{("--%1*%1+-")}. 1159The default value of @code{mode-line-modified} is @code{("%1*%1+")}.
1168This means that the mode line displays @samp{--**-} if the buffer is 1160This means that the mode line displays @samp{**} if the buffer is
1169modified, @samp{-----} if the buffer is not modified, @samp{--%%-} if 1161modified, @samp{--} if the buffer is not modified, @samp{%%} if the
1170the buffer is read only, and @samp{--%*--} if the buffer is read only 1162buffer is read only, and @samp{%*} if the buffer is read only and
1171and modified. 1163modified.
1172 1164
1173Changing this variable does not force an update of the mode line. 1165Changing 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
1170This variable identifies the current frame. The default value is
1171@code{" "} if you are using a window system which can show multiple
1172frames, or @code{"-%F "} on an ordinary terminal which shows only one
1173frame at a time.
1174@end defvar
1175
1176@defvar mode-line-buffer-identification 1176@defvar mode-line-buffer-identification
1177This variable identifies the buffer being displayed in the window. Its 1177This variable identifies the buffer being displayed in the window. Its
1178default value is @code{("%F: %17b")}, which means that it usually 1178default value is @code{("%12b")}, which means that it usually
1179displays @samp{Emacs:} followed by seventeen characters of the buffer 1179displays @samp{Emacs:} followed by seventeen characters of the buffer
1180name. (In a terminal frame, it displays the frame name instead of 1180name. (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
1285The variable @code{vc-mode}, local in each buffer, records whether the 1285The variable @code{vc-mode}, buffer-local in each buffer, records
1286buffer's visited file is maintained with version control, and, if so, 1286whether the buffer's visited file is maintained with version control,
1287which kind. Its value is @code{nil} for no version control, or a string 1287and, if so, which kind. Its value is @code{nil} for no version control,
1288that appears in the mode line. 1288or 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}
1305function. @xref{Buffer File Name}. 1305function. @xref{Buffer File Name}.
1306 1306
1307@item %F 1307@item %F
1308The name of the selected frame. 1308The 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
1311The current column number of point. 1312The 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
1387The buffer index contains the names and positions of the definitions or 1388section in the buffer, from a menu which lists all of them, to go
1388portions of in the buffer, so the user can pick one of themand move to 1389directly to that location in the buffer. Imenu works by constructing a
1389it. This section explains how to customize Imenu for a major mode. The 1390buffer index which lists the names and positions of the definitions or
1390usual and simplest way is to set the variable 1391portions of in the buffer, so the user can pick one of them to move to.
1391@code{imenu-generic-expression}. 1392This 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
1394This variable, if non-@code{nil}, specifies regular expressions for 1398This variable, if non-@code{nil}, specifies regular expressions for
@@ -1407,9 +1411,8 @@ in the top level of the buffer index.
1407 1411
1408The second item in the list, @var{regexp}, is a regular expression 1412The 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
1410to be mentioned in the buffer index. The third item, @var{subexp}, 1414to mention in the buffer index. The third item, @var{subexp}, indicates
1411indicates which subexpression in @var{regexp} contains the name for the 1415which subexpression in @var{regexp} matches the definition's name.
1412definition.
1413 1416
1414An element can also look like this: 1417An 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
1442This variable is local in all buffers, if it is set. 1445Setting 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
1447is case-sensitive: @code{t}, the default, means matching should ignore 1450is case-sensitive: @code{t}, the default, means matching should ignore
1448case. 1451case.
1449 1452
1450This variable is local in all buffers, if it is set. 1453Setting 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
1454variables @code{imenu-prev-index-position-function} and 1457variables @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
1458If this variable is non-@code{nil}, its value should be a function for 1461If 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
1460backwards in the file. 1463backwards in the file.
1461 1464
1462The function should leave point at the place to be connected to the 1465The function should leave point at the place to be connected to the
1463index item, and it should return @code{nil} when it doesn't find another 1466index item; it should return @code{nil} if it doesn't find another item.
1464item.
1465 1467
1466This variable is local in all buffers, if it is set. 1468Setting 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
1470If this variable is non-@code{nil}, its value should be a function to 1472If this variable is non-@code{nil}, its value should be a function to
1471return the name for a definition, assuming point is at that definition. 1473return the name for a definition, assuming point is in that definition
1474as the @code{imenu-prev-index-position-function} function would leave
1475it.
1472 1476
1473This variable is local in all buffers, if it is set. 1477Setting 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
1481variables @code{imenu-create-index-function}:
1482
1476@defvar imenu-create-index-function 1483@defvar imenu-create-index-function
1477This variable specifies the function to use for creating a buffer index. 1484This variable specifies the function to use for creating a buffer index.
1478The function should take no arguments, and return an index for the 1485The function should take no arguments, and return an index for the
@@ -1484,13 +1491,12 @@ The default value is a function that uses
1484specify a different function, then @code{imenu-generic-expression} is 1491specify a different function, then @code{imenu-generic-expression} is
1485not used. 1492not used.
1486 1493
1487The variable @code{imenu-create-index-function} is local in all buffers, 1494Setting this variable makes it buffer-local in the current buffer.
1488if it is set.
1489@end defvar 1495@end defvar
1490 1496
1491@defvar imenu-index-alist 1497@defvar imenu-index-alist
1492This variable holds the index alist for the current buffer. 1498This variable holds the index alist for the current buffer.
1493It is local in each buffer, once it is set. 1499Setting it makes it buffer-local in the current buffer.
1494 1500
1495Simple elements in the alist look like @code{(@var{index-name} 1501Simple 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
1517syntactic role. How it parses the buffer depends on the major mode; 1523syntactic role. How it parses the buffer depends on the major mode;
1518most major modes define a set of syntactic criteria for which faces to 1524most major modes define syntactic criteria for which faces to use, in
1519use, in which contexts. This section explains how to customize Font 1525which contexts. This section explains how to customize Font Lock for a
1520Lock for a particular language---in other words, for a particular major 1526particular language---in other words, for a particular major mode.
1521mode.
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
1524parsing based on the syntax table, and through searching (usually for 1529parsing based on the syntax table, and through searching (usually for
1525regular expressions). Syntactic fontification happens first; it finds 1530regular expressions). Syntactic fontification happens first; it finds
1526comments and string constants, and highlights them using 1531comments 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
1542text. But major modes should not set any of these variables directly. 1548text. But major modes should not set any of these variables directly.
1543Instead, it should set @code{font-lock-defaults} as a local variable. 1549Instead, it should set @code{font-lock-defaults} as a buffer-local
1544The value assigned to this variable is used, if and when Font Lock mode 1550variable. The value assigned to this variable is used, if and when Font
1545is enabled, to set all the other variables. 1551Lock mode is enabled, to set all the other variables.
1546 1552
1547@defvar font-lock-defaults 1553@defvar font-lock-defaults
1548This variable is set by major modes, as a buffer-local variable, to 1554This 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
1564The second element, @var{keywords-only}, specifies the value of the 1570The second element, @var{keywords-only}, specifies the value of the
1565variable @code{font-lock-keywords-only}. If this is is non-@code{nil}, 1571variable @code{font-lock-keywords-only}. If this is is non-@code{nil},
1566syntactic fontification (strings and comments) is not performed. 1572syntactic fontification (of strings and comments) is not performed.
1567 1573
1568The third element, @var{case-fold}, specifies the value of 1574The 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
1570mode ignores case when obeying @code{font-lock-keywords}. 1576mode ignores case when searching as directed by
1577@code{font-lock-keywords}.
1571 1578
1572If the fourth element, @var{syntax-alist}, is non-@code{nil}, it should be 1579If the fourth element, @var{syntax-alist}, is non-@code{nil}, it should be
1573a list of cons cells of the form @code{(@var{char-or-string} 1580a list of cons cells of the form @code{(@var{char-or-string}
@@ -1576,8 +1583,7 @@ fontification (@pxref{Syntax Table Functions}). The resulting syntax
1576table is stored in @code{font-lock-syntax-table}. 1583table is stored in @code{font-lock-syntax-table}.
1577 1584
1578The fifth element, @var{syntax-begin}, specifies the value of 1585The 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).
1580explanation of what this value means.
1581 1587
1582Any further elements @var{other-vars} are have form 1588Any 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
1596This variable's value is a list of the keywords to highlight. Be 1602This variable's value is a list of the keywords to highlight. Be
1597careful when composing regexps for this list; a poorly written pattern 1603careful when composing regular expressions for this list; a poorly
1598can dramatically slow things down! 1604written 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
1602certain cases of text, and how to highlight those cases. An element 1608certain cases of text, and how to highlight those cases. Font Lock mode
1603should have one of these forms: 1609processes the elements of @code{font-lock-keywords} one by one, and for
1610each element, it finds and handles all matches. Ordinarily, once
1611part of the text has been fontified already, this cannot be overridden
1612by a subsequent match in the same text; but you can specify different
1613behavior using the @var{override} element of a @var{highlighter}.
1614
1615 Each element of @code{font-lock-keywords} should have one of these
1616forms:
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
1616The function @code{regexp-opt} (@pxref{Syntax of Regexps}) is often 1629The function @code{regexp-opt} (@pxref{Syntax of Regexps}) is useful for
1617useful for calculating complex regular expressions to match a number of 1630calculating optimal regular expressions to match a number of different
1618different keywords. 1631keywords.
1619 1632
1620@item @var{function} 1633@item @var{function}
1621Find text by calling @var{function}, and highlight the matches 1634Find text by calling @var{function}, and highlight the matches
@@ -1629,7 +1642,7 @@ match data to describe the match that was found.
1629In this kind of element, @var{matcher} stands for either a regular 1642In this kind of element, @var{matcher} stands for either a regular
1630expression or a function, as described above. The @sc{cdr}, 1643expression 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
1632highlighted (instead of the entire text that matched @var{matcher}). 1645highlighted (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
1640If you use @code{regexp-opt} to produce a regular expression for 1653If 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
1642of Regexps}) to calculate the value for @var{match}. 1655of 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
1663The @sc{car}, @var{subexp}, is an integer specifying which subexpression 1676The @sc{car}, @var{subexp}, is an integer specifying which subexpression
1664of the match to fontify (0 means the entire matching text). 1677of the match to fontify (0 means the entire matching text). The second
1665@var{facename}, specifies the face, as described above. 1678subelement, @var{facename}, specifies the face, as described above.
1666 1679
1667The last two values in @var{highlighter}, @var{override} and 1680The 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})
1753Here @var{form} is an expression. to be evaluated the first time 1766Here @var{form} is an expression to be evaluated the first time
1754this value of @code{font-lock-keywords} is used in a buffer. 1767this value of @code{font-lock-keywords} is used in a buffer.
1755Its value should be another element of one of these forms. 1768Its 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
1761updating when you edit the buffer does not, since it considers text one 1774updating when you edit the buffer does not, since it considers text one
1762line at a time. 1775line at a time.
1763 1776
1764@defvar font-lock-syntactic-keywords
1765Font Lock mode can be used to update @code{syntax-table} properties
1766automatically. This is useful in languages for which a single
1767syntax table by itself is not sufficient.
1768
1769This variable enables and controls the feature. Its value should
1770be 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
1776The parts of this element have the same meanings as in the corresponding
1777sort 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
1783However, 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
1786whose value is a syntax table, a syntax entry of the form
1787@code{(@var{syntax-code} . @var{matching-char})}, or an expression whose
1788value 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
1798Non-@code{nil} means Font Lock should not fontify comments or strings 1784Non-@code{nil} means Font Lock should not fontify comments or strings
1799syntactictally; it should only fontify based on @code{font-lock-keywords}. 1785syntactically; 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
1810Non-@code{nil} means that regular expression matching for 1797Non-@code{nil} means that regular expression matching for the sake of
1811patterns 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
1815If this variable is non-@code{nil}, it should be a function to use to 1802This variable specifies the syntax table to use for fontification of
1816move back outside of a syntactic block. 1803comments 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 1807If this variable is non-@code{nil}, it should be a function to move
1820@c beginning of a syntactic block? 1808point back to a position that is syntactically at ``top level'' and
1809outside of strings or comments. Font Lock uses this when necessary
1810to get the right results for syntactic fontification.
1821 1811
1822This function is called with no arguments. It should leave point at the 1812This function is called with no arguments. It should leave point at the
1823beginning of any enclosing syntactic block. Typical values are 1813beginning of any enclosing syntactic block. Typical values are
@@ -1827,30 +1817,21 @@ modes or @code{backward-paragraph} for textual modes (i.e., the
1827mode-dependent function is known to move outside a syntactic block). 1817mode-dependent function is known to move outside a syntactic block).
1828 1818
1829If the value is @code{nil}, the beginning of the buffer is used as a 1819If the value is @code{nil}, the beginning of the buffer is used as a
1830position outside of a syntactic block, in the worst case. 1820position outside of a syntactic block. This cannot be wrong, but it can
1831@end defvar 1821be slow.
1832
1833@defvar font-lock-syntax-table
1834This variable specifies the syntax table to use for fontification of
1835comments and strings.
1836@end defvar 1822@end defvar
1837 1823
1838@defvar font-lock-mark-block-function 1824@defvar font-lock-mark-block-function
1839If this variable is non-@code{nil}, it should be a function with no args 1825If this variable is non-@code{nil}, it should be a function that is
1840used to mark an enclosing range of text for refontification when the 1826called with no arguments, to choose an enclosing range of text for
1841text in the buffer changes. A good choice of this function chooses a 1827refontification for the command @kbd{M-g M-g}
1842range of text large enough to give proper results, but not too large so 1828(@code{font-lock-fontify-block}).
1843that refontification becomes slow. 1829
1844 1830The function should report its choice by placing the region around it.
1845Typical values are @code{mark-defun} for programming modes or 1831A 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 1832but not too large so that refontification becomes slow. Typical values
1847function is known to put point and mark around a text block relevant to 1833are @code{mark-defun} for programming modes or @code{mark-paragraph} for
1848that mode). 1834textual 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
1863chosen level's symbol value is used to initialize 1844chosen 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
1848fontification:
1849
1866@itemize @bullet 1850@itemize @bullet
1867@item 1851@item
1868Level 1: highlight function declarations, file directives (such as include or 1852Level 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
1870the most important and top-level components are fontified. 1854the most important and top-level components are fontified.
1871 1855
1872@item 1856@item
1873Level 2: in addition to level 1, highlight all language keywords (with 1857Level 2: in addition to level 1, highlight all language keywords,
1874keyword-face) including type names (using type-face), constant values 1858including type names that act like keywords, as well as named constant
1875(with reference-face, e.g., "true" and "false" or case/switch 1859values. The idea is that all keywords (either syntactic or semantic)
1876constants). The idea is that all reserved words should be fontified 1860should be fontified appropriately.
1877appropriately.
1878 1861
1879@item 1862@item
1880Level 3: in addition to level 2, highlight all symbols that are defined 1863Level 3: in addition to level 2, highlight the symbols being defined in
1881in function and variable declarations, and all builtin functions, 1864function and variable declarations, and all builtin function names,
1882wherever they appear. The idea is that all declared objects should be 1865wherever they appear.
1883fontified.
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
1948directives in C. 1930directives 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
1937automatically. This is useful in languages for which a single syntax
1938table by itself is not sufficient.
1939
1940@defvar font-lock-syntactic-keywords
1941This variable enables and controls syntactic Font Lock. Its value
1942should 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
1948The parts of this element have the same meanings as in the corresponding
1949sort 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
1955However, 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
1958whose value is a syntax table, a syntax entry of the form
1959@code{(@var{syntax-code} . @var{matching-char})}, or an expression whose
1960value 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
1970for a user to customize the behavior of the mode, by overriding the 1982for a user to customize the behavior of the mode, by overriding the
1971local variable assignments already made by the mode. But hooks are used 1983buffer-local variable assignments already made by the mode. But hooks
1972in other contexts too. For example, the hook @code{suspend-hook} runs 1984are used in other contexts too. For example, the hook
1973just 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
1976calling @code{add-hook} (see below). The hook functions may be any of 1989calling @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
1995is just a single function, not a list of functions. 2008is 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
1998when in Lisp Interaction mode: 2011in 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
2005formats C code. (People often have strong personal preferences for one
2006format or another.) Here the hook function is an anonymous lambda
2007expression.
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
2028run particular hooks. This function calls the hook functions that have 2018run particular hooks. This function calls the hook functions that have
2029been added with @code{add-hook}. 2019been added with @code{add-hook}.
@@ -2068,13 +2058,12 @@ It is best to design your hook functions so that the order in which they
2068are executed does not matter. Any dependence on the order is ``asking 2058are executed does not matter. Any dependence on the order is ``asking
2069for trouble.'' However, the order is predictable: normally, 2059for 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
2071executed first (barring another @code{add-hook} call). 2061executed first (barring another @code{add-hook} call). If the optional
2072 2062argument @var{append} is non-@code{nil}, the new hook function goes at
2073If the optional argument @var{append} is non-@code{nil}, the new hook 2063the end of the hook list and will be executed last.
2074function goes at the end of the hook list and will be executed last.
2075 2064
2076If @var{local} is non-@code{nil}, that says to make the new hook 2065If @var{local} is non-@code{nil}, that says to make the new hook
2077function local to the current buffer. Before you can do this, you must 2066function buffer-local in the current buffer. Before you can do this, you must
2078make the hook itself buffer-local by calling @code{make-local-hook} 2067make 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
2080buffer-local, then the value of @var{local} makes no difference---the 2069buffer-local, then the value of @var{local} makes no difference---the
@@ -2085,22 +2074,24 @@ hook function is always global.
2085This function removes @var{function} from the hook variable @var{hook}. 2074This function removes @var{function} from the hook variable @var{hook}.
2086 2075
2087If @var{local} is non-@code{nil}, that says to remove @var{function} 2076If @var{local} is non-@code{nil}, that says to remove @var{function}
2088from the local hook list instead of from the global hook list. If the 2077from the buffer-local hook list instead of from the global hook list.
2089hook itself is not buffer-local, then the value of @var{local} makes no 2078If the hook variable itself is not buffer-local, then the value of
2090difference. 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
2094This function makes the hook variable @code{hook} local to the current 2083This function makes the hook variable @code{hook} buffer-local in the
2095buffer. When a hook variable is local, it can have local and global 2084current buffer. When a hook variable is buffer-local, it can have
2096hook functions, and @code{run-hooks} runs all of them. 2085buffer-local and global hook functions, and @code{run-hooks} runs all of
2086them.
2097 2087
2098This function works by making @code{t} an element of the buffer-local 2088This function works by making @code{t} an element of the buffer-local
2099value. That serves as a flag to use the hook functions in the default 2089value. That serves as a flag to use the hook functions in the default
2100value of the hook variable as well as those in the local value. Since 2090value 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 2091Since @code{run-hooks} understands this flag, @code{make-local-hook}
2102with all normal hooks. It works for only some non-normal hooks---those 2092works with all normal hooks. It works for only some non-normal
2103whose callers have been updated to understand this meaning of @code{t}. 2093hooks---those whose callers have been updated to understand this meaning
2094of @code{t}.
2104 2095
2105Do not use @code{make-local-variable} directly for hook variables; it is 2096Do not use @code{make-local-variable} directly for hook variables; it is
2106not sufficient. 2097not 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
42therefore the possible character codes range from 0 to 255. Codes 0 45therefore the possible character codes range from 0 to 255. Codes 0
43through 127 are @sc{ASCII} characters; the codes from 128 through 255 46through 127 are @sc{ASCII} characters; the codes from 128 through 255
44are used for one non-@sc{ASCII} character set (you can choose which one 47are used for one non-@sc{ASCII} character set (you can choose which
45by setting the variable @code{nonascii-insert-offset}). 48character 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.
67If it is non-@code{nil}, the buffer contains multibyte text; otherwise, 70If it is non-@code{nil}, the buffer contains multibyte text; otherwise,
68it contains unibyte text. 71it contains unibyte text.
69 72
70@strong{Warning:} do not set this variable directly; instead, use the 73You cannot set this variable directly; instead, use the function
71function @code{set-buffer-multibyte} to change a buffer's 74@code{set-buffer-multibyte} to change a buffer's representation.
72representation.
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
112the characters that might be in the multibyte text. The other natural 114the characters that might be in the multibyte text. The other natural
113alternative, to convert the buffer contents to multibyte, is not 115alternative, to convert the buffer contents to multibyte, is not
114acceptable because the buffer's representation is a choice made by the 116acceptable because the buffer's representation is a choice made by the
115user that cannot simply be overrided. 117user 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
118unchanged. It converts the non-@sc{ASCII} codes 128 through 255 by 120unchanged, and likewise 128 through 159. It converts the non-@sc{ASCII}
119adding the value @code{nonascii-insert-offset} to each character code. 121codes 160 through 255 by adding the value @code{nonascii-insert-offset}
120By setting this variable, you specify which character set the unibyte 122to each character code. By setting this variable, you specify which
121characters correspond to. For example, if @code{nonascii-insert-offset} 123character set the unibyte characters correspond to. For example, if
122is 2048, which is @code{(- (make-char 'latin-iso8859-1 0) 128)}, then 124@code{nonascii-insert-offset} is 2048, which is @code{(- (make-char
123the 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
1242688, which is @code{(- (make-char 'greek-iso8859-7 0) 128)}, then they 126correspond to Latin 1. If it is 2688, which is @code{(- (make-char
125correspond 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
128logical-and of each character code with 255. If 130logical-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
151how to translate each code in the range of 128 through 255 into a 153how to translate each code in the range of 128 through 255 into a
152multibyte character. The value should be a vector, or @code{nil}. 154multibyte character. The value should be a vector, or @code{nil}.
155If 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
157This function converts the text of @var{string} to unibyte 160This function converts the text of @var{string} to unibyte
158representation, if it isn't already, and return the result. If 161representation, if it isn't already, and return the result. If
159conversion does not change the contents, the value may be @var{string} 162@var{string} is a unibyte string, it is returned unchanged.
160itself.
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
165This function converts the text of @var{string} to multibyte 167This function converts the text of @var{string} to multibyte
166representation, if it isn't already, and return the result. If 168representation, if it isn't already, and return the result. If
167conversion does not change the contents, the value may be @var{string} 169@var{string} is a multibyte string, it is returned unchanged.
168itself.
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
189This function sets @code{enable-multibyte-characters} to record which 190This function sets @code{enable-multibyte-characters} to record which
190representation is in use. It also adjusts various data in the buffer 191representation 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
192cover or fall between the same text as they did before. 193same 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
198treating each byte as a character. This means that the value may have 199treating each byte as a character. This means that the value may have
199more characters than @var{string} has. 200more characters than @var{string} has.
200 201
201If @var{string} is unibyte already, then the value may be @var{string} 202If @var{string} is unibyte already, then the value is @var{string}
202itself. 203itself.
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
208treating each multibyte sequence as one character. This means that the 209treating each multibyte sequence as one character. This means that the
209value may have fewer characters than @var{string} has. 210value may have fewer characters than @var{string} has.
210 211
211If @var{string} is multibyte already, then the value may be @var{string} 212If @var{string} is multibyte already, then the value is @var{string}
212itself. 213itself.
213@end defun 214@end defun
214 215
@@ -221,8 +222,9 @@ codes. The valid character codes for unibyte representation range from
2210 to 255---the values that can fit in one byte. The valid character 2220 to 255---the values that can fit in one byte. The valid character
222codes for multibyte representation range from 0 to 524287, but not all 223codes for multibyte representation range from 0 to 524287, but not all
223values in that range are valid. In particular, the values 128 through 224values in that range are valid. In particular, the values 128 through
224255 are not valid in multibyte text. Only the @sc{ASCII} codes 0 225255 are not legitimate in multibyte text (though they can occur in ``raw
225through 127 are used in both representations. 226bytes''; @pxref{Explicit Encoding}). Only the @sc{ASCII} codes 0
227through 127 are fully legitimate in both representations.
226 228
227@defun char-valid-p charcode 229@defun char-valid-p charcode
228This returns @code{t} if @var{charcode} is valid for either one of the two 230This 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
250example, @code{latin-iso8859-1} is one character set, 252example, @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
252Emacs character set can hold at most 9025 characters; therefore. in some 254Emacs character set can hold at most 9025 characters; therefore, in some
253cases, a set of characters that would logically be grouped together are 255cases, characters that would logically be grouped together are split
254split into several character sets. For example, one set of Chinese 256into several character sets. For example, one set of Chinese characters
255characters is divided into eight Emacs character sets, 257is divided into eight Emacs character sets, @code{chinese-cns11643-1}
256@code{chinese-cns11643-1} through @code{chinese-cns11643-7}. 258through @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
301bytes. The functions in this section convert between characters and the 303bytes. The functions in this section convert between characters and the
302byte values used to represent them. 304byte values used to represent them. For most purposes, there is no need
305to be concerned with the number of bytes used to represent a character
306because 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
306This function returns the number of bytes used to represent the 310This function returns the number of bytes used to represent the
307character @var{character}. In most cases, this is the same as 311character @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
309ASCII characters, which use just one byte. 313ASCII characters and the codes used in unibyte text, which use just one
314byte.
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
378characters; for example, there are three coding systems for the Cyrillic 383characters; 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
383on various systems for end of line. The Unix convention is to use the
384linefeed character (also called newline). The DOS convention is to use
385the two character sequence, carriage-return linefeed, at the end of a
386line. 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
389conversion, but some of them leave this unspecified---to be chosen 387conversion, but some of them leave this unspecified---to be chosen
390heuristically based on the data. 388heuristically based on the data.
391 389
390@cindex end of line conversion
391 @dfn{End of line conversion} handles three different conventions used
392on various systems for representing end of line in files. The Unix
393convention is to use the linefeed character (also called newline). The
394DOS convention is to use the two character sequence, carriage-return
395linefeed, at the end of a line. The Mac convention is to use just
396carriage-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
398well. Each base coding system has three corresponding variants whose 404well. Each base coding system has three corresponding variants whose
399names are formed by adding @samp{-unix}, @samp{-dos} and @samp{-mac}. 405names 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}.
420Otherwise it signals an error with condition @code{coding-system-error}. 429Otherwise 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
434Return 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
436encode any multibyte characters in the text.
437
438If the text contains no multibyte characters, return a list of a single
439element @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
425This function chooses a plausible coding system for decoding the text 444This function chooses a plausible coding system for decoding the text
426from @var{start} to @var{end}. This text should be ``raw bytes'' 445from @var{start} to @var{end}. This text should be ``raw bytes''
427(@pxref{Specifying Coding Systems}). 446(@pxref{Explicit Encoding}).
428 447
429Normally this function returns is a list of coding systems that could 448Normally this function returns is a list of coding systems that could
430handle decoding the text that was scanned. They are listed in order of 449handle 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
496system, with completion. @xref{Completion}.
497
498@tindex read-coding-system
499@defun read-coding-system prompt default
500This function reads a coding system using the minibuffer, prompting with
501string @var{prompt}, and returns the coding system name as a symbol. If
502the user enters null input, @var{default} specifies which coding system
503to 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
508This function reads a coding system using the minibuffer, prompting with
509string @var{prompt},and returns the coding system name as a symbol. If
510the 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},
480certain files or when running certain subprograms. The idea of these 518certain files or when running certain subprograms. The idea of these
481variables is that you set them once and for all to the defaults you 519variables is that you set them once and for all to the defaults you
482want, and then do not change them again. To specify a particular coding 520want, and then do not change them again. To specify a particular coding
483system for a particular operation, don't change these variables; 521system for a particular operation in a Lisp program, don't change these
484instead, override them using @code{coding-system-for-read} and 522variables; instead, override them using @code{coding-system-for-read}
485@code{coding-system-for-write} (@pxref{Specifying Coding Systems}). 523and @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
520This variable is an alist that specifies the coding system to use for 558This variable is an alist that specifies the coding system to use for
521network streams. It works much like @code{file-coding-system-alist}, 559network streams. It works much like @code{file-coding-system-alist},
522with the difference that the @var{pattern} in an elemetn may be either a 560with the difference that the @var{pattern} in an element may be either a
523port number or a regular expression. If it is a regular expression, it 561port number or a regular expression. If it is a regular expression, it
524is matched against the network service name used to open the network 562is matched against the network service name used to open the network
525stream. 563stream.
@@ -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
590All operations that use a coding system set this variable 628All I/O operations that use a coding system set this variable
591to the coding system name that was used. 629to 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
646way that an external file would. When a buffer contains raw bytes, it 684way that an external file would. When a buffer contains raw bytes, it
647is most natural to mark that buffer as using unibyte representation, 685is most natural to mark that buffer as using unibyte representation,
648using @code{set-buffer-multibyte} (@pxref{Selecting a Representation}), 686using @code{set-buffer-multibyte} (@pxref{Selecting a Representation}),
649but this is not required. 687but this is not required. If the buffer's contents are only temporarily
688raw, leave the buffer multibyte, which will be correct after you decode
689them.
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
652to read them with from a file with @code{insert-file-contents-literally} 692to 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}
654arguments when visiting a file with @code{find-file-noselect}. 694argument 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
657encoding text is to copy them to a file or process---for example, to 697encoding text is to copy them to a file or process---for example, to
658write it with @code{write-region} (@pxref{Writing to Files}), and 698write them with @code{write-region} (@pxref{Writing to Files}), and
659suppress encoding for that @code{write-region} call by binding 699suppress 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
664This function encodes the text from @var{start} to @var{end} according 704This function encodes the text from @var{start} to @var{end} according
665to coding system @var{coding-system}. The encoded text replaces 705to coding system @var{coding-system}. The encoded text replaces the
666the original text in the buffer. The result of encoding is 706original text in the buffer. The result of encoding is ``raw bytes,''
667``raw bytes.'' 707but 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
672This function encodes the text in @var{string} according to coding 712This function encodes the text in @var{string} according to coding
673system @var{coding-system}. It returns a new string containing the 713system @var{coding-system}. It returns a new string containing the
674encoded text. The result of encoding is ``raw bytes.'' 714encoded 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
689decoded text. To make explicit decoding useful, the contents of 729decoded 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
743text files or binary files. For a text file, Emacs always uses DOS
744end-of-line conversion. For a binary file, Emacs does no end-of-line
745conversion and no character code conversion.
746
747@defvar buffer-file-type
748This variable, automatically buffer-local in each buffer, records the
749file type of the buffer's visited file. The value is @code{nil} for
750text, @code{t} for binary. When a buffer does not specify a coding
751system with @code{buffer-file-coding-system}, this variable is used by
752the function @code{find-buffer-file-type-coding-system} to determine
753which coding system to use when writing the contents of the buffer.
754@end defvar
755
756@defopt file-name-buffer-file-type-alist
757This variable holds an alist for recognizing text and binary files.
758Each 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
761compute which. If it is a function, then it is called with a single
762argument (the file name) and should return @code{t} or @code{nil}.
763
764Emacs when running on MS-DOS or MS-Windows checks this alist to decide
765which 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}
767is used.
768
769If 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
774This variable says how to handle files for which
775@code{file-name-buffer-file-type-alist} says nothing about the type.
776
777If this variable is non-@code{nil}, then these files are treated as
778binary. Otherwise, nothing special is done for them---the coding system
779is 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
786way to specify the kind of end-of-line conversion to use for input and
787output. The variable @code{binary-process-input} applies to input sent
788to the subprocess, and @code{binary-process-output} applies to output
789received from it. A non-@code{nil} value means the data is ``binary,''
790and @code{nil} means the data is text.
791
792@defvar binary-process-input
793If this variable is @code{nil}, convert newlines to @sc{crlf} sequences in
794the input to a synchronous subprocess.
795@end defvar
796
797@defvar binary-process-output
798If this variable is @code{nil}, convert @sc{crlf} sequences to newlines in
799the 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
14numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or 14numbers are numbers with fractional parts, such as @minus{}4.5, 0.0, or
152.71828. They can also be expressed in exponential notation: 152.71828. They can also be expressed in exponential notation: 1.5e2
161.5e2 equals 150; in this example, @samp{e2} stands for ten to the 16equals 150; in this example, @samp{e2} stands for ten to the second
17second power, and is multiplied by 1.5. Floating point values are not 17power, and that is multiplied by 1.5. Floating point values are not
18exact; they have a fixed, limited amount of precision. 18exact; 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
149there is no correct answer. For example, @code{(sqrt -1.0)} returns a 149there is no correct answer. For example, @code{(sqrt -1.0)} returns a
150NaN. For practical purposes, there's no significant difference between 150NaN. For practical purposes, there's no significant difference between
151different NaN values in Emacs Lisp, and there's no rule for precisely 151different NaN values in Emacs Lisp, and there's no rule for precisely
152which NaN value should be used in a particular case, so this manual 152which NaN value should be used in a particular case, so Emacs Lisp
153doesn't try to distinguish them. Here are the read syntaxes for 153doesn't try to distinguish them. Here are the read syntaxes for
154these numbers: 154these 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
166zero in IEEE floating point (although @code{equal} and @code{=} consider
167them 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
166point number (or estimate the logarithm of an integer): 170point 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
331This 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
379if any argument is floating. 387if 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
382do not check for overflow. Thus @code{(1+ 134217727)} may evaluate to 390do 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:
414This function returns @var{number-or-marker} minus 1. 422This function returns @var{number-or-marker} minus 1.
415@end defun 423@end defun
416 424
417@defun abs number
418This returns the absolute value of @var{number}.
419@end defun
420
421@defun + &rest numbers-or-markers 425@defun + &rest numbers-or-markers
422This function adds its arguments together. When given no arguments, 426This 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
478machines round in the standard fashion. 482machines round in the standard fashion.
479 483
480@cindex @code{arith-error} in division 484@cindex @code{arith-error} in division
481If you divide by 0, an @code{arith-error} error is signaled. 485If 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
487infinity or a NaN if your machine supports IEEE floating point;
488otherwise, 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
928These mathematical functions are available if floating point is 940 These mathematical functions allow integers as well as floating point
929supported. They allow integers as well as floating point numbers 941numbers as arguments.
930as 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.
25which all other types are constructed, are called @dfn{primitive 25which all other types are constructed, are called @dfn{primitive
26types}. Each object belongs to one and only one primitive type. These 26types}. Each object belongs to one and only one primitive type. These
27types include @dfn{integer}, @dfn{float}, @dfn{cons}, @dfn{symbol}, 27types 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
29several special types, such as @dfn{buffer}, that are related to 29several special types, such as @dfn{buffer}, that are related to
30editing. (@xref{Editing Types}.) 30editing. (@xref{Editing Types}.)
31 31
@@ -69,8 +69,9 @@ input accepted by the Lisp reader (the function @code{read}) for that
69object. @xref{Read and Print}. 69object. @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
72object have no read syntax; except for these cases, the printed 72object have no read syntax, since it may not make sense to enter objects
73representation of an object is also a read syntax for it. 73of these types directly in a Lisp program. Except for these cases, the
74printed 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
76Lisp, an expression is primarily a Lisp object and only secondarily the 77Lisp, 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
83syntax, since it may not make sense to enter objects of these types 84syntax---for example, the buffer type has none. Objects of these types
84directly in a Lisp program. For example, the buffer type does not have 85are printed in @dfn{hash notation}: the characters @samp{#<} followed by
85a read syntax. Objects of these types are printed in @dfn{hash 86a descriptive string (typically the type name followed by the name of
86notation}: the characters @samp{#<} followed by a descriptive string 87the object), and closed with a matching @samp{>}. Hash notation cannot
87(typically the type name followed by the name of the object), and closed 88be read at all, so the Lisp reader signals the error
88with a matching @samp{>}. Hash notation cannot be read at all, so the 89@code{invalid-read-syntax} whenever it encounters @samp{#<}.
89Lisp reader signals the error @code{invalid-read-syntax} whenever it
90encounters @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{.}.
1901 ; @r{The integer 1.} 1891 ; @r{The integer 1.}
1911. ; @r{Also The integer 1.} 1901. ; @r{Also The integer 1.}
192+1 ; @r{Also the integer 1.} 191+1 ; @r{Also the integer 1.}
193268435457 ; @r{Also the integer 1!} 192268435457 ; @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
228range of 0 to 524287---nineteen bits. But not all values in that range 226range of 0 to 524287---nineteen bits. But not all values in that range
229are valid character codes. Characters that represent keyboard input 227are valid character codes. Codes 0 through 127 are ASCII codes; the
230have a much wider range, so they can modifier keys such as Control, Meta 228rest are non-ASCII (@pxref{Non-ASCII Characters}). Characters that represent
231and Shift. 229keyboard input have a much wider range, to encode modifier keys such as
230Control, 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}:
314that exist in @sc{ASCII}; but for keyboard input purposes, you can turn 313that exist in @sc{ASCII}; but for keyboard input purposes, you can turn
315any character into a control character with @samp{C-}. The character 314any character into a control character with @samp{C-}. The character
316codes for these non-@sc{ASCII} control characters include the 315codes 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
3212**26 3202**26
322@end ifinfo 321@end ifinfo
@@ -334,21 +333,22 @@ the control equivalent of @kbd{?}:
334 333
335@noindent 334@noindent
336As a result, it is currently not possible to represent the character 335As 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
338not 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
339way. 338to @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,
342we recommend the @samp{^} syntax; for control characters in keyboard 341we recommend the @samp{^} syntax; for control characters in keyboard
343input, we prefer the @samp{C-} syntax. This does not affect the meaning 342input, we prefer the @samp{C-} syntax. Which one you use does not
344of the program, but may guide the understanding of people who read it. 343affect the meaning of the program, but may guide the understanding of
344people 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}
348modifier key. The integer that represents such a character has the 348modifier 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
3532**27 3532**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
357of basic character codes. 357of 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
3642**7 3642**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
380for example, @sc{ASCII} distinguishes between the characters @samp{a} 380for example, @sc{ASCII} distinguishes between the characters @samp{a}
381and @samp{A}. But @sc{ASCII} has no way to represent whether a control 381and @samp{A}. But @sc{ASCII} has no way to represent whether a control
382character is upper case or lower case. Emacs uses the 382character 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
3872**25 3872**25
388@end ifinfo 388@end ifinfo
389bit to indicate that the shift key was used for typing a control 389bit to indicate that the shift key was used in typing a control
390character. This distinction is possible only when you use X terminals 390character. This distinction is possible only when you use X terminals
391or other special terminals; ordinary terminals do not indicate the 391or other special terminals; ordinary terminals do not report the
392distinction to the computer in any way. 392distinction 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.
398in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes 398in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes
399for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, 399for 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
402Numerically, the 402Numerically, the
403bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. 403bit 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
406Numerically, the 406Numerically, the
407bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. 407bit 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.
434Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the 434Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the
435character @kbd{C-a}, and @code{?\x8c0} for the character 435character @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
478the name of a symbol simply quotes the single character that follows the 478the name of a symbol simply quotes the single character that follows the
479backslash. For example, in a string, @samp{\t} represents a tab 479backslash. For example, in a string, @samp{\t} represents a tab
480character; in the name of a symbol, however, @samp{\t} merely quotes the 480character; in the name of a symbol, however, @samp{\t} merely quotes the
481letter @kbd{t}. To have a symbol with a tab character in its name, you 481letter @samp{t}. To have a symbol with a tab character in its name, you
482must actually use a tab (preceded with a backslash). But it's rare to 482must actually use a tab (preceded with a backslash). But it's rare to
483do such a thing. 483do such a thing.
484 484
@@ -525,26 +525,28 @@ elements. There are two kinds of sequence in Emacs Lisp, lists and
525arrays. Thus, an object of type list or of type array is also 525arrays. Thus, an object of type list or of type array is also
526considered a sequence. 526considered 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
529hold elements of any type, but string elements must be characters in the 529bool-vectors. Vectors can hold elements of any type, but string
530range from 0 to 255. However, the characters in a string can have text 530elements must be characters, and bool-vector elements must be @code{t}
531properties like characters in a buffer (@pxref{Text Properties}); 531or @code{nil}. The characters in a string can have text properties like
532vectors do not support text properties even when their elements happen 532characters in a buffer (@pxref{Text Properties}); vectors and
533to be characters. 533bool-vectors do not support text properties even when their elements
534 534happen to be characters. Char-tables are like vectors except that they
535 Lists, strings and vectors are different, but they have important 535are indexed by any valid character code.
536similarities. For example, all have a length @var{l}, and all have 536
537elements 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
538several functions, called sequence functions, accept any kind of 538important similarities. For example, all have a length @var{l}, and all
539have elements which can be indexed from zero to @var{l} minus one.
540Several functions, called sequence functions, accept any kind of
539sequence. For example, the function @code{elt} can be used to extract 541sequence. For example, the function @code{elt} can be used to extract
540an element of a sequence, given its index. @xref{Sequences Arrays 542an element of a sequence, given its index. @xref{Sequences Arrays
541Vectors}. 543Vectors}.
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
544always created anew upon reading. If you read the read syntax for a 546sequences are always created anew upon reading. If you read the read
545sequence twice, you get two sequences with equal contents. There is one 547syntax for a sequence twice, you get two sequences with equal contents.
546exception: the empty list @code{()} always stands for the same object, 548There is one exception: the empty list @code{()} always stands for the
547@code{nil}. 549same 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
777referring to other Lisp objects, arranged in a contiguous block of 785referring to other Lisp objects, arranged in a contiguous block of
778memory. Accessing any element of an array takes the same amount of 786memory. Accessing any element of an array takes approximately the same
779time. In contrast, accessing an element of a list requires time 787amount of time. In contrast, accessing an element of a list requires
780proportional to the position of the element in the list. (Elements at 788time proportional to the position of the element in the list. (Elements
781the end of a list take longer to access than elements at the beginning 789at the end of a list take longer to access than elements at the
782of a list.) 790beginning 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
785array of characters and a vector is an array of arbitrary objects. Both 793char-tables.
786are one-dimensional. (Most other programming languages support 794
787multidimensional 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
788same effect with an array of arrays.) Each type of array has its own 796arbitrary objects. A bool-vector can hold only @code{t} or @code{nil}.
789read syntax; see @ref{String Type}, and @ref{Vector Type}. 797These kinds of array may have any length up to the largest integer.
790 798Char-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 799can hold arbitrary objects.
792created, it has a fixed size. The first element of an array has index 800
793zero, 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 802index 1, and so on. This is called @dfn{zero-origin} indexing. For
795indices 0, 1, 2, @w{and 3}. 803example, an array of four elements has indices 0, 1, 2, @w{and 3}. The
796 804largest 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 805Once an array is created, its length is fixed.
798string type and the vector type. 806
807 All Emacs Lisp arrays are one-dimensional. (Most other programming
808languages support multidimensional arrays, but they are not essential;
809you can get the same effect with an array of arrays.) Each type of
810array has its own read syntax; see the following sections for details.
811
812 The array type is contained in the sequence type and
813contains the string type, the vector type, the bool-vector type, and the
814char-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."
854constant by writing it literally. There are two text representations 870constant by writing it literally. There are two text representations
855for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte 871for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte
856and multibyte. If the string constant is read from a multibyte source, 872and multibyte. If the string constant is read from a multibyte source,
857then the character is read as a multibyte character, and that makes the 873such as a multibyte buffer or string, or a file that would be visited as
858string multibyte. If the string constant is read from a unibyte source, 874multibyte, then the character is read as a multibyte character, and that
859then the character is read as unibyte and that makes the string unibyte. 875makes the string multibyte. If the string constant is read from a
876unibyte source, then the character is read as unibyte and that makes the
877string 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
862character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many 881character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many
863digits as necessary. (Multibyte non-@sc{ASCII} character codes are all 882digits 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
897string constant, this sets the 916string constant, this sets the
898@iftex 917@tex
899$2^{7}$ 918$2^{7}$
900@end iftex 919@end tex
901@ifinfo 920@ifinfo
9022**7 9212**7
903@end ifinfo 922@end ifinfo
@@ -975,9 +994,24 @@ special purposes. A char-table can also specify a single value for
975a whole character set. 994a 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
978except that there is an extra @samp{#} at the beginning. 997except 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.
1000Uses of char-tables include:
1001
1002@itemize @bullet
1003@item
1004Case tables (@pxref{Case Tables}).
1005
1006@item
1007Character category tables (@pxref{Categories}).
1008
1009@item
1010Display Tables (@pxref{Display Tables}).
1011
1012@item
1013Syntax 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
1029language. It is represented as an object much like a function, but with 1066language. It is represented as an object much like a function, but with
1030different parameter-passing semantics. A Lisp macro has the form of a 1067different argument-passing semantics. A Lisp macro has the form of a
1031list whose first element is the symbol @code{macro} and whose @sc{cdr} 1068list whose first element is the symbol @code{macro} and whose @sc{cdr}
1032is a Lisp function object, including the @code{lambda} symbol. 1069is 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
1056primitive. However, this does matter if you try to substitute a 1093primitive. However, this does matter if you try to redefine a primitive
1057function written in Lisp for a primitive of the same name. The reason 1094with a function written in Lisp. The reason is that the primitive
1058is that the primitive function may be called directly from C code. 1095function may be called directly from C code. Calls to the redefined
1059Calls to the redefined function from Lisp will use the new definition, 1096function from Lisp will use the new definition, but calls from C code
1060but calls from C code may still use the built-in definition. Therefore, 1097may still use the built-in definition. Therefore, @strong{we discourage
1061@strong{we discourage redefinition of primitive functions}. 1098redefinition 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
1064in Lisp or C. @xref{Function Type}, for information about the 1101in 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
1118Emacs Lisp provides several additional data types for purposes connected 1155purposes, and most of them are common to most Lisp dialects. Emacs Lisp
1119with editing. 1156provides several additional data types for purposes connected with
1157editing.
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
1146used like strings in Emacs Lisp, and the available operations are 1183used like strings in Emacs Lisp, and the available operations are
1147different. For example, insertion of text into a buffer is very 1184different. For example, you can insert text efficiently into an
1148efficient, whereas ``inserting'' text into a string requires 1185existing buffer, whereas ``inserting'' text into a string requires
1149concatenating substrings, and the result is an entirely new string 1186concatenating substrings, and the result is an entirely new string
1150object. 1187object.
1151 1188
@@ -1167,10 +1204,10 @@ a local syntax table (@pxref{Syntax Tables});
1167a local keymap (@pxref{Keymaps}); and, 1204a local keymap (@pxref{Keymaps}); and,
1168 1205
1169@item 1206@item
1170a local variable binding list (@pxref{Buffer-Local Variables}). 1207a list of buffer-local variable bindings (@pxref{Buffer-Local Variables}).
1171 1208
1172@item 1209@item
1173a list of overlays (@pxref{Overlays}). 1210overlays (@pxref{Overlays}).
1174 1211
1175@item 1212@item
1176text properties for the text in the buffer (@pxref{Text Properties}). 1213text properties for the text in the buffer (@pxref{Text Properties}).
@@ -1183,7 +1220,7 @@ behavior of programs in different buffers, without actually changing the
1183programs. 1220programs.
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
1186of another buffer. @xref{Indirect Buffers}. 1223of 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
1189buffer name. 1226buffer 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
1282Configurations}, for a description of several functions related to 1319Configurations}, for a description of several functions related to
1283window configurations. 1320window 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,
1327sizes, and contents of the windows in all frames. It is actually
1328a list whose @sc{car} is @code{frame-configuration} and whose
1329@sc{cdr} is an alist. Each alist element describes one frame,
1330which appears as the @sc{car} of that element.
1331
1332 @xref{Frame Configurations}, for a description of several functions
1333related 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
1344keys, local as well as global keymaps, and changing key bindings. 1394keys, 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
1350each character, for word and list parsing. Each element of the syntax
1351table defines how one character is interpreted when it appears in a
1352buffer. For example, in C mode (@pxref{Major Modes}), the @samp{+}
1353character is punctuation, but in Lisp mode it is a valid character in a
1354symbol. These modes specify different interpretations by changing the
1355syntax 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
1358buffers, not for reading Lisp expressions. The syntax that the Lisp
1359interpreter uses to read expressions is built into the Emacs source code
1360and cannot be changed; thus, to change the list delimiters to be
1361@samp{@{} and @samp{@}} instead of @samp{(} and @samp{)} would be
1362impossible. (Some Lisp systems provide ways to redefine the read
1363syntax, but we decided to leave this feature out of Emacs Lisp for
1364simplicity.)
1365
1366 @xref{Syntax Tables}, for details about syntax classes and how to make
1367and 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.
1373Each buffer and each window can have its own display table. A display
1374table 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
1556This function returns a symbol naming the primitive type of 1588This 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
1595object. 1628object.
1596 1629
1597(The @code{make-symbol} function returns an uninterned symbol that is
1598not interned in the standard @code{obarray}. When uninterned symbols
1599are in use, symbol names are no longer unique. Distinct symbols with
1600the 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
1672not interned in the standard @code{obarray}. When uninterned symbols
1673are in use, symbol names are no longer unique. Distinct symbols with
1674the 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
64even earlier than this.) 64even earlier than this.)
65 65
66@item 66@item
67It initializes the X window frame and faces, if appropriate. 67It initializes the window frame and faces, if appropriate.
68 68
69@item 69@item
70It runs the normal hook @code{before-init-hook}. 70It 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
79It loads the file @file{~/.emacs} unless @samp{-q} was specified on 79It loads the file @file{~/.emacs}, unless @samp{-q} was specified on the
80the command line. (This is not done in @samp{-batch} mode.) The @samp{-u} 80command line. (This is not done in @samp{-batch} mode.) The @samp{-u}
81option can specify the user name whose home directory should be used 81option can specify another user name whose home directory should be used
82instead of @file{~}. 82instead of @file{~}.
83 83
84@item 84@item
85It loads the library @file{default} unless @code{inhibit-default-init} 85It loads the library @file{default}, unless @code{inhibit-default-init}
86is non-@code{nil}. (This is not done in @samp{-batch} mode or if 86is 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
88is usually @file{default.el}. 88is usually @file{default.el}.
@@ -461,11 +461,11 @@ likely @code{fg}.
461systems, ``suspension'' actually creates a new shell temporarily as a 461systems, ``suspension'' actually creates a new shell temporarily as a
462subprocess of Emacs. Then you would exit the shell to return to Emacs. 462subprocess 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
465Emacs job may not have a parent that can resume it again, and in any 465may not have a parent that can resume it again, and in any case you can
466case you can give input to some other job such as a shell merely by 466give input to some other job such as a shell merely by moving to a
467moving to a different window. Therefore, suspending is not allowed 467different window. Therefore, suspending is not allowed when Emacs is using
468when Emacs is an X client. 468a window system.
469 469
470@defun suspend-emacs string 470@defun suspend-emacs string
471This function stops Emacs and returns control to the superior process. 471This 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
478appear. 478appear.
479 479
480Before suspending, @code{suspend-emacs} runs the normal hook 480Before 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}.
482normal hook; its value was a single function, and if its value was
483non-@code{nil}, then @code{suspend-emacs} returned immediately without
484actually suspending anything.
485 482
486After the user resumes Emacs, @code{suspend-emacs} runs the normal hook 483After 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.
553through various functions. These variables include the name of the 550through various functions. These variables include the name of the
554system, the user's @sc{uid}, and so on. 551system, the user's @sc{uid}, and so on.
555 552
553@defvar system-configuration
554This variable holds the GNU configuration name for the hardware/software
555configuration of your system, as a string. The convenient way to test
556parts of this string is with @code{string-match}.
557@end defvar
558
556@defvar system-type 559@defvar system-type
557The value of this variable is a symbol indicating the type of operating 560The value of this variable is a symbol indicating the type of operating
558system Emacs is operating on. Here is a table of the possible values: 561system Emacs is operating on. Here is a table of the possible values:
@@ -568,10 +571,12 @@ Berkeley BSD.
568Data General DGUX operating system. 571Data General DGUX operating system.
569 572
570@item gnu 573@item gnu
571A GNU system (using the GNU kernel, which consists of the HURD and Mach). 574the GNU system (using the GNU kernel, which consists of the HURD and Mach).
572 575
573@item gnu/linux 576@item gnu/linux
574A variant GNU system using the Linux kernel. 577A GNU/Linux system---that is, a variant GNU system, using the Linux
578kernel. (These systems are the ones people often call ``Linux,'' but
579actually Linux is just the kernel, not the whole system.)
575 580
576@item hpux 581@item hpux
577Hewlett-Packard HPUX operating system. 582Hewlett-Packard HPUX operating system.
@@ -611,12 +616,6 @@ alternatives in the future. We recommend using
611systems. 616systems.
612@end defvar 617@end defvar
613 618
614@defvar system-configuration
615This variable holds the GNU configuration name for the hardware/software
616configuration of your system, as a string. The convenient way to test
617parts of this string is with @code{string-match}.
618@end defvar
619
620@defun system-name 619@defun system-name
621This function returns the name of the machine you are running on. 620This function returns the name of the machine you are running on.
622@example 621@example
@@ -944,7 +943,7 @@ in the past or future.
944Time conversion functions always use the Gregorian calendar, even for 943Time conversion functions always use the Gregorian calendar, even for
945dates before the Gregorian calendar was introduced. Year numbers count 944dates before the Gregorian calendar was introduced. Year numbers count
946the number of years since the year 1 B.C., and do not skip zero as 945the number of years since the year 1 B.C., and do not skip zero as
947traditional Gregorian years do; for example, the year number -37 946traditional Gregorian years do; for example, the year number @minus{}37
948represents the Gregorian year 38 B.C@. 947represents 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.
1012This stands for the week of the year (01-52), assuming that weeks 1011This stands for the week of the year (01-52), assuming that weeks
1013start on Monday. 1012start on Monday.
1014@item %x 1013@item %x
1015This has a locale-specific meaning. In the default locale (named C), it 1014This has a locale-specific meaning. In the default locale (named
1016is equivalent to @samp{%D}. 1015@samp{C}), it is equivalent to @samp{%D}.
1017@item %X 1016@item %X
1018This has a locale-specific meaning. In the default locale (named C), it 1017This has a locale-specific meaning. In the default locale (named
1019is equivalent to @samp{%T}. 1018@samp{C}), it is equivalent to @samp{%T}.
1020@item %y 1019@item %y
1021This stands for the year without century (00-99). 1020This 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
1028You can also specify the field width and type of padding for any of 1027You can also specify the field width and type of padding for any of
1029these @samp{%}-constructs. This works as in @code{printf}: you write 1028these @samp{%}-sequences. This works as in @code{printf}: you write
1030the field width as digits in the middle of a @samp{%}-construct. If you 1029the field width as digits in the middle of a @samp{%}-sequences. If you
1031start the field width with 0, it means to pad with zeros. 1030start the field width with 0, it means to pad with zeros.
1032 1031
1033For example, @samp{%S} specifies the number of seconds since the minute; 1032For 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
1069Greenwich. 1068Greenwich.
1070@end table 1069@end table
1071 1070
1072Note 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
1112after a certain length of idleness. 1111after 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
1115can run them only when Emacs could accept output from a subprocess: 1114can run them only when Emacs could accept output from a subprocess:
1116namely, while waiting or inside certain primitive functions such as 1115namely, 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
1124later, and @var{args} are the arguments to give it when it is called. 1123later, and @var{args} are the arguments to give it when it is called.
1125The time @var{time} is specified as a string. 1124The time @var{time} is specified as a string.
1126 1125
1127Absolute times may be specified in a variety of formats; The form 1126Absolute times may be specified in a wide variety of formats, and tries
1127to 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
1130the format that @code{current-time-string} returns is also allowed. 1130format that @code{current-time-string} returns is also allowed.
1131 1131
1132To specify a relative time, use numbers followed by units. 1132To specify a relative time, use numbers followed by units.
1133For example: 1133For example:
@@ -1208,12 +1208,12 @@ idleness will continue to increase and will not go down to five seconds
1208again. 1208again.
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
1211handle data from a subprocess. But these interludes during idleness 1211handle data from a subprocess. But these interludes during idleness do
1212have little effect on idle timers. An idle timer set for 600 seconds 1212not interfere with idle timers, because they do not reset the clock of
1213will run when ten minutes have elapsed since the last user command was 1213idleness to zero. An idle timer set for 600 seconds will run when ten
1214finished, even if subprocess output has been accepted thousands of times 1214minutes have elapsed since the last user command was finished, even if
1215within those ten minutes, even if there have been garbage collections 1215subprocess output has been accepted thousands of times within those ten
1216and autosaves. 1216minutes, 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
1219input. Then it becomes idle again, and all the idle timers that are 1219input. 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
1250This function sets the mode for reading keyboard input. If 1250This 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
1253directly with X, it ignores this argument and uses interrupts if that is 1253system dependent. Some systems always use @sc{cbreak} mode regardless
1254the way it knows how to communicate. 1254of what is specified.
1255 1255
1256If @var{flow} is non-@code{nil}, then Emacs uses @sc{xon/xoff} (@kbd{C-q}, 1256When 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 1257uses interrupts if that is the way it knows how to communicate.
1258in @sc{cbreak} mode. @xref{Flow Control}.
1259 1258
1260The default setting is system dependent. Some systems always use 1259If @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
1261has no effect except in @sc{cbreak} mode. @xref{Flow Control}.
1262 1262
1263@c Emacs 19 feature 1263@c Emacs 19 feature
1264The argument @var{meta} controls support for input character codes 1264The 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},
1267Emacs disregards the 8th bit; this is necessary when the terminal uses 1267Emacs disregards the 8th bit; this is necessary when the terminal uses
1268it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil}, 1268it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil},
1269Emacs uses all 8 bits of input unchanged. This is good for terminals 1269Emacs uses all 8 bits of input unchanged. This is good for terminals
1270using European 8-bit character sets. 1270that use 8-bit character sets.
1271 1271
1272@c Emacs 19 feature 1272@c Emacs 19 feature
1273If @var{quit-char} is non-@code{nil}, it specifies the character to 1273If @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
1292is non-@code{nil} if Emacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s}) 1292is non-@code{nil} if Emacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s})
1293flow control for output to the terminal. This value has no effect 1293flow control for output to the terminal. This value has effect when
1294unless @var{interrupt} is non-@code{nil}. 1294unless @var{interrupt} is @code{nil}.
1295@item meta 1295@item meta
1296is @code{t} if Emacs treats the eighth bit of input characters as 1296is @code{t} if Emacs treats the eighth bit of input characters as
1297the meta bit; @code{nil} means Emacs clears the eighth bit of every 1297the 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}.
1310other input events before they become part of key sequences. These 1310other input events before they become part of key sequences. These
1311features apply to each event in the order they are described here: each 1311features apply to each event in the order they are described here: each
1312event is first modified according to @code{extra-keyboard-modifiers}, 1312event is first modified according to @code{extra-keyboard-modifiers},
1313then translated through @code{keyboard-translate-table} (if applicable). 1313then translated through @code{keyboard-translate-table} (if applicable),
1314If it is being read as part of a key sequence, it is then added to the 1314and finally decoded with the specified keyboard coding system. If it is
1315sequece being read; then subsequences containing it are checked first 1315being read as part of a key sequence, it is then added to the sequence
1316with @code{function-key-map} and then with @code{key-translation-map}. 1316being 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.
1334Each time the user types a keyboard key, it is altered as if the 1335Each time the user types a keyboard key, it is altered as if the
1335modifier keys specified in the bit mask were held down. 1336modifier keys specified in the bit mask were held down.
1336 1337
1337When using X windows, the program can ``press'' any of the modifier 1338When using a window system, the program can ``press'' any of the
1338keys in this way. Otherwise, only the @key{CTL} and @key{META} keys can 1339modifier keys in this way. Otherwise, only the @key{CTL} and @key{META}
1339be virtually pressed. 1340keys 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
1394sequences being read. They are implemented in @code{read-key-sequence} 1395sequences being read. They are implemented in @code{read-key-sequence}
1395and have no effect on @code{read-char}. 1396and have no effect on input read with @code{read-event}.
1396 1397
1397@defvar function-key-map 1398@defvar function-key-map
1398This variable holds a keymap that describes the character sequences sent 1399This 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
1406key sequence, it is replaced with the events in @var{v}. 1407key sequence, it is replaced with the events in @var{v}.
1407 1408
1408For example, VT100 terminals send @kbd{@key{ESC} O P} when the 1409For example, VT100 terminals send @kbd{@key{ESC} O P} when the
1409keypad PF1 key is pressed. Therefore, we want Emacs to translate 1410keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate
1410that sequence of events into the single event @code{pf1}. We accomplish 1411that sequence of events into the single event @code{pf1}. We accomplish
1411this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in 1412this 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
1419Entries in @code{function-key-map} are ignored if they conflict with 1420Entries in @code{function-key-map} are ignored if they conflict with
1420bindings made in the minor mode, local, or global keymaps. The intent 1421bindings made in the minor mode, local, or global keymaps. The intent
1421is that the character sequences that function keys send should not have 1422is that the character sequences that function keys send should not have
1422command bindings in their own right. 1423command bindings in their own right---but if they do, the ordinary
1424bindings take priority.
1423 1425
1424The value of @code{function-key-map} is usually set up automatically 1426The value of @code{function-key-map} is usually set up automatically
1425according to the terminal's Terminfo or Termcap entry, but sometimes 1427according 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
1427terminal-specific files for many common terminals; their main purpose is 1429terminal-specific files for many common terminals; their main purpose is
1428to make entries in @code{function-key-map} beyond those that can be 1430to make entries in @code{function-key-map} beyond those that can be
1429deduced from Termcap and Terminfo. @xref{Terminal-Specific}. 1431deduced from Termcap and Terminfo. @xref{Terminal-Specific}.
1430
1431Emacs versions 18 and earlier used totally different means of detecting
1432the 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 1496Finally, 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) 1498translations listed above. @xref{Specifying Coding Systems}. In future
1500The @file{iso-transl} library uses this feature to provide a way of 1499Emacs versions, character set decoding may be done before the other
1501inputting non-ASCII Latin-1 characters. 1500translations.
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
1507This function returns a vector containing the last 100 input events 1506This function returns a vector containing the last 100 input events from
1508from the keyboard or mouse. All input events are included, whether or 1507the keyboard or mouse. All input events are included, whether or not
1509not they were used as parts of key sequences. Thus, you always get the 1508they were used as parts of key sequences. Thus, you always get the last
1510last 100 inputs, not counting keyboard macros. (Events from keyboard 1509100 input events, not counting events generated by keyboard macros.
1511macros are excluded because they are less interesting for debugging; it 1510(These are excluded because they are less interesting for debugging; it
1512should be enough to see the events that invoked the macros.) 1511should 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
1565than optimal. To fix the problem, set @code{baud-rate}. 1564than optimal. To fix the problem, set @code{baud-rate}.
1566 1565
1567@defun baud-rate 1566@defun baud-rate
1568This function returns the value of the variable @code{baud-rate}. In 1567This obsolete function returns the value of the variable
1569Emacs versions 18 and earlier, this was the only way to find out the 1568@code{baud-rate}.
1570terminal 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
1619This variable's value should be an alist with one element for each 1617This variable's value should be an alist with one element for each
1620system-specific keysym. An element has this form: @code{(@var{code} 1618system-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
1622including the ``vendor specific'' bit, 1 << 28), and @var{symbol} is the 1620including the ``vendor specific'' bit,
1623name for the function key. 1621@ifinfo
1622-2**28,
1623@end ifinfo
1624@tex
1625$-2^{28}$,
1626@end tex
1627and @var{symbol} is the name for the function key.
1624 1628
1625For example @code{(168 . mute-acute)} defines a system-specific key used 1629For example @code{(168 . mute-acute)} defines a system-specific key used
1626by HP X servers whose numeric code is (1 << 28) + 168. 1630by 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
1628It is not a problem if the alist defines keysyms for other X servers, as 1639It is not crucial to exclude from the alist the keysyms of other X
1629long as they don't conflict with the ones used by the X server actually 1640servers; those do no harm, as long as they don't conflict with the ones
1630in use. 1641used by the X server actually in use.
1631 1642
1632The variable is always local to the current X terminal and cannot be 1643The variable is always local to the current X terminal and cannot be
1633buffer-local. @xref{Multiple Displays}. 1644buffer-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
1641to use flow-control characters in its command character set?'' For a 1652flow-control characters in its command character set?'' For a second
1642second view on this issue, read the comments on flow control in the 1653view 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
1644entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}. 1655entries 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
1651Emacs, for economy of keystrokes and portability, used nearly all the 1662was natural and uncontroversial. With so many commands needing key
1652@sc{ASCII} control characters, with mnemonic meanings when possible; 1663assignments. of course we assigned meanings to nearly all @sc{ASCII}
1653thus, @kbd{C-s} for search and @kbd{C-q} for quote. 1664control characters.
1654 1665
1655 Later, some terminals were introduced which required these characters 1666 Later, some terminals were introduced which required these characters
1656for flow control. They were not very good terminals for full-screen 1667for flow control. They were not very good terminals for full-screen
1657editing, so Emacs maintainers did not pay attention. In later years, 1668editing, so Emacs maintainers ignored them. In later years, flow
1658flow control with @kbd{C-s} and @kbd{C-q} became widespread among 1669control with @kbd{C-s} and @kbd{C-q} became widespread among terminals,
1659terminals, but by this time it was usually an option. And the majority 1670but by this time it was usually an option. And the majority of Emacs
1660of users, who can turn flow control off, were unwilling to switch to 1671users, who can turn flow control off, did not want to switch to less
1661less mnemonic key bindings for the sake of flow control. 1672mnemonic 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
1664concentrator manufacturers? This question has no simple answer. 1675concentrator 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.
1668techniques (albeit less common in practice) for flow control that 1679techniques (albeit less common in practice) for flow control that
1669preserve transparency of the character stream. Note also that their use 1680preserve transparency of the character stream. Note also that their use
1670for flow control is not an official standard. Interestingly, on the 1681for flow control is not an official standard. Interestingly, on the
1671model 33 teletype with a paper tape punch (which is very old), @kbd{C-s} 1682model 33 teletype with a paper tape punch (around 1970), @kbd{C-s} and
1672and @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
1675terminals, this problem is gradually being cured. For the mean time, 1686terminals, the flow control problem is gradually disappearing. For the
1676Emacs provides a convenient way of enabling flow control if you want it: 1687mean time, Emacs provides a convenient way of enabling flow control if
1677call the function @code{enable-flow-control}. 1688you want it: call the function @code{enable-flow-control}.
1678 1689
1679@deffn Command enable-flow-control 1690@deffn Command enable-flow-control
1680This function enables use of @kbd{C-s} and @kbd{C-q} for output flow 1691This 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.
241In an interactive call, @var{n} is the numeric prefix argument, 241In an interactive call, @var{n} is the numeric prefix argument,
242if provided; otherwise @var{n} defaults to @code{nil}. 242if provided; otherwise @var{n} defaults to @code{nil}.
243 243
244Don'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.
253In an interactive call, @var{n} is the numeric prefix argument, 253In an interactive call, @var{n} is the numeric prefix argument,
254if provided; otherwise @var{n} defaults to @code{nil}. 254if provided; otherwise @var{n} defaults to @code{nil}.
255 255
256Don'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
763not prevent functions which modify the buffer from setting
764@code{deactivate-mark}, and thus causing the deactivation of the mark
765after 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
127file name. 125file 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
132which contains file names that were specified by the user. These
133programs ought to be able to support any valid file name. But the shell
134gives special treatment to certain characters, and if these characters
135occur in the file name, they will confuse the shell. To handle these
136characters, use the function @code{shell-quote-argument}:
137
138@defun shell-quote-argument argument
139This function returns a string which represents, in shell syntax,
140an argument whose actual contents are @var{argument}. It should
141work reliably to concatenate the return value into a shell command
142and then pass it to a shell for execution.
143
144Precisely what this function does depends on your operating system. The
145function is designed to work with the usual shell syntax; if you use an
146unusual shell, you will need to redefine this function. On MS-DOS, the
147function returns @var{argument} unchanged; while this is not really
148correct, it is the best one can do, since the MS-DOS shell has no
149quoting 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
157Here's an example of using @code{shell-quote-argument} to construct
158a 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
145user types another @kbd{C-g}, that kills the subprocess instantly with 183user 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
14918. Now they return an indication of how the process terminated. 187process 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
152coding system, much like text read from a file. The input sent to a 190coding system, much like text read from a file. The input sent to a
153subprocess by @code{call-process-region} is encoded using a coding 191subprocess by @code{call-process-region} is encoded using a coding
154system, much like text written into a file. @xref{Coding Systems}. 192system, much like text written into a file. @xref{Coding Systems}.
193On Microsoft operating systems, additional variables control
194the 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
157This function calls @var{program} in a separate process and waits for 197This 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
168standard output stream and the standard error stream of the process. 208standard output stream and the standard error stream of the process.
169 209
170@item a string 210@item a string
171Find the buffer with that name, then insert the output in that buffer, 211Insert the output in a buffer with that name, before point.
172before point.
173 212
174@item @code{t} 213@item @code{t}
175Insert the output in the current buffer, before point. 214Insert the output in the current buffer, before point.
@@ -190,9 +229,9 @@ function returns.
190Keep the standard output stream separate from the standard error stream; 229Keep the standard output stream separate from the standard error stream;
191deal with the ordinary output as specified by @var{real-destination}, 230deal with the ordinary output as specified by @var{real-destination},
192and dispose of the error output according to @var{error-destination}. 231and dispose of the error output according to @var{error-destination}.
193The value @code{nil} means discard it, @code{t} means mix it with the 232If @var{error-destination} is @code{nil}, that means to discard the
194ordinary output, and a string specifies a file name to redirect error 233error output, @code{t} means mix it with the ordinary output, and a
195output into. 234string specifies a file name to redirect error output into.
196 235
197You can't directly specify a buffer to put the error output in; that is 236You can't directly specify a buffer to put the error output in; that is
198too difficult to implement. But you can achieve this result by sending 237too 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
240The @code{insert-directory} function contains a good example of the use 279Here is a good example of the use of @code{call-process}, which used to
241of @code{call-process}: 280be 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,
318then returns the command's output as a string. 357then 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
325a synchronous subprocess are text or binary. Text data requires
326translation 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
331subprocess, and @code{binary-process-output} applies to output received
332from it. A non-@code{nil} value means the data is non-text; @code{nil}
333means the data is text, and calls for conversion.
334
335@defvar binary-process-input
336If this variable is @code{nil}, convert newlines to @sc{crlf} sequences in
337the input to a synchronous subprocess.
338@end defvar
339
340@defvar binary-process-output
341If this variable is @code{nil}, convert @sc{crlf} sequences to newlines in
342the 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
403command name, and @var{command-args} are the arguments for the shell 416command name, and @var{command-args} are the arguments for the shell
404command. The variable @code{shell-file-name} specifies which shell to 417command. The variable @code{shell-file-name} specifies which shell to
405use. 418use.
419
420The point of running a program through the shell, rather than directly
421with @code{start-process}, is so that you can employ shell features such
422as wildcards in the arguments. It follows that if you include an
423arbitrary user-specified filename in the command, you should quote it
424with @code{shell-quote-argument} first, so that any special shell
425characters in the file name do @emph{not} have their special shell
426meanings. @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
602For a network connection, @code{process-status} returns one of the symbols 623For 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
604closed the connection, or Emacs did @code{delete-process}. 625closed the connection, or Emacs did @code{delete-process}.
605
606In Emacs version 18, the status of a network connection was @code{run}
607if 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
789signal @code{SIGTSTP}. Use @code{continue-process} to resume its 806signal @code{SIGTSTP}. Use @code{continue-process} to resume its
790execution. 807execution.
791 808
792On systems with job control, outside of Emacs)\, the ``stop character'' 809Outside 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
199need to use one of the special characters. Here is a list of them: 199need 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
205is a special character that matches any single character except a newline. 205is a special character that matches any single character except a newline.
206Using concatenation, we can make regular expressions like @samp{a.b}, which 206Using concatenation, we can make regular expressions like @samp{a.b}, which
207matches any three-character string that begins with @samp{a} and ends with 207matches 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
212is not a construct by itself; it is a postfix operator that means to 212is not a construct by itself; it is a postfix operator that means to
213match the preceding regular expression repetitively as many times as 213match 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
237concluding that none of them can work. To make sure your regular 237concluding that none of them can work. To make sure your regular
238expressions run fast, check nested repetitions carefully. 238expressions run fast, check nested repetitions carefully.
239 239
240@item + 240@item @samp{+}
241@cindex @samp{+} in regexp 241@cindex @samp{+} in regexp
242is a postfix operator, similar to @samp{*} except that it must match 242is a postfix operator, similar to @samp{*} except that it must match
243the preceding expression at least once. So, for example, @samp{ca+r} 243the preceding expression at least once. So, for example, @samp{ca+r}
244matches the strings @samp{car} and @samp{caaaar} but not the string 244matches 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
249is a postfix operator, similar to @samp{*} except that it must match the 249is a postfix operator, similar to @samp{*} except that it must match the
250preceding expression either once or not at all. For example, 250preceding 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
257is a @dfn{character set}, which begins with @samp{[} and is terminated 257is a @dfn{character alternative}, which begins with @samp{[} and is
258by @samp{]}. In the simplest case, the characters between the two 258terminated by @samp{]}. In the simplest case, the characters between
259brackets are what this set can match. 259the two brackets are what this character alternative can match.
260 260
261Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and 261Thus, @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}
264matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc. 264matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc.
265 265
266You can also include character ranges in a character set, by writing the 266You can also include character ranges in a character alternative, by
267starting and ending characters with a @samp{-} between them. Thus, 267writing the starting and ending characters with a @samp{-} between them.
268@samp{[a-z]} matches any lower-case ASCII letter. Ranges may be 268Thus, @samp{[a-z]} matches any lower-case ASCII letter. Ranges may be
269intermixed freely with individual characters, as in @samp{[a-z$%.]}, 269intermixed freely with individual characters, as in @samp{[a-z$%.]},
270which matches any lower case ASCII letter or @samp{$}, @samp{%} or 270which matches any lower case ASCII letter or @samp{$}, @samp{%} or
271period. 271period.
@@ -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
286Note that the usual regexp special characters are not special inside a 286Note that the usual regexp special characters are not special inside a
287character set. A completely different set of special characters exists 287character alternative. A completely different set of characters are
288inside character sets: @samp{]}, @samp{-} and @samp{^}. 288special inside character alternatives: @samp{]}, @samp{-} and @samp{^}.
289 289
290To include a @samp{]} in a character set, you must make it the first 290To include a @samp{]} in a character alternative, you must make it the
291character. For example, @samp{[]a]} matches @samp{]} or @samp{a}. To 291first character. For example, @samp{[]a]} matches @samp{]} or @samp{a}.
292include a @samp{-}, write @samp{-} as the first or last character of the 292To include a @samp{-}, write @samp{-} as the first or last character of
293set, or put it after a range. Thus, @samp{[]-]} matches both @samp{]} 293the character alternative, or put it after a range. Thus, @samp{[]-]}
294and @samp{-}. 294matches both @samp{]} and @samp{-}.
295 295
296To include @samp{^} in a set, put it anywhere but at the beginning of 296To include @samp{^} in a character alternative, put it anywhere but at
297the set. 297the 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
302character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches 302character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches
303all characters @emph{except} letters and digits. 303all 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
306character. The character following the @samp{^} is treated as if it 306character. The character following the @samp{^} is treated as if it
307were first (in other words, @samp{-} and @samp{]} are not special there). 307were first (in other words, @samp{-} and @samp{]} are not special there).
308 308
309A complemented character set can match a newline, unless newline is 309A complemented character alternative can match a newline, unless newline is
310mentioned as one of the characters not to match. This is in contrast to 310mentioned as one of the characters not to match. This is in contrast to
311the handling of regexps in programs such as @code{grep}. 311the 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
316is a special character that matches the empty string, but only at the 316is a special character that matches the empty string, but only at the
@@ -321,7 +321,7 @@ the beginning of a line.
321When matching a string instead of a buffer, @samp{^} matches at the 321When matching a string instead of a buffer, @samp{^} matches at the
322beginning of the string or after a newline character @samp{\n}. 322beginning 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
326is similar to @samp{^} but matches only at the end of a line. Thus, 326is 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,
329When matching a string instead of a buffer, @samp{$} matches at the end 329When matching a string instead of a buffer, @samp{$} matches at the end
330of the string or before a newline character @samp{\n}. 330of 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
334has two functions: it quotes the special characters (including 334has 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
360second character in the sequence is always an ordinary character on 360second character in the sequence is always an ordinary character on
361their own. Here is a table of @samp{\} constructs. 361their 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}.
454they don't use up any characters---but whether they match depends on the 454they don't use up any characters---but whether they match depends on the
455context. 455context.
456 456
457@table @kbd 457@table @samp
458@item \` 458@item \`
459@cindex @samp{\`} in regexp 459@cindex @samp{\`} in regexp
460matches the empty string, but only at the beginning 460matches 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
520One use of @code{regexp-quote} is to combine an exact string match with 520One use of @code{regexp-quote} is to combine an exact string match with
521context described as a regular expression. For example, this searches 521context described as a regular expression. For example, this searches
522for the string that is the value of @code{string}, surrounded by 522for the string that is the value of @var{string}, surrounded by
523whitespace: 523whitespace:
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
560This function returns the total number of grouping constructs 560This 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
583In contrast, if you evaluate the variable @code{sentence-end}, you
583will see the following: 584will see the following:
584 585
585@example 586@example
586@group 587@group
587sentence-end 588sentence-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 [.?!]
602The first part of the pattern is a character set that matches any one of 602The first part of the pattern is a character alternative that matches
603three characters: period, question mark, and exclamation mark. The 603any one of three characters: period, question mark, and exclamation
604match must begin with one of these three characters. 604mark. The match must begin with one of these three characters.
605 605
606@item []\"')@}]* 606@item []\"')@}]*
607The second part of the pattern matches any closing braces and quotation 607The second part of the pattern matches any closing braces and quotation
608marks, zero or more of them, that may follow the period, question mark 608marks, zero or more of them, that may follow the period, question mark
609or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in 609or exclamation mark. The @code{\"} is Lisp syntax for a double-quote in
610a string. The @samp{*} at the end indicates that the immediately 610a string. The @samp{*} at the end indicates that the immediately
611preceding regular expression (a character set, in this case) may be 611preceding regular expression (a character alternative, in this case) may be
612repeated zero or more times. 612repeated 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
634incrementally or not. For incremental search commands, see @ref{Regexp 634expression either incrementally or not. For incremental search
635Search, , Regular Expression Search, emacs, The GNU Emacs Manual}. Here 635commands, see @ref{Regexp Search, , Regular Expression Search, emacs,
636we describe only the search functions useful in programs. The principal 636The GNU Emacs Manual}. Here we describe only the search functions
637one is @code{re-search-forward}. 637useful 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
640the buffer is multibyte; they convert the regular expression to unibyte 640the 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
704beginning to end, and starts at a specified beginning position. 704beginning to end, and starts at a specified beginning position.
705 705
706A true mirror-image of @code{re-search-forward} would require a special 706A true mirror-image of @code{re-search-forward} would require a special
707feature for matching regexps from end to beginning. It's not worth the 707feature for matching regular expressions from end to beginning. It's
708trouble of implementing that. 708not 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
1001match data around it, to prevent it from being overwritten. 1001match 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
1019This function replaces the text in the buffer (or in @var{string}) that
1020was matched by the last search. It replaces that text with
1021@var{replacement}.
1022
1023If you did the last search in a buffer, you should specify @code{nil}
1024for @var{string}. Then @code{replace-match} does the replacement by
1025editing the buffer; it leaves point at the end of the replacement text,
1026and returns @code{t}.
1027
1028If you did the search in a string, pass the same string as @var{string}.
1029Then @code{replace-match} does the replacement by constructing and
1030returning a new string.
1031
1032If @var{fixedcase} is non-@code{nil}, then the case of the replacement
1033text is not changed; otherwise, the replacement text is converted to a
1034different case depending upon the capitalization of the text to be
1035replaced. If the original text is all upper case, the replacement text
1036is converted to upper case. If the first word of the original text is
1037capitalized, then the first word of the replacement text is capitalized.
1038If the original text contains just one word, and that word is a capital
1039letter, @code{replace-match} considers this a capitalized first word
1040rather than all upper case.
1041
1042If @code{case-replace} is @code{nil}, then case conversion is not done,
1043regardless of the value of @var{fixed-case}. @xref{Searching and Case}.
1044
1045If @var{literal} is non-@code{nil}, then @var{replacement} is inserted
1046exactly as it is, the only alterations being case changes as needed.
1047If it is @code{nil} (the default), then the character @samp{\} is treated
1048specially. If a @samp{\} appears in @var{replacement}, then it must be
1049part 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
1059matched the @var{n}th subexpression in the original regexp.
1060Subexpressions 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
1067If @var{subexp} is non-@code{nil}, that says to replace just
1068subexpression number @var{subexp} of the regexp that was matched, not
1069the entire match. For example, after matching @samp{foo \(ba*r\)},
1070calling @code{replace-match} with 1 as @var{subexp} means to replace
1071just 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
1039If the last such operation was done against a string with 1102If 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
1041argument @var{in-string}. Otherwise, after a buffer search or match, 1104argument @var{in-string}. After a buffer search or match,
1042you should omit @var{in-string} or pass @code{nil} for it; but you 1105you should omit @var{in-string} or pass @code{nil} for it; but you
1043should make sure that the current buffer when you call 1106should 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
1057If @var{count} is zero, then the value is the position of the start of 1120If @var{count} is zero, then the value is the position of the start of
1058the entire match. Otherwise, @var{count} specifies a subexpression in 1121the entire match. Otherwise, @var{count} specifies a subexpression in
1059the regular expresion, and the value of the function is the starting 1122the regular expression, and the value of the function is the starting
1060position of the match for that subexpression. 1123position of the match for that subexpression.
1061 1124
1062The value is @code{nil} for a subexpression inside a @samp{\|} 1125The 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
1137character of the buffer counts as 1.) 1200character 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
1147This function replaces the text in the buffer (or in @var{string}) that
1148was matched by the last search. It replaces that text with
1149@var{replacement}.
1150
1151If you did the last search in a buffer, you should specify @code{nil}
1152for @var{string}. Then @code{replace-match} does the replacement by
1153editing the buffer; it leaves point at the end of the replacement text,
1154and returns @code{t}.
1155
1156If you did the search in a string, pass the same string as @var{string}.
1157Then @code{replace-match} does the replacement by constructing and
1158returning a new string.
1159
1160If @var{fixedcase} is non-@code{nil}, then the case of the replacement
1161text is not changed; otherwise, the replacement text is converted to a
1162different case depending upon the capitalization of the text to be
1163replaced. If the original text is all upper case, the replacement text
1164is converted to upper case. If the first word of the original text is
1165capitalized, then the first word of the replacement text is capitalized.
1166If the original text contains just one word, and that word is a capital
1167letter, @code{replace-match} considers this a capitalized first word
1168rather than all upper case.
1169
1170If @code{case-replace} is @code{nil}, then case conversion is not done,
1171regardless of the value of @var{fixed-case}. @xref{Searching and Case}.
1172
1173If @var{literal} is non-@code{nil}, then @var{replacement} is inserted
1174exactly as it is, the only alterations being case changes as needed.
1175If it is @code{nil} (the default), then the character @samp{\} is treated
1176specially. If a @samp{\} appears in @var{replacement}, then it must be
1177part 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
1187matched the @var{n}th subexpression in the original regexp.
1188Subexpressions 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
1195If @var{subexp} is non-@code{nil}, that says to replace just
1196subexpression number @var{subexp} of the regexp that was matched, not
1197the entire match. For example, after matching @samp{foo \(ba*r\)},
1198calling @code{replace-match} with 1 as @var{subexp} means to replace
1199just 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
1231All the elements are markers or @code{nil} if matching was done on a 1231All the elements are markers or @code{nil} if matching was done on a
1232buffer, and all are integers or @code{nil} if matching was done on a 1232buffer, and all are integers or @code{nil} if matching was done on a
1233string with @code{string-match}. (In Emacs 18 and earlier versions, 1233string with @code{string-match}.
1234markers were used even for matching on a string, except in the case
1235of the integer 0.)
1236 1234
1237As always, there must be no possibility of intervening searches between 1235As always, there must be no possibility of intervening searches between
1238the call to a search function and the call to @code{match-data} that is 1236the 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
1258an error; that sets the match data in a meaningless but harmless way. 1256an 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
1287data around it. 1285data 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
1291imitate the effect of the special form @code{save-match-data}. This is 1289imitate the effect of the special form @code{save-match-data}. Here is
1292useful for writing code that can run in Emacs 18. Here is how: 1290how:
1293 1291
1294@example 1292@example
1295@group 1293@group
@@ -1384,9 +1382,10 @@ same as @code{(default-value 'case-fold-search)}.
1384used for certain purposes in editing: 1382used for certain purposes in editing:
1385 1383
1386@defvar page-delimiter 1384@defvar page-delimiter
1387This is the regexp describing line-beginnings that separate pages. The 1385This is the regular expression describing line-beginnings that separate
1388default value is @code{"^\014"} (i.e., @code{"^^L"} or @code{"^\C-l"}); 1386pages. The default value is @code{"^\014"} (i.e., @code{"^^L"} or
1389this matches a line that starts with a formfeed character. 1387@code{"^\C-l"}); this matches a line that starts with a formfeed
1388character.
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
11types: lists, vectors, and strings. In other words, any list is a 11types: lists and arrays. In other words, any list is a sequence, and
12sequence, any vector is a sequence, and any string is a sequence. The 12any array is a sequence. The common property that all sequences have is
13common property that all sequences have is that each is an ordered 13that each is an ordered collection of elements.
14collection 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
17elements. All the elements are accessible in constant time, but the 16of its elements. All the elements are accessible in constant time, but
18length of an existing array cannot be changed. Strings and vectors are 17the length of an existing array cannot be changed. Strings, vectors,
19the two types of arrays. 18char-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
22object; it is made of cons cells, one cell per element. Finding the 21object; 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
63string. The common property that all sequences have is that each is an 66common property of all sequences is that they are ordered collections of
64ordered collection of elements. This section describes functions that 67elements. This section describes functions that accept any kind of
65accept any kind of sequence. 68sequence.
66 69
67@defun sequencep object 70@defun sequencep object
68Returns @code{t} if @var{object} is a list, vector, or 71Returns @code{t} if @var{object} is a list, vector, or
69string, @code{nil} otherwise. 72string, @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
80This 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
83signaled.
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
113This function returns the element of @var{sequence} indexed by
114@var{index}. Legitimate values of @var{index} are integers ranging from
1150 up to one less than the length of @var{sequence}. If @var{sequence}
116is a list, then out-of-range values of @var{index} return @code{nil};
117otherwise, 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
143This 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
74Returns a copy of @var{sequence}. The copy is the same type of object 149Returns 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
141Returns the number of elements in @var{sequence}. If @var{sequence} is
142a 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
169This function returns the element of @var{sequence} indexed by
170@var{index}. Legitimate values of @var{index} are integers ranging from
1710 up to one less than the length of @var{sequence}. If @var{sequence}
172is a list, then out-of-range values of @var{index} return @code{nil};
173otherwise, 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
198This 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
209requires access time that is proportional to the position of the element 218requires access time that is proportional to the position of the element
210in the list. 219in 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:
213The amount of space allocated depends on the number of elements. 222@dfn{strings}, @dfn{vectors}, @dfn{bool-vectors} and @dfn{char-tables}.
214Therefore, it is impossible to change the size of an array once it is 223A vector is a general array; its elements can be any Lisp objects. A
215created; you cannot add or remove elements. However, you can replace an 224string is a specialized array; its elements must be characters (i.e.,
216element with a different value. 225integers between 0 and 255). Each type of array has its own read
217 226syntax. @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
220elements can be any Lisp objects. A string is a specialized array; its
221elements must be characters (i.e., integers between 0 and 255). Each
222type 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
231example, an array of four elements has indices 0, 1, 2, @w{and 3}. 234example, an array of four elements has indices 0, 1, 2, @w{and 3}.
232 235
233@item 236@item
237The length of the array is fixed once you create it; you cannot
238change the length of an existing array.
239
240@item
241The array is a constant, for evaluation---in other words, it evaluates
242to itself.
243
244@item
234The elements of an array may be referenced or changed with the functions 245The 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
239could use either a string or a vector. In practice, we always choose 250its length. You cannot specify the length of a char-table, because that
240strings for such applications, for four reasons: 251is determined by the range of character codes.
252
253 In principle, if you want an array of text characters, you could use
254either a string or a vector. In practice, we always choose strings for
255such 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
373whose elements can be accessed in constant time. A @dfn{vector} is a 387whose elements can be accessed in constant time. A @dfn{vector} is a
374general-purpose array; its elements can be any Lisp objects. (By 388general-purpose array of specified length; its elements can be any Lisp
375contrast, a string can hold only characters as elements.) Vectors in 389objects. (By contrast, a string can hold only characters as elements.)
376Emacs are used for obarrays (vectors of symbols), and as part of keymaps 390Vectors 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 391of keymaps (vectors of commands). They are also used internally as part
378representation of a byte-compiled function; if you print such a 392of the representation of a byte-compiled function; if you print such a
379function, you will see a vector in it. 393function, 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
490The @code{vconcat} function also allows byte-code function objects as
491arguments. This is a special feature to make it easy to access the entire
492contents of a byte-code function object. @xref{Byte-Code Objects}.
493
476The @code{vconcat} function also allows integers as arguments. It 494The @code{vconcat} function also allows integers as arguments. It
477converts them to strings of digits, making up the decimal print 495converts them to strings of digits, making up the decimal print
478representation of the integer, and then uses the strings instead of the 496representation 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
507character codes. Any valid character code, without modifiers, can be 525character codes. Any valid character code, without modifiers, can be
508used as an index in a char-table. You can access a char-table with 526used as an index in a char-table. You can access a char-table's
509@code{aref} and @code{aset}, just like a vector. 527elements with @code{aref} and @code{aset}, as with any array.
528Char-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
534element is initialized to @var{init}, which defaults to @code{nil}. You 553element is initialized to @var{init}, which defaults to @code{nil}. You
535cannot alter the subtype of a char-table after the char-table is 554cannot alter the subtype of a char-table after the char-table is
536created. 555created.
556
557There is no argument to specify the length of the char-table, because
558all 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
541This function returns @code{t} if @code{object} is a char-table, 563This function returns @code{t} if @var{object} is a char-table,
542otherwise @code{nil}. 564otherwise @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
629is a possible @var{range} argument for @code{char-table-range}, and the 651is a possible @var{range} argument for @code{char-table-range}, and the
630value is @code{(char-table-range @var{char-table} @var{key})}. Invalid 652value is @code{(char-table-range @var{char-table} @var{key})}. Invalid
631character codes are never used as the key. 653character codes are never used as @var{key}.
632 654
633Overall, the keys-value pairs passed to @var{function} describe all the 655Overall, the key-value pairs passed to @var{function} describe all the
634values stored in @var{char-table}. 656values 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
642values @code{t} and @code{nil}. If you try to store any non-@code{nil} 664values @code{t} and @code{nil}. If you try to store any non-@code{nil}
643value into an element of the bool-vector, that actually stores @code{t} 665value into an element of the bool-vector, the effect is to store
644there. 666@code{t} there. As with all arrays, bool-vector indices start from 0,
667and the length cannot be changed once the bool-vector is created.
668Bool-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
647from that, you manipulate them with same functions used for other kinds 671from 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
106The input characters are generated by @var{function}, one character per 106The input characters are generated by @var{function}, which must support
107call. Normally @var{function} is called with no arguments, and should 107two kinds of calls:
108return a character. 108
109 109@itemize @bullet
110@cindex unreading 110@item
111Occasionally @var{function} is called with one argument (always a 111When it is called with no arguments, it should return the next character.
112character). When that happens, @var{function} should save the argument 112
113and 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 114When it is called with one argument (always a character), @var{function}
115character too many and wants to ``put it back where it came from''. 115should save the argument and arrange to return it on the next call.
116In this case, it makes no difference what value @var{function} returns. 116This is called @dfn{unreading} the character; it happens when the Lisp
117reader reads one character too many and wants to ``put it back where it
118came 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.
163Note that the first read skips a space. Reading skips any amount of 167Note that the first read skips a space. Reading skips any amount of
164whitespace preceding the significant text. 168whitespace preceding the significant text.
165 169
166 In Emacs 18, reading a symbol discarded the delimiter terminating the
167symbol. Thus, point would end up at the beginning of @samp{contents}
168rather than after @samp{the}. The current behavior is superior because
169it correctly handles input such as @samp{bar(foo)}, where the
170open-parenthesis that ends one object is needed as the beginning of
171another 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,
174initially positioned at the beginning of the buffer shown. The value 171initially positioned at the beginning of the buffer shown. The value
175read is the symbol @code{This}. 172read is the symbol @code{This}.
@@ -296,9 +293,9 @@ and whose @sc{cdr} is an integer giving the position of the next
296remaining character in the string (i.e., the first one not read). 293remaining character in the string (i.e., the first one not read).
297 294
298If @var{start} is supplied, then reading begins at index @var{start} in 295If @var{start} is supplied, then reading begins at index @var{start} in
299the string (where the first character is at index 0). If @var{end} is 296the string (where the first character is at index 0). If you specify
300also 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
301of the string were not there. 298the rest of the string were not there.
302 299
303For example: 300For 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
384difference between input and output streams is therefore mostly one of 381difference between input and output streams is therefore more a matter
385how you use a Lisp object, not a distinction of types of object. 382of 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
388initially located as shown immediately before the @samp{h} in 385initially located as shown immediately before the @samp{h} in
@@ -532,18 +529,18 @@ being taken as delimiters when reading. @xref{Printed Representation},
532for full details. You specify quoting or no quoting by the choice of 529for full details. You specify quoting or no quoting by the choice of
533printing function. 530printing 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
536with quoting characters to avoid ambiguity. Likewise, if the purpose is 533quoting characters to avoid ambiguity. Likewise, if the purpose is to
537to describe a Lisp object clearly for a Lisp programmer. However, if 534describe a Lisp object clearly for a Lisp programmer. However, if the
538the purpose of the output is to look nice for humans, then it is better 535purpose of the output is to look nice for humans, then it is usually
539to print without quoting. 536better 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
542text. In certain cases, trying to produce this text leads to a stack 539an infinite amount of text, and could even result in stack overflow.
543overflow. Emacs detects such recursion and prints @samp{#@var{level}} 540Emacs detects such recursion and prints @samp{#@var{level}} instead of
544instead of recursively printing an object already being printed. For 541recursively printing an object already being printed. For example, here
545example, 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
546level 0 of the current print operation: 543the 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
696are printed as @samp{\n} and formfeeds are printed as @samp{\f}. 693are printed as @samp{\n} and formfeeds are printed as @samp{\f}.
697Normally these characters are printed as actual newlines and formfeeds. 694Normally these characters are printed as actual newlines and formfeeds.
698 695
699This variable affects the print functions @code{prin1} and @code{print}, 696This variable affects the print functions @code{prin1} and @code{print}
700as well as everything that uses them. It does not affect @code{princ}. 697that print with quoting. It does not affect @code{princ}. Here is an
701Here is an example using @code{prin1}: 698example 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
40characters. Characters are represented in Emacs Lisp as integers; 40characters. Characters are represented in Emacs Lisp as integers;
41whether an integer was intended as a character or not is determined only 41whether an integer is a character or not is determined only by how it is
42by how it is used. Thus, strings really contain integers. 42used. 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
45altered once the string exists. Strings in Lisp are @emph{not} 45altered once the string exists. Strings in Lisp are @emph{not}
46terminated by a distinguished character code. (By contrast, strings in 46terminated by a distinguished character code. (By contrast, strings in
47C are terminated by a character with @sc{ASCII} code 0.) 47C 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
50general array functions. (@xref{Sequences Arrays Vectors}.) For 50operate on them with the general array and sequence functions.
51example, you can access or change individual characters in a string 51(@xref{Sequences Arrays Vectors}.) For example, you can access or
52using the functions @code{aref} and @code{aset} (@pxref{Array 52change individual characters in a string using the functions @code{aref}
53Functions}). 53and @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
56Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text 56Emacs 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
64a key sequence, string elements in the range 128 to 255 represent meta 64a key sequence, string elements in the range 128 to 255 represent meta
65characters (which are extremely large integers) rather than keyboard 65characters (which are extremely large integers) rather than character
66events in the range 128 to 255. 66codes 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
69modifiers; they can hold @sc{ASCII} control characters, but no other 69modifiers; they can hold @sc{ASCII} control characters, but no other
@@ -201,14 +201,19 @@ Functions}).
201If the characters copied from @var{string} have text properties, the 201If the characters copied from @var{string} have text properties, the
202properties are copied into the new string also. @xref{Text Properties}. 202properties are copied into the new string also. @xref{Text Properties}.
203 203
204@code{substring} also allows vectors for the first argument.
205For example:
206
207@example
208(substring [a b (c) "d"] 1 3)
209 @result{} [b (c)]
210@end example
211
204A @code{wrong-type-argument} error is signaled if either @var{start} or 212A @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}
206error is signaled if @var{start} indicates a character following 214error 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
210the first argument.
211
212Contrast this function with @code{buffer-substring} (@pxref{Buffer 217Contrast this function with @code{buffer-substring} (@pxref{Buffer
213Contents}), which returns a string containing a portion of the text in 218Contents}), which returns a string containing a portion of the text in
214the current buffer. The beginning of a string is at index 0, but the 219the 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}
315needs a different number of bytes from the character already present at 320needs a different number of bytes from the character already present at
316that index, @code{aset} gets an error. 321that 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
326Since it is impossible to change the length of an existing string, it is 331Since it is impossible to change the length of an existing string, it is
327an error if @var{obj} doesn't fit within @var{string}'s actual length, 332an error if @var{obj} doesn't fit within @var{string}'s actual length,
328or if it requires a different number of bytes from the characters 333of if any new character requires a different number of bytes from the
329currently present at that point in @var{string}. 334character 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
365strings. When @code{equal} (@pxref{Equality Predicates}) compares two 370strings. When @code{equal} (@pxref{Equality Predicates}) compares two
366strings, it uses @code{string=}. 371strings, it uses @code{string=}.
367 372
368If the arguments contain non-@sc{ASCII} characters, and one is unibyte 373If the strings contain non-@sc{ASCII} characters, and one is unibyte
369while the other is multibyte, then they cannot be equal. @xref{Text 374while the other is multibyte, then they cannot be equal. @xref{Text
370Representations}. 375Representations}.
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
388Pairs of characters are compared by their @sc{ASCII} codes. Keep in 393Pairs of characters are compared according to their character codes.
389mind that lower case letters have higher numeric values in the 394Keep 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
391many punctuation characters have a lower numeric value than upper case 396many punctuation characters have a lower numeric value than upper case
392letters. A unibyte non-@sc{ASCII} character is always less than any 397letters. An @sc{ASCII} character is less than any non-@sc{ASCII}
398character; a unibyte non-@sc{ASCII} character is always less than any
393multibyte non-@sc{ASCII} character (@pxref{Text Representations}). 399multibyte 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. 462This function returns a new string containing one character,
457The value of @var{character}, modulo 256, is used to initialize the 463@var{character}. This function is semi-obsolete because the function
458element of the string. 464@code{string} is more general. @xref{Creating Strings}.
459
460This function is similar to @code{make-string} with an integer argument
461of 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
579in how they use the result of formatting. 571in 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 574This 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
584in the copy with encodings of the corresponding @var{objects}. The 576in the copy with encodings of the corresponding @var{objects}. The
585arguments @var{objects} are the computed values to be formatted. 577arguments @var{objects} are the computed values to be formatted.
@@ -619,7 +611,7 @@ meaningless.
619@item %s 611@item %s
620Replace the specification with the printed representation of the object, 612Replace the specification with the printed representation of the object,
621made without quoting (that is, using @code{princ}, not 613made 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
623by their contents alone, with no @samp{"} characters, and symbols appear 615by their contents alone, with no @samp{"} characters, and symbols appear
624without @samp{\} characters. 616without @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
751of the contents of strings. The functions convert only alphabetic 744of 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
824This function capitalizes the initials of the words in @var{string}.
825without altering any letters other than the initials. It returns a new
826string whose contents are a copy of @var{string-or-char}, in which each
827word has been converted to upper case.
828
829The definition of a word is any sequence of consecutive characters that
830are assigned to the word constituent syntax class in the current syntax
831table (@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
834table}. A case table specifies the mapping between upper case and lower 845table}. A case table specifies the mapping between upper case and lower
835case letters. It affects both the string and character case conversion 846case letters. It affects both the case conversion functions for Lisp
836functions (see the previous section) and those that apply to text in the 847objects (see the previous section) and those that apply to text in the
837buffer (@pxref{Case Changes}). 848buffer (@pxref{Case Changes}). Each buffer has a case table; there is
849also a standard case table which is used to initialize the case table
850of 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
840char-table maps each character into the corresponding lower case 853@code{case-table}. This char-table maps each character into the
841character It has three extra slots, which are related tables: 854corresponding lower case character. It has three extra slots, which
855hold 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
874equivalent characters.) 888equivalent 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
878and upper case mappings. You can also provide @code{nil} for 892and 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
881components are non-@code{nil}. Do not try to specify @var{equivalences} 895components are non-@code{nil}. Do not try to specify @var{equivalences}
882without also specifying @var{canonicalize}. 896without also specifying @var{canonicalize}.
883 897
884 Each buffer has a case table. Emacs also has a @dfn{standard case
885table} which is copied into each buffer when you create the buffer.
886Changing 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
896This function makes @var{table} the standard case table, so that it will 906This function makes @var{table} the standard case table, so that it will
897apply to any buffers created subsequently. 907be 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
913that define non-@sc{ASCII} character sets. They modify the specified 923that define non-@sc{ASCII} character sets. They modify the specified
914case table @var{case-table}; they also modify the standard syntax table. 924case 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
926the 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
918This function specifies a pair of corresponding letters, one upper case 929This 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
147symbol as a global variable. They are documented in detail in 147symbol 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
149be 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
151expression and storing it in the function cell of the symbol. This 152expression 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
229to result in good hashing; lengths one less than a power of two are also 230to result in good hashing; lengths one less than a power of two are also
230good. 231good.
231 232
232 It is possible for two different symbols to have the same name in
233different obarrays; these symbols are not @code{eq} or @code{equal}.
234However, 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
238not work---only @code{intern} can enter a symbol in an obarray properly. 234not 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
440symbol are stored in the same property list, so there is a possibility 436symbol are stored in the same property list, so there is a possibility
441of a conflict between different uses of a property name. (For this 437of a conflict between different uses of a property name. (For this
442reason, it is a good idea to choose property names that are probably 438reason, it is a good idea to choose property names that are probably
443unique, such as by including the name of the library in the property 439unique, such as by beginning the property name with the program's usual
444name.) An association list may be used like a stack where associations 440name-prefix for variables and functions.) An association list may be
445are pushed on the front of the list and later discarded; this is not 441used like a stack where associations are pushed on the front of the list
446possible with a property list. 442and 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
44this chapter. 44this 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
48a list that encodes the syntax of the character in question. 48index @var{c} describes the character with code @var{c}. The element's
49value should be a list that encodes the syntax of the character in
50question.
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
51Lisp reader. Emacs Lisp uses built-in syntactic rules when reading Lisp 53Lisp reader. Emacs Lisp uses built-in syntactic rules when reading Lisp
52expressions, and these rules cannot be changed. 54expressions, and these rules cannot be changed. (Some Lisp systems
55provide ways to redefine the read syntax, but we decided to leave this
56feature 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
55idea of the syntactic class of various characters. For example, in Lisp 59idea 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
81syntax of a character, and how they are represented as a @dfn{syntax 85syntax of a character, and how they are represented as a @dfn{syntax
82descriptor}, which is a Lisp string that you pass to 86descriptor}, 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
86puts each character into one class. There is no necessary relationship 90is no necessary relationship between the class of a character in one
87between the class of a character in one syntax table and its class in 91syntax table and its class in any other table.
88any 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
91name of the class when you need to specify a class. Usually the 94name of the class when you need to specify a class. Usually the
@@ -124,7 +127,8 @@ their meanings, and examples of their use.
124separate symbols and words from each other. Typically, whitespace 127separate symbols and words from each other. Typically, whitespace
125characters have no other syntactic significance, and multiple whitespace 128characters have no other syntactic significance, and multiple whitespace
126characters are syntactically equivalent to a single one. Space, tab, 129characters are syntactically equivalent to a single one. Space, tab,
127newline and formfeed are almost always classified as whitespace. 130newline and formfeed are classified as whitespace in almost all major
131modes.
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}.
384altering syntax tables. 388altering syntax tables.
385 389
386@defun make-syntax-table 390@defun make-syntax-table
387This function creates a new syntax table. Character codes 32 through 391This function creates a new syntax table. It inherits the syntax for
388127 are set up by copying the syntax from the standard syntax table. 392letters and control characters from the standard syntax table. For
389All other codes are set up to inherit from the standard syntax table. 393other characters, the syntax is copied from the standard syntax table.
390 394
391Most major mode syntax tables are created in this way. 395Most 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
487We 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
500the syntax table for specific character occurrences in the buffer. 507the syntax table for specific character occurrences in the buffer.
501@xref{Text Properties}. 508@xref{Text Properties}.
502 509
503The valid values of @code{syntax-table} text property are 510The 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
531certain syntax classes. None of these functions exists in Emacs 538have certain syntax classes.
532version 18 or earlier.
533 539
534@defun skip-syntax-forward syntaxes &optional limit 540@defun skip-syntax-forward syntaxes &optional limit
535This function moves point forward across characters having syntax classes 541This 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
598The fifth argument @var{state} is a nine-element list of the same form 604The fifth argument @var{state} is a nine-element list of the same form
599as the value of this function, described below. (It is ok to omit the 605as the value of this function, described below. (It is OK to omit the
600last element of the nine.) The return value of one call may be used to 606last element of the nine.) The return value of one call may be used to
601initialize the state of the parse on another call to 607initialize 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
759to each syntactic type. 765to 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
765whitespace 771@i{Integer} @i{Class}
766@item 1 772@tab
767punctuation 773@i{Integer} @i{Class}
768@item 2 774@item@tab
769word 7750 @ @ whitespace
770@item 3 776@tab
771symbol 7775 @ @ close parenthesis
772@item 4 778@tab
773open parenthesis 77910 @ @ character quote
774@item 5 780@item@tab
775close parenthesis 7811 @ @ punctuation
776@item 6 782@tab
777expression prefix 7836 @ @ expression prefix
778@item 7 784@tab
779string quote 78511 @ @ comment-start
780@item 8 786@item@tab
781paired delimiter 7872 @ @ word
782@item 9 788@tab
783escape 7897 @ @ string quote
784@item 10 790@tab
785character quote 79112 @ @ comment-end
786@item 11 792@item@tab
787comment-start 7933 @ @ symbol
788@item 12 794@tab
789comment-end 7958 @ @ paired delimiter
790@item 13 796@tab
791inherit 79713 @ @ inherit
792@item 14 798@item@tab
793comment-fence 7994 @ @ open parenthesis
794@item 15 800@tab
795string-fence 8019 @ @ escape
796@end table 802@tab
80314 @ @ comment-fence
804@item@tab
80515 @ 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
802least significant bit. This table gives the power of two which 812least significant bit. This table gives the power of two which
803corresponds to each syntax flag. 813corresponds 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
827syntactically. You can define a large number of categories, and then 841syntactically. You can define several categories as needed, then
828independently assign each character to one or more of them. Unlike 842independently assign each character to one or more categories. Unlike
829syntax classes, categories are not mutually exclusive; it is normal for 843syntax classes, categories are not mutually exclusive; it is normal for
830one character to belong to several categories. 844one 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
833are defined and also which characters belong to each category. Each 847are defined and also which characters belong to each category. Each
834category table defines its own categories. Each category has a name, 848category table defines its own categories, but normally these are
835which is an @sc{ASCII} printing character in the range @w{@samp{ }} to 849initialized by copying from the standard categories table, so that the
836@samp{~}. You specify the name of a category when you define it with 850standard 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
853the range @w{@samp{ }} to @samp{~}. You specify the name of a category
854when 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}).
840The element of the category table at index @var{c} is a @dfn{category 857The 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
867This function returns a category name (a character) which is not 884This function returns a category name (a character) which is not
868currently defined in @var{table}. If none is still available, it 885currently defined in @var{table}. If all possible categories are in use
869returns @code{nil}, 886in @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
83This function returns the character in the current buffer immediately
84before position @var{position}. If @var{position} is out of range for
85this purpose, either before the beginning of the buffer, or at or beyond
86the end, then the value is @code{nil}.
87@end defun
88
82@defun following-char 89@defun following-char
83This function returns the character following point in the current 90This function returns the character following point in the current
84buffer. This is similar to @code{(char-after (point))}. However, if 91buffer. 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
186This is like @code{buffer-substring}, except that it does not copy text 193This is like @code{buffer-substring}, except that it does not copy text
187properties, just the characters themselves. @xref{Text Properties}. 194properties, just the characters themselves. @xref{Text Properties}.
188Here's an example of using this function to get a word to look up in an
189alist:
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
198If this were written using @code{buffer-substring} instead, it would not
199work reliably; any text properties that happened to be in the word
200copied 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
286goes at point---between the character before point and the character 282goes at point---between the character before point and the character
287after point. 283after point. Some insertion functions leave point before the inserted
284text, while other functions leave it after. We call the former
285insertion @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
290insertion point, so that they stay with the surrounding text 288insertion 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,
292insertion normally doesn't relocate the marker, so that it points to the 290insertion may or may not relocate the marker, depending on the marker's
293beginning of the inserted text; however, certain special functions such 291insertion type (@pxref{Marker Insertion Types}). Certain special
294as @code{insert-before-markers} relocate such markers to point after the 292functions such as @code{insert-before-markers} relocate all such markers
295inserted text. 293to point after the inserted text, regardless of the markers' insertion
296 294type.
297@cindex insertion before point
298@cindex before point, insertion
299 Some insertion functions leave point before the inserted text, while
300other functions leave it after. We call the former insertion @dfn{after
301point} 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
304read-only. 297read-only.
@@ -329,11 +322,11 @@ inserted text falls outside the overlay; if a nonempty overlay ends at
329the insertion point, the inserted text falls inside that overlay. 322the 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
333This function inserts @var{count} instances of @var{character} into the 326This function inserts @var{count} instances of @var{character} into the
334current buffer before point. The argument @var{count} must be a number, 327current buffer before point. The argument @var{count} should be a
335and @var{character} must be a character. The value is @code{nil}. 328number (@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. 329The value is @code{nil}.
337 330
338If @var{inherit} is non-@code{nil}, then the inserted characters inherit 331If @var{inherit} is non-@code{nil}, then the inserted characters inherit
339sticky text properties from the two characters before and after the 332sticky text properties from the two characters before and after the
@@ -531,6 +524,16 @@ the kill ring.
531The value returned is always @code{nil}. 524The 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
529This option specifies how @code{backward-delete-char-untabify} should
530deal with whitespace. Possible values include @code{untabify}, the
531default, meaning convert a tab to many spaces and delete one;
532@code{hungry}, meaning delete all the whitespace characters before point
533with one command, and @code{nil}, meaning do nothing special for
534whitespace 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
672it so that the user can reinsert it by @dfn{yanking}. Most of these 675it so that the user can reinsert it by @dfn{yanking}. Most of these
673functions have @samp{kill-} in their name. By contrast, the functions 676functions have @samp{kill-} in their name. By contrast, the functions
674whose names start with @samp{delete-} normally do not save text for 677whose 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
832level, but still convenient for use in Lisp programs. They take care of 835lower level, but still convenient for use in Lisp programs, because they
833interaction with X Window selections. They do not exist in Emacs 836take care of interaction with window system selections
834version 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
837The function @code{current-kill} rotates the yanking pointer which 840The 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
873then that value is used as the ``most recent kill''. If it returns 876then 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
876The normal use of this hook is to get the X server's primary selection 879The normal use of this hook is to get the window system's primary
877as the most recent kill, even if the selection belongs to another X 880selection as the most recent kill, even if the selection belongs to
878client. @xref{X Selections}. 881another 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
886If the value is a function, @code{kill-new} and @code{kill-append} call 889If the value is a function, @code{kill-new} and @code{kill-append} call
887it with the new first element of the kill ring as an argument. 890it with the new first element of the kill ring as an argument.
888 891
889The normal use of this hook is to set the X server's primary selection 892The normal use of this hook is to set the window system's primary
890from the newly killed text. 893selection 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
928kill-ring kill-ring-yank-pointer 931kill-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.
1103This function returns @code{nil}. It cannot be called interactively. 1108This function returns @code{nil}. It cannot be called interactively.
1104 1109
1105The name @code{buffer-flush-undo} is not considered obsolete, but the 1110The name @code{buffer-flush-undo} is not considered obsolete, but the
1106preferred name @code{buffer-disable-undo} is new as of Emacs versions 1111preferred name is @code{buffer-disable-undo}.
110719.
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
1153can be @code{left}, @code{right}, @code{full}, or @code{center}, to 1157can be @code{left}, @code{right}, @code{full}, or @code{center}, to
1154request a specific style of justification. If it is @code{t}, that 1158request a specific style of justification. If it is @code{t}, that
1155means to use the current justification style for this part of the text 1159means 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
1161as @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
1159argument implies the value @code{full} for @var{justify}. 1164argument implies the value @code{full} for @var{justify}.
@@ -1358,10 +1363,19 @@ whitespace.
1358 1363
1359@defvar left-margin 1364@defvar left-margin
1360This variable specifies the base left margin column. In Fundamental 1365This variable specifies the base left margin column. In Fundamental
1361mode, @key{LFD} indents to this column. This variable automatically 1366mode, @kbd{C-j} indents to this column. This variable automatically
1362becomes buffer-local when set in any fashion. 1367becomes 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
1372This variable gives major modes a way to specify not to break a line at
1373certain places. Its value should be a function. This function is
1374called during filling, with no arguments and with point located at the
1375place where a break is being considered. If the function returns
1376non-@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
1396This variable specifies the function to use for 1410This 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
1398modes can set this locally to alter how Auto Fill works. 1412modes can set buffer-local values for this variable to alter how Auto
1413Fill 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
1631Note that @code{sort-columns} uses the @code{sort} utility program, 1643Note that @code{sort-columns} uses the @code{sort} utility program,
1632and so cannot work properly on text containing tab characters. Use 1644and 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
1717insert indentation. The functions in the following sections use these 1729insert indentation. The functions in the following sections use these
1718primitives. 1730primitives. @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
1746If this variable is non-@code{nil}, indentation functions can insert 1758If this variable is non-@code{nil}, indentation functions can insert
1747tabs as well as spaces. Otherwise, they insert only spaces. Setting 1759tabs as well as spaces. Otherwise, they insert only spaces. Setting
1748this variable automatically makes it local to the current buffer. 1760this 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
2015buffer. @xref{Character Case}, for case conversion commands that work 2027buffer. @xref{Case Conversion}, for case conversion functions that work
2016on strings and characters. @xref{Case Table}, for how to customize 2028on strings and characters. @xref{Case Tables}, for how to customize
2017which characters are upper or lower case and how to convert them. 2029which 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
2420meanings. The following section lists a few more special property names 2432meanings. The following sections list a few additional special property
2421that are used to control filling. All other names have no standard 2433names that control filling and property inheritance. All other names
2422meaning, and you can use them as you like. 2434have 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
2958marker, a string, a rectangle, a window configuration (of one frame), or 2970variety of different kinds of values. Each register is named by a
2959a frame configuration (of all frames). Each register is named by a 2971single character. All ASCII characters and their meta variants (but
2960single character. All characters, including control and meta characters 2972with 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. 2973there are 255 possible registers. A register is designated in Emacs
2962Thus, there are 255 possible registers. A register is designated in 2974Lisp by the character that is its name.
2963Emacs Lisp by a character that is its name.
2964
2965 The functions in this section return unpredictable values unless
2966otherwise stated.
2967 2975
2968@defvar register-alist 2976@defvar register-alist
2969This variable is an alist of elements of the form @code{(@var{name} . 2977This 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} .
2971register that has been used. 2979register that has been used.
2972 2980
2973The object @var{name} is a character (an integer) identifying the 2981The object @var{name} is a character (an integer) identifying the
2974register. The object @var{contents} is a string, marker, window 2982register.
2975configuration, frame configuration, or list representing the register
2976contents. A string represents text stored in the register. A marker
2977represents a position. A list represents a rectangle; its elements are
2978strings, 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
2989A number stands for itself. If @code{insert-register} finds a number
2990in the register, it converts the number to decimal.
2991
2992@item a marker
2993A marker represents a buffer position to jump to.
2994
2995@item a string
2996A string is text saved in the register.
2997
2998@item a rectangle
2999A rectangle is represented by a list of strings.
3000
3001@item @code{(@var{window-configuration} @var{position})}
3002This represents a window configuration to restore in one frame, and a
3003position to jump to in the current buffer.
3004
3005@item @code{(@var{frame-configuration} @var{position})}
3006This represents a frame configuration to restore, and a position
3007to jump to in the current buffer.
3008
3009@item (file @var{filename})
3010This represents a file to visit; jumping to this value visits file
3011@var{filename}.
3012
3013@item (file-query @var{filename} @var{position})
3014This represents a file to visit and a position in it; jumping to this
3015value visits file @var{filename} and goes to buffer position
3016@var{position}. Restoring this type of position asks the user for
3017confirmation first.
3018@end table
3019
3020 The functions in this section return unpredictable values unless
3021otherwise stated.
3022
2981@defun get-register reg 3023@defun get-register reg
2982This function returns the contents of the register 3024This 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.
3136If a program makes several text changes in the same area of the buffer, 3178If a program makes several text changes in the same area of the buffer,
3137using the macro @code{combine-after-change-calls} around that part of 3179using the macro @code{combine-after-change-calls} around that part of
3138the program can make it run considerably faster when after-change hooks 3180the program can make it run considerably faster when after-change hooks
3139are in use. 3181are in use. When the after-change hooks are ultimately called, the
3182arguments specify a portion of the buffer including all of the changes
3183made 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
3143the body of a @code{combine-after-change-calls} form. 3187the body of a @code{combine-after-change-calls} form.
3188
3189@strong{Note:} If the changes you combine occur in widely scattered
3190parts of the buffer, this will still work, but it is not advisable,
3191because it may lead to inefficient behavior for some change hook
3192functions.
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
37prefix. This helps avoid name conflicts. 37prefix. This helps avoid name conflicts.
38 38
39This recommendation applies even to names for traditional Lisp 39This recommendation applies even to names for traditional Lisp
40primitives that are not primitives in Emacs Lisp---even to @code{cadr}. 40primitives that are not primitives in Emacs Lisp---even to
41Believe 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 42way to define @code{copy-list}. Play it safe; append your name prefix
43like @code{foo-cadr} or @code{mylib-cadr} instead. 43to produce a name like @code{foo-copy-list} or @code{mylib-copy-list}
44instead.
44 45
45If you write a function that you think ought to be added to Emacs under 46If you write a function that you think ought to be added to Emacs under
46a certain name, such as @code{twiddle-files}, don't call it by that name 47a 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 80to make the @code{require} work.) This will cause @var{bar} to be
80byte-compile @var{foo}. Otherwise, you risk compiling @var{foo} without 81loaded when you byte-compile @var{foo}. Otherwise, you risk compiling
81the necessary macro loaded, and that would produce compiled code that 82@var{foo} without the necessary macro loaded, and that would produce
82won't work right. @xref{Compiling Macros}. 83compiled code that won't work right. @xref{Compiling Macros}.
83 84
84Using @code{eval-when-compile} avoids loading @var{bar} when 85Using @code{eval-when-compile} avoids loading @var{bar} when
85the compiled version of @var{foo} is @emph{used}. 86the compiled version of @var{foo} is @emph{used}.
@@ -111,9 +112,9 @@ Instead, define sequences consisting of @kbd{C-c} followed by a control
111character, a digit, or certain punctuation characters. These sequences 112character, a digit, or certain punctuation characters. These sequences
112are reserved for major modes. 113are reserved for major modes.
113 114
114Changing all the major modes in Emacs 18 so they would follow this 115Changing all the Emacs major modes to follow this convention was a lot
115convention was a lot of work. Abandoning this convention would make 116of work. Abandoning this convention would make that work go to waste,
116that work go to waste, and inconvenience users. 117and inconvenience users.
117 118
118@item 119@item
119Sequences consisting of @kbd{C-c} followed by @kbd{@{}, @kbd{@}}, 120Sequences 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
138Do not bind a key sequence ending in @key{ESC} except following 139Do not bind a key sequence ending in @key{ESC} except following
139another @key{ESC}. (That is, it is ok to bind a sequence ending in 140another @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
142The reason for this rule is that a non-prefix binding for @key{ESC} in 143The 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}.
251In some other systems there is a convention of choosing variable names 252In some other systems there is a convention of choosing variable names
252that begin and end with @samp{*}. We don't use that convention in Emacs 253that begin and end with @samp{*}. We don't use that convention in Emacs
253Lisp, so please don't use it in your programs. (Emacs uses such names 254Lisp, so please don't use it in your programs. (Emacs uses such names
254only for program-generated buffers.) The users will find Emacs more 255only for special-purpose buffers.) The users will find Emacs more
255coherent if all libraries use the same conventions. 256coherent if all libraries use the same conventions.
256 257
257@item 258@item
@@ -273,7 +274,7 @@ default indentation parameters.
273Don't make a habit of putting close-parentheses on lines by themselves; 274Don't make a habit of putting close-parentheses on lines by themselves;
274Lisp programmers find this disconcerting. Once in a while, when there 275Lisp programmers find this disconcerting. Once in a while, when there
275is a sequence of many consecutive close-parentheses, it may make sense 276is a sequence of many consecutive close-parentheses, it may make sense
276to split them in one or two significant places. 277to split the sequence in one or two significant places.
277 278
278@item 279@item
279Please put a copyright notice on the file if you give copies to anyone. 280Please 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
373strings. 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.
471When a documentation string refers to a Lisp symbol, write it as it 476When a documentation string refers to a Lisp symbol, write it as it
472would be printed (which usually means in lower case), with single-quotes 477would be printed (which usually means in lower case), with single-quotes
473around it. For example: @samp{lambda}. There are two exceptions: write 478around it. For example: @samp{lambda}. There are two exceptions: write
474t and nil without single-quotes. (In this manual, we normally do use 479t and nil without single-quotes. (In this manual, we use a different
475single-quotes for those symbols.) 480convention, with single-quotes for all symbols.)
476@end ifinfo 481@end ifinfo
477 482
483For example:
484
485@example
486The value of `swim-speed' specifies how fast to swim.
487Possible values are t for high speed, nil for low speed,
488and `medium' for medium speed.
489@end example
490
478@item 491@item
479Don't write key sequences directly in documentation strings. Instead, 492Don't write key sequences directly in documentation strings. Instead,
480use the @samp{\\[@dots{}]} construct to stand for them. For example, 493use 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
544Every function that has no documentation string (because it is use only 557Every function that has no documentation string (presumably one that is
545internally within the package it belongs to), should have instead a 558used only internally within the package it belongs to), should have
546two-semicolon comment right before the function, explaining what the 559instead a two-semicolon comment right before the function, explaining
547function does and how to call it properly. Explain precisely what each 560what the function does and how to call it properly. Explain precisely
548argument means and how the function interprets its possible values. 561what each argument means and how the function interprets its possible
562values.
549 563
550@item ;;; 564@item ;;;
551Comments that start with three semicolons, @samp{;;;}, should start at 565Comments that start with three semicolons, @samp{;;;}, should start at
@@ -584,7 +598,7 @@ program. For example:
584 598
585@noindent 599@noindent
586The indentation commands of the Lisp modes in Emacs, such as @kbd{M-;} 600The 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}),
588automatically indent comments according to these conventions, 602automatically indent comments according to these conventions,
589depending on the number of semicolons. @xref{Comments,, 603depending on the number of semicolons. @xref{Comments,,
590Manipulating Comments, emacs, The GNU Emacs Manual}. 604Manipulating 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
74assuming the @code{setq} form shown above has already been executed. 76assuming 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
79one:
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
100These include @code{nil} and @code{t}, as well as any symbol whose 103include @code{nil} and @code{t}, as well as any symbol whose name starts
101name starts with @samp{:}. 104with @samp{:}. These symbols cannot be rebound, nor can their values be
102 105changed. 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
104themselves. These symbols cannot be rebound, nor can their values be 107starts with @samp{:}, except that you are allowed to set such symbol to
105changed. Any attempt to change the value of @code{nil} or @code{t} 108itself.
106signals 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
123If this variable is @code{nil}, you are allowed to set and bind symbols
124whose names start with @samp{:} as you wish. This is to make it
125possible 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
127with new values. Sometimes it is useful to create variable values that 136with new values. Sometimes it is useful to create variable values that
128exist temporarily---only while within a certain part of the program. 137exist temporarily---only until a certain part of the program finishes.
129These values are called @dfn{local}, and the variables so used are 138These values are called @dfn{local}, and the variables so used are
130called @dfn{local variables}. 139called @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,
145this replaces the local value; it does not alter the global value, or 154this replaces the local value; it does not alter the global value, or
146previous local values that are shadowed. To model this behavior, we 155previous local values, that are shadowed. To model this behavior, we
147speak of a @dfn{local binding} of the variable as well as a local value. 156speak 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
162example, if there are nested @code{let} forms that bind it). In such a 171example, if there are nested @code{let} forms that bind it). In such a
163case, the most recently created local binding that still exists is the 172case, 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
165scoping}; see @ref{Variable Scoping}.) If there are no local bindings, 174@dfn{dynamic scoping}; see @ref{Variable Scoping}.) If there are no
166the variable's global binding is its current binding. We also call the 175local bindings, the variable's global binding is its current binding.
167current binding the @dfn{most-local existing binding}, for emphasis. 176We sometimes call the current binding the @dfn{most-local existing
168Ordinary evaluation of a symbol always returns the value of its current 177binding}, for emphasis. Ordinary evaluation of a symbol always returns
169binding. 178the 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
172local bindings. 181local 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
304local binding, since all the constructs that create local bindings 312local binding, since all the constructs that create local bindings
305create them with values. In this case, the voidness lasts at most as 313create them with values. In this case, the voidness lasts at most as
306long as the binding does; when the binding is removed due to exit from 314long as the binding does; when the binding is removed due to exit from
307the construct that made it, the previous or global binding is reexposed 315the construct that made it, the previous local or global binding is
308as usual, and the variable is no longer void unless the newly reexposed 316reexposed as usual, and the variable is no longer void unless the newly
309binding was void all along. 317reexposed 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
440If the first character of @var{doc-string} is @samp{*}, it means that 448If the first character of @var{doc-string} is @samp{*}, it means that
441this variable is considered a user option. This lets users set the 449this variable is considered a user option. This lets users set the
442variable conventiently using the commands @code{set-variable} and 450variable 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}
444instead of @code{defvar}, for user option variables, to specify 452instead of @code{defvar} for user option variables, so you can specify
445customization information. @xref{Customization}. 453customization information. @xref{Customization}.
446 454
447Here are some examples. This form defines @code{foo} but does not 455Here 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
581This method has several benefits. First, if the user quits while 589This method has several benefits. First, if the user quits while
582loading the file, the variable is either still uninitialized or 590loading the file, the variable is either still uninitialized or
583initialized properly, never in-between. If it is uninitialized, 591initialized properly, never in-between. If it is still uninitialized,
584reloading the file will initialize it properly. Second, reloading the 592reloading the file will initialize it properly. Second, reloading the
585file once the variable is initialized will not alter it; that is 593file once the variable is initialized will not alter it; that is
586important if the user has run hooks to alter part of the contents (such 594important 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
623This code sets the variable, then alters it, but only if the variable 631This code sets the variable, then alters it, but it does so in more than
624had been @code{ni}. If the user quits just after the @code{setq}, that 632one step. If the user quits just after the @code{setq}, that leaves the
625leaves the variable neither correctly initialized nor void nor 633variable neither correctly initialized nor void nor @code{nil}. Once
626@code{nil}. Once that happens, reloading the file will not initialize 634that happens, reloading the file will not initialize the variable; it
627the variable; it will remain incomplete. 635will 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
676A @code{void-variable} error is signaled if @var{symbol} has neither a 684A @code{void-variable} error is signaled if the current binding of
677local 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.
803The argument @var{symbol} is not implicitly quoted; @code{add-to-list} 811The argument @var{symbol} is not implicitly quoted; @code{add-to-list}
804is an ordinary function, like @code{set} and unlike @code{setq}. Quote 812is an ordinary function, like @code{set} and unlike @code{setq}. Quote
805the argument yourself if that is what you want. 813the argument yourself if that is what you want.
814@end defun
806 815
807Here's a scenario showing how to use @code{add-to-list}: 816Here'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}:
819foo ;; @r{@code{foo} was changed.} 828foo ;; @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.
979works) may help you understand dynamic binding. This technique is 987works) may help you understand dynamic binding. This technique is
980called @dfn{deep binding} and was used in early Lisp systems. 988called @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.
983to a function or to a @code{let} form, we can push bindings onto the stack 991At entry to a function or to a @code{let} form, we can push bindings
984for the arguments or local variables created there. We can pop those 992onto the stack for the arguments or local variables created there. We
985bindings from the stack at exit from the binding construct. 993can pop those bindings from the stack at exit from the binding
994construct.
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
988bottom for a binding for that variable; the value from that binding is 997bottom 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
1055languages in one form or another. Emacs also supports another, unusual 1064languages in one form or another. Emacs also supports additional,
1056kind of variable binding: @dfn{buffer-local} bindings, which apply only 1065unusual kinds of variable binding: @dfn{buffer-local} bindings, which
1057to one buffer. Emacs Lisp is meant for programming editing commands, 1066apply only in one buffer, and frame-local bindings, which apply only in
1058and having different values for a variable in different buffers is an 1067one frame. Having different values for a variable in different buffers
1059important customization method. (A few variables have bindings that 1068and/or frames is an important customization method.
1060are local to a given X terminal; see @ref{Multiple Displays}.) 1069
1070 This section describes buffer-local bindings; for frame-local
1071bindings, see the following section, @ref{Frame-Local Variables}. (A few
1072variables 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
1084other buffers. The default binding is shared by all the buffers that 1097other buffers. The default binding is shared by all the buffers that
1085don't have their own bindings for the variable. If you set the variable 1098don't have their own bindings for the variable. (This includes all
1086in a buffer that does not have a buffer-local binding for it, this sets 1099newly created buffers.) If you set the variable in a buffer that does
1087the default binding, so the new value is visible in all the buffers that 1100not have a buffer-local binding for it, this sets the default binding
1088see the default binding. 1101(assuming there are no frame-local bindings to complicate the matter),
1102so the new value is visible in all the buffers that see the default
1103binding.
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
1091variables that control the behavior of commands. For example, C mode and 1106variables that control the behavior of commands. For example, C mode and
1092Lisp mode both set the variable @code{paragraph-start} to specify that only 1107Lisp mode both set the variable @code{paragraph-start} to specify that only
1093blank lines separate paragraphs. They do this by making the variable 1108blank lines separate paragraphs. They do this by making the variable
1094buffer-local in the buffer that is being put into C mode or Lisp mode, and 1109buffer-local in the buffer that is being put into C mode or Lisp mode, and
1095then setting it to the new value for that mode. 1110then 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
1099affects just the current buffer; all other buffers (including those yet to 1114use. This affects just the current buffer; all other buffers (including
1100be created) continue to share the default value. 1115those yet to be created) will continue to share the default value unless
1116they 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
1107precisely, the effect is that setting the variable automatically makes 1123precisely, the effect is that setting the variable automatically makes
1108the variable local to the current buffer if it is not already so. All 1124the variable local to the current buffer if it is not already so. All
1109buffers start out by sharing the default value of the variable as usual, 1125buffers start out by sharing the default value of the variable as usual,
1110but any @code{setq} creates a buffer-local binding for the current 1126but setting the variable creates a buffer-local binding for the current
1111buffer. The new value is stored in the buffer-local binding, leaving 1127buffer. The new value is stored in the buffer-local binding, leaving
1112the default binding untouched. The default value can no longer be 1128the default binding untouched. This means that the default value cannot
1113changed with @code{setq} in this buffer; you need to use 1129be changed with @code{setq} in any buffer; the only way to change it is
1114@code{setq-default} to do that. 1130with @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
1117more buffers, you can get Emacs very confused by binding the variable 1133more 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:
1161buffer-local binding of buffer @samp{b}. 1177buffer-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
1164values when you visit the file. @xref{Auto Major Mode}. 1180values when you visit the file. @xref{File Variables,,, emacs, The
1181GNU 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
1211Making a variable buffer-local within a @code{let}-binding for that 1228Making a variable buffer-local within a @code{let}-binding for that
1212variable does not work. This is because @code{let} does not distinguish 1229variable does not work reliably, unless the buffer in which you do this
1213between different kinds of bindings; it knows only which variable the 1230is not current either on entry to or exit from the @code{let}. This is
1214binding was made for. 1231because @code{let} does not distinguish between different kinds of
1232bindings; it knows only which variable the binding was made for.
1215 1233
1216If the variable is terminal-local, this function signals an error. Such 1234If the variable is terminal-local, this function signals an error. Such
1217variables cannot have buffer-local bindings as well. @xref{Multiple 1235variables cannot have buffer-local bindings as well. @xref{Multiple
@@ -1226,16 +1244,24 @@ This function marks @var{variable} (a symbol) automatically
1226buffer-local, so that any subsequent attempt to set it will make it 1244buffer-local, so that any subsequent attempt to set it will make it
1227local to the current buffer at the time. 1245local to the current buffer at the time.
1228 1246
1229The value returned is @var{variable}. 1247A peculiar wrinkle of this feature is that binding the variable (with
1248@code{let} or other binding constructs) does not create a buffer-local
1249binding 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} 1252The value returned is @var{variable}.
1232for user-option variables, simply because users @emph{might} want to
1233customize them differently in different buffers. Users can make any
1234variable local, when they wish to.
1235 1253
1236The main use of @code{make-variable-buffer-local} is when a variable is 1254@strong{Warning:} Don't assume that you should use
1237used for internal purposes, and the Lisp program depends on having 1255@code{make-variable-buffer-local} for user-option variables, simply
1238separate values in separate buffers. 1256because users @emph{might} want to customize them differently in
1257different buffers. Users can make any variable local, when they wish
1258to. It is better to leave the choice to them.
1259
1260The time to use @code{make-variable-buffer-local} is when it is crucial
1261that no two buffers ever share the same binding. For example, when a
1262variable is used for internal purposes in a Lisp program which depends
1263on 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
1248This function returns a list describing the buffer-local variables in 1274This function returns a list describing the buffer-local variables in
1249buffer @var{buffer}. It returns an association list (@pxref{Association 1275buffer @var{buffer}. (If @var{buffer} is omitted, the current buffer is
1250Lists}) in which each association contains one buffer-local variable and 1276used.) It returns an association list (@pxref{Association Lists}) in
1251its value. When a buffer-local variable is void in @var{buffer}, then 1277which each element contains one buffer-local variable and its value.
1252it appears directly in the resulting list. If @var{buffer} is omitted, 1278However, when a variable's buffer-local binding in @var{buffer} is void,
1253the current buffer is used. 1279then 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
1309of @code{fundamental-mode-abbrev-table}. 1335of @code{fundamental-mode-abbrev-table}.
1310 1336
1311The very first thing this function does is run the normal hook 1337The 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
1314Every major mode command begins by calling this function, which has the 1340Every major mode command begins by calling this function, which has the
1315effect of switching to Fundamental mode and erasing most of the effects 1341effect 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
1349The function @code{kill-all-local-variables} runs this normal hook
1350before it does anything else. This gives major modes a way to arrange
1351for something special to be done if the user switches to a different
1352major mode. For best results, make this variable buffer-local, so that
1353it will disappear after doing its job and will not interfere with the
1354subsequent 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
1324A buffer-local variable is @dfn{permanent} if the variable name (a 1359A 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
1334called the @dfn{default} value, because it is the value that is in 1369called the @dfn{default} value, because it is the value that is in
1335effect except when specifically overridden. 1370effect whenever neither the current buffer nor the selected frame has
1371its 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
1338change a variable's default value regardless of whether the current 1374change 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
1347default value (if they set the variable at all), rather than any 1383default value (if they set the variable at all), rather than any
1348buffer-local value. 1384buffer-local or frame-local value.
1349 1385
1350@defun default-value symbol 1386@defun default-value symbol
1351This function returns @var{symbol}'s default value. This is the value 1387This function returns @var{symbol}'s default value. This is the value
1352that is seen in buffers that do not have their own values for this 1388that is seen in buffers and frames that do not have their own values for
1353variable. If @var{symbol} is not buffer-local, this is equivalent to 1389this variable. If @var{symbol} is not buffer-local, this is equivalent
1354@code{symbol-value} (@pxref{Accessing Variables}). 1390to @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
1394local 1430buffer-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}:}
1404local 1440buffer-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}:}
1422local 1458buffer-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
1486frame-local bindings. These bindings belong to one frame, and are in
1487effect when that frame is selected. Frame-local bindings are actually
1488frame parameters: you create a frame-local binding in a specific frame
1489by calling @code{modify-frame-parameters} and specifying the variable
1490name 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
1496Enable the use of frame-local bindings for @var{variable}. This does
1497not in itself create any frame-local bindings for the variable; however,
1498if some frame already has a value for @var{variable} as a frame
1499parameter, that value automatically becomes a frame-local binding.
1500
1501If the variable is terminal-local, this function signals an error. Such
1502variables cannot have buffer-local bindings as well. @xref{Multiple
1503Displays}. A few variables that are implemented specially in Emacs
1504can 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,
1508consider a variable @code{foo}: if the current buffer has a buffer-local
1509binding for @code{foo}, that binding is active; otherwise, if the
1510selected frame has a frame-local binding for @code{foo}, that binding is
1511active; 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
1531buffer @samp{b1} is current, its buffer-local binding is in effect,
1532regardless of the selected frame:
1533
1534@example
1535(select-frame f1)
1536(set-buffer (get-buffer-create "b1"))
1537foo
1538 @result{} (b 1)
1539
1540(select-frame f2)
1541(set-buffer (get-buffer-create "b1"))
1542foo
1543 @result{} (b 1)
1544@end example
1545
1546@noindent
1547Otherwise, 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*"))
1553foo
1554 @result{} (f 2)
1555@end example
1556
1557@noindent
1558When neither the current buffer nor the selected frame provides
1559a binding, the default binding is used:
1560
1561@example
1562(select-frame f1)
1563(set-buffer (get-buffer "*scratch*"))
1564foo
1565 @result{} nil
1566@end example
1567
1568@noindent
1569When the active binding of a variable is a frame-local binding, setting
1570the 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
1585of frames---for example, all color frames, or all frames with dark
1586backgrounds. We have not implemented them because it is not clear that
1587this feature is really useful. You can get more or less the same
1588results by adding a function to @code{after-make-frame-hook}, set up to
1589define a particular frame parameter according to the appropriate
1590conditions for each frame.
1591
1592 It would also be possible to implement window-local bindings. We
1593don't know of many situations where they would be useful, and it seems
1594that indirect buffers (@pxref{Indirect Buffers}) with buffer-local
1595bindings offer a way to handle these situations more robustly.
1596
1597 If sufficient application is found for either of these two kinds of
1598local 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
248Normally, Emacs indicates the border between two side-by-side windows 248Normally, Emacs indicates the border between two side-by-side windows
249with a scroll bar (@pxref{X Frame Parameters,Scroll Bars}) or @samp{|} 249with a scroll bar (@pxref{Window Frame Parameters,Scroll Bars}) or @samp{|}
250characters. The display table can specify alternative border 250characters. The display table can specify alternative border
251characters; see @ref{Display Tables}. 251characters; see @ref{Display Tables}.
252@end deffn 252@end deffn
@@ -328,8 +328,7 @@ of a window aside from restoring a saved window configuration
328deletes any windows that aren't part of that configuration. 328deletes 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
331adjacent sibling. (In Emacs version 18, the space was divided evenly 331adjacent sibling.
332among 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
344This function removes @var{window} from the display. If @var{window} 343This function removes @var{window} from display, and returns @code{nil}.
345is omitted, then the selected window is deleted. An error is signaled 344If @var{window} is omitted, then the selected window is deleted. An
346if there is only one window when @code{delete-window} is called. 345error is signaled if there is only one window when @code{delete-window}
347 346is called.
348This function returns @code{nil}.
349
350When @code{delete-window} is called interactively, @var{window}
351defaults 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
356deleting the other windows in that frame. If @var{window} is omitted or 351deleting 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
359The result is @code{nil}. 354The 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,
426the change persists. 421the change persists.
427 422
428Each frame, at any time, has a window selected within the frame. This 423Each frame, at any time, has a window selected within the frame. This
429macro only saves @emph{the} selected window; it does not save anything 424macro saves only @emph{the} selected window; it does not save anything
430about other frames. If the @var{forms} select some other frame and 425about other frames. If the @var{forms} select some other frame and
431alter the window selected within it, the change persists. 426alter 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
567This function selects the @var{count}th following window in the cyclic 562This function selects the @var{count}th following window in the cyclic
568order. If count is negative, then it selects the @minus{}@var{count}th 563order. If count is negative, then it moves back @minus{}@var{count}
569preceding window. It returns @code{nil}. 564windows in the cycle, rather than forward. It returns @code{nil}.
570 565
571In an interactive call, @var{count} is the numeric prefix argument. 566In 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
696current so that a Lisp program can access or modify it; they are too 691current so that a Lisp program can access or modify it; they are too
697drastic for that purpose, since they change the display of buffers in 692drastic for that purpose, since they change the display of buffers in
698windows, which is gratuitous and will surprise the user. Instead, use 693windows, 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
701access without affecting the display of buffers in windows. 696access 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
713set according to the variable @code{default-major-mode}. @xref{Auto 708set according to the variable @code{default-major-mode}. @xref{Auto
714Major Mode}. 709Major Mode}.
715 710
716Normally the specified buffer is put at the front of the buffer list. 711Normally the specified buffer is put at the front of the buffer list
717This affects the operation of @code{other-buffer}. However, if 712(both the selected frame's buffer list and the frame-independent buffer
713list). 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
719List}. 715List}.
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
795This variable is always local in each buffer. When the buffer is 791This variable is always buffer-local in each buffer. When the buffer is
796created, @code{buffer-display-count} has value 0. Each time the buffer 792created, @code{buffer-display-count} has value 0. Each time the buffer
797is displayed in a window, that increments the value of 793is 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
967A window can be marked as ``dedicated'' to its buffer. Then 963A 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
965other buffer.
969 966
970@defun window-dedicated-p window 967@defun window-dedicated-p window
971This function returns @code{t} if @var{window} is marked as dedicated; 968This 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
1069description of @code{count-lines} in @ref{Text Lines}. 1066description 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
1073This function returns the position of the end of the display in window 1070This 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
1075used. 1072used.
1076 1073
1077Simply changing the buffer text or moving point does not update the 1074Simply changing the buffer text or moving point does not update the
1078value that @code{window-end} returns. The value is updated only when 1075value that @code{window-end} returns. The value is updated only when
1079Emacs redisplays and redisplay actually finishes. 1076Emacs redisplays and redisplay completes without being preempted.
1080 1077
1081If the last redisplay of @var{window} was preempted, and did not finish, 1078If the last redisplay of @var{window} was preempted, and did not finish,
1082Emacs does not know the position of the end of display in that window. 1079Emacs does not know the position of the end of display in that window.
1083In that case, this function returns a value that is not correct. In a 1080In that case, this function returns @code{nil}.
1084future version, @code{window-end} will return @code{nil} in that case.
1085@ignore
1086in that case, this function returns @code{nil}. You can compute where
1087the end of the window @emph{would} have been, if redisplay had finished,
1088like this:
1089 1081
1090@example 1082If you @var{update} is non-@code{nil}, @code{window-end} always returns
1091(save-excursion 1083an up-to-date value for where the window ends. If the saved value is
1092 (goto-char (window-start window)) 1084valid, @code{window-end} returns that; otherwise it computes the correct
1093 (vertical-motion (1- (window-height window)) 1085value 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
1431This function returns the number of lines in @var{window}, including 1419This function returns the number of lines in @var{window}, including its
1432its mode line. If @var{window} fills its entire frame, this is one less 1420mode line. If @var{window} fills its entire frame, this is typically
1433than the value of @code{frame-height} on that frame (since the last line 1421one less than the value of @code{frame-height} on that frame (since the
1434is always reserved for the minibuffer). 1422last line is always reserved for the minibuffer).
1435 1423
1436If @var{window} is @code{nil}, the function uses the selected window. 1424If @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.
1654This function checks whether a particular frame position falls within 1642This function checks whether a particular frame position falls within
1655the window @var{window}. 1643the window @var{window}.
1656 1644
1657@need 3000 1645The argument @var{coordinates} is a cons cell of the form @code{(@var{x}
1658The argument @var{coordinates} is a cons cell of this form: 1646. @var{y})}. The coordinates @var{x} and @var{y} are measured in
1659 1647characters, 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
1665The coordinates @var{x} and @var{y} are measured in characters, and
1666count from the top left corner of the screen or frame.
1667 1648
1668The value returned by @code{coordinates-in-window-p} is non-@code{nil} 1649The value returned by @code{coordinates-in-window-p} is non-@code{nil}
1669if the coordinates are inside @var{window}. The value also indicates 1650if 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
1713current window configuration, including the number of windows, their 1694current window configuration, including the number of windows, their
1714sizes and current buffers, which window is the selected window, and for 1695sizes and current buffers, which window is the selected window, and for
1715each window the displayed buffer, the display-start position, and the 1696each window the displayed buffer, the display-start position, and the
1716positions of point and the mark. An exception is made for point in the 1697positions 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
1717current buffer, whose value is not saved. 1700current 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.
1721This function restores the configuration of windows and buffers as 1704This function restores the configuration of windows and buffers as
1722specified by @var{configuration}. The argument @var{configuration} must 1705specified by @var{configuration}. The argument @var{configuration} must
1723be a value that was previously returned by 1706be 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
1725frame for which @var{configuration} was made, whether that frame is 1708the frame from which @var{configuration} was made, whether that frame is
1726selected or not. 1709selected or not. This always counts as a window size change and
1727 1710triggers execution of the @code{window-size-change-functions}
1728This function always counts as a window size change and triggers 1711(@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
1729execution of the @code{window-size-change-functions}. (It doesn't know 1712know how to tell whether the new configuration actually differs from the
1730how to tell whether the new configuration actually differs from the old 1713old one.
1731one.) 1714
1715If the frame which @var{configuration} was saved from is dead, all this
1716function does is restore the three variables @code{window-min-height},
1717@code{window-min-width} and @code{minibuffer-scroll-window}.
1732 1718
1733Here is a way of using this function to get the same effect 1719Here is a way of using this function to get the same effect
1734as @code{save-window-excursion}: 1720as @code{save-window-excursion}:
@@ -1786,6 +1772,17 @@ For example:
1786This function returns @code{t} if @var{object} is a window configuration. 1772This 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
1776This function compares two window configurations as regards the
1777structure of windows, but ignores the values of point and mark and the
1778saved scrolling positions---it can return @code{t} even if those
1779aspects differ.
1780
1781The function @code{equal} can also compare two window configurations; it
1782regards configurations as unequal if they differ in any respect, even a
1783saved 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,
1790but none are implemented. It is not clear they are useful enough to be 1787but none are implemented. It is not clear they are useful enough to be
1791worth implementing. 1788worth implementing.
@@ -1799,8 +1796,8 @@ There are three actions that can change this: scrolling the window,
1799switching buffers in the window, and changing the size of the window. 1796switching buffers in the window, and changing the size of the window.
1800The first two actions run @code{window-scroll-functions}; the last runs 1797The 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
1802hooks is Lazy Lock mode; see @ref{Support Modes, Lazy Lock, Font Lock 1799hooks is in the implementation of Lazy Lock mode; see @ref{Support
1803Support Modes, emacs, The GNU Emacs Manual}. 1800Modes, Lazy Lock, Font Lock Support Modes, emacs, The GNU Emacs Manual}.
1804 1801
1805@defvar window-scroll-functions 1802@defvar window-scroll-functions
1806This variable holds a list of functions that Emacs should call before 1803This variable holds a list of functions that Emacs should call before