Subject: [PATCH] treesit-install-language-grammar ignores out-dir

From: john muhl <[email-masked]>
Date: Sun, 25 Jun 2023 19:43:18 -0500

Running interactively from emacs -Q:

  M-x t-i-l-g RET bash RET y RET RET RET RET RET ~/tmp/tree-sitter RET

installs to user-emacs-directory/tree-sitter instead of the supplied
directory.

Here’s the tiny change to make it work.

>From 6d38e4c74488d424c2563ff57d963cadf24531f7 Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Sun, 25 Jun 2023 19:38:08 -0500
Subject: [PATCH] Fix treesit-install-language-grammar for custom out-dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

  M-x t-i-l-g RET bash RET y RET RET RET RET RET ~/tmp/tree-sitter RET

installs to user-emacs-directory/tree-sitter instead of the supplied
directory.

Here’s the tiny patch to make it work.
---
 lisp/treesit.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index df13dd9f424..81920834329 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3094,8 +3094,7 @@ treesit-install-language-grammar
     (condition-case err
         (progn
           (apply #'treesit--install-language-grammar-1
-                 ;; The nil is OUT-DIR.
-                 (cons nil recipe))
+                 (cons out-dir recipe))
 
           ;; Check that the installed language grammar is loadable.
           (pcase-let ((`(,available . ,err)
-- 
2.41.0