Please scrap my last indirect buffer fix, and apply this one instead.
The problem was a little bit more complex, because I noticed that some
things don't work as well as I originally assumed; some stuff in
prepare_to_modify_buffer() and signal_after_change() needs to be
called only once, so I had to add MAP_INDIRECT_BUFFERS to them.
I'm afraid this patch will not apply without my extend-modification
patches. Steve, let me know how I can find the latest insdel.c from
21.2, and I'll send you a patch you can apply.
1998-09-10 Hrvoje Niksic <hniksic(a)srce.hr>
* insdel.c (signal_after_change): Map across indirect buffers
here, and not in the upper-level functions.
(signal_first_change): Don't check for Armageddon.
(signal_before_change): Map across indirect buffers here.
(prepare_to_modify_buffer): ...and here.
--- src/insdel.c.orig Wed Sep 9 23:35:34 1998
+++ src/insdel.c Thu Sep 10 21:28:00 1998
@@ -2130,8 +2130,7 @@
if (!in_first_change)
{
- if (!preparing_for_armageddon &&
- !NILP (symbol_value_in_buffer (Qfirst_change_hook, buffer)))
+ if (!NILP (symbol_value_in_buffer (Qfirst_change_hook, buffer)))
{
int speccount = specpdl_depth ();
record_unwind_protect (first_change_hook_restore, buffer);
@@ -2150,11 +2149,13 @@
signal_before_change (struct buffer *buf, Bufpos start, Bufpos end)
{
/* This function can GC */
- Lisp_Object buffer;
- XSETBUFFER (buffer, buf);
+ struct buffer *mbuf;
+ Lisp_Object bufcons;
if (!inside_change_hook)
{
+ Lisp_Object buffer;
+
/* Are we in a multiple-change session? */
if (buf->text->changes->in_multiple_change &&
buf->text->changes->mc_begin != 0)
@@ -2183,28 +2184,41 @@
/* If buffer is unmodified, run a special hook for that case. */
if (BUF_SAVE_MODIFF (buf) >= BUF_MODIFF (buf))
- signal_first_change (buf);
+ {
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ signal_first_change (mbuf);
+ }
+ }
/* Now in any case run the before-change-functions if any. */
- if (!NILP (symbol_value_in_buffer (Qbefore_change_functions, buffer))
- /* Obsolete, for compatibility */
- || !NILP (symbol_value_in_buffer (Qbefore_change_function, buffer)))
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
{
- int speccount = specpdl_depth ();
- record_unwind_protect (change_function_restore, Fcurrent_buffer ());
- set_buffer_internal (buf);
- inside_change_hook = 1;
- va_run_hook_with_args (Qbefore_change_functions, 2,
- make_int (start), make_int (end));
- /* Obsolete, for compatibility */
- va_run_hook_with_args (Qbefore_change_function, 2,
- make_int (start), make_int (end));
- unbind_to (speccount, Qnil);
+ XSETBUFFER (buffer, mbuf);
+ if (!NILP (symbol_value_in_buffer (Qbefore_change_functions, buffer))
+ /* Obsolete, for compatibility */
+ || !NILP (symbol_value_in_buffer (Qbefore_change_function, buffer)))
+ {
+ int speccount = specpdl_depth ();
+ record_unwind_protect (change_function_restore, Fcurrent_buffer ());
+ set_buffer_internal (buf);
+ inside_change_hook = 1;
+ va_run_hook_with_args (Qbefore_change_functions, 2,
+ make_int (start), make_int (end));
+ /* Obsolete, for compatibility */
+ va_run_hook_with_args (Qbefore_change_function, 2,
+ make_int (start), make_int (end));
+ unbind_to (speccount, Qnil);
+ }
}
- report_extent_modification (buffer, start, end,
- &inside_change_hook, 0);
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ XSETBUFFER (buffer, mbuf);
+ report_extent_modification (buffer, start, end,
+ &inside_change_hook, 0);
+ }
/* Only now do we indicate that the before-change-functions have
been called, in case some function throws out. */
@@ -2223,15 +2237,25 @@
Bufpos new_end)
{
/* This function can GC */
- Lisp_Object buffer;
- XSETBUFFER (buffer, buf);
+ struct buffer *mbuf;
+ Lisp_Object bufcons;
- /* always do this. */
- buffer_signal_changed_region (buf, start, new_end);
- font_lock_maybe_update_syntactic_caches (buf, start, orig_end, new_end);
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ /* always do this. */
+ buffer_signal_changed_region (mbuf, start, new_end);
+ }
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ /* #### This seems inefficient. Wouldn't it be better to just
+ keep one cache per base buffer? */
+ font_lock_maybe_update_syntactic_caches (mbuf, start, orig_end, new_end);
+ }
if (!inside_change_hook)
{
+ Lisp_Object buffer;
+
if (buf->text->changes->in_multiple_change &&
buf->text->changes->mc_begin != 0)
{
@@ -2243,28 +2267,37 @@
return; /* after-change-functions signalled when all changes done */
}
- if (!NILP (symbol_value_in_buffer (Qafter_change_functions, buffer))
- /* Obsolete, for compatibility */
- || !NILP (symbol_value_in_buffer (Qafter_change_function, buffer)))
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
{
- int speccount = specpdl_depth ();
- record_unwind_protect (change_function_restore, Fcurrent_buffer ());
- set_buffer_internal (buf);
- inside_change_hook = 1;
- /* The actual after-change functions take slightly
- different arguments than what we were passed. */
- va_run_hook_with_args (Qafter_change_functions, 3,
- make_int (start), make_int (new_end),
- make_int (orig_end - start));
- /* Obsolete, for compatibility */
- va_run_hook_with_args (Qafter_change_function, 3,
- make_int (start), make_int (new_end),
- make_int (orig_end - start));
- unbind_to (speccount, Qnil);
+ XSETBUFFER (buffer, mbuf);
+
+ if (!NILP (symbol_value_in_buffer (Qafter_change_functions, buffer))
+ /* Obsolete, for compatibility */
+ || !NILP (symbol_value_in_buffer (Qafter_change_function, buffer)))
+ {
+ int speccount = specpdl_depth ();
+ record_unwind_protect (change_function_restore, Fcurrent_buffer ());
+ set_buffer_internal (buf);
+ inside_change_hook = 1;
+ /* The actual after-change functions take slightly
+ different arguments than what we were passed. */
+ va_run_hook_with_args (Qafter_change_functions, 3,
+ make_int (start), make_int (new_end),
+ make_int (orig_end - start));
+ /* Obsolete, for compatibility */
+ va_run_hook_with_args (Qafter_change_function, 3,
+ make_int (start), make_int (new_end),
+ make_int (orig_end - start));
+ unbind_to (speccount, Qnil);
+ }
}
- report_extent_modification (buffer, start, new_end,
- &inside_change_hook, 1);
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ XSETBUFFER (buffer, mbuf);
+ report_extent_modification (buffer, start, new_end,
+ &inside_change_hook, 1);
+ }
}
}
@@ -2281,10 +2314,14 @@
/* dmoore - This function can also kill the buffer buf, the current
buffer, and do anything it pleases. So if you call it, be
careful. */
- Lisp_Object buffer;
+ struct buffer *mbuf;
+ Lisp_Object buffer, bufcons;
struct gcpro gcpro1;
- barf_if_buffer_read_only (buf, start, end);
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ barf_if_buffer_read_only (mbuf, start, end);
+ }
/* if this is the first modification, see about locking the buffer's
file */
@@ -2328,7 +2365,10 @@
Vdeactivate_mark = Qt;
#endif
- buf->point_before_scroll = Qnil;
+ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
+ {
+ mbuf->point_before_scroll = Qnil;
+ }
}
@@ -2418,17 +2458,14 @@
#### buffer_insert_from_buffer_1() doesn't! */
GCPRO1 (reloc);
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- prepare_to_modify_buffer (mbuf, pos, pos, !(flags & INSDEL_NO_LOCKING));
+ prepare_to_modify_buffer (buf, pos, pos, !(flags & INSDEL_NO_LOCKING));
- /* Defensive steps in case the before-change-functions fuck around */
- if (!BUFFER_LIVE_P (buf))
- {
- UNGCPRO;
- /* Bad bad pre-change function. */
- return 0;
- }
+ /* Defensive steps in case the before-change-functions fuck around */
+ if (!BUFFER_LIVE_P (buf))
+ {
+ UNGCPRO;
+ /* Bad bad pre-change function. */
+ return 0;
}
/* Make args be valid again. prepare_to_modify_buffer() might have
@@ -2531,10 +2568,7 @@
}
}
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- signal_after_change (mbuf, pos, pos, pos + cclen);
- }
+ signal_after_change (buf, pos, pos, pos + cclen);
UNGCPRO;
@@ -2644,15 +2678,12 @@
if ((numdel = to - from) <= 0)
return;
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- prepare_to_modify_buffer (mbuf, from, to, !(flags & INSDEL_NO_LOCKING));
+ prepare_to_modify_buffer (buf, from, to, !(flags & INSDEL_NO_LOCKING));
- /* Defensive steps in case the before-change-functions fuck around */
- if (!BUFFER_LIVE_P (buf))
- /* Bad bad pre-change function. */
- return;
- }
+ /* Defensive steps in case the before-change-functions fuck around */
+ if (!BUFFER_LIVE_P (buf))
+ /* Bad bad pre-change function. */
+ return;
/* Make args be valid again. prepare_to_modify_buffer() might have
modified the buffer. */
@@ -2843,10 +2874,7 @@
}
#endif
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- signal_after_change (mbuf, from, to, from);
- }
+ signal_after_change (buf, from, to, from);
}
@@ -2879,15 +2907,12 @@
Lisp_Object bufcons;
/* then we can just replace the text. */
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- prepare_to_modify_buffer (mbuf, pos, pos + 1,
- !not_real_change || force_lock_check);
- /* Defensive steps in case the before-change-functions fuck around */
- if (!BUFFER_LIVE_P (buf))
- /* Bad bad pre-change function. */
- return;
- }
+ prepare_to_modify_buffer (buf, pos, pos + 1,
+ !not_real_change || force_lock_check);
+ /* Defensive steps in case the before-change-functions fuck around */
+ if (!BUFFER_LIVE_P (buf))
+ /* Bad bad pre-change function. */
+ return;
/* Make args be valid again. prepare_to_modify_buffer() might have
modified the buffer. */
@@ -2916,10 +2941,8 @@
BUF_MODIFF (buf)++;
}
memcpy (BUF_BYTE_ADDRESS (buf, pos), newstr, newlen);
- MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
- {
- signal_after_change (mbuf, pos, pos + 1, pos + 1);
- }
+
+ signal_after_change (buf, pos, pos + 1, pos + 1);
/* We do not have to adjust the Mule data; we just replaced a
character with another of the same number of bytes. */
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Oh lord won't you buy me a color TV...