comparison man/lispref/text.texi @ 2256:6ffd69eff907

[xemacs-hg @ 2004-09-08 17:40:14 by james] Document field interface.
author james
date Wed, 08 Sep 2004 17:40:20 +0000
parents 37e56e920ac5
children 6772ce4d982b
comparison
equal deleted inserted replaced
2255:03d9d549c3fa 2256:6ffd69eff907
2125 * Changing Properties:: Setting the properties of a range of text. 2125 * Changing Properties:: Setting the properties of a range of text.
2126 * Property Search:: Searching for where a property changes value. 2126 * Property Search:: Searching for where a property changes value.
2127 * Special Properties:: Particular properties with special meanings. 2127 * Special Properties:: Particular properties with special meanings.
2128 * Saving Properties:: Saving text properties in files, and reading 2128 * Saving Properties:: Saving text properties in files, and reading
2129 them back. 2129 them back.
2130 * Fields:: Emacs-compatible text fields.
2130 @end menu 2131 @end menu
2131 2132
2132 @node Examining Properties 2133 @node Examining Properties
2133 @subsection Examining Text Properties 2134 @subsection Examining Text Properties
2134 2135
2457 difficult to write, and slow. Instead, choose a set of possible data 2458 difficult to write, and slow. Instead, choose a set of possible data
2458 types that are reasonably flexible, and not too hard to encode. 2459 types that are reasonably flexible, and not too hard to encode.
2459 2460
2460 @xref{Format Conversion}, for a related feature. 2461 @xref{Format Conversion}, for a related feature.
2461 2462
2463 @node Fields
2464 @subsection Fields
2465 @cindex text fields
2466 @cindex fields
2467
2468 Emacs supplies a notion of a @emph{text field}, which is a region of
2469 text where every character has the same value of the @code{field}
2470 property. It is used to identify regions of a buffer used for
2471 communicating with an external process, for example. XEmacs supplies a
2472 compatible interface. In XEmacs, the @code{field} property can be set
2473 as either an extent property or a text property, mirroring the Emacs
2474 capability of using either overlays or text properties.
2475
2476 The field manipulating functions take a buffer position as the
2477 field-identifying argument, defaulting to point. This really means the
2478 field containing that buffer position. Consecutive buffer positions
2479 with no @code{field} property are considered an ``empty'' field. There
2480 is some ambiguity when a specified buffer position falls at the very
2481 beginning or the very end of a field: does it belong to the preceding or
2482 the following field? The answer depends on the openness or closedness
2483 of the corresponding extents (@pxref{Extent Endpoints}). A buffer
2484 position corresponds to the field whose property would be inherited by a
2485 character inserted at that position. If the buffer position is between
2486 an end-open and a start-open extent, then it corresponds to an empty
2487 field at that position, since an inserted character will belong to
2488 neither extent.
2489
2490 @defvar inhibit-field-text-motion
2491 This variable controls whether the text motion commands notice fields or
2492 not. When it is nil (the default), commands such as beginning-of-line
2493 will try to move only within fields.
2494 @end defvar
2495
2496 @defun make-field value from to &optional buffer
2497 There is no Emacs counterpart to this function. The default open and
2498 closedness of extents in XEmacs is opposite to the default for Emacs
2499 overlays. Hence, fields based on extents in XEmacs behave differently
2500 from the equivalent fields based on overlays in Emacs. This function
2501 creates a field with value @var{value} over the region @var{from} to
2502 @var{to} in @var{buffer}, which defaults to the current buffer, with the
2503 default Emacs open and closedness.
2504 @end defun
2505
2506 @defun find-field &optional pos merge-at-boundary beg-limit end-limit
2507 There is no (Lisp-visible) Emacs counterpart to this function. It is
2508 the workhorse for the other functions. It returns a dotted pair
2509 @code{(start . stop)} holding the endpoints of the field matching a
2510 specification. If @var{pos} is non-@code{nil}, it specifies a buffer
2511 position whose enclosing field should be found; otherwise, the value of
2512 point is used.
2513
2514 If @var{merge-at-boundary} is non-@code{nil}, then two changes are made
2515 to the search algorithm. First, if @var{pos} is at the very first
2516 position of a field, then the beginning of the previous field is
2517 returned instead of the beginning of @var{pos}'s field. Second, if the
2518 value of the @code{field} property at @var{pos} is the symbol
2519 @code{boundary}, then the beginning of the field before the boundary
2520 field and the end of the field after the boundary field are returned.
2521
2522 If @var{beg-limit} is a buffer position, and the start position that
2523 would be returned is less than @var{beg-limit}, then @var{beg-limit} is
2524 returned instead. Likewise, if @var{end-limit} is a buffer position,
2525 and the stop position that would be returned is greater than
2526 @var{end-limit}, then @var{end-limit} is returned instead.
2527 @end defun
2528
2529 @defun delete-field &optional pos
2530 Delete the text of the field at @var{pos}.
2531 @end defun
2532
2533 @defun field-string &optional pos
2534 Return the contents of the field at @var{pos} as a string.
2535 @end defun
2536
2537 @defun field-string-no-properties &optional pos
2538 Return the contents of the field at @var{pos} as a string, without text
2539 properties.
2540 @end defun
2541
2542 @defun field-beginning &optional pos escape-from-edge limit
2543 Return the beginning of the field at @var{pos}. If
2544 @var{escape-from-edge} is non-nil and @var{pos} is at the beginning of a
2545 field, then the beginning of the field that ends at @var{pos} is
2546 returned instead. If @var{limit} is a buffer position and the returned
2547 value would be less than @var{limit}, then @var{limit} is returned
2548 instead.
2549 @end defun
2550
2551 @defun field-end &optional pos escape-from-edge limit
2552 Return the end of the field at @var{pos}. If @var{escape-from-edge} is
2553 non-nil and @var{pos} is at the end of a field, then the end of the
2554 field that begins at @var{pos} is returned instead. If @var{limit} is a
2555 buffer position and the returned value would be greater than
2556 @var{limit}, then @var{limit} is returned instead.
2557 @end defun
2558
2559 @defun constrain-to-field new-pos old-pos &optional escape-from-edge only-in-line inhibit-capture-property
2560 Return the position closest to @var{new-pos} that is in the same field
2561 as @var{old-pos}. If @var{new-pos} is @code{nil}, then the value of
2562 point is used instead @emph{and} point is set to the value that is
2563 returned.
2564
2565 If @var{escape-from-edge} is non-@code{nil} and @var{old-pos} is at the
2566 boundary of two fields, then the two adjacent fields are considered one
2567 field. Furthermore, if @var{new-pos} is in a field whose @code{field}
2568 property is the symbol @code{boundary}, then the preceding field, the
2569 boundary field, and the following field are considered one field.
2570
2571 If @var{only-in-line} is non-@code{nil} and the returned position would
2572 be on a different line than @var{new-pos}, return @var{new-pos} instead.
2573
2574 If @var{inhibit-capture-property} is non-@code{nil} and the character at
2575 @var{old-pos} has a property of the same name as the value of
2576 @var{inhibit-capture-property}, then all field boundaries are ignored;
2577 i.e., @var{new-pos} is returned.
2578
2579 If @var{inhibit-field-text-motion} is non-@code{nil}, then all field
2580 boundaries are ignored and this function always returns @var{new-pos}.
2581 @end defun
2582
2462 @node Substitution 2583 @node Substitution
2463 @section Substituting for a Character Code 2584 @section Substituting for a Character Code
2464 2585
2465 The following functions replace characters within a specified region 2586 The following functions replace characters within a specified region
2466 based on their character codes. 2587 based on their character codes.