[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama a93b48f120 1/2: Use more meaningful buffer names
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ellama a93b48f120 1/2: Use more meaningful buffer names. |
Date: |
Sun, 7 Jan 2024 15:57:44 -0500 (EST) |
branch: externals/ellama
commit a93b48f12050da14fe5d192167905d03f02e21d3
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>
Use more meaningful buffer names.
Fixes #33
---
NEWS.org | 2 ++
README.md | 2 ++
ellama.el | 24 ++++++++++++++++++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 2c5ed4a2ed..e69f41d6ea 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,5 @@
+* Version 0.5.1
+- Use more meaningful buffer names.
* Version 0.5.0
- Eliminate aliases.
* Version 0.4.14
diff --git a/README.md b/README.md
index 18285391f9..1088ff8edf 100644
--- a/README.md
+++ b/README.md
@@ -209,6 +209,8 @@ documentation](https://elpa.gnu.org/packages/llm.html)
automatically during generation. Disabled by default.
- `ellama-fill-paragraphs`: Option to customize ellama paragraphs
filling behaviour.
+- `ellama-name-prompt-words-count`: Count of words in prompt to
+ generate name.
## Acknowledgments
diff --git a/ellama.el b/ellama.el
index fb7e775728..f3a2648033 100644
--- a/ellama.el
+++ b/ellama.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/s-kostyaev/ellama
;; Keywords: help local tools
;; Package-Requires: ((emacs "28.1") (llm "0.6.0") (spinner "1.7.4"))
-;; Version: 0.5.0
+;; Version: 0.5.1
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023
@@ -164,6 +164,11 @@
(function :tag "By predicate")
(repeat :tag "In specific modes" (symbol))))
+(defcustom ellama-name-prompt-words-count 5
+ "Count of words in prompt to generate name."
+ :group 'ellama
+ :type 'integer)
+
(defvar-local ellama--chat-prompt nil)
(defvar-local ellama--change-group nil)
@@ -192,6 +197,18 @@
;; If ellama-enable-keymap is nil, remove the key bindings
(define-key global-map (kbd ellama-keymap-prefix) nil))))
+(defun ellama-generate-name (action prompt)
+ "Generate name for ellama ACTION according to PROMPT."
+ (let ((prompt-words (split-string prompt)))
+ (string-join
+ (flatten-tree
+ (list (split-string (format "%s" action) "-")
+ (seq-take prompt-words ellama-name-prompt-words-count)
+ (if (> (length prompt-words) ellama-name-prompt-words-count)
+ "..."
+ nil)))
+ " ")))
+
(defun ellama-stream (prompt &rest args)
"Query ellama for PROMPT.
ARGS contains keys for fine control.
@@ -334,7 +351,10 @@ when the request completes (with BUFFER current)."
(defun ellama-instant (prompt)
"Prompt ellama for PROMPT to reply instantly."
- (let ((buffer (get-buffer-create (make-temp-name ellama-buffer))))
+ (let* ((buffer-name (ellama-generate-name real-this-command prompt))
+ (buffer (get-buffer-create (if (get-buffer buffer-name)
+ (make-temp-name (concat buffer-name "
"))
+ buffer-name))))
(display-buffer buffer)
(ellama-stream prompt :buffer buffer (point-min))))