comparison src/insdel.c @ 1289:74b26ab86df4

* insdel.c: #include "intervals.h" (prepare_to_modify_buffer): Call verify_interval_modification(). (insert_from_string): Call offset_intervals() and graft_intervals_into_buffer(). (del_range): Call offset_intervals(). (insert): Call offset_intervals().
author Joseph Arceneaux <jla@gnu.org>
date Thu, 01 Oct 1992 00:56:11 +0000
parents 8dce1588f37f
children 04fb1d3d6992
comparison
equal deleted inserted replaced
1288:b05982e82d93 1289:74b26ab86df4
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 19
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "lisp.h" 22 #include "lisp.h"
23 #include "intervals.h"
23 #include "buffer.h" 24 #include "buffer.h"
24 #include "window.h" 25 #include "window.h"
25 26
26 /* Nonzero means don't allow protected fields to be modified. */ 27 /* Nonzero means don't allow protected fields to be modified. */
27 28
303 record_insert (point, length); 304 record_insert (point, length);
304 MODIFF++; 305 MODIFF++;
305 306
306 bcopy (string, GPT_ADDR, length); 307 bcopy (string, GPT_ADDR, length);
307 308
309 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
310 offset_intervals (current_buffer, point, length);
311
308 GAP_SIZE -= length; 312 GAP_SIZE -= length;
309 GPT += length; 313 GPT += length;
310 ZV += length; 314 ZV += length;
311 Z += length; 315 Z += length;
312 SET_PT (point + length); 316 SET_PT (point + length);
313 317
314 signal_after_change (point-length, 0, length); 318 signal_after_change (point-length, 0, length);
315 } 319 }
316 320
317 /* Function to insert part of the text of a string (STRING) consisting 321 /* Insert the part of the text of STRING, a Lisp object assumed to be
318 of LENGTH characters at position POS. 322 of type string, consisting of the LENGTH characters starting at
319 It does not work to use `insert' for this, becase a GC could happen 323 position POS. If the text of STRING has properties, they are absorbed
324 into the buffer.
325
326 It does not work to use `insert' for this, because a GC could happen
320 before we bcopy the stuff into the buffer, and relocate the string 327 before we bcopy the stuff into the buffer, and relocate the string
321 without insert noticing. */ 328 without insert noticing. */
329
322 insert_from_string (string, pos, length) 330 insert_from_string (string, pos, length)
323 Lisp_Object string; 331 Lisp_Object string;
324 register int pos, length; 332 register int pos, length;
325 { 333 {
326 register Lisp_Object temp; 334 register Lisp_Object temp;
346 MODIFF++; 354 MODIFF++;
347 UNGCPRO; 355 UNGCPRO;
348 356
349 bcopy (XSTRING (string)->data, GPT_ADDR, length); 357 bcopy (XSTRING (string)->data, GPT_ADDR, length);
350 358
359 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
360 offset_intervals (current_buffer, point, length);
361
351 GAP_SIZE -= length; 362 GAP_SIZE -= length;
352 GPT += length; 363 GPT += length;
353 ZV += length; 364 ZV += length;
354 Z += length; 365 Z += length;
366
367 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
368 graft_intervals_into_buffer (XSTRING (string)->intervals, point,
369 current_buffer);
370
355 SET_PT (point + length); 371 SET_PT (point + length);
356 372
357 signal_after_change (point-length, 0, length); 373 signal_after_change (point-length, 0, length);
358 } 374 }
359 375
425 441
426 prepare_to_modify_buffer (from, to); 442 prepare_to_modify_buffer (from, to);
427 443
428 record_delete (from, numdel); 444 record_delete (from, numdel);
429 MODIFF++; 445 MODIFF++;
446
447 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
448 offset_intervals (current_buffer, point, - numdel);
430 449
431 /* Relocate point as if it were a marker. */ 450 /* Relocate point as if it were a marker. */
432 if (from < point) 451 if (from < point)
433 { 452 {
434 if (point < to) 453 if (point < to)
466 end_unchanged = Z - end; 485 end_unchanged = Z - end;
467 MODIFF++; 486 MODIFF++;
468 } 487 }
469 488
470 /* Check that it is okay to modify the buffer between START and END. 489 /* Check that it is okay to modify the buffer between START and END.
471 Run the before-change-function, if any. */ 490 Run the before-change-function, if any. If intervals are in use,
491 verify that the text to be modified is not read-only, and call
492 any modification properties the text may have. */
472 493
473 prepare_to_modify_buffer (start, end) 494 prepare_to_modify_buffer (start, end)
474 Lisp_Object start, end; 495 Lisp_Object start, end;
475 { 496 {
476 if (!NILP (current_buffer->read_only)) 497 if (!NILP (current_buffer->read_only))
477 Fbarf_if_buffer_read_only (); 498 Fbarf_if_buffer_read_only ();
478 499
500 #if 0 /* Superceded by interval code */
479 if (check_protected_fields) 501 if (check_protected_fields)
480 Fregion_fields (start, end, Qnil, Qt); 502 Fregion_fields (start, end, Qnil, Qt);
503 #endif
504
505 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
506 verify_interval_modification (current_buffer, start, end);
481 507
482 #ifdef CLASH_DETECTION 508 #ifdef CLASH_DETECTION
483 if (!NILP (current_buffer->filename) 509 if (!NILP (current_buffer->filename)
484 && current_buffer->save_modified >= MODIFF) 510 && current_buffer->save_modified >= MODIFF)
485 lock_file (current_buffer->filename); 511 lock_file (current_buffer->filename);