tinted-theming / tinty

A base16 and base24 color scheme manager
MIT License
31 stars 3 forks source link

Feature: File-extension #32

Closed 1ynn1ei closed 1 day ago

1ynn1ei commented 5 days ago

There still needs to be tests written and the documentation to be updated, but I wanted to get this out there to get some opinion on it first before committing to those.

First, the requirements for emacs that we are trying to meet:

hurdle one was just properly identifying the emacs scheme files. The addition of an Optional parameter, theme-file-extension works around that: if this parameter is enabled it will search for the scheme-name with the theme-file-extension together.

For example, base16-nord normally will look for any file that matches base16-nord.*. With theme-file-extension="-theme.el", base16-nord will now match for any file that is base16-nord-theme.el. This solves our first hurdle.

The second hurdle is easily handled by hooks, but the third and fourth require an additional macro within the hook: %n, which provides the full scheme name.

[[items]]
name = "base16-emacs"
path = "https://github.com/tinted-theming/base16-emacs"
theme-file-extension="-theme.el"
themes-dir="build"
hook = "cp -f %f ~/.emacs.d/themes/%n-theme.el && emacsclient -e \"(load-theme (quote %n) t)\""

This solves all the issues involved with tinty and supplying an appropriate theme, via tinty apply, to the emacs daemon. There are some other issues, but those are related to my implementation of the hook (will most likely need to be moved into a script for more elegant handling of old -theme.el files, persistent application of the theme, etc.)

Let me know what you think of the solution and please provide feedback. The goal is to get Tinty working with emacs the Tinty way :)

(Related to task #30)

1ynn1ei commented 5 days ago

Found another case for the theme-file-extension to give us a more broad look at what requirements we need to meet.

[[items]]
name = "base16-qutebrowser"
path = "https://github.com/tinted-theming/base16-qutebrowser"
themes-dir = "themes/default"
theme-file-extension = ".config.py"
hook = "cp -f %f ~/.config/qutebrowser/theme.py && pgrep qutebrowser && qutebrowser :config-source"
JamyGolden commented 2 days ago

I just saw this pr manually, it looks like belak was tagged automatically so I didn't get a notification. I'll go through this tomorrow! (or later today I should say)

1ynn1ei commented 2 days ago

@JamyGolden Thank you for writing that test, I would be happy to write them in the future but I appreciate it. Added the test in, passes just fine.

JamyGolden commented 1 day ago

I've published 0.16.0 with the change, thanks for spotting the problem and doing the work!