GNU bug report logs - #60525
29.0.60; tree-sitter support in semantic-symref

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 3 Jan 2023 18:08:02 UTC

Severity: wishlist

Found in version 29.0.60

To reply to this bug, email your comments to 60525 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Tue, 03 Jan 2023 18:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 03 Jan 2023 18:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; tree-sitter support in semantic-symref
Date: Tue, 03 Jan 2023 20:06:25 +0200
[Message part 1 (text/plain, inline)]
This duplication is needed to support 'M-?' (xref-find-references) in ts-modes:

[ts-semantic-symref.patch (text/x-diff, inline)]
diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el
index c698c2ef5a2..cebeac3adca 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -44,7 +44,9 @@ semantic-symref-tool-grep
 
 (defvar semantic-symref-filepattern-alist
   '((c-mode "*.[ch]")
+    (c-ts-mode "*.[ch]")
     (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
+    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
     (html-mode "*.html" "*.shtml" "*.php")
     (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
                                             ; duplication of
@@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
                                             ; major mode definition?
     (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
                "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
+    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
+                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
     (python-mode "*.py" "*.pyi" "*.pyw")
+    (python-ts-mode "*.py" "*.pyi" "*.pyw")
     (perl-mode "*.pl" "*.PL")
     (cperl-mode "*.pl" "*.PL")
     (lisp-interaction-mode "*.el" "*.ede" ".emacs" "_emacs")

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Tue, 03 Jan 2023 20:19:01 GMT) Full text and rfc822 format available.

Message #8 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 60525 <at> debbugs.gnu.org
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Tue, 03 Jan 2023 22:19:01 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Date: Tue, 03 Jan 2023 20:06:25 +0200
> 
> This duplication is needed to support 'M-?' (xref-find-references) in ts-modes:

Thanks, this is okay for the emacs-29 branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 01:52:01 GMT) Full text and rfc822 format available.

Message #11 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, 60525 <at> debbugs.gnu.org
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 4 Jan 2023 03:51:28 +0200
On 03/01/2023 20:06, Juri Linkov wrote:
> +    (c-ts-mode "*.[ch]")
>       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
> +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>       (html-mode "*.html" "*.shtml" "*.php")
>       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>                                               ; duplication of
> @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>                                               ; major mode definition?
>       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
> +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
> +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>       (python-mode "*.py" "*.pyi" "*.pyw")

Instead of duplicating entries, we could try to look up the remappings 
in major-mode-remap-alist.

Or (more effort) change the structure of the "alist" to also contain 
lists of modes in the keys. Like in eglot-server-programs.

diff --git a/lisp/cedet/semantic/symref/grep.el 
b/lisp/cedet/semantic/symref/grep.el
index c698c2ef5a2..ecfeaae220c 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -71,7 +71,10 @@ semantic-symref-derive-find-filepatterns
 Optional argument MODE specifies the `major-mode' to test."
   ;; First, try the filepattern alist.
   (let* ((mode (or mode major-mode))
-	 (pat (cdr (assoc mode semantic-symref-filepattern-alist))))
+	 (pat
+          (or (assoc-default mode semantic-symref-filepattern-alist)
+              (assoc-default (car (rassoc mode major-mode-remap-alist))
+                             semantic-symref-filepattern-alist))))
     (when (not pat)
       ;; No hit, try auto-mode-alist.
       (dolist (X auto-mode-alist)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 07:50:02 GMT) Full text and rfc822 format available.

Message #14 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 60525 <at> debbugs.gnu.org
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 09:43:12 +0200
>>       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>>                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>
> Instead of duplicating entries, we could try to look up the remappings in
> major-mode-remap-alist.
>
> Or (more effort) change the structure of the "alist" to also contain lists
> of modes in the keys. Like in eglot-server-programs.
>
> diff --git a/lisp/cedet/semantic/symref/grep.el
> ...
> -	 (pat (cdr (assoc mode semantic-symref-filepattern-alist))))
> +	 (pat
> +          (or (assoc-default mode semantic-symref-filepattern-alist)
> +              (assoc-default (car (rassoc mode major-mode-remap-alist))
> +                             semantic-symref-filepattern-alist))))

I'm fine with this change if Eli agrees to install it
on the emacs-29 branch.

But also note that such duplication is unavoidable in many other places.
For example, to support abbreviations there is the need to manually
rename

  (define-abbrev-table 'ruby-mode-abbrev-table

to

  (define-abbrev-table 'ruby-base-mode-abbrev-table

in ~/.emacs.d/abbrev_defs.  But on exiting Emacs it insists
on saving duplicate abbrevs to 

  (define-abbrev-table 'ruby-ts-mode-abbrev-table




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 12:07:02 GMT) Full text and rfc822 format available.

Message #17 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: 60525 <at> debbugs.gnu.org
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 4 Jan 2023 14:06:38 +0200
On 04/01/2023 09:43, Juri Linkov wrote:
> But also note that such duplication is unavoidable in many other places.
> For example, to support abbreviations there is the need to manually
> rename
> 
>    (define-abbrev-table 'ruby-mode-abbrev-table
> 
> to
> 
>    (define-abbrev-table 'ruby-base-mode-abbrev-table
> 
> in ~/.emacs.d/abbrev_defs.  But on exiting Emacs it insists
> on saving duplicate abbrevs to
> 
>    (define-abbrev-table 'ruby-ts-mode-abbrev-table

Perhaps something could be done inside abbrev (e.g. save which major 
mode it was enabled in). Not sure.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 14:27:02 GMT) Full text and rfc822 format available.

Message #20 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 60525 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 16:26:09 +0200
> Date: Wed, 4 Jan 2023 03:51:28 +0200
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> 
> On 03/01/2023 20:06, Juri Linkov wrote:
> > +    (c-ts-mode "*.[ch]")
> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
> >       (html-mode "*.html" "*.shtml" "*.php")
> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
> >                                               ; duplication of
> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
> >                                               ; major mode definition?
> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
> >       (python-mode "*.py" "*.pyi" "*.pyw")
> 
> Instead of duplicating entries, we could try to look up the remappings 
> in major-mode-remap-alist.

That doesn't sound to me like the use of major-mode-remap-alist that
was intended.

I'm okay with duplication at this point.  It is much easier, and we
can always augment or fix later as needed.  I see no reason to do
anything fancier at this point.

Stefan, Lars, WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 14:35:01 GMT) Full text and rfc822 format available.

Message #23 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 16:34:10 +0200
> Cc: 60525 <at> debbugs.gnu.org
> From: Juri Linkov <juri <at> linkov.net>
> Date: Wed, 04 Jan 2023 09:43:12 +0200
> 
> > diff --git a/lisp/cedet/semantic/symref/grep.el
> > ...
> > -	 (pat (cdr (assoc mode semantic-symref-filepattern-alist))))
> > +	 (pat
> > +          (or (assoc-default mode semantic-symref-filepattern-alist)
> > +              (assoc-default (car (rassoc mode major-mode-remap-alist))
> > +                             semantic-symref-filepattern-alist))))
> 
> I'm fine with this change if Eli agrees to install it
> on the emacs-29 branch.

No, it's too much for the release branch, and as I wrote elsewhere,
doesn't sound justified to me.

> But also note that such duplication is unavoidable in many other places.
> For example, to support abbreviations there is the need to manually
> rename
> 
>   (define-abbrev-table 'ruby-mode-abbrev-table
> 
> to
> 
>   (define-abbrev-table 'ruby-base-mode-abbrev-table
> 
> in ~/.emacs.d/abbrev_defs.  But on exiting Emacs it insists
> on saving duplicate abbrevs to 
> 
>   (define-abbrev-table 'ruby-ts-mode-abbrev-table

There's no way around that: people who want use both modes will have
to live with duplication for now.  There's a limit to what we can do
so close to the release.  Sorry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 15:49:02 GMT) Full text and rfc822 format available.

Message #26 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, juri <at> linkov.net, 60525 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 10:47:54 -0500
>> On 03/01/2023 20:06, Juri Linkov wrote:
>> > +    (c-ts-mode "*.[ch]")
>> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> >       (html-mode "*.html" "*.shtml" "*.php")
>> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>> >                                               ; duplication of
>> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>> >                                               ; major mode definition?
>> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> >       (python-mode "*.py" "*.pyi" "*.pyw")
>> 
>> Instead of duplicating entries, we could try to look up the remappings 
>> in major-mode-remap-alist.
>
> That doesn't sound to me like the use of major-mode-remap-alist that
> was intended.
>
> I'm okay with duplication at this point.  It is much easier, and we
> can always augment or fix later as needed.  I see no reason to do
> anything fancier at this point.
>
> Stefan, Lars, WDYT?

I'll just note that the above alists already duplicate info present in
`auto-mode-alist`.  Admittedly, this redundant info is present in
a different form, so maybe not directly usable as is, but if we care
about redundancy, we should maybe add some layer on top which we can
then use both for `semantic-symref-filepattern-alist` and for
`auto-mode-alist`.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 16:58:02 GMT) Full text and rfc822 format available.

Message #29 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 18:57:40 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Dmitry Gutov <dgutov <at> yandex.ru>,  Lars Ingebrigtsen <larsi <at> gnus.org>,
>   juri <at> linkov.net,  60525 <at> debbugs.gnu.org
> Date: Wed, 04 Jan 2023 10:47:54 -0500
> 
> >> On 03/01/2023 20:06, Juri Linkov wrote:
> >> > +    (c-ts-mode "*.[ch]")
> >> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
> >> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
> >> >       (html-mode "*.html" "*.shtml" "*.php")
> >> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
> >> >                                               ; duplication of
> >> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
> >> >                                               ; major mode definition?
> >> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
> >> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
> >> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
> >> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
> >> >       (python-mode "*.py" "*.pyi" "*.pyw")
> >> 
> >> Instead of duplicating entries, we could try to look up the remappings 
> >> in major-mode-remap-alist.
> >
> > That doesn't sound to me like the use of major-mode-remap-alist that
> > was intended.
> >
> > I'm okay with duplication at this point.  It is much easier, and we
> > can always augment or fix later as needed.  I see no reason to do
> > anything fancier at this point.
> >
> > Stefan, Lars, WDYT?
> 
> I'll just note that the above alists already duplicate info present in
> `auto-mode-alist`.  Admittedly, this redundant info is present in
> a different form, so maybe not directly usable as is, but if we care
> about redundancy, we should maybe add some layer on top which we can
> then use both for `semantic-symref-filepattern-alist` and for
> `auto-mode-alist`.

I' aware of the redundancy.  But since we decided to go with those
separate modes in Emacs 29, I think the redundancy is in general
unavoidable.  If we can use the fact that auto-mode-alist already
mentions both modes, and we can do that cleanly, it's fine by me.
Otherwise we will have to live with this for now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 17:04:02 GMT) Full text and rfc822 format available.

Message #32 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, 60525 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 4 Jan 2023 19:03:28 +0200
On 04/01/2023 18:57, Eli Zaretskii wrote:
> I' aware of the redundancy.  But since we decided to go with those
> separate modes in Emacs 29, I think the redundancy is in general
> unavoidable.  If we can use the fact that auto-mode-alist already
> mentions both modes, and we can do that cleanly, it's fine by me.
> Otherwise we will have to live with this for now.

I believe Stefan is referring to redundancy between auto-mode-alist and 
semantic-symref-filepattern-alist. Which seems unavoidable so far as the 
former requires just one element in the car position, and the latter 
works with lists of filename globs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 17:18:02 GMT) Full text and rfc822 format available.

Message #35 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: larsi <at> gnus.org, 60525 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca,
 juri <at> linkov.net
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 19:17:17 +0200
> Date: Wed, 4 Jan 2023 19:03:28 +0200
> Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> 
> On 04/01/2023 18:57, Eli Zaretskii wrote:
> > I' aware of the redundancy.  But since we decided to go with those
> > separate modes in Emacs 29, I think the redundancy is in general
> > unavoidable.  If we can use the fact that auto-mode-alist already
> > mentions both modes, and we can do that cleanly, it's fine by me.
> > Otherwise we will have to live with this for now.
> 
> I believe Stefan is referring to redundancy between auto-mode-alist and 
> semantic-symref-filepattern-alist.

Yes, I understood that, and my response was to that aspect.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 18:08:02 GMT) Full text and rfc822 format available.

Message #38 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 13:07:47 -0500
>> >> On 03/01/2023 20:06, Juri Linkov wrote:
>> >> > +    (c-ts-mode "*.[ch]")
>> >> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> >> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> >> >       (html-mode "*.html" "*.shtml" "*.php")
>> >> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>> >> >                                               ; duplication of
>> >> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>> >> >                                               ; major mode definition?
>> >> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> >> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> >> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> >> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> >> >       (python-mode "*.py" "*.pyi" "*.pyw")
>> >> 
>> >> Instead of duplicating entries, we could try to look up the remappings 
>> >> in major-mode-remap-alist.
>> >
>> > That doesn't sound to me like the use of major-mode-remap-alist that
>> > was intended.
>> >
>> > I'm okay with duplication at this point.  It is much easier, and we
>> > can always augment or fix later as needed.  I see no reason to do
>> > anything fancier at this point.
>> >
>> > Stefan, Lars, WDYT?
>> 
>> I'll just note that the above alists already duplicate info present in
>> `auto-mode-alist`.  Admittedly, this redundant info is present in
>> a different form, so maybe not directly usable as is, but if we care
>> about redundancy, we should maybe add some layer on top which we can
>> then use both for `semantic-symref-filepattern-alist` and for
>> `auto-mode-alist`.
>
> I' aware of the redundancy.  But since we decided to go with those
> separate modes in Emacs 29, I think the redundancy is in general
> unavoidable.  If we can use the fact that auto-mode-alist already
> mentions both modes, and we can do that cleanly, it's fine by me.
> Otherwise we will have to live with this for now.

BTW, other ways to reduce the redundancy (not between
`semantic-symref-filepattern-alist` and `auto-mode-alist`, but the one
introduced by the patch above):

- make the various variants of a major mode all inherit from a shared
  parent mode (and then use that shared parent mode in
  `semantic-symref-filepattern-alist`).

- Use `set-auto-mode--last` which remembers the mode specified before it
  was remapped by things like `major-mode-remap-alist` (or by dispatch
  functions like `tex-mode`).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 18:21:01 GMT) Full text and rfc822 format available.

Message #41 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 13:20:26 -0500
>>> >> On 03/01/2023 20:06, Juri Linkov wrote:
>>> >> > +    (c-ts-mode "*.[ch]")
>>> >> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>>> >> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>>> >> >       (html-mode "*.html" "*.shtml" "*.php")
>>> >> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>>> >> >                                               ; duplication of
>>> >> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>>> >> >                                               ; major mode definition?
>>> >> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>>> >> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>>> >> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>>> >> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>>> >> >       (python-mode "*.py" "*.pyi" "*.pyw")
>>> >> 
>>> >> Instead of duplicating entries, we could try to look up the remappings 
>>> >> in major-mode-remap-alist.
>>> >
>>> > That doesn't sound to me like the use of major-mode-remap-alist that
>>> > was intended.
>>> >
>>> > I'm okay with duplication at this point.  It is much easier, and we
>>> > can always augment or fix later as needed.  I see no reason to do
>>> > anything fancier at this point.
>>> >
>>> > Stefan, Lars, WDYT?
>>> 
>>> I'll just note that the above alists already duplicate info present in
>>> `auto-mode-alist`.  Admittedly, this redundant info is present in
>>> a different form, so maybe not directly usable as is, but if we care
>>> about redundancy, we should maybe add some layer on top which we can
>>> then use both for `semantic-symref-filepattern-alist` and for
>>> `auto-mode-alist`.
>>
>> I' aware of the redundancy.  But since we decided to go with those
>> separate modes in Emacs 29, I think the redundancy is in general
>> unavoidable.  If we can use the fact that auto-mode-alist already
>> mentions both modes, and we can do that cleanly, it's fine by me.
>> Otherwise we will have to live with this for now.
>
> BTW, other ways to reduce the redundancy (not between
> `semantic-symref-filepattern-alist` and `auto-mode-alist`, but the one
> introduced by the patch above):
>
> - make the various variants of a major mode all inherit from a shared
>   parent mode (and then use that shared parent mode in
>   `semantic-symref-filepattern-alist`).
>
> - Use `set-auto-mode--last` which remembers the mode specified before it
>   was remapped by things like `major-mode-remap-alist` (or by dispatch
>   functions like `tex-mode`).

Oh, and of course:

- move the info from `semantic-symref-filepattern-alist` to
  a buffer-local `semantic-symref-filepattern` which is set by the major
  modes, so the same setting can be shared by the various modes like all
  the other buffer-local settings (`comment-start`, ...).

BTW, I see that the info provided by `semantic-symref-filepattern-alist`
could be (re)used also in `C-u M-x grep`.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 18:40:01 GMT) Full text and rfc822 format available.

Message #44 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 20:39:19 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: dgutov <at> yandex.ru,  larsi <at> gnus.org,  juri <at> linkov.net,  60525 <at> debbugs.gnu.org
> Date: Wed, 04 Jan 2023 13:07:47 -0500
> 
> - make the various variants of a major mode all inherit from a shared
>   parent mode (and then use that shared parent mode in
>   `semantic-symref-filepattern-alist`).

This idea was tried, but it doesn't work well enough, at least not for
all such mode pairs.

> - Use `set-auto-mode--last` which remembers the mode specified before it
>   was remapped by things like `major-mode-remap-alist` (or by dispatch
>   functions like `tex-mode`).

I'd need to see the code to reason about it (though I understand the
general idea).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 18:44:02 GMT) Full text and rfc822 format available.

Message #47 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 20:43:21 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: dgutov <at> yandex.ru,  larsi <at> gnus.org,  juri <at> linkov.net,  60525 <at> debbugs.gnu.org
> Date: Wed, 04 Jan 2023 13:20:26 -0500
> 
> - move the info from `semantic-symref-filepattern-alist` to
>   a buffer-local `semantic-symref-filepattern` which is set by the major
>   modes, so the same setting can be shared by the various modes like all
>   the other buffer-local settings (`comment-start`, ...).
> 
> BTW, I see that the info provided by `semantic-symref-filepattern-alist`
> could be (re)used also in `C-u M-x grep`.

Fine with me, but that is hardly for the release branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 19:05:01 GMT) Full text and rfc822 format available.

Message #50 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: larsi <at> gnus.org, 60525 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 4 Jan 2023 21:04:19 +0200
On 04/01/2023 20:39, Eli Zaretskii wrote:
>> From: Stefan Monnier<monnier <at> iro.umontreal.ca>
>> Cc:dgutov <at> yandex.ru,larsi <at> gnus.org,juri <at> linkov.net,60525 <at> debbugs.gnu.org
>> Date: Wed, 04 Jan 2023 13:07:47 -0500
>>
>> - make the various variants of a major mode all inherit from a shared
>>    parent mode (and then use that shared parent mode in
>>    `semantic-symref-filepattern-alist`).
> This idea was tried, but it doesn't work well enough, at least not for
> all such mode pairs.
> 

2 out of 3 modes added by this patch do have "base" modes that can be 
used: python-base-mode and ruby-base-mode.

The search will have to become a little more complex, though, to account 
for parent modes. Not just (cdr (assoc mode 
semantic-symref-filepattern-alist)).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 19:37:01 GMT) Full text and rfc822 format available.

Message #53 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 60525 <at> debbugs.gnu.org, larsi <at> gnus.org,
 juri <at> linkov.net
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 14:36:17 -0500
> The search will have to become a little more complex, though, to account for
> parent modes. Not just (cdr (assoc mode semantic-symref-filepattern-alist)).

If it doesn't account for mode inheritance, then I'd argue that it's
already broken.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Wed, 04 Jan 2023 19:39:02 GMT) Full text and rfc822 format available.

Message #56 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, juri <at> linkov.net, 60525 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Wed, 04 Jan 2023 14:38:26 -0500
>> - move the info from `semantic-symref-filepattern-alist` to
>>   a buffer-local `semantic-symref-filepattern` which is set by the major
>>   modes, so the same setting can be shared by the various modes like all
>>   the other buffer-local settings (`comment-start`, ...).
>>
>> BTW, I see that the info provided by `semantic-symref-filepattern-alist`
>> could be (re)used also in `C-u M-x grep`.
>
> Fine with me, but that is hardly for the release branch.

None of the my "alternatives" were meant for `emacs-29`, indeed (tho
apparently there's a `ruby-base-mode` so it could have been an option,
if it weren't for the fact that `semantic-symref-filepattern-alist` is
too simplistic for that).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Thu, 05 Jan 2023 17:57:04 GMT) Full text and rfc822 format available.

Message #59 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 60525 <at> debbugs.gnu.org, larsi <at> gnus.org,
 dgutov <at> yandex.ru
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Thu, 05 Jan 2023 19:29:35 +0200
>>>> >> On 03/01/2023 20:06, Juri Linkov wrote:
>>>> >> > +    (c-ts-mode "*.[ch]")
>>>> >> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>>>> >> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>>>> >> >       (html-mode "*.html" "*.shtml" "*.php")
>>>> >> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>>>> >> >                                               ; duplication of
>>>> >> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>>>> >> >                                               ; major mode definition?
>>>> >> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>>>> >> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>>>> >> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>>>> >> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>>>> >> >       (python-mode "*.py" "*.pyi" "*.pyw")
>
> BTW, I see that the info provided by `semantic-symref-filepattern-alist`
> could be (re)used also in `C-u M-x grep`.

Indeed, another duplication with:

  (defcustom grep-files-aliases
    '(("all" .   "* .*")
      ("el" .    "*.el")
      ("ch" .    "*.[ch]")
      ("c" .     "*.c")
      ("cc" .    "*.cc *.cxx *.cpp *.C *.CC *.c++")
      ("cchh" .  "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++")
      ("hh" .    "*.hxx *.hpp *.[Hh] *.HH *.h++")
      ("h" .     "*.h")
      ("l" .     "[Cc]hange[Ll]og*")
      ("am" .    "Makefile.am GNUmakefile *.mk")
      ("m" .     "[Mm]akefile*")
      ("tex" .   "*.tex")
      ("texi" .  "*.texi")
      ("asm" .   "*.[sS]"))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60525; Package emacs. (Thu, 05 Jan 2023 18:20:02 GMT) Full text and rfc822 format available.

Message #62 received at 60525 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 60525 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#60525: 29.0.60; tree-sitter support in semantic-symref
Date: Thu, 05 Jan 2023 20:18:36 +0200
>> > +    (c-ts-mode "*.[ch]")
>> >       (c++-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> > +    (c++-ts-mode "*.[chCH]" "*.[ch]pp" "*.cc" "*.hh")
>> >       (html-mode "*.html" "*.shtml" "*.php")
>> >       (mhtml-mode "*.html" "*.shtml" "*.php") ; FIXME: remove
>> >                                               ; duplication of
>> > @@ -53,7 +55,10 @@ semantic-symref-filepattern-alist
>> >                                               ; major mode definition?
>> >       (ruby-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> >                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> > +    (ruby-ts-mode "*.r[bu]" "*.rake" "*.gemspec" "*.erb" "*.haml"
>> > +                  "Rakefile" "Thorfile" "Capfile" "Guardfile" "Vagrantfile")
>> >       (python-mode "*.py" "*.pyi" "*.pyw")
>
> I'm okay with duplication at this point.  It is much easier, and we
> can always augment or fix later as needed.  I see no reason to do
> anything fancier at this point.

So I pushed this to emacs-29, and leave this bug report open
for more generalization in master.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 04 Sep 2023 15:01:02 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.