Skip to content

Commit

Permalink
Enhance header line format handling in ellama.el
Browse files Browse the repository at this point in the history
Ensure that modifications to the `header-line-format` only occur when it is a
list. This prevents errors when `header-line-format` is not a list, such as
when magit set it to string.
  • Loading branch information
s-kostyaev committed Feb 22, 2025
1 parent 4340f71 commit 7ac470c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ellama.el
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,8 @@ the context."
(add-hook 'window-state-change-hook #'ellama-context-update-header-line)
(if ellama-context-header-line-mode
(ellama-context-update-header-line)
(setq header-line-format (delete '(:eval (ellama-context-line)) header-line-format))))
(when (listp header-line-format)
(setq header-line-format (delete '(:eval (ellama-context-line)) header-line-format)))))

;;;###autoload
(define-globalized-minor-mode ellama-context-header-line-global-mode
Expand All @@ -1166,11 +1167,12 @@ the context."

(defun ellama-context-update-header-line ()
"Update and display context information in the header line."
(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))))
(when (listp header-line-format)
(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)))))

;;;###autoload
(define-minor-mode ellama-context-mode-line-mode
Expand Down

0 comments on commit 7ac470c

Please sign in to comment.