diff options
| author | Richard M. Stallman | 1997-08-13 04:13:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-08-13 04:13:22 +0000 |
| commit | b86e0aaf0fbed1cb4ebb10afba54b1965538b7c8 (patch) | |
| tree | bc4e372a51124da5d3104451c1c955ee19008a0a /src | |
| parent | e376701ac136b269bb24da62dd28ed70eb790631 (diff) | |
| download | emacs-b86e0aaf0fbed1cb4ebb10afba54b1965538b7c8.tar.gz emacs-b86e0aaf0fbed1cb4ebb10afba54b1965538b7c8.zip | |
(signal_before_change): Relocate START and END
using markers for subsequent functions, when we run a function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/insdel.c b/src/insdel.c index 73f177c02d2..a001c81bd99 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -999,6 +999,18 @@ prepare_to_modify_buffer (start, end, preserve_ptr) | |||
| 999 | unchain_marker (preserve_marker); \ | 999 | unchain_marker (preserve_marker); \ |
| 1000 | } | 1000 | } |
| 1001 | 1001 | ||
| 1002 | #define PRESERVE_START_END \ | ||
| 1003 | if (NILP (start_marker)) \ | ||
| 1004 | start_marker = Fcopy_marker (start, Qnil); \ | ||
| 1005 | if (NILP (end_marker)) \ | ||
| 1006 | end_marker = Fcopy_marker (end, Qnil); | ||
| 1007 | |||
| 1008 | #define FETCH_START \ | ||
| 1009 | (! NILP (start_marker) ? Fmarker_position (start_marker) : start) | ||
| 1010 | |||
| 1011 | #define FETCH_END \ | ||
| 1012 | (! NILP (end_marker) ? Fmarker_position (end_marker) : end) | ||
| 1013 | |||
| 1002 | /* Signal a change to the buffer immediately before it happens. | 1014 | /* Signal a change to the buffer immediately before it happens. |
| 1003 | START_INT and END_INT are the bounds of the text to be changed. | 1015 | START_INT and END_INT are the bounds of the text to be changed. |
| 1004 | 1016 | ||
| @@ -1011,13 +1023,16 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1011 | int *preserve_ptr; | 1023 | int *preserve_ptr; |
| 1012 | { | 1024 | { |
| 1013 | Lisp_Object start, end; | 1025 | Lisp_Object start, end; |
| 1026 | Lisp_Object start_marker, end_marker; | ||
| 1014 | Lisp_Object preserve_marker; | 1027 | Lisp_Object preserve_marker; |
| 1015 | struct gcpro gcpro1; | 1028 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1016 | 1029 | ||
| 1017 | start = make_number (start_int); | 1030 | start = make_number (start_int); |
| 1018 | end = make_number (end_int); | 1031 | end = make_number (end_int); |
| 1019 | preserve_marker = Qnil; | 1032 | preserve_marker = Qnil; |
| 1020 | GCPRO1 (preserve_marker); | 1033 | start_marker = Qnil; |
| 1034 | end_marker = Qnil; | ||
| 1035 | GCPRO3 (preserve_marker, start_marker, end_marker); | ||
| 1021 | 1036 | ||
| 1022 | /* If buffer is unmodified, run a special hook for that case. */ | 1037 | /* If buffer is unmodified, run a special hook for that case. */ |
| 1023 | if (SAVE_MODIFF >= MODIFF | 1038 | if (SAVE_MODIFF >= MODIFF |
| @@ -1025,6 +1040,7 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1025 | && !NILP (Vrun_hooks)) | 1040 | && !NILP (Vrun_hooks)) |
| 1026 | { | 1041 | { |
| 1027 | PRESERVE_VALUE; | 1042 | PRESERVE_VALUE; |
| 1043 | PRESERVE_START_END; | ||
| 1028 | call1 (Vrun_hooks, Qfirst_change_hook); | 1044 | call1 (Vrun_hooks, Qfirst_change_hook); |
| 1029 | } | 1045 | } |
| 1030 | 1046 | ||
| @@ -1034,7 +1050,8 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1034 | if (!NILP (Vbefore_change_function)) | 1050 | if (!NILP (Vbefore_change_function)) |
| 1035 | { | 1051 | { |
| 1036 | PRESERVE_VALUE; | 1052 | PRESERVE_VALUE; |
| 1037 | call2 (Vbefore_change_function, start, end); | 1053 | PRESERVE_START_END; |
| 1054 | call2 (Vbefore_change_function, FETCH_START, FETCH_END); | ||
| 1038 | } | 1055 | } |
| 1039 | 1056 | ||
| 1040 | /* Now run the before-change-functions if any. */ | 1057 | /* Now run the before-change-functions if any. */ |
| @@ -1046,6 +1063,7 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1046 | struct gcpro gcpro1, gcpro2; | 1063 | struct gcpro gcpro1, gcpro2; |
| 1047 | 1064 | ||
| 1048 | PRESERVE_VALUE; | 1065 | PRESERVE_VALUE; |
| 1066 | PRESERVE_START_END; | ||
| 1049 | 1067 | ||
| 1050 | /* "Bind" before-change-functions and after-change-functions | 1068 | /* "Bind" before-change-functions and after-change-functions |
| 1051 | to nil--but in a way that errors don't know about. | 1069 | to nil--but in a way that errors don't know about. |
| @@ -1058,8 +1076,8 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1058 | 1076 | ||
| 1059 | /* Actually run the hook functions. */ | 1077 | /* Actually run the hook functions. */ |
| 1060 | args[0] = Qbefore_change_functions; | 1078 | args[0] = Qbefore_change_functions; |
| 1061 | args[1] = start; | 1079 | args[1] = FETCH_START; |
| 1062 | args[2] = end; | 1080 | args[2] = FETCH_END; |
| 1063 | run_hook_list_with_args (before_change_functions, 3, args); | 1081 | run_hook_list_with_args (before_change_functions, 3, args); |
| 1064 | 1082 | ||
| 1065 | /* "Unbind" the variables we "bound" to nil. */ | 1083 | /* "Unbind" the variables we "bound" to nil. */ |
| @@ -1072,9 +1090,14 @@ signal_before_change (start_int, end_int, preserve_ptr) | |||
| 1072 | || !NILP (current_buffer->overlays_after)) | 1090 | || !NILP (current_buffer->overlays_after)) |
| 1073 | { | 1091 | { |
| 1074 | PRESERVE_VALUE; | 1092 | PRESERVE_VALUE; |
| 1075 | report_overlay_modification (start, end, 0, start, end, Qnil); | 1093 | report_overlay_modification (FETCH_START, FETCH_END, 0, |
| 1094 | FETCH_START, FETCH_END, Qnil); | ||
| 1076 | } | 1095 | } |
| 1077 | 1096 | ||
| 1097 | if (! NILP (start_marker)) | ||
| 1098 | free_marker (start_marker); | ||
| 1099 | if (! NILP (end_marker)) | ||
| 1100 | free_marker (end_marker); | ||
| 1078 | RESTORE_VALUE; | 1101 | RESTORE_VALUE; |
| 1079 | UNGCPRO; | 1102 | UNGCPRO; |
| 1080 | } | 1103 | } |