[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code quality of some -ts-mode major modes

From: Eli Zaretskii
Subject: Re: Code quality of some -ts-mode major modes
Date: Fri, 17 Mar 2023 13:52:46 +0200

> Cc: Yuan Fu <casouri@gmail.com>, emacs-devel@gnu.org
> Date: Fri, 17 Mar 2023 18:29:52 +0800
> From:  Ruijie Yu via "Emacs development discussions." <emacs-devel@gnu.org>
> >  (require 'treesit)
> >
> > -(declare-function treesit-parser-create "treesit.c")
> > +;; (declare-function treesit-parser-create "treesit.c") ;doesn't appear 
> > necessary
> I noticed this portion as well as in c-ts-mode.el, where a bunch of
> `declare-function''s follow `(require 'treesit)'.  Does it work if all
> calls to `(require 'treesit)' are wrapped with `eval-and-compile', and
> we remove all the `declare-function''s?

No, it doesn't.  The declare-function are about functions implemented
in treesit.c, not treesit.el, so loading the latter cannot possibly
fix the need for declare-function in these cases.

> Or were these `declare-functions' calls simply there for redundancy?

No, they are there to avoid byte-compiler warnings when building Emacs
without tree-sitter support (which is optional).

> > -  (when (treesit-ready-p 'yaml)
> > +  (when (treesit-ready-p 'yaml)         ;why not raise an `user-error'?
> >      (treesit-parser-create 'yaml)
> Raising a `user-error' would disallow the user from staying in the TS
> mode (in this case, `yaml-ts-mode').  IIRC, someone said that a TS mode
> should be roughly the same as `fundamental-mode' if the respective TS
> grammar library is absent.  Not sure exactly, so let's wait for a
> maintainer's response on that.

We _want_ this to signal an error so that the user is acutely aware
his/her system is not configured for these modes.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]