Closed sacredirritant closed 1 month ago
I don't think this is possible, auto-fill only works when running self-insert
with space. So it doesn't work in gptel for the same reason that it doesn't work when you yank text.
You can fill text in gptel's post-response hook:
(add-hook 'gptel-post-response-functions 'fill-region)
Or, conditioned on auto-fill-mode
,
(add-hook 'gptel-post-response-functions
(lambda (beg end)
(when auto-fill-function
(fill-region beg end))))
I see, thank you for the work around.
Due to the way text properties are handled by gptel, you may get errors with some LLMs when continuing a conversation after filling text. If you get errors as a result of filling text please reopen this issue.
Thought this was working pretty well at first, but then noticed it messes up source block formatting.
(add-hook 'gptel-post-response-functions
(lambda (beg end)
(when auto-fill-function
(fill-region beg end))))
I ended up just going with soft-wrapping (add-hook 'gptel-mode-hook #'visual-line-mode)
It would be nice if the response insertion behaved the same as ordinary interactive insertion so that inserting a space at a column beyond current-fill-column automatically breaks the line at a previous space when Auto Fill mode is enabled. Long lines in the response are currently inserted as-is.