Skip to content

Add __DIR__ path completion capf and php-dot-context primitive#822

Merged
zonuexe merged 2 commits into
rewrite/cc-free-php-modefrom
feature/dir-path-completion
Jul 17, 2026
Merged

Add __DIR__ path completion capf and php-dot-context primitive#822
zonuexe merged 2 commits into
rewrite/cc-free-php-modefrom
feature/dir-path-completion

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

Redefine php-complete.el as a small collection of dependency-light, offline completion-at-point functions, and add path completion for the __DIR__ . '/...' idiom. Each capf works both as an M-x command and as a building block for cape-capf-super.

Changes

lisp/php.el

  • php-dot-context: new dependency-free primitive classifying the context before point (string-or-comment / next-to-string / code) for context-sensitive . insertion. Built on php-leading-tokens and php-magical-constants, with no cc-engine dependency. Meant to drive smartchr/key-combo setups.

lisp/php-complete.el

  • State the file's mission in the Commentary.
  • php-complete-complete-function: redefine as the offline built-in function-name source (behavior unchanged).
  • php-complete-path-dir-constants: new option; directory-valued subset of php-magical-constants (default '("__DIR__")).
  • php-complete-complete-path: new capf completing a filesystem path inside __DIR__ . '/...', one component at a time, rooted at the current file's directory. Robust to the unterminated string that is normal while typing; binds default-directory in a closure so it does not depend on the buffer's default-directory.
  • Inserting . '/' is left to the editor (see php-dot-context + smartchr recipe), not the capf.

tests/php-mode-test.el

  • Add php-mode-test-dot-context and php-mode-test-complete-path.

README.md, README.ja.md

  • Document the completion capfs, cape-capf-super composition, and a php-dot-context-based smartchr recipe for ..

Design

Key-driven insertion (smartchr) and completion (capf) stay orthogonal but consistent by sharing php-dot-context's notion of "string" and "magic constant": smartchr writes the __DIR__ . '/' skeleton, the capf fills in the path.

Testing

  • make test: 74 tests, 0 unexpected (4 pre-existing environment skips).
  • Byte-compiles with no warnings.

zonuexe added 2 commits July 18, 2026 04:56
Redefine php-complete.el as a small collection of dependency-light,
offline completion-at-point functions usable both as `M-x` commands and
as building blocks for `cape-capf-super'.

* lisp/php.el (php-dot-context): New dependency-free primitive that
  classifies the context before point (`string-or-comment',
  `next-to-string', `code') for context-sensitive `.' insertion, without
  cc-engine.  Meant to drive smartchr/key-combo setups.

* lisp/php-complete.el: State the file's mission in the Commentary.
  (php-complete-complete-function): Redefine as the offline built-in
  function-name source (behavior unchanged).
  (php-complete-path-dir-constants): New option; directory-valued subset
  of `php-magical-constants'.
  (php-complete-complete-path): New capf completing a filesystem path in
  the `__DIR__ . '/...'' idiom, one component at a time, rooted at the
  directory of the current file.  Robust to the unterminated string that
  is normal while typing.

* tests/php-mode-test.el: Cover `php-dot-context' and
  `php-complete-complete-path'.

* README.md, README.ja.md: Document the completion capfs, `cape-capf-super'
  composition, and a `php-dot-context'-based smartchr recipe for `.'.
Follow the "Personal Settings" pattern in the README: add the capfs from
a named setup function inside `with-eval-after-load 'php-mode', rather
than adding an anonymous closure to the hook, which is hard to remove or
redefine later.

Also fix "補完" that had been garbled to "補completion" in README.ja.md.
@zonuexe
zonuexe merged commit 6f907e6 into rewrite/cc-free-php-mode Jul 17, 2026
@zonuexe
zonuexe deleted the feature/dir-path-completion branch July 17, 2026 21:33
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