copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.71k stars 122 forks source link

Add customization to disable max char warning #311

Closed Gleek closed 4 weeks ago

Gleek commented 1 month ago

Completions work well enough for me even when the file is truncated. Getting a warning every time is therefore unecessary.

amake commented 4 weeks ago

This has been suggested and rejected in #273.

However I also came here with the intent to ask for this sort of feature. My problem is that I get warnings like the below when I update packages via e.g. package-update-all.

⛔ Warning (copilot):  *temp*-529187 size exceeds 'copilot-max-char' (100000), copilot completions may not work

I am activating copilot-mode in prog-mode-hook, so I assume that it's catching large Elisp files that are opened at package install time. I do want copilot-mode in regular Elisp files, so I don't think it's feasible to be more selective about what hook I put it on.

Would it make sense to have copilot ignore buffers with the *temp*- prefix?

Gleek commented 4 weeks ago

Got it. I missed that this has already been addressed. I'll close this here. Thanks for pointing out.

I think you could disable copilot for such buffers, as @emil-vdw suggested in the original issue thread. Maybe you could modify it slightly to handle your case specifically. Something like:

(defun my/activate-copilot ()
  (if (or (> (buffer-size) copilot-max-char)
          (string-prefix-p "*temp*-" (buffer-name)))
      ;; Or don't even warn to get rid of it.
      (warn "Buffer size exceeds copilot max char limit or buffer is temporary. Copilot will not be activated.")
    (copilot-mode)))
amake commented 4 weeks ago

My position is that I shouldn't have to concoct my own custom activation mechanism to avoid warnings during normal Emacs operations like updating a package. I think that's something that copilot should handle out of the box.

Gleek commented 4 weeks ago

Understand what you're saying now. I suppose this could be discussed in a dedicated issue of it's own.