Subject: bug#66400: [PATCH] Fix 'treesit-query-validate'

From: nvp <[email-masked]>
Date: Sat, 7 Oct 2023 19:55:27 -0700

Tags: patch

Bug: when calling `treesit-query-validate` interactively,
the query is expanded with `treesit-query-expand`, despite being a
string. This produces unreadable output in the error message buffer.

* lisp/treesit.el (treesit-query-validate): Only expand sexp queries
before insertion into query error buffer.

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD
Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS

Configured using:
 'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'
From 2583a37af1aa4b33649b74ce5f148cd8521de5b9 Mon Sep 17 00:00:00 2001
From: nverno <[email-masked]>
Date: Sat, 7 Oct 2023 19:36:44 -0700
Subject: [PATCH] fix: dont expand string query in treesit-query-validate

---
 lisp/treesit.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 402417c6ca9..048cdd4e594 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -2889,7 +2889,7 @@ treesit-query-validate
                   (start (nth 1 data))
                   (inhibit-read-only t))
              (erase-buffer)
-             (insert (treesit-query-expand query))
+             (insert (if (stringp query) query (treesit-query-expand query)))
              (goto-char start)
              (search-forward " " nil t)
              (put-text-property start (point) 'face 'error)
-- 
2.34.1