rougier / nano-modeline

GNU Emacs / N Λ N O Modeline
GNU General Public License v3.0
170 stars 29 forks source link

Setting a default modeline results in different faces being used #58

Open aaronjensen opened 1 year ago

aaronjensen commented 1 year ago

Specifically this line does not apply to every buffer:

  (face-remap-set-base 'header-line 'nano-modeline--empty-face)

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.

rougier commented 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?

aaronjensen commented 1 year ago

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))
aaronjensen commented 1 year ago

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))))
rougier commented 1 year ago

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.