karthink / gptel

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

How do I move the cursor to the new prompt after a query response is returned? #36

Closed dylan-conlin closed 1 year ago

dylan-conlin commented 1 year ago

Is there a hook variable I can add a hook to to move to cursor to the new prompt?

I use evil-mode, so after submitting a query I just wait until the response is finished because I've found that pressing escape to enter visual mode cancels the request. After I get a response, I'd like to automatically focus on the next new prompt.

Thank you for this package, I've tried more than a few of these clients and this is my favorite by far!

karthink commented 1 year ago

@dylan-conlin I added gptel-post-response-hook today, you could try something like

(add-hook 'gptel-post-response-hook #'markdown-outline-next)

Replace with the Org equivalent if you are using gptel in org-mode.

dylan-conlin commented 1 year ago

Thank you!

This is working nicely for me now:

  (defun move-to-next-org-heading ()
    "Move to the next org heading"
    (interactive)
    (org-next-visible-heading 1)
    (org-end-of-line))
  (add-hook 'gptel-post-response-hook #'move-to-next-org-heading)
karthink commented 1 year ago

Looks good! If you use gptel in more than dedicated chat buffers, you may want to add a check to move-to-next-org-heading to ensure the current-buffer is in org-mode.