[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cleaning up code
From: |
Michael Albinus |
Subject: |
Re: Cleaning up code |
Date: |
Thu, 15 Aug 2013 10:40:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> However, setting `byte-compile-force-lexical-warnings' to t is too
>> coarse. For example, Tramp's macro `with-parsed-tramp-file-name'
>> let-binds several variables "just in case". They are reported as unused
>> then, on every invocation of that macro.
>
> Yup, that's one of the main problems: when a single let in the source
> ends up duplicated after expansion so some expansions may use it while
> others end up not using it.
>
> We need to add some way to tell Emacs that it should check "the sum of
> all uses" or something like that. In your case, this "sum" is
> open-ended, so we should instead just tell it not to check at all.
Yep.
There is also another case where it doesn't work as expected. Often, I
let bind a variable for side effect, like this:
(let ((default-directory (tramp-compat-temporary-file-directory))
(outline-regexp tramp-debug-outline-regexp))
(outline-mode))
And I get from the byte compiler
tramp.el:1400:1:Warning: Unused lexical variable `outline-regexp'
In Tramp, there are many such stanzas of intended side effect
bindings. Therefore, there are too many false positives, that I could
see the real warnings I should fix.
Could we have a byte-compiler option telling that such bindings are
intended? Something like this:
(let ((byte-compile-force-lexical-warnings nil)
(default-directory (tramp-compat-temporary-file-directory))
(outline-regexp tramp-debug-outline-regexp))
(outline-mode))
> Stefan
Best regards, Michael.