From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Call for volunteers: add tree-sitter support to major modes Date: Sun, 9 Oct 2022 15:39:49 -0700 Message-ID: <158F25C9-A539-4515-8D49-50A7E6252960@gmail.com> References: <83czb1jrm3.fsf@gnu.org> <84436B1D-3359-487F-B997-A7F56FDEA636@thornhill.no> <83bkqljih5.fsf@gnu.org> <87fsfx6ufb.fsf@thornhill.no> <8335bxjdpf.fsf@gnu.org> <1D07A0F1-A269-410A-9D3C-8A53113FFE2F@thornhill.no> <83sfjxhuvc.fsf@gnu.org> <87bkqk7qb0.fsf@thornhill.no> <8735bw7kwm.fsf@thornhill.no> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21115"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 10 00:40:59 2022 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 1oheyh-0005Ja-Fr for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 00:40:59 +0200 Original-Received: from localhost ([::1]:39828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oheyg-0008Ec-1U for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Oct 2022 18:40:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohexf-0007Vh-Vq for emacs-devel@gnu.org; Sun, 09 Oct 2022 18:39:56 -0400 Original-Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:44878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohexe-0001nA-5E; Sun, 09 Oct 2022 18:39:55 -0400 Original-Received: by mail-pl1-x631.google.com with SMTP id x6so8899268pll.11; Sun, 09 Oct 2022 15:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lPVwt6Q/y5jpDg85Ow9BhwPbzLvZEKt78wAoNojnXRA=; b=VYuSHaQLWAtf7Ky7I38mayAgSZrjF3qcQyX4tVdazc2LRaG5uf/k0YTK0aIFc5KN3s wYaB7qqF/xtQU+XM/6wwMFkhdqHqkxlUZgki0Z7Lga6nmPlqEIrMEPlPVxPdyxwRnomf gJlRCPsv4AR78wk/tu+yy3HhFBwRnlQ06nhert9E6DdLprNhIlWNOnbbTo10gUrQaKTQ LYPPl2LIPEPVK3P1OhlRd6/x26XzW/wx+D013Fj0TY4teMe0leX4sjvl9C/F+PjmZpIr CHB4Wn6hIrY96VTuzI8PvOwxHjH664ue/0daYrFGC8XBhSUbQSUqlF7UmMHPKeLIy7+z 8N+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lPVwt6Q/y5jpDg85Ow9BhwPbzLvZEKt78wAoNojnXRA=; b=4xqRtnlSpCP15KH4V8BMjlQ6s4Aio8OZWFTzoj8KAQih4ihloM/kiw7FM0UrPfRXB3 MZszY9wOnaLJfDy4B7G/3CZEu7kvyiJmkOIgxiRUfNzBgfShNfaHeAHszYbRpjUK6qex 4q+QDJxVqDvS8bMOGzVGrWIa2fLWKK/CNPJhA2TQRfKWE00d5ClodnZ2xMalm0dBR0MI ob5B7gyjNzwmKq7x/lfntK09IoyAaHgN8aX1IPwBnMpg9zUF8Jv+T17HZdpS7SnDipMl /OJ8eAqJptMdu81+bwxm3n6MJeDkwN/KQTj0bncbjXgqH2MQ2F9tIygunef5xJIOWnBf Iqog== X-Gm-Message-State: ACrzQf1vlP/v8lcyTOw4LHsXZTL0cirRyAIzo1n1j0LcXlgrM0gelc+v YEHv1makPG6K/H7vpJ5hurijCdkkjg8= X-Google-Smtp-Source: AMsMyM7Bqv+mE57Ji6aJ0j+I4qbD14UYFt5+9SiTXLxARpYkoswzON9XOoyU2lxobWeZPpHg/Jpwxg== X-Received: by 2002:a17:902:8303:b0:182:4ef1:8740 with SMTP id bd3-20020a170902830300b001824ef18740mr2820810plb.4.1665355191965; Sun, 09 Oct 2022 15:39:51 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id b12-20020a170902d50c00b00181f1f4fcc0sm1387363plg.202.2022.10.09.15.39.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Oct 2022 15:39:51 -0700 (PDT) In-Reply-To: <8735bw7kwm.fsf@thornhill.no> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=casouri@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.devel:297295 Archived-At: > On Oct 9, 2022, at 2:21 PM, Theodor Thornhill = wrote: >=20 > Theodor Thornhill writes: >=20 >> Eli Zaretskii writes: >>=20 >>>> Date: Sun, 09 Oct 2022 17:18:52 +0200 >>>> From: Theodor Thornhill >>>> CC: emacs-devel@gnu.org >>>>=20 >>>> BTW, I can do json as well, should be quick enough :) I'll add it = in a different patch >>>=20 >>> TIA >>=20 >> So I added tree sitter support for js-json-mode, js-jsx-mode as well. >> The changes were simple enough not to warrant a separate patch, IMO, = so >> I just updated the old one. >>=20 >> What do you think, Yuan and Eli? >=20 > A small followup patch - this should be the last to consider for now - > sorry the many patches :) >=20 > Theodor > <0001-Add-tree-sitter-functionality-to-js-mode.patch> Looks good! Here are some comments. + + ;; FIXME: We need to be able to set the priority for font-locking + ;; somehow. We cannot just override all of the template string, + ;; as that would mess up interpolated expressions + ;; + ;; (template_string) @font-lock-string-face + (template_substitution ["${" "}"] @font-lock-constant-face) + ))) What exactly do you mean by priority here? Why doesn't :override t work? + +(defvar js-treesit--defun-query + "[(class_declaration) + (method_definition) + (function_declaration) + (variable_declarator)] @defun") This should be compiled. + +(defun js--treesit-enable () + (unless (and (treesit-can-enable-p) + (treesit-language-available-p 'javascript)) + (error "Tree sitter isn't available")) I don't think we should error here, I'd displaying a message instead. + + ;; Comments + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") I think it's best to not repeat code, could you move this outside the (if tree-sitter) form and have it run regardless? +(defun js--json-treesit-enable () + (unless (and (treesit-can-enable-p) + (treesit-language-available-p 'json)) + (error "Tree sitter isn't available")) Same as above, IMO message is better. Thanks, Yuan