GNU bug report logs - #72069
[PATCH] Move configuration of auto-mode-alist out of js-ts-mode

Previous Next

Package: emacs;

Reported by: Damien Cassou <damien <at> cassou.me>

Date: Fri, 12 Jul 2024 08:00:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 72069 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#72069; Package emacs. (Fri, 12 Jul 2024 08:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Damien Cassou <damien <at> cassou.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 Jul 2024 08:00:02 GMT) Full text and rfc822 format available.

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

From: Damien Cassou <damien <at> cassou.me>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Move configuration of auto-mode-alist out of js-ts-mode
Date: Fri, 12 Jul 2024 09:58:45 +0200
[Message part 1 (text/plain, inline)]
Tags: patch

Hi,

The current version of the code requires the `js-ts-mode' function to
have already been executed for `auto-mode-alist' to contain an entry for
".jsx" files. The patch makes sure that `auto-mode-alist' is updates
when js.el is loaded.

Best

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
[0001-Move-configuration-of-auto-mode-alist-out-of-js-ts-m.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72069; Package emacs. (Wed, 24 Jul 2024 14:08:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Damien Cassou <damien <at> cassou.me>
Cc: Yuan Fu <casouri <at> gmail.com>, 72069 <at> debbugs.gnu.org
Subject: Re: bug#72069: [PATCH] Move configuration of auto-mode-alist out of
 js-ts-mode
Date: Wed, 24 Jul 2024 07:05:55 -0700
Damien Cassou <damien <at> cassou.me> writes:

> The current version of the code requires the `js-ts-mode' function to
> have already been executed for `auto-mode-alist' to contain an entry for
> ".jsx" files. The patch makes sure that `auto-mode-alist' is updates
> when js.el is loaded.

Thanks for the patch.

What about js-mode?  Shouldn't that be used out-of-the-box for these files?

>>From 7fc9bb52a9f51a8caf4d5d016dc8a8812dd5c6a3 Mon Sep 17 00:00:00 2001
> From: Damien Cassou <damien <at> cassou.me>
> Date: Fri, 12 Jul 2024 09:50:45 +0200
> Subject: [PATCH] Move configuration of auto-mode-alist out of js-ts-mode
>
> * lisp/progmodes/js.el (js-ts-mode): Remove configuration of
> auto-mode-alist.
> ---
>  lisp/progmodes/js.el | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
> index f8140c14a49..c3e6077a352 100644
> --- a/lisp/progmodes/js.el
> +++ b/lisp/progmodes/js.el
> @@ -3957,10 +3957,10 @@ js-ts-mode
>                                          "method_definition")
>                                  eos)
>                     nil nil)))
> -    (treesit-major-mode-setup)
> +    (treesit-major-mode-setup)))
>
> -    (add-to-list 'auto-mode-alist
> -                 '("\\(\\.js[mx]\\|\\.har\\)\\'" . js-ts-mode))))
> +(add-to-list 'auto-mode-alist
> +             '("\\(\\.js[mx]\\|\\.har\\)\\'" . js-ts-mode))

Shouldn't this be wrapped in

    (if (treesit-ready-p js) ...)

?

>
>  (derived-mode-add-parents 'js-ts-mode '(js-mode))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72069; Package emacs. (Mon, 29 Jul 2024 18:21:01 GMT) Full text and rfc822 format available.

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

From: Damien Cassou <damien <at> cassou.me>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, 72069 <at> debbugs.gnu.org
Subject: Re: bug#72069: [PATCH] Move configuration of auto-mode-alist out of
 js-ts-mode
Date: Mon, 29 Jul 2024 20:20:12 +0200
Hi Stefan,

thank you very much for your review.

Stefan Kangas <stefankangas <at> gmail.com> writes:
> Damien Cassou <damien <at> cassou.me> writes:
> What about js-mode?  Shouldn't that be used out-of-the-box for these files?


Definitely, I don't know what I was thinking. I'm not sure there is
anything to save on this patch.

If you believe I should wrap the call to `add-to-list' within a `(if
(treesit-ready-p js) ...)' block I will do that but I don't think this
is how things are done for other kinds of files. Otherwise, feel free to
close this ticket and please forgive me.

Best


>>>From 7fc9bb52a9f51a8caf4d5d016dc8a8812dd5c6a3 Mon Sep 17 00:00:00 2001
>> From: Damien Cassou <damien <at> cassou.me>
>> Date: Fri, 12 Jul 2024 09:50:45 +0200
>> Subject: [PATCH] Move configuration of auto-mode-alist out of js-ts-mode
>>
>> * lisp/progmodes/js.el (js-ts-mode): Remove configuration of
>> auto-mode-alist.
>> ---
>>  lisp/progmodes/js.el | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
>> index f8140c14a49..c3e6077a352 100644
>> --- a/lisp/progmodes/js.el
>> +++ b/lisp/progmodes/js.el
>> @@ -3957,10 +3957,10 @@ js-ts-mode
>>                                          "method_definition")
>>                                  eos)
>>                     nil nil)))
>> -    (treesit-major-mode-setup)
>> +    (treesit-major-mode-setup)))
>>
>> -    (add-to-list 'auto-mode-alist
>> -                 '("\\(\\.js[mx]\\|\\.har\\)\\'" . js-ts-mode))))
>> +(add-to-list 'auto-mode-alist
>> +             '("\\(\\.js[mx]\\|\\.har\\)\\'" . js-ts-mode))
>
> Shouldn't this be wrapped in
>
>     (if (treesit-ready-p js) ...)
>
> ?
>
>>
>>  (derived-mode-add-parents 'js-ts-mode '(js-mode))

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill




This bug report was last modified 80 days ago.

Previous Next


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