all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* etags-regen-mode: handling extensionless files
@ 2024-09-20  9:20 Sean Whitton
  2024-09-20 18:23 ` Dmitry Gutov
  0 siblings, 1 reply; 17+ messages in thread
From: Sean Whitton @ 2024-09-20  9:20 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

Hello Dmitry,

I'm working on a Perl project which has .pm files (which should be added
to etags-regen-file-extensions; I've written mail about that) but also
programs intended for execution, which have no file extension:
    <https://salsa.debian.org/dgit-team/dgit>.
E.g. 'dgit' and 'git-debrebase' in the project root.

On the one hand, it makes sense not to index these files because they're
programs not libraries, so their internal definitions won't ever be
referenced elsewhere.

On the other hand, it would be nice just to be able to use a simple
M-. to jump to definition, and not have to think about whether the
function is defined in the program or in a library.

Should we have some etags defcustom that allows specifying extra files
to index?  Or, as another idea, maybe etags could somehow include
looking at what imenu finds?  Might be too clever.

Let me know what you think about this use case.

-- 
Sean Whitton



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-20  9:20 etags-regen-mode: handling extensionless files Sean Whitton
@ 2024-09-20 18:23 ` Dmitry Gutov
  2024-09-22 12:02   ` Sean Whitton
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-20 18:23 UTC (permalink / raw)
  To: Sean Whitton; +Cc: emacs-devel

Hi Sean,

On 20/09/2024 12:20, Sean Whitton wrote:

> I'm working on a Perl project which has .pm files (which should be added
> to etags-regen-file-extensions; I've written mail about that) but also
> programs intended for execution, which have no file extension:
>      <https://salsa.debian.org/dgit-team/dgit>.
> E.g. 'dgit' and 'git-debrebase' in the project root.
> 
> On the one hand, it makes sense not to index these files because they're
> programs not libraries, so their internal definitions won't ever be
> referenced elsewhere.

They're probably referenced internally though, at least once.

> On the other hand, it would be nice just to be able to use a simple
> M-. to jump to definition, and not have to think about whether the
> function is defined in the program or in a library.
> 
> Should we have some etags defcustom that allows specifying extra files
> to index?  Or, as another idea, maybe etags could somehow include
> looking at what imenu finds?  Might be too clever.

I guess we could add that extra option.

But see my other email regarding etags' hashbang detection.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-20 18:23 ` Dmitry Gutov
@ 2024-09-22 12:02   ` Sean Whitton
  2024-09-23 17:00     ` Dmitry Gutov
  0 siblings, 1 reply; 17+ messages in thread
From: Sean Whitton @ 2024-09-22 12:02 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

Hello,

On Fri 20 Sep 2024 at 09:23pm +03, Dmitry Gutov wrote:

> Hi Sean,
>
> On 20/09/2024 12:20, Sean Whitton wrote:
>
>> I'm working on a Perl project which has .pm files (which should be added
>> to etags-regen-file-extensions; I've written mail about that) but also
>> programs intended for execution, which have no file extension:
>>      <https://salsa.debian.org/dgit-team/dgit>.
>> E.g. 'dgit' and 'git-debrebase' in the project root.
>> On the one hand, it makes sense not to index these files because they're
>> programs not libraries, so their internal definitions won't ever be
>> referenced elsewhere.
>
> They're probably referenced internally though, at least once.

Good point.

>> On the other hand, it would be nice just to be able to use a simple
>> M-. to jump to definition, and not have to think about whether the
>> function is defined in the program or in a library.
>> Should we have some etags defcustom that allows specifying extra files
>> to index?  Or, as another idea, maybe etags could somehow include
>> looking at what imenu finds?  Might be too clever.
>
> I guess we could add that extra option.
>
> But see my other email regarding etags' hashbang detection.

Hashbang detection would solve my problem elegantly.

Is my reading of the other thread correct that if we can fix the fortran
fallback then we can enable the hashbang detection?

-- 
Sean Whitton



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-22 12:02   ` Sean Whitton
@ 2024-09-23 17:00     ` Dmitry Gutov
  2024-09-25  6:21       ` Sean Whitton
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-23 17:00 UTC (permalink / raw)
  To: Sean Whitton; +Cc: emacs-devel

On 22/09/2024 15:02, Sean Whitton wrote:

>> But see my other email regarding etags' hashbang detection.
> 
> Hashbang detection would solve my problem elegantly.
> 
> Is my reading of the other thread correct that if we can fix the fortran
> fallback then we can enable the hashbang detection?

Yep, I think so.

We would probably also discuss etags' auto-detection and its list of 
default extensions, during the next release's development.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-23 17:00     ` Dmitry Gutov
@ 2024-09-25  6:21       ` Sean Whitton
  2024-09-25 11:41         ` Dmitry Gutov
  2024-09-25 12:10         ` etags-regen-mode: handling extensionless files Eli Zaretskii
  0 siblings, 2 replies; 17+ messages in thread
From: Sean Whitton @ 2024-09-25  6:21 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

Hello,

On Mon 23 Sep 2024 at 08:00pm +03, Dmitry Gutov wrote:

> On 22/09/2024 15:02, Sean Whitton wrote:
>
>>> But see my other email regarding etags' hashbang detection.
>> Hashbang detection would solve my problem elegantly.
>> Is my reading of the other thread correct that if we can fix the fortran
>> fallback then we can enable the hashbang detection?
>
> Yep, I think so.
>
> We would probably also discuss etags' auto-detection and its list of default
> extensions, during the next release's development.

Okay, cool!  Should we have a bug to track this?

-- 
Sean Whitton



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-25  6:21       ` Sean Whitton
@ 2024-09-25 11:41         ` Dmitry Gutov
  2024-09-25 19:27           ` bug#73484: 31.0.50; Abolishing etags-regen-file-extensions Sean Whitton
  2024-09-25 12:10         ` etags-regen-mode: handling extensionless files Eli Zaretskii
  1 sibling, 1 reply; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-25 11:41 UTC (permalink / raw)
  To: Sean Whitton; +Cc: emacs-devel

On 25/09/2024 09:21, Sean Whitton wrote:
>> We would probably also discuss etags' auto-detection and its list of default
>> extensions, during the next release's development.
> Okay, cool!  Should we have a bug to track this?

Sure, please go ahead.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-25  6:21       ` Sean Whitton
  2024-09-25 11:41         ` Dmitry Gutov
@ 2024-09-25 12:10         ` Eli Zaretskii
  2024-09-25 21:19           ` Francesco Potortì
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-09-25 12:10 UTC (permalink / raw)
  To: Sean Whitton; +Cc: dgutov, emacs-devel

> From: Sean Whitton <spwhitton@spwhitton.name>
> Cc: emacs-devel@gnu.org
> Date: Wed, 25 Sep 2024 07:21:58 +0100
> 
> Hello,
> 
> On Mon 23 Sep 2024 at 08:00pm +03, Dmitry Gutov wrote:
> 
> > On 22/09/2024 15:02, Sean Whitton wrote:
> >
> >>> But see my other email regarding etags' hashbang detection.
> >> Hashbang detection would solve my problem elegantly.
> >> Is my reading of the other thread correct that if we can fix the fortran
> >> fallback then we can enable the hashbang detection?
> >
> > Yep, I think so.
> >
> > We would probably also discuss etags' auto-detection and its list of default
> > extensions, during the next release's development.
> 
> Okay, cool!  Should we have a bug to track this?

We could, but adding an option to disable the Fortran fallback is so
easy that I hope someone will just do it...



^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-25 11:41         ` Dmitry Gutov
@ 2024-09-25 19:27           ` Sean Whitton
  2024-09-25 22:30             ` Dmitry Gutov
  0 siblings, 1 reply; 17+ messages in thread
From: Sean Whitton @ 2024-09-25 19:27 UTC (permalink / raw)
  To: 73484

Hello,

On Wed 25 Sep 2024 at 02:41pm +03, Dmitry Gutov wrote:

> On 25/09/2024 09:21, Sean Whitton wrote:
>>> We would probably also discuss etags' auto-detection and its list of default
>>> extensions, during the next release's development.
>> Okay, cool!  Should we have a bug to track this?

We want to replace etags-regen-file-extensions with enabling etags's
hashbang detection support.  That requires disabling its Fortran
fallback.

-- 
Sean Whitton





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-25 12:10         ` etags-regen-mode: handling extensionless files Eli Zaretskii
@ 2024-09-25 21:19           ` Francesco Potortì
  2024-09-26  6:22             ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Francesco Potortì @ 2024-09-25 21:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, dgutov, Sean Whitton

Eli Zaretskii <eliz@gnu.org>
>> > We would probably also discuss etags' auto-detection and its list of default
>> > extensions, during the next release's development.

Sean Whitton <spwhitton@spwhitton.name>
>> Okay, cool!  Should we have a bug to track this?
>
>We could, but adding an option to disable the Fortran fallback is so
>easy that I hope someone will just do it...

How about just going with the backward-incompatible change of disabling both fallbacks entirely?  In my opinion the whole fallback idea was already obsolete when I worked on it in 1993.

Today, I can't imagine a situation where it can be useful, that is, where you work on Fortran or C sources without an extension.

On the other hand, if you are working on thirty-years old sources, I argue you should use thirty-years old tools, rather than assuming that today's tool do the right thing on them.

-- 
fp



^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-25 19:27           ` bug#73484: 31.0.50; Abolishing etags-regen-file-extensions Sean Whitton
@ 2024-09-25 22:30             ` Dmitry Gutov
  2024-09-26  7:43               ` Francesco Potortì
  2024-09-29  8:25               ` Eli Zaretskii
  0 siblings, 2 replies; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-25 22:30 UTC (permalink / raw)
  To: Sean Whitton, 73484

Hi!

On 25/09/2024 22:27, Sean Whitton wrote:

> On Wed 25 Sep 2024 at 02:41pm +03, Dmitry Gutov wrote:
> 
>> On 25/09/2024 09:21, Sean Whitton wrote:
>>>> We would probably also discuss etags' auto-detection and its list of default
>>>> extensions, during the next release's development.
>>> Okay, cool!  Should we have a bug to track this?
> 
> We want to replace etags-regen-file-extensions with enabling etags's
> hashbang detection support.  That requires disabling its Fortran
> fallback.

Thanks, a fuller plan would look something like this:

- Implement the --no-fortran-fallback flag in etags. Or an environment 
variable, or etc. Use it conditionally in etags-regen-mode.
- Revisit the default lists of extensions that etags recognizes, keeping 
in mind the recent thread we talking this about in - e.g. *.a seems out 
of place for ASM (someone more familiar with assembly dialects please 
feel free to correctme).
- Add new possible value t to etags-regen-file-extensions, and switch 
the default to it.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: etags-regen-mode: handling extensionless files
  2024-09-25 21:19           ` Francesco Potortì
@ 2024-09-26  6:22             ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2024-09-26  6:22 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: emacs-devel, dgutov, spwhitton

> From: Francesco Potortì <pot@gnu.org>
> Date: Wed, 25 Sep 2024 23:19:10 +0200
> Cc: emacs-devel@gnu.org,
> 	dgutov@yandex.ru,
> 	Sean Whitton <spwhitton@spwhitton.name>
> 
> Eli Zaretskii <eliz@gnu.org>
> >We could, but adding an option to disable the Fortran fallback is so
> >easy that I hope someone will just do it...
> 
> How about just going with the backward-incompatible change of disabling both fallbacks entirely?  In my opinion the whole fallback idea was already obsolete when I worked on it in 1993.

Since no one complained about it, and the only real use case is when
invoking 'etags' from a Lisp program, which can easily use a
non-standard option, I don't see a compelling reason for a
backward-incompatible change in behavior.  In some future version, we
can then flip the default and make the fallback disabled by default.

> Today, I can't imagine a situation where it can be useful, that is, where you work on Fortran or C sources without an extension.

My gray hair tells me that our ability to imagine such situations is
severely limited or biased, and we have enough evidence of this bias
to not trust our imagination in these matters anymore.

> On the other hand, if you are working on thirty-years old sources, I argue you should use thirty-years old tools, rather than assuming that today's tool do the right thing on them.

These arguments are usually not well taken, IME.  People want new
tools because they give them more functionality and performance, but
they do NOT want incompatibilities in the package.  IOW, everyone
likes to have the cake and eat it, too.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-25 22:30             ` Dmitry Gutov
@ 2024-09-26  7:43               ` Francesco Potortì
  2024-09-26 12:18                 ` Dmitry Gutov
  2024-09-29  8:25               ` Eli Zaretskii
  1 sibling, 1 reply; 17+ messages in thread
From: Francesco Potortì @ 2024-09-26  7:43 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 73484, Sean Whitton

>- Implement the --no-fortran-fallback flag in etags. Or an environment 
>variable, or etc. Use it conditionally in etags-regen-mode.

If your purpose is to avoid Etags creating false tags on files whose language it cannot detect, you need to disable all fallbacks, rather than just Fortran.

Sorry if I got lost and missed something.

-- 
fp





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-26  7:43               ` Francesco Potortì
@ 2024-09-26 12:18                 ` Dmitry Gutov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-26 12:18 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 73484, Sean Whitton

On 26/09/2024 10:43, Francesco Potortì wrote:
>> - Implement the --no-fortran-fallback flag in etags. Or an environment
>> variable, or etc. Use it conditionally in etags-regen-mode.
> If your purpose is to avoid Etags creating false tags on files whose language it cannot detect, you need to disable all fallbacks, rather than just Fortran.

Yeah, sorry, I guess the next fallback is C?

We'll want to disable both, so the flag would be --no-fallbacks, I guess.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-25 22:30             ` Dmitry Gutov
  2024-09-26  7:43               ` Francesco Potortì
@ 2024-09-29  8:25               ` Eli Zaretskii
  2024-09-29 10:56                 ` Eli Zaretskii
  2024-09-30 23:19                 ` Dmitry Gutov
  1 sibling, 2 replies; 17+ messages in thread
From: Eli Zaretskii @ 2024-09-29  8:25 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 73484, spwhitton

> Date: Thu, 26 Sep 2024 01:30:55 +0300
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> > We want to replace etags-regen-file-extensions with enabling etags's
> > hashbang detection support.  That requires disabling its Fortran
> > fallback.
> 
> Thanks, a fuller plan would look something like this:
> 
> - Implement the --no-fortran-fallback flag in etags. Or an environment 
> variable, or etc. Use it conditionally in etags-regen-mode.
> - Revisit the default lists of extensions that etags recognizes, keeping 
> in mind the recent thread we talking this about in - e.g. *.a seems out 
> of place for ASM (someone more familiar with assembly dialects please 
> feel free to correctme).
> - Add new possible value t to etags-regen-file-extensions, and switch 
> the default to it.

I understand that we need to disable the Fortran and C fallbacks to
avoid false positives, but what do we want to do if the fallbacks are
disabled and no suitable language parser is found using the file name?
Just skip the file and do nothing? emit a warning? something else?

I also don't understand why enabling the etags' shebang detection
requires to disable the Fortran and C fallbacks: etags looks for
shebang _before_ it falls back to Fortran and C, so what am I missing?





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-29  8:25               ` Eli Zaretskii
@ 2024-09-29 10:56                 ` Eli Zaretskii
  2024-09-29 17:15                   ` Francesco Potortì
  2024-09-30 23:19                 ` Dmitry Gutov
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-09-29 10:56 UTC (permalink / raw)
  To: dmitry; +Cc: 73484, spwhitton

> Cc: 73484@debbugs.gnu.org, spwhitton@spwhitton.name
> Date: Sun, 29 Sep 2024 11:25:45 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> I understand that we need to disable the Fortran and C fallbacks to
> avoid false positives, but what do we want to do if the fallbacks are
> disabled and no suitable language parser is found using the file name?
> Just skip the file and do nothing? emit a warning? something else?

Wait a minute... we already have "--language=none", which means only
do regexp processing, if any.  If no regexps were specified, 'none'
produces a single entry for a file, stating just its name, like this:

  ^L
  foo,0

where ^L is a literal \f character.  Is the intent here to prevent
even that from being written to TAGS?  If not, then we don't need any
new command-line option; instead, etags-regen could simply pass the
"--language=none" option before each file with no extension, and be
done, no?

Or maybe this is "the missing link" between this and the shebang
processing?





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-29 10:56                 ` Eli Zaretskii
@ 2024-09-29 17:15                   ` Francesco Potortì
  0 siblings, 0 replies; 17+ messages in thread
From: Francesco Potortì @ 2024-09-29 17:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dmitry, 73484, spwhitton

Eli Zaretskii:
>> I understand that we need to disable the Fortran and C fallbacks to
>> avoid false positives, but what do we want to do if the fallbacks are
>> disabled and no suitable language parser is found using the file name?
>> Just skip the file and do nothing? emit a warning? something else?

Eli Zaretskii:
>Wait a minute... we already have "--language=none", which means only
>do regexp processing, if any.  If no regexps were specified, 'none'
>produces a single entry for a file, stating just its name, like this:
>
>  ^L
>  foo,0
>
>where ^L is a literal \f character.  Is the intent here to prevent
>even that from being written to TAGS?  If not, then we don't need any
>new command-line option; instead, etags-regen could simply pass the
>"--language=none" option before each file with no extension, and be
>done, no?
>
>Or maybe this is "the missing link" between this and the shebang
>processing?

If you set language=none for files whose extension is unknown to Etags, then you give up on shebang processing.  If you do not set language=none and Etags does not recognise any shebang, it defaults to Fortran.  If it does not find any Fortran tags, it defaults to C/C++.  When default processing happens on a file which is neither Fortran nor C/C++, it usually generates no tags, but may occasionally generate fake tags.

AFAIU, the problem is that there are use cases when you have to feed Etags with files that should generate no tags, yet the occasional fake tags are not tolerable.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
  2024-09-29  8:25               ` Eli Zaretskii
  2024-09-29 10:56                 ` Eli Zaretskii
@ 2024-09-30 23:19                 ` Dmitry Gutov
  1 sibling, 0 replies; 17+ messages in thread
From: Dmitry Gutov @ 2024-09-30 23:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 73484, spwhitton

On 29/09/2024 11:25, Eli Zaretskii wrote:
> I understand that we need to disable the Fortran and C fallbacks to
> avoid false positives, but what do we want to do if the fallbacks are
> disabled and no suitable language parser is found using the file name?
> Just skip the file and do nothing? emit a warning? something else?

Just do nothing. We'd really want to delegate language detection to 
etags rather than doing it inside Elisp - the latter is slower and 
ultimately more limited. But for that etags needs to have a reliable 
detection logic, one without too many false positives (and IME false 
positives here are worse than false negatives, because scanning too much 
can often mean both wrong tags and long scans, and a completion table 
that gets too large because of bogus tags).

For shebangs in particular, however, see Francesco's very good 
explanation. And detecting shebangs in Lisp would not be practical -- 
too slow.





^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-09-30 23:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-20  9:20 etags-regen-mode: handling extensionless files Sean Whitton
2024-09-20 18:23 ` Dmitry Gutov
2024-09-22 12:02   ` Sean Whitton
2024-09-23 17:00     ` Dmitry Gutov
2024-09-25  6:21       ` Sean Whitton
2024-09-25 11:41         ` Dmitry Gutov
2024-09-25 19:27           ` bug#73484: 31.0.50; Abolishing etags-regen-file-extensions Sean Whitton
2024-09-25 22:30             ` Dmitry Gutov
2024-09-26  7:43               ` Francesco Potortì
2024-09-26 12:18                 ` Dmitry Gutov
2024-09-29  8:25               ` Eli Zaretskii
2024-09-29 10:56                 ` Eli Zaretskii
2024-09-29 17:15                   ` Francesco Potortì
2024-09-30 23:19                 ` Dmitry Gutov
2024-09-25 12:10         ` etags-regen-mode: handling extensionless files Eli Zaretskii
2024-09-25 21:19           ` Francesco Potortì
2024-09-26  6:22             ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.