From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 18 02:52:46 2025 Received: (at submit) by debbugs.gnu.org; 18 Sep 2025 06:52:46 +0000 Received: from localhost ([127.0.0.1]:59673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uz8Va-00009o-37 for submit@debbugs.gnu.org; Thu, 18 Sep 2025 02:52:46 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55038) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uz8VV-00009W-7K for submit@debbugs.gnu.org; Thu, 18 Sep 2025 02:52:43 -0400 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 1uz8VP-0004fe-31 for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2025 02:52:35 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1uz8VM-0003iP-9Q for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2025 02:52:34 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4cS5t33lbgz9th3 for ; Thu, 18 Sep 2025 08:52:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1758178347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=e/usQzB+UqEQhFuGjuXTJp5SD/KZlbN2kcORGSfToPI=; b=IZ2Fqi4SPgTSk6UhDKbjQxHIIydGIdt4sH7eb15ngBk1wPvvqA5D+QtLp+cOYVbZjwpVx1 JI1WxZHpiE7/jcaPbUkWTzhXGTIU422Gn6k/24v4tB66uEr03B1l61mpcALapIvsQXNWhz xgOPOEIIe8wiBm9t9w6VCkROsTksZN1u3Fi6Bex1PFfeikiQNaNNXb45+arRg5XkJOdh/6 L4mbkBVwll3S/5uT2LEtNuULCR0YW15GfN8TyEW6nIfecfEP5QpelNouxPxRXVQZe+yNlU HR//UwvaM5Z8gJaaB3B2PPn9i1cz5AzZO71z4bYelDeMfCaIfQjXzRo7b099cQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: js-ts-mode treesit-thing-settings Organization: LINKOV.NET X-Debbugs-Cc: Yuan Fu Date: Thu, 18 Sep 2025 09:48:04 +0300 Message-ID: <87tt10uuhn.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Rspamd-Queue-Id: 4cS5t33lbgz9th3 Received-SPF: pass client-ip=80.241.56.161; envelope-from=juri@linkov.net; helo=mout-p-103.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain While improving treesit-things for ts-modes, I hesitated to change js--treesit-thing-settings, but now don't see a problem with adapting the same rule as already used by c-ts-mode for a long time that matches all nodes except "{" "}" "[" "]" "(" ")" ",". The problem is that the existing 'js--treesit-sexp-nodes' is a list of nodes joined together by 'js--regexp-opt-symbol', whereas the new definition is a sexp matcher. Therefore we could make the internal variable 'js--treesit-sexp-nodes' obsolete like in this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=js--treesit-thing-settings.patch diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 00c57b72e18..0fda7d62145 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3949,38 +3949,11 @@ js--treesit-sentence-nodes "Nodes that designate sentences in JavaScript. See `treesit-thing-settings' for more information.") -(defvar js--treesit-sexp-nodes - '("expression" - "parenthesized_expression" - "formal_parameters" - "pattern" - "array" - "function" - "string" - "template_string" - "template_substitution" - "escape" - "template" - "regex" - "number" - "identifier" - "property_identifier" - "this" - "super" - "true" - "false" - "null" - "undefined" - "arguments" - "pair" - "jsx" - "statement_block" - "object" - "object_pattern" - "named_imports" - "class_body") +(defvar js--treesit-sexp-nodes nil "Nodes that designate sexps in JavaScript. See `treesit-thing-settings' for more information.") +(make-obsolete 'js--treesit-sexp-nodes + "`js--treesit-sexp-nodes' will be removed soon, use `js--treesit-thing-settings' instead." "31.1") (defvar js--treesit-list-nodes '("export_clause" @@ -4011,7 +3984,13 @@ js--treesit-jsdoc-beginning-regexp (defvar js--treesit-thing-settings `((javascript - (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes)) + (sexp ,(if js--treesit-sexp-nodes + (js--regexp-opt-symbol js--treesit-sexp-nodes) + `(not (or (and named + ,(rx bos (or "program" "comment") eos)) + (and anonymous + ,(rx (or "{" "}" "[" "]" + "(" ")" ","))))))) (list ,(js--regexp-opt-symbol js--treesit-list-nodes)) (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes)) (text ,(js--regexp-opt-symbol '("comment" --=-=-=--