Subject: Re: bug#44494: etags.el xref-location-marker does not handle TAGS references to .el.gz files

From: Eli Zaretskii <[email-masked]>
Date: Sat, 07 Nov 2020 09:18:55 +0200

> From: Pierre Rouleau <[email-masked]>
> Date: Fri, 6 Nov 2020 18:22:46 -0500
> 
> One could consider that the issue is inside the etags utility.

I don't think this is the best alternative.  TAGS tables are supposed
to provide information in a way that doesn't require re-running etags
each time some change in the sources is made.  The way things are now,
compressing or decompressing a file doesn't require re-running etags,
which is a Good Thing.

Handling this in the code which accesses and interprets TAGS sounds
like a better alternative.

> Here's a proposal for a solution:
> 
> (defun etags-file-or-compressed-file-for (fname)
>   "Return the valid file name for FNAME.
> Check if FNAME is an existing file name, if not
> try FNAME appended with the following compression extensions:
> - \".gz\", the extension of compressed files created by gzip
> - \".bz2\", the extension for compressed files created by bzip2
> - \".xz\", the extension for compressed files created by xz
> - \".lzma\", the extension for compressed files created by xz.
> 
> Return the file that exists or nil if nothing found."
>   (let ((fpath nil))
>     (cl-dolist (ext '(""
>                       ".gz"
>                       ".bz2"
>                       ".xz"
>                       ".lzma"))
>       (setq fpath (concat fname ext))
>       (when (file-exists-p fpath)
>         (cl-return fpath)))))

We already have in etags.el support for finding compressed files, see
tag-find-file-of-tag-noselect.  Can't that be reused?  If not, let's
at least reuse tags-compression-info-list, okay?