From d0c685e5014531f4e54b0429464e684490a8c567 Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Fri, 19 Jan 2024 14:19:22 -0800 Subject: [PATCH] gptel: checkdoc linting and indentation rules * gptel.el (gptel-use-header-line, gptel--parse-buffer): Docstrings. * gptel-transient.el (gptel--transient-read-variable): Docstring. * gptel-openai.el (gptel-make-openai, gptel-make-azure): Add indent declaration. * gptel-ollama.el (gptel-make-ollama): Add indent declaration. * gptel-kagi.el (gptel-make-kagi): Add indent declaration. * gptel-gemini.el (gptel-make-gemini): Add indent declaration. --- gptel-gemini.el | 1 + gptel-kagi.el | 1 + gptel-ollama.el | 1 + gptel-openai.el | 4 +++- gptel-transient.el | 9 ++++++--- gptel.el | 7 +++---- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gptel-gemini.el b/gptel-gemini.el index 8910743..27ce987 100644 --- a/gptel-gemini.el +++ b/gptel-gemini.el @@ -135,6 +135,7 @@ alist, like: KEY (optional) is a variable whose value is the API key, or function that returns the key." + (declare (indent 1)) (let ((backend (gptel--make-gemini :name name :host host diff --git a/gptel-kagi.el b/gptel-kagi.el index 5298f3b..8d8b21c 100644 --- a/gptel-kagi.el +++ b/gptel-kagi.el @@ -156,6 +156,7 @@ Example: ------- (gptel-make-kagi \"Kagi\" :key my-kagi-key)" + (declare (indent 1)) stream ;Silence byte-compiler (let ((backend (gptel--make-kagi :name name diff --git a/gptel-ollama.el b/gptel-ollama.el index 605b951..b03de0c 100644 --- a/gptel-ollama.el +++ b/gptel-ollama.el @@ -138,6 +138,7 @@ Example: :host \"localhost:11434\" :models \\='(\"mistral:latest\") :stream t)" + (declare (indent 1)) (let ((backend (gptel--make-ollama :name name :host host diff --git a/gptel-openai.el b/gptel-openai.el index 7000973..1b6c2d8 100644 --- a/gptel-openai.el +++ b/gptel-openai.el @@ -141,7 +141,8 @@ alist, like: ((\"Content-Type\" . \"application/json\")) KEY (optional) is a variable whose value is the API key, or -function that returns the key." +function that returns the key." + (declare (indent 1)) (let ((backend (gptel--make-openai :name name :host host @@ -201,6 +202,7 @@ Example: \"/openai/deployments/DEPLOYMENT_NAME/completions?api-version=2023-05-15\" :stream t :models \\='(\"gpt-3.5-turbo\" \"gpt-4\"))" + (declare (indent 1)) (let ((backend (gptel--make-openai :name name :host host diff --git a/gptel-transient.el b/gptel-transient.el index 5c988c0..8add342 100644 --- a/gptel-transient.el +++ b/gptel-transient.el @@ -257,7 +257,10 @@ Customize `gptel-directives' for task-specific prompts." ;; ** Infixes for model parameters (defun gptel--transient-read-variable (prompt initial-input history) - "Read value from minibuffer and interpret the result as a Lisp object." + "Read value from minibuffer and interpret the result as a Lisp object. + +PROMPT, INITIAL-INPUT and HISTORY are as in the Transient reader +documention." (ignore-errors (read-from-minibuffer prompt initial-input read-expression-map t history))) @@ -322,7 +325,7 @@ will get progressively longer!" :model 'gptel-model :key "-m" :reader (lambda (prompt &rest _) - (let* ((backend-name + (let* ((backend-name (if (<= (length gptel--known-backends) 1) (caar gptel--known-backends) (completing-read @@ -402,7 +405,7 @@ will get progressively longer!" (list (line-beginning-position) (line-end-position)))))) ((member "y" args) (unless (car-safe kill-ring) - (user-error "`kill-ring' is empty! Nothing to send.")) + (user-error "`kill-ring' is empty! Nothing to send")) (if current-prefix-arg (read-from-kill-ring "Prompt from kill-ring: ") (current-kill 0)))))) diff --git a/gptel.el b/gptel.el index f353b98..9ce07c2 100644 --- a/gptel.el +++ b/gptel.el @@ -297,8 +297,7 @@ is only inserted in dedicated gptel buffers before the AI's response." :type '(alist :key-type symbol :value-type string)) (defcustom gptel-use-header-line t - "Whether `gptel-mode' should use header-line for status -information. + "Whether `gptel-mode' should use header-line for status information. When set to nil, use the mode line for (minimal) status information and the echo area for messages." @@ -806,6 +805,7 @@ streamed, as in `gptel-stream'. Do not set this if you are specifying a custom CALLBACK! Model parameters can be let-bound around calls to this function." + (declare (indent 1)) (let* ((gptel-stream stream) (start-marker (cond @@ -985,8 +985,7 @@ there." (gptel--parse-buffer gptel-backend max-entries))))) (cl-defgeneric gptel--parse-buffer (backend max-entries) - "Parse the current buffer backwards from point and return a list -of prompts. + "Parse current buffer backwards from point and return a list of prompts. BACKEND is the LLM backend in use.