Subject: bug#72229: (setq overriding-terminal-local-map nil) in isearch-done

From: Michael Heerdegen <[email-masked]>
Date: Tue, 23 Jul 2024 18:05:31 +0200

Juri Linkov <[email-masked]> writes:

> Indeed, you are right, `isearch-done' should restore the original value.
> The existing variable `isearch--saved-overriding-local-map' can't be used,
> so a similar variable should be added like in this patch:

LGTM for master - thank you.

> This mechanism looks like a variable watcher enabled by
> `add-variable-watcher'.
> So you could add a watcher that conditionally controls variable
> modifications.

I don't think variable watchers are very helpful here.  They don't solve
the underlying problem: potentially infinite variables of the same name
can exist, shadowing each other, with values partly sharing structures.

Using variable watchers I can see whether a variable value gets shadowed
or unassigned using a set operation - but I can't know whether the
previous value still exists, as binding of some other variable, and if
it will be stored back into the variable.  Nor do I have access to old
bindings and their values until the program assigns it back to the
variable.

I saw that in Bug#70938.  Manipulations of a variable can interfere in
annoying ways.

Functions are different.  You have only one dynamic binding (unless in
the rare case of using `cl-letf', which is extremely rare).  And you
always have access to it to undo any prior modification.

Michael.