Subject: bug#24354: Address some compiler warnings in undo-tree

From: Jonas Bernoulli <[email-masked]>
Date: Fri, 02 Sep 2016 15:32:26 +0200

Hello,

The below two commits address some compiler warnings in `undo-tree',
which is available from GNU Elpa.  They should be applied to the
upstream repository, which should then be merged into its Elpa
subtree.

Earlier I have pointed out that `undo-tree' isn't currently being
properly merged into the Elpa repository.  See debbugs#24303.  It
would probably be a good idea to take care of that first.

----------------------------------------------------------------
After applying these two patches the byte-compiler still complains
about some other things:

    In undo-tree-pull-undo-in-region-branch:
    undo-tree.el:2279:36:Warning: ‘undo-elt-crosses-region’ is an obsolete
        function (as of 25.1).

    In undo-tree-pull-redo-in-region-branch:
    undo-tree.el:2476:25:Warning: ‘undo-elt-crosses-region’ is an obsolete
        function (as of 25.1).

    In end of data:
    undo-tree.el:4381:1:Warning: the function ‘gv--defsetter’ might not be
        defined at runtime.

Maybe `undo-elt-crosses-region' should not be declared to be obsolete
since `undo-tree' still uses it, or maybe `undo-tree' should stop using
it.  I don't know.

`undo-tree.el' requires `cl' and uses `defsetf' which is defined there.
The `defsetf' macro uses some functions from `gv.el', without requiring
`gv'.  Simply requiring `gv' in `undo-tree' should be avoided because
that would break compatibility with older Emacsen.  Also it does not
actually make that warning go away.  However it might be the case that
without explicitly requiring `gv' when using Emacsen that come with that
library might mean that `gv' might end up not being loaded at run-time,
and should therefore be explicitly loaded for such Emacsen.  I don't
know.

----------------------------------------------------------------
The following changes since commit a3e81b682053a81e082139300ef0a913a7a610a2
are available in the git repository at:

  [email-masked]:tarsius/undo-tree.git silencio

for you to fetch.

----------------------------------------------------------------
Jonas Bernoulli (2):
      Use _ as VAR in calls to dotimes.
      Declare two mode variables to silence byte-compiler.

 undo-tree.el | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

----------------------------------------------------------------
Toby, I am aware that I have suggested before that you use `_' as VAR in
calls to `dotimes' instead of `i'.  You rejected that suggestion,
claiming that the byte-compiler complaining about `i' not being used is
a bug.

That is not so, it is a feature, which is helpful when you accidentially
don't use `i'.  The byte-compiler *not* complaining when you use `_'
instead is also a feature, it allows using `dotimes' even when you
intentionally don't use `_' without getting these warnings which would
be bogus in this case.  This is not unique to `dotimes' and I think that
now that `undo-tree' is part of Emacs/Elpa you should respect those
conventions / use those features, even if you should think that they are
misguided.

  Best regards,
  Jonas