From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: Why didn't setq work here?
Date: Sat, 08 Jan 2011 09:50:02 +1100 [thread overview]
Message-ID: <87lj2w9vmt.fsf@puma.rapttech.com.au> (raw)
In-Reply-To: mailman.6.1294416372.29236.help-gnu-emacs@gnu.org
Eric Lilja <mindcooler@gmail.com> writes:
> On 2011-01-07 15:26, Tassilo Horn wrote:
>> Eric Lilja<mindcooler@gmail.com> writes:
>>
>>> I have one final question though. fill-column does seem to be a
>>> variable.
>>
>> It is.
>>
>>> It can be described using C-h v and set using M-x
>>> set-variable. However, if I replace (set-fill-column 76) with (setq
>>> fill-column 76) the variable value is never changed (and no byte
>>> compiler warning btw).
>>
>> I presume, your observation is false. In fact, `set-fill-column' does
>> nothing except reading its argument and then doing (setq fill-column
>> arg) itself.
>>
>> Bye,
>> Tassilo
>>
>>
>>
>
> Thanks for your reply Mr Horn. Either my mind is playing tricks on me or there
> is some stochastic error here which makes setq sometimes not stick. I tried it
> ten times in a row and one time it claimed fill-column was at the default
> value. Anyway, I documented my .emacs like the following and I now consider
> this case closed. I learned quite a bit about configuring emacs in this little
> thread so I am happy! I will look out for set-fill-column not "sticking" as it
> should if my brain was indeed not fooling me.
>
Something to be aware of is that emacs has what are called buffer local
variables, that behave a little differently from normal global
variables.
Essentially, a buffer will use the global value for a buffer local
variable until that variable is modified/changed. From that point
onwards, the buffer will have its own copy of that variable with a new
value and will use that value instead of the global value.
What this means in practice is that the value you see for a buffer local
variable may be different depending on what buffer you are in when you
examine the value. So, if you are changing the value of fill-column,
which is a buffer local variable, in a specific mode via a mode hook,
you need to make sure you are in a buffer of that mode before you look
at the value of fill-column to see what it is now set to. This could
possibly explain why you observed what appeared to be inconsistent
behavior. Note also that if you use a function to set a buffer local
variable, you need to ensure it is associated with the appropriate
buffer, either via a mode hook or by switching to that buffer and doing
it via the interactive form of set variable.
HTH
Tim
P.S. Newer versions of emacs come with "An Introduction to Emacs Lisp"
by Robert J. Chassell (normally in info format). This is an excellent
starting point on emacs lisp and is not too taxing - very gentle in
fact. You can also get it on-line via the FSF website. I would strongly
recommend a quick read. It will clarify some of the terminology and key
concepts, saving you lots of time in the long run.
--
tcross (at) rapttech dot com dot au
next prev parent reply other threads:[~2011-01-07 22:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 2:05 Why didn't setq work here? Eric Lilja
2011-01-07 3:40 ` Deniz Dogan
2011-01-07 12:43 ` Eric Lilja
2011-01-07 14:26 ` Tassilo Horn
2011-01-07 16:05 ` Eric Lilja
2011-01-07 16:59 ` Peter Dyballa
2011-01-08 17:29 ` Tassilo Horn
[not found] ` <mailman.6.1294416372.29236.help-gnu-emacs@gnu.org>
2011-01-07 22:50 ` Tim X [this message]
[not found] <mailman.23.1294365997.1330.help-gnu-emacs@gnu.org>
2011-01-07 2:54 ` Pascal J. Bourguignon
2011-01-07 3:50 ` rusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lj2w9vmt.fsf@puma.rapttech.com.au \
--to=timx@nospam.dev.null \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).