tarsius / moody

Tabs and ribbons for the mode-line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Direct support for theming moody

Koekelas opened this issue · comments

Reusing the faces mode-line and mode-line-inactive works well for tabs but not always for ribbons. For example, a dark foreground with a light background and a dark border or the inverse results in unreadable ribbons. Yes, one can pass alternate faces to moody-ribbon, however, that requires defining faces, i.e., difficult to support by themes. As it currently stands, one has to modify the faces anyway, couldn't moody define its own faces which themes can target? Open to suggestions. Whatever you decide, thank you in advance.

IMO this is not necessary but it would take me quite a few paragraphs to more or less explain why that is so. Since you have already said you would accept my decision, I am just taking the shortcut here. Sorry.

I expected this to be rejected, it would break every Moody user's configuration. In retrospect, what I wanted was feedback and feedback I got, thank you.

For those stumbling upon this, I made this request after I requested the Modus themes to support Moody. Ribbons proved to be troublesome, the border color needs to contrast not only with the foreground but also with the background color. For this situation, Emacs provides the face attribute :distant-foreground. From the Elisp manual:

‘:distant-foreground’
     Alternative foreground color, a string.  This is like ‘:foreground’
     but the color is only used as a foreground when the background
     color is near to the foreground that would have been used.  This is
     useful for example when marking text (i.e., the region face).  If
     the text has a foreground that is visible with the region face,
     that foreground is used.  If the foreground is near the region face
     background, ‘:distant-foreground’ is used instead so the text is
     readable.

The variable face-near-same-color-threshold controls when :distant-foreground is chosen over :foreground. While color distance isn't a substitute for color contrast, it's a good heuristic. The default is rather low.

Thanks for the hint.

@Koekelas what do you do now that modus-themes-mode-line has been removed? https://protesilaos.com/emacs/modus-themes-changelog

@p00f, support for Moody was removed in Modus Themes 4. It's easy to add support ourselves (untested):

(defun setup-modus-themes-moody-faces ()
  "Setup faces used by Moody.
Intended to be called after loading one of the Modus Themes, see
`modus-themes-load-theme'."
  (modus-themes-with-colors
    (custom-set-faces
     `(mode-line          ((,c
                            :box unspecified
                            :overline ,border-mode-line-active
                            :underline ,border-mode-line-active)))
     `(mode-line-inactive ((,c
                            :box unspecified
                            :overline ,border-mode-line-inactive
                            :underline ,border-mode-line-inactive))))))

(add-hook 'modus-themes-after-load-theme-hook #'setup-modus-themes-moody-faces)

For information on custom-set-faces, see Applying Customizations (Emacs Lisp Reference Manual). For information on modus-themes-with-colors, see Use theme colors in code with modus-themes-with-colors (Modus Themes Manual). For a load theme hook not tied to the Modus Themes, see A theme-agnostic hook for theme loading (Modus Themes Manual). For inspiration on configuring the Modus Themes, see the manual, or the relevant part of my dotfiles (GitHub) (work in progress, missing docstrings).

I just noticed Moody is still listed as supported, it must be removed.