Skip to content

Conversation

@tninja
Copy link
Owner

@tninja tninja commented Nov 15, 2025

So code-change and ask-question can better focus on a particular selected region.

@tninja tninja requested a review from Copilot November 15, 2025 01:59
Copilot finished reviewing on behalf of tninja November 15, 2025 02:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the code-change and ask-question commands by adding git-relative file paths and line number information to selected regions in prompts. The region location is formatted as path/to/file.el#L10-L20 (following GitHub's URL fragment syntax), helping AI models better focus on specific code regions.

Key Changes

  • Added region location information (git-relative path + line numbers) to prompts when a region is selected
  • Updated prompt formatting to use "Selected region:" label with optional location info
  • Made note messages context-aware, distinguishing between region-specific and general operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
ai-code-discussion.el Added region location info computation and updated prompt formatting for ask-question commands
ai-code-change.el Added declare-function for ai-code--get-git-relative-paths, computed region location info, and updated prompt formatting for code-change commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +101
(region-end-line (when region-active
(line-number-at-pos (region-end))))
(git-relative-path (when (and region-active buffer-file-name)
(car (ai-code--get-git-relative-paths (list buffer-file-name)))))
(region-location-info (when (and region-active git-relative-path region-start-line region-end-line)
(format "%s#L%d-L%d" git-relative-path region-start-line region-end-line)))
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The logic for computing region-end-line, git-relative-path, and region-location-info is duplicated between this file and ai-code-change.el (lines 103-108). Consider extracting this into a shared helper function to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

tninja and others added 2 commits November 14, 2025 19:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Nov 15, 2025

@tninja I've opened a new pull request, #49, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tninja tninja merged commit c01101f into main Nov 15, 2025
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.

2 participants