branch: externals/ellama commit d78513a5e06bb2402d6d72245d05f3dae98fdafa Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Ensure buffer exists before updating context Ensured that the buffer `ellama--context-buffer` is created if it does not exist before attempting to update and show context. This prevents errors related to non-existent buffers. Also, added calls to `ellama-update-context-show` in both header line and mode line minor modes to ensure context is shown when these modes are toggled. --- ellama.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ellama.el b/ellama.el index b51db7d737..d099a0424b 100644 --- a/ellama.el +++ b/ellama.el @@ -1123,7 +1123,7 @@ the context." "Update and show context in posframe of header line." (declare-function posframe-show "ext:posframe") (declare-function posframe-hide "ext:posframe") - (with-current-buffer ellama--context-buffer + (with-current-buffer (get-buffer-create ellama--context-buffer) (erase-buffer) (if ellama--global-context (insert (format @@ -1168,6 +1168,7 @@ the context." (define-minor-mode ellama-context-header-line-mode "Toggle Ellama Context header line mode." :group 'ellama + (ellama-update-context-show) (add-hook 'window-state-change-hook #'ellama-context-update-header-line) (if ellama-context-header-line-mode (ellama-context-update-header-line) @@ -1192,6 +1193,7 @@ the context." (define-minor-mode ellama-context-mode-line-mode "Toggle Ellama Context mode line mode." :group 'ellama + (ellama-update-context-show) (add-hook 'window-state-change-hook #'ellama-context-update-mode-line) (if ellama-context-mode-line-mode (ellama-context-update-mode-line)