From unknown Sun Aug 17 00:58:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash Resent-From: Brian Leung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Nov 2022 02:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59471 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 59471@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16690857062872 (code B ref -1); Tue, 22 Nov 2022 02:56:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Nov 2022 02:55:06 +0000 Received: from localhost ([127.0.0.1]:49292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxJRB-0000kG-LU for submit@debbugs.gnu.org; Mon, 21 Nov 2022 21:55:06 -0500 Received: from lists.gnu.org ([209.51.188.17]:36472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxJR8-0000k3-Fq for submit@debbugs.gnu.org; Mon, 21 Nov 2022 21:55:04 -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 1oxJR8-0003k3-8k for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 21:55:02 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxJR6-0001p4-5U for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 21:55:02 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 230FC240101 for ; Tue, 22 Nov 2022 03:54:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1669085698; bh=KEYL9HiVI2Ly9acXDkfpPAYCufES9LpLWg8XhgKV8+I=; h=From:To:Subject:Date:From; b=rr8D1b+ti6vXzgHEC81GPDyXiekdBK3lFip9CjHMMNjN0whQr9yJi6XyjE2xgKtys dmZVfgblvkB1xQkSLGNdwnd0F9qvRucafunVpZiveNsWhBvM6TjUFk/9PO5E+bxd0x Y/YaviTXSbI4BNH3xDGAM1sqal4C1d5ovo8TcN2UxDcpyzh64hFMpiOGyWVH43mTcu WYEkaKYkNn1JJQsfW27CEn41Jnj5lWSfeXigf53sQH0Zz21Ne9LgJzRhcT4VKzkn5z 0mMgfhtGA+VpoImXzd3B5wMWuE8j6lai1pJvntyfpom5AKbNM2lyItwpT729aBxSZN AYVlWZ/9K12RA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NGTPs0FJ9z6tqs for ; Tue, 22 Nov 2022 03:54:56 +0100 (CET) From: Brian Leung Date: Tue, 22 Nov 2022 02:54:55 +0000 Message-ID: <87bkozpukg.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=leungbk@posteo.net; helo=mout02.posteo.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.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: -2.3 (--) --=-=-= Content-Type: text/plain Tags: patch This patch guards the treesit-ready-p check to run only when sh-shell is 'bash, in order to prevent an annoying warning when viewing (say) sh or zsh files. But maybe we also want to allow treesitter when sh-shell is 'sh? In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) Repository revision: aeadba1418d8fc18f17b4ae415cde35e9e272e7a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: NixOS 22.11 (Raccoon) Configured using: 'configure --prefix=/nix/store/yf7bpm9w6nqwil5xfxa9iz22m57wz4l1-emacs-git-20221121.0 --disable-build-details --with-modules --with-x-toolkit=lucid --with-xft --with-cairo --with-native-compilation' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-sh-mode-Run-treesit-ready-p-only-when-sh-shell-is-ba.patch >From aa8c60cff6f834e18db44587a6e623292b01978e Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Mon, 21 Nov 2022 18:52:26 -0800 Subject: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash * lisp/progmodes/sh-script.el (sh-mode): Guard treesit-ready-p check. Without this patch, enabling sh-mode in any non-Bash file results in an annoying warning like: Warning (treesit): Cannot activate tree-sitter, because language definition for zsh is unavailable (not-found): (libtree-sitter-zsh libtree-sitter-zsh.so) No such file or directory --- lisp/progmodes/sh-script.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 54f005508c..0a0617bddd 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1587,7 +1587,8 @@ sh-mode (cond ;; Tree-sitter. If the shell is bash, we can enable tree-sitter. - ((treesit-ready-p sh-shell) + ((and (eq sh-shell 'bash) + (treesit-ready-p sh-shell)) (setq-local treesit-font-lock-feature-list '((comment function string heredoc) (variable keyword command declaration-command) -- 2.38.1 --=-=-=-- From unknown Sun Aug 17 00:58:17 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: Brian Leung Subject: bug#59471: closed (Re: bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash) Message-ID: References: <16C1E196-AD5B-4358-BCFD-BF5995EC21D0@gmail.com> <87bkozpukg.fsf@posteo.net> X-Gnu-PR-Message: they-closed 59471 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 59471@debbugs.gnu.org Date: Wed, 23 Nov 2022 01:40:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1669167602-21744-1" This is a multi-part message in MIME format... ------------=_1669167602-21744-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash 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 59471@debbugs.gnu.org. --=20 59471: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D59471 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1669167602-21744-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 59471-done) by debbugs.gnu.org; 23 Nov 2022 01:39:23 +0000 Received: from localhost ([127.0.0.1]:52965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxejS-0005dn-MB for submit@debbugs.gnu.org; Tue, 22 Nov 2022 20:39:22 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:37777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxejN-0005dW-E1 for 59471-done@debbugs.gnu.org; Tue, 22 Nov 2022 20:39:20 -0500 Received: by mail-pl1-f170.google.com with SMTP id p12so15335501plq.4 for <59471-done@debbugs.gnu.org>; Tue, 22 Nov 2022 17:39:17 -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=c1emr8PoFW4rSKxw1h077mYF4q0mtM1M4AvTdFYRjto=; b=bthChdLW932HDdLaZyrOTLivBGS0QkU8/1dCGhfGJQvzdotaUIAs3EUouSEcTudv9A oyRew7QkZy+/nrqbamfMFGZun5rRfq5pl99KFREko/k5cGogv7M6Xmw31kr8WTvFLMkl VlNyByOqeU6VkBMaYaOZtIjOsE/jJcolmJtaG20om7wFgZM1vnXyFMZiP/Jg+IHNa7RM ugyWIPs/sydQ4zq8P2Q8H74EY9gc6uICjpQqeq7yVIVQ8b10RByf3llIeaNVeyrxI3Zs Od6Ub1JH9EbQESqblEREwHc9RMmsc/3rhbh+ecGwqthh8vE/EJKJDHhPun7bKOtz23Ri Cmcw== 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=c1emr8PoFW4rSKxw1h077mYF4q0mtM1M4AvTdFYRjto=; b=L7kWdZhtFaATvnQkcYg3cPhI8WPcQaSTxjHM9X6/v6vi23PS10gDv6q54Jgyfoe91G WlFRfK6JSLmfzo1v/vgVYfBuqAYh6jUih7n3jF0PQny4NbGqCoMPBwHONFxtDZWK05Vb GPG7ZmESs/05+9EpEmQ9MRB3CkJMalZDYuB5VcmzJI6ucKW2x3tGT0YMuWojSQmGkM3L 60chFUy0tlLAD9ntmF8G7bKZPPzKDPwunSnCClKpoEAx1ACzt1b2nTEyBngSUupjex6e kECtDY/rGCOYrG2UZpBIp3pzuWYcgHBHJ7pC1judKnvx6Riof4zgrJ9zDWpEIY/w2WnR duUQ== X-Gm-Message-State: ANoB5pmaOcrLoXAzH8QZ0RLUoL1faC0soR60U2s2z6yDmcxctaUSJHmV jsRTQ+A5VV8T3M4JBiM/06w= X-Google-Smtp-Source: AA0mqf4rDtsjrRKh1qT6khDIDaeuDVKJ73NwU59lNf7cyqk1kGhivKpEsbBUL5E+tlkRBXCKKvBRUg== X-Received: by 2002:a17:902:b908:b0:189:1ef4:237b with SMTP id bf8-20020a170902b90800b001891ef4237bmr7059266plb.20.1669167551311; Tue, 22 Nov 2022 17:39:11 -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 x3-20020aa79403000000b0056d2317455bsm11324010pfo.7.2022.11.22.17.39.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2022 17:39:10 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash Message-Id: <16C1E196-AD5B-4358-BCFD-BF5995EC21D0@gmail.com> Date: Tue, 22 Nov 2022 17:39:08 -0800 To: leungbk@posteo.net X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59471-done Cc: 59471-done@debbugs.gnu.org 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 (-) Brian Leung writes: > Tags: patch > > This patch guards the treesit-ready-p check to run only when sh-shell is > 'bash, in order to prevent an annoying warning when viewing (say) sh or > zsh files. But maybe we also want to allow treesitter when sh-shell is > 'sh? Oh, thanks! Though I did it a bit differently, by separating tree-sitter-based mode into a independent major mode (sh-ts-mode), which is in line with other tree-sitter-based modes (python-ts-mode, js-ts-mode, etc). How to make bash-ts-mode fallback to sh-mode when it encounters a shell script other than bash is still in discussion. Yuan ------------=_1669167602-21744-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 22 Nov 2022 02:55:06 +0000 Received: from localhost ([127.0.0.1]:49292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxJRB-0000kG-LU for submit@debbugs.gnu.org; Mon, 21 Nov 2022 21:55:06 -0500 Received: from lists.gnu.org ([209.51.188.17]:36472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxJR8-0000k3-Fq for submit@debbugs.gnu.org; Mon, 21 Nov 2022 21:55:04 -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 1oxJR8-0003k3-8k for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 21:55:02 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxJR6-0001p4-5U for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 21:55:02 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 230FC240101 for ; Tue, 22 Nov 2022 03:54:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1669085698; bh=KEYL9HiVI2Ly9acXDkfpPAYCufES9LpLWg8XhgKV8+I=; h=From:To:Subject:Date:From; b=rr8D1b+ti6vXzgHEC81GPDyXiekdBK3lFip9CjHMMNjN0whQr9yJi6XyjE2xgKtys dmZVfgblvkB1xQkSLGNdwnd0F9qvRucafunVpZiveNsWhBvM6TjUFk/9PO5E+bxd0x Y/YaviTXSbI4BNH3xDGAM1sqal4C1d5ovo8TcN2UxDcpyzh64hFMpiOGyWVH43mTcu WYEkaKYkNn1JJQsfW27CEn41Jnj5lWSfeXigf53sQH0Zz21Ne9LgJzRhcT4VKzkn5z 0mMgfhtGA+VpoImXzd3B5wMWuE8j6lai1pJvntyfpom5AKbNM2lyItwpT729aBxSZN AYVlWZ/9K12RA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NGTPs0FJ9z6tqs for ; Tue, 22 Nov 2022 03:54:56 +0100 (CET) From: Brian Leung To: bug-gnu-emacs@gnu.org Subject: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash Date: Tue, 22 Nov 2022 02:54:55 +0000 Message-ID: <87bkozpukg.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=leungbk@posteo.net; helo=mout02.posteo.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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.3 (--) --=-=-= Content-Type: text/plain Tags: patch This patch guards the treesit-ready-p check to run only when sh-shell is 'bash, in order to prevent an annoying warning when viewing (say) sh or zsh files. But maybe we also want to allow treesitter when sh-shell is 'sh? In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) Repository revision: aeadba1418d8fc18f17b4ae415cde35e9e272e7a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: NixOS 22.11 (Raccoon) Configured using: 'configure --prefix=/nix/store/yf7bpm9w6nqwil5xfxa9iz22m57wz4l1-emacs-git-20221121.0 --disable-build-details --with-modules --with-x-toolkit=lucid --with-xft --with-cairo --with-native-compilation' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-sh-mode-Run-treesit-ready-p-only-when-sh-shell-is-ba.patch >From aa8c60cff6f834e18db44587a6e623292b01978e Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Mon, 21 Nov 2022 18:52:26 -0800 Subject: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash * lisp/progmodes/sh-script.el (sh-mode): Guard treesit-ready-p check. Without this patch, enabling sh-mode in any non-Bash file results in an annoying warning like: Warning (treesit): Cannot activate tree-sitter, because language definition for zsh is unavailable (not-found): (libtree-sitter-zsh libtree-sitter-zsh.so) No such file or directory --- lisp/progmodes/sh-script.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 54f005508c..0a0617bddd 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1587,7 +1587,8 @@ sh-mode (cond ;; Tree-sitter. If the shell is bash, we can enable tree-sitter. - ((treesit-ready-p sh-shell) + ((and (eq sh-shell 'bash) + (treesit-ready-p sh-shell)) (setq-local treesit-font-lock-feature-list '((comment function string heredoc) (variable keyword command declaration-command) -- 2.38.1 --=-=-=-- ------------=_1669167602-21744-1--