unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: emacs-29 56cd810b9d1: Don’t signal warning when loading go-ts-mode.el without grammar
Date: Thu, 02 Mar 2023 09:41:12 +0200	[thread overview]
Message-ID: <83r0u7eh2f.fsf@gnu.org> (raw)

> branch: emacs-29
> commit 56cd810b9d1a4d537bee5a2fd954d6e0d346631a
> Author: Yuan Fu <casouri@gmail.com>
> Commit: Yuan Fu <casouri@gmail.com>
> 
>     Don’t signal warning when loading go-ts-mode.el without grammar
>     
>     * lisp/progmodes/go-ts-mode.el: Add a QUIET flag to the call of
>     treesit-ready-p, so that it doesn't signal a warning if
>     go-mod (tree-sitter grammar) is not available.
> ---
>  lisp/progmodes/go-ts-mode.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
> index e8f93d14744..6043c86ac93 100644
> --- a/lisp/progmodes/go-ts-mode.el
> +++ b/lisp/progmodes/go-ts-mode.el
> @@ -393,7 +393,7 @@ what the parent of the node would be if it were a node."
>  
>      (treesit-major-mode-setup)))
>  
> -(if (treesit-ready-p 'gomod)
> +(if (treesit-ready-p 'gomod t)
>      (add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode)))
>  
>  (provide 'go-ts-mode)

Yuan, why was this change made?  The fact that loading go-ts-mode.el
without a grammar library causes a warning is the intended behavior:
users who don't have tree-sitter setup for Go shouldn't load this
mode, and if they do, they should know it failed, and why.  The above
change makes it fail silently, which is not a Good Thing.

What was the problem you were trying to solve?

The subsequent change, viz.:

> branch: emacs-29
> commit 59365f928565f1be551b1697b9246b00cb87a9b7
> Author: Yuan Fu <casouri@gmail.com>
> Commit: Yuan Fu <casouri@gmail.com>
> 
>     * lisp/progmodes/go-ts-mode.el: Use treesit-language-available-p.
>     
>     treesit-ready-p does more checks than language grammar availability.
> ---
>  lisp/progmodes/go-ts-mode.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
> index 6043c86ac93..fbe085a2c6c 100644
> --- a/lisp/progmodes/go-ts-mode.el
> +++ b/lisp/progmodes/go-ts-mode.el
> @@ -393,7 +393,7 @@ what the parent of the node would be if it were a node."
>  
>      (treesit-major-mode-setup)))
>  
> -(if (treesit-ready-p 'gomod t)
> +(if (treesit-language-available-p 'gomod)
>      (add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode)))
>  
>  (provide 'go-ts-mode)

made this even worse: now we have a byte-compilation warning in a
build without tree-sitter, and this code will signal a generic error
(whose text is not very helpful to users) if the file is loaded in a
build without tree-sitter.  This is all against the intended behavior
of these modes.

Again, what problem were you trying to fix with that change?



             reply	other threads:[~2023-03-02  7:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02  7:41 Eli Zaretskii [this message]
2023-03-03  3:05 ` emacs-29 56cd810b9d1: Don’t signal warning when loading go-ts-mode.el without grammar Yuan Fu
2023-03-03  7:41   ` Eli Zaretskii
2023-03-03 22:06     ` Yuan Fu
2023-03-04  7:05       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r0u7eh2f.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).