Mercurial > emacs
comparison lispref/text.texi @ 15760:0489cb739a5f
(Lazy Properties): New node.
(buffer-undo-list): New type of element for marker adjustment.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 23 Jul 1996 15:36:22 +0000 |
parents | acb0ab49f4e7 |
children | 71e49abd5906 |
comparison
equal
deleted
inserted
replaced
15759:e74f36ff89e7 | 15760:0489cb739a5f |
---|---|
984 | 984 |
985 @example | 985 @example |
986 (put-text-property @var{beg} @var{end} @var{property} @var{value}) | 986 (put-text-property @var{beg} @var{end} @var{property} @var{value}) |
987 @end example | 987 @end example |
988 | 988 |
989 @item (@var{marker} . @var{adjustment}) | |
990 This kind of element records the fact that the marker @var{marker} was | |
991 relocated due to deletion of surrounding text, and that it moved | |
992 @var{adjustment} character positions. Undoing this element moves | |
993 @var{marker} @minus{} @var{adjustment} characters. | |
994 | |
989 @item @var{position} | 995 @item @var{position} |
990 This element indicates where point was at an earlier time. Undoing this | 996 This element indicates where point was at an earlier time. Undoing this |
991 element sets point to @var{position}. Deletion normally creates an | 997 element sets point to @var{position}. Deletion normally creates an |
992 element of this kind as well as a reinsertion element. | 998 element of this kind as well as a reinsertion element. |
993 | 999 |
2086 * Format Properties:: Properties for representing formatting of text. | 2092 * Format Properties:: Properties for representing formatting of text. |
2087 * Sticky Properties:: How inserted text gets properties from | 2093 * Sticky Properties:: How inserted text gets properties from |
2088 neighboring text. | 2094 neighboring text. |
2089 * Saving Properties:: Saving text properties in files, and reading | 2095 * Saving Properties:: Saving text properties in files, and reading |
2090 them back. | 2096 them back. |
2097 * Lazy Properties:: Computing text properties in a lazy fashion | |
2098 only when text is examined. | |
2091 * Not Intervals:: Why text properties do not use | 2099 * Not Intervals:: Why text properties do not use |
2092 Lisp-visible text intervals. | 2100 Lisp-visible text intervals. |
2093 @end menu | 2101 @end menu |
2094 | 2102 |
2095 @node Examining Properties | 2103 @node Examining Properties |
2637 | 2645 |
2638 @xref{Format Conversion}, for a related feature. | 2646 @xref{Format Conversion}, for a related feature. |
2639 | 2647 |
2640 @c ??? In next edition, merge this info Format Conversion. | 2648 @c ??? In next edition, merge this info Format Conversion. |
2641 | 2649 |
2650 @node Lazy Properties | |
2651 @subsection Lazy Computation of Text Properties | |
2652 | |
2653 Instead of computing text properties for all the text in the buffer, | |
2654 you can arrange to compute the text properties for parts of the text | |
2655 when and if something depends on them. | |
2656 | |
2657 The primitive that extracts text from the buffer along with its | |
2658 properties is @code{buffer-substring}. Before examining the properties, | |
2659 this function runs the abnormal hook @code{buffer-access-fontify-functions}. | |
2660 | |
2661 @defvar buffer-access-fontify-functions | |
2662 This variable holds a list of functions for computing text properties. | |
2663 Before @code{buffer-substring} copies the text and text properties for a | |
2664 portion of the buffer, it calls all the functions in this list. Each of | |
2665 the functions receives two arguments that specify the range of the | |
2666 buffer being accessed. (The buffer itself is always the current | |
2667 buffer.) | |
2668 @end defvar | |
2669 | |
2670 The function @code{buffer-substring-no-properties} does not call these | |
2671 functions, since it ignores text properties anyway. | |
2672 | |
2673 In order to prevent the hook functions from being called more than | |
2674 once for the same part of the buffer, you can use the variable | |
2675 @code{buffer-access-fontified-property}. | |
2676 | |
2677 @defvar buffer-access-fontified-property | |
2678 If this value's variable is non-@code{nil}, it is a symbol which is used | |
2679 as a text property name. A non-@code{nil} value for that text property | |
2680 means, ``the other text properties for this character have already been | |
2681 computed.'' | |
2682 | |
2683 If all the characters in the range specified for @code{buffer-substring} | |
2684 have a non-@code{nil} value for this property, @code{buffer-substring} | |
2685 does not call the @code{buffer-access-fontify-functions} functions. It | |
2686 assumes these characters already have the right text properties, and | |
2687 just copies the properties they already have. | |
2688 | |
2689 The normal way to use this feature is that the | |
2690 @code{buffer-access-fontify-functions} functions add this property, as | |
2691 well as others, to the characters they operate on. That way, they avoid | |
2692 being called over and over for the same text. | |
2693 @end defvar | |
2694 | |
2642 @node Not Intervals | 2695 @node Not Intervals |
2643 @subsection Why Text Properties are not Intervals | 2696 @subsection Why Text Properties are not Intervals |
2644 @cindex intervals | 2697 @cindex intervals |
2645 | 2698 |
2646 Some editors that support adding attributes to text in the buffer do | 2699 Some editors that support adding attributes to text in the buffer do |