From 5163afdc2fd4b8009bae47fff6a8bc6e26269c8f Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 3 Jan 2010 05:01:10 +0100 Subject: [PATCH] Propagate buffer-local-variables changes to other threads. It is done in a quite expensive way, O(n^2) in the threads number. --- src/data.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/data.c b/src/data.c index e7d4a963b0d..96c77124c57 100644 --- a/src/data.c +++ b/src/data.c @@ -819,22 +819,22 @@ blocal_get_thread_data (struct Lisp_Buffer_Local_Value *l) Lisp_Object ret = assq_no_quit (get_current_thread (), l->thread_data); if (NILP (ret)) { - Lisp_Object tem, val, len, it, parent = Qnil; + Lisp_Object tem, val = Qnil, len, it, parent = Qnil; for (it = l->thread_data; !NILP (it); it = XCDR (it)) { Lisp_Object head = XCDR (XCAR (it)); - if (current_buffer && (BLOCAL_BUFFER_VEC (head)) + if ((EQ (Fcurrent_buffer (), BLOCAL_BUFFER_VEC (head))) && (! l->check_frame || EQ (selected_frame, BLOCAL_FRAME_VEC (head)))) { val = XCDR (BLOCAL_CDR_VEC (head)); + parent = head; break; } } - XSETFASTINT (len, 4); ret = Fmake_vector (len, Qnil); @@ -1135,6 +1135,30 @@ store_symval_forwarding (symbol, valcontents, newval, buf) valcontents = SYMBOL_VALUE (symbol); if (BUFFER_LOCAL_VALUEP (valcontents)) { + Lisp_Object v = BLOCAL_CDR (XBUFFER_LOCAL_VALUE (valcontents)); + if (!EQ (v, XCAR (v))) + { + Lisp_Object it; + for (it = XBUFFER_LOCAL_VALUE (valcontents)->thread_data; + !NILP (it); it = XCDR (it)) + { + Lisp_Object head = XCDR (XCAR (it)); + if (EQ (BLOCAL_BUFFER (XBUFFER_LOCAL_VALUE (valcontents)), + BLOCAL_BUFFER_VEC (head)) + && (! XBUFFER_LOCAL_VALUE (valcontents)->check_frame + || EQ (selected_frame, BLOCAL_FRAME_VEC (head))) + && !EQ (BLOCAL_CDR_VEC (head), + XCAR (BLOCAL_CDR_VEC (head)))) + { + Lisp_Object rv + = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; + Fsetcdr (assq_no_quit (XCAR (XCAR (it)), + XTHREADLOCAL (rv)->thread_alist), + newval); + XSETCDR (XCAR (BLOCAL_CDR_VEC (head), newval); + } + } + } BLOCAL_REALVALUE (XBUFFER_LOCAL_VALUE (valcontents)) = newval; } else if (THREADLOCALP (valcontents)) -- 2.11.4.GIT