aboutsummaryrefslogtreecommitdiffstats
path: root/src/insdel.c
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1994-04-10 02:34:02 +0000
committerRichard M. Stallman <[email protected]>1994-04-10 02:34:02 +0000
commite45fb8bf247e6fcf74e02fb0132e733dd1b58373 (patch)
treee559f6ea4f0e017d45d82959a654a9d700643a65 /src/insdel.c
parent03c6309ac76f8ffca43e4b2def928f5bf2ca9b39 (diff)
(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/insdel.c')
-rw-r--r--src/insdel.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 06cd05d4eb..5cee99f89c 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1,5 +1,5 @@
/* Buffer insertion/deletion and gap motion for GNU Emacs.
- Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1993, 1994 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -588,6 +588,20 @@ after_change_function_restore (value)
Vafter_change_function = value;
}
+static Lisp_Object
+before_change_functions_restore (value)
+ Lisp_Object value;
+{
+ Vbefore_change_functions = value;
+}
+
+static Lisp_Object
+after_change_functions_restore (value)
+ Lisp_Object value;
+{
+ Vafter_change_functions = value;
+}
+
/* Signal a change to the buffer immediately before it happens.
START and END are the bounds of the text to be changed,
as Lisp objects. */
@@ -608,16 +622,52 @@ signal_before_change (start, end)
Lisp_Object function;
function = Vbefore_change_function;
+
record_unwind_protect (after_change_function_restore,
Vafter_change_function);
record_unwind_protect (before_change_function_restore,
Vbefore_change_function);
+ record_unwind_protect (after_change_functions_restore,
+ Vafter_change_functions);
+ record_unwind_protect (before_change_functions_restore,
+ Vbefore_change_functions);
Vafter_change_function = Qnil;
Vbefore_change_function = Qnil;
+ Vafter_change_functions = Qnil;
+ Vbefore_change_functions = Qnil;
call2 (function, start, end);
unbind_to (count, Qnil);
}
+
+ /* Now in any case run the before-change-function if any. */
+ if (!NILP (Vbefore_change_functions))
+ {
+ int count = specpdl_ptr - specpdl;
+ Lisp_Object functions;
+
+ functions = Vbefore_change_functions;
+
+ record_unwind_protect (after_change_function_restore,
+ Vafter_change_function);
+ record_unwind_protect (before_change_function_restore,
+ Vbefore_change_function);
+ record_unwind_protect (after_change_functions_restore,
+ Vafter_change_functions);
+ record_unwind_protect (before_change_functions_restore,
+ Vbefore_change_functions);
+ Vafter_change_function = Qnil;
+ Vbefore_change_function = Qnil;
+ Vafter_change_functions = Qnil;
+ Vbefore_change_functions = Qnil;
+
+ while (CONSP (functions))
+ {
+ call2 (XCONS (functions)->car, start, end);
+ functions = XCONS (functions)->cdr;
+ }
+ unbind_to (count, Qnil);
+ }
}
/* Signal a change immediately after it happens.
@@ -639,11 +689,45 @@ signal_after_change (pos, lendel, lenins)
Vafter_change_function);
record_unwind_protect (before_change_function_restore,
Vbefore_change_function);
+ record_unwind_protect (after_change_functions_restore,
+ Vafter_change_functions);
+ record_unwind_protect (before_change_functions_restore,
+ Vbefore_change_functions);
Vafter_change_function = Qnil;
Vbefore_change_function = Qnil;
+ Vafter_change_functions = Qnil;
+ Vbefore_change_functions = Qnil;
call3 (function, make_number (pos), make_number (pos + lenins),
make_number (lendel));
unbind_to (count, Qnil);
}
+ if (!NILP (Vafter_change_functions))
+ {
+ int count = specpdl_ptr - specpdl;
+ Lisp_Object functions;
+ functions = Vafter_change_functions;
+
+ record_unwind_protect (after_change_function_restore,
+ Vafter_change_function);
+ record_unwind_protect (before_change_function_restore,
+ Vbefore_change_function);
+ record_unwind_protect (after_change_functions_restore,
+ Vafter_change_functions);
+ record_unwind_protect (before_change_functions_restore,
+ Vbefore_change_functions);
+ Vafter_change_function = Qnil;
+ Vbefore_change_function = Qnil;
+ Vafter_change_functions = Qnil;
+ Vbefore_change_functions = Qnil;
+
+ while (CONSP (functions))
+ {
+ call3 (XCONS (functions)->car,
+ make_number (pos), make_number (pos + lenins),
+ make_number (lendel));
+ functions = XCONS (functions)->cdr;
+ }
+ unbind_to (count, Qnil);
+ }
}