gptel-curl: Rename functions for linting

gptel-curl.el (gptel-curl--process-alist, gptel-curl--get-args,
gptel--curl-sentinel, gptel-curl--parse-response): Rename internal
functions and variables to use the `gptel-curl--` prefix instead of
`gptel--curl-`.
This commit is contained in:
Karthik Chikmagalur 2023-03-08 19:23:17 -08:00
parent 65e6d73372
commit 4e35e998a8

View file

@ -34,10 +34,10 @@
(require 'json) (require 'json)
(require 'aio) (require 'aio)
(defvar gptel--curl-process-alist nil (defvar gptel-curl--process-alist nil
"Alist of active GPTel curl requests.") "Alist of active GPTel curl requests.")
(defun gptel--curl-get-args (prompts token) (defun gptel-curl--get-args (prompts token)
"Produce list of arguments for calling Curl. "Produce list of arguments for calling Curl.
PROMPTS is the data to send, TOKEN is a unique identifier." PROMPTS is the data to send, TOKEN is a unique identifier."
@ -72,36 +72,36 @@ PROMPTS is the data to send, TOKEN is a unique identifier."
(let* ((token (md5 (format "%s%s%s%s" (let* ((token (md5 (format "%s%s%s%s"
(random) (emacs-pid) (user-full-name) (random) (emacs-pid) (user-full-name)
(recent-keys)))) (recent-keys))))
(args (gptel--curl-get-args prompts token)) (args (gptel-curl--get-args prompts token))
(process (apply #'start-process "gptel-curl" (current-buffer) (process (apply #'start-process "gptel-curl" (current-buffer)
"curl" args)) "curl" args))
(promise (aio-promise)) (promise (aio-promise))
(cb (lambda (result) (cb (lambda (result)
(aio-resolve promise (lambda () result)) (aio-resolve promise (lambda () result))
(setf (alist-get process (setf (alist-get process
gptel--curl-process-alist nil 'remove) gptel-curl--process-alist nil 'remove)
nil)))) nil))))
(prog1 promise (prog1 promise
(set-process-query-on-exit-flag process nil) (set-process-query-on-exit-flag process nil)
(setf (alist-get process gptel--curl-process-alist) (setf (alist-get process gptel-curl--process-alist)
(list :callback cb :token token)) (list :callback cb :token token))
(set-process-sentinel process #'gptel--curl-sentinel))))) (set-process-sentinel process #'gptel-curl--sentinel)))))
(defun gptel--curl-sentinel (process status) (defun gptel-curl--sentinel (process status)
"Process sentinel for GPTel curl requests. "Process sentinel for GPTel curl requests.
PROCESS and STATUS are process parameters." PROCESS and STATUS are process parameters."
(let ((proc-buf (process-buffer process))) (let ((proc-buf (process-buffer process)))
(if-let* ((ok-p (equal status "finished\n")) (if-let* ((ok-p (equal status "finished\n"))
(proc-info (alist-get process gptel--curl-process-alist)) (proc-info (alist-get process gptel-curl--process-alist))
(proc-token (plist-get proc-info :token)) (proc-token (plist-get proc-info :token))
(content (gptel--curl-parse-response proc-buf proc-token))) (content (gptel-curl--parse-response proc-buf proc-token)))
(funcall (plist-get proc-info :callback) content) (funcall (plist-get proc-info :callback) content)
;; Failed ;; Failed
(funcall (plist-get proc-info :callback) nil)) (funcall (plist-get proc-info :callback) nil))
(kill-buffer proc-buf))) (kill-buffer proc-buf)))
(defun gptel--curl-parse-response (buf token) (defun gptel-curl--parse-response (buf token)
"Parse the buffer BUF with curl's response. "Parse the buffer BUF with curl's response.
TOKEN is used to disambiguate multiple requests in a single TOKEN is used to disambiguate multiple requests in a single