[Top][All Lists]

[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 20:19:57 -0700

> It seems that mode-line-format was "always buffer-local" in 
> Emacs-20 and changed to "buffer-local by default" in Emacs-21.
> I don't know what was the reason for it, but in any case an
> explicit call to `make-local-variable' before the let will
> clear up any ambiguity.

Oh, I thought it _was_ always buffer-local, even in recent Emacs. And I thought
the manual was advising not to use `let' with buffer-local variables. 

That text is not too clear to me. Is it trying to say instead to not use `let'
with a variable that _will be_ buffer-local but is not yet so? But it's OK to
use `let' with a variable that is already buffer-local? Not too clear, IMO.

Yes, it's simpler and looks cleaner to do what you mention than to monkey around
with setq and unwind-protect. From the doc, I didn't get the impression that
that would help, but it seems to work fine.

(defun foo (text &optional buffer)
  (with-current-buffer (or buffer (current-buffer))
    (make-local-variable 'mode-line-format)
    (let ((mode-line-format  text))
      (force-mode-line-update) (sit-for 10))

Whether or not that is actually cleaner, I don't know, but it certainly looks
so. I admit that I don't understand the problem with `let' and
buffer-local-to-be-but-not-yet vars.

reply via email to

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