diff options
| author | Yuan Fu | 2023-04-12 00:00:26 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-04-12 00:02:21 -0700 |
| commit | c146bd893dfbc8a4c92f9d1f33def8f29e7ece1f (patch) | |
| tree | fb7e34c2d9ce1fb54f11036b0bbae5f3f620612f | |
| parent | 1a5a03c15abf4043cbbabaa5bcbb874fbef69505 (diff) | |
| download | emacs-c146bd893dfbc8a4c92f9d1f33def8f29e7ece1f.tar.gz emacs-c146bd893dfbc8a4c92f9d1f33def8f29e7ece1f.zip | |
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.
| -rw-r--r-- | lisp/treesit.el | 18 |
1 files 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." | |||
| 3022 | (buffer-local-value 'url-http-response-status buffer) | 3022 | (buffer-local-value 'url-http-response-status buffer) |
| 3023 | 200))))) | 3023 | 200))))) |
| 3024 | 3024 | ||
| 3025 | (defvar treesit--install-language-grammar-out-dir-history nil | ||
| 3026 | "History for OUT-DIR for `treesit-install-language-grammar'.") | ||
| 3027 | |||
| 3025 | ;;;###autoload | 3028 | ;;;###autoload |
| 3026 | (defun treesit-install-language-grammar (lang) | 3029 | (defun treesit-install-language-grammar (lang) |
| 3027 | "Build and install the tree-sitter language grammar library for LANG. | 3030 | "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." | |||
| 3043 | (when-let ((recipe | 3046 | (when-let ((recipe |
| 3044 | (or (assoc lang treesit-language-source-alist) | 3047 | (or (assoc lang treesit-language-source-alist) |
| 3045 | (treesit--install-language-grammar-build-recipe | 3048 | (treesit--install-language-grammar-build-recipe |
| 3046 | lang)))) | 3049 | lang))) |
| 3050 | (default-out-dir | ||
| 3051 | (or (car treesit--install-language-grammar-out-dir-history) | ||
| 3052 | (locate-user-emacs-file "tree-sitter"))) | ||
| 3053 | (out-dir | ||
| 3054 | (read-string | ||
| 3055 | (format "Install to (default: %s): " | ||
| 3056 | default-out-dir) | ||
| 3057 | nil | ||
| 3058 | 'treesit--install-language-grammar-out-dir-history | ||
| 3059 | default-out-dir))) | ||
| 3047 | (condition-case err | 3060 | (condition-case err |
| 3048 | (apply #'treesit--install-language-grammar-1 | 3061 | (apply #'treesit--install-language-grammar-1 |
| 3049 | ;; The nil is OUT-DIR. | 3062 | (cons out-dir recipe)) |
| 3050 | (cons nil recipe)) | ||
| 3051 | (error | 3063 | (error |
| 3052 | (display-warning | 3064 | (display-warning |
| 3053 | 'treesit | 3065 | 'treesit |