[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lexical-binding is turned on in more use cases

From: Alan Mackenzie
Subject: Re: lexical-binding is turned on in more use cases
Date: Mon, 9 Mar 2020 20:22:59 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Stefan.

On Sun, Mar 08, 2020 at 19:41:44 -0400, Stefan Monnier wrote:
> > .  This complained about c-syntactic-context being unbound, so I
> > tried:

> >    M-: (let ((c-syntactic-context (c-guess-basic-syntax)))
> >    (c-align-cpp-indent-to-body))

> > , and was puzzled that c-syntactic-context was _still_ unbound.  So I
> > checked the spelling, and was more puzzled.  Eventually I used setq,
> > which worked, but caused me further problems later on in my Emacs
> > session.

> Indeed `c-syntactic-context` is only declared as dynamically scoped in
> some files but not globally, for some reason.

That reason appearing to be a misfeature of defvar.  Why is (defvar foo)
a no-op?  Why does it not set the declared_special bit inside the symbol?
This would be sensible and consistent (even if unacceptable for Emacs

> It's rather unusual.

Even if that's the case, it doesn't make it unimportant.  Let binding
from the minibuffer should work consistently, its effect not varying
chaotically between dynamic and lexical binding.

[ .... ]

> > Furthermore, c-syntactic-context is explicitly declared a dynamic
> > variable by a defvar form.

> But a `defvar` with no 2nd arg (i.e. no default value), which means it
> only affects the current file (not sure if this is part of the reason
> why you have `(defvar c-syntactic-context)` both `cc-cmds.el` and in
> `cc-vars.el`, but it would explain it tho the `(cc-bytecomp-defvar
> c-syntactic-context)` in `cc-vars.el` makes the whole situation much
> more murky).

See above.  defvar should not be a no-op.  It shouldn't be necessary to
write (defvar foo) in more than one file.


> ;-)

> > Looking at the git log, it appears this change was made nearly a year ago.

> Indeed, it's a wonder you managed to survive with such a majorly broken
> Emacs for so long ;-)

Why did you not initiate a discussion on emacs-devel before committing
this patch?  Also the title of the patch is highly misleading, since the
patch has nothing to do with defaults, only with forced lexical binding,
whether wanted or not.

How about making this lexical binding optional, controlled by a
customisable variable?  It would not be difficult.

>         Stefan

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]