comparison man/lispref/text.texi @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents d883f39b8495
children 697ef44129c6
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
68 is omitted. (In FSF Emacs, and earlier versions of XEmacs, these 68 is omitted. (In FSF Emacs, and earlier versions of XEmacs, these
69 functions usually did not have these optional @var{buffer} arguments 69 functions usually did not have these optional @var{buffer} arguments
70 and always operated on the current buffer.) 70 and always operated on the current buffer.)
71 71
72 72
73 @defun char-after position &optional buffer 73 @defun char-after &optional position buffer
74 This function returns the character in the buffer at (i.e., 74 This function returns the character in the buffer at (i.e.,
75 immediately after) position @var{position}. If @var{position} is out of 75 immediately after) position @var{position}. If @var{position} is out of
76 range for this purpose, either before the beginning of the buffer, or at 76 range for this purpose, either before the beginning of the buffer, or at
77 or beyond the end, then the value is @code{nil}. If optional argument 77 or beyond the end, then the value is @code{nil}. The default for
78 @var{buffer} is @code{nil}, the current buffer is assumed. 78 @var{position} is point. If optional argument @var{buffer} is
79 @code{nil}, the current buffer is assumed.
79 80
80 In the following example, assume that the first character in the 81 In the following example, assume that the first character in the
81 buffer is @samp{@@}: 82 buffer is @samp{@@}:
82 83
83 @example 84 @example
84 @group 85 @group
85 (char-to-string (char-after 1)) 86 (char-to-string (char-after 1))
86 @result{} "@@" 87 @result{} "@@"
87 @end group 88 @end group
88 @end example 89 @end example
90 @end defun
91
92 @defun char-before &optional position buffer
93 This function returns the character in the current buffer immediately
94 before position @var{position}. If @var{position} is out of range for
95 this purpose, either at or before the beginning of the buffer, or beyond
96 the end, then the value is @code{nil}. The default for
97 @var{position} is point. If optional argument @var{buffer} is
98 @code{nil}, the current buffer is assumed.
89 @end defun 99 @end defun
90 100
91 @defun following-char &optional buffer 101 @defun following-char &optional buffer
92 This function returns the character following point in the buffer. 102 This function returns the character following point in the buffer.
93 This is similar to @code{(char-after (point))}. However, if point is at 103 This is similar to @code{(char-after (point))}. However, if point is at
1476 Alphabetical sorting means that two sort keys are compared by 1486 Alphabetical sorting means that two sort keys are compared by
1477 comparing the first characters of each, the second characters of each, 1487 comparing the first characters of each, the second characters of each,
1478 and so on. If a mismatch is found, it means that the sort keys are 1488 and so on. If a mismatch is found, it means that the sort keys are
1479 unequal; the sort key whose character is less at the point of first 1489 unequal; the sort key whose character is less at the point of first
1480 mismatch is the lesser sort key. The individual characters are compared 1490 mismatch is the lesser sort key. The individual characters are compared
1481 according to their numerical values. Since Emacs uses the @sc{ASCII} 1491 according to their numerical values. Since Emacs uses the @sc{ascii}
1482 character set, the ordering in that set determines alphabetical order. 1492 character set, the ordering in that set determines alphabetical order.
1483 @c version 19 change 1493 @c version 19 change
1484 1494
1485 The value of the @var{record-regexp} argument specifies how to divide 1495 The value of the @var{record-regexp} argument specifies how to divide
1486 the buffer into sort records. At the end of each record, a search is 1496 the buffer into sort records. At the end of each record, a search is
2462 @end example 2472 @end example
2463 @end defun 2473 @end defun
2464 2474
2465 @defun translate-region start end table 2475 @defun translate-region start end table
2466 This function applies a translation table to the characters in the 2476 This function applies a translation table to the characters in the
2467 buffer between positions @var{start} and @var{end}. 2477 buffer between positions @var{start} and @var{end}. The translation
2468 2478 table @var{table} can be either a string, a vector, or a char-table.
2469 The translation table @var{table} is a string; @code{(aref @var{table} 2479
2470 @var{ochar})} gives the translated character corresponding to 2480 If @var{table} is a string, its @var{n}th element is the mapping for the
2471 @var{ochar}. If the length of @var{table} is less than 256, any 2481 character with code @var{n}.
2472 characters with codes larger than the length of @var{table} are not 2482
2473 altered by the translation. 2483 If @var{table} is a vector, its @var{n}th element is the mapping for
2484 character with code @var{n}. Legal mappings are characters, strings, or
2485 @code{nil} (meaning don't replace.)
2486
2487 If @var{table} is a char-table, its elements describe the mapping
2488 between characters and their replacements. The char-table should be of
2489 type @code{char} or @code{generic}.
2490
2491 When the @var{table} is a string or vector and its length is less than
2492 the total number of characters (256 without Mule), any characters with
2493 codes larger than the length of @var{table} are not altered by the
2494 translation.
2474 2495
2475 The return value of @code{translate-region} is the number of 2496 The return value of @code{translate-region} is the number of
2476 characters that were actually changed by the translation. This does 2497 characters that were actually changed by the translation. This does
2477 not count characters that were mapped into themselves in the 2498 not count characters that were mapped into themselves in the
2478 translation table. 2499 translation table.
2500
2501 @strong{NOTE}: Prior to XEmacs 21.2, the @var{table} argument was
2502 allowed only to be a string. This is still the case in FSF Emacs.
2503
2504 The following example creates a char-table that is passed to
2505 @code{translate-region}, which translates character @samp{a} to
2506 @samp{the letter a}, removes character @samp{b}, and translates
2507 character @samp{c} to newline.
2508
2509 @example
2510 @group
2511 ---------- Buffer: foo ----------
2512 Here is a sentence in the buffer.
2513 ---------- Buffer: foo ----------
2514 @end group
2515
2516 @group
2517 (let ((table (make-char-table 'generic)))
2518 (put-char-table ?a "the letter a" table)
2519 (put-char-table ?b "" table)
2520 (put-char-table ?c ?\n table)
2521 (translate-region (point-min) (point-max) table))
2522 @result{} 3
2523
2524 ---------- Buffer: foo ----------
2525 Here is the letter a senten
2526 e in the uffer.
2527 ---------- Buffer: foo ----------
2528 @end group
2529 @end example
2479 @end defun 2530 @end defun
2480 2531
2481 @node Registers 2532 @node Registers
2482 @section Registers 2533 @section Registers
2483 @cindex registers 2534 @cindex registers