From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Code quality of some -ts-mode major modes Date: Fri, 17 Mar 2023 13:52:46 +0200 Message-ID: <83ilezegs1.fsf@gnu.org> References: <87fsa3g05n.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38354"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, casouri@gmail.com, emacs-devel@gnu.org To: Ruijie Yu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 17 12:53:27 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pd8eF-0009dn-0A for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Mar 2023 12:53:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pd8dc-0006G8-9H; Fri, 17 Mar 2023 07:52:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pd8db-0006Fx-91 for emacs-devel@gnu.org; Fri, 17 Mar 2023 07:52:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pd8da-0007nX-JD; Fri, 17 Mar 2023 07:52:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=bfhwRzCDl2vEb9QpPqqwk0HO8+LSGRKrsKFItKZLF0Q=; b=Vsl9C101WjTd vTmdyPxH6kwTMz/Vl+gOlUbGnh0lkNaHwuK91tpRqFx7boVfccf3N4DTeNogylXix6a04HRECJ7iq L8W7sMVGvSBxO/uGgU4O0JZ+zhhcNM4a/1YIH0AkMNoiITcl02Z6iXoxx2i69WIJK9w4uRNmi7Rar FPFlm9nN4q7Pm/t4ZKcfvH4eMQkFCbPtfuBW1cnTsNMZibL3HvJG+y2LUjTWJjhL3n79REtvlk+j0 GZECrfVowoS5rPcIlJQqYU3hVV4bBwrVg2kRMSIItcxqiTKbblVnDgO6UWbewpa/gibtzr80Yvk1G Ik6HBOQsNP35lO//lVLtLw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pd8da-0006z4-42; Fri, 17 Mar 2023 07:52:46 -0400 In-Reply-To: (emacs-devel@gnu.org) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304545 Archived-At: > Cc: Yuan Fu , emacs-devel@gnu.org > Date: Fri, 17 Mar 2023 18:29:52 +0800 > From: Ruijie Yu via "Emacs development discussions." > > > (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.