GNU bug report logs - #61849
29.0.60; Unable to use treesit-install-language-grammar because repo doesn't have parser.c

Previous Next

Package: emacs;

Reported by: Misha Zharov <mishazharov1 <at> gmail.com>

Date: Mon, 27 Feb 2023 19:48:02 UTC

Severity: normal

Found in version 29.0.60

Full log


Message #53 received at 61849 <at> debbugs.gnu.org (full text, mbox):

From: Przemysław Kryger <pkryger <at> gmail.com>
To: 61849 <at> debbugs.gnu.org
Cc: mishazharov1 <at> gmail.com, eliz <at> gnu.org, casouri <at> gmail.com, dgutov <at> yandex.ru
Subject: Re: bug#61849: 29.0.60;
 Unable to use treesit-install-language-grammar because repo doesn't
 have parser.c
Date: Mon, 31 Mar 2025 17:35:40 +0100
Just to add another example.  It seems that LaTeX grammar [1] maintainers made
a decision to remove parser.c in
https://github.com/latex-lsp/tree-sitter-latex/pull/114.

And for posterity, here's a workaround I added to my configuration (sightly
more complicated than it could be for Emacs 30, but it has been written with
Emacs 29 in mind (the latter I still use)):

(defun pk/treesit-generate-parser (&rest args)
  "Try to run \\='tree-sitter generate\\=' if there's no parser.c."
  (when-let* (((equal "parser.c" (car (last args))))
              ((not (file-exists-p (expand-file-name "parser.c"))))
              (tree-sitter (executable-find "tree-sitter"))
              (default-directory (file-name-parent-directory default-directory)))
      (message "Generating parser.c")
      (treesit--call-process-signal
       tree-sitter nil t nil "generate")))

(advice-add 'treesit--call-process-signal
            :before #'pk/treesit-generate-parser)

Perhaps similar concept could be added to the treesit-install-language-grammar:
when user provides tree-sitter executable in LANG recipe and parser.c is not
found then generate it?  Alternatively, always generate parser.c if the
tree-sitter executable is passed in the LANG recipe.  Or make it the decision
whether to generate the parser yet another parameter in the LANG recipe.

Cheers,
PK

[1] https://github.com/latex-lsp/tree-sitter-latex




This bug report was last modified 83 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.