Subject: Re: #40185: 28.0.50; Emacs Calc selection of a sub-formula doesn't highlight it
From: Mattias Engdegård <[email-masked]>
To: Narendra Joshi <[email-masked]>
Cc: [email-masked]
Date: Mon, 23 Mar 2020 21:37:40 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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.