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

From: Misha Zharov <[email-masked]>
Date: Sun, 26 Feb 2023 23:34:57 -0800

Add (sql "https://github.com/m-novikov/tree-sitter-sql") to
treesit-language-source-alist. Then use
treesit-install-language-grammar. The following error occurs:

    Error encountered when installing language grammar: (treesit-error
    Command: cc -fPIC -c -I. parser.c Error output: cc1: fatal error:
    parser.c: No such file or directory compilation terminated.)

This error occurs because we need to run a configuration step on the
repo to generate parser.c. I believe this is because we need to either
run `npm run generate` or `tree-sitter generate` to generate the
`src/parser.c` file. It would be nice if we could implement a patch to:

  1. Allow users to specify a configuration step to configure the repo
     before searching for parser.c (like passing a lambda into
     `treesit-language-source-alist`)
  2. Allow users to specify a git hash that should be checked out before
     the configuration step is run. I know currently different branches
     are supported, but not all projects have release branches.
  3. Alternatively this function can be split into 2 function, the first one
      would clone and configure the repository, and well as find the
      required files. The second function would simply compile the required
      files into the shared libraries, and move them to the appropriate location

I can have a go at implementing some of the above if those changes are
welcome. The reason this is important is because it seems like more
repos in the future will move away from providing the autogenerated
files in their repos, so this function might be on borrowed time in its
current incarnation.

In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2023-02-24 built on misha-N552VX
Repository revision: 5cf50d60041c82deccc4b32a8ecdb1a28b6e8f91
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.2 LTS

Configured using:
 'configure --with-json --with-cairo --with-xwidgets
 --prefix=/opt/emacs/ --with-x-toolkit=gtk3 --with-tree-sitter
 --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11
XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_CA.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Help

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  windmove-mode: t
  marginalia-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  override-global-mode: t
  global-company-mode: t
  company-mode: t
  savehist-mode: t
  vertico-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  isearch-fold-quotes-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/misha/.emacs.d/straight/build/transient/transient hides
/opt/emacs/share/emacs/29.0.60/lisp/transient
/home/misha/.emacs.d/straight/build/xref/xref hides
/opt/emacs/share/emacs/29.0.60/lisp/progmodes/xref
/home/misha/.emacs.d/straight/build/project/project hides
/opt/emacs/share/emacs/29.0.60/lisp/progmodes/project
/home/misha/.emacs.d/straight/build/let-alist/let-alist hides
/opt/emacs/share/emacs/29.0.60/lisp/emacs-lisp/let-alist

Features:
(shadow sort mail-extr emacsbug treesit pulse jka-compr consult-xref
cl-print debug backtrace cus-start cus-load misearch multi-isearch
wid-edit lee-ho-fook shortdoc help-fns radix-tree vc-hg vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference face-remap
magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit package browse-url url-handlers magit-repos
magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode
diff git-commit log-edit message sendmail yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log magit-core magit-autorevert autorevert
filenotify magit-margin magit-transient magit-process with-editor shell
magit-mode transient magit-git magit-base magit-section crm
embark-consult consult-vertico consult bookmark embark-org embark ffap
vc-git diff-mode vc-dispatcher mule-util pp comp comp-cstr server
checkdoc lisp-mnt flymake-proc flymake warnings init windmove
rustic-spellcheck rustic-expand rustic-lsp rustic-playground
rustic-rustfix rustic-racer rustic-babel rustic-rustfmt org-element
org-persist org-id org-refile avl-tree org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete
org-list org-footnote org-faces org-entities time-date ob-emacs-lisp
ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys
oc org-loaddefs find-func cal-menu calendar cal-loaddefs org-version
org-compat org-macs format-spec rustic-comint rustic-clippy rustic-doc
xdg f f-shortdoc url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
rustic-popup rustic-cargo rustic-compile spinner compile
text-property-search comint ansi-osc ansi-color s xterm-color
markdown-mode color url-parse auth-source eieio eieio-core
password-cache json map url-vars noutline outline icons
rustic-interaction rustic rust-utils thingatpt rust-mode rx dash
rustic-autoloads xterm-color-autoloads spinner-autoloads
project-autoloads xref-autoloads let-alist-autoloads f-autoloads
s-autoloads rust-mode-autoloads embark-consult-autoloads
embark-autoloads consult-autoloads marginalia marginalia-autoloads
orderless orderless-autoloads flyspell ispell display-line-numbers
edmacro kmacro use-package-bind-key bind-key easy-mmode company-oddmuse
company-keywords company-etags etags fileloop generator xref project
byte-opt ring company-gtags company-dabbrev-code company-dabbrev
company-files company-clang company-capf company-cmake company-semantic
company-template company-bbdb company pcase company-autoloads savehist
vertico compat vertico-autoloads exec-path-from-shell
exec-path-from-shell-autoloads use-package-core magit-autoloads
magit-section-autoloads git-commit-autoloads with-editor-autoloads
transient-autoloads dash-autoloads compat-autoloads info finder-inf
markdown-mode-autoloads straight-autoloads cl-seq cl-extra help-mode
straight subr-x cl-macs gv cl-loaddefs cl-lib bytecomp byte-compile
wombat-theme rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
xinput2 x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 401016 69034)
 (symbols 48 29231 0)
 (strings 32 116731 2681)
 (string-bytes 1 5343184)
 (vectors 16 68498)
 (vector-slots 8 1875280 195634)
 (floats 8 416 486)
 (intervals 56 2213 217)
 (buffers 984 30))