diff --git a/copilot.el b/copilot.el index a1340a6693edc3f989df661ace4dcbb97e991ebd..1a8a7509f28926909e67963535cec957de0d0dcc 100644 --- a/copilot.el +++ b/copilot.el @@ -69,7 +69,7 @@ (inhibit-quit t) (curfile (buffer-file-name)) (lang (file-name-extension curfile)) - (promptfile (concat curfile ".prompt")) + ;; extract the entire buffer up to the current position (code (save-excursion (beginning-of-buffer) @@ -91,9 +91,6 @@ Only output the missing parts of the code. \ Generate %s code to complete the following snippet:\n```%s\n%s" system context lang lang code))) - ;; write out the prompt to a temporary file - (write-region prompt nil promptfile 'silent) - ;; run ollama streaming stdout into buffer catching ctrl-g (with-local-quit (copilot--run-ollama prompt)) @@ -109,10 +106,7 @@ Generate %s code to complete the following snippet:\n```%s\n%s" (goto-char spot) (while (re-search-forward "```[a-z]*" end t) (setq end (- end (length (match-string 0)))) - (replace-match "")))) - - ;; remove temporary files - (delete-file promptfile))) + (replace-match "")))))) ;; define `ctrl-c ctrl-k` keybinding for llm code completion (defun copilot-c-hook ()