diff options
| author | Stefan Monnier | 2003-05-17 18:47:18 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-17 18:47:18 +0000 |
| commit | 4867a28394c1af8f26428bb8e7f2e17d3823fba0 (patch) | |
| tree | 0f8bfb45afbfb4ce635f9e7e30ab51b8cb17ab2e /src | |
| parent | dfe6cbf8f308376e8bc0dd16056cf27849250c75 (diff) | |
| download | emacs-4867a28394c1af8f26428bb8e7f2e17d3823fba0.tar.gz emacs-4867a28394c1af8f26428bb8e7f2e17d3823fba0.zip | |
(create_root_interval, graft_intervals_into_buffer): Use BEG.
(merge_properties, intervals_equal, merge_properties_sticky): Use XCAR, XCDR.
(adjust_for_invis_intang): Pass new arg to text_property_stickiness.
(get_local_map): Use get_pos_property (for stickiness and empty overlays).
Diffstat (limited to 'src')
| -rw-r--r-- | src/intervals.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/src/intervals.c b/src/intervals.c index 21048f93cb1..a9e36f8b9b1 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Code for doing intervals. | 1 | /* Code for doing intervals. |
| 2 | Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002, 2003 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -77,7 +77,7 @@ create_root_interval (parent) | |||
| 77 | - BUF_BEG (XBUFFER (parent))); | 77 | - BUF_BEG (XBUFFER (parent))); |
| 78 | CHECK_TOTAL_LENGTH (new); | 78 | CHECK_TOTAL_LENGTH (new); |
| 79 | BUF_INTERVALS (XBUFFER (parent)) = new; | 79 | BUF_INTERVALS (XBUFFER (parent)) = new; |
| 80 | new->position = 1; | 80 | new->position = BEG; |
| 81 | } | 81 | } |
| 82 | else if (STRINGP (parent)) | 82 | else if (STRINGP (parent)) |
| 83 | { | 83 | { |
| @@ -121,20 +121,21 @@ merge_properties (source, target) | |||
| 121 | MERGE_INTERVAL_CACHE (source, target); | 121 | MERGE_INTERVAL_CACHE (source, target); |
| 122 | 122 | ||
| 123 | o = source->plist; | 123 | o = source->plist; |
| 124 | while (! EQ (o, Qnil)) | 124 | while (CONSP (o)) |
| 125 | { | 125 | { |
| 126 | sym = Fcar (o); | 126 | sym = XCAR (o); |
| 127 | val = Fmemq (sym, target->plist); | 127 | val = Fmemq (sym, target->plist); |
| 128 | 128 | ||
| 129 | if (NILP (val)) | 129 | if (NILP (val)) |
| 130 | { | 130 | { |
| 131 | o = Fcdr (o); | 131 | o = XCDR (o); |
| 132 | val = Fcar (o); | 132 | CHECK_CONS (o); |
| 133 | val = XCAR (o); | ||
| 133 | target->plist = Fcons (sym, Fcons (val, target->plist)); | 134 | target->plist = Fcons (sym, Fcons (val, target->plist)); |
| 134 | o = Fcdr (o); | 135 | o = XCDR (o); |
| 135 | } | 136 | } |
| 136 | else | 137 | else |
| 137 | o = Fcdr (Fcdr (o)); | 138 | o = Fcdr (XCDR (o)); |
| 138 | } | 139 | } |
| 139 | } | 140 | } |
| 140 | 141 | ||
| @@ -159,13 +160,13 @@ intervals_equal (i0, i1) | |||
| 159 | abort (); | 160 | abort (); |
| 160 | i1_len /= 2; | 161 | i1_len /= 2; |
| 161 | i0_cdr = i0->plist; | 162 | i0_cdr = i0->plist; |
| 162 | while (!NILP (i0_cdr)) | 163 | while (CONSP (i0_cdr)) |
| 163 | { | 164 | { |
| 164 | /* Lengths of the two plists were unequal. */ | 165 | /* Lengths of the two plists were unequal. */ |
| 165 | if (i1_len == 0) | 166 | if (i1_len == 0) |
| 166 | return 0; | 167 | return 0; |
| 167 | 168 | ||
| 168 | i0_sym = Fcar (i0_cdr); | 169 | i0_sym = XCAR (i0_cdr); |
| 169 | i1_val = Fmemq (i0_sym, i1->plist); | 170 | i1_val = Fmemq (i0_sym, i1->plist); |
| 170 | 171 | ||
| 171 | /* i0 has something i1 doesn't. */ | 172 | /* i0 has something i1 doesn't. */ |
| @@ -173,11 +174,12 @@ intervals_equal (i0, i1) | |||
| 173 | return 0; | 174 | return 0; |
| 174 | 175 | ||
| 175 | /* i0 and i1 both have sym, but it has different values in each. */ | 176 | /* i0 and i1 both have sym, but it has different values in each. */ |
| 176 | i0_cdr = Fcdr (i0_cdr); | 177 | i0_cdr = XCDR (i0_cdr); |
| 177 | if (! EQ (Fcar (Fcdr (i1_val)), Fcar (i0_cdr))) | 178 | CHECK_CONS (i0_cdr); |
| 179 | if (!EQ (Fcar (Fcdr (i1_val)), XCAR (i0_cdr))) | ||
| 178 | return 0; | 180 | return 0; |
| 179 | 181 | ||
| 180 | i0_cdr = Fcdr (i0_cdr); | 182 | i0_cdr = XCDR (i0_cdr); |
| 181 | i1_len--; | 183 | i1_len--; |
| 182 | } | 184 | } |
| 183 | 185 | ||
| @@ -666,8 +668,8 @@ find_interval (tree, position) | |||
| 666 | else | 668 | else |
| 667 | { | 669 | { |
| 668 | tree->position | 670 | tree->position |
| 669 | = (position - relative_position /* the left edge of *tree */ | 671 | = (position - relative_position /* left edge of *tree. */ |
| 670 | + LEFT_TOTAL_LENGTH (tree)); /* the left edge of this interval */ | 672 | + LEFT_TOTAL_LENGTH (tree)); /* left edge of this interval. */ |
| 671 | 673 | ||
| 672 | return tree; | 674 | return tree; |
| 673 | } | 675 | } |
| @@ -1125,19 +1127,19 @@ merge_properties_sticky (pleft, pright) | |||
| 1125 | rrear = textget (pright, Qrear_nonsticky); | 1127 | rrear = textget (pright, Qrear_nonsticky); |
| 1126 | 1128 | ||
| 1127 | /* Go through each element of PRIGHT. */ | 1129 | /* Go through each element of PRIGHT. */ |
| 1128 | for (tail1 = pright; CONSP (tail1); tail1 = Fcdr (Fcdr (tail1))) | 1130 | for (tail1 = pright; CONSP (tail1); tail1 = Fcdr (XCDR (tail1))) |
| 1129 | { | 1131 | { |
| 1130 | Lisp_Object tmp; | 1132 | Lisp_Object tmp; |
| 1131 | 1133 | ||
| 1132 | sym = Fcar (tail1); | 1134 | sym = XCAR (tail1); |
| 1133 | 1135 | ||
| 1134 | /* Sticky properties get special treatment. */ | 1136 | /* Sticky properties get special treatment. */ |
| 1135 | if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) | 1137 | if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) |
| 1136 | continue; | 1138 | continue; |
| 1137 | 1139 | ||
| 1138 | rval = Fcar (Fcdr (tail1)); | 1140 | rval = Fcar (XCDR (tail1)); |
| 1139 | for (tail2 = pleft; CONSP (tail2); tail2 = Fcdr (Fcdr (tail2))) | 1141 | for (tail2 = pleft; CONSP (tail2); tail2 = Fcdr (XCDR (tail2))) |
| 1140 | if (EQ (sym, Fcar (tail2))) | 1142 | if (EQ (sym, XCAR (tail2))) |
| 1141 | break; | 1143 | break; |
| 1142 | 1144 | ||
| 1143 | /* Indicate whether the property is explicitly defined on the left. | 1145 | /* Indicate whether the property is explicitly defined on the left. |
| @@ -1183,24 +1185,24 @@ merge_properties_sticky (pleft, pright) | |||
| 1183 | } | 1185 | } |
| 1184 | 1186 | ||
| 1185 | /* Now go through each element of PLEFT. */ | 1187 | /* Now go through each element of PLEFT. */ |
| 1186 | for (tail2 = pleft; CONSP (tail2); tail2 = Fcdr (Fcdr (tail2))) | 1188 | for (tail2 = pleft; CONSP (tail2); tail2 = Fcdr (XCDR (tail2))) |
| 1187 | { | 1189 | { |
| 1188 | Lisp_Object tmp; | 1190 | Lisp_Object tmp; |
| 1189 | 1191 | ||
| 1190 | sym = Fcar (tail2); | 1192 | sym = XCAR (tail2); |
| 1191 | 1193 | ||
| 1192 | /* Sticky properties get special treatment. */ | 1194 | /* Sticky properties get special treatment. */ |
| 1193 | if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) | 1195 | if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) |
| 1194 | continue; | 1196 | continue; |
| 1195 | 1197 | ||
| 1196 | /* If sym is in PRIGHT, we've already considered it. */ | 1198 | /* If sym is in PRIGHT, we've already considered it. */ |
| 1197 | for (tail1 = pright; CONSP (tail1); tail1 = Fcdr (Fcdr (tail1))) | 1199 | for (tail1 = pright; CONSP (tail1); tail1 = Fcdr (XCDR (tail1))) |
| 1198 | if (EQ (sym, Fcar (tail1))) | 1200 | if (EQ (sym, XCAR (tail1))) |
| 1199 | break; | 1201 | break; |
| 1200 | if (! NILP (tail1)) | 1202 | if (! NILP (tail1)) |
| 1201 | continue; | 1203 | continue; |
| 1202 | 1204 | ||
| 1203 | lval = Fcar (Fcdr (tail2)); | 1205 | lval = Fcar (XCDR (tail2)); |
| 1204 | 1206 | ||
| 1205 | /* Even if lrear or rfront say nothing about the stickiness of | 1207 | /* Even if lrear or rfront say nothing about the stickiness of |
| 1206 | SYM, Vtext_property_default_nonsticky may give default | 1208 | SYM, Vtext_property_default_nonsticky may give default |
| @@ -1728,6 +1730,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1728 | Qnil, buf, 0); | 1730 | Qnil, buf, 0); |
| 1729 | } | 1731 | } |
| 1730 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) | 1732 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| 1733 | /* Shouldn't be necessary. -stef */ | ||
| 1731 | BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer)); | 1734 | BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer)); |
| 1732 | return; | 1735 | return; |
| 1733 | } | 1736 | } |
| @@ -1741,7 +1744,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1741 | Lisp_Object buf; | 1744 | Lisp_Object buf; |
| 1742 | XSETBUFFER (buf, buffer); | 1745 | XSETBUFFER (buf, buffer); |
| 1743 | BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); | 1746 | BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); |
| 1744 | BUF_INTERVALS (buffer)->position = 1; | 1747 | BUF_INTERVALS (buffer)->position = BEG; |
| 1745 | 1748 | ||
| 1746 | /* Explicitly free the old tree here? */ | 1749 | /* Explicitly free the old tree here? */ |
| 1747 | 1750 | ||
| @@ -1763,7 +1766,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1763 | about inserting properly. For now, just waste the old intervals. */ | 1766 | about inserting properly. For now, just waste the old intervals. */ |
| 1764 | { | 1767 | { |
| 1765 | BUF_INTERVALS (buffer) = reproduce_tree (source, INTERVAL_PARENT (tree)); | 1768 | BUF_INTERVALS (buffer) = reproduce_tree (source, INTERVAL_PARENT (tree)); |
| 1766 | BUF_INTERVALS (buffer)->position = 1; | 1769 | BUF_INTERVALS (buffer)->position = BEG; |
| 1767 | /* Explicitly free the old tree here. */ | 1770 | /* Explicitly free the old tree here. */ |
| 1768 | 1771 | ||
| 1769 | return; | 1772 | return; |
| @@ -1963,7 +1966,7 @@ adjust_for_invis_intang (pos, test_offs, adj, test_intang) | |||
| 1963 | such that an insertion at POS would inherit it. */ | 1966 | such that an insertion at POS would inherit it. */ |
| 1964 | && (NILP (invis_overlay) | 1967 | && (NILP (invis_overlay) |
| 1965 | /* Invisible property is from a text-property. */ | 1968 | /* Invisible property is from a text-property. */ |
| 1966 | ? (text_property_stickiness (Qinvisible, make_number (pos)) | 1969 | ? (text_property_stickiness (Qinvisible, make_number (pos), Qnil) |
| 1967 | == (test_offs == 0 ? 1 : -1)) | 1970 | == (test_offs == 0 ? 1 : -1)) |
| 1968 | /* Invisible property is from an overlay. */ | 1971 | /* Invisible property is from an overlay. */ |
| 1969 | : (test_offs == 0 | 1972 | : (test_offs == 0 |
| @@ -2338,7 +2341,15 @@ get_local_map (position, buffer, type) | |||
| 2338 | --position; | 2341 | --position; |
| 2339 | XSETFASTINT (lispy_position, position); | 2342 | XSETFASTINT (lispy_position, position); |
| 2340 | XSETBUFFER (lispy_buffer, buffer); | 2343 | XSETBUFFER (lispy_buffer, buffer); |
| 2344 | /* First check if the CHAR has any property. This is because when | ||
| 2345 | we click with the mouse, the mouse pointer is really pointing | ||
| 2346 | to the CHAR after POS. */ | ||
| 2341 | prop = Fget_char_property (lispy_position, type, lispy_buffer); | 2347 | prop = Fget_char_property (lispy_position, type, lispy_buffer); |
| 2348 | /* If not, look at the POS's properties. This is necessary because when | ||
| 2349 | editing a field with a `local-map' property, we want insertion at the end | ||
| 2350 | to obey the `local-map' property. */ | ||
| 2351 | if (NILP (prop)) | ||
| 2352 | prop = get_pos_property (lispy_position, type, lispy_buffer); | ||
| 2342 | 2353 | ||
| 2343 | BUF_BEGV (buffer) = old_begv; | 2354 | BUF_BEGV (buffer) = old_begv; |
| 2344 | BUF_ZV (buffer) = old_zv; | 2355 | BUF_ZV (buffer) = old_zv; |