comparison src/intervals.c @ 4718:a05b833e61c4

(graft_intervals_into_buffer): New arg INHERIT.
author Richard M. Stallman <rms@gnu.org>
date Tue, 14 Sep 1993 12:10:53 +0000
parents 1fc792473491
children 99edf052bfa0
comparison
equal deleted inserted replaced
4717:5297e155e1d2 4718:a05b833e61c4
1246 only its properties, as if neither sticky property were set. Perhaps 1246 only its properties, as if neither sticky property were set. Perhaps
1247 we should consider merging all three sets of properties onto the new 1247 we should consider merging all three sets of properties onto the new
1248 text... */ 1248 text... */
1249 1249
1250 void 1250 void
1251 graft_intervals_into_buffer (source, position, buffer) 1251 graft_intervals_into_buffer (source, position, buffer, inherit)
1252 INTERVAL source; 1252 INTERVAL source;
1253 int position; 1253 int position;
1254 struct buffer *buffer; 1254 struct buffer *buffer;
1255 int inherit;
1255 { 1256 {
1256 register INTERVAL under, over, this, prev; 1257 register INTERVAL under, over, this, prev;
1257 register INTERVAL tree = buffer->intervals; 1258 register INTERVAL tree = buffer->intervals;
1258 int middle; 1259 int middle;
1259 1260
1282 Lisp_Object buf; 1283 Lisp_Object buf;
1283 XSET (buf, Lisp_Buffer, buffer); 1284 XSET (buf, Lisp_Buffer, buffer);
1284 tree = create_root_interval (buf); 1285 tree = create_root_interval (buf);
1285 } 1286 }
1286 } 1287 }
1287 else 1288 else if (TOTAL_LENGTH (tree) == TOTAL_LENGTH (source))
1288 if (TOTAL_LENGTH (tree) == TOTAL_LENGTH (source)) 1289 /* If the buffer contains only the new string, but
1289 /* If the buffer contains only the new string, but 1290 there was already some interval tree there, then it may be
1290 there was already some interval tree there, then it may be 1291 some zero length intervals. Eventually, do something clever
1291 some zero length intervals. Eventually, do something clever 1292 about inserting properly. For now, just waste the old intervals. */
1292 about inserting properly. For now, just waste the old intervals. */ 1293 {
1293 { 1294 buffer->intervals = reproduce_tree (source, tree->parent);
1294 buffer->intervals = reproduce_tree (source, tree->parent); 1295 /* Explicitly free the old tree here. */
1295 /* Explicitly free the old tree here. */ 1296
1296 1297 return;
1297 return; 1298 }
1298 } 1299 /* Paranoia -- the text has already been added, so this buffer
1299 else 1300 should be of non-zero length. */
1300 /* Paranoia -- the text has already been added, so this buffer 1301 else if (TOTAL_LENGTH (tree) == 0)
1301 should be of non-zero length. */ 1302 abort ();
1302 if (TOTAL_LENGTH (tree) == 0)
1303 abort ();
1304 1303
1305 this = under = find_interval (tree, position); 1304 this = under = find_interval (tree, position);
1306 if (NULL_INTERVAL_P (under)) /* Paranoia */ 1305 if (NULL_INTERVAL_P (under)) /* Paranoia */
1307 abort (); 1306 abort ();
1308 over = find_interval (source, 1); 1307 over = find_interval (source, 1);
1343 copy_properties (under, this); 1342 copy_properties (under, this);
1344 } 1343 }
1345 else 1344 else
1346 this = under; 1345 this = under;
1347 copy_properties (over, this); 1346 copy_properties (over, this);
1348 if (MERGE_INSERTIONS (this)) 1347 if (inherit)
1349 merge_properties (over, this); 1348 merge_properties (over, this);
1350 else 1349 else
1351 copy_properties (over, this); 1350 copy_properties (over, this);
1352 over = next_interval (over); 1351 over = next_interval (over);
1353 } 1352 }