Skip to content

Improve project.el and Projectile interoperability in php-project#823

Open
zonuexe wants to merge 1 commit into
masterfrom
feature/php-project-project-el-interop
Open

Improve project.el and Projectile interoperability in php-project#823
zonuexe wants to merge 1 commit into
masterfrom
feature/php-project-project-el-interop

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

Make php-project.el a better citizen of the built-in project.el ecosystem and align it with Projectile 3, which now registers itself on project-find-functions.

Changes

Fix broken VC project value (bug)

php-project-project-find-function built a (vc . ROOT) cons. That is only valid on Emacs 27; since Emacs 28 the VC project is the 3-element (vc BACKEND ROOT) form, so project-root (which reads (nth 2 ...)) signalled wrong-type-argument on the value this function returned. It now delegates to project-try-vc, which yields the representation the running Emacs expects, and falls back to a transient project otherwise.

Fall back to project.el for root detection

php-project-get-root-dir now falls back to project-current when no PHP-specific marker (.projectile, composer.json/composer.lock, VCS dir) is found. This lets any project.el backend contribute detection — Projectile 3, project-vc-extra-root-markers (Emacs 29+), and other VCS — while preserving the composer.json-first precedence that matters in monorepos. php-project-project-find-function is temporarily removed from the hook during the fallback to avoid recursing back into detection.

Deprecate php-project-use-projectile-to-detect-root

Projectile 3 is now consulted automatically through the project.el fallback, so the dedicated option is redundant. It is marked obsolete (1.28.0) but still works.

Drop the load-time (require 'projectile nil t)

Projectile is only touched behind fboundp/projectile-mode guards, and an active projectile-mode already implies the library is loaded — so requiring it at load time only pulled in the whole of Projectile for no benefit. Replaced with (require 'project), which the fixes above need.

Docs

Document the integration and the low-priority project-find-functions registration in both README.md and README.ja.md, plus CHANGELOG entries.

Testing

  • Byte-compiles cleanly with no warnings.
  • Verified: a composer.json sub-package keeps its own root (not swallowed by the git root); a git root returns a valid (vc Git ROOT) on which project-root no longer errors; a marker miss falls back to project-current.
  • Verified no infinite recursion when php-project-project-find-function is registered on project-find-functions and detection misses.

`php-project-project-find-function` built a `(vc . ROOT)` cons, which is
only valid on Emacs 27.  Since Emacs 28 the VC project is the 3-element
`(vc BACKEND ROOT)` form, so `project-root` (which reads `(nth 2 ...)`)
signalled `wrong-type-argument` on the returned value.  Delegate to
`project-try-vc`, which yields the representation the running Emacs
expects, and fall back to a `transient` project otherwise.

Let `php-project-get-root-dir` fall back to `project-current` when no
PHP-specific marker is found.  This lets any project.el backend
contribute detection -- Projectile 3 (which registers itself on
`project-find-functions'), `project-vc-extra-root-markers', and other
VCS -- while keeping the composer.json-first precedence that matters for
monorepos.  `php-project-project-find-function' is removed from the hook
during the fallback to avoid recursing back into detection.

Deprecate `php-project-use-projectile-to-detect-root': Projectile 3 is
now consulted automatically through the project.el fallback, so the
dedicated option is redundant.

Drop the load-time `(require 'projectile nil t)'; Projectile is only
touched behind `fboundp'/`projectile-mode' guards, and an active
`projectile-mode' already implies the library is loaded.

Document the integration and the low-priority `project-find-functions'
registration in both READMEs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant