From: Eli Zaretskii Date: Sat, 3 Jun 2023 09:50:49 +0000 (-0400) Subject: Merge from origin/emacs-29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85af52bacd2f68d7064683d01f7ed5a220ca9640;p=emacs.git Merge from origin/emacs-29 3f441525679 Save the tree-sitter grammar recipe when installing a gra... c0c7b947baf Add instructions and test file for VS-15/VS-16 3be33aff963 A better fix for "Fix cancellation of Wdired" 756244c6963 ; * lisp/minibuffer.el (completions-header-format): Doc fix. 5d844e129ad Fix tmm-menubar when 'tmm-completion-prompt' is nil # Conflicts: # lisp/treesit.el --- 85af52bacd2f68d7064683d01f7ed5a220ca9640 diff --cc lisp/treesit.el index cc7ec977851,3ec4fbc5c91..ea701ce1ff7 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@@ -3050,29 -2897,32 +3051,47 @@@ nil, the grammar is installed to the st (interactive (list (intern (completing-read "Language: " - (mapcar #'car treesit-language-source-alist))))) + (mapcar #'car treesit-language-source-alist))) + 'interactive)) (when-let ((recipe (or (assoc lang treesit-language-source-alist) - (treesit--install-language-grammar-build-recipe - lang)))) + (if (eq out-dir 'interactive) + (treesit--install-language-grammar-build-recipe + lang) + (signal 'treesit-error `("Cannot find recipe for this language" ,lang))))) + (default-out-dir + (or (car treesit--install-language-grammar-out-dir-history) + (locate-user-emacs-file "tree-sitter"))) + (out-dir + (if (eq out-dir 'interactive) + (read-string + (format "Install to (default: %s): " + default-out-dir) + nil + 'treesit--install-language-grammar-out-dir-history + default-out-dir) + out-dir))) (condition-case err - (apply #'treesit--install-language-grammar-1 - (cons out-dir recipe)) + (progn + (apply #'treesit--install-language-grammar-1 + ;; The nil is OUT-DIR. + (cons nil recipe)) + + ;; Check that the installed language grammar is loadable. + (pcase-let ((`(,available . ,err) + (treesit-language-available-p lang t))) + (if (not available) + (display-warning + 'treesit + (format "The installed language grammar for %s cannot be located or has problems (%s): %s" + lang (nth 0 err) + (string-join + (mapcar (lambda (x) (format "%s" x)) + (cdr err)) + " "))) + ;; If success, Save the recipe for the current session. + (setf (alist-get lang treesit-language-source-alist) + recipe)))) (error (display-warning 'treesit