From: Joel Reicher <joel.reicher@gmail.com>
To: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Cc: Heime <heimeborgia@protonmail.com>
Subject: Re: fill-column setq-default and add-hook
Date: Wed, 04 Dec 2024 23:00:12 +1100 [thread overview]
Message-ID: <86ed2nr73n.fsf@gmail.com> (raw)
In-Reply-To: <F5jffkEwtQo2yAD8pQLvxBMlkpwdtJC1PVzhOwpBpXMy19X9b3gPUu-lNyRjQTQrwkNWJVQcpxF9jYrtF5j1TIh_7woQ88pGNsxEa5nXnLE=@protonmail.com> (Heime via Users list for the's message of "Sat, 30 Nov 2024 17:38:15 +0000")
Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> I want to understand the setting of fill-column. It is a buffer
> local variable.
>
> But then there the following possibilities
>
> (setq-default fill-column 72)
>
> and
>
> (add-hook 'prog-mode-hook (lambda () (setq fill-column 72)))
>
> The first sets fill-column globally.
It sets a default value, which is a different instance than any of
the buffer local instances. ("Instance" is not strictly the
correct term, but I'm trying it on.)
> What does that mean? I interpret that the value is set globally
> but only to those buffers for which there is no local binding.
It doesn't set anything for a buffer. It sets the default
instance. Any buffer that lacks a local instance will use that
default instance. Any local instance created after that will
default to the value of that default instance.
> This setting the value (setq-default fill-column 72) does not
> always work for the current buffer.
It's not really doing anything to any buffer. It's doing something
to the default instance. The question of which buffers (if any)
use that instance is separate.
> How can one solve this problem?
If you want to set the current buffer's value, use setq.
> What does the mode hook do exactly?
When you enter a mode derived from prog-mode, it will set
fill-column to 72, which for that variable creates a buffer local
instance of it (and sets that instance).
Regards,
- Joel
next prev parent reply other threads:[~2024-12-04 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-30 17:38 fill-column setq-default and add-hook Heime via Users list for the GNU Emacs text editor
2024-12-04 12:00 ` Joel Reicher [this message]
2024-12-04 12:39 ` Heime via Users list for the GNU Emacs text editor
2024-12-05 1:46 ` Joel Reicher
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=86ed2nr73n.fsf@gmail.com \
--to=joel.reicher@gmail.com \
--cc=heimeborgia@protonmail.com \
--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).