Skip to content

Include selected region in Emacs runtime debug prompts#359

Merged
tninja merged 2 commits into
mainfrom
copilot/support-current-selected-region-context
May 17, 2026
Merged

Include selected region in Emacs runtime debug prompts#359
tninja merged 2 commits into
mainfrom
copilot/support-current-selected-region-context

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

ai-code-debug-emacs-runtime previously 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

    • Extend ai-code--emacs-runtime-debug-prompt to accept optional selected-region context.
    • Append a Selected region: block to the generated prompt when a region is active.
    • Include git-relative line location metadata when available, matching existing prompt conventions elsewhere in the package.
  • Command behavior

    • Update ai-code-debug-emacs-runtime to capture the active region before assembling the confirmation prompt.
    • Preserve existing behavior when no region is selected.
  • Focused coverage

    • Add a targeted ERT case verifying that the runtime debug prompt includes:
      • the selected region label
      • region location info
      • the selected Elisp snippet itself

Example of the prompt shape after this change:

Runtime issue description:
C-c x runs the wrong interactive command

Selected region:
ai-code.el#L10-L11
(global-set-key (kbd "C-c x") #'wrong-command)

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
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)
  • elpa.gnu.org
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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:

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
Copilot finished work on behalf of tninja May 17, 2026 01:10
Copilot AI requested a review from tninja May 17, 2026 01:10
@tninja tninja requested a review from Copilot May 17, 2026 02:03
Copy link
Copy Markdown
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 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.

@tninja tninja marked this pull request as ready for review May 17, 2026 03:29
@tninja tninja merged commit e333ced into main May 17, 2026
3 checks passed
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.

ai-code-debug-emacs-runtime should support current selected region as context sent to ai coding session

3 participants