Subject: 30.0.50; php-ts-mode parser recipe fix

From: Skyler Mayfield <[email-masked]>
Date: Sat, 22 Jun 2024 10:31:50 +0200

Looks like the new php-ts-mode has a problem with the treesit parser
recipe for php. This looks to me like the same problem as bug#71562, but
affecting php instead of typescript. The bug can be reproduced as
follows:

1. Move ~/.emacs.d/tree-sitter/ to somewhere else temporarily.
2. Run emacs -Q
3. In the scratch buffer, run M-x php-ts-mode
4. Observe the warning about the missing language grammar (this warning
   is to be expected after step 1)
5. Run the provided function for installing the php parser libraries:
   M-x php-ts-mode-install-parsers
6. Observe that some libraries, but not the php language parser, are
   successfully installed to ~/.emacs.d/tree-sitter/
7. Observe a warning:
   ⛔ Warning (treesit): Error encountered when installing language
   grammar: (file-missing Setting current directory No such file or
   directory /tmp/treesit-workdirekdLGw/repo/src)

The attached patch modifies the recipe used for installing the php
treesitter grammar in a similar way as is necessary for the typescript
grammars as described in bug#71562. The fix can be confirmed via the
following:

1. Move ~/.emacs.d/tree-sitter/ to somewhere else temporarily.
2. Run emacs -Q
3. In the scratch buffer, run M-x php-ts-mode
4. Observe the warning about the missing language grammar (this warning
   is to be expected after step 1)
5. Evaluate the patched definition of php-ts-mode--language-source-alist
   in the scratch buffer.
6. Run the provided function for installing the php parser libraries:
   M-x php-ts-mode-install-parsers
7. Observe that all of the language parsers are successfully installed.
8. Verify the functionality by running M-x php-ts-mode in a php file;
   the treesitter syntax highlighting should now begin working.

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.42, cairo version 1.18.0) of 2024-06-21 built on void
Repository revision: e7123edfe7f7abc9043429dfb3f84941f83d6565
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Void Linux

Configured using:
 'configure --with-json --with-tree-sitter --with-x-toolkit=gtk3
 --with-file-notification=inotify --with-modules --with-jpeg --with-tiff
 --with-gif --with-png --with-webp --with-xpm --with-rsvg --with-xml2
 --with-gnutls --with-sound --with-harfbuzz --with-cairo --with-sqlite3'

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

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Diff

Minor modes in effect:
  whitespace-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  gcmh-mode: t
  server-mode: t
  minions-mode: t
  winner-mode: t
  repeat-mode: t
  savehist-mode: t
  save-place-mode: t
  electric-pair-mode: t
  global-auto-revert-mode: t
  recentf-mode: t
  diredfl-global-mode: t
  global-devil-mode: t
  devil-mode: t
  marginalia-mode: t
  vertico-mode: t
  global-corfu-mode: t
  corfu-mode: t
  editorconfig-mode: t
  openwith-mode: t
  global-treesit-auto-mode: t
  shell-command-x-mode: t
  eros-mode: t
  pulsar-global-mode: t
  pulsar-mode: t
  global-page-break-lines-mode: t
  default-text-scale-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/clock/.emacs.d/elpa/dired-hacks/dired-subtree hides /home/clock/.emacs.d/elpa/dired-subtree-20230512.1107/dired-subtree
/home/clock/.emacs.d/elpa/dired-hacks/dired-hacks-utils hides /home/clock/.emacs.d/elpa/dired-hacks-utils-20230512.1107/dired-hacks-utils
/home/clock/.emacs.d/elpa/lispy-20230314.1738/elpa hides /home/clock/.emacs.d/elpa/ivy-20240524.1139/elpa
/home/clock/.emacs.d/elpa/transient-20240619.1324/transient hides /usr/local/share/emacs/30.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug mu4e mu4e-org mu4e-main mu4e-view
mu4e-headers mu4e-compose mu4e-draft mu4e-actions org-capture smtpmail
mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message flow-fill
mu4e-contacts mu4e-update mu4e-folders mu4e-server mu4e-context
mu4e-vars mu4e-helpers mu4e-config ido whitespace magit-patch
magit-subtree magit-gitignore magit-ediff ediff ediff-merg ediff-mult
ediff-wind ediff-diff ediff-help ediff-init ediff-util apheleia
apheleia-rcs apheleia-dp apheleia-formatters apheleia-utils apheleia-log
apheleia-formatter-context wdired pcmpl-gnu helpful cc-langs trace
cl-print info-look f elisp-refs s consult-dir vc-hg vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs magit-extras face-remap magit-bookmark
magit-submodule 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
magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff git-commit log-edit add-log magit-core magit-autorevert
magit-margin magit-transient magit-process with-editor magit-mode
transient benchmark magit-git magit-base magit-section cursor-sensor crm
ispell html-ts-mode pcmpl-unix org-autolist org-superstar markdown-mode
bug-reference php-ts-mode js cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs css-mode sgml-mode facemenu
imenu org-indent oc-basic org-element org-persist org-id org-refile
org-element-ast inline avl-tree ol-eww eww url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg
dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range message
sendmail yank-media puny rfc822 mml mml-sec epa epg rfc6068 epg-config
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader
gnus-util mail-utils range mm-util mail-prsvr ol-docview doc-view
image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m ol-doi org-link-doi
jka-compr conf-mode java-ts-mode c-ts-common dired-subtree
dired-hacks-utils eat term disp-table ehelp make-mode run-command
run-command-runner-eat run-command-runner-vterm
run-command-runner-compile run-command-runner-term
run-command-selector-completing-read run-command-selector-ivy
run-command-selector-helm run-command-util run-command-core lispy hydra
lv delsel lispy-inline avy etags fileloop generator xref edebug debug
backtrace lispy-tags mode-local zoutline org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src sh-script smie executable ob-comint
org-pcomplete org-list org-footnote org-faces org-entities ob-emacs-lisp
ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys
oc org-loaddefs thingatpt find-func cal-menu calendar cal-loaddefs
org-version org-compat org-macs noutline outline highlight-defined
advice highlight-quoted hl-line display-line-numbers ws-butler hideshow
vc-git diff-hl log-view pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode
track-changes hl-todo consult bookmark project dired-aux
all-the-icons-dired all-the-icons all-the-icons-faces data-material
data-weathericons data-octicons data-fileicons data-faicons
data-alltheicons buffer-env modus-operandi-theme modus-themes
vertico-directory help-fns radix-tree mule-util orderless compile
text-property-search gcmh server minions winner repeat savehist
saveplace tramp-sh tramp trampver tramp-integration files-x
tramp-message tramp-compat xdg parse-time iso8601 time-date format-spec
tramp-loaddefs elec-pair autorevert filenotify recentf tree-widget
wid-edit dired-x diredfl dired dired-loaddefs devil wrap-region
marginalia vertico corfu editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch openwith treesit-auto
treesit shell-command-x shell pcomplete comint ansi-osc ansi-color ring
eros pp pulsar pulse page-break-lines default-text-scale
gruvbox-dark-hard-theme gruvbox-theme gruvbox autothemer color lisp-mnt
dash derived inheritenv comp comp-cstr warnings comp-run comp-common rx
edmacro kmacro no-littering compat use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
cl-extra help-mode use-package-core finder-inf
all-the-icons-dired-autoloads apheleia-autoloads easy-mmode
autothemer-autoloads breadcrumb-autoloads buffer-env-autoloads
consult-dir-autoloads consult-eglot-autoloads corfu-autoloads
default-text-scale-autoloads devil-autoloads diff-hl-autoloads
dired-hacks-autoloads dired-sidebar-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads diredfl-autoloads eat-autoloads
editorconfig-autoloads eldoc-box-autoloads embark-consult-autoloads
consult-autoloads embark-autoloads emmet-mode-autoloads eros-autoloads
esup-autoloads flymake-eslint-autoloads gcmh-autoloads
geiser-mit-autoloads geiser-autoloads git-timemachine-autoloads
helpful-autoloads elisp-refs-autoloads highlight-defined-autoloads
highlight-quoted-autoloads hl-todo-autoloads ibuffer-project-autoloads
inheritenv-autoloads lispy-autoloads iedit-autoloads lua-mode-autoloads
magit-autoloads pcase git-commit-autoloads magit-section-autoloads
marginalia-autoloads markdown-mode-autoloads minions-autoloads
no-littering-autoloads nov-autoloads esxml-autoloads kv-autoloads
nvm-autoloads dash-functional-autoloads f-autoloads openwith-autoloads
orderless-autoloads org-autolist-autoloads org-superstar-autoloads
page-break-lines-autoloads prisma-mode-autoloads pulsar-autoloads
restclient-autoloads run-command-autoloads shell-command-x-autoloads
sly-asdf-autoloads popup-autoloads sly-autoloads swiper-autoloads
ivy-autoloads transient-autoloads treemacs-all-the-icons-autoloads
treemacs-autoloads cfrs-autoloads posframe-autoloads ht-autoloads
hydra-autoloads lv-autoloads pfuture-autoloads ace-window-autoloads
avy-autoloads s-autoloads all-the-icons-autoloads treesit-auto-autoloads
vertico-autoloads web-mode-autoloads wgrep-autoloads why-this-autoloads
with-editor-autoloads wrap-region-autoloads info dash-autoloads
ws-butler-autoloads yaml-mode-autoloads yaml-pro-autoloads
yaml-autoloads zoutline-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
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 touch-screen 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 dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 1087077 441049) (symbols 48 51312 0) (strings 32 233896 24179)
 (string-bytes 1 8643395) (vectors 16 104980) (vector-slots 8 2060691 223252)
 (floats 8 1889 2190) (intervals 56 21118 2268) (buffers 992 63))
diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 8bb18dab3d5..1c76e55c1d6 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -82,7 +82,7 @@
 
 ;;; Install treesitter language parsers
 (defvar php-ts-mode--language-source-alist
-  '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.5"))
+  '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.5" "php/src"))
     (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
     (html . ("https://github.com/tree-sitter/tree-sitter-html"  "v0.20.3"))
     (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2"))