[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexica
From: |
Mattias Engdegård |
Subject: |
bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding |
Date: |
Sat, 1 Feb 2020 20:24:56 +0100 |
1 feb. 2020 kl. 08.48 skrev Eli Zaretskii <eliz@gnu.org>:
> If that's the case, then why don't we say that loud and clear in the
> ELisp manual? (The doc string of add-to-list has some vague
> recommendation, not sure if it really talks about this aspect, but
> that's definitely not enough for such a serious issue.)
>
> And doesn't it mean we should audit all the gazillion uses of
> add-to-list in our sources, and do that urgently?
Yes, I agree, but it's not quite as simple as I thought at first. A mechanised
scan of the source for uses of add-to-list on lexical variables revealed a
handful:
lisp/cedet/mode-local.el:823:23: add-to-list to lexical variable mc
lisp/net/tramp-cache.el:376:45: add-to-list to lexical variable properties
lisp/net/tramp-cache.el:430:25: add-to-list to lexical variable result
lisp/net/zeroconf.el:259:40: add-to-list to lexical variable result
lisp/net/zeroconf.el:267:40: add-to-list to lexical variable result
lisp/net/zeroconf.el:281:23: add-to-list to lexical variable result
lisp/org/org.el:18685:49: add-to-list to lexical variable load-uncore
lisp/autoinsert.el:174:47: add-to-list to lexical variable modes
lisp/whitespace.el:1687:33: add-to-list to lexical variable style
test/lisp/emacs-lisp/map-tests.el:230:30: add-to-list to lexical variable result
However, add-to-list has a compiler macro which tries to make it work even for
lexical variables, and it mostly does -- specifically, when the LIST-VAR
parameter is on the form (quote VARIABLE), which is the case in all the above
cases except the one i mode-local.el.
The macro (which apparently works in non-compiled code as well) attempts to
warn about lexical variables but somehow this warning doesn't always trigger. I
haven't researched this further.
It all seems rather fragile to me, and I'd rather add a note about not using
add-to-list for lexical variables to its doc string and the manual, and fix all
the calls listed above. However, this last point is not strictly necessary for
correctness.
Two patches attached: a doc update, and a replacement of add-to-list in the
cases listed above.
0001-Clarify-add-to-list-documentation-bug-39373.patch
Description: Binary data
0002-Replace-add-to-list-to-lexical-variable-with-push-bu.patch
Description: Binary data
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Eli Zaretskii, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Drew Adams, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding,
Mattias Engdegård <=
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Eli Zaretskii, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Stefan Monnier, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Mattias Engdegård, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Eli Zaretskii, 2020/02/01
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Mattias Engdegård, 2020/02/02
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Stefan Monnier, 2020/02/02
- bug#39373: 27.0.50; [PATCH] mode-local-print-bindings broken with lexical-binding, Mattias Engdegård, 2020/02/02