all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Heime <heimeborgia@protonmail.com>
Cc: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : The operation of default-value
Date: Fri, 2 Dec 2022 02:49:04 +0000	[thread overview]
Message-ID: <SJ0PR10MB54882475F858A9385FB33FF1F3179@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <QWPMZwQ3laQ1OxZ_HHEgcpXT5LETzrHZ4UeErnn42u_xYzyRs1EOIv53xcZrItnN-qgkBPP0FC3VDdPeaSMujlfZKHzLzzKLbjx4Fshd5kQ=@protonmail.com>

> > I think node `Creating Buffer-Local' explains this.
> >
> > If you don't create/set a buffer-local value in
> > buffer A for a variable then its global, "default"
> > value applies in buffer A. It's as simple as that.
> 
> Meaning that a package can change the buffer-local variable,
> with the default-value being different.

A package, or anything else, can set a buffer-local
value, yes.

> Thusly, the variable used in the buffer is either
> the default value when the local
> value is nil, or the local value when they differ.

You can think of it being a different variable, yes.
Or you can think of it as being the same variable,
with both (1) a default value and (2) a buffer-local
value; that is, with two kinds of _bindings_.  The
doc generally speaks of it in this second way:

  “buffer-local” bindings, which apply only in one
   buffer.  Having different values for a variable
   in different buffers

But it also talks about "buffer-local variables" (not
just buffer-local variable bindings):

   A buffer-local variable has a buffer-local binding
   associated with a particular buffer.

"Buffer-local variable" refers to the buffer-local
binding of a variable.

`setq-local' sets the buffer-local value for the
current buffer.  So does `setq', if the variable
has already been made buffer-local in the buffer.

`make-local-variable' makes a variable's value be
buffer-local in the current buffer.
`make-variable-buffer-local' makes a variable always
be buffer-local, in every buffer.

If you look at the definition of `setq-local' you'll
see that it's just this, since `make-local-variable'
conveniently returns the variable (symbol).

  (set (make-local-variable 'VARIABLE VALUE))

> Meaning that I cannot rely completely on default-value,
> because the local value might be set up differently.

As usual, your meaning isn't clear.  Specify what
you mean by "rely completely on".

Even when a variable has a buffer-local value, you
can always access -- get or set -- its default value.
Functions `default-value' and `setq-default' do that,
respectively.

If this explanation helps, I suggest you reread the
doc that covers this subject.  With the added
understanding you may get more out of it on a second
reading.  If this didn't help, hopefully someone else
can help better.  But you really owe it to yourself,
as well as those who try to help you, to make clearer
what you're asking.

  reply	other threads:[~2022-12-02  2:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 22:47 The operation of default-value Heime
2022-12-01 23:16 ` [External] : " Drew Adams
2022-12-01 23:35   ` Heime
2022-12-02  2:49     ` Drew Adams [this message]
2022-12-02  2:57       ` Emanuel Berg
2022-12-02  3:03         ` Emanuel Berg

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB54882475F858A9385FB33FF1F3179@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.