-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move point to the end of inserted text when inserting into a buffer #269
Comments
* gptel.el (gptel--insert-response): Moving point in a buffer does not move window-point in a window displaying that buffer if the window is not selected (#269). So select the gptel response window explicitly (if possible) when running `gptel-post-response-functions`. NOTE: Instead of selecting the window before running the hook, We could run `set-window-point` in the window after running it. Since the hook can have any kind of behavior (smooth-scrolling for instance) we want it to play out interactively. * gptel-curl.el (gptel--curl-stream-cleanup): Ditto.
This was a bug, thanks for reporting it! It's not that it was only running in gptel chat buffers -- the problem is that moving point like this: (with-current-buffer gptel-buffer
(goto-char (somewhere))) does not move the point in a window showing that buffer unless the window is selected. Each window has its own point in the buffer and it only moves if the buffer is selected -- a fact I have to remind myself of every couple of years. Fixed by selecting the window (if possible) before running the hook.
I will not do this by default. It breaks the async behavior, Emacs or the user can be doing any number of other things in the buffer. The hook method is the recommended way to do this. |
Thank you for fixing this 🙏 — I can now implement the behavior I need using Incidentally, I think this variable needs a docstring fix. The docstring says "This hook is called in the buffer from which the prompt was sent", it probably should say "This hook is called in the buffer to which the response was sent"? Also, not sure if that is intentional or not, but the |
* gptel.el (gptel-post-response-functions): Adjust docstring for this hook to mention that the hook runs in the response buffer, not the prompt buffer. (#269)
Fixed, thanks for catching that.
I am following the guidelines for naming hooks as laid out in the Elisp manual
The problem is use-package's bad defaults. You can change it by adjusting |
I would suggest that gptel move the point to the end of the inserted text when generating into a buffer. Right now, if I'm running gptel several times, each reply gets inserted before the previous one. I expected to be able to generate several replies into a buffer, one after another, separated by a newline.
I tried
(add-hook 'gptel-post-response-functions 'gptel-end-of-response)
, but that only seems to work for the gptel buffer, not for other text buffers (I am testing with*scratch*
in Markdown mode).The text was updated successfully, but these errors were encountered: