Exafunction / codeium.el

Free, ultrafast Copilot alternative for Emacs
https://www.codeium.com
MIT License
412 stars 13 forks source link

Stopping codeium integration and restarting #106

Closed ghmon closed 2 weeks ago

ghmon commented 2 weeks ago

Due to low computer memory i want sometimes to temporarily stop codeium integration and server, and restart later, both from within emacs, without ending emacs. codeium is loaded on startup.

I have found a solution, see below - but it is very ugly. Is there a better, even documented way?

(defun walk-buffers (fn)
  "Execute function FN in all buffers."
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (funcall fn))))

(defun codeium-server-off()
  (interactive)
  (call-process-shell-command "pkill codeium")
  ;; before emacs 22.1: (shell-command "pkill codeium")
  (remove-hook 'completion-at-point-functions 'codeium-completion-at-point)
  (walk-buffers
   '(lambda ()
      (remove-hook 'completion-at-point-functions 'codeium-completion-at-point t))))

(defun codeium-server-on()
  (interactive)
    (walk-buffers
   '(lambda ()
      (add-hook 'completion-at-point-functions #'codeium-completion-at-point))))
fortenforge commented 2 weeks ago

We don't have any documented way of doing this.

ghmon commented 2 weeks ago

Ok; described way works, at least using one window with several buffers. I close the issue.