branch: externals/ellama
commit f36cf928e435f639bc9c36eb1e30c2dacacfd810
Author: Sergey Kostyaev <sskosty...@gmail.com>
Commit: Sergey Kostyaev <sskosty...@gmail.com>

    Refactor marker setting logic
    
    Introduced a new function `ellama-set-markers` to encapsulate the
    logic for setting markers. This refactoring improves code readability
    and maintainability by reducing duplication and centralizing the
    marker-setting logic.
---
 ellama.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ellama.el b/ellama.el
index 8defd63a87..dcb25ea3b1 100644
--- a/ellama.el
+++ b/ellama.el
@@ -1875,10 +1875,7 @@ failure (with BUFFER current).
                  (undo-amalgamate-change-group ellama--change-group)))))
        (setq ellama--change-group (prepare-change-group))
        (activate-change-group ellama--change-group)
-       (set-marker start point)
-       (set-marker end point)
-       (set-marker-insertion-type start nil)
-       (set-marker-insertion-type end t)
+       (ellama-set-markers start end point)
        (spinner-start ellama-spinner-type)
        (let ((request (llm-chat-streaming provider
                                           llm-prompt
@@ -1923,6 +1920,13 @@ failure (with BUFFER current).
          (with-current-buffer buffer
            (setq ellama--current-request request)))))))
 
+(defun ellama-set-markers (start end point)
+  "Set markers for START and END positions at POINT."
+  (set-marker start point)
+  (set-marker end point)
+  (set-marker-insertion-type start nil)
+  (set-marker-insertion-type end t))
+
 (defun ellama-chain (initial-prompt forms &optional acc)
   "Call chain of FORMS on INITIAL-PROMPT.
 ACC will collect responses in reverse order (previous answer will be on top).

Reply via email to