Add __DIR__ path completion capf and php-dot-context primitive#822
Merged
Conversation
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.
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
Redefine
php-complete.elas a small collection of dependency-light, offline completion-at-point functions, and add path completion for the__DIR__ . '/...'idiom. Each capf works both as anM-xcommand and as a building block forcape-capf-super.Changes
lisp/php.elphp-dot-context: new dependency-free primitive classifying the context before point (string-or-comment/next-to-string/code) for context-sensitive.insertion. Built onphp-leading-tokensandphp-magical-constants, with no cc-engine dependency. Meant to drive smartchr/key-combo setups.lisp/php-complete.elphp-complete-complete-function: redefine as the offline built-in function-name source (behavior unchanged).php-complete-path-dir-constants: new option; directory-valued subset ofphp-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; bindsdefault-directoryin a closure so it does not depend on the buffer'sdefault-directory.. '/'is left to the editor (seephp-dot-context+ smartchr recipe), not the capf.tests/php-mode-test.elphp-mode-test-dot-contextandphp-mode-test-complete-path.README.md,README.ja.mdcape-capf-supercomposition, and aphp-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).