Open aaronjensen opened 1 year ago
I'm not sure to get the point here. We only want to modify the header (or mode) line face when nano-modeline is in use, no?
Yes, but the recommendation for setting a default is to invoke (nano-modeline-text-mode t)
. That will result in that line only applying to the current buffer:
(defun nano-modeline-header (left &optional right default)
"Install a header line made of LEFT and RIGHT parts. Line can be
made DEFAULT."
(require 'tooltip)
(if default
(setq-default header-line-format (nano-modeline--make left right 'header))
(setq-local header-line-format (nano-modeline--make left right 'header)))
;; Everything below here only applies to the current buffer (aside from the things that are not buffer local, of course)
(make-local-variable 'nano-modeline--buttons)
(setq nano-modeline--buttons nil)
(advice-add 'tooltip-hide :before #'nano-modeline--reset-button-state)
(face-remap-set-base 'header-line 'nano-modeline--empty-face)
(add-hook 'post-command-hook #'nano-modeline--update-selected-window))
I do this instead:
(add-hook 'after-change-major-mode-hook #'aj-nano-modeline)
(defun aj-nano-modeline ()
"Set modeline accordingly"
(cond ((derived-mode-p 'prog-mode)
(aj-nano-modeline-prog-mode))
((derived-mode-p 'vterm-mode))
(t
(aj-nano-modeline-text-mode))))
Oh, I got it. I see your solution but this is precisely what I wanted to avoid even though it is now a hook. I wonder if there's a better solution.
Specifically this line does not apply to every buffer:
Because of that, any buffer that does not have an explicit hook to establish a modeline format will use header-line as the basis, rather than default.