From c146bd893dfbc8a4c92f9d1f33def8f29e7ece1f Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 12 Apr 2023 00:00:26 -0700 Subject: [PATCH] Prompt target dir in treesit-install-language-grammar (bug#62704) * lisp/treesit.el (treesit--check-repo-url): New variable. (treesit-install-language-grammar): Prompt for target directory. --- lisp/treesit.el | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 9068a111489..3932920a962 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3022,6 +3022,9 @@ See `treesit-language-source-alist' for details." (buffer-local-value 'url-http-response-status buffer) 200))))) +(defvar treesit--install-language-grammar-out-dir-history nil + "History for OUT-DIR for `treesit-install-language-grammar'.") + ;;;###autoload (defun treesit-install-language-grammar (lang) "Build and install the tree-sitter language grammar library for LANG. @@ -3043,11 +3046,20 @@ executable programs, such as the C/C++ compiler and linker." (when-let ((recipe (or (assoc lang treesit-language-source-alist) (treesit--install-language-grammar-build-recipe - lang)))) + lang))) + (default-out-dir + (or (car treesit--install-language-grammar-out-dir-history) + (locate-user-emacs-file "tree-sitter"))) + (out-dir + (read-string + (format "Install to (default: %s): " + default-out-dir) + nil + 'treesit--install-language-grammar-out-dir-history + default-out-dir))) (condition-case err (apply #'treesit--install-language-grammar-1 - ;; The nil is OUT-DIR. - (cons nil recipe)) + (cons out-dir recipe)) (error (display-warning 'treesit -- 2.39.2