Mercurial > emacs
comparison src/insdel.c @ 10391:55428c377c84
Declare all non-returning functions `void'.
(insert_1): Make non-static. New arg PREPARE. All callers changed.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 11 Jan 1995 01:40:25 +0000 |
parents | 0de21e27722f |
children | 69cae342dde5 |
comparison
equal
deleted
inserted
replaced
10390:a653accbfcbb | 10391:55428c377c84 |
---|---|
23 #include "intervals.h" | 23 #include "intervals.h" |
24 #include "buffer.h" | 24 #include "buffer.h" |
25 #include "window.h" | 25 #include "window.h" |
26 #include "blockinput.h" | 26 #include "blockinput.h" |
27 | 27 |
28 static void insert_1 (); | |
29 static void insert_from_string_1 (); | 28 static void insert_from_string_1 (); |
30 static void insert_from_buffer_1 (); | 29 static void insert_from_buffer_1 (); |
31 static void gap_left (); | 30 static void gap_left (); |
32 static void gap_right (); | 31 static void gap_right (); |
33 static void adjust_markers (); | 32 static void adjust_markers (); |
34 static void adjust_point (); | 33 static void adjust_point (); |
35 | 34 |
36 /* Move gap to position `pos'. | 35 /* Move gap to position `pos'. |
37 Note that this can quit! */ | 36 Note that this can quit! */ |
38 | 37 |
38 void | |
39 move_gap (pos) | 39 move_gap (pos) |
40 int pos; | 40 int pos; |
41 { | 41 { |
42 if (pos < GPT) | 42 if (pos < GPT) |
43 gap_left (pos, 0); | 43 gap_left (pos, 0); |
257 BUF_PT (current_buffer) += amount; | 257 BUF_PT (current_buffer) += amount; |
258 } | 258 } |
259 | 259 |
260 /* Make the gap INCREMENT characters longer. */ | 260 /* Make the gap INCREMENT characters longer. */ |
261 | 261 |
262 void | |
262 make_gap (increment) | 263 make_gap (increment) |
263 int increment; | 264 int increment; |
264 { | 265 { |
265 unsigned char *result; | 266 unsigned char *result; |
266 Lisp_Object tem; | 267 Lisp_Object tem; |
307 | 308 |
308 /* Insert a string of specified length before point. | 309 /* Insert a string of specified length before point. |
309 DO NOT use this for the contents of a Lisp string or a Lisp buffer! | 310 DO NOT use this for the contents of a Lisp string or a Lisp buffer! |
310 prepare_to_modify_buffer could relocate the text. */ | 311 prepare_to_modify_buffer could relocate the text. */ |
311 | 312 |
313 void | |
312 insert (string, length) | 314 insert (string, length) |
313 register unsigned char *string; | 315 register unsigned char *string; |
314 register length; | 316 register length; |
315 { | 317 { |
316 if (length > 0) | 318 if (length > 0) |
317 { | 319 { |
318 insert_1 (string, length, 0); | 320 insert_1 (string, length, 0, 1); |
319 signal_after_change (PT-length, 0, length); | 321 signal_after_change (PT-length, 0, length); |
320 } | 322 } |
321 } | 323 } |
322 | 324 |
325 void | |
323 insert_and_inherit (string, length) | 326 insert_and_inherit (string, length) |
324 register unsigned char *string; | 327 register unsigned char *string; |
325 register length; | 328 register length; |
326 { | 329 { |
327 if (length > 0) | 330 if (length > 0) |
328 { | 331 { |
329 insert_1 (string, length, 1); | 332 insert_1 (string, length, 1, 1); |
330 signal_after_change (PT-length, 0, length); | 333 signal_after_change (PT-length, 0, length); |
331 } | 334 } |
332 } | 335 } |
333 | 336 |
334 static void | 337 void |
335 insert_1 (string, length, inherit) | 338 insert_1 (string, length, inherit, prepare) |
336 register unsigned char *string; | 339 register unsigned char *string; |
337 register length; | 340 register int length; |
338 int inherit; | 341 int inherit, prepare; |
339 { | 342 { |
340 register Lisp_Object temp; | 343 register Lisp_Object temp; |
341 | 344 |
342 /* Make sure point-max won't overflow after this insertion. */ | 345 /* Make sure point-max won't overflow after this insertion. */ |
343 XSETINT (temp, length + Z); | 346 XSETINT (temp, length + Z); |
344 if (length + Z != XINT (temp)) | 347 if (length + Z != XINT (temp)) |
345 error ("maximum buffer size exceeded"); | 348 error ("maximum buffer size exceeded"); |
346 | 349 |
347 prepare_to_modify_buffer (PT, PT); | 350 if (prepare) |
351 prepare_to_modify_buffer (PT, PT); | |
348 | 352 |
349 if (PT != GPT) | 353 if (PT != GPT) |
350 move_gap (PT); | 354 move_gap (PT); |
351 if (GAP_SIZE < length) | 355 if (GAP_SIZE < length) |
352 make_gap (length - GAP_SIZE); | 356 make_gap (length - GAP_SIZE); |
382 | 386 |
383 It does not work to use `insert' for this, because a GC could happen | 387 It does not work to use `insert' for this, because a GC could happen |
384 before we bcopy the stuff into the buffer, and relocate the string | 388 before we bcopy the stuff into the buffer, and relocate the string |
385 without insert noticing. */ | 389 without insert noticing. */ |
386 | 390 |
391 void | |
387 insert_from_string (string, pos, length, inherit) | 392 insert_from_string (string, pos, length, inherit) |
388 Lisp_Object string; | 393 Lisp_Object string; |
389 register int pos, length; | 394 register int pos, length; |
390 int inherit; | 395 int inherit; |
391 { | 396 { |
534 /* Like `insert' except that all markers pointing at the place where | 539 /* Like `insert' except that all markers pointing at the place where |
535 the insertion happens are adjusted to point after it. | 540 the insertion happens are adjusted to point after it. |
536 Don't use this function to insert part of a Lisp string, | 541 Don't use this function to insert part of a Lisp string, |
537 since gc could happen and relocate it. */ | 542 since gc could happen and relocate it. */ |
538 | 543 |
544 void | |
539 insert_before_markers (string, length) | 545 insert_before_markers (string, length) |
540 unsigned char *string; | 546 unsigned char *string; |
541 register int length; | 547 register int length; |
542 { | 548 { |
543 if (length > 0) | 549 if (length > 0) |
544 { | 550 { |
545 register int opoint = PT; | 551 register int opoint = PT; |
546 insert_1 (string, length, 0); | 552 insert_1 (string, length, 0, 1); |
547 adjust_markers (opoint - 1, opoint, length); | 553 adjust_markers (opoint - 1, opoint, length); |
548 signal_after_change (PT-length, 0, length); | 554 signal_after_change (PT-length, 0, length); |
549 } | 555 } |
550 } | 556 } |
551 | 557 |
558 void | |
552 insert_before_markers_and_inherit (string, length) | 559 insert_before_markers_and_inherit (string, length) |
553 unsigned char *string; | 560 unsigned char *string; |
554 register int length; | 561 register int length; |
555 { | 562 { |
556 if (length > 0) | 563 if (length > 0) |
557 { | 564 { |
558 register int opoint = PT; | 565 register int opoint = PT; |
559 insert_1 (string, length, 1); | 566 insert_1 (string, length, 1, 1); |
560 adjust_markers (opoint - 1, opoint, length); | 567 adjust_markers (opoint - 1, opoint, length); |
561 signal_after_change (PT-length, 0, length); | 568 signal_after_change (PT-length, 0, length); |
562 } | 569 } |
563 } | 570 } |
564 | 571 |
565 /* Insert part of a Lisp string, relocating markers after. */ | 572 /* Insert part of a Lisp string, relocating markers after. */ |
566 | 573 |
574 void | |
567 insert_from_string_before_markers (string, pos, length, inherit) | 575 insert_from_string_before_markers (string, pos, length, inherit) |
568 Lisp_Object string; | 576 Lisp_Object string; |
569 register int pos, length; | 577 register int pos, length; |
570 int inherit; | 578 int inherit; |
571 { | 579 { |
579 } | 587 } |
580 | 588 |
581 /* Delete characters in current buffer | 589 /* Delete characters in current buffer |
582 from FROM up to (but not including) TO. */ | 590 from FROM up to (but not including) TO. */ |
583 | 591 |
592 void | |
584 del_range (from, to) | 593 del_range (from, to) |
585 register int from, to; | 594 register int from, to; |
586 { | 595 { |
587 return del_range_1 (from, to, 1); | 596 del_range_1 (from, to, 1); |
588 } | 597 } |
589 | 598 |
590 /* Like del_range; PREPARE says whether to call prepare_to_modify_buffer. */ | 599 /* Like del_range; PREPARE says whether to call prepare_to_modify_buffer. */ |
591 | 600 |
601 void | |
592 del_range_1 (from, to, prepare) | 602 del_range_1 (from, to, prepare) |
593 register int from, to, prepare; | 603 register int from, to, prepare; |
594 { | 604 { |
595 register int numdel; | 605 register int numdel; |
596 | 606 |
642 | 652 |
643 /* Call this if you're about to change the region of BUFFER from START | 653 /* Call this if you're about to change the region of BUFFER from START |
644 to END. This checks the read-only properties of the region, calls | 654 to END. This checks the read-only properties of the region, calls |
645 the necessary modification hooks, and warns the next redisplay that | 655 the necessary modification hooks, and warns the next redisplay that |
646 it should pay attention to that area. */ | 656 it should pay attention to that area. */ |
657 void | |
647 modify_region (buffer, start, end) | 658 modify_region (buffer, start, end) |
648 struct buffer *buffer; | 659 struct buffer *buffer; |
649 int start, end; | 660 int start, end; |
650 { | 661 { |
651 struct buffer *old_buffer = current_buffer; | 662 struct buffer *old_buffer = current_buffer; |
672 /* Check that it is okay to modify the buffer between START and END. | 683 /* Check that it is okay to modify the buffer between START and END. |
673 Run the before-change-function, if any. If intervals are in use, | 684 Run the before-change-function, if any. If intervals are in use, |
674 verify that the text to be modified is not read-only, and call | 685 verify that the text to be modified is not read-only, and call |
675 any modification properties the text may have. */ | 686 any modification properties the text may have. */ |
676 | 687 |
688 void | |
677 prepare_to_modify_buffer (start, end) | 689 prepare_to_modify_buffer (start, end) |
678 Lisp_Object start, end; | 690 Lisp_Object start, end; |
679 { | 691 { |
680 if (!NILP (current_buffer->read_only)) | 692 if (!NILP (current_buffer->read_only)) |
681 Fbarf_if_buffer_read_only (); | 693 Fbarf_if_buffer_read_only (); |
742 | 754 |
743 /* Signal a change to the buffer immediately before it happens. | 755 /* Signal a change to the buffer immediately before it happens. |
744 START and END are the bounds of the text to be changed, | 756 START and END are the bounds of the text to be changed, |
745 as Lisp objects. */ | 757 as Lisp objects. */ |
746 | 758 |
759 void | |
747 signal_before_change (start, end) | 760 signal_before_change (start, end) |
748 Lisp_Object start, end; | 761 Lisp_Object start, end; |
749 { | 762 { |
750 /* If buffer is unmodified, run a special hook for that case. */ | 763 /* If buffer is unmodified, run a special hook for that case. */ |
751 if (SAVE_MODIFF >= MODIFF | 764 if (SAVE_MODIFF >= MODIFF |
818 (Not the whole buffer; just the part that was changed.) | 831 (Not the whole buffer; just the part that was changed.) |
819 LENINS is the number of characters in the changed text. | 832 LENINS is the number of characters in the changed text. |
820 | 833 |
821 (Hence POS + LENINS - LENDEL is the position after the changed text.) */ | 834 (Hence POS + LENINS - LENDEL is the position after the changed text.) */ |
822 | 835 |
836 void | |
823 signal_after_change (pos, lendel, lenins) | 837 signal_after_change (pos, lendel, lenins) |
824 int pos, lendel, lenins; | 838 int pos, lendel, lenins; |
825 { | 839 { |
826 if (!NILP (Vafter_change_function)) | 840 if (!NILP (Vafter_change_function)) |
827 { | 841 { |