Improve project.el and Projectile interoperability in php-project#823
Open
zonuexe wants to merge 1 commit into
Open
Improve project.el and Projectile interoperability in php-project#823zonuexe wants to merge 1 commit into
zonuexe wants to merge 1 commit into
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
php-project.ela better citizen of the built-inproject.elecosystem and align it with Projectile 3, which now registers itself onproject-find-functions.Changes
Fix broken VC project value (bug)
php-project-project-find-functionbuilt 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, soproject-root(which reads(nth 2 ...)) signalledwrong-type-argumenton the value this function returned. It now delegates toproject-try-vc, which yields the representation the running Emacs expects, and falls back to atransientproject otherwise.Fall back to
project.elfor root detectionphp-project-get-root-dirnow falls back toproject-currentwhen no PHP-specific marker (.projectile,composer.json/composer.lock, VCS dir) is found. This lets anyproject.elbackend contribute detection — Projectile 3,project-vc-extra-root-markers(Emacs 29+), and other VCS — while preserving thecomposer.json-first precedence that matters in monorepos.php-project-project-find-functionis temporarily removed from the hook during the fallback to avoid recursing back into detection.Deprecate
php-project-use-projectile-to-detect-rootProjectile 3 is now consulted automatically through the
project.elfallback, 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-modeguards, and an activeprojectile-modealready 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-functionsregistration in bothREADME.mdandREADME.ja.md, plus CHANGELOG entries.Testing
composer.jsonsub-package keeps its own root (not swallowed by the git root); a git root returns a valid(vc Git ROOT)on whichproject-rootno longer errors; a marker miss falls back toproject-current.php-project-project-find-functionis registered onproject-find-functionsand detection misses.