Detect bare relative and punctuation-wrapped file paths (#107)#110
Merged
Detect bare relative and punctuation-wrapped file paths (#107)#110
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Ghostel’s plain-text link detection to recognize more compiler/traceback-style file:line[:col] references (including bare relative paths with / and punctuation-wrapped paths), and to jump to the reported column when present.
Changes:
- Add customizable
ghostel-file-detection-regexand updateghostel--detect-urlsto use it, including per-scanfile-exists-pmemoization. - Extend
fileref:handling inghostel--open-linkto support optional:col. - Add tests/bench inputs and refresh README benchmark numbers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ghostel.el |
Introduces configurable file detection regex, memoized existence checks, and :col support when opening fileref: links. |
test/ghostel-test.el |
Adds ERT coverage for new file detection patterns and :col cursor positioning. |
bench/ghostel-bench.el |
Expands benchmark URL/path generator with new path formats to reflect updated detection. |
README.md |
Updates benchmark results to current measurements/hardware. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d1c61da to
4a13868
Compare
Broaden `ghostel--detect-urls` to linkify compiler-output-style paths that the old `\(?:\./\|/\)…:[0-9]+` regex missed: - Bare relative paths containing at least one `/` — Rust's `retroact-macros/src/lib.rs:43:4`, Go's `pkg/foo/bar.go:12:5`, TypeScript's `src/components/Button.tsx:17`. - Paths wrapped in punctuation — Python tracebacks like `(/home/user/index.js:17:5)`, bracketed `[path:N]`, backtick or quote-wrapped paths. - Optional `:column` after `:line`; `ghostel--open-link` now moves to that column when present. New `ghostel-file-detection-regex` defcustom exposes the pattern so users can narrow or widen it. Group 1 captures the linkified text; the outer match may include a leading path-boundary character that is not part of the link. Bare filenames without a `/` (e.g. `main.go:12`) are deliberately not matched by default — relying on `file-exists-p` alone for those risks stat'ing every `word:digits` token on slow or network filesystems. The new default regex uses non-backtracking character classes (`[^ \t\n\r:\"<>/]*/`) and a punctuation-boundary anchor so the scan is cheap even on URL-heavy output. A small per-scan hash memoizes `file-exists-p` so repeated paths in a redraw (common in Rust `-->` blocks and Python tracebacks) aren't re-stat'd. PTY benchmark (5 MB url-heavy `cat` through a real pipe): ghostel (old regex): 44 MB/s ghostel (this PR): 56 MB/s (+27%, matches strictly more patterns) Also refreshes README benchmark numbers to current hardware and adds Rust/Go/TS sample lines to the url bench fixture so the URL-heavy scenario actually exercises the new matcher. Fixes #107
4a13868 to
ed17efb
Compare
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
ghostel--detect-urlsnow linkifies compiler-output-style paths the old\(?:\./\|/\)…:[0-9]+regex missed: bare relative paths with a/(Rustretroact-macros/src/lib.rs:43:4, Gopkg/foo/bar.go:12:5, TSsrc/Button.tsx:17), and paths wrapped in punctuation (Python tracebacks(/home/user/x.js:17:5),[path:N], backtick/quote-wrapped).:column;ghostel--open-linkmoves the cursor to that column when present.ghostel-file-detection-regexdefcustom exposes the pattern. Bare filenames without a/(e.g.main.go:12) are intentionally not matched by default — relying onfile-exists-palone for those risks stat'ing everyword:digitstoken on slow or network filesystems. Users can opt in via the defcustom.file-exists-pfor repeated paths (Rust-->blocks, Python tracebacks).Performance
Despite matching strictly more patterns, PTY throughput on URL-heavy output improved:
catthrough PTYThe old regex had no leading anchor and retried a full path scan at every
/in URL text. The new regex anchors on whitespace or common path-wrapper punctuation (([{<\'"`) and uses non-backtracking character classes, so the match-attempt count drops sharply on URL-dense output.README benchmark numbers were also refreshed to current hardware (M4 Max, Emacs 31) as part of this PR.
Test plan
make test— all 115 elisp tests pass, including 5 new cases:/skipped (false-positive protection)ghostel-file-detection-regexopts into broader matchingfileref:PATH:LINE:COLround-trips throughghostel--open-linkmake bench— url-heavy throughput up 27%, plain unchangedcargo checkin a ghostel buffer, click through to the files