From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59931: 30.0.50; [PATCH] Tweak various ts-modes indent and font-lock Date: Fri, 09 Dec 2022 22:38:36 +0100 Message-ID: <87edt8i7fn.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1924"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com To: 59931@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 09 22:39:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3l5U-0000GL-U9 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 09 Dec 2022 22:39:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3l5F-0001Mb-Nf; Fri, 09 Dec 2022 16:39:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3l5D-0001MH-MV for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 16:39:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3l5C-0007rL-Ki for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 16:39:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3l5C-00064P-Av; Fri, 09 Dec 2022 16:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: casouri@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Dec 2022 21:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: casouri@gmail.com Original-Received: via spool by submit@debbugs.gnu.org id=B.167062192423322 (code B ref -1); Fri, 09 Dec 2022 21:39:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Dec 2022 21:38:44 +0000 Original-Received: from localhost ([127.0.0.1]:38670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3l4u-000646-C7 for submit@debbugs.gnu.org; Fri, 09 Dec 2022 16:38:44 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:58412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3l4t-000640-8E for submit@debbugs.gnu.org; Fri, 09 Dec 2022 16:38:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3l4s-0001K1-EN for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 16:38:43 -0500 Original-Received: from out-67.mta0.migadu.com ([91.218.175.67]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3l4p-0007pw-Su for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 16:38:41 -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=1670621917; 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=m1r/FSJdnua5JRaIGJ8jbN9kHax+WK8pvwnN0KgCFW0=; b=woNz5BEwPAMC3X6NesHJoxwHdSLz1B69VROhST+/d3O4iXoorVUtzA5589H0sRv/rMPsib N8r8EMbNEdcr6iJgUtonbOHjts2sdBlmNrQwmpYL7QnM79+dtOvwoCO+IjpVdTDcz2TfTj MKRqDMS6UNwY6whuwE+3QIprnW3kWTUF8VTFtM3UIxS4Uvrf7Ck7u3cFaApcSBPHJ8HJyn scJdSIdoMf0QpP4zF+OcEgyes+Odq5XSwiKLiheYt1yPM3HcySKh5Ehf3Bf5+1Dj/nLjjY mf3X8yn+AXuhZfEmJPMGikrdTdDozX4QL0E7ZpmA+D6pZAMSIGLlc52aSbdvqg== X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.67; envelope-from=theo@thornhill.no; helo=out-67.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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250469 Archived-At: --=-=-= Content-Type: text/plain Hi! Yet some more tweaks - please apply when you find some time :-) Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Tweak-various-ts-modes-indent-and-font-lock.patch >From 88a9cc7d4e8407251976b07c9f03f32eabd3bfb7 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 22:36:03 +0100 Subject: [PATCH] Tweak various ts-modes indent and font-lock * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw string literal font-locking. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block indent rule. (java-ts-mode--font-lock-settings): Add text_block font-locking. * lisp/progmodes/js.el (js-ts-mode): Prefer top-level navigation. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment feature. (json-ts-mode): Use comment feature. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Prefer top-level navigation. --- lisp/progmodes/c-ts-mode.el | 4 +++- lisp/progmodes/java-ts-mode.el | 4 +++- lisp/progmodes/js.el | 1 + lisp/progmodes/json-ts-mode.el | 5 ++++- lisp/progmodes/typescript-ts-mode.el | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 7b41718a74..5976e94512 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -251,7 +251,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 23e166ee4c..d3d658c8b8 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -73,6 +73,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -162,7 +163,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..571938c8f0 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3868,6 +3868,7 @@ js-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. + (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index a118908a00..6fb982e37b 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -74,6 +74,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -161,7 +164,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 243f6146ae..1dec357e4e 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -328,6 +328,8 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-defun-prefer-top-level t) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) -- 2.34.1 --=-=-=--