unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Andreas Schwab'" <schwab@linux-m68k.org>
Cc: 5971@debbugs.gnu.org, tracker@debbugs.gnu.org,
	'GNU bug Tracking System' <help-debbugs@gnu.org>
Subject: bug#5971: 23.1.95; `delete' modifies default value instead of buffer-local value
Date: Mon, 19 Apr 2010 11:58:07 -0700	[thread overview]
Message-ID: <6CC9DF69BADF4A27825D1A0BDE4219F1@us.oracle.com> (raw)
In-Reply-To: <m2hbn7l1w4.fsf@igel.home>

> >> > Nothing in the doc states that they share list structure.
> >> 
> >> There is no buffer-local value before you set it.
> >
> > Yes, I know that. And I noted that explicitly.
> 
> So you know that the default value is *the value you are modifying*.

No, I do not know that. Where does it say that `setq' modifies the default
value?

If there is no buffer-local value, then the default value is used, yes. That
doesn't say anything about modifying or setting anything.

The modification of the default value was done in buffer X. It is buffer Y that
does not yet have a buffer local value. When modifying buffer X's value of the
var, I used `setq' with `delete'. I did not use `setq-default'.

I do not see any doc that would indicate that `setq' with `delete' should modify
the default value. On the contrary, everything seems to say that setting the var
using setq should set the buffer-local value (only).

> >> The doc is pretty clear that a buffer-local value only 
> >> starts to exist the first time it is set:
> >> 
> >> Make VARIABLE become buffer-local whenever it is set.
> >> At any time, the value for the current buffer is in effect,
> >> unless the variable has never been set in this buffer,
> >> in which case the default value is in effect.
> >>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > Yes, and I explictly said that too. Please read what I wrote.
> 
> Please read what I wrote.

You just repeated what I acknowledged from the beginning: it is normal that if
no buffer-local value is set in buffer Y then the default value for the variable
is used (returned) in buffer Y.

That has nothing to do with the question at hand, which is how/why
modifying/setting the buffer-local value in buffer X also ends up
modifying/setting the default value. 

When, in buffer X, I use `setq' with `delete' I am destructively modifying the
_buffer-local_ value in X, not the default value.

Or at least that's what the doc says I am doing. The variable is declared with
`make-variable-buffer-local', which means that whenever it is set it is the
_buffer-local_ value that is set (unless I use, say, `setq-default').

> > What is _not_ documented AFAICT is that using `delete' to 
> > set the buffer-local value in buffer X also modifies the
> > default value. There is no reason to expect that, from reading the doc.
> 
> You are *not* modifying the buffer-local value, because *it does not
> exist* yet.

No, it does not yet exist when I set it (in buffer X). But it is a buffer-local
variable, declared using `make-variable-buffer-local'. And that means that
_whenever it is set_, it is the buffer-local value, _not_ the default value,
that is set.

,----
| make-variable-buffer-local is an interactive built-in function in `C
| source code'.
| 
| (make-variable-buffer-local VARIABLE)
| 
| Make VARIABLE become buffer-local whenever it is set.
| At any time, the value for the current buffer is in effect,
| unless the variable has never been set in this buffer,
| in which case the default value is in effect.
| Note that binding the variable with `let', or setting it while
| a `let'-style binding made in this buffer is in effect,
| does not make the variable buffer-local.  Return VARIABLE.
| 
| In most cases it is better to use `make-local-variable',
| which makes a variable local in just one buffer.
| 
| The function `default-value' gets the default value and `set-default' sets it.
`----

What part of "whenever it is set" is one of us not understanding?

Using `setq' to set the variable should set its _buffer-local_ value.

Yes, until you set the buffer-local value, it is the default value that is
returned for the variable. But "_whenever it is set_", it is the buffer-local
value that is set, _not_ the default value.

At least that's what the doc says.







  reply	other threads:[~2010-04-19 18:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-19  2:41 bug#5971: 23.1.95; `delete' modifies default value instead of buffer-local value Drew Adams
2010-04-19  4:23 ` Stefan Monnier
2010-04-19  5:24   ` Drew Adams
2010-04-19  6:25     ` Stefan Monnier
2010-04-19 15:09       ` Drew Adams
2010-04-19 15:56         ` Glenn Morris
2010-04-19 16:05         ` Andreas Schwab
2010-04-19 16:15           ` Drew Adams
2010-04-19 16:31             ` Andreas Schwab
2010-04-19 17:03               ` Drew Adams
2010-04-19 18:42                 ` Andreas Schwab
2010-04-19 18:58                   ` Drew Adams [this message]
2010-04-19 20:18                     ` Andreas Schwab
2010-04-19 20:31                       ` Drew Adams
2010-04-19 20:38                         ` Andreas Schwab
2010-04-19 22:06                           ` Drew Adams
2010-04-21  7:29                             ` Kevin Rodgers
2010-04-21 11:58                               ` Drew Adams
2011-07-09  5:47                               ` Glenn Morris
2010-04-19 15:09     ` bug#5971: - reopen Drew Adams

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=6CC9DF69BADF4A27825D1A0BDE4219F1@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=5971@debbugs.gnu.org \
    --cc=help-debbugs@gnu.org \
    --cc=schwab@linux-m68k.org \
    --cc=tracker@debbugs.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 public inbox

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

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).