Skip to content
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

Auto Fill mode should be respected #302

Closed
sacredirritant opened this issue May 3, 2024 · 4 comments
Closed

Auto Fill mode should be respected #302

sacredirritant opened this issue May 3, 2024 · 4 comments

Comments

@sacredirritant
Copy link

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.

@karthink
Copy link
Owner

karthink commented May 3, 2024

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))))

@sacredirritant
Copy link
Author

I see, thank you for the work around.

@karthink
Copy link
Owner

karthink commented May 4, 2024

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.

@willbush
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants