branch: externals/ellama
commit 4026bd66d47896ea31e0df95c3067baffb9fbaca
Author: Alex Bennée <[email protected]>
Commit: Alex Bennée <[email protected]>
ellama-context: add new static method to indicate quotes
A quote is a subset of a full buffer/file which will be useful for
enriching summary information. As the methods don't actually use
element in the body I had to preface them with _ to get the compiler
to ignore them.
---
ellama-context.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ellama-context.el b/ellama-context.el
index ff0e82ff24..dcdb1a263a 100644
--- a/ellama-context.el
+++ b/ellama-context.el
@@ -332,6 +332,9 @@ the context."
(cl-defgeneric ellama-context-element-format (element mode)
"Format the context ELEMENT for the major MODE.")
+(cl-defgeneric ellama-context-element-quote-p (element)
+ "Return t is ELEMENT is a quote, nil otherwise.")
+
(cl-defmethod ellama-context-element-add ((element ellama-context-element))
"Add the ELEMENT to the Ellama context."
(setf ellama-context-global (nreverse ellama-context-global))
@@ -350,6 +353,10 @@ the context."
(get-buffer-create ellama--context-buffer t)
(ellama-context-update-show))
+(cl-defmethod ellama-context-element-quote-p ((_element
ellama-context-element))
+ "Return t is ELEMENT is a quote, nil otherwise."
+ nil)
+
;; Buffer context element
(defclass ellama-context-element-buffer (ellama-context-element)
@@ -427,6 +434,11 @@ the context."
(format "[[%s][%s]] [[elisp:(display-buffer \"%s\")][show]]"
name name (ellama-context--quote-buffer content)))))
+(cl-defmethod ellama-context-element-quote-p
+ ((_element ellama-context-element-buffer-quote))
+ "Return t to indicate this `ELEMENT' is a quote."
+ t)
+
;; File context element
(defclass ellama-context-element-file (ellama-context-element)
@@ -617,6 +629,11 @@ the context."
(format "[[%s][%s]] [[elisp:(display-buffer \"%s\")][show]]"
url name (ellama-context--quote-buffer content)))))
+(cl-defmethod ellama-context-element-quote-p
+ ((_element ellama-context-element-webpage-quote))
+ "Return t to indicate this `ELEMENT' is a quote."
+ t)
+
;; Info node quote context elements
(defclass ellama-context-element-info-node-quote (ellama-context-element)
@@ -669,6 +686,11 @@ the context."
name)
(ellama-context--quote-buffer content)))))
+(cl-defmethod ellama-context-element-quote-p
+ ((_element ellama-context-element-info-node-quote))
+ "Return t to indicate this `ELEMENT' is a quote."
+ t)
+
;; File quote context elements
(defclass ellama-context-element-file-quote (ellama-context-element)
@@ -710,6 +732,10 @@ the context."
(format "[[%s][%s]] [[elisp:(display-buffer \"%s\")][show]]"
path path (ellama-context--quote-buffer content)))))
+(cl-defmethod ellama-context-element-quote-p
+ ((_element ellama-context-element-file-quote))
+ "Return t to indicate this `ELEMENT' is a quote."
+ t)
;;;###autoload
(defun ellama-context-add-file (&optional ephemeral)