karthink/gptel

gptel-mode should work with any text-mode derived mode.

Opened this issue · 2 comments

Please update gptel first -- errors are often fixed by the time they're reported.

  • I have updated gptel to the latest commit and tested that the issue still exists

Bug Description

gptel-mode only works with org-mode and markdown-mode derived modes. I have some text-mode derived mode I use it with but oob it fails because of the mode compatibility check.

Here's how I fixed it in gptel.el:

  (if gptel-mode
      (progn
        (unless (or (derived-mode-p 'org-mode 'markdown-mode 'text-mode) ;; <<< Change here, add 'text-mode
                    (eq major-mode 'text-mode))
          (gptel-mode -1)
          (user-error (format "`gptel-mode' is not supported in `%s'." major-mode)))
        (add-hook 'before-save-hook #'gptel--save-state nil t)

Steps to Reproduce

Try to use gptel-mode with a text-mode derived mode that isnt text-mode itself.

The reason(s) support for modes derived from text-mode is not currently enabled are:

  1. Many modes derive from text-mode where it does not make sense to use a chat interface. For example, yaml-mode.
  2. You can use gptel in any buffer -- turning on the mode is not necessary to use gptel. (gptel-mode only adds the prompt/resposne prefixes and the header-line.)

Can you describe the use case you have in mind?

I use gptel mode in a wiki mode (Creole syntax - legacy stuff...) that derives from text-mode. Maybe a more appropriate solution is to have an allow list of derived modes (or even just the modes themselves) in a user configurable value?