all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* default-toplevel-value and set-default-toplevel-value
@ 2016-12-12 16:19 Eli Zaretskii
  2016-12-12 16:57 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-12 16:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

These functions were evidently introduced in Emacs 24.4, but they are
not documented, neither in NEWS nor in the ELisp manual.  The doc
strings are minimal, and leave me confused about how these are
different from default-value and set-default.  Is this just about a
possible let-binding of a localized variable, or is there something
else involved?

And why did the commit that added these functions also made changes in
Custom functions?

TIA



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-12 16:19 default-toplevel-value and set-default-toplevel-value Eli Zaretskii
@ 2016-12-12 16:57 ` Stefan Monnier
  2016-12-24 18:45   ` Eli Zaretskii
  2016-12-26  3:29   ` Eli Zaretskii
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2016-12-12 16:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> These functions were evidently introduced in Emacs 24.4, but they are
> not documented, neither in NEWS nor in the ELisp manual.  The doc
> strings are minimal, and leave me confused about how these are
> different from default-value and set-default.  Is this just about a
> possible let-binding of a localized variable,

Yes.

> or is there something else involved?

No, that's it.

> And why did the commit that added these functions also made changes in
> Custom functions?

Because this was introduced to make defvar (and defcustom) operate on
the default-toplevel-value rather than on the default-value, to avoid
problems when loading, from within a let-binding of foo-bar, a file `foo`
which defines foo-bar.  E.g. this happens when `foo-operate` is
autoloaded in code like:

   (let ((foo-bar t))
     (foo-operate ...))


-- Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-12 16:57 ` Stefan Monnier
@ 2016-12-24 18:45   ` Eli Zaretskii
  2016-12-26  3:29   ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-24 18:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 12 Dec 2016 11:57:09 -0500
> 
> > These functions were evidently introduced in Emacs 24.4, but they are
> > not documented, neither in NEWS nor in the ELisp manual.  The doc
> > strings are minimal, and leave me confused about how these are
> > different from default-value and set-default.  Is this just about a
> > possible let-binding of a localized variable,
> 
> Yes.
> 
> > or is there something else involved?
> 
> No, that's it.

It seems there is:

    (defvar bufferlocal 'value-default)
     => bufferlocal

    (setq-default bufferlocal 'value-default)
     => value-default

    (setq-local bufferlocal 'value-in-foo)
     => value-in-foo

    (let ((bufferlocal 'let-bound-value))
      (default-value 'bufferlocal))
     => value-default

Based on what you said, I expected the last expression to yield
let-bound-value.  What am I missing?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-12 16:57 ` Stefan Monnier
  2016-12-24 18:45   ` Eli Zaretskii
@ 2016-12-26  3:29   ` Eli Zaretskii
  2016-12-26  4:09     ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-26  3:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 12 Dec 2016 11:57:09 -0500
> 
> > These functions were evidently introduced in Emacs 24.4, but they are
> > not documented, neither in NEWS nor in the ELisp manual.  The doc
> > strings are minimal, and leave me confused about how these are
> > different from default-value and set-default.  Is this just about a
> > possible let-binding of a localized variable,
> 
> Yes.
> 
> > or is there something else involved?
> 
> No, that's it.

I seem to see there's more to this than meets the eye, see
http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00924.html.
Could you please help me understand it?  I'd like to document this for
Emacs 25.2.

TIA



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-26  3:29   ` Eli Zaretskii
@ 2016-12-26  4:09     ` Stefan Monnier
  2016-12-26 15:40       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-12-26  4:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> I seem to see there's more to this than meets the eye, see
> http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00924.html.
> Could you please help me understand it?  I'd like to document this for
> Emacs 25.2.

I don't understand: there's no use of default-toplevel-value in your
example, AFAICT.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-26  4:09     ` Stefan Monnier
@ 2016-12-26 15:40       ` Eli Zaretskii
  2016-12-26 16:45         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-26 15:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: emacs-devel@gnu.org
> Date: Sun, 25 Dec 2016 23:09:37 -0500
> 
> > I seem to see there's more to this than meets the eye, see
> > http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00924.html.
> > Could you please help me understand it?  I'd like to document this for
> > Emacs 25.2.
> 
> I don't understand: there's no use of default-toplevel-value in your
> example, AFAICT.

Yes, because there doesn't seem to be any need for using it, as
default-value is unaffected by the let-binding.  I expected
default-value to return the value from let-binding, and
default-toplevel-value to return the global value, otherwise I don't
see why the latter is needed.  I guess I misunderstood something that
you and/or the doc string were trying to tell.

Thanks.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-26 15:40       ` Eli Zaretskii
@ 2016-12-26 16:45         ` Stefan Monnier
  2016-12-26 17:13           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-12-26 16:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> Yes, because there doesn't seem to be any need for using it, as
> default-value is unaffected by the let-binding.

That's because the let-binding was in a buffer which had a buffer-local
value, so the let-binding only affects the buffer-local value.

    (defun get-A ()
      (with-current-buffer "A" myvar))
    (defun get-B ()
      (with-current-buffer "B" myvar))

    (defun get-test ()
      (setq myvar 'global)
      (with-current-buffer (get-buffer-create "A")
        (setq-local myvar 'local-A))
      (with-current-buffer (get-buffer-create "B")
        (setq-local myvar 'local-B))
      (list (list (get-A) (get-B) (default-value 'myvar))
            (with-current-buffer "*scratch*"
              (let ((myvar 'let-bound))
                (list (get-A) (get-B) (default-value 'myvar))))
            (with-current-buffer "A"
              (let ((myvar 'let-bound))
                (list (get-A) (get-B) (default-value 'myvar))))
            (with-current-buffer "B"
              (let ((myvar 'let-bound))
                (list (get-A) (get-B) (default-value 'myvar))))))


-- Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-26 16:45         ` Stefan Monnier
@ 2016-12-26 17:13           ` Eli Zaretskii
  2016-12-27  1:17             ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-26 17:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 26 Dec 2016 11:45:55 -0500
> 
> > Yes, because there doesn't seem to be any need for using it, as
> > default-value is unaffected by the let-binding.
> 
> That's because the let-binding was in a buffer which had a buffer-local
> value, so the let-binding only affects the buffer-local value.

So this is only for when Lisp code runs in a buffer that doesn't have
a localized binding?

Thanks, I think I've got it.  Please see if the documentation I just
pushed to the emacs-25 branch looks okay.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: default-toplevel-value and set-default-toplevel-value
  2016-12-26 17:13           ` Eli Zaretskii
@ 2016-12-27  1:17             ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2016-12-27  1:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> That's because the let-binding was in a buffer which had a buffer-local
>> value, so the let-binding only affects the buffer-local value.
> So this is only for when Lisp code runs in a buffer that doesn't have
> a localized binding?

Right, which is also "any buffer" if the buffer doesn't have any
buffer-local settings in any buffer.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-12-27  1:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12 16:19 default-toplevel-value and set-default-toplevel-value Eli Zaretskii
2016-12-12 16:57 ` Stefan Monnier
2016-12-24 18:45   ` Eli Zaretskii
2016-12-26  3:29   ` Eli Zaretskii
2016-12-26  4:09     ` Stefan Monnier
2016-12-26 15:40       ` Eli Zaretskii
2016-12-26 16:45         ` Stefan Monnier
2016-12-26 17:13           ` Eli Zaretskii
2016-12-27  1:17             ` Stefan Monnier

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.