[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: add-to-list on lexical vars (Re: Error on loading polyglossia.el)
From: |
Tassilo Horn |
Subject: |
Re: add-to-list on lexical vars (Re: Error on loading polyglossia.el) |
Date: |
Sat, 09 Jan 2021 10:41:59 +0100 |
User-agent: |
mu4e 1.5.7; emacs 28.0.50 |
Ikumi Keita <ikumi@ikumi.que.jp> writes:
Hi Ikumi,
>>> I did notice, BTW, that this function uses `add-to-list`, the doc
>>> string of which warns against using it in Lisp code.
>
>> Yes, you should definitely not use it on lexical local variables.
>> With AUCTeX 13, we switched to lexical-binding, and now that doesn't
>> work anymore.
>
> According to the output of "git grep add-to-list", there are still
> some usage of `add-to-list' on lexical scope variables, and I made the
> attached patch. Does this look reasonable?
Yes, looks good to me.
> What is strange to me is that those wrong usages of `add-to-list'
> don't cause error in a way the former polyglossia.el troubled Joost.
> Customizing `TeX-view-program-list' and `TeX-view-program-selection'
> in custom buffer proceeds smoothly
I think the reason is that those usages are in back-ticked forms and
defcustom is a macro, and the expansion doesn't have those add-to-list
usages anymore. And probably the code being run in the macro expansion
phase isn't byte-compiled because it's a one-shot business anyway.
> and `TeX-add-to-alist' runs without error for me, even without the
> patch.
Not for me. Just eval in *scratch* which has lexical-binding at least
in my emacs master checkout:
--8<---------------cut here---------------start------------->8---
(let ((alist nil))
(TeX-add-to-alist 'alist '((a 1)))
alist) ;; <== C-j here
Debugger entered--Lisp error: (void-variable alist)
TeX-add-to-alist(alist ((a 1)))
(let ((alist nil)) (TeX-add-to-alist 'alist '((a 1))) alist)
(progn (let ((alist nil)) (TeX-add-to-alist 'alist '((a 1))) alist))
eval((progn (let ((alist nil)) (TeX-add-to-alist 'alist '((a 1))) alist)) t)
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
--8<---------------cut here---------------end--------------->8---
However, it works fine when I eval the form in this mail buffer (where
lexical-binding is nil).
While you are at it, could you please add some TeX-add-to-alist tests to
our suite. Looking at your relevant diff hunk it is obvious that this
function isn't trivial and some tests are justified.
Thanks!
Tassilo
Re: Error on loading polyglossia.el, Joost Kremers, 2021/01/09