Subject: bug#40185: #40185: 28.0.50; Emacs Calc selection of a sub-formula doesn't highlight it

From: Narendra Joshi <[email-masked]>
Date: Mon, 23 Mar 2020 23:37:07 +0100

Thanks for the explanation. :) I think I got it. It seems to me that
porting a large package like `calc` to use lexical binding everywhere
would mean fixing a lot of such bugs.

Is the fix also going to be merged to `master` or will it be merged
sometime later?

- Narendra

On Mon, Mar 23, 2020 at 9:37 PM Mattias Engdegård <[email-masked]> wrote:
>
> 23 mars 2020 kl. 20.06 skrev Narendra Joshi <[email-masked]>:
>
> > Can you please help me
> > understand what exactly the issue was and how declaring the variable
> > fixed it? I see that it is `defvar`ed  in `calc-ext.el`.
>
> 'defvar' without an initial value is a declaration scoped to the surrounding lexical scope (or file, if at top level). It appears that calc.el does not require calc-ext, so that math-comp-selected was assumed to be lexical where it was bound in math-format-stack-value. This caused it to have the wrong number further down the call tree (in math-comp-to-string-flat, I think).
>
> In Emacs 26 and earlier, calc.el used dynamic binding.
>
> Thanks for verifying! Patch pushed to emacs-27.
>