Ask etags to stop language auto-detection from falling back to Fortran and C?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Ask etags to stop language auto-detection from falling back to Fortran and C?

Dmitry Gutov
So, I want auto-detection, but the list of files I'm passing to etags is
very naively auto-generated (basically, all files in the project), and
includes languages that etags doesn't know about (e.g. CSS).

How do I stop it from parsing them as Fortran files? Please add an option.

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Eli Zaretskii
> From: Dmitry Gutov <[hidden email]>
> Date: Thu, 11 Jan 2018 03:07:39 +0300
>
> So, I want auto-detection, but the list of files I'm passing to etags is
> very naively auto-generated (basically, all files in the project), and
> includes languages that etags doesn't know about (e.g. CSS).
>
> How do I stop it from parsing them as Fortran files? Please add an option.

There is already such an option: --language=none.  If you have both
files that you do want etags to parse for some language and files that
you don't, then either put all the latter at the end of the list and
precede them with --language=none, or wrap each such file name with
"--language=none FILE --language=auto".  This works because --language
takes effect on files specified after it.

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Dmitry Gutov
On 1/11/18 7:41 PM, Eli Zaretskii wrote:

> There is already such an option: --language=none.  If you have both
> files that you do want etags to parse for some language and files that
> you don't,

I want etags to detect the language, but without the ridiculous
fallback. Like described in its help output:

     ... If no such sequence is found,
     Fortran is tried first; if no tags are found, C is tried next.

> then either put all the latter at the end of the list and
> precede them with --language=none, or wrap each such file name with
> "--language=none FILE --language=auto".  This works because --language
> takes effect on files specified after it.

Won't "--language=none" stop it detecting the language based on file
extension and the sharp-bang declaration?


Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Eli Zaretskii
> Cc: [hidden email]
> From: Dmitry Gutov <[hidden email]>
> Date: Fri, 12 Jan 2018 00:49:36 +0300
>
> On 1/11/18 7:41 PM, Eli Zaretskii wrote:
>
> > There is already such an option: --language=none.  If you have both
> > files that you do want etags to parse for some language and files that
> > you don't,
>
> I want etags to detect the language, but without the ridiculous
> fallback.

I don't understand: if the file's language can be detected by means
known to etags, then it will never get to the fallbacks.  It will only
try the fallbacks if all the means to detect the language failed.  So
what do you mean by "detect, but without the fallbacks"?

> > then either put all the latter at the end of the list and
> > precede them with --language=none, or wrap each such file name with
> > "--language=none FILE --language=auto".  This works because --language
> > takes effect on files specified after it.
>
> Won't "--language=none" stop it detecting the language based on file
> extension and the sharp-bang declaration?

It will, for the files following --language=none on the command line
(but not for those that come before this switch).  But if the
extension and/or sharp-bang are in the file, the detection should not
have failed, and the fallbacks would not have been attempted.  So I
feel I'm missing something in your use case, because I don't
understand why you think --language=none is not what you want.

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Dmitry Gutov
On 1/12/18 11:16 AM, Eli Zaretskii wrote:

>> I want etags to detect the language, but without the ridiculous
>> fallback.
>
> I don't understand: if the file's language can be detected by means
> known to etags, then it will never get to the fallbacks.

OK, to *try to* detect the language.

> It will only
> try the fallbacks if all the means to detect the language failed.  So
> what do you mean by "detect, but without the fallbacks"?

I'm saying I don't want the fallbacks. If you've failed to detect the
language based on the file extension or the sharp-bang, stop, don't try
to parse the file with something that will most likely get wrong results.

> It will, for the files following --language=none on the command line
> (but not for those that come before this switch).  But if the
> extension and/or sharp-bang are in the file, the detection should not
> have failed,

It does if etags is unfamiliar with the file's language.

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Eli Zaretskii
> Cc: [hidden email]
> From: Dmitry Gutov <[hidden email]>
> Date: Fri, 12 Jan 2018 11:23:46 +0300
>
> > It will only
> > try the fallbacks if all the means to detect the language failed.  So
> > what do you mean by "detect, but without the fallbacks"?
>
> I'm saying I don't want the fallbacks. If you've failed to detect the
> language based on the file extension or the sharp-bang, stop, don't try
> to parse the file with something that will most likely get wrong results.
>
> > It will, for the files following --language=none on the command line
> > (but not for those that come before this switch).  But if the
> > extension and/or sharp-bang are in the file, the detection should not
> > have failed,
>
> It does if etags is unfamiliar with the file's language.

OK, so next question: why do you care about the fallbacks?  At worst,
they will generate tags that no one will ever try to find, right?

IOW, can you present a real-life use case where these fallbacks do any
harm?

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Dmitry Gutov
On 1/12/18 12:41 PM, Eli Zaretskii wrote:

> OK, so next question: why do you care about the fallbacks?  At worst,
> they will generate tags that no one will ever try to find, right?
>
> IOW, can you present a real-life use case where these fallbacks do any
> harm?

a) That increases the parsing time. Like, makes in 2-3 times longer in
one example I had.

b) It creates very weird entries, like some multiline undisplayable byte
sequence in one example (an OTF file, IIRC), and those do show up in the
completions list, for xref-find-references. Or C-u xref-find-definitions.

c) It does create false positives for real names. For instance, I can
search for the definition of 'push' (a method in Ruby or JS), and it
will show me these as possible destinations:

/home/dgutov/xxx/yyy/zzz/public/app/less/bs-less/mixins/grid.less
  33: .make-xs-column-push(
  57: .make-sm-column-push(
  85: .make-md-column-push(
113: .make-lg-column-push(

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Eli Zaretskii
> Cc: [hidden email]
> From: Dmitry Gutov <[hidden email]>
> Date: Fri, 12 Jan 2018 13:03:44 +0300
>
> a) That increases the parsing time. Like, makes in 2-3 times longer in
> one example I had.
>
> b) It creates very weird entries, like some multiline undisplayable byte
> sequence in one example (an OTF file, IIRC), and those do show up in the
> completions list, for xref-find-references. Or C-u xref-find-definitions.
>
> c) It does create false positives for real names. For instance, I can
> search for the definition of 'push' (a method in Ruby or JS), and it
> will show me these as possible destinations:
>
> /home/dgutov/xxx/yyy/zzz/public/app/less/bs-less/mixins/grid.less
>   33: .make-xs-column-push(
>   57: .make-sm-column-push(
>   85: .make-md-column-push(
> 113: .make-lg-column-push(

Thanks.  I consider these weak reasons, so it doesn't look a very
urgent issue, especially since running etags on all the files in a
tree is not a very wise thing to do anyway (as mentioned in
http://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00383.html).

However, feel free to file a feature request on debbugs, the
implementation shouldn't be hard.

Reply | Threaded
Open this post in threaded view
|

Re: Ask etags to stop language auto-detection from falling back to Fortran and C?

Dmitry Gutov
On 1/12/18 1:41 PM, Eli Zaretskii wrote:

> Thanks.  I consider these weak reasons, so it doesn't look a very
> urgent issue, especially since running etags on all the files in a
> tree is not a very wise thing to do anyway (as mentioned in
> http://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00383.html).

Like I mentioned in the same thread, Emacs development is not the
primary target of that feature. Nor are the projects that support 'make
tags'.

Not urgent, like "not for emacs-26"? With that I agree, of course.

> However, feel free to file a feature request on debbugs, the
> implementation shouldn't be hard.

Done.