emacs-devel
[Top][All Lists]
Advanced

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

RE: mode-line-format - local variableness


From: Drew Adams
Subject: RE: mode-line-format - local variableness
Date: Sun, 5 Apr 2009 16:29:23 -0700

> From: Johan "Bockgård" Sent: Sunday, April 05, 2009 3:50 PM
> > What am I missing? `mode-line-format' is a buffer-local variable.
> 
> No, it isn't.
> (local-variable-p 'mode-line-format)         => nil
> (local-variable-if-set-p 'mode-line-format)  => t

Then there seems to be a bug (either Emacs behavior or doc). `C-h v
mode-line-format' seems to say that it is buffer-local:

"Automatically becomes buffer-local when set in any fashion."
And "Each buffer has its own value of this variable."

And exactly the same thing is said after you do M-: (make-variable-buffer-local
'mode-line-format). To me, that doc is saying that the variable is buffer-local
in all buffers: setting it in a buffer affects only the mode-line of that
buffer.

Looking at some of the Emacs source code, things are not too clear. hideshow.el
(why hideshow.el?), for instance, calls `make-variable-buffer-local' for it. I
don't see where it is made buffer-local generally (hide-show.el is not loaded by
default, AFAIK), but the doc string does seem to indicate that it is. (Maybe
it's done in C code.)

To me, the behavior from the code snippet I sent seems like a product bug, not a
doc bug. But Emacs has been this way apparently since Emacs 21 (not 20).
 
Wrt the code I sent (which uses `let', not `setq'), this, from Elisp manual node
Creating Buffer-Local, seems to be part of the explanation:

"A peculiar wrinkle of this feature is that binding the variable
(with `let' or other binding constructs) does not create a
buffer-local binding for it.  Only setting the variable (with
`set' or `setq'), while the variable does not have a `let'-style
binding that was made in the current buffer, does so."

That text was not present in Emacs 20, where the code works (only the mode-line
of the given buffer is affected).

I guess the bottom line is that I will need to use `setq' for the code to work
beyond Emacs 20. Presumably (hopefully), the change that introduced "this
feature" (whatever the undisclosed feature might be) did improve something, even
at the cost of breaking this. Further elucidations/advice is welcome.






reply via email to

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