branch: externals/minuet commit f4a49dc75d7f3fd93e36d4efab996cbc25f6821b Author: Milan Glacier <d...@milanglacier.com> Commit: Milan Glacier <d...@milanglacier.com>
chore: fix byte compiler warning. --- minuet.el | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/minuet.el b/minuet.el index 445906349d..4cfac7e04a 100644 --- a/minuet.el +++ b/minuet.el @@ -39,6 +39,8 @@ "Minuet group." :group 'applications) +(declare-function evil-emacs-state-p "evil-states") +(declare-function evil-insert-state-p "evil-states") (defcustom minuet-auto-suggestion-debounce-delay 0.2 "Debounce delay in seconds for auto-suggestions." @@ -46,9 +48,11 @@ :group 'minuet) (defcustom minuet-auto-suggestion-block-functions '(minuet-evil-not-insert-state-p) - "List of functions that determine whether auto-suggestions should be blocked. -Each function should return non-nil if auto-suggestions should be blocked. -If any function in this list returns non-nil, auto-suggestions will not be shown." + "List of functions to determine whether auto-suggestions should be blocked. + +Each function should return non-nil if auto-suggestions should be +blocked. If any function in this list returns non-nil, +auto-suggestions will not be shown." :type '(repeat function) :group 'minuet) @@ -130,14 +134,16 @@ completion item containing only its first line." (defcustom minuet-after-cursor-filter-length 15 "Length of context after cursor used to filter completion text. + Defines the length of non-whitespace context after the cursor used to filter completion text. Set to 0 to disable filtering. -Example: With after_cursor_filter_length = 3 and context: 'def -fib(n):\\n|\\n\\nfib(5)' (where | represents cursor position), if the -completion text contains 'fib', then 'fib' and subsequent text will be -removed. This setting filters repeated text generated by the LLM. A -large value (e.g., 15) is recommended to avoid false positives." +Example: With after_cursor_filter_length = 3 and context: \"def +fib(n):\\n|\\n\\nfib(5)\" (where | represents cursor position), if the +completion text contains \"fib\", then \"fib\" and subsequent text +will be removed. This setting filters repeated text generated by the +LLM. A large value (e.g., 15) is recommended to avoid false +positives." :type 'integer :group 'minuet) @@ -320,7 +326,8 @@ symbol, return its value. Else return itself." (setq minuet--current-requests nil))) (defun minuet--cleanup-suggestion (&optional no-cancel) - "Remove the current suggestion overlay and cancel any pending requests unless NO-CANCEL is t." + "Remove the current suggestion overlay. +Also cancel any pending requests unless NO-CANCEL is t." (unless no-cancel (minuet--cancel-requests)) (when minuet--current-overlay @@ -386,7 +393,7 @@ symbol, return its value. Else return itself." (let ((prev-index (mod (1- minuet--current-suggestion-index) (length minuet--current-suggestions)))) (minuet--display-suggestion minuet--current-suggestions prev-index)) - (funcall minuet-show-suggestion))) + (minuet-show-suggestion))) ;;;###autoload (defun minuet-show-suggestion () @@ -529,7 +536,8 @@ Also print the MESSAGE when MESSAGE-P is t." items)) (defun minuet--filter-context-sequence-in-items (items context) - "Obtain the filter sequence from CONTEXT, and apply the filter sequence in each item in ITEMS." + "Apply the filter sequence in each item in ITEMS. +The filter sequence is obtained from CONTEXT." (minuet--filter-sequence-in-items items (minuet--make-context-filter-sequence (plist-get context :after-cursor) @@ -540,12 +548,12 @@ Also print the MESSAGE when MESSAGE-P is t." (setq response (split-string response "[\r]?\n")) (let (result) (dolist (line response) - (if-let* ((json (condition-case err + (if-let* ((json (condition-case _ (json-parse-string (replace-regexp-in-string "^data: " "" line) :object-type 'plist :array-type 'list) (error nil))) - (text (condition-case err + (text (condition-case _ (funcall get-text-fn json) (error nil)))) (when (and (stringp text) @@ -565,7 +573,10 @@ Also print the MESSAGE when MESSAGE-P is t." (push text ,response))) (defun minuet--stream-decode-raw (response get-text-fn) - "Decode the raw stream stored in the temp variable create by `minuet--make-process-stream-filter' from RESPONSE and GET-TEXT-FN." + "Decode the raw stream used by minuet. + +RESPONSE will be stored in the temp variable create by +`minuet--make-process-stream-filter' parsed by GET-TEXT-FN." (when-let* ((response (nreverse response)) (response (apply #'concat response))) (minuet--stream-decode response get-text-fn))) @@ -711,7 +722,7 @@ Return nil if not exists or is an empty string." (n-completions-template (plist-get template :n-completions-template)) (n-completions-template (minuet--eval-value n-completions-template)) (n-completions-template (if (stringp n-completions-template) - (format n-completions-template (or minuet-n-completions 1)) + (format n-completions-template n-completions) ""))) (setq tmpl (replace-regexp-in-string "{{{:n-completions-template}}}" n-completions-template @@ -806,7 +817,7 @@ CONTEXT and CALLBACK will be passed to the base function." callback)) (defun minuet--openai-fim-get-text-fn (json) - "Function to get the completion from a JSON object for openai-fim compatible service." + "Function to get the completion from a JSON object for openai-fim compatible." (--> json (plist-get it :choices) car @@ -1039,7 +1050,7 @@ When enabled, Minuet will automatically show suggestions while you type." :keymap minuet-active-mode-map) ;;;###autoload -(define-obsolete-function-alias 'minuet-completion-in-region 'minuet-complete-with-minibuffer "0.2") +(define-obsolete-function-alias 'minuet-completion-in-region #'minuet-complete-with-minibuffer "0.2") (provide 'minuet) ;;; minuet.el ends here