On Sat, Dec 10, 2016 at 3:24 PM, Eli Zaretskii wrote: > > When I worked on merging the concurrency branch, I bumped into a > problem with the recently introduced watcher feature. The problem is > that variables can have thread-local bindings, so when there's a > thread switch, Emacs needs to rebind those variables to the values > they have in the new thread. If such a variable is marked as > trap-write, rebinding would normally call the watchers, which I think > is not what we want. Do you agree? Yes, I agree. The fact that thread-local values are implemented by rebinding is a C level implementation detail that shouldn't leak into Lisp code. > > If you agree, then we need a way of bypassing the watchers call when > the rebinding is due to a thread switch. In the merged concurrency > code I used a semi-kludgey solution for that, see the two FIXMEs I > left behind, in rebind_for_thread_switch and unbind_for_thread_switch. > Could you please look at that and suggest a cleaner solution? > The easiest is adding a global flag, but after doing that, I realized adding a parameter to set_internal and friends isn't too much trouble. So my suggestion is the attached v2 patch, I've included the v1 for comparison, since I had written it already anyway.