rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.52k stars 194 forks source link

Basic solaire mode functionality #78

Open tefkah opened 3 years ago

tefkah commented 3 years ago

This PR adds the minimum to work with solaire-mode, which darkens non-file-visiting buffers. The values are picked somewhat arbitrarily, but they look nice I think. Should not conflict with non-solaire-mode users.

Dark image

Light image

rougier commented 3 years ago

Thanks! Do you know if it is possible to darken the header line as well in solaire mode?

tefkah commented 3 years ago

Yes, I've been trying to implement it, but it's been rather difficult due to the way the faces in nano-modeline are implemented. Solaire-mode works by remapping the header-line face for certain buffers, but none of the nano-modeline faces inherit from that face. Additionally, header-line is set to be blank by default, but even after changing this it does not work.

I found a way to make it work, but it's extremely cumbersome:

  1. Set the header-line face to the current colors (nano-face-subtle as background)
  2. In nano-modeline, change all the 'face 'nano-header-default definitions to
    `face '(:background (face-background `header-line)
        :foreground (face-foreground `nano-face-header-default)
        :weight (face-attribute`nano-face-header-default :weight))

    You cannot simply inherit from nano-face-header-default and just set the background differently, for some reason that does not work. There's probably a slightly nicer way to do this, but that does not change the nature of it.

The best way would probably be to rewrite nano-headline to use header-line more directly, or to use something else than the strings of concat (propertize) it's has now, but that would be a rather big rewrite, plus kind of against the spirit of nano by not just using the 6 faces.

tefkah commented 3 years ago

From commit [c43b36](https://github.com/rougier/nano-emacs/pull/78/commits/c4d3b46be3c04af217f2f5debe1ab50ef05552c50 the modeline now updates properly, but it did include changing the modeline function somewhat, but luckily less than I'd feared.

Ideally we would set some new colors for the header-line background and foreground face, the current implementation works alright, but it'd be better to lighten the text in the light-theme somewhat, and darken it in the dark-theme. There's probably some clever function you can write for that, but I don't currently know how to, very happy to hear your suggestions!

Light image

Dark image

rougier commented 3 years ago

Wonderful! I'm not sure we can modify the text color without adding a new specific face and I would prefer to avoid that for such a specific case. I think your PR is ready to be merged for me. If you're happy with it, I'll merge.

tefkah commented 3 years ago

I'm happy enough with it, you can merge it!

rougier commented 3 years ago

With the new modeline I managed to have active/inactive face for the header or mode line. Hopefully, this should solved the problem with solaire.