emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: frame-local variables weirdness


From: Stefan Monnier
Subject: Re: frame-local variables weirdness
Date: Wed, 17 Oct 2007 19:53:03 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

>> I found the discussion.  I see that someone asked for a feature to
>> display frame-specific data in the mode line, and I decided this
>> general feature (with which the job could be done) was cleaner and
>> simpler than a specific feature which could do only that one job.

> That's a reasonable request, and indeed there are situations where we can
> lookup a variable but we cannot call a function which could potentially run
> arbitrary code.
> Maybe that's enough to keep the feature.

>> Since it isn't very useful, we can take it out if we cannot fix it.
>> But first let's try to fix it.

> But the above request does not mean we need to be able to mix&match
> let-bindings, buffer-local, and frame-local variables.  If we disallowed the
> buffer-local&frame-local variables, the problem would disappear.  This part
> of the language is already complex enough as it stands.

More specifically, I propose to change the manual to say that we cannot mix
buffer-local and frame-local with a single variable (just like a variable
cannot be both buffer-local and keyboard-local or keyboard-local and
frame-local).

This could come with the attached change in the code, which would fix the
OP's problem by signalling the odd situation earlier.  This would be
installed on the 22 branch, since it's obviously safe.


        Stefan


Index: data.c
===================================================================
RCS file: /sources/emacs/emacs/src/data.c,v
retrieving revision 1.280
diff -u -u -b -r1.280 data.c
--- data.c      16 Oct 2007 15:42:58 -0000      1.280
+++ data.c      17 Oct 2007 23:47:34 -0000
@@ -1521,7 +1521,9 @@
   variable = indirect_variable (variable);
 
   valcontents = SYMBOL_VALUE (variable);
-  if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
+  if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents)
+      || (BUFFER_LOCAL_VALUEP (valcontents)
+         && XBUFFER_LOCAL_VALUE (valcontents)->check_frame))
     error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME 
(variable)));
 
   if (BUFFER_OBJFWDP (valcontents))
@@ -1578,7 +1580,9 @@
   variable = indirect_variable (variable);
 
   valcontents = SYMBOL_VALUE (variable);
-  if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
+  if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents)
+      || (BUFFER_LOCAL_VALUEP (valcontents)
+         && XBUFFER_LOCAL_VALUE (valcontents)->check_frame))
     error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME 
(variable)));
 
   if ((BUFFER_LOCAL_VALUEP (valcontents)
@@ -1733,8 +1737,9 @@
   variable = indirect_variable (variable);
 
   valcontents = SYMBOL_VALUE (variable);
-  if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)
-      || BUFFER_OBJFWDP (valcontents))
+  if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents)
+      || (BUFFER_LOCAL_VALUEP (valcontents)
+         && !XBUFFER_LOCAL_VALUE (valcontents)->check_frame))
     error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable)));
 
   if (BUFFER_LOCAL_VALUEP (valcontents))


Diffs between working revision and workfile end here.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]