Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aaronjensen opened this issue Jun 9, 2023 · 4 comments
Open

Comments

@aaronjensen
Copy link
Contributor

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
Copy link
Owner

rougier commented Jun 19, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

rougier commented Jun 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants