branch: externals/ellama commit ee030435d480df28ef9872d1ae059ac855c2928b Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Add option to always show context line in header or mode line Added new customization option `ellama-context-line-always-visible` to ensure the context header or mode line is always visible, even when there is no content in the context. Updated relevant functions to incorporate this new option. Fix #237 --- README.org | 2 ++ ellama.el | 32 +++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index 1bda4fb572..6e5c2a6ad5 100644 --- a/README.org +++ b/README.org @@ -444,6 +444,8 @@ argument generated text string. ~display-buffer-same-window~. - ~ellama-preview-context-element-display-action-function~: Display action function for ~ellama-preview-context-element~. +- ~ellama-context-line-always-visible~: Make context header or mode line always + visible, even with empty context. ** Minor modes diff --git a/ellama.el b/ellama.el index 23a0ff6007..694057b0e4 100644 --- a/ellama.el +++ b/ellama.el @@ -131,6 +131,11 @@ Make reasoning models more useful for many cases." :group 'ellama :type 'boolean) +(defcustom ellama-context-line-always-visible nil + "Make context header or mode line always visible, even with empty context." + :group 'ellama + :type 'boolean) + (defcustom ellama-command-map (let ((map (make-sparse-keymap))) ;; code @@ -1085,15 +1090,16 @@ If EPHEMERAL non nil new session will not be associated with any file." (declare-function posframe-hide "ext:posframe") (with-current-buffer ellama--context-buffer (erase-buffer) - (when ellama--global-context - (insert (format - " ellama ctx: %s" - (string-join - (mapcar - (lambda (el) - (ellama-context-element-display el)) - ellama--global-context) - " "))))) + (if ellama--global-context + (insert (format + " ellama ctx: %s" + (string-join + (mapcar + (lambda (el) + (ellama-context-element-display el)) + ellama--global-context) + " "))) + (insert " ellama ctx"))) (when ellama-context-posframe-enabled (require 'posframe) (if ellama--global-context @@ -1139,7 +1145,9 @@ If EPHEMERAL non nil new session will not be associated with any file." (defun ellama-context-update-header-line () "Update and display context information in the header line." - (if (and ellama-context-header-line-mode ellama--global-context) + (if (and ellama-context-header-line-mode + (or ellama-context-line-always-visible + ellama--global-context)) (add-to-list 'header-line-format '(:eval (ellama-context-line)) t) (setq header-line-format (delete '(:eval (ellama-context-line)) header-line-format)))) @@ -1165,7 +1173,9 @@ If EPHEMERAL non nil new session will not be associated with any file." (defun ellama-context-update-mode-line () "Update and display context information in the mode line." - (if (and ellama-context-mode-line-mode ellama--global-context) + (if (and ellama-context-mode-line-mode + (or ellama-context-line-always-visible + ellama--global-context)) (add-to-list 'mode-line-format '(:eval (ellama-context-line)) t) (setq mode-line-format (delete '(:eval (ellama-context-line)) mode-line-format))))