branch: externals/ellama commit 40a4680982254a1a1fdea54fae52dae63f89275b Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Convert Org mode content to Markdown before adding to context Added functionality to convert Org mode content to Markdown when extracting buffer or file content for the context. This ensures that any Org mode files are properly formatted as Markdown before being processed further. --- ellama.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ellama.el b/ellama.el index 116af5a7d9..67301e5187 100644 --- a/ellama.el +++ b/ellama.el @@ -1115,7 +1115,11 @@ If EPHEMERAL non nil new session will not be associated with any file." "Extract the content of the context ELEMENT." (with-slots (name) element (with-current-buffer name - (buffer-substring-no-properties (point-min) (point-max))))) + (let* ((data (buffer-substring-no-properties (point-min) (point-max))) + (content (if (derived-mode-p 'org-mode) + (ellama-convert-org-to-md data) + data))) + content)))) (cl-defmethod ellama-context-element-display ((element ellama-context-element-buffer)) @@ -1189,7 +1193,11 @@ If EPHEMERAL non nil new session will not be associated with any file." (with-slots (name) element (with-temp-buffer (insert-file-contents name) - (buffer-substring-no-properties (point-min) (point-max))))) + (let* ((data (buffer-substring-no-properties (point-min) (point-max))) + (ext (file-name-extension name))) + (if (string= ext "org") + (ellama-convert-org-to-md data) + data))))) (cl-defmethod ellama-context-element-display ((element ellama-context-element-file)) @@ -1503,7 +1511,10 @@ If EPHEMERAL non nil new session will not be associated with any file." "Add active region to context." (interactive) (if (region-active-p) - (let* ((content (buffer-substring-no-properties (region-beginning) (region-end))) + (let* ((data (buffer-substring-no-properties (region-beginning) (region-end))) + (content (if (derived-mode-p 'org-mode) + (ellama-convert-org-to-md data) + data)) (file-name (buffer-file-name)) (buffer-name (buffer-name (current-buffer))) (element (if file-name