unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash
@ 2022-11-22  2:54 Brian Leung
  2022-11-23  1:39 ` Yuan Fu
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Leung @ 2022-11-22  2:54 UTC (permalink / raw)
  To: 59471

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-sh-mode-Run-treesit-ready-p-only-when-sh-shell-is-ba.patch --]
[-- Type: text/patch, Size: 1226 bytes --]

From aa8c60cff6f834e18db44587a6e623292b01978e Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@posteo.net>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash
  2022-11-22  2:54 bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash Brian Leung
@ 2022-11-23  1:39 ` Yuan Fu
  0 siblings, 0 replies; 2+ messages in thread
From: Yuan Fu @ 2022-11-23  1:39 UTC (permalink / raw)
  To: leungbk; +Cc: 59471-done


Brian Leung <leungbk@posteo.net> 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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-23  1:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  2:54 bug#59471: [PATCH] sh-mode: Run treesit-ready-p only when sh-shell is 'bash Brian Leung
2022-11-23  1:39 ` Yuan Fu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).