copilot.el icon indicating copy to clipboard operation
copilot.el copied to clipboard

Chat interaction?

Open dov opened this issue 8 months ago • 6 comments

I wonder if the following is possible.

Let's say I have the following line selected:

    std::cout << "Hello, World!" << std::endl;

and I would like to give the prompt "Rewrite code using printf()". Is that possible?

dov avatar Apr 16 '25 07:04 dov

I think it's possible, provided we implement something along the lines of #343 first.

bbatsov avatar Apr 16 '25 08:04 bbatsov

Please see copilot-chat.el https://github.com/chep/copilot-chat.el

peterbecich avatar May 16 '25 07:05 peterbecich

Please see copilot-chat.el https://github.com/chep/copilot-chat.el

I'm using copilot-chat.el to have an interactive chat session with copilot. However I am not aware that I can select something in a source code buffer and give a command which will carry out a rewrite like in the example I gave above. Am I missing something?

dov avatar May 16 '25 08:05 dov

@dov , upon further review I agree with you. It is close but a.f.a.i.k. not exactly what you want. Example for buffer A:

  • copilot-chat-custom-prompt-selection: asks for a prompt, applies it to the selection in buffer A, puts the output in the *Copilot Chat* buffer. The code is put into an Org-mode code block. Non-code etc. is outside the Org-mode code block.
  • copilot-chat-yank: copies the Org-mode code block from the *Copilot Chat* buffer to the cursor in buffer A. Does not overwrite the previous selection. If it overwrote the previous selection, I think it would be what you are asking for.

I will make a feature request:

  • combine these two commands into one
  • overwrite the selection with the code block prompt output

peterbecich avatar May 18 '25 06:05 peterbecich

@dov I think this is the main issue for this topic in copilot-chat https://github.com/chep/copilot-chat.el/issues/63

peterbecich avatar May 18 '25 06:05 peterbecich

Just saying but gptel also have support for GithubCopilot. And it allows you to select a region and have it rewrite in place

kiennq avatar May 19 '25 02:05 kiennq