emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ellama 8b85207838 1/3: Eliminate eval call


From: ELPA Syncer
Subject: [elpa] externals/ellama 8b85207838 1/3: Eliminate eval call
Date: Sun, 4 Feb 2024 03:57:52 -0500 (EST)

branch: externals/ellama
commit 8b8520783840d81b1d02f6d9a0081e9155fb4348
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>

    Eliminate eval call
---
 ellama.el | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/ellama.el b/ellama.el
index de47eeeb4a..40255c2ef6 100644
--- a/ellama.el
+++ b/ellama.el
@@ -497,7 +497,7 @@ If EPHEMERAL non nil new session will not be associated 
with any file."
           (file-name (ellama-session-file session))
           (session-file-name (ellama--get-session-file-name file-name)))
       (with-temp-file session-file-name
-       (insert "(setq ellama--current-session " (prin1-to-string session) 
")")))))
+       (insert (prin1-to-string session))))))
 
 ;;;###autoload
 (defun ellama-load-session ()
@@ -519,9 +519,29 @@ If EPHEMERAL non nil new session will not be associated 
with any file."
              (buffer (find-file-noselect file-name))
              (session-buffer (find-file-noselect session-file-name)))
     (with-current-buffer session-buffer
-      (goto-char (point-min)))
+      (goto-char (point-min))
+      ;; old sessions support
+      (when (string= "(setq "
+                    (buffer-substring-no-properties 1 7))
+       (goto-char (point-min))
+       ;; skip "("
+       (forward-char)
+       ;; skip setq
+       (forward-sexp)
+       ;; skip ellama--current-session
+       (forward-sexp)
+       ;; skip space
+       (forward-char)
+       ;; remove all above
+       (kill-region (point-min) (point))
+       (goto-char (point-max))
+       ;; remove ")"
+       (delete-char -1)
+       ;; save session in new format
+       (save-buffer)
+       (goto-char (point-min))))
     (with-current-buffer buffer
-      (eval (read session-buffer))
+      (setq ellama--current-session (read session-buffer))
       (setq ellama--current-session-id (ellama-session-id 
ellama--current-session))
       (puthash (ellama-session-id ellama--current-session)
               buffer ellama--active-sessions)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]