diff options
| author | Richard M. Stallman | 1994-04-10 02:34:02 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-10 02:34:02 +0000 |
| commit | e45fb8bf247e6fcf74e02fb0132e733dd1b58373 (patch) | |
| tree | e559f6ea4f0e017d45d82959a654a9d700643a65 /src | |
| parent | 03c6309ac76f8ffca43e4b2def928f5bf2ca9b39 (diff) | |
| download | emacs-e45fb8bf247e6fcf74e02fb0132e733dd1b58373.tar.gz emacs-e45fb8bf247e6fcf74e02fb0132e733dd1b58373.zip | |
(before_change_functions_restore):
(after_change_functions_restore): New functions.
(signal_before_change): Handle Vbefore_change_functions.
(signal_after_change): Handle Vafter_change_functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/insdel.c b/src/insdel.c index 06cd05d4eba..5cee99f89cd 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Buffer insertion/deletion and gap motion for GNU Emacs. | 1 | /* Buffer insertion/deletion and gap motion for GNU Emacs. |
| 2 | Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc. | 2 | Copyright (C) 1985, 1986, 1993, 1994 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -588,6 +588,20 @@ after_change_function_restore (value) | |||
| 588 | Vafter_change_function = value; | 588 | Vafter_change_function = value; |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | static Lisp_Object | ||
| 592 | before_change_functions_restore (value) | ||
| 593 | Lisp_Object value; | ||
| 594 | { | ||
| 595 | Vbefore_change_functions = value; | ||
| 596 | } | ||
| 597 | |||
| 598 | static Lisp_Object | ||
| 599 | after_change_functions_restore (value) | ||
| 600 | Lisp_Object value; | ||
| 601 | { | ||
| 602 | Vafter_change_functions = value; | ||
| 603 | } | ||
| 604 | |||
| 591 | /* Signal a change to the buffer immediately before it happens. | 605 | /* Signal a change to the buffer immediately before it happens. |
| 592 | START and END are the bounds of the text to be changed, | 606 | START and END are the bounds of the text to be changed, |
| 593 | as Lisp objects. */ | 607 | as Lisp objects. */ |
| @@ -608,16 +622,52 @@ signal_before_change (start, end) | |||
| 608 | Lisp_Object function; | 622 | Lisp_Object function; |
| 609 | 623 | ||
| 610 | function = Vbefore_change_function; | 624 | function = Vbefore_change_function; |
| 625 | |||
| 611 | record_unwind_protect (after_change_function_restore, | 626 | record_unwind_protect (after_change_function_restore, |
| 612 | Vafter_change_function); | 627 | Vafter_change_function); |
| 613 | record_unwind_protect (before_change_function_restore, | 628 | record_unwind_protect (before_change_function_restore, |
| 614 | Vbefore_change_function); | 629 | Vbefore_change_function); |
| 630 | record_unwind_protect (after_change_functions_restore, | ||
| 631 | Vafter_change_functions); | ||
| 632 | record_unwind_protect (before_change_functions_restore, | ||
| 633 | Vbefore_change_functions); | ||
| 615 | Vafter_change_function = Qnil; | 634 | Vafter_change_function = Qnil; |
| 616 | Vbefore_change_function = Qnil; | 635 | Vbefore_change_function = Qnil; |
| 636 | Vafter_change_functions = Qnil; | ||
| 637 | Vbefore_change_functions = Qnil; | ||
| 617 | 638 | ||
| 618 | call2 (function, start, end); | 639 | call2 (function, start, end); |
| 619 | unbind_to (count, Qnil); | 640 | unbind_to (count, Qnil); |
| 620 | } | 641 | } |
| 642 | |||
| 643 | /* Now in any case run the before-change-function if any. */ | ||
| 644 | if (!NILP (Vbefore_change_functions)) | ||
| 645 | { | ||
| 646 | int count = specpdl_ptr - specpdl; | ||
| 647 | Lisp_Object functions; | ||
| 648 | |||
| 649 | functions = Vbefore_change_functions; | ||
| 650 | |||
| 651 | record_unwind_protect (after_change_function_restore, | ||
| 652 | Vafter_change_function); | ||
| 653 | record_unwind_protect (before_change_function_restore, | ||
| 654 | Vbefore_change_function); | ||
| 655 | record_unwind_protect (after_change_functions_restore, | ||
| 656 | Vafter_change_functions); | ||
| 657 | record_unwind_protect (before_change_functions_restore, | ||
| 658 | Vbefore_change_functions); | ||
| 659 | Vafter_change_function = Qnil; | ||
| 660 | Vbefore_change_function = Qnil; | ||
| 661 | Vafter_change_functions = Qnil; | ||
| 662 | Vbefore_change_functions = Qnil; | ||
| 663 | |||
| 664 | while (CONSP (functions)) | ||
| 665 | { | ||
| 666 | call2 (XCONS (functions)->car, start, end); | ||
| 667 | functions = XCONS (functions)->cdr; | ||
| 668 | } | ||
| 669 | unbind_to (count, Qnil); | ||
| 670 | } | ||
| 621 | } | 671 | } |
| 622 | 672 | ||
| 623 | /* Signal a change immediately after it happens. | 673 | /* Signal a change immediately after it happens. |
| @@ -639,11 +689,45 @@ signal_after_change (pos, lendel, lenins) | |||
| 639 | Vafter_change_function); | 689 | Vafter_change_function); |
| 640 | record_unwind_protect (before_change_function_restore, | 690 | record_unwind_protect (before_change_function_restore, |
| 641 | Vbefore_change_function); | 691 | Vbefore_change_function); |
| 692 | record_unwind_protect (after_change_functions_restore, | ||
| 693 | Vafter_change_functions); | ||
| 694 | record_unwind_protect (before_change_functions_restore, | ||
| 695 | Vbefore_change_functions); | ||
| 642 | Vafter_change_function = Qnil; | 696 | Vafter_change_function = Qnil; |
| 643 | Vbefore_change_function = Qnil; | 697 | Vbefore_change_function = Qnil; |
| 698 | Vafter_change_functions = Qnil; | ||
| 699 | Vbefore_change_functions = Qnil; | ||
| 644 | 700 | ||
| 645 | call3 (function, make_number (pos), make_number (pos + lenins), | 701 | call3 (function, make_number (pos), make_number (pos + lenins), |
| 646 | make_number (lendel)); | 702 | make_number (lendel)); |
| 647 | unbind_to (count, Qnil); | 703 | unbind_to (count, Qnil); |
| 648 | } | 704 | } |
| 705 | if (!NILP (Vafter_change_functions)) | ||
| 706 | { | ||
| 707 | int count = specpdl_ptr - specpdl; | ||
| 708 | Lisp_Object functions; | ||
| 709 | functions = Vafter_change_functions; | ||
| 710 | |||
| 711 | record_unwind_protect (after_change_function_restore, | ||
| 712 | Vafter_change_function); | ||
| 713 | record_unwind_protect (before_change_function_restore, | ||
| 714 | Vbefore_change_function); | ||
| 715 | record_unwind_protect (after_change_functions_restore, | ||
| 716 | Vafter_change_functions); | ||
| 717 | record_unwind_protect (before_change_functions_restore, | ||
| 718 | Vbefore_change_functions); | ||
| 719 | Vafter_change_function = Qnil; | ||
| 720 | Vbefore_change_function = Qnil; | ||
| 721 | Vafter_change_functions = Qnil; | ||
| 722 | Vbefore_change_functions = Qnil; | ||
| 723 | |||
| 724 | while (CONSP (functions)) | ||
| 725 | { | ||
| 726 | call3 (XCONS (functions)->car, | ||
| 727 | make_number (pos), make_number (pos + lenins), | ||
| 728 | make_number (lendel)); | ||
| 729 | functions = XCONS (functions)->cdr; | ||
| 730 | } | ||
| 731 | unbind_to (count, Qnil); | ||
| 732 | } | ||
| 649 | } | 733 | } |