Mercurial > emacs
comparison lispref/text.texi @ 12098:a6eb5f12b0f3
*** empty log message ***
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 06 Jun 1995 19:21:15 +0000 |
parents | 73dc8205d259 |
children | 586e3ea81792 |
comparison
equal
deleted
inserted
replaced
12097:d8c035332be8 | 12098:a6eb5f12b0f3 |
---|---|
24 @var{end} is outside the accessible portion of the buffer. In an | 24 @var{end} is outside the accessible portion of the buffer. In an |
25 interactive call, point and the mark are used for these arguments. | 25 interactive call, point and the mark are used for these arguments. |
26 | 26 |
27 @cindex buffer contents | 27 @cindex buffer contents |
28 Throughout this chapter, ``text'' refers to the characters in the | 28 Throughout this chapter, ``text'' refers to the characters in the |
29 buffer. | 29 buffer, together with their properties (when relevant). |
30 | 30 |
31 @menu | 31 @menu |
32 * Near Point:: Examining text in the vicinity of point. | 32 * Near Point:: Examining text in the vicinity of point. |
33 * Buffer Contents:: Examining text in a general fashion. | 33 * Buffer Contents:: Examining text in a general fashion. |
34 * Comparing Text:: Comparing substrings of buffers. | 34 * Comparing Text:: Comparing substrings of buffers. |
39 * The Kill Ring:: Where removed text sometimes is saved for later use. | 39 * The Kill Ring:: Where removed text sometimes is saved for later use. |
40 * Undo:: Undoing changes to the text of a buffer. | 40 * Undo:: Undoing changes to the text of a buffer. |
41 * Maintaining Undo:: How to enable and disable undo information. | 41 * Maintaining Undo:: How to enable and disable undo information. |
42 How to control how much information is kept. | 42 How to control how much information is kept. |
43 * Filling:: Functions for explicit filling. | 43 * Filling:: Functions for explicit filling. |
44 * Margins:: How to specify margins for filling commands. | |
44 * Auto Filling:: How auto-fill mode is implemented to break lines. | 45 * Auto Filling:: How auto-fill mode is implemented to break lines. |
45 * Sorting:: Functions for sorting parts of the buffer. | 46 * Sorting:: Functions for sorting parts of the buffer. |
46 * Columns:: Computing horizontal positions, and using them. | 47 * Columns:: Computing horizontal positions, and using them. |
47 * Indentation:: Functions to insert or adjust indentation. | 48 * Indentation:: Functions to insert or adjust indentation. |
48 * Case Changes:: Case conversion of parts of the buffer. | 49 * Case Changes:: Case conversion of parts of the buffer. |
237 first is greater, and zero if they are equal. The absolute value of | 238 first is greater, and zero if they are equal. The absolute value of |
238 the result is one plus the index of the first differing characters | 239 the result is one plus the index of the first differing characters |
239 within the substrings. | 240 within the substrings. |
240 | 241 |
241 This function ignores case when comparing characters | 242 This function ignores case when comparing characters |
242 if @code{case-fold-search} is non-@code{nil}. | 243 if @code{case-fold-search} is non-@code{nil}. It always ignores |
244 text properties. | |
243 | 245 |
244 Suppose the current buffer contains the text @samp{foobarbar | 246 Suppose the current buffer contains the text @samp{foobarbar |
245 haha!rara!}; then in this example the two substrings are @samp{rbar } | 247 haha!rara!}; then in this example the two substrings are @samp{rbar } |
246 and @samp{rara!}. The value is 2 because the first substring is greater | 248 and @samp{rara!}. The value is 2 because the first substring is greater |
247 at the second character. | 249 at the second character. |
248 | 250 |
249 @example | 251 @example |
250 (compare-buffer-substring nil 6 11 nil 16 21) | 252 (compare-buffer-substring nil 6 11 nil 16 21) |
251 @result{} 2 | 253 @result{} 2 |
252 @end example | 254 @end example |
253 | |
254 This function does not exist in Emacs version 18 and earlier. | |
255 @end defun | 255 @end defun |
256 | 256 |
257 @node Insertion | 257 @node Insertion |
258 @section Insertion | 258 @section Inserting Text |
259 @cindex insertion of text | 259 @cindex insertion of text |
260 @cindex text insertion | 260 @cindex text insertion |
261 | 261 |
262 @dfn{Insertion} means adding new text to a buffer. The inserted text | 262 @dfn{Insertion} means adding new text to a buffer. The inserted text |
263 goes at point---between the character before point and the character | 263 goes at point---between the character before point and the character |
277 other functions leave it after. We call the former insertion @dfn{after | 277 other functions leave it after. We call the former insertion @dfn{after |
278 point} and the latter insertion @dfn{before point}. | 278 point} and the latter insertion @dfn{before point}. |
279 | 279 |
280 Insertion functions signal an error if the current buffer is | 280 Insertion functions signal an error if the current buffer is |
281 read-only. | 281 read-only. |
282 | |
283 These functions copy text characters from strings and buffers along | |
284 with their properties. The inserted characters have exactly the same | |
285 properties as the characters they were copied from. By contrast, | |
286 characters specified as separate arguments, not part of a string or | |
287 buffer, inherit their text properties from the neighboring text. | |
282 | 288 |
283 @defun insert &rest args | 289 @defun insert &rest args |
284 This function inserts the strings and/or characters @var{args} into the | 290 This function inserts the strings and/or characters @var{args} into the |
285 current buffer, at point, moving point forward. In other words, it | 291 current buffer, at point, moving point forward. In other words, it |
286 inserts the text before point. An error is signaled unless all | 292 inserts the text before point. An error is signaled unless all |
391 @code{auto-fill-function} does is insert a newline; thus, the overall | 397 @code{auto-fill-function} does is insert a newline; thus, the overall |
392 result in this case is to insert two newlines at different places: one | 398 result in this case is to insert two newlines at different places: one |
393 at point, and another earlier in the line. @code{newline} does not | 399 at point, and another earlier in the line. @code{newline} does not |
394 auto-fill if @var{number-of-newlines} is non-@code{nil}. | 400 auto-fill if @var{number-of-newlines} is non-@code{nil}. |
395 | 401 |
402 This command indents to the left margin if that is not zero. | |
403 @xref{Margins}. | |
404 | |
396 The value returned is @code{nil}. In an interactive call, @var{count} | 405 The value returned is @code{nil}. In an interactive call, @var{count} |
397 is the numeric prefix argument. | 406 is the numeric prefix argument. |
398 @end deffn | 407 @end deffn |
399 | 408 |
400 @deffn Command split-line | 409 @deffn Command split-line |
412 non-@code{nil} value enables the mode. It is automatically made | 421 non-@code{nil} value enables the mode. It is automatically made |
413 buffer-local when set in any fashion. | 422 buffer-local when set in any fashion. |
414 @end defvar | 423 @end defvar |
415 | 424 |
416 @node Deletion | 425 @node Deletion |
417 @section Deletion of Text | 426 @section Deleting Text |
418 | 427 |
419 @cindex deletion vs killing | 428 @cindex deletion vs killing |
420 Deletion means removing part of the text in a buffer, without saving | 429 Deletion means removing part of the text in a buffer, without saving |
421 it in the kill ring (@pxref{The Kill Ring}). Deleted text can't be | 430 it in the kill ring (@pxref{The Kill Ring}). Deleted text can't be |
422 yanked, but can be reinserted using the undo mechanism (@pxref{Undo}). | 431 yanked, but can be reinserted using the undo mechanism (@pxref{Undo}). |
542 @code{delete-indentation} joins this line to the following line | 551 @code{delete-indentation} joins this line to the following line |
543 instead. The value is @code{nil}. | 552 instead. The value is @code{nil}. |
544 | 553 |
545 If there is a fill prefix, and the second of the lines being joined | 554 If there is a fill prefix, and the second of the lines being joined |
546 starts with the prefix, then @code{delete-indentation} deletes the | 555 starts with the prefix, then @code{delete-indentation} deletes the |
547 fill prefix before joining the lines. @xref{Filling}. | 556 fill prefix before joining the lines. @xref{Margins}. |
548 | 557 |
549 In the example below, point is located on the line starting | 558 In the example below, point is located on the line starting |
550 @samp{events}, and it makes no difference if there are trailing spaces | 559 @samp{events}, and it makes no difference if there are trailing spaces |
551 in the preceding line. | 560 in the preceding line. |
552 | 561 |
711 variable to determine whether the previous command was a kill command, | 720 variable to determine whether the previous command was a kill command, |
712 and if so appends the killed text to the most recent entry. | 721 and if so appends the killed text to the most recent entry. |
713 | 722 |
714 @deffn Command kill-region start end | 723 @deffn Command kill-region start end |
715 This function kills the text in the region defined by @var{start} and | 724 This function kills the text in the region defined by @var{start} and |
716 @var{end}. The text is deleted but saved in the kill ring. The value | 725 @var{end}. The text is deleted but saved in the kill ring, along with |
717 is always @code{nil}. | 726 its text properties. The value is always @code{nil}. |
718 | 727 |
719 In an interactive call, @var{start} and @var{end} are point and | 728 In an interactive call, @var{start} and @var{end} are point and |
720 the mark. | 729 the mark. |
721 | 730 |
722 @c Emacs 19 feature | 731 @c Emacs 19 feature |
726 text into the kill ring from a read-only buffer. | 735 text into the kill ring from a read-only buffer. |
727 @end deffn | 736 @end deffn |
728 | 737 |
729 @deffn Command copy-region-as-kill start end | 738 @deffn Command copy-region-as-kill start end |
730 This command saves the region defined by @var{start} and @var{end} on | 739 This command saves the region defined by @var{start} and @var{end} on |
731 the kill ring, but does not delete the text from the buffer. It returns | 740 the kill ring (including text properties), but does not delete the text |
732 @code{nil}. It also indicates the extent of the text copied by moving | 741 from the buffer. It returns @code{nil}. It also indicates the extent |
733 the cursor momentarily, or by displaying a message in the echo area. | 742 of the text copied by moving the cursor momentarily, or by displaying a |
743 message in the echo area. | |
734 | 744 |
735 The command does not set @code{this-command} to @code{kill-region}, so a | 745 The command does not set @code{this-command} to @code{kill-region}, so a |
736 subsequent kill command does not append to the same kill ring entry. | 746 subsequent kill command does not append to the same kill ring entry. |
737 | 747 |
738 Don't call @code{copy-region-as-kill} in Lisp programs unless you aim to | 748 Don't call @code{copy-region-as-kill} in Lisp programs unless you aim to |
743 @node Yank Commands | 753 @node Yank Commands |
744 @comment node-name, next, previous, up | 754 @comment node-name, next, previous, up |
745 @subsection Functions for Yanking | 755 @subsection Functions for Yanking |
746 | 756 |
747 @dfn{Yanking} means reinserting an entry of previously killed text | 757 @dfn{Yanking} means reinserting an entry of previously killed text |
748 from the kill ring. | 758 from the kill ring. The text properties are copied too. |
749 | 759 |
750 @deffn Command yank &optional arg | 760 @deffn Command yank &optional arg |
751 @cindex inserting killed text | 761 @cindex inserting killed text |
752 This command inserts before point the text in the first entry in the | 762 This command inserts before point the text in the first entry in the |
753 kill ring. It positions the mark at the beginning of that text, and | 763 kill ring. It positions the mark at the beginning of that text, and |
973 @example | 983 @example |
974 (put-text-property @var{beg} @var{end} @var{property} @var{value}) | 984 (put-text-property @var{beg} @var{end} @var{property} @var{value}) |
975 @end example | 985 @end example |
976 | 986 |
977 @item @var{position} | 987 @item @var{position} |
978 This element indicates where point was at an earlier time. | 988 This element indicates where point was at an earlier time. Undoing this |
979 Undoing this element sets point to @var{position}. | 989 element sets point to @var{position}. Deletion normally creates an |
990 element of this kind as well as a reinsertion element. | |
980 | 991 |
981 @item nil | 992 @item nil |
982 This element is a boundary. The elements between two boundaries are | 993 This element is a boundary. The elements between two boundaries are |
983 called a @dfn{change group}; normally, each change group corresponds to | 994 called a @dfn{change group}; normally, each change group corresponds to |
984 one keyboard command, and undo commands normally undo an entire group as | 995 one keyboard command, and undo commands normally undo an entire group as |
1016 | 1027 |
1017 @code{primitive-undo} adds elements to the buffer's undo list when it | 1028 @code{primitive-undo} adds elements to the buffer's undo list when it |
1018 changes the buffer. Undo commands avoid confusion by saving the undo | 1029 changes the buffer. Undo commands avoid confusion by saving the undo |
1019 list value at the beginning of a sequence of undo operations. Then the | 1030 list value at the beginning of a sequence of undo operations. Then the |
1020 undo operations use and update the saved value. The new elements added | 1031 undo operations use and update the saved value. The new elements added |
1021 by undoing are not part of the saved value, so they don't interfere with | 1032 by undoing are not part of this saved value, so they don't interfere with |
1022 continuing to undo. | 1033 continuing to undo. |
1023 @end defun | 1034 @end defun |
1024 | 1035 |
1025 @node Maintaining Undo | 1036 @node Maintaining Undo |
1026 @section Maintaining Undo Lists | 1037 @section Maintaining Undo Lists |
1087 @cindex filling, explicit | 1098 @cindex filling, explicit |
1088 | 1099 |
1089 @dfn{Filling} means adjusting the lengths of lines (by moving the line | 1100 @dfn{Filling} means adjusting the lengths of lines (by moving the line |
1090 breaks) so that they are nearly (but no greater than) a specified | 1101 breaks) so that they are nearly (but no greater than) a specified |
1091 maximum width. Additionally, lines can be @dfn{justified}, which means | 1102 maximum width. Additionally, lines can be @dfn{justified}, which means |
1092 that spaces are inserted between words to make the line exactly the | 1103 inserting spaces to make the left and/or right margins line up |
1093 specified width. The width is controlled by the variable | 1104 precisely. The width is controlled by the variable @code{fill-column}. |
1094 @code{fill-column}. For ease of reading, lines should be no longer than | 1105 For ease of reading, lines should be no longer than 70 or so columns. |
1095 70 or so columns. | |
1096 | 1106 |
1097 You can use Auto Fill mode (@pxref{Auto Filling}) to fill text | 1107 You can use Auto Fill mode (@pxref{Auto Filling}) to fill text |
1098 automatically as you insert it, but changes to existing text may leave | 1108 automatically as you insert it, but changes to existing text may leave |
1099 it improperly filled. Then you must fill the text explicitly. | 1109 it improperly filled. Then you must fill the text explicitly. |
1100 | 1110 |
1101 Most of the commands in this section return values that are not | 1111 Most of the commands in this section return values that are not |
1102 meaningful. All the functions that do filling take note of the current | 1112 meaningful. All the functions that do filling take note of the current |
1103 left margin, current right margin, and current justification style. If | 1113 left margin, current right margin, and current justification style |
1104 the current justification style is @code{none}, the filling functions | 1114 (@pxref{Margins}). If the current justification style is |
1105 don't actually do anything. | 1115 @code{none}, the filling functions don't actually do anything. |
1106 | 1116 |
1107 @deffn Command fill-paragraph justify-flag | 1117 Several of the filling functions have an argument @var{justify}. |
1118 If it is non-@code{nil}, that requests some kind of justification. It | |
1119 can be @code{left}, @code{right}, @code{full}, or @code{center}, to | |
1120 request a specific style of justification. If it is @code{t}, that | |
1121 means to use the current justification style for this part of the text | |
1122 (see @code{current-justification}, below). | |
1123 | |
1124 When you call the filling functions interactively, using a prefix | |
1125 argument implies the value @code{full} for @var{justify}. | |
1126 | |
1127 @deffn Command fill-paragraph justify | |
1108 @cindex filling a paragraph | 1128 @cindex filling a paragraph |
1109 This command fills the paragraph at or after point. If | 1129 This command fills the paragraph at or after point. If |
1110 @var{justify-flag} is non-@code{nil}, each line is justified as well. | 1130 @var{justify} is non-@code{nil}, each line is justified as well. |
1111 It uses the ordinary paragraph motion commands to find paragraph | 1131 It uses the ordinary paragraph motion commands to find paragraph |
1112 boundaries. @xref{Paragraphs,,, emacs, The Emacs Manual}. | 1132 boundaries. @xref{Paragraphs,,, emacs, The Emacs Manual}. |
1113 @end deffn | 1133 @end deffn |
1114 | 1134 |
1115 @deffn Command fill-region start end &optional justify-flag | 1135 @deffn Command fill-region start end &optional justify |
1116 This command fills each of the paragraphs in the region from @var{start} | 1136 This command fills each of the paragraphs in the region from @var{start} |
1117 to @var{end}. It justifies as well if @var{justify-flag} is | 1137 to @var{end}. It justifies as well if @var{justify} is |
1118 non-@code{nil}. | 1138 non-@code{nil}. |
1119 | 1139 |
1120 The variable @code{paragraph-separate} controls how to distinguish | 1140 The variable @code{paragraph-separate} controls how to distinguish |
1121 paragraphs. @xref{Standard Regexps}. | 1141 paragraphs. @xref{Standard Regexps}. |
1122 @end deffn | 1142 @end deffn |
1123 | 1143 |
1124 @deffn Command fill-individual-paragraphs start end &optional justify-flag mail-flag | 1144 @deffn Command fill-individual-paragraphs start end &optional justify mail-flag |
1125 This command fills each paragraph in the region according to its | 1145 This command fills each paragraph in the region according to its |
1126 individual fill prefix. Thus, if the lines of a paragraph were indented | 1146 individual fill prefix. Thus, if the lines of a paragraph were indented |
1127 with spaces, the filled paragraph will remain indented in the same | 1147 with spaces, the filled paragraph will remain indented in the same |
1128 fashion. | 1148 fashion. |
1129 | 1149 |
1130 The first two arguments, @var{start} and @var{end}, are the beginning | 1150 The first two arguments, @var{start} and @var{end}, are the beginning |
1131 and end of the region to be filled. The third and fourth arguments, | 1151 and end of the region to be filled. The third and fourth arguments, |
1132 @var{justify-flag} and @var{mail-flag}, are optional. If | 1152 @var{justify} and @var{mail-flag}, are optional. If |
1133 @var{justify-flag} is non-@code{nil}, the paragraphs are justified as | 1153 @var{justify} is non-@code{nil}, the paragraphs are justified as |
1134 well as filled. If @var{mail-flag} is non-@code{nil}, it means the | 1154 well as filled. If @var{mail-flag} is non-@code{nil}, it means the |
1135 function is operating on a mail message and therefore should not fill | 1155 function is operating on a mail message and therefore should not fill |
1136 the header lines. | 1156 the header lines. |
1137 | 1157 |
1138 Ordinarily, @code{fill-individual-paragraphs} regards each change in | 1158 Ordinarily, @code{fill-individual-paragraphs} regards each change in |
1145 @defopt fill-individual-varying-indent | 1165 @defopt fill-individual-varying-indent |
1146 This variable alters the action of @code{fill-individual-paragraphs} as | 1166 This variable alters the action of @code{fill-individual-paragraphs} as |
1147 described above. | 1167 described above. |
1148 @end defopt | 1168 @end defopt |
1149 | 1169 |
1150 @deffn Command fill-region-as-paragraph start end &optional justify-flag | 1170 @deffn Command fill-region-as-paragraph start end &optional justify |
1151 This command considers a region of text as a paragraph and fills it. If | 1171 This command considers a region of text as a paragraph and fills it. If |
1152 the region was made up of many paragraphs, the blank lines between | 1172 the region was made up of many paragraphs, the blank lines between |
1153 paragraphs are removed. This function justifies as well as filling when | 1173 paragraphs are removed. This function justifies as well as filling when |
1154 @var{justify-flag} is non-@code{nil}. The precise value of | 1174 @var{justify} is non-@code{nil}. |
1155 @var{justify-flag} specifies a style of justification, as in | |
1156 @code{justify-current-line}, below. | |
1157 | 1175 |
1158 In an interactive call, any prefix argument requests justification. | 1176 In an interactive call, any prefix argument requests justification. |
1159 | 1177 |
1160 In Adaptive Fill mode, which is enabled by default, | 1178 In Adaptive Fill mode, which is enabled by default, |
1161 @code{fill-region-as-paragraph} on an indented paragraph when there is | 1179 @code{fill-region-as-paragraph} on an indented paragraph when there is |
1185 | 1203 |
1186 @defopt default-justification | 1204 @defopt default-justification |
1187 This variable's value specifies the style of justification to use for | 1205 This variable's value specifies the style of justification to use for |
1188 text that doesn't specify a style with a text property. The possible | 1206 text that doesn't specify a style with a text property. The possible |
1189 values are @code{left}, @code{right}, @code{full}, @code{center}, or | 1207 values are @code{left}, @code{right}, @code{full}, @code{center}, or |
1190 @code{none}. | 1208 @code{none}. The default value is @code{left}. |
1191 @end defopt | 1209 @end defopt |
1192 | 1210 |
1193 @defun current-justification | 1211 @defun current-justification |
1194 This function returns the proper justification style to use for filling | 1212 This function returns the proper justification style to use for filling |
1195 the text around point. | 1213 the text around point. |
1196 @end defun | 1214 @end defun |
1215 | |
1216 @defvar fill-paragraph-function | |
1217 This variable provides a way for major modes to override the filling of | |
1218 paragraphs. If the value is non-@code{nil}, @code{fill-paragraph} calls | |
1219 this function to do the work. If the function returns a non-@code{nil} | |
1220 value, @code{fill-paragraph} assumes the job is done, and immediately | |
1221 returns that value. | |
1222 | |
1223 The usual use of this feature is to fill comments in programming | |
1224 language modes. If the function needs to fill a paragraph in the usual | |
1225 way, it can do so as follows: | |
1226 | |
1227 @example | |
1228 (let ((fill-paragraph-function nil)) | |
1229 (fill-paragraph arg)) | |
1230 @end example | |
1231 @end defvar | |
1232 | |
1233 @defvar use-hard-newlines | |
1234 If this variable is non-@code{nil}, the filling functions do not delete | |
1235 newlines that have the @code{hard} text property. These ``hard | |
1236 newlines'' act as paragraph separators. | |
1237 @end defvar | |
1238 | |
1239 @node Margins | |
1240 @section Margins for Filling | |
1197 | 1241 |
1198 @defopt fill-prefix | 1242 @defopt fill-prefix |
1199 This variable specifies a string of text that appears at the beginning | 1243 This variable specifies a string of text that appears at the beginning |
1200 of normal text lines and should be disregarded when filling them. Any | 1244 of normal text lines and should be disregarded when filling them. Any |
1201 line that fails to start with the fill prefix is considered the start of | 1245 line that fails to start with the fill prefix is considered the start of |
1202 a paragraph; so is any line that starts with the fill prefix followed by | 1246 a paragraph; so is any line that starts with the fill prefix followed by |
1203 additional whitespace. Lines that start with the fill prefix but no | 1247 additional whitespace. Lines that start with the fill prefix but no |
1204 additional whitespace are ordinary text lines that can be filled | 1248 additional whitespace are ordinary text lines that can be filled |
1205 together. The resulting filled lines also start with the fill prefix. | 1249 together. The resulting filled lines also start with the fill prefix. |
1250 | |
1251 The fill prefix follows the left margin whitespace, if any. | |
1206 @end defopt | 1252 @end defopt |
1207 | 1253 |
1208 @defopt fill-column | 1254 @defopt fill-column |
1209 This buffer-local variable specifies the maximum width of filled | 1255 This buffer-local variable specifies the maximum width of filled |
1210 lines. Its value should be an integer, which is a number of columns. | 1256 lines. Its value should be an integer, which is a number of columns. |
1223 @code{(default-value 'fill-column)}. | 1269 @code{(default-value 'fill-column)}. |
1224 | 1270 |
1225 The default value for @code{default-fill-column} is 70. | 1271 The default value for @code{default-fill-column} is 70. |
1226 @end defvar | 1272 @end defvar |
1227 | 1273 |
1228 @defvar fill-paragraph-function | |
1229 This variable provides a way for major modes to override the filling of | |
1230 paragraphs. If the value is non-@code{nil}, @code{fill-paragraph} calls | |
1231 this function to do the work. If the function returns a non-@code{nil} | |
1232 value, @code{fill-paragraph} assumes the job is done, and immediately | |
1233 returns that value. | |
1234 | |
1235 The usual use of this feature is to fill comments in programming | |
1236 language modes. If the function needs to fill a paragraph in the usual | |
1237 way, it can do so as follows: | |
1238 | |
1239 @example | |
1240 (let ((fill-paragraph-function nil)) | |
1241 (fill-paragraph arg)) | |
1242 @end example | |
1243 @end defvar | |
1244 | |
1245 @deffn Command set-left-margin from to margin | 1274 @deffn Command set-left-margin from to margin |
1246 This sets the @code{left-margin} property on the text from @var{from} to | 1275 This sets the @code{left-margin} property on the text from @var{from} to |
1247 @var{to} to the value @var{margin}. If Auto Fill mode is enabled, this | 1276 @var{to} to the value @var{margin}. If Auto Fill mode is enabled, this |
1248 command also refills the region to fit the new margin. | 1277 command also refills the region to fit the new margin. |
1249 @end deffn | 1278 @end deffn |
1250 | 1279 |
1251 @deffn Command set-right-margin from to margin | 1280 @deffn Command set-right-margin from to margin |
1252 This sets the @code{fill-colmn} property on the text from @var{from} to | 1281 This sets the @code{right-margin} property on the text from @var{from} |
1253 @var{to} so as to yield a right margin of width @var{margin}. If Auto | 1282 to @var{to} to the value @var{margin}. If Auto Fill mode is enabled, |
1254 Fill mode is enabled, this command also refills the region to fit the | 1283 this command also refills the region to fit the new margin. |
1255 new margin. | |
1256 @end deffn | 1284 @end deffn |
1257 | 1285 |
1258 @defun current-left-margin | 1286 @defun current-left-margin |
1259 This function returns the proper left margin value to use for filling | 1287 This function returns the proper left margin value to use for filling |
1260 the text around point. The value is the sum of the @code{left-margin} | 1288 the text around point. The value is the sum of the @code{left-margin} |
1261 property of the character at the start of the current line (or zero if | 1289 property of the character at the start of the current line (or zero if |
1262 none), plus the value of the variable @code{left-margin}. | 1290 none), and the value of the variable @code{left-margin}. |
1263 @end defun | 1291 @end defun |
1264 | 1292 |
1265 @defun current-fill-column | 1293 @defun current-fill-column |
1266 This function returns the proper fill column value to use for filling | 1294 This function returns the proper fill column value to use for filling |
1267 the text around point. The value is the value of the @code{fill-column} | 1295 the text around point. The value is the value of the @code{fill-column} |
1270 @end defun | 1298 @end defun |
1271 | 1299 |
1272 @deffn Command move-to-left-margin &optional n force | 1300 @deffn Command move-to-left-margin &optional n force |
1273 This function moves point to the left margin of the current line. The | 1301 This function moves point to the left margin of the current line. The |
1274 column moved to is determined by calling the function | 1302 column moved to is determined by calling the function |
1275 @code{current-left-margin}. If the argument @var{n} is specified, | 1303 @code{current-left-margin}. If the argument @var{n} is non-@code{nil}, |
1276 @code{move-to-left-margin} moves forward @var{n}@minus{}1 lines first. | 1304 @code{move-to-left-margin} moves forward @var{n}@minus{}1 lines first. |
1277 | 1305 |
1278 If @var{force} is non-@code{nil}, that says to fix the line's | 1306 If @var{force} is non-@code{nil}, that says to fix the line's |
1279 indentation if that doesn't match the left margin value. | 1307 indentation if that doesn't match the left margin value. |
1280 @end deffn | 1308 @end deffn |
1284 between @var{from} and @var{to}. The amount of indentation | 1312 between @var{from} and @var{to}. The amount of indentation |
1285 to delete is determined by calling @code{current-left-margin}. | 1313 to delete is determined by calling @code{current-left-margin}. |
1286 In no case does this function delete non-whitespace. | 1314 In no case does this function delete non-whitespace. |
1287 @end defun | 1315 @end defun |
1288 | 1316 |
1317 @defun indent-to-left-margin | |
1318 This is the default @code{indent-line-function}, used in Fundamental | |
1319 mode, Text mode, etc. Its effect is to adjust the indentation at the | |
1320 beginning of the current line to the value specified by the variable | |
1321 @code{left-margin}. This may involve either inserting or deleting | |
1322 whitespace. | |
1323 @end defun | |
1324 | |
1325 @defvar left-margin | |
1326 This variable specifies the base left margin column. In Fundamental | |
1327 mode, @key{LFD} indents to this column. This variable automatically | |
1328 becomes buffer-local when set in any fashion. | |
1329 @end defvar | |
1330 | |
1289 @node Auto Filling | 1331 @node Auto Filling |
1290 @comment node-name, next, previous, up | 1332 @comment node-name, next, previous, up |
1291 @section Auto Filling | 1333 @section Auto Filling |
1292 @cindex filling, automatic | 1334 @cindex filling, automatic |
1293 @cindex Auto Fill mode | 1335 @cindex Auto Fill mode |
1294 | 1336 |
1295 Auto Fill mode is a minor mode that fills lines automatically as text | 1337 Auto Fill mode is a minor mode that fills lines automatically as text |
1296 as inserted. This section describes the hook used by Auto Fill mode. | 1338 as inserted. This section describes the hook used by Auto Fill mode. |
1297 For a description of functions that you can call explicitly to fill and | 1339 For a description of functions that you can call explicitly to fill and |
1298 justify existing text, see @ref{Filling}. | 1340 justify existing text, see @ref{Filling}. |
1341 | |
1342 Auto Fill mode also enables the functions that change the margins and | |
1343 justification style to refill portions of the text. @xref{Margins}. | |
1299 | 1344 |
1300 @defvar auto-fill-function | 1345 @defvar auto-fill-function |
1301 The value of this variable should be a function (of no arguments) to be | 1346 The value of this variable should be a function (of no arguments) to be |
1302 called after self-inserting a space or a newline. It may be @code{nil}, | 1347 called after self-inserting a space or a newline. It may be @code{nil}, |
1303 in which case nothing special is done in that case. | 1348 in which case nothing special is done in that case. |
1537 @var{end}, are included in the region sorted. | 1582 @var{end}, are included in the region sorted. |
1538 | 1583 |
1539 Note that @code{sort-columns} uses the @code{sort} utility program, | 1584 Note that @code{sort-columns} uses the @code{sort} utility program, |
1540 and so cannot work properly on text containing tab characters. Use | 1585 and so cannot work properly on text containing tab characters. Use |
1541 @kbd{M-x @code{untabify}} to convert tabs to spaces before sorting. | 1586 @kbd{M-x @code{untabify}} to convert tabs to spaces before sorting. |
1542 | |
1543 The @code{sort-columns} function did not work on VMS prior to Emacs 19. | |
1544 @end deffn | 1587 @end deffn |
1545 | 1588 |
1546 @node Columns | 1589 @node Columns |
1547 @comment node-name, next, previous, up | 1590 @comment node-name, next, previous, up |
1548 @section Counting Columns | 1591 @section Counting Columns |
1686 This command calls the function in @code{indent-line-function} to indent | 1729 This command calls the function in @code{indent-line-function} to indent |
1687 the current line; except that if that function is | 1730 the current line; except that if that function is |
1688 @code{indent-to-left-margin}, it calls @code{insert-tab} instead. (That | 1731 @code{indent-to-left-margin}, it calls @code{insert-tab} instead. (That |
1689 is a trivial command that inserts a tab character.) | 1732 is a trivial command that inserts a tab character.) |
1690 @end deffn | 1733 @end deffn |
1691 | |
1692 @defun indent-to-left-margin | |
1693 This is the default @code{indent-line-function}, used in Fundamental | |
1694 mode, Text mode, etc. Its effect is to adjust the indentation at the | |
1695 beginning of the current line to the value specified by the variable | |
1696 @code{left-margin}. This may involve either inserting or deleting | |
1697 whitespace. | |
1698 @end defun | |
1699 | |
1700 @defvar left-margin | |
1701 This variable specifies the column for @code{indent-to-left-margin} to | |
1702 indent to. In Fundamental mode, @key{LFD} indents to this column. This | |
1703 variable automatically becomes buffer-local when set in any fashion. | |
1704 @end defvar | |
1705 | 1734 |
1706 @deffn Command newline-and-indent | 1735 @deffn Command newline-and-indent |
1707 @comment !!SourceFile simple.el | 1736 @comment !!SourceFile simple.el |
1708 This function inserts a newline, then indents the new line (the one | 1737 This function inserts a newline, then indents the new line (the one |
1709 following the newline just inserted) according to the major mode. | 1738 following the newline just inserted) according to the major mode. |
2105 @end defun | 2134 @end defun |
2106 | 2135 |
2107 @defvar default-text-properties | 2136 @defvar default-text-properties |
2108 This variable holds a property list giving default values for text | 2137 This variable holds a property list giving default values for text |
2109 properties. Whenever a character does not specify a value for a | 2138 properties. Whenever a character does not specify a value for a |
2110 property, the value stored in this list is used instead. Here is an | 2139 property, neither directly nor through a category symbol, the value |
2111 example: | 2140 stored in this list is used instead. Here is an example: |
2112 | 2141 |
2113 @example | 2142 @example |
2114 (setq default-text-properties '(foo 69)) | 2143 (setq default-text-properties '(foo 69)) |
2115 ;; @r{Make sure character 1 has no properties of its own.} | 2144 ;; @r{Make sure character 1 has no properties of its own.} |
2116 (set-text-properties 1 2 nil) | 2145 (set-text-properties 1 2 nil) |
2132 Since text properties are considered part of the buffer's contents, and | 2161 Since text properties are considered part of the buffer's contents, and |
2133 can affect how the buffer looks on the screen, any change in the text | 2162 can affect how the buffer looks on the screen, any change in the text |
2134 properties is considered a buffer modification. Buffer text property | 2163 properties is considered a buffer modification. Buffer text property |
2135 changes are undoable (@pxref{Undo}). | 2164 changes are undoable (@pxref{Undo}). |
2136 | 2165 |
2166 @defun put-text-property start end prop value &optional object | |
2167 This function sets the @var{prop} property to @var{value} for the text | |
2168 between @var{start} and @var{end} in the string or buffer @var{object}. | |
2169 If @var{object} is @code{nil}, it defaults to the current buffer. | |
2170 @end defun | |
2171 | |
2137 @defun add-text-properties start end props &optional object | 2172 @defun add-text-properties start end props &optional object |
2138 This function modifies the text properties for the text between | 2173 This function modifies the text properties for the text between |
2139 @var{start} and @var{end} in the string or buffer @var{object}. If | 2174 @var{start} and @var{end} in the string or buffer @var{object}. If |
2140 @var{object} is @code{nil}, it defaults to the current buffer. | 2175 @var{object} is @code{nil}, it defaults to the current buffer. |
2141 | 2176 |
2153 | 2188 |
2154 @example | 2189 @example |
2155 (add-text-properties @var{start} @var{end} | 2190 (add-text-properties @var{start} @var{end} |
2156 '(comment t face highlight)) | 2191 '(comment t face highlight)) |
2157 @end example | 2192 @end example |
2158 @end defun | |
2159 | |
2160 @defun put-text-property start end prop value &optional object | |
2161 This function sets the @var{prop} property to @var{value} for the text | |
2162 between @var{start} and @var{end} in the string or buffer @var{object}. | |
2163 If @var{object} is @code{nil}, it defaults to the current buffer. | |
2164 @end defun | 2193 @end defun |
2165 | 2194 |
2166 @defun remove-text-properties start end props &optional object | 2195 @defun remove-text-properties start end props &optional object |
2167 This function deletes specified text properties from the text between | 2196 This function deletes specified text properties from the text between |
2168 @var{start} and @var{end} in the string or buffer @var{object}. If | 2197 @var{start} and @var{end} in the string or buffer @var{object}. If |
2212 In typical use of text properties, most of the time several or many | 2241 In typical use of text properties, most of the time several or many |
2213 consecutive characters have the same value for a property. Rather than | 2242 consecutive characters have the same value for a property. Rather than |
2214 writing your programs to examine characters one by one, it is much | 2243 writing your programs to examine characters one by one, it is much |
2215 faster to process chunks of text that have the same property value. | 2244 faster to process chunks of text that have the same property value. |
2216 | 2245 |
2217 Here are functions you can use to do this. In all cases, @var{object} | 2246 Here are functions you can use to do this. They use @code{eq} for |
2218 defaults to the current buffer. | 2247 comparing property values. In all cases, @var{object} defaults to the |
2248 current buffer. | |
2219 | 2249 |
2220 For high performance, it's very important to use the @var{limit} | 2250 For high performance, it's very important to use the @var{limit} |
2221 argument to these functions, especially the ones that search for a | 2251 argument to these functions, especially the ones that search for a |
2222 single property---otherwise, they may spend a long time considering | 2252 single property---otherwise, they may spend a long time scanning to the |
2223 changes in other properties while scanning to the end of the buffer. | 2253 end of the buffer, if the property you are interested in does not change. |
2224 | 2254 |
2225 Remember that a position is always between two characters; the position | 2255 Remember that a position is always between two characters; the position |
2226 returned by these functions is between two characters with different | 2256 returned by these functions is between two characters with different |
2227 properties. | 2257 properties. |
2228 | 2258 |
2312 @end defun | 2342 @end defun |
2313 | 2343 |
2314 @node Special Properties | 2344 @node Special Properties |
2315 @subsection Properties with Special Meanings | 2345 @subsection Properties with Special Meanings |
2316 | 2346 |
2347 Here is a table of text property names that have special built-in | |
2348 meanings. The following section lists a few more special property names | |
2349 that are used to control filling. All other names have no standard | |
2350 meaning, and you can use them as you like. | |
2351 | |
2317 @table @code | 2352 @table @code |
2318 @cindex category of text character | 2353 @cindex category of text character |
2319 @kindex category @r{(text property)} | 2354 @kindex category @r{(text property)} |
2320 @item category | 2355 @item category |
2321 If a character has a @code{category} property, we call it the | 2356 If a character has a @code{category} property, we call it the |
2368 | 2403 |
2369 @item intangible | 2404 @item intangible |
2370 @kindex intangible @r{(text property)} | 2405 @kindex intangible @r{(text property)} |
2371 If a group of consecutive characters have equal and non-@code{nil} | 2406 If a group of consecutive characters have equal and non-@code{nil} |
2372 @code{intangible} properties, then you cannot place point between them. | 2407 @code{intangible} properties, then you cannot place point between them. |
2373 If you move point forward into the group, point actually moves to the | 2408 If you try to move point forward into the group, point actually moves to |
2374 end of the group. If you try to move point backward into the group, | 2409 the end of the group. If you try to move point backward into the group, |
2375 point actually moves to the start of the group. | 2410 point actually moves to the start of the group. |
2376 | 2411 |
2377 When the variable @code{inhibit-point-motion-hooks} is non-@code{nil}, | 2412 When the variable @code{inhibit-point-motion-hooks} is non-@code{nil}, |
2378 the @code{intangible} property is ignored. | 2413 the @code{intangible} property is ignored. |
2379 | 2414 |
2442 @code{point-entered} hooks are not run, and the @code{intangible} | 2477 @code{point-entered} hooks are not run, and the @code{intangible} |
2443 property has no effect. | 2478 property has no effect. |
2444 @end defvar | 2479 @end defvar |
2445 | 2480 |
2446 @node Format Properties | 2481 @node Format Properties |
2447 @section Formatted Text Properties | 2482 @subsection Formatted Text Properties |
2448 | 2483 |
2449 These text properties affect the behavior of the fill commands. They | 2484 These text properties affect the behavior of the fill commands. They |
2450 are used for representing formatted text. @xref{Filling}. | 2485 are used for representing formatted text. @xref{Filling}, and |
2451 | 2486 @ref{Margins}. |
2452 @table code | 2487 |
2488 @table @code | |
2453 @item hard | 2489 @item hard |
2454 If a newline character has this property, it is a ``hard'' newline. | 2490 If a newline character has this property, it is a ``hard'' newline. |
2455 The fill commands do not alter hard newlines and do not move words | 2491 The fill commands do not alter hard newlines and do not move words |
2456 across them. However, this property takes effect only if the variable | 2492 across them. However, this property takes effect only if the variable |
2457 @code{use-hard-newlines} is non-@code{nil}. | 2493 @code{use-hard-newlines} is non-@code{nil}. |
2458 | 2494 |
2459 @item right-margin | 2495 @item right-margin |
2460 This property specifies the right margin for filling this part of the | 2496 This property specifies an extra right margin for filling this part of the |
2461 text. | 2497 text. |
2462 | 2498 |
2463 @item left-margin | 2499 @item left-margin |
2464 This property specifies the left margin for filling this part of the | 2500 This property specifies an extra left margin for filling this part of the |
2465 text. | 2501 text. |
2466 | 2502 |
2467 @item justification | 2503 @item justification |
2468 This property specifies the style of justification for filling this part | 2504 This property specifies the style of justification for filling this part |
2469 of the text. | 2505 of the text. |
2539 @cindex saving text properties | 2575 @cindex saving text properties |
2540 | 2576 |
2541 You can save text properties in files, and restore text properties | 2577 You can save text properties in files, and restore text properties |
2542 when inserting the files, using these two hooks: | 2578 when inserting the files, using these two hooks: |
2543 | 2579 |
2544 @defvar write-region-annotation-functions | 2580 @defvar write-region-annotate-functions |
2545 This variable's value is a list of functions for @code{write-region} to | 2581 This variable's value is a list of functions for @code{write-region} to |
2546 run to encode text properties in some fashion as annotations to the text | 2582 run to encode text properties in some fashion as annotations to the text |
2547 being written in the file. @xref{Writing to Files}. | 2583 being written in the file. @xref{Writing to Files}. |
2548 | 2584 |
2549 Each function in the list is called with two arguments: the start and | 2585 Each function in the list is called with two arguments: the start and |
2594 | 2630 |
2595 We suggest not trying to handle arbitrary Lisp objects as property | 2631 We suggest not trying to handle arbitrary Lisp objects as property |
2596 names or property values---because a program that general is probably | 2632 names or property values---because a program that general is probably |
2597 difficult to write, and slow. Instead, choose a set of possible data | 2633 difficult to write, and slow. Instead, choose a set of possible data |
2598 types that are reasonably flexible, and not too hard to encode. | 2634 types that are reasonably flexible, and not too hard to encode. |
2635 | |
2636 @xref{Format Conversion}, for a related feature. | |
2637 | |
2638 @c ??? In next edition, merge this info Format Conversion. | |
2599 | 2639 |
2600 @node Not Intervals | 2640 @node Not Intervals |
2601 @subsection Why Text Properties are not Intervals | 2641 @subsection Why Text Properties are not Intervals |
2602 @cindex intervals | 2642 @cindex intervals |
2603 | 2643 |
2657 with the character @var{new-char} in the region of the current buffer | 2697 with the character @var{new-char} in the region of the current buffer |
2658 defined by @var{start} and @var{end}. | 2698 defined by @var{start} and @var{end}. |
2659 | 2699 |
2660 @cindex Outline mode | 2700 @cindex Outline mode |
2661 @cindex undo avoidance | 2701 @cindex undo avoidance |
2662 If @var{noundo} is non-@code{nil}, then @code{subst-char-in-region} | 2702 If @var{noundo} is non-@code{nil}, then @code{subst-char-in-region} does |
2663 does not record the change for undo and does not mark the buffer as | 2703 not record the change for undo and does not mark the buffer as modified. |
2664 modified. This feature is useful for changes that are not considered | 2704 This feature is used for controlling selective display (@pxref{Selective |
2665 significant, such as when Outline mode changes visible lines to | 2705 Display}). |
2666 invisible lines and vice versa. | |
2667 | 2706 |
2668 @code{subst-char-in-region} does not move point and returns | 2707 @code{subst-char-in-region} does not move point and returns |
2669 @code{nil}. | 2708 @code{nil}. |
2670 | 2709 |
2671 @example | 2710 @example |
2698 | 2737 |
2699 The return value of @code{translate-region} is the number of | 2738 The return value of @code{translate-region} is the number of |
2700 characters that were actually changed by the translation. This does | 2739 characters that were actually changed by the translation. This does |
2701 not count characters that were mapped into themselves in the | 2740 not count characters that were mapped into themselves in the |
2702 translation table. | 2741 translation table. |
2703 | |
2704 This function is available in Emacs versions 19 and later. | |
2705 @end defun | 2742 @end defun |
2706 | 2743 |
2707 @node Registers | 2744 @node Registers |
2708 @section Registers | 2745 @section Registers |
2709 @cindex registers | 2746 @cindex registers |
2873 beginning from the region end.) All three arguments are integers. The | 2910 beginning from the region end.) All three arguments are integers. The |
2874 buffer that's about to change is always the current buffer. | 2911 buffer that's about to change is always the current buffer. |
2875 @end defvar | 2912 @end defvar |
2876 | 2913 |
2877 @defvar before-change-function | 2914 @defvar before-change-function |
2878 This variable holds one function to call before any buffer modification | 2915 This obsolete variable holds one function to call before any buffer |
2879 (or @code{nil} for no function). It is called just like the functions | 2916 modification (or @code{nil} for no function). It is called just like |
2880 in @code{before-change-functions}. | 2917 the functions in @code{before-change-functions}. |
2881 @end defvar | 2918 @end defvar |
2882 | 2919 |
2883 @defvar after-change-function | 2920 @defvar after-change-function |
2884 This variable holds one function to call after any buffer modification | 2921 This obsolete variable holds one function to call after any buffer modification |
2885 (or @code{nil} for no function). It is called just like the functions in | 2922 (or @code{nil} for no function). It is called just like the functions in |
2886 @code{after-change-functions}. | 2923 @code{after-change-functions}. |
2887 @end defvar | 2924 @end defvar |
2888 | 2925 |
2889 The four variables above are temporarily bound to @code{nil} during the | 2926 The four variables above are temporarily bound to @code{nil} during the |
2914 | 2951 |
2915 @defvar first-change-hook | 2952 @defvar first-change-hook |
2916 This variable is a normal hook that is run whenever a buffer is changed | 2953 This variable is a normal hook that is run whenever a buffer is changed |
2917 that was previously in the unmodified state. | 2954 that was previously in the unmodified state. |
2918 @end defvar | 2955 @end defvar |
2919 | |
2920 The variables described in this section are meaningful only starting | |
2921 with Emacs version 19. |