comparison lispref/text.texi @ 21682:90da2489c498

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Mon, 20 Apr 1998 17:43:57 +0000
parents 66d807bdc5b4
children d4ac295a98b3
comparison
equal deleted inserted replaced
21681:11eafe90b842 21682:90da2489c498
77 @result{} "@@" 77 @result{} "@@"
78 @end group 78 @end group
79 @end example 79 @end example
80 @end defun 80 @end defun
81 81
82 @defun char-before position
83 This function returns the character in the current buffer immediately
84 before position @var{position}. If @var{position} is out of range for
85 this purpose, either before the beginning of the buffer, or at or beyond
86 the end, then the value is @code{nil}.
87 @end defun
88
82 @defun following-char 89 @defun following-char
83 This function returns the character following point in the current 90 This function returns the character following point in the current
84 buffer. This is similar to @code{(char-after (point))}. However, if 91 buffer. This is similar to @code{(char-after (point))}. However, if
85 point is at the end of the buffer, then @code{following-char} returns 0. 92 point is at the end of the buffer, then @code{following-char} returns 0.
86 93
183 @end defun 190 @end defun
184 191
185 @defun buffer-substring-no-properties start end 192 @defun buffer-substring-no-properties start end
186 This is like @code{buffer-substring}, except that it does not copy text 193 This is like @code{buffer-substring}, except that it does not copy text
187 properties, just the characters themselves. @xref{Text Properties}. 194 properties, just the characters themselves. @xref{Text Properties}.
188 Here's an example of using this function to get a word to look up in an
189 alist:
190
191 @example
192 (setq flammable
193 (assoc (buffer-substring-no-properties start end)
194 '(("wood" . t) ("paper" . t)
195 ("steel" . nil) ("asbestos" . nil))))
196 @end example
197
198 If this were written using @code{buffer-substring} instead, it would not
199 work reliably; any text properties that happened to be in the word
200 copied from the buffer would make the comparisons fail.
201 @end defun 195 @end defun
202 196
203 @defun buffer-string 197 @defun buffer-string
204 This function returns the contents of the entire accessible portion of 198 This function returns the contents of the entire accessible portion of
205 the current buffer as a string. This is the portion between 199 the current buffer as a string. This is the portion between
280 @node Insertion 274 @node Insertion
281 @section Inserting Text 275 @section Inserting Text
282 @cindex insertion of text 276 @cindex insertion of text
283 @cindex text insertion 277 @cindex text insertion
284 278
279 @cindex insertion before point
280 @cindex before point, insertion
285 @dfn{Insertion} means adding new text to a buffer. The inserted text 281 @dfn{Insertion} means adding new text to a buffer. The inserted text
286 goes at point---between the character before point and the character 282 goes at point---between the character before point and the character
287 after point. 283 after point. Some insertion functions leave point before the inserted
284 text, while other functions leave it after. We call the former
285 insertion @dfn{after point} and the latter insertion @dfn{before point}.
288 286
289 Insertion relocates markers that point at positions after the 287 Insertion relocates markers that point at positions after the
290 insertion point, so that they stay with the surrounding text 288 insertion point, so that they stay with the surrounding text
291 (@pxref{Markers}). When a marker points at the place of insertion, 289 (@pxref{Markers}). When a marker points at the place of insertion,
292 insertion normally doesn't relocate the marker, so that it points to the 290 insertion may or may not relocate the marker, depending on the marker's
293 beginning of the inserted text; however, certain special functions such 291 insertion type (@pxref{Marker Insertion Types}). Certain special
294 as @code{insert-before-markers} relocate such markers to point after the 292 functions such as @code{insert-before-markers} relocate all such markers
295 inserted text. 293 to point after the inserted text, regardless of the markers' insertion
296 294 type.
297 @cindex insertion before point
298 @cindex before point, insertion
299 Some insertion functions leave point before the inserted text, while
300 other functions leave it after. We call the former insertion @dfn{after
301 point} and the latter insertion @dfn{before point}.
302 295
303 Insertion functions signal an error if the current buffer is 296 Insertion functions signal an error if the current buffer is
304 read-only. 297 read-only.
305 298
306 These functions copy text characters from strings and buffers along 299 These functions copy text characters from strings and buffers along
327 after the inserted text. If an overlay begins the insertion point, the 320 after the inserted text. If an overlay begins the insertion point, the
328 inserted text falls outside the overlay; if a nonempty overlay ends at 321 inserted text falls outside the overlay; if a nonempty overlay ends at
329 the insertion point, the inserted text falls inside that overlay. 322 the insertion point, the inserted text falls inside that overlay.
330 @end defun 323 @end defun
331 324
332 @defun insert-char character count &optional inherit 325 @defun insert-char character &optional count inherit
333 This function inserts @var{count} instances of @var{character} into the 326 This function inserts @var{count} instances of @var{character} into the
334 current buffer before point. The argument @var{count} must be a number, 327 current buffer before point. The argument @var{count} should be a
335 and @var{character} must be a character. The value is @code{nil}. 328 number (@code{nil} means 1), and @var{character} must be a character.
336 @c It's unfortunate that count comes second. Not like make-string, etc. 329 The value is @code{nil}.
337 330
338 If @var{inherit} is non-@code{nil}, then the inserted characters inherit 331 If @var{inherit} is non-@code{nil}, then the inserted characters inherit
339 sticky text properties from the two characters before and after the 332 sticky text properties from the two characters before and after the
340 insertion point. @xref{Sticky Properties}. 333 insertion point. @xref{Sticky Properties}.
341 @end defun 334 @end defun
528 argument is supplied, then one character is deleted, but not saved in 521 argument is supplied, then one character is deleted, but not saved in
529 the kill ring. 522 the kill ring.
530 523
531 The value returned is always @code{nil}. 524 The value returned is always @code{nil}.
532 @end deffn 525 @end deffn
526
527 @tindex backward-delete-char-untabify-method
528 @defopt backward-delete-char-untabify-method
529 This option specifies how @code{backward-delete-char-untabify} should
530 deal with whitespace. Possible values include @code{untabify}, the
531 default, meaning convert a tab to many spaces and delete one;
532 @code{hungry}, meaning delete all the whitespace characters before point
533 with one command, and @code{nil}, meaning do nothing special for
534 whitespace characters.
535 @end defopt
533 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
537 This section describes higher-level commands for deleting text, 540 This section describes higher-level commands for deleting text,
666 669
667 @node The Kill Ring 670 @node The Kill Ring
668 @section The Kill Ring 671 @section The Kill Ring
669 @cindex kill ring 672 @cindex kill ring
670 673
671 @dfn{Kill} functions delete text like the deletion functions, but save 674 @dfn{Kill functions} delete text like the deletion functions, but save
672 it so that the user can reinsert it by @dfn{yanking}. Most of these 675 it so that the user can reinsert it by @dfn{yanking}. Most of these
673 functions have @samp{kill-} in their name. By contrast, the functions 676 functions have @samp{kill-} in their name. By contrast, the functions
674 whose names start with @samp{delete-} normally do not save text for 677 whose names start with @samp{delete-} normally do not save text for
675 yanking (though they can still be undone); these are ``deletion'' 678 yanking (though they can still be undone); these are ``deletion''
676 functions. 679 functions.
826 @end deffn 829 @end deffn
827 830
828 @node Low-Level Kill Ring 831 @node Low-Level Kill Ring
829 @subsection Low-Level Kill Ring 832 @subsection Low-Level Kill Ring
830 833
831 These functions and variables provide access to the kill ring at a lower 834 These functions and variables provide access to the kill ring at a
832 level, but still convenient for use in Lisp programs. They take care of 835 lower level, but still convenient for use in Lisp programs, because they
833 interaction with X Window selections. They do not exist in Emacs 836 take care of interaction with window system selections
834 version 18. 837 (@pxref{Window System Selections}).
835 838
836 @defun current-kill n &optional do-not-move 839 @defun current-kill n &optional do-not-move
837 The function @code{current-kill} rotates the yanking pointer which 840 The function @code{current-kill} rotates the yanking pointer which
838 designates the ``front'' of the kill ring by @var{n} places (from newer 841 designates the ``front'' of the kill ring by @var{n} places (from newer
839 kills to older ones), and returns the text at that place in the ring. 842 kills to older ones), and returns the text at that place in the ring.
871 If the value is a function, @code{current-kill} calls it to get the 874 If the value is a function, @code{current-kill} calls it to get the
872 ``most recent kill''. If the function returns a non-@code{nil} value, 875 ``most recent kill''. If the function returns a non-@code{nil} value,
873 then that value is used as the ``most recent kill''. If it returns 876 then that value is used as the ``most recent kill''. If it returns
874 @code{nil}, then the first element of @code{kill-ring} is used. 877 @code{nil}, then the first element of @code{kill-ring} is used.
875 878
876 The normal use of this hook is to get the X server's primary selection 879 The normal use of this hook is to get the window system's primary
877 as the most recent kill, even if the selection belongs to another X 880 selection as the most recent kill, even if the selection belongs to
878 client. @xref{X Selections}. 881 another application. @xref{Window System Selections}.
879 @end defvar 882 @end defvar
880 883
881 @defvar interprogram-cut-function 884 @defvar interprogram-cut-function
882 This variable provides a way of communicating killed text to other 885 This variable provides a way of communicating killed text to other
883 programs, when you are using a window system. Its value should be 886 programs, when you are using a window system. Its value should be
884 @code{nil} or a function of one argument. 887 @code{nil} or a function of one argument.
885 888
886 If the value is a function, @code{kill-new} and @code{kill-append} call 889 If the value is a function, @code{kill-new} and @code{kill-append} call
887 it with the new first element of the kill ring as an argument. 890 it with the new first element of the kill ring as an argument.
888 891
889 The normal use of this hook is to set the X server's primary selection 892 The normal use of this hook is to set the window system's primary
890 from the newly killed text. 893 selection from the newly killed text. @xref{Window System Selections}.
891 @end defvar 894 @end defvar
892 895
893 @node Internals of Kill Ring 896 @node Internals of Kill Ring
894 @comment node-name, next, previous, up 897 @comment node-name, next, previous, up
895 @subsection Internals of the Kill Ring 898 @subsection Internals of the Kill Ring
923 pointing to the second entry in the kill ring @code{("some text" "a 926 pointing to the second entry in the kill ring @code{("some text" "a
924 different piece of text" "yet older text")}. 927 different piece of text" "yet older text")}.
925 928
926 @example 929 @example
927 @group 930 @group
928 kill-ring kill-ring-yank-pointer 931 kill-ring ---- kill-ring-yank-pointer
929 | | 932 | |
930 | ___ ___ ---> ___ ___ ___ ___ 933 | v
931 --> |___|___|------> |___|___|--> |___|___|--> nil 934 | --- --- --- --- --- ---
935 --> | | |------> | | |--> | | |--> nil
936 --- --- --- --- --- ---
932 | | | 937 | | |
933 | | | 938 | | |
934 | | -->"yet older text" 939 | | -->"yet older text"
935 | | 940 | |
936 | --> "a different piece of text" 941 | --> "a different piece of text"
1101 has no effect. 1106 has no effect.
1102 1107
1103 This function returns @code{nil}. It cannot be called interactively. 1108 This function returns @code{nil}. It cannot be called interactively.
1104 1109
1105 The name @code{buffer-flush-undo} is not considered obsolete, but the 1110 The name @code{buffer-flush-undo} is not considered obsolete, but the
1106 preferred name @code{buffer-disable-undo} is new as of Emacs versions 1111 preferred name is @code{buffer-disable-undo}.
1107 19.
1108 @end defun 1112 @end defun
1109 1113
1110 As editing continues, undo lists get longer and longer. To prevent 1114 As editing continues, undo lists get longer and longer. To prevent
1111 them from using up all available memory space, garbage collection trims 1115 them from using up all available memory space, garbage collection trims
1112 them back to size limits you can set. (For this purpose, the ``size'' 1116 them back to size limits you can set. (For this purpose, the ``size''
1151 Several of the filling functions have an argument @var{justify}. 1155 Several of the filling functions have an argument @var{justify}.
1152 If it is non-@code{nil}, that requests some kind of justification. It 1156 If it is non-@code{nil}, that requests some kind of justification. It
1153 can be @code{left}, @code{right}, @code{full}, or @code{center}, to 1157 can be @code{left}, @code{right}, @code{full}, or @code{center}, to
1154 request a specific style of justification. If it is @code{t}, that 1158 request a specific style of justification. If it is @code{t}, that
1155 means to use the current justification style for this part of the text 1159 means to use the current justification style for this part of the text
1156 (see @code{current-justification}, below). 1160 (see @code{current-justification}, below). Any other value is treated
1161 as @code{full}.
1157 1162
1158 When you call the filling functions interactively, using a prefix 1163 When you call the filling functions interactively, using a prefix
1159 argument implies the value @code{full} for @var{justify}. 1164 argument implies the value @code{full} for @var{justify}.
1160 1165
1161 @deffn Command fill-paragraph justify 1166 @deffn Command fill-paragraph justify
1356 whitespace. 1361 whitespace.
1357 @end defun 1362 @end defun
1358 1363
1359 @defvar left-margin 1364 @defvar left-margin
1360 This variable specifies the base left margin column. In Fundamental 1365 This variable specifies the base left margin column. In Fundamental
1361 mode, @key{LFD} indents to this column. This variable automatically 1366 mode, @kbd{C-j} indents to this column. This variable automatically
1362 becomes buffer-local when set in any fashion. 1367 becomes buffer-local when set in any fashion.
1368 @end defvar
1369
1370 @tindex fill-nobreak-predicate
1371 @defvar fill-nobreak-predicate
1372 This variable gives major modes a way to specify not to break a line at
1373 certain places. Its value should be a function. This function is
1374 called during filling, with no arguments and with point located at the
1375 place where a break is being considered. If the function returns
1376 non-@code{nil}, then the line won't be broken there.
1363 @end defvar 1377 @end defvar
1364 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
1393 @end defvar 1407 @end defvar
1394 1408
1395 @defvar normal-auto-fill-function 1409 @defvar normal-auto-fill-function
1396 This variable specifies the function to use for 1410 This variable specifies the function to use for
1397 @code{auto-fill-function}, if and when Auto Fill is turned on. Major 1411 @code{auto-fill-function}, if and when Auto Fill is turned on. Major
1398 modes can set this locally to alter how Auto Fill works. 1412 modes can set buffer-local values for this variable to alter how Auto
1413 Fill works.
1399 @end defvar 1414 @end defvar
1400 1415
1401 @node Sorting 1416 @node Sorting
1402 @section Sorting Text 1417 @section Sorting Text
1403 @cindex sorting text 1418 @cindex sorting text
1483 @group 1498 @group
1484 (interactive "P\nr") 1499 (interactive "P\nr")
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
1494 Here @code{forward-line} moves point to the start of the next record, 1507 Here @code{forward-line} moves point to the start of the next record,
1495 and @code{end-of-line} moves point to the end of record. We do not pass 1508 and @code{end-of-line} moves point to the end of record. We do not pass
1501 1514
1502 @example 1515 @example
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
1511 1523
1512 Markers pointing into any sort records are left with no useful 1524 Markers pointing into any sort records are left with no useful
1628 containing position @var{beg}, and the entire line containing position 1640 containing position @var{beg}, and the entire line containing position
1629 @var{end}, are included in the region sorted. 1641 @var{end}, are included in the region sorted.
1630 1642
1631 Note that @code{sort-columns} uses the @code{sort} utility program, 1643 Note that @code{sort-columns} uses the @code{sort} utility program,
1632 and so cannot work properly on text containing tab characters. Use 1644 and so cannot work properly on text containing tab characters. Use
1633 @kbd{M-x @code{untabify}} to convert tabs to spaces before sorting. 1645 @kbd{M-x untabify} to convert tabs to spaces before sorting.
1634 @end deffn 1646 @end deffn
1635 1647
1636 @node Columns 1648 @node Columns
1637 @comment node-name, next, previous, up 1649 @comment node-name, next, previous, up
1638 @section Counting Columns 1650 @section Counting Columns
1713 @node Primitive Indent 1725 @node Primitive Indent
1714 @subsection Indentation Primitives 1726 @subsection Indentation Primitives
1715 1727
1716 This section describes the primitive functions used to count and 1728 This section describes the primitive functions used to count and
1717 insert indentation. The functions in the following sections use these 1729 insert indentation. The functions in the following sections use these
1718 primitives. 1730 primitives. @xref{Width}, for related functions.
1719 1731
1720 @defun current-indentation 1732 @defun current-indentation
1721 @comment !!Type Primitive Function 1733 @comment !!Type Primitive Function
1722 @comment !!SourceFile indent.c 1734 @comment !!SourceFile indent.c
1723 This function returns the indentation of the current line, which is 1735 This function returns the indentation of the current line, which is
1743 1755
1744 @defopt indent-tabs-mode 1756 @defopt indent-tabs-mode
1745 @comment !!SourceFile indent.c 1757 @comment !!SourceFile indent.c
1746 If this variable is non-@code{nil}, indentation functions can insert 1758 If this variable is non-@code{nil}, indentation functions can insert
1747 tabs as well as spaces. Otherwise, they insert only spaces. Setting 1759 tabs as well as spaces. Otherwise, they insert only spaces. Setting
1748 this variable automatically makes it local to the current buffer. 1760 this variable automatically makes it buffer-local in the current buffer.
1749 @end defopt 1761 @end defopt
1750 1762
1751 @node Mode-Specific Indent 1763 @node Mode-Specific Indent
1752 @subsection Indentation Controlled by Major Mode 1764 @subsection Indentation Controlled by Major Mode
1753 1765
2007 @end deffn 2019 @end deffn
2008 2020
2009 @node Case Changes 2021 @node Case Changes
2010 @comment node-name, next, previous, up 2022 @comment node-name, next, previous, up
2011 @section Case Changes 2023 @section Case Changes
2012 @cindex case changes 2024 @cindex case conversion in buffers
2013 2025
2014 The case change commands described here work on text in the current 2026 The case change commands described here work on text in the current
2015 buffer. @xref{Character Case}, for case conversion commands that work 2027 buffer. @xref{Case Conversion}, for case conversion functions that work
2016 on strings and characters. @xref{Case Table}, for how to customize 2028 on strings and characters. @xref{Case Tables}, for how to customize
2017 which characters are upper or lower case and how to convert them. 2029 which characters are upper or lower case and how to convert them.
2018 2030
2019 @deffn Command capitalize-region start end 2031 @deffn Command capitalize-region start end
2020 This function capitalizes all words in the region defined by 2032 This function capitalizes all words in the region defined by
2021 @var{start} and @var{end}. To capitalize means to convert each word's 2033 @var{start} and @var{end}. To capitalize means to convert each word's
2415 2427
2416 @node Special Properties 2428 @node Special Properties
2417 @subsection Properties with Special Meanings 2429 @subsection Properties with Special Meanings
2418 2430
2419 Here is a table of text property names that have special built-in 2431 Here is a table of text property names that have special built-in
2420 meanings. The following section lists a few more special property names 2432 meanings. The following sections list a few additional special property
2421 that are used to control filling. All other names have no standard 2433 names that control filling and property inheritance. All other names
2422 meaning, and you can use them as you like. 2434 have no standard meaning, and you can use them as you like.
2423 2435
2424 @table @code 2436 @table @code
2425 @cindex category of text character 2437 @cindex category of text character
2426 @kindex category @r{(text property)} 2438 @kindex category @r{(text property)}
2427 @item category 2439 @item category
2811 (interactive "e") 2823 (interactive "e")
2812 (let (file) 2824 (let (file)
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
2821 2833
2822 @noindent 2834 @noindent
2953 @node Registers 2965 @node Registers
2954 @section Registers 2966 @section Registers
2955 @cindex registers 2967 @cindex registers
2956 2968
2957 A register is a sort of variable used in Emacs editing that can hold a 2969 A register is a sort of variable used in Emacs editing that can hold a
2958 marker, a string, a rectangle, a window configuration (of one frame), or 2970 variety of different kinds of values. Each register is named by a
2959 a frame configuration (of all frames). Each register is named by a 2971 single character. All ASCII characters and their meta variants (but
2960 single character. All characters, including control and meta characters 2972 with the exception of @kbd{C-g}) can be used to name registers. Thus,
2961 (but with the exception of @kbd{C-g}), can be used to name registers. 2973 there are 255 possible registers. A register is designated in Emacs
2962 Thus, there are 255 possible registers. A register is designated in 2974 Lisp by the character that is its name.
2963 Emacs Lisp by a character that is its name.
2964
2965 The functions in this section return unpredictable values unless
2966 otherwise stated.
2967 2975
2968 @defvar register-alist 2976 @defvar register-alist
2969 This variable is an alist of elements of the form @code{(@var{name} . 2977 This variable is an alist of elements of the form @code{(@var{name} .
2970 @var{contents})}. Normally, there is one element for each Emacs 2978 @var{contents})}. Normally, there is one element for each Emacs
2971 register that has been used. 2979 register that has been used.
2972 2980
2973 The object @var{name} is a character (an integer) identifying the 2981 The object @var{name} is a character (an integer) identifying the
2974 register. The object @var{contents} is a string, marker, window 2982 register.
2975 configuration, frame configuration, or list representing the register
2976 contents. A string represents text stored in the register. A marker
2977 represents a position. A list represents a rectangle; its elements are
2978 strings, one per line of the rectangle.
2979 @end defvar 2983 @end defvar
2984
2985 The @var{contents} of a register can have several possible types:
2986
2987 @table @asis
2988 @item a number
2989 A number stands for itself. If @code{insert-register} finds a number
2990 in the register, it converts the number to decimal.
2991
2992 @item a marker
2993 A marker represents a buffer position to jump to.
2994
2995 @item a string
2996 A string is text saved in the register.
2997
2998 @item a rectangle
2999 A rectangle is represented by a list of strings.
3000
3001 @item @code{(@var{window-configuration} @var{position})}
3002 This represents a window configuration to restore in one frame, and a
3003 position to jump to in the current buffer.
3004
3005 @item @code{(@var{frame-configuration} @var{position})}
3006 This represents a frame configuration to restore, and a position
3007 to jump to in the current buffer.
3008
3009 @item (file @var{filename})
3010 This represents a file to visit; jumping to this value visits file
3011 @var{filename}.
3012
3013 @item (file-query @var{filename} @var{position})
3014 This represents a file to visit and a position in it; jumping to this
3015 value visits file @var{filename} and goes to buffer position
3016 @var{position}. Restoring this type of position asks the user for
3017 confirmation first.
3018 @end table
3019
3020 The functions in this section return unpredictable values unless
3021 otherwise stated.
2980 3022
2981 @defun get-register reg 3023 @defun get-register reg
2982 This function returns the contents of the register 3024 This function returns the contents of the register
2983 @var{reg}, or @code{nil} if it has no contents. 3025 @var{reg}, or @code{nil} if it has no contents.
2984 @end defun 3026 @end defun
3134 that seems safe. 3176 that seems safe.
3135 3177
3136 If a program makes several text changes in the same area of the buffer, 3178 If a program makes several text changes in the same area of the buffer,
3137 using the macro @code{combine-after-change-calls} around that part of 3179 using the macro @code{combine-after-change-calls} around that part of
3138 the program can make it run considerably faster when after-change hooks 3180 the program can make it run considerably faster when after-change hooks
3139 are in use. 3181 are in use. When the after-change hooks are ultimately called, the
3182 arguments specify a portion of the buffer including all of the changes
3183 made within the @code{combine-after-change-calls} body.
3140 3184
3141 @strong{Warning:} You must not alter the values of 3185 @strong{Warning:} You must not alter the values of
3142 @code{after-change-functions} and @code{after-change-function} within 3186 @code{after-change-functions} and @code{after-change-function} within
3143 the body of a @code{combine-after-change-calls} form. 3187 the body of a @code{combine-after-change-calls} form.
3188
3189 @strong{Note:} If the changes you combine occur in widely scattered
3190 parts of the buffer, this will still work, but it is not advisable,
3191 because it may lead to inefficient behavior for some change hook
3192 functions.
3144 @end defmac 3193 @end defmac
3145 3194
3146 @defvar before-change-function 3195 @defvar before-change-function
3147 This obsolete variable holds one function to call before any buffer 3196 This obsolete variable holds one function to call before any buffer
3148 modification (or @code{nil} for no function). It is called just like 3197 modification (or @code{nil} for no function). It is called just like
3175 (defun indirect-after-change-function (beg end len) 3224 (defun indirect-after-change-function (beg end len)
3176 (let ((list my-own-after-change-functions)) 3225 (let ((list my-own-after-change-functions))
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
3185 This variable is a normal hook that is run whenever a buffer is changed 3237 This variable is a normal hook that is run whenever a buffer is changed
3186 that was previously in the unmodified state. 3238 that was previously in the unmodified state.