Repository navigation
C-c a @: copy file + line range only for regions longer than 5 lines - #514
Merged
Merged
Conversation
Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix: Use file and line range for long selected regions
C-c a @: copy file + line range only for regions longer than 5 lines
Sep 17, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is focused and tested; only a minor documentation correction remains.
Pull request overview
Adds configurable suppression of large selected-region text in copied context references.
Changes:
- Introduces a configurable five-line default threshold.
- Adds ERT coverage for short/long regions and both copy actions.
- One minor docstring issue was noted.
File summaries
| File | Description |
|---|---|
ai-code-file.el |
Applies the region-length threshold when copying context. |
test/test_ai-code-file.el |
Tests threshold behavior and context-menu actions. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+112
to
+113
| before that context reference, unless the region spans more than 5 | ||
| lines; then only the file path with line range is copied. |
tninja
marked this pull request as ready for review
September 18, 2026 03:44
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.
The
C-c a @copy actions always prepended the full selected region text to the context reference, producing unwieldy clipboard content for large selections. Long selections now copy only the file path with line range; the region text is kept for selections of 5 lines or fewer.Changes
ai-code-file.elai-code-copy-buffer-file-name-to-clipboard: include region text only when the region spans at mostai-code-region-text-max-lines; otherwise copy just thefile#Lstart-Lendreference. Applies to both "Copy context" and "Copy context with full path".ai-code-region-text-max-lines(default 5) controlling the threshold.ai-code--current-file-context-reference.Behavior
test/test_ai-code-file.el: new ERT tests covering the ≤5-line path (text preserved), the >5-line path (line range only), and both copy sub-menu entries viaai-code-context-action.