emacs-devel
[Top][All Lists]
Advanced

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

Re: with a fresh emacs "(buffer-local-value fundamental-mode (current-


From: Davis Herring
Subject: Re: with a fresh emacs "(buffer-local-value fundamental-mode (current-buffer))" error.
Date: Thu, 9 Apr 2009 08:26:57 -0700 (PDT)
User-agent: SquirrelMail/1.4.8-5.3.lanl2

>> First, you need to quote your variable names:
> Prob. but in this case, once the variable is set (evaluated) I don't :P
>
> (longlines-mode)
> (buffer-local-value longlines-mode (current-buffer)) => t
> (longlines-mode)
> (buffer-local-value longlines-mode (current-buffer)) => nil

Because you are only using (current-buffer), you are missing something
rather important.  `buffer-local-value' is a function, so its arguments
are evaluated before it is even called.  What you have done is equivalent
to

(buffer-local-value 't (current-buffer))
(buffer-local-value 'nil (current-buffer))

because t and nil are the values that `longlines-mode' has each time you
check.  (Of course, you do not normally quote t and nil, but this is the
formally equivalent thing.)

Since t and nil are constants that are their own values (which is why you
don't quote them!), their value in any buffer is themselves, so you just
get them back from `buffer-local-value'.  If you try doing something like

(longlines-mode)
(buffer-local-value longlines-mode (get-buffer-create "*other*"))
(longlines-mode)
(buffer-local-value longlines-mode (get-buffer-create "*other*"))

you will _still_ get t and then nil, because the other buffer is entirely
irrelevant to the _value_ of `longlines-mode' (which is implicitly derived
from the current buffer).  If instead you try

(longlines-mode)
(buffer-local-value 'longlines-mode (get-buffer-create "*other*"))
(longlines-mode)
(buffer-local-value 'longlines-mode (get-buffer-create "*other*"))

...you will get nil twice, because calling `longlines-mode' in this buffer
doesn't change its value in *other*.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

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