Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ai-code-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ or nil (prompt the user)."
(defvar ai-code-pr-title-history nil
"Minibuffer history for optional PR titles.")

;; DONE: when press C-c a v, if there is a selected region, and if there is a url inside, it should be used as a default value when asking user for PR or issue URL.

(defun ai-code--extract-url-from-region ()
"Return the first URL found in the active region, or nil."
(when (use-region-p)
(let ((text (buffer-substring-no-properties (region-beginning) (region-end))))
(when (string-match "https?://[^ \t\n]+" text)
(match-string 0 text)))))

(defun ai-code--git-ignored-repo-file-p (file root)
"Return non-nil when FILE should be ignored for repo candidates under ROOT."
(when (and file root)
Expand Down Expand Up @@ -242,7 +251,8 @@ Otherwise, ask for the relevant pull request or issue URL."
(ai-code--build-send-current-branch-pr-init-prompt
review-source current-branch target-branch pr-title)))
(let* ((url-prompt (ai-code--pull-or-review-url-prompt review-mode))
(target-url (ai-code-read-string url-prompt)))
(region-url (ai-code--extract-url-from-region))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Capture region URL before prompting for review options

Compute the region URL before entering the minibuffer prompts; as written, ai-code--extract-url-from-region runs only after ai-code-pull-or-review-diff-file has already asked for review source and mode, and those interactive reads typically clear the active region, so use-region-p is nil and the URL default is not populated. In the common C-c a v flow (select URL in buffer, then choose source/mode), this makes the new feature effectively not work.

Useful? React with 👍 / 👎.

(target-url (ai-code-read-string url-prompt region-url)))
(ai-code--build-pr-init-prompt review-source target-url review-mode))))
(prompt-label (if (eq review-mode 'send-current-branch-pr)
"Enter PR creation prompt: "
Expand Down
2 changes: 1 addition & 1 deletion ai-code-prompt-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ If PROMPT-TEXT is a command (starts with /), execute it directly instead."
(not (string-match-p " " processed-prompt)))
(ai-code--execute-command processed-prompt)
(let* ((append-summary-p (and (derived-mode-p 'ai-code-prompt-mode)
(org-at-heading-p)
(ignore-errors (save-excursion (org-back-to-heading t) t))
(y-or-n-p "Append result summary to current section? ")))
(final-prompt (if append-summary-p
(concat processed-prompt
Expand Down
Loading