diff options
| author | Richard M. Stallman | 1995-08-05 22:57:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-08-05 22:57:13 +0000 |
| commit | 3d1e2d9c911cf455f6f31fd501d30de961910fc4 (patch) | |
| tree | 9310ebde8267f06f5a73eba6988c3cd7849d51f1 /src | |
| parent | dae3612398029091cb1ba58766ea90a479039113 (diff) | |
| download | emacs-3d1e2d9c911cf455f6f31fd501d30de961910fc4.tar.gz emacs-3d1e2d9c911cf455f6f31fd501d30de961910fc4.zip | |
(signal_before_change, signal_after_change): Major rewrite.
(before_change_function_restore, after_change_function_restore)
(before_change_functions_restore, after_change_functions_restore):
Functions deleted.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 178 |
1 files changed, 59 insertions, 119 deletions
diff --git a/src/insdel.c b/src/insdel.c index c486715df96..24704015f77 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -741,34 +741,6 @@ prepare_to_modify_buffer (start, end) | |||
| 741 | Vdeactivate_mark = Qt; | 741 | Vdeactivate_mark = Qt; |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | static Lisp_Object | ||
| 745 | before_change_function_restore (value) | ||
| 746 | Lisp_Object value; | ||
| 747 | { | ||
| 748 | Vbefore_change_function = value; | ||
| 749 | } | ||
| 750 | |||
| 751 | static Lisp_Object | ||
| 752 | after_change_function_restore (value) | ||
| 753 | Lisp_Object value; | ||
| 754 | { | ||
| 755 | Vafter_change_function = value; | ||
| 756 | } | ||
| 757 | |||
| 758 | static Lisp_Object | ||
| 759 | before_change_functions_restore (value) | ||
| 760 | Lisp_Object value; | ||
| 761 | { | ||
| 762 | Vbefore_change_functions = value; | ||
| 763 | } | ||
| 764 | |||
| 765 | static Lisp_Object | ||
| 766 | after_change_functions_restore (value) | ||
| 767 | Lisp_Object value; | ||
| 768 | { | ||
| 769 | Vafter_change_functions = value; | ||
| 770 | } | ||
| 771 | |||
| 772 | /* Signal a change to the buffer immediately before it happens. | 744 | /* Signal a change to the buffer immediately before it happens. |
| 773 | START and END are the bounds of the text to be changed, | 745 | START and END are the bounds of the text to be changed, |
| 774 | as Lisp objects. */ | 746 | as Lisp objects. */ |
| @@ -777,64 +749,45 @@ void | |||
| 777 | signal_before_change (start, end) | 749 | signal_before_change (start, end) |
| 778 | Lisp_Object start, end; | 750 | Lisp_Object start, end; |
| 779 | { | 751 | { |
| 780 | Lisp_Object args[2]; | ||
| 781 | |||
| 782 | /* If buffer is unmodified, run a special hook for that case. */ | 752 | /* If buffer is unmodified, run a special hook for that case. */ |
| 783 | if (SAVE_MODIFF >= MODIFF | 753 | if (SAVE_MODIFF >= MODIFF |
| 784 | && !NILP (Vfirst_change_hook) | 754 | && !NILP (Vfirst_change_hook) |
| 785 | && !NILP (Vrun_hooks)) | 755 | && !NILP (Vrun_hooks)) |
| 786 | call1 (Vrun_hooks, Qfirst_change_hook); | 756 | call1 (Vrun_hooks, Qfirst_change_hook); |
| 787 | 757 | ||
| 788 | /* Now in any case run the before-change-function if any. */ | 758 | /* Run the before-change-function if any. |
| 759 | We don't bother "binding" this variable to nil | ||
| 760 | because it is obsolete anyway and new code should not use it. */ | ||
| 789 | if (!NILP (Vbefore_change_function)) | 761 | if (!NILP (Vbefore_change_function)) |
| 790 | { | 762 | call2 (Vbefore_change_function, start, end); |
| 791 | int count = specpdl_ptr - specpdl; | ||
| 792 | Lisp_Object function; | ||
| 793 | |||
| 794 | function = Vbefore_change_function; | ||
| 795 | |||
| 796 | record_unwind_protect (after_change_function_restore, | ||
| 797 | Vafter_change_function); | ||
| 798 | record_unwind_protect (before_change_function_restore, | ||
| 799 | Vbefore_change_function); | ||
| 800 | record_unwind_protect (after_change_functions_restore, | ||
| 801 | Vafter_change_functions); | ||
| 802 | record_unwind_protect (before_change_functions_restore, | ||
| 803 | Vbefore_change_functions); | ||
| 804 | Vafter_change_function = Qnil; | ||
| 805 | Vbefore_change_function = Qnil; | ||
| 806 | Vafter_change_functions = Qnil; | ||
| 807 | Vbefore_change_functions = Qnil; | ||
| 808 | |||
| 809 | call2 (function, start, end); | ||
| 810 | unbind_to (count, Qnil); | ||
| 811 | } | ||
| 812 | 763 | ||
| 813 | /* Now in any case run the before-change-function if any. */ | 764 | /* Now run the before-change-functions if any. */ |
| 814 | if (!NILP (Vbefore_change_functions)) | 765 | if (!NILP (Vbefore_change_functions)) |
| 815 | { | 766 | { |
| 816 | int count = specpdl_ptr - specpdl; | 767 | Lisp_Object args[3]; |
| 817 | Lisp_Object functions; | 768 | Lisp_Object before_change_functions; |
| 818 | 769 | Lisp_Object after_change_functions; | |
| 819 | functions = Vbefore_change_functions; | 770 | struct gcpro gcpro1, gcpro2; |
| 820 | 771 | ||
| 821 | record_unwind_protect (after_change_function_restore, | 772 | /* "Bind" before-change-functions and after-change-functions |
| 822 | Vafter_change_function); | 773 | to nil--but in a way that errors don't know about. |
| 823 | record_unwind_protect (before_change_function_restore, | 774 | That way, if there's an error in them, they will stay nil. */ |
| 824 | Vbefore_change_function); | 775 | before_change_functions = Vbefore_change_functions; |
| 825 | record_unwind_protect (after_change_functions_restore, | 776 | after_change_functions = Vafter_change_functions; |
| 826 | Vafter_change_functions); | ||
| 827 | record_unwind_protect (before_change_functions_restore, | ||
| 828 | Vbefore_change_functions); | ||
| 829 | Vafter_change_function = Qnil; | ||
| 830 | Vbefore_change_function = Qnil; | 777 | Vbefore_change_function = Qnil; |
| 831 | Vafter_change_functions = Qnil; | 778 | Vafter_change_function = Qnil; |
| 832 | Vbefore_change_functions = Qnil; | 779 | GCPRO2 (before_change_functions, after_change_functions); |
| 833 | 780 | ||
| 834 | args[0] = start; | 781 | /* Actually run the hook functions. */ |
| 835 | args[1] = end; | 782 | args[0] = Qbefore_change_functions; |
| 836 | Frun_hook_with_args (intern ("before-change-functions"), 2, args); | 783 | args[1] = start; |
| 837 | unbind_to (count, Qnil); | 784 | args[2] = end; |
| 785 | run_hook_list_with_args (before_change_functions, 3, args); | ||
| 786 | |||
| 787 | /* "Unbind" the variables we "bound" to nil. */ | ||
| 788 | Vbefore_change_functions = before_change_functions; | ||
| 789 | Vafter_change_functions = after_change_functions; | ||
| 790 | UNGCPRO; | ||
| 838 | } | 791 | } |
| 839 | 792 | ||
| 840 | if (!NILP (current_buffer->overlays_before) | 793 | if (!NILP (current_buffer->overlays_before) |
| @@ -854,55 +807,42 @@ void | |||
| 854 | signal_after_change (pos, lendel, lenins) | 807 | signal_after_change (pos, lendel, lenins) |
| 855 | int pos, lendel, lenins; | 808 | int pos, lendel, lenins; |
| 856 | { | 809 | { |
| 857 | Lisp_Object args[3]; | 810 | /* Run the after-change-function if any. |
| 858 | 811 | We don't bother "binding" this variable to nil | |
| 812 | because it is obsolete anyway and new code should not use it. */ | ||
| 859 | if (!NILP (Vafter_change_function)) | 813 | if (!NILP (Vafter_change_function)) |
| 860 | { | 814 | call3 (Vafter_change_function, |
| 861 | int count = specpdl_ptr - specpdl; | 815 | make_number (pos), make_number (pos + lenins), |
| 862 | Lisp_Object function; | 816 | make_number (lendel)); |
| 863 | function = Vafter_change_function; | ||
| 864 | |||
| 865 | record_unwind_protect (after_change_function_restore, | ||
| 866 | Vafter_change_function); | ||
| 867 | record_unwind_protect (before_change_function_restore, | ||
| 868 | Vbefore_change_function); | ||
| 869 | record_unwind_protect (after_change_functions_restore, | ||
| 870 | Vafter_change_functions); | ||
| 871 | record_unwind_protect (before_change_functions_restore, | ||
| 872 | Vbefore_change_functions); | ||
| 873 | Vafter_change_function = Qnil; | ||
| 874 | Vbefore_change_function = Qnil; | ||
| 875 | Vafter_change_functions = Qnil; | ||
| 876 | Vbefore_change_functions = Qnil; | ||
| 877 | 817 | ||
| 878 | call3 (function, make_number (pos), make_number (pos + lenins), | ||
| 879 | make_number (lendel)); | ||
| 880 | unbind_to (count, Qnil); | ||
| 881 | } | ||
| 882 | if (!NILP (Vafter_change_functions)) | 818 | if (!NILP (Vafter_change_functions)) |
| 883 | { | 819 | { |
| 884 | int count = specpdl_ptr - specpdl; | 820 | Lisp_Object args[4]; |
| 885 | Lisp_Object functions; | 821 | Lisp_Object before_change_functions; |
| 886 | functions = Vafter_change_functions; | 822 | Lisp_Object after_change_functions; |
| 887 | 823 | struct gcpro gcpro1, gcpro2; | |
| 888 | record_unwind_protect (after_change_function_restore, | 824 | |
| 889 | Vafter_change_function); | 825 | /* "Bind" before-change-functions and after-change-functions |
| 890 | record_unwind_protect (before_change_function_restore, | 826 | to nil--but in a way that errors don't know about. |
| 891 | Vbefore_change_function); | 827 | That way, if there's an error in them, they will stay nil. */ |
| 892 | record_unwind_protect (after_change_functions_restore, | 828 | before_change_functions = Vbefore_change_functions; |
| 893 | Vafter_change_functions); | 829 | after_change_functions = Vafter_change_functions; |
| 894 | record_unwind_protect (before_change_functions_restore, | ||
| 895 | Vbefore_change_functions); | ||
| 896 | Vafter_change_function = Qnil; | ||
| 897 | Vbefore_change_function = Qnil; | 830 | Vbefore_change_function = Qnil; |
| 898 | Vafter_change_functions = Qnil; | 831 | Vafter_change_function = Qnil; |
| 899 | Vbefore_change_functions = Qnil; | 832 | GCPRO2 (before_change_functions, after_change_functions); |
| 900 | 833 | ||
| 901 | XSETFASTINT (args[0], pos); | 834 | /* Actually run the hook functions. */ |
| 902 | XSETFASTINT (args[1], pos + lenins); | 835 | args[0] = Qafter_change_functions; |
| 903 | XSETFASTINT (args[2], lendel); | 836 | XSETFASTINT (args[1], pos); |
| 904 | Frun_hook_with_args (intern ("after-change-functions"), 3, args); | 837 | XSETFASTINT (args[2], pos + lenins); |
| 905 | unbind_to (count, Qnil); | 838 | XSETFASTINT (args[3], lendel); |
| 839 | run_hook_list_with_args (after_change_functions, | ||
| 840 | 4, args); | ||
| 841 | |||
| 842 | /* "Unbind" the variables we "bound" to nil. */ | ||
| 843 | Vbefore_change_functions = before_change_functions; | ||
| 844 | Vafter_change_functions = after_change_functions; | ||
| 845 | UNGCPRO; | ||
| 906 | } | 846 | } |
| 907 | 847 | ||
| 908 | if (!NILP (current_buffer->overlays_before) | 848 | if (!NILP (current_buffer->overlays_before) |