karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 113 forks source link

Capture text from gptel-system buffer before swapping buffer context. #139

Closed blacklandco closed 7 months ago

blacklandco commented 7 months ago

Fix for https://github.com/karthink/gptel/issues/138

I'm not well versed in elisp so maybe there is a more idiomatic way to fix this, but figured I'd give it a shot.

As best I understand it, in 3c01477c37f494e4421970dcf2ddb69c25958aa7 the code changed to use with-current-buffer orig-buf but then within that context the buffer-substring function acts on the original buffer where the command was issued from, not on the *gptel-system* buffer where the user has entered text, so it sets the prompt to the wrong thing.

karthink commented 7 months ago

Oops, I just saw this after I fixed #138, sorry! This was basically the fix I made, only I refactored some code to add an abort function.