Skip to content

Add php-core.el for the dependency-free primitives#815

Merged
zonuexe merged 1 commit into
masterfrom
refactor/php-core
Jul 16, 2026
Merged

Add php-core.el for the dependency-free primitives#815
zonuexe merged 1 commit into
masterfrom
refactor/php-core

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 16, 2026

Copy link
Copy Markdown
Member

First step of the php.el decomposition, aimed at the v1.28 series.

Why

php.el is required by every PHP package, but it requires flymake, php-project and (for now) CC Mode. A module that only wants the php customization group or a syntax-ppss predicate pays for all of it — measured on a byte-compiled tree:

features time
(require 'php) 17 ~53 ms

The indentation engine pulling in flymake to get a 7-line defgroup is the clearest symptom.

What moves

lisp/php-core.el (new, zero dependencies):

  • the php customization group
  • php-executable
  • php-in-string-p, php-in-comment-p, php-in-string-or-comment-p, php-in-poly-php-html-mode
  • php-base-mode

php.el requires php-core.el and therefore still exposes every one of them, so (require 'php) behaves exactly as before and nothing has to migrate. This is the facade direction: the dependency arrow points core ← php, with no cycle.

php-indent.el, which only ever wanted the customization group, now requires php-core.el instead:

features time
(require 'php-indent) 2 ~1 ms

with no flymake, php-project or cc-engine in its chain.

Two consequences worth calling out

php.el's defcustoms specify :group 'php again. #813 removed those as redundant, which was true only while the defgroup sat in the same file: custom-current-group keys off load-file-name, so with the defgroup in php-core.el they silently fall out of the group. Without this, M-x customize-group php lists 2 members instead of 29. They are required now, not redundant.

The syntax tables stay in php.el for the moment. They are built with c-populate-syntax-table, so moving them would drag CC Mode into php-core.el and defeat the purpose. They can follow once php.el stops requiring cc-engine.

Verification

  • (get GROUP 'custom-group) membership is identical to master for every php* group (php, php-mode, php-faces, php-format, php-ide, php-ide-phpactor, php-flymake, php-complete, php-project).
  • Byte-compiles with no new warnings; the existing test suite is unaffected (62 tests, unchanged).
  • php-core.el uses no Emacs 28+ functions, so it does not front-run Drop Emacs 27 Support #811 — this is intended for the Emacs 27-supporting v1.28 series.

Follow-ups (not here)

  • php-executable currently has two bound-and-true-p / boundp workarounds — php-project.el:224 and php-flymake.el:104 — because neither can require php.el (php.el requires php-project, so it would be circular). Both can now require php-core.el instead and drop the workaround. Kept out of this PR to keep it a pure move with no behaviour change.
  • Moving the syntax tables and the token scanner, once cc-engine is gone from php.el.
  • php-magical-constants → php-keywords.el with an obsolete alias.

php.el is required by every PHP package, but it requires flymake,
php-project and (for now) CC Mode.  A module that only wants the `php'
customization group or a syntax-ppss predicate pays for all of it:
`(require 'php)' pulls in 17 features and ~53 ms.

Move the definitions that depend on nothing into php-core.el:

  - the `php' customization group,
  - `php-executable',
  - `php-in-string-p' and its siblings,
  - `php-base-mode'.

php.el requires php-core.el and therefore still exposes all of them, so
`(require 'php)' behaves exactly as before and nothing has to migrate.
php-indent.el, which only ever wanted the customization group, now
requires php-core.el instead: 2 features and ~1 ms, with no flymake,
php-project or cc-engine in its dependency chain.

Two consequences worth noting:

* php.el's defcustoms specify `:group 'php' again.  #813 removed those
  as redundant, which was true only while the defgroup sat in the same
  file: `custom-current-group' keys off `load-file-name', so with the
  defgroup in php-core.el they would silently fall out of the group
  (`M-x customize-group php' listed 2 members instead of 29).  They are
  required now, not redundant.
* The syntax tables stay in php.el for the moment.  They are built with
  `c-populate-syntax-table', so moving them would drag CC Mode into
  php-core.el and defeat the purpose; they can follow once php.el stops
  requiring cc-engine.

Verified that (get GROUP 'custom-group) membership is identical to
before for every php* group.
@zonuexe
zonuexe merged commit a357bc8 into master Jul 16, 2026
14 checks passed
@zonuexe
zonuexe deleted the refactor/php-core branch July 16, 2026 14:23
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