Subject: bug#34318: 26.1.90; Strange behavior of two line message with running shell

From: martin rudalics <[email-masked]>
Date: Fri, 08 Feb 2019 10:58:04 +0100

> The regression appears to be that the synchronisation of buffer local
 > and global values doesn't work.  When I type M-x, then C-h v
 > print-escape-newlines, I get this:
 >
 > print-escape-newlines is a variable defined in ‘C source code’.
 > Its value is nil
 > Local in buffer  *Minibuf-1*; global value is t
 >
 > Which doesn't make sense (the values are swapped).

The problem is with

2018-06-03  Stefan Monnier  <[email-masked]>

	Fix bug#30846, along with misc cleanups found along the way

and in particular

	Don't call swap_in_symval_forwarding since the currently swapped
	binding is never one we've modified.

I don't care how it gets fixed but it should get fixed, for example,
as in the attached patch.  Bugs like this can make people spend hours
of debugging all sorts of completely unrelated areas which is no fun.

So please, pretty please review that entire patch again - maybe it
contains additional sorts of problems.

Thank you in advance, martin
diff --git a/src/data.c b/src/data.c
index 5711148..c8193db 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1956,6 +1956,13 @@ struct Lisp_Symbol *
 		BVAR (current_buffer, local_var_alist)));
     }
 
+  /* If the symbol forwards into a C variable, then load the binding
+     for this buffer now.  If C code modifies the variable before we
+     load the binding in, then that new value will clobber the default
+     binding the next time we unload it.  */
+  if (blv->fwd)
+    swap_in_symval_forwarding (sym, blv);
+
   return variable;
 }