From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: casouri@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Nov 2022 19:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 59617@debbugs.gnu.org Cc: casouri@gmail.com X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: casouri@gmail.com Received: via spool by submit@debbugs.gnu.org id=B.166948920014495 (code B ref -1); Sat, 26 Nov 2022 19:00:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Nov 2022 19:00:00 +0000 Received: from localhost ([127.0.0.1]:41434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0PA-0003lj-47 for submit@debbugs.gnu.org; Sat, 26 Nov 2022 14:00:00 -0500 Received: from lists.gnu.org ([209.51.188.17]:45108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0P4-0003lb-ND for submit@debbugs.gnu.org; Sat, 26 Nov 2022 13:59:58 -0500 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 1oz0P4-00059g-5E for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 13:59:54 -0500 Received: from out-218.mta0.migadu.com ([2001:41d0:1004:224b::da]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oz0P0-0001OW-PA for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 13:59:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669489182; 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=hHqJtJ5OUR8kaaSdhXfT+EXWKhoS56BfvXytuUkztzw=; b=dAKjnYkcM/1WulJeDOt++zr0abpsISLPX05VkAV0ID9k3YfKiDWKryeh3meCqkM1q9rEC3 r6TAJzkqogA0Pn3k3GdKBV2zmdJuajuNW+VOrWooz9NSCQOJhyPrjQ9HwVxTc31UNn/knI fZvS5PQHfXEX6nPU5LCQbjnTQRSxqUt0CHA8Z8niKeg3cOMgJTpVlbXkezmtlWt17EiLJo TNxpyeqYlZ3+b7ocCrD4/kCwKKxtZ3UUZ5V6aMmZ8zF2NMbWDKCu0R7cSclLHCmfglrCBG dikK8bbG+bwvHs/OAOyWyF3eLfQMkjfTPgS9VNT+bVKTC8V34hMbGuAWmZwmbg== From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:59:34 +0100 Message-ID: <87r0xp4k4p.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::da; envelope-from=theo@thornhill.no; helo=out-218.mta0.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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: -2.4 (--) --=-=-= Content-Type: text/plain Hi Yuan and others! I've added in the ability for users to set their own indentation style should that be needed. I just followed what I already did in c-ts-mode and c++-ts-mode, so I believe this shouldn't be too controversial :-) Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From 5f5695916b71af4f9e778f4bd5c51edb2c85067e Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 121 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fc35d9aedd..c384182772 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index a544a4b5cb..a6373b5826 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -696,6 +696,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -962,7 +980,8 @@ csharp-ts-mode (setq-local comment-end "") ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index ee2934f53c..29de2ccb28 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -42,6 +42,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -305,7 +323,8 @@ java-ts-mode (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index da05b7b364..9535d4986f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3862,7 +3880,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..4ee2cad9da 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 763686bf66..106b8363f0 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -308,7 +326,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 734252ee66..eaf3fec939 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1804,7 +1822,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Nov 2022 11:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 59617@debbugs.gnu.org Cc: eliz@gnu.org, larsi@gnus.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.16695498306068 (code B ref 59617); Sun, 27 Nov 2022 11:51:01 +0000 Received: (at 59617) by debbugs.gnu.org; 27 Nov 2022 11:50:30 +0000 Received: from localhost ([127.0.0.1]:42211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozGB3-0001Zo-U1 for submit@debbugs.gnu.org; Sun, 27 Nov 2022 06:50:30 -0500 Received: from out-118.mta0.migadu.com ([91.218.175.118]:13670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozGB1-0001Zg-Oo for 59617@debbugs.gnu.org; Sun, 27 Nov 2022 06:50:28 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669549826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tjI6PVQ3Wn8DOPfThZFqqM1CsPQRnS2U8v3WSlPudJk=; b=kCzeItszwhcz1fFPM+S9yfkCeambP+hURcvSVN1t+f9zrySzZSeAnl8k5zo90QIwg/tAhr uzuPs1FtXy1KK+gTLwEb9hkq43+6Z5NC1NhQI/CZZFiDixzbJKap97EcIp3jubTbcrt2cA msC7gSnCHlvQJmpQ0JHP8k+Nh64pCYwQhHadhJK90N//cYWMBLjCJrRUnhZwZaNIk3hm1H AM7choDixVys6L6xyQNm9688AwnaN5g9XS7o/MEVVBfqFcqnBtSQHahDDVSrGaWWzLKB49 gvxc5rjJTgxXHsSw/XGo3zhS7mWGFv1DDc+h3FF92NOr+cVhY5SJxtpA9EgFkQ== From: Theodor Thornhill In-Reply-To: References: <87r0xp4k4p.fsf@thornhill.no> Date: Sun, 27 Nov 2022 12:50:19 +0100 Message-ID: <87v8n01uro.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) Hi Eli and Lars :-) I have some other ideas and improvements I'm planning in the tree-sitter modes, and it would be really nice to be able to do this myself. I know we've discussed this already, but do you still think it's premature giving me write access? Building commits on top of eachother, then splitting up and so on is a hassle while waiting for things to be committed for me. And it causes extra work for you guys. If you still think so that's ok, but I'd like to still get some more stuff in before the split! Theo From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Nov 2022 23:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.16695923368207 (code B ref 59617); Sun, 27 Nov 2022 23:39:01 +0000 Received: (at 59617) by debbugs.gnu.org; 27 Nov 2022 23:38:56 +0000 Received: from localhost ([127.0.0.1]:44843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozREd-00028J-Kp for submit@debbugs.gnu.org; Sun, 27 Nov 2022 18:38:56 -0500 Received: from out-156.mta0.migadu.com ([91.218.175.156]:38282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozREa-00028D-Ad for 59617@debbugs.gnu.org; Sun, 27 Nov 2022 18:38:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669592330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FROUznJSeHC5CWmYnCjvMeLCH7OXWJuNlCDzeDsmPwI=; b=izRmMWfDvptKfqTiq8EA5UwJU1Onx42cuTpIjjhbbSgNLPDF6V7ryDGODFN5XZ/twFrzNk d16hQzSkGSGUVDkqBewf71rlQB9PDLgEU5n+MpL9TEFCElfIM3SXyZ0Ht8XfFYynWoZMgl w57jZt3NBpx/RkwaRfNYROYrzIpr1dYLv6K5wKVrwUrvjHJSqO5tH9OzytywoRWm3yvT1D qiFM/vdtkyFlnJsYaV7Yyc5yhOmiMcIYx52CP/VsUbSR4yn/3eJDVUMXpj+7SSeMjZrlxX uK2kraSP1EkeeONC7CVfPmVdAmMpb6bKDnl2PGvIkZ2cdQfpyJx2FBnp/jRU7A== From: Theodor Thornhill In-Reply-To: References: <87r0xp4k4p.fsf@thornhill.no> Date: Mon, 28 Nov 2022 00:38:43 +0100 Message-ID: <87r0xo0xz0.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) --=-=-= Content-Type: text/plain Fixed a typo - see this patch: Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From be876fa59bb2999a70f183081bbd682245350d0b Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. (json-ts-mode--indent-rules): Rename from 'json-ts--indent-rules' * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. (Bug#59617) --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 23 +++++++++++++++++++++-- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 122 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 086257483e..ae0d163d6f 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 3f691956f8..01b8a7a502 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -625,6 +625,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -892,7 +910,8 @@ csharp-ts-mode (setq-local comment-end "") ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index dd3d6d31e0..561168008a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -42,6 +42,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -305,7 +323,8 @@ java-ts-mode (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index f2016deb5d..82c33e5b58 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3862,7 +3880,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..113b25a899 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -64,7 +82,7 @@ json-ts-mode--syntax-table "Syntax table for `json-ts-mode'.") -(defvar json-ts--indent-rules +(defvar json-ts-mode--indent-rules `((json ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 8a9d540bd3..61e13d1723 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -304,7 +322,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 734252ee66..eaf3fec939 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1804,7 +1822,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 07:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 59617@debbugs.gnu.org Cc: Yuan Fu Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.16696187628593 (code B ref 59617); Mon, 28 Nov 2022 07:00:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 06:59:22 +0000 Received: from localhost ([127.0.0.1]:46714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozY6r-0002EX-8P for submit@debbugs.gnu.org; Mon, 28 Nov 2022 01:59:22 -0500 Received: from out-34.mta0.migadu.com ([91.218.175.34]:12829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozY6o-0002ER-CG for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 01:59:19 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669618756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gP/xNjo28URWvPOK0J6uF1L4icjirXP7Z/tIEBcVgyI=; b=Dn+mGaSBH70GuxaxxAad4vtdMNyy3adN+GbaIp8G0BFS6ZcyqPCYBOrpusrO7ZEIhwCe8Z r+xbmOPZyfLQboy/F9wV4r8DZIhxzgZn5HAjXL9ZLJD63NkTsQvdZ3Tv5N0QU74MP3Zr8K dKKs9zAJoIFoL/DG69llte7S1lPXNu3CVsjDA7aZgjDV52zh+iuUfOMy3ctbOIWsJ7peQK E4te6Mp6h5YTc/U4Ytw4+75RG3pdtkiIbtaSoanlZSu0aLaFK1mnOSv/2cpfsd9nvDxqE7 Qdod1Bsre2kR1O2mK1Sp3XPW6rtsm6cwJJ5m0vVPn40vn/KVtNJdM3JQiNz98Q== From: Theodor Thornhill In-Reply-To: <87r0xo0xz0.fsf@thornhill.no> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> Date: Mon, 28 Nov 2022 07:59:10 +0100 Message-ID: <87tu2jo98h.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) --=-=-= Content-Type: text/plain Theodor Thornhill writes: > Fixed a typo - see this patch: > Rebased the patch on top of origin/master: What do you think, Yuan? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From be876fa59bb2999a70f183081bbd682245350d0b Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. (json-ts-mode--indent-rules): Rename from 'json-ts--indent-rules' * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. (Bug#59617) --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 23 +++++++++++++++++++++-- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 122 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 086257483e..ae0d163d6f 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 3f691956f8..01b8a7a502 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -625,6 +625,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -892,7 +910,8 @@ csharp-ts-mode (setq-local comment-end "") ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index dd3d6d31e0..561168008a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -42,6 +42,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -305,7 +323,8 @@ java-ts-mode (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index f2016deb5d..82c33e5b58 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3862,7 +3880,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..113b25a899 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -64,7 +82,7 @@ json-ts-mode--syntax-table "Syntax table for `json-ts-mode'.") -(defvar json-ts--indent-rules +(defvar json-ts-mode--indent-rules `((json ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 8a9d540bd3..61e13d1723 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -304,7 +322,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 734252ee66..eaf3fec939 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1804,7 +1822,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 12:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.16696383735783 (code B ref 59617); Mon, 28 Nov 2022 12:27:01 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 12:26:13 +0000 Received: from localhost ([127.0.0.1]:48288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozdDA-0001VD-5a for submit@debbugs.gnu.org; Mon, 28 Nov 2022 07:26:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozdD3-0001Uq-7J for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 07:26:10 -0500 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 1ozdCx-0001Xc-RT; Mon, 28 Nov 2022 07:25:59 -0500 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=yeOh/OVHAEN/x3Fgg1Rmv/KZC3EAv9okPh4h9ybPdLQ=; b=CkDOltn3ES+m Z6mmPp2799NcI0jialNYRCKOkdFIBU4ESf815OTcLkwqr9MhFrPtbnAANEvOQsFS66xHLPl03/wGc GE74OMsekBAYuKI5mQ/13bExY0usLQQ/msZxIbl0vSr6vIFB7WrJ+Jj0YDx0m6FrRPg8squpGNW/0 20l+uWtjvC7d2kWRGn859wkcztmA1xP2MiU52I4Gd68+KOxM5+pvIWWnqA9YlDzljwRS+xP8Mg6+V sLTChIYH7CkZjJivw+8NLj4hWeNI920gKGVodjmHgj2aWDmY8X9K99wxHEok9g+tLj7dlURVfPdcA veCy24FtQlCPENFk/G6sxg==; 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 1ozdCj-0005p9-1E; Mon, 28 Nov 2022 07:25:57 -0500 Date: Mon, 28 Nov 2022 14:26:16 +0200 Message-Id: <83v8mznu3b.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87tu2jo98h.fsf@thornhill.no> (bug-gnu-emacs@gnu.org) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > Cc: Yuan Fu > Date: Mon, 28 Nov 2022 07:59:10 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Theodor Thornhill writes: > > > Fixed a typo - see this patch: > > > > Rebased the patch on top of origin/master: > > What do you think, Yuan? FWIW, I consider user options that require functions as values not a good UI. Many users, especially newbies, will not be able to use such options, because they cannot come up with functions that do what they want. It is okay to have a function value as one of N alternatives, where N > 5, say, so that such users could still choose from "simpler" values, where the "function" was pre-arranged by us for them. But having just the default and a function is definitely not good enough IMO. Cannot we come up with a couple of popular styles for each language, and have those styles ready to be selected by simple atom values in the defcustom? Thanks. P.S. Btw, what about other indentation-related facilities, like "C-c C-q" in CC Mode? From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 12:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166963912214956 (code B ref 59617); Mon, 28 Nov 2022 12:39:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 12:38:42 +0000 Received: from localhost ([127.0.0.1]:48354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozdPF-0003tA-VQ for submit@debbugs.gnu.org; Mon, 28 Nov 2022 07:38:42 -0500 Received: from out2.migadu.com ([188.165.223.204]:35033) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozdPD-0003t3-LJ for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 07:38:40 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669639118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1eKdhF64PpiRqmKjGicoUSUmcfaWPbAkLdLYSauVYMM=; b=kOS9pQeXgBfv13o3ZxZog7U36atEal7tDybQX4PO50x0cZ94bbmYNF33V57G7kt3JSIrlu Us4JRtf8oDNNNhGodLVZmhoROPuDcXSL08bXXcOTyjiKUHrCLK4wqXem+SiQDJcivCz0DV k+fYq9J2FEzNKNsD/LK+vHGjsufltd0LoyQ3L4nHcAkAJ+yaIxGHo0pIN0w/qehBCmtM3W XCnflvK/+jyLRO//fRYWFLLph1HAExkygG6NUXZhc73ZUUczpG60e7G3Tnmpfxs8F+gRha 23cRIaaGtJU1mr2VXX9g+zQi3XweOXyAAH1qq2p3w1EonzKSDw/gcqnni0btjg== From: Theodor Thornhill In-Reply-To: <83v8mznu3b.fsf@gnu.org> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> Date: Mon, 28 Nov 2022 13:38:30 +0100 Message-ID: <87y1rv9ruh.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) 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: -1.0 (-) Eli Zaretskii writes: >> Cc: Yuan Fu >> Date: Mon, 28 Nov 2022 07:59:10 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Theodor Thornhill writes: >> >> > Fixed a typo - see this patch: >> > >> >> Rebased the patch on top of origin/master: >> >> What do you think, Yuan? > > FWIW, I consider user options that require functions as values not a good > UI. Many users, especially newbies, will not be able to use such options, > because they cannot come up with functions that do what they want. > > It is okay to have a function value as one of N alternatives, where N > 5, > say, so that such users could still choose from "simpler" values, where the > "function" was pre-arranged by us for them. But having just the default and > a function is definitely not good enough IMO. > > Cannot we come up with a couple of popular styles for each language, and > have those styles ready to be selected by simple atom values in the > defcustom? > I guess we could, but most other languages provided here have a pretty standard coding style, IIRC. Not saying it's not any variations. This is meant mostly as an escape hatch if needed, so that a user _can_ provide their own indentation style should they need it. > > P.S. Btw, what about other indentation-related facilities, like "C-c C-q" in > CC Mode? I'm planning on making those, yes From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 13:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964190616604 (code B ref 59617); Mon, 28 Nov 2022 13:26:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 13:25:06 +0000 Received: from localhost ([127.0.0.1]:48594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oze89-0004Jk-VO for submit@debbugs.gnu.org; Mon, 28 Nov 2022 08:25:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oze88-0004JE-H6 for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 08:25:04 -0500 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 1oze83-0003kg-9D; Mon, 28 Nov 2022 08:24:59 -0500 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=JDg6lqanx9S5iEQMFoCNaNOVLN3Krz5eaCzmem8f9us=; b=P2EP1mNBBknq FS9fSC7sk28rZ+pY/PoB9EJ2ihZt5raw0v1XFGW49zXp7gA7FqymZ1gtRPxrCM1J3W9O5Q5NmhZ6P W9WXtk7LjDu1z1oUvvpiBjnoGl7mo62mtz6JsSA+/uLeA/z5+tAehXy/mWHvG3lTlioG177iAS4Da 0PujDhbaXB429cmcw2NOJ+3UDyUKRXJ77GviZ+LrOSe2y6yX3pV8VbBAxac1E6a5CgPo1vs/+9ZNU rJof+JGNaP+wmL9W0nUF8VfWDa6fXmXp3jG3Kibt5RcPxP/A25a2TCsor6zTM9MQQJUKvFqQpsbxI dp/EOpIV80+TWj7YKmzacw==; 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 1oze82-0007Df-FZ; Mon, 28 Nov 2022 08:24:58 -0500 Date: Mon, 28 Nov 2022 15:25:29 +0200 Message-Id: <83k03fnrcm.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87y1rv9ruh.fsf@thornhill.no> (message from Theodor Thornhill on Mon, 28 Nov 2022 13:38:30 +0100) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > From: Theodor Thornhill > Cc: 59617@debbugs.gnu.org, casouri@gmail.com > Date: Mon, 28 Nov 2022 13:38:30 +0100 > > > Cannot we come up with a couple of popular styles for each language, and > > have those styles ready to be selected by simple atom values in the > > defcustom? > > > > I guess we could, but most other languages provided here have a pretty > standard coding style, IIRC. Only one standard style? I'm surprised. Even if the variations are much less popular, they still deserve to be supported OOTB, IMO. > Not saying it's not any variations. This is meant mostly as an escape > hatch if needed, so that a user _can_ provide their own indentation style > should they need it. If we don't expect anyone reasonable to try that, fine. But if we do (and a defcustom seems to say we do), then I'd provide a couple of other styles, even if they are used much more rarely. > > P.S. Btw, what about other indentation-related facilities, like "C-c C-q" in > > CC Mode? > > I'm planning on making those, yes Thanks! From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 13:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964292917175 (code B ref 59617); Mon, 28 Nov 2022 13:43:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 13:42:09 +0000 Received: from localhost ([127.0.0.1]:48681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozeOf-0004Sx-1N for submit@debbugs.gnu.org; Mon, 28 Nov 2022 08:42:09 -0500 Received: from out-114.mta0.migadu.com ([91.218.175.114]:37090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozeOc-0004Sr-OX for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 08:42:07 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669642925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8tmTt0xmw77V8hNtu/RyPdoVo8miNUn537CGmBLKCKg=; b=fdaWqdT2nshCOI1nXYBr4qO5B8H3ZAq0Dx3dCD1Fr00g6YBhJe+iFLAJ1K7GuP4y7QOWk4 oYi1rb7t6iL/186pAlFbJD9ctIxbGbYz97+ElWgqJsj0Lj1rOi1OLwpDQauQ7naqg2wVh1 BPE4H1Tg2RTdfH+LzrK8QEqaUzrPN90i6vNrxzYVWjiVRrja5dBCAHMbTgK0t/JC30md5g q8N9LmSKjgLUt+iJOfos+9Fm7hGWPUuyGYWeEQRME9f5eIBFhCqvAnemjGwfFf57edr1aJ 3JzcdZBbHQmnuJodchEFp8ZQMicDkRHRg0jgyCW950G+zwa9BqKL82E32NjhSw== From: Theodor Thornhill In-Reply-To: <83k03fnrcm.fsf@gnu.org> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> Date: Mon, 28 Nov 2022 14:41:57 +0100 Message-ID: <87v8mz9owq.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: 59617@debbugs.gnu.org, casouri@gmail.com >> Date: Mon, 28 Nov 2022 13:38:30 +0100 >> >> > Cannot we come up with a couple of popular styles for each language, and >> > have those styles ready to be selected by simple atom values in the >> > defcustom? >> > >> >> I guess we could, but most other languages provided here have a pretty >> standard coding style, IIRC. > > Only one standard style? I'm surprised. Even if the variations are much > less popular, they still deserve to be supported OOTB, IMO. > >> Not saying it's not any variations. This is meant mostly as an escape >> hatch if needed, so that a user _can_ provide their own indentation style >> should they need it. > > If we don't expect anyone reasonable to try that, fine. But if we do (and > a defcustom seems to say we do), then I'd provide a couple of other styles, > even if they are used much more rarely. > Ok, I can supply some more styles. This bug or a subsequent bug? >> > P.S. Btw, what about other indentation-related facilities, like "C-c C-q" in >> > CC Mode? >> >> I'm planning on making those, yes > > Thanks! No problem. Theo From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 13:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964305717260 (code B ref 59617); Mon, 28 Nov 2022 13:45:01 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 13:44:17 +0000 Received: from localhost ([127.0.0.1]:48699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozeQi-0004UK-SS for submit@debbugs.gnu.org; Mon, 28 Nov 2022 08:44:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozeQg-0004UE-Ky for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 08:44:15 -0500 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 1ozeQa-0007uv-P0; Mon, 28 Nov 2022 08:44:09 -0500 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=nKW+2GzFBYKgxT0YDKgwe4O5oTEbyvflpHw2PODEekc=; b=JXWpv94W9oCT Gxe1boZfmZuglVsUHnNcOiyQyWBlIu167xxnB0jWXjw8Pvqk7rsENQw0p7JuhA+vt9FG0VMbOb/MJ jreKDOjj6zkzRjus9IWZ/7xlYcGpTt5ZtuLPAuRQAcVulIx4KyrO/OqwPlOQpzrTyBMuUx9t/wTah DTDKcYyegNppxl2OpP9pr2xHBH2O2c0jr/IkDbG1OXRWac4pekd626L6ddkgIdcCzyMJrZlfAVFTa S06QlhSrh0IsDrhhpbCMYNqXjY1ZnM8Y0THRHINhP9SCgLl3/rLsGavZbAPmXXb9t+iv0QJo8D/Tc zf38gygHs+pAZMPBKTWOSA==; 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 1ozeQX-0006fW-R3; Mon, 28 Nov 2022 08:44:06 -0500 Date: Mon, 28 Nov 2022 15:44:36 +0200 Message-Id: <83edtnnqgr.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87v8mz9owq.fsf@thornhill.no> (message from Theodor Thornhill on Mon, 28 Nov 2022 14:41:57 +0100) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > From: Theodor Thornhill > Cc: 59617@debbugs.gnu.org, casouri@gmail.com > Date: Mon, 28 Nov 2022 14:41:57 +0100 > > Eli Zaretskii writes: > > > If we don't expect anyone reasonable to try that, fine. But if we do (and > > a defcustom seems to say we do), then I'd provide a couple of other styles, > > even if they are used much more rarely. > > > > Ok, I can supply some more styles. This bug or a subsequent bug? This one, I think. It's the same issue. From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 15:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964767219818 (code B ref 59617); Mon, 28 Nov 2022 15:02:01 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 15:01:12 +0000 Received: from localhost ([127.0.0.1]:49067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfdA-00059a-0E for submit@debbugs.gnu.org; Mon, 28 Nov 2022 10:01:12 -0500 Received: from out-216.mta0.migadu.com ([91.218.175.216]:10313) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfd6-00059U-17 for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 10:01:10 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669647666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gr/uSetFK/7qDfJNeTQfzMT/9QO4hkU+NutUe8ukkO4=; b=GzfHpZW/bL7dIzYmSvc91+ny8JnKJi1BNvSctCluiMRoVeF9Or7s6/po/qJn4QHkzzPvJo 7jl8G92URfttZm1ZMbLkEKNXzTmG4rZb0Jsf4oQwgpqGoqUDp1YzavyG8NYSmludhXlneo xXR2y0TFf2yazAIYxud5nYugygZpmQF/4LzD0y/hgJ0AsQbV0jDFwQKjuOCkFseDWhMkrr xel8WrRLCidxC5w19rOCO6XCkNoBw1iOp2LqloT3bjnplybwVFs+/Udo3PD2I1sGuxAEWT RpPIH54h/ZgBr3Vva2FQjz2No4vjPK9jOnU1krBznTJ552o4yIF8eddvNvCe8w== From: Theodor Thornhill In-Reply-To: <83edtnnqgr.fsf@gnu.org> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> Date: Mon, 28 Nov 2022 16:00:58 +0100 Message-ID: <874jujktsl.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: 59617@debbugs.gnu.org, casouri@gmail.com >> Date: Mon, 28 Nov 2022 14:41:57 +0100 >> >> Eli Zaretskii writes: >> >> > If we don't expect anyone reasonable to try that, fine. But if we do (and >> > a defcustom seems to say we do), then I'd provide a couple of other styles, >> > even if they are used much more rarely. >> > >> >> Ok, I can supply some more styles. This bug or a subsequent bug? > > This one, I think. It's the same issue. Hmm, I really cannot seem to find any very specific, recognized styles for any of the languages. I think either we go with this like it is now, or wait until later altogether. My reasoning was that _if_ some people have very specific needs we can accomodate that, but IMO it's a little too time-consuming looking all around after styles that noone uses :-) I'd rather focus on improving what we have. Should we just close this? I'm fine either way. Theo From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 15:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964788419945 (code B ref 59617); Mon, 28 Nov 2022 15:05:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 15:04:44 +0000 Received: from localhost ([127.0.0.1]:49094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfga-0005Bd-Ab for submit@debbugs.gnu.org; Mon, 28 Nov 2022 10:04:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfgZ-0005BW-EG for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 10:04:43 -0500 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 1ozfgU-0005rs-2M; Mon, 28 Nov 2022 10:04:38 -0500 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=v0gcMltqAUrxJOHeCGLKyuOlPVDvDY3VtHpxKcOOC/E=; b=dSl+uqPtzo6h woUXrQeW1g4/38zzgQ7NV6UmIKbQd2ZQ8gVkGPAMPcC6wU8i6W7O4UsrZaJTh13WRmvGsXszTqLz5 +AS1J3iVEUTCCYeM5VamopOmEsyoQMpUdDlF/2sKN0VGplCx5VEQ7fEaqkREU3OXVB7qCfQS1qjqN 28eXou4EsUN79t4xpt0O5SNfCEj3OCYUIFA8Ff3ixlYToSajghLHiRXJx2/g5wewnRudbo9uwPTWy /LSZ5VMHjy4JPIqfhQlPb1q1FdJPRjK2xDMnhjGjcjekaomtU9e6l7RbRN0tiFla6k5i5629fh9ZB oqSzhbYRohVgCu3w9pMnzQ==; 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 1ozfgT-0003dp-0G; Mon, 28 Nov 2022 10:04:37 -0500 Date: Mon, 28 Nov 2022 17:05:07 +0200 Message-Id: <838rjvnmqk.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <874jujktsl.fsf@thornhill.no> (message from Theodor Thornhill on Mon, 28 Nov 2022 16:00:58 +0100) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > From: Theodor Thornhill > Cc: 59617@debbugs.gnu.org, casouri@gmail.com > Date: Mon, 28 Nov 2022 16:00:58 +0100 > > Hmm, I really cannot seem to find any very specific, recognized styles > for any of the languages. I think either we go with this like it is > now, or wait until later altogether. My reasoning was that _if_ some > people have very specific needs we can accomodate that, but IMO it's a > little too time-consuming looking all around after styles that noone > uses :-) I'd rather focus on improving what we have. > > Should we just close this? Feel free. From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 15:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: theo@thornhill.no Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166964808620121 (code B ref 59617); Mon, 28 Nov 2022 15:09:02 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 15:08:06 +0000 Received: from localhost ([127.0.0.1]:49119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfjp-0005ET-T6 for submit@debbugs.gnu.org; Mon, 28 Nov 2022 10:08:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozfjo-0005E6-0Q for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 10:08:04 -0500 Received: from [2001:470:142:3::e] (helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozfji-0006XS-Jn; Mon, 28 Nov 2022 10:07:58 -0500 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=LkG5k3Qcp8zbHlAPl/8GFXljWyJCGzIXvqOq9jSWLKA=; b=O/tO8ue2SF63 Ve58X9of6+0QIIFULGVTuhyRYX+xM7TzLlVxSEG6XNt6UKBQ+yTARh1ABDN3/AL/Z16T4AteQItV8 nUq2wEnOYNjbZaEjzLkOq6AZUJmNrGbaKyWIGZshrG08VclAjQSTbW5ViT/gOwlLKk/oPor7Gcu2z 6eY9494lEDh8a4g2tXgSl72gGUMa7lW4ALHOiuVrtTX/KOCQekTMTTyZ4voPQUaHFmXQZz/NVPhOK NvDOWtGxRU9iTJAu4sxAfS2NyBjdbZ+6Xf2sXjg3p+SZQwHgsOJ/yZnFd28uGxxfa5c4Ge4oNmsPm 2TPlOpgI3XqFMsiM73Qkkg==; 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 1ozfjc-0007Yw-4H; Mon, 28 Nov 2022 10:07:52 -0500 Date: Mon, 28 Nov 2022 17:08:22 +0200 Message-Id: <837czfnml5.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <838rjvnmqk.fsf@gnu.org> (message from Eli Zaretskii on Mon, 28 Nov 2022 17:05:07 +0200) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> <838rjvnmqk.fsf@gnu.org> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > Cc: casouri@gmail.com, 59617@debbugs.gnu.org > Date: Mon, 28 Nov 2022 17:05:07 +0200 > From: Eli Zaretskii > > > From: Theodor Thornhill > > Cc: 59617@debbugs.gnu.org, casouri@gmail.com > > Date: Mon, 28 Nov 2022 16:00:58 +0100 > > > > Hmm, I really cannot seem to find any very specific, recognized styles > > for any of the languages. I think either we go with this like it is > > now, or wait until later altogether. My reasoning was that _if_ some > > people have very specific needs we can accomodate that, but IMO it's a > > little too time-consuming looking all around after styles that noone > > uses :-) I'd rather focus on improving what we have. > > > > Should we just close this? > > Feel free. But please say in the doc string that the custom function is called with no arguments. From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Nov 2022 16:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166965304022995 (code B ref 59617); Mon, 28 Nov 2022 16:31:01 +0000 Received: (at 59617) by debbugs.gnu.org; 28 Nov 2022 16:30:40 +0000 Received: from localhost ([127.0.0.1]:49556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozh1j-0005yp-NL for submit@debbugs.gnu.org; Mon, 28 Nov 2022 11:30:40 -0500 Received: from out-96.mta0.migadu.com ([91.218.175.96]:36679) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozh1g-0005yj-6h for 59617@debbugs.gnu.org; Mon, 28 Nov 2022 11:30:37 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669653034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g1cmI2Z3R3baXbFFAlPP+7HU6PGait9BnzhB4cEvKKI=; b=Zl2jmeWjAWHZCsjYmJbg9PiywUxgWyQCkyD+4OOkXXi5DDv2pGEEvmukLwDF3dBN0rhg1Y pQd0QcFvUrbdhNxgoOvxHTRRreW+0oVobCL5/BokwuAufZ8Z+TQU6Xs9yeBeEnGtI5IbRo jqwx66ZcL+LhVGin7qx14DDF98fYkRP4flhCpip4qNPAFAtaUf0ofkMWsfrIFV4ebnK4gw VCoy5cTvma9BZS3hXVghh25xgA8OeQOBNaQwkniQjUBPzmlJlbvYfPbu8UhpXOPz8GR8rY BKVXGZGnLPH0O7K1N6t9UYKutNgU4RYow/Al2BS+Yv4FU9HGciLSXMairLvvog== From: Theodor Thornhill In-Reply-To: <837czfnml5.fsf@gnu.org> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> <838rjvnmqk.fsf@gnu.org> <837czfnml5.fsf@gnu.org> Date: Mon, 28 Nov 2022 17:30:27 +0100 Message-ID: <87tu2jrqho.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Cc: casouri@gmail.com, 59617@debbugs.gnu.org >> Date: Mon, 28 Nov 2022 17:05:07 +0200 >> From: Eli Zaretskii >> >> > From: Theodor Thornhill >> > Cc: 59617@debbugs.gnu.org, casouri@gmail.com >> > Date: Mon, 28 Nov 2022 16:00:58 +0100 >> > >> > Hmm, I really cannot seem to find any very specific, recognized styles >> > for any of the languages. I think either we go with this like it is >> > now, or wait until later altogether. My reasoning was that _if_ some >> > people have very specific needs we can accomodate that, but IMO it's a >> > little too time-consuming looking all around after styles that noone >> > uses :-) I'd rather focus on improving what we have. >> > >> > Should we just close this? >> >> Feel free. > > But please say in the doc string that the custom function is called with no > arguments. Ok, added in this patch. Thanks! Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From 7480e472ffd4ec2cd22df2825f5b2c07b2fefc64 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. (json-ts-mode--indent-rules): Rename from 'json-ts--indent-rules' * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. (Bug#59617) --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 23 +++++++++++++++++++++-- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 122 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index a79dabcd31..b72c17a8bd 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 6712fcc57e..59fc71356f 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -626,6 +626,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -898,7 +916,8 @@ csharp-ts-mode (seq (+ "*") "/"))))) ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index cf2482bb6e..9806b23d34 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -43,6 +43,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -309,7 +327,8 @@ java-ts-mode (seq (+ "*") "/"))))) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index ad1fe62d42..1f25412796 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3865,7 +3883,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..0a6debf788 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -64,7 +82,7 @@ json-ts-mode--syntax-table "Syntax table for `json-ts-mode'.") -(defvar json-ts--indent-rules +(defvar json-ts-mode--indent-rules `((json ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index bf483a31d3..5790959e3f 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -307,7 +325,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 734252ee66..5ac456b02f 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1804,7 +1822,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Nov 2022 06:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166970231615815 (code B ref 59617); Tue, 29 Nov 2022 06:12:02 +0000 Received: (at 59617) by debbugs.gnu.org; 29 Nov 2022 06:11:56 +0000 Received: from localhost ([127.0.0.1]:53385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oztqV-000471-JC for submit@debbugs.gnu.org; Tue, 29 Nov 2022 01:11:56 -0500 Received: from out2.migadu.com ([188.165.223.204]:36690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oztqT-00046u-MJ for 59617@debbugs.gnu.org; Tue, 29 Nov 2022 01:11:54 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669702313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RqC2EaqaTDxDu1LL7KOcMWs0UK/+llep+TM2fiU0epI=; b=rgZhlzPJ2KSlYkfiAKX5tPtRz+InqsrXGjhxyR0TlaYts+48kwRv6gXNt93pVIldEW11Ng U27svkgLScyCZbEjadwRuUePzrCqzGCYvpMP3y0D9MEG//4sqwNzA2DvADNQTtoaN5EVgH bVrdA4UxB6m3PAohlWGEU2CHeIHBUd8xs/VRE9uUr3/wXOkUxtFx6QQstgc/jjglXwgzKn DuWGFLr09R0fhn4tj5EJv4Ta3KnMiNuiB85YiIZ4SiiaRETTicrtWFPEUCS4GoqbKBu236 H92GmB2iBhxSRrosxoPBMcGR0TnH60Pila79tLeXhRkoly2UON7DnYbLhqhXdg== From: Theodor Thornhill In-Reply-To: <87tu2jrqho.fsf@thornhill.no> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> <838rjvnmqk.fsf@gnu.org> <837czfnml5.fsf@gnu.org> <87tu2jrqho.fsf@thornhill.no> Date: Tue, 29 Nov 2022 07:11:45 +0100 Message-ID: <87pmd6jnmm.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) 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: -1.0 (-) --=-=-= Content-Type: text/plain Rebased on emacs-29. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From 7690dbbd4359e4bc7dad3272cc4190af0692961a Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. (json-ts-mode--indent-rules): Rename from 'json-ts--indent-rules' * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. (Bug#59617) --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 23 +++++++++++++++++++++-- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 122 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index a79dabcd31..b72c17a8bd 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 3da3079f08..426ac141a0 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -626,6 +626,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -908,7 +926,8 @@ csharp-ts-mode (seq (+ "*") "/"))))) ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index cf2482bb6e..9806b23d34 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -43,6 +43,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -309,7 +327,8 @@ java-ts-mode (seq (+ "*") "/"))))) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index ad1fe62d42..1f25412796 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3865,7 +3883,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..0a6debf788 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -64,7 +82,7 @@ json-ts-mode--syntax-table "Syntax table for `json-ts-mode'.") -(defvar json-ts--indent-rules +(defvar json-ts-mode--indent-rules `((json ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 6c926a4e3e..cf4e8512c0 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -313,7 +331,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index b82886e397..aaf1c91443 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function takes no arguments +and is expected to return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1832,7 +1850,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Nov 2022 15:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166973517113674 (code B ref 59617); Tue, 29 Nov 2022 15:20:02 +0000 Received: (at 59617) by debbugs.gnu.org; 29 Nov 2022 15:19:31 +0000 Received: from localhost ([127.0.0.1]:54706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02OQ-0003YU-SD for submit@debbugs.gnu.org; Tue, 29 Nov 2022 10:19:31 -0500 Received: from out-242.mta0.migadu.com ([91.218.175.242]:12400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02OO-0003YO-DI for 59617@debbugs.gnu.org; Tue, 29 Nov 2022 10:19:29 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669735167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wKwmYetHNaAUH5AEPHyipvLvpMIb/tPw8fwyvw0m/r8=; b=mecik55JiUZ2jrzVP915beRMXStrKmxPHdBYfPgVhWS3zJ3qAWnWz3+dbTb8pBIWXL3B4g S/adR356MW5AJVhbnYbLS8+b0f9BywbpAOqaagVv/fY9IBSQHSKE5JkjkVrYYJj1HV9q/x QqQ4UssPtOCMQpn6c4y32O+0+BeRZOu6tSycC30YTN6WNRk7VWXhC8le5Ei6e659cXAvPZ bUgnpwFxqpM9cFMRc0nknjsZRYD30Cmo7K1l2WFfxuQbtMHtjYCYxkz2JqKi0xj92Xmphf +JQFJQYtEx3S/ctv8tEUTeCQNvIbBXUj38Wv31tvHsdWOEqUBAFdAxakhuEhhg== From: Theodor Thornhill In-Reply-To: <87pmd6jnmm.fsf@thornhill.no> References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> <838rjvnmqk.fsf@gnu.org> <837czfnml5.fsf@gnu.org> <87tu2jrqho.fsf@thornhill.no> <87pmd6jnmm.fsf@thornhill.no> Date: Tue, 29 Nov 2022 16:19:26 +0100 Message-ID: <87a649aiv5.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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: -1.0 (-) Theodor Thornhill writes: > Rebased on emacs-29. > Is this good to go or should I change something here? Theo From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Nov 2022 15:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill Cc: casouri@gmail.com, 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166973663914730 (code B ref 59617); Tue, 29 Nov 2022 15:44:01 +0000 Received: (at 59617) by debbugs.gnu.org; 29 Nov 2022 15:43:59 +0000 Received: from localhost ([127.0.0.1]:54827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02m6-0003pW-Pv for submit@debbugs.gnu.org; Tue, 29 Nov 2022 10:43:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p02m4-0003pN-Bz for 59617@debbugs.gnu.org; Tue, 29 Nov 2022 10:43:57 -0500 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 1p02ly-0003hd-5s; Tue, 29 Nov 2022 10:43:50 -0500 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=2iReqJju/SVobB9YB82BwRr7oVsb4U/We9EzD7Mz/w4=; b=HjQ6q7bFkl27 Kd/Y3RqvQkXBYiZfEUUxcV/5++PEfBfzy9jYjgwm40ELaTz5aKg+NujhCaVzAbHXp+3pdxnExChsL y8JV9kr5RpIcRyaRc/ORCex+3Q8Qp9Wl3SzhhilOdNRk6ERxyyPBK9aAsYirHbe3FTlIG93Ro6GFi y0RDLSYA3hx52dV01E7UL58MVQSqQHknbkT4vXd94tphyRBo5CFWkJN4Y5yvbvsqLLXs7pks4qR9F DLqoug9YTEzgTMMl0JDVUxhJ1W0kJRlPufHBf6jnj+LCLyxcGiPhhKmx2mOPrPMuCXDOt6AC/oiu7 JRhFp874ZaRInS9/zGknqQ==; 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 1p02lx-0008Pp-Kg; Tue, 29 Nov 2022 10:43:49 -0500 Date: Tue, 29 Nov 2022 17:44:21 +0200 Message-Id: <83y1rtlq96.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87a649aiv5.fsf@thornhill.no> (message from Theodor Thornhill on Tue, 29 Nov 2022 16:19:26 +0100) References: <87r0xp4k4p.fsf@thornhill.no> <87r0xo0xz0.fsf@thornhill.no> <87tu2jo98h.fsf@thornhill.no> <83v8mznu3b.fsf@gnu.org> <87y1rv9ruh.fsf@thornhill.no> <83k03fnrcm.fsf@gnu.org> <87v8mz9owq.fsf@thornhill.no> <83edtnnqgr.fsf@gnu.org> <874jujktsl.fsf@thornhill.no> <838rjvnmqk.fsf@gnu.org> <837czfnml5.fsf@gnu.org> <87tu2jrqho.fsf@thornhill.no> <87pmd6jnmm.fsf@thornhill.no> <87a649aiv5.fsf@thornhill.no> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > From: Theodor Thornhill > Cc: casouri@gmail.com, 59617@debbugs.gnu.org > Date: Tue, 29 Nov 2022 16:19:26 +0100 > > Theodor Thornhill writes: > > > Rebased on emacs-29. > > > > Is this good to go or should I change something here? Good to go from my POV, but I wanted also to hear from Yuan. Thanks. From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes References: <87r0xp4k4p.fsf@thornhill.no> In-Reply-To: <87r0xp4k4p.fsf@thornhill.no> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Nov 2022 21:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Theodor Thornhill , 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.16698446928198 (code B ref 59617); Wed, 30 Nov 2022 21:45:02 +0000 Received: (at 59617) by debbugs.gnu.org; 30 Nov 2022 21:44:52 +0000 Received: from localhost ([127.0.0.1]:35284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0Ust-00028A-KL for submit@debbugs.gnu.org; Wed, 30 Nov 2022 16:44:51 -0500 Received: from mail-pg1-f169.google.com ([209.85.215.169]:37428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0Uso-000284-U8 for 59617@debbugs.gnu.org; Wed, 30 Nov 2022 16:44:50 -0500 Received: by mail-pg1-f169.google.com with SMTP id v3so17301147pgh.4 for <59617@debbugs.gnu.org>; Wed, 30 Nov 2022 13:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=AY7A2r7SnF5hfdzf0lwa+tgHBYT51sTMfKvD0TbziSk=; b=QJagwIP/+iqMZPSMwRDcR01gOfHwfkPV72qjfYhRywlyPbJqipV9+NXsCHOp3/cjkM iQeNo7goiqpfwUs+7dYv7Oy9LpSIOJjHn2MKeMLhJRqZarexmqsAw8YRyO52KgHfy6Zy cWTgdE1bzFy76/gJJFdYPYKcrKWeXm+7DCdXdEO0atNoEnNnOlhfVGNjj4YOx0APeL3Q 7IrgjNvEbNCknkB0VBZ+gA8S7Z+sllrowRvIeJ6DwllOBuW4/8nBBzF9yd7/xR0OsYat FKzK3nYJNJ60al7ZILwc0Tm6sZ0Bm2wepo0S5IfPIMdGD3QkTCXIZfjgvSUBJMkATq6M aMSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AY7A2r7SnF5hfdzf0lwa+tgHBYT51sTMfKvD0TbziSk=; b=6ZHG+DvueScQY4wJj0YBD3BQikJyAvSB3/rm3StsyaYz8Xan9rUzNlv7EFdMiFubZ6 rWwb/8Xl9zSN8ah2i/wfFQ9hZ3lOJ3KVk27yK8+ntbko1wUvXwzHYi6B7UDxUc4gLXRn RfFTCegeEasLFFIgLCmmqr3JK8ChwrlA4iubxZuxkblrSKvM/+Ufv3yUyt+a1VXzSB6r y8yM4bcCOKPBvg+ZJ34S8mJbLOprNnIBQCK0iDT5Cy9mj3NS2h5aC1WZdtiLTBIY3UYx xwIYosPoZfWLTlK1XE8sUAoq2ZElDKjP8TCSAGiRvx9Rn/xVclCSfy9OQPIg97vqCJao Ktaw== X-Gm-Message-State: ANoB5pkd0Ka+Dqq96qaymDu1JrMbBFrXqGuLuFPZK5jn0FALoDW8UkS7 oLffr5Y3toL4oqXgIgLLS7w= X-Google-Smtp-Source: AA0mqf6/mgTS1tlT3Nxi4/Yin/H1SpsavORdF5ZIcOBtnok+I1Fhu8Q9Oh1y8MBzr0UUFTCZow5xog== X-Received: by 2002:a65:6a01:0:b0:477:693f:b8d3 with SMTP id m1-20020a656a01000000b00477693fb8d3mr38285872pgu.333.1669844681026; Wed, 30 Nov 2022 13:44:41 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id i9-20020a17090a058900b00210039560c0sm3508223pji.49.2022.11.30.13.44.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 13:44:40 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Message-Id: Date: Wed, 30 Nov 2022 13:44:39 -0800 X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) 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: -1.0 (-) Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: casouri@gmail.com, 59617@debbugs.gnu.org >> Date: Tue, 29 Nov 2022 16:19:26 +0100 >>=20 >> Theodor Thornhill writes: >>=20 >> > Rebased on emacs-29. >> > >>=20 >> Is this good to go or should I change something here? > > Good to go from my POV, but I wanted also to hear from Yuan. > > Thanks. Hey sorry, I was busy with some other things. I=E2=80=99ve looked at the = patch, it seems adding a hook that sets treesit-simple-indent-rules would have the same effect, no? (Ie, user already can set a custom indent style) Like instead of (defvar my-personal-csharp-mode-indent-rules (...)) (setq csharp-ts-mode-indent-style (lambda () my-personal-csharp-mode-indent-rules)) you can just do (defvar my-personal-csharp-mode-indent-rules (...)) (add-hook 'csharp-mode-hook (lambda () (setq treesit-simple-indent-rules my-personal-csharp-mode-indent-rules))) This way there is no need to define a custom option and a function for each mode. And users can use the same variable treesit-simple-indent-rules, just in different major mode hooks. Yuan From unknown Sun Jul 27 00:27:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Nov 2022 22:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Yuan Fu , Eli Zaretskii Cc: 59617@debbugs.gnu.org Received: via spool by 59617-submit@debbugs.gnu.org id=B59617.166984709918199 (code B ref 59617); Wed, 30 Nov 2022 22:25:02 +0000 Received: (at 59617) by debbugs.gnu.org; 30 Nov 2022 22:24:59 +0000 Received: from localhost ([127.0.0.1]:35466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0VVi-0004jT-QW for submit@debbugs.gnu.org; Wed, 30 Nov 2022 17:24:59 -0500 Received: from out2.migadu.com ([188.165.223.204]:47691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0VVd-0004jN-7W for 59617@debbugs.gnu.org; Wed, 30 Nov 2022 17:24:57 -0500 Date: Wed, 30 Nov 2022 23:24:18 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669847091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D7hzlwyOuWSpenXxgCN1gXdyEcxOLw8GR/gNO8oJL4o=; b=TOHg+TzMu7MIKOVAw/WRR6Wj3dq6PchjJydUa/ipC8dUEEvPVImo0v8ED1s8DG2z8jbAsj rBFH6MO7uvGVdgGiogpe2Glj7NKOyq4xZPe3sbtApirqRvcs4gdwo4+zxg2BepNCwH9HRi M0FsI7PR6GkdykGbdROPRIZBp18fkod7ViDEcG3D1du2p5U1cKtny2Bwp7tFWKRCpxfIY2 jESF8IlY7fpOfDCje6849mBVx99Zqa8xo+xhP72ZBHR1yH12PPZTte1ilyIyJT4C9Lzuz9 e+Z22vuF24m1QQ19c2GNkt1CCLTihfBNemP2Z0SPnfNbnkG3doqHiU+TSRKpUA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill In-Reply-To: References: Message-ID: <9B669C4C-9CC7-4706-A801-8049E4141C3A@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) 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: -1.0 (-) On 30 November 2022 22:44:39 CET, Yuan Fu wrote: > >Eli Zaretskii writes: > >>> From: Theodor Thornhill >>> Cc: casouri@gmail=2Ecom, 59617@debbugs=2Egnu=2Eorg >>> Date: Tue, 29 Nov 2022 16:19:26 +0100 >>>=20 >>> Theodor Thornhill writes: >>>=20 >>> > Rebased on emacs-29=2E >>> > >>>=20 >>> Is this good to go or should I change something here? >> >> Good to go from my POV, but I wanted also to hear from Yuan=2E >> >> Thanks=2E > >Hey sorry, I was busy with some other things=2E I=E2=80=99ve looked at th= e patch, >it seems adding a hook that sets treesit-simple-indent-rules would have >the same effect, no? (Ie, user already can set a custom indent style) >Like instead of > >(defvar my-personal-csharp-mode-indent-rules (=2E=2E=2E)) > >(setq csharp-ts-mode-indent-style > (lambda () my-personal-csharp-mode-indent-rules)) > >you can just do > >(defvar my-personal-csharp-mode-indent-rules (=2E=2E=2E)) > >(add-hook 'csharp-mode-hook > (lambda () > (setq treesit-simple-indent-rules > my-personal-csharp-mode-indent-rules))) > >This way there is no need to define a custom option and a function for >each mode=2E And users can use the same variable >treesit-simple-indent-rules, just in different major mode hooks=2E > >Yuan Hmm I think you're right, and I think I agree :) Theo From unknown Sun Jul 27 00:27:08 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Theodor Thornhill Subject: bug#59617: closed (Re: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes) Message-ID: References: <87r0xp4k4p.fsf@thornhill.no> X-Gnu-PR-Message: they-closed 59617 X-Gnu-PR-Package: emacs Reply-To: 59617@debbugs.gnu.org Date: Fri, 02 Dec 2022 05:27:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1669958821-29521-1" This is a multi-part message in MIME format... ------------=_1669958821-29521-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #59617: 29.0.50; Add indent styles to all tree-sitter modes which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59617@debbugs.gnu.org. --=20 59617: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D59617 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1669958821-29521-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 59617-done) by debbugs.gnu.org; 2 Dec 2022 05:26:55 +0000 Received: from localhost ([127.0.0.1]:44215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yZa-0007fx-GK for submit@debbugs.gnu.org; Fri, 02 Dec 2022 00:26:54 -0500 Received: from mail-pj1-f52.google.com ([209.85.216.52]:46068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yZU-0007fo-Qz for 59617-done@debbugs.gnu.org; Fri, 02 Dec 2022 00:26:52 -0500 Received: by mail-pj1-f52.google.com with SMTP id o5-20020a17090a678500b00218cd5a21c9so4159967pjj.4 for <59617-done@debbugs.gnu.org>; Thu, 01 Dec 2022 21:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=QkjS9LZMt+6iaasc8SmG+PsHz0v6tUaba8hQkCtRjtw=; b=fOPZe56JJjKVr4zaUOcX49Bjx4FYHwAamBmNBCiOZmnaqSLoVZbqnS95zB1t45xk6N PljURliuy7m5Zc47VliT9B5w5eCXtGZJYxtp2YKZa11VyasqXl7ATA6mv9oUnyN79GbC vInDOrDaWE5rlLL2ITjX2FuJ7iIaWiZJJ8PHA+S7rYin82az/98c03K03b1edkcoofVu 1gUH/o2xbTOwTOomrEoR8Zhgt/Fj+l6QbdTZAH6IXlKWZqb72VU3jD/wHf+b7Dzpht16 dBbqXDpS4PYoZ1ReEi+qjiM8KkE1Q1H/4PbEKVgp8BMA1KmHdE3RB+e6DgPC+NmDt1qf H02w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QkjS9LZMt+6iaasc8SmG+PsHz0v6tUaba8hQkCtRjtw=; b=ys0WbKM0TcKBz/E8ud1tdPDqn+O+PakUdcZ23aww1gdlqdpLrDvc4+QBda4w1PD3A6 eg8RByL89D2KZD2DMJ/mh23Eel9N0/p1dQWxw6vGXh3pG9VAN+ACKLVwruD9aXIEgTpb LPEOcSDuceMV7Bhb1lrjmj7gyXN3/rIlE2CWFe/+gkRdp/XxcADZSyyb5iQ1nkEcdz8q 2r1zHwoNElJGaGAacDdfgHFHPkbCUgo60UjwEJISWxr53+IMV4mHQYZqUO/5YNPsrUT0 F6ffFHyySia5ehKFc2zoldLtAtrwkFeXGR/wUJEJe+xCAjqIwTESbNp78q7UxZQoLLgF YZtA== X-Gm-Message-State: ANoB5pnZnKo2mvEPbOJZVc8vN5EwFJx+5HBFVaYN2X9usWoBcT3QKUJH OWLowCd1OInl504nRcs6qyIL6I+v/cw1EA== X-Google-Smtp-Source: AA0mqf6bmFXF3e8Hl1A03/cebfulKju/+F76HQutoWQaj7tVEAFW3NnHEbtsGuh0ZFlrpYSuS2jckg== X-Received: by 2002:a17:90b:e18:b0:219:31ed:22be with SMTP id ge24-20020a17090b0e1800b0021931ed22bemr26246115pjb.75.1669958803290; Thu, 01 Dec 2022 21:26:43 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id w80-20020a627b53000000b0056d73ef41fdsm4155032pfc.75.2022.12.01.21.26.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2022 21:26:41 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59617: 29.0.50; Add indent styles to all tree-sitter modes Message-Id: Date: Thu, 1 Dec 2022 21:26:40 -0800 To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59617-done Cc: 59617-done@debbugs.gnu.org, Eli Zaretskii 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: -1.0 (-) Theodor Thornhill writes: > On 30 November 2022 22:44:39 CET, Yuan Fu wrote: >> >>Eli Zaretskii writes: >> >>>> From: Theodor Thornhill >>>> Cc: casouri@gmail.com, 59617@debbugs.gnu.org >>>> Date: Tue, 29 Nov 2022 16:19:26 +0100 >>>>=20 >>>> Theodor Thornhill writes: >>>>=20 >>>> > Rebased on emacs-29. >>>> > >>>>=20 >>>> Is this good to go or should I change something here? >>> >>> Good to go from my POV, but I wanted also to hear from Yuan. >>> >>> Thanks. >> >>Hey sorry, I was busy with some other things. I=E2=80=99ve looked at = the patch, >>it seems adding a hook that sets treesit-simple-indent-rules would = have >>the same effect, no? (Ie, user already can set a custom indent style) >>Like instead of >> >>(defvar my-personal-csharp-mode-indent-rules (...)) >> >>(setq csharp-ts-mode-indent-style >> (lambda () my-personal-csharp-mode-indent-rules)) >> >>you can just do >> >>(defvar my-personal-csharp-mode-indent-rules (...)) >> >>(add-hook 'csharp-mode-hook >> (lambda () >> (setq treesit-simple-indent-rules >> my-personal-csharp-mode-indent-rules))) >> >>This way there is no need to define a custom option and a function for >>each mode. And users can use the same variable >>treesit-simple-indent-rules, just in different major mode hooks. >> >>Yuan > > Hmm I think you're right, and I think I agree :) > > Theo Cool :-) I=E2=80=99m closing this then. Yuan ------------=_1669958821-29521-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 Nov 2022 19:00:00 +0000 Received: from localhost ([127.0.0.1]:41434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0PA-0003lj-47 for submit@debbugs.gnu.org; Sat, 26 Nov 2022 14:00:00 -0500 Received: from lists.gnu.org ([209.51.188.17]:45108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0P4-0003lb-ND for submit@debbugs.gnu.org; Sat, 26 Nov 2022 13:59:58 -0500 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 1oz0P4-00059g-5E for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 13:59:54 -0500 Received: from out-218.mta0.migadu.com ([2001:41d0:1004:224b::da]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oz0P0-0001OW-PA for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 13:59:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669489182; 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=hHqJtJ5OUR8kaaSdhXfT+EXWKhoS56BfvXytuUkztzw=; b=dAKjnYkcM/1WulJeDOt++zr0abpsISLPX05VkAV0ID9k3YfKiDWKryeh3meCqkM1q9rEC3 r6TAJzkqogA0Pn3k3GdKBV2zmdJuajuNW+VOrWooz9NSCQOJhyPrjQ9HwVxTc31UNn/knI fZvS5PQHfXEX6nPU5LCQbjnTQRSxqUt0CHA8Z8niKeg3cOMgJTpVlbXkezmtlWt17EiLJo TNxpyeqYlZ3+b7ocCrD4/kCwKKxtZ3UUZ5V6aMmZ8zF2NMbWDKCu0R7cSclLHCmfglrCBG dikK8bbG+bwvHs/OAOyWyF3eLfQMkjfTPgS9VNT+bVKTC8V34hMbGuAWmZwmbg== From: Theodor Thornhill To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Add indent styles to all tree-sitter modes X-Debbugs-CC: casouri@gmail.com Date: Sat, 26 Nov 2022 19:59:34 +0100 Message-ID: <87r0xp4k4p.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::da; envelope-from=theo@thornhill.no; helo=out-218.mta0.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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: -2.4 (--) --=-=-= Content-Type: text/plain Hi Yuan and others! I've added in the ability for users to set their own indentation style should that be needed. I just followed what I already did in c-ts-mode and c++-ts-mode, so I believe this shouldn't be too controversial :-) Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-indent-styles-to-all-tree-sitter-modes.patch >From 5f5695916b71af4f9e778f4bd5c51edb2c85067e Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 26 Nov 2022 19:54:47 +0100 Subject: [PATCH] Add indent styles to all tree-sitter modes Enable users to provide their own function to control the indentation style. Even though we don't supply any extra styles for indentation, this should give the users an escape hatch should the provided style not suit their needs. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-style): Fix typo. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-indent-style) (csharp-ts-mode--set-indent-style, csharp-ts-mode): New defcustom and helper. * lisp/progmodes/java-ts-mode.el (java-ts-mode-indent-style) (java-ts-mode--set-indent-style, java-ts-mode): New defcustom and helper. * lisp/progmodes/js.el (js-ts-mode-indent-style) (js--treesit-set-indent-style, js-ts-mode): New defcustom and helper. * lisp/progmodes/json-ts-mode.el (json-ts-mode-indent-style) (json-ts-mode--set-indent-style, json-ts-mode): Enable custom indent style. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-indent-style) (typescript-ts-mode--set-indent-style, typescript-ts-mode): Enable custom indent style. * lisp/progmodes/css.el (css-ts-mode-indent-style) (css--treesit-set-indent-style, css-ts-mode): New defcustom and helper. --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/csharp-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/js.el | 21 ++++++++++++++++++++- lisp/progmodes/json-ts-mode.el | 21 ++++++++++++++++++++- lisp/progmodes/typescript-ts-mode.el | 21 ++++++++++++++++++++- lisp/textmodes/css-mode.el | 21 ++++++++++++++++++++- 7 files changed, 121 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fc35d9aedd..c384182772 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -52,7 +52,7 @@ c-ts-mode-indent-style The selected style could be one of GNU, K&R, LINUX or BSD. If one of the supplied styles doesn't suffice a function could be -set instead. This function is expected return a list that +set instead. This function is expected to return a list that follows the form of `treesit-simple-indent-rules'." :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index a544a4b5cb..a6373b5826 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -696,6 +696,24 @@ csharp-ts-mode-indent-offset :safe 'integerp :group 'csharp) +(defcustom csharp-ts-mode-indent-style 'csharp-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'csharp-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'csharp) + +(defun csharp-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp csharp-ts-mode-indent-style) + (funcall csharp-ts-mode-indent-style) + csharp-ts-mode--indent-rules)) + (defvar csharp-ts-mode--indent-rules `((c-sharp ((parent-is "compilation_unit") parent-bol 0) @@ -962,7 +980,8 @@ csharp-ts-mode (setq-local comment-end "") ;; Indent. - (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (csharp-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index ee2934f53c..29de2ccb28 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -42,6 +42,24 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-indent-style 'java-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'java-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'java) + +(defun java-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp java-ts-mode-indent-style) + (funcall java-ts-mode-indent-style) + java-ts-mode--indent-rules)) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -305,7 +323,8 @@ java-ts-mode (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Indent. - (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (java-ts-mode--set-indent-style)) ;; Electric (setq-local electric-indent-chars diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index da05b7b364..9535d4986f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3457,6 +3457,24 @@ js--treesit-indent-rules ((node-is "/") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level))))) +(defcustom js-ts-mode-indent-style 'js--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'js--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'javascript) + +(defun js--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp js-ts-mode-indent-style) + (funcall js-ts-mode-indent-style) + js--treesit-indent-rules)) + (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" @@ -3862,7 +3880,8 @@ js-ts-mode ;; Tree-sitter setup. (treesit-parser-create 'javascript) ;; Indent. - (setq-local treesit-simple-indent-rules js--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (js--treesit-set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..4ee2cad9da 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -44,6 +44,24 @@ json-ts-mode-indent-offset :safe 'integerp :group 'json) +(defcustom json-ts-mode-indent-style 'json-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'json-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'json) + +(defun json-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp json-ts-mode-indent-style) + (funcall json-ts-mode-indent-style) + json-ts-mode--indent-rules)) + (defvar json-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -147,7 +165,8 @@ json-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules json-ts--indent-rules) + (setq-local treesit-simple-indent-rules + (json-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 763686bf66..106b8363f0 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -37,6 +37,24 @@ typescript-ts-mode-indent-offset :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-indent-style 'typescript-ts-mode--default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'typescript-ts-mode--default-style) + (function :tag "A function for user customized style" ignore)) + :group 'typescript) + +(defun typescript-ts-mode--set-indent-style () + "Helper function to set indentation style." + (if (functionp typescript-ts-mode-indent-style) + (funcall typescript-ts-mode-indent-style) + typescript-ts-mode--indent-rules)) + (defvar typescript-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -308,7 +326,8 @@ typescript-ts-mode (append "{}():;," electric-indent-chars)) ;; Indent. - (setq-local treesit-simple-indent-rules typescript-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules + (typescript-ts-mode--set-indent-style)) ;; Navigation. (setq-local treesit-defun-type-regexp diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 734252ee66..eaf3fec939 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1343,6 +1343,24 @@ css--treesit-indent-rules ((match nil "declaration" nil 3) (nth-sibling 2) 0))) "Tree-sitter indentation rules for `css-ts-mode'.") +(defcustom css-ts-mode-indent-style 'css--treesit-default-style + "Style used for indentation. + +The selected style could either be the default style, or a +function could be set instead. This function is expected to +return a list that follows the form of +`treesit-simple-indent-rules'." + :version "29.1" + :type '(choice (symbol :tag "Default" 'css--treesit-default-style) + (function :tag "A function for user customized style" ignore)) + :group 'css) + +(defun css--treesit-set-indent-style () + "Helper function to set indentation style." + (if (functionp css-ts-mode-indent-style) + (funcall css-ts-mode-indent-style) + css--treesit-indent-rules)) + (defvar css--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1804,7 +1822,8 @@ css-ts-mode ;; Tree-sitter specific setup. (treesit-parser-create 'css) - (setq-local treesit-simple-indent-rules css--treesit-indent-rules) + (setq-local treesit-simple-indent-rules + (css--treesit-set-indent-style)) (setq-local treesit-defun-type-regexp "rule_set") (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list -- 2.34.1 --=-=-=-- ------------=_1669958821-29521-1--