[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama a9c48d4416 2/7: Ensure user nick is present at t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ellama a9c48d4416 2/7: Ensure user nick is present at the end of session buffer |
Date: |
Fri, 29 Nov 2024 18:58:09 -0500 (EST) |
branch: externals/ellama
commit a9c48d44164408aa111a277fc69f4d745363ce4b
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>
Ensure user nick is present at the end of session buffer
Ensured that the user's nick is always present at the end of the session
buffer. Added checks and insertions to handle cases where the buffer
might not have the user's nick, especially for new sessions or empty
buffers. Adjusted the insertion points and conditions to maintain
consistency across different scenarios.
---
ellama.el | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/ellama.el b/ellama.el
index a42faa5df8..3c942d0163 100644
--- a/ellama.el
+++ b/ellama.el
@@ -779,6 +779,16 @@ If EPHEMERAL non nil new session will not be associated
with any file."
(save-buffer)
(goto-char (point-min))))
(with-current-buffer buffer
+ ;; support sessions without user nick at the end of buffer
+ (when (not (save-excursion
+ (save-match-data
+ (goto-char (point-max))
+ (and (search-backward (concat
(ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n") nil t)
+ (search-forward (concat
(ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n") nil t)
+ (equal (point) (point-max))))))
+ (goto-char (point-max))
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n")
+ (save-buffer))
(let ((session (read session-buffer)))
(setq ellama--current-session
(make-ellama-session
@@ -1566,7 +1576,7 @@ Extract profession from this message. Be short and
concise."
Will call `ellama-chat-done-callback' and ON-DONE on TEXT."
(save-excursion
(goto-char (point-max))
- (insert "\n\n")
+ (insert "\n\n" (ellama-get-nick-prefix-for-mode) " " ellama-user-nick
":\n")
(when ellama-session-auto-save
(save-buffer)))
(when ellama-chat-done-callback
@@ -1699,9 +1709,12 @@ the full response text when the request completes (with
BUFFER current)."
(with-current-buffer buffer
(save-excursion
(goto-char (point-max))
- (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n"
- (ellama--format-context session) (ellama--fill-long-lines
prompt) "\n\n"
- (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick
":\n")
+ (if (equal (point-min) (point-max)) ;; empty buffer
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick
":\n"
+ (ellama--format-context session) (ellama--fill-long-lines
prompt) "\n\n"
+ (ellama-get-nick-prefix-for-mode) " "
ellama-assistant-nick ":\n")
+ (insert (ellama--format-context session) (ellama--fill-long-lines
prompt) "\n\n"
+ (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick
":\n"))
(ellama-stream prompt
:session session
:on-done (if donecb (list 'ellama-chat-done donecb)
- [elpa] externals/ellama updated (7a714c9114 -> d4927093e2), ELPA Syncer, 2024/11/29
- [elpa] externals/ellama 6ecde6aa8b 5/7: Add display action functions for chat and instant modes, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama 6abe8d46aa 3/7: Add functionality to send last user message, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama a9c48d4416 2/7: Ensure user nick is present at the end of session buffer,
ELPA Syncer <=
- [elpa] externals/ellama 1a3dd96d62 4/7: Add ellama-chat-send-last-message to documentation., ELPA Syncer, 2024/11/29
- [elpa] externals/ellama d4927093e2 7/7: Bump version, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama d8e5659680 6/7: Merge pull request #184 from s-kostyaev/send-message-from-session-buffer, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama b1467d15e0 1/7: Add function to convert org syntax to markdown, ELPA Syncer, 2024/11/29