Include selected region in Emacs runtime debug prompts#359
Merged
Conversation
Agent-Logs-Url: https://github.com/tninja/ai-code-interface.el/sessions/939be737-72fa-45c4-a90d-bc962ceb186d Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for current selected region as AI context
Include selected region in Emacs runtime debug prompts
May 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Emacs runtime debugging prompts so selected Elisp/config regions are included as context for AI-assisted runtime investigation.
Changes:
- Adds optional selected-region text and location metadata to
ai-code--emacs-runtime-debug-prompt. - Captures active region context in
ai-code-debug-emacs-runtime. - Adds focused ERT coverage for selected-region prompt inclusion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
ai-code.el |
Adds selected-region context to runtime debug prompt generation and command flow. |
test/test_ai-code.el |
Adds an ERT test verifying selected region label, location, and snippet are included. |
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.
ai-code-debug-emacs-runtimepreviously only sent the freeform issue description to the AI session. When debugging keybindings or interactive behavior, that omitted the exact Elisp/config snippet the user had selected.Runtime debug prompt context
ai-code--emacs-runtime-debug-promptto accept optional selected-region context.Selected region:block to the generated prompt when a region is active.Command behavior
ai-code-debug-emacs-runtimeto capture the active region before assembling the confirmation prompt.Focused coverage
Example of the prompt shape after this change:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https(dns block)elpa.gnu.org/usr/bin/emacs emacs -Q -batch --eval (progn (require 'package) (setq package-archives '(("gnu" . "REDACTED") ("nongnu" . "REDACTED") ("melpa" . "REDACTED"))) (package-initialize) (package-refresh-contents) (dolist (pkg '(transie get mand-not-found/ the(dns block)elpa.nongnu.org/usr/bin/emacs emacs -Q -batch --eval (progn (require 'package) (setq package-archives '(("gnu" . "REDACTED") ("nongnu" . "REDACTED") ("melpa" . "REDACTED"))) (package-initialize) (package-refresh-contents) (dolist (pkg '(transie get mand-not-found/ the(dns block)melpa.org/usr/bin/emacs emacs -Q -batch --eval (progn (require 'package) (setq package-archives '(("gnu" . "REDACTED") ("nongnu" . "REDACTED") ("melpa" . "REDACTED"))) (package-initialize) (package-refresh-contents) (dolist (pkg '(transie get mand-not-found/ the(dns block)If you need me to access, download, or install something from one of these locations, you can either: