-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature: File-extension #32
Feature: File-extension #32
Conversation
Found another case for the [[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" |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I tested it out locally and is working as expected. Can you add a test for this? I've created one, but if you want to do it differently and do a different test that's ok too!
tests/cli_apply_subcommand_tests.rs
:
#[test]
fn test_cli_apply_subcommand_with_config_theme_file_extension() -> Result<()> {
// -------
// Arrange
// -------
let scheme_name = "base16-uwunicorn";
let (config_path, data_path, command_vec, cleanup) = setup(
"test_cli_apply_subcommand_with_custom_schemes",
format!("apply {}", &scheme_name).as_str(),
)?;
let config_content = r#"
[[items]]
path = "https://github.com/tinted-theming/tinted-alacritty"
name = "tinted-alacritty"
themes-dir = "colors"
hook = "echo \"expected alacritty output: %n\""
[[items]]
name = "base16-emacs"
path = "https://github.com/tinted-theming/base16-emacs"
theme-file-extension="-theme.el"
themes-dir="build"
hook = "echo \"expected emacs output: %n\""
"#;
let expected_output =
"expected alacritty output: base16-uwunicorn\nexpected emacs output: base16-uwunicorn\n";
write_to_file(&config_path, config_content)?;
// ---
// Act
// ---
utils::run_install_command(&config_path, &data_path)?;
let (stdout, stderr) = utils::run_command(command_vec).unwrap();
// ------
// Assert
// ------
assert_eq!(stdout, expected_output,);
assert!(
stderr.is_empty(),
"stderr does not contain the expected output"
);
cleanup()?;
Ok(())
}
@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. |
I've published |
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:
-theme.el
custom-theme-directory
(this one is easy)theme name
as the theme provided withintheme name
via emacsclienthurdle 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 thescheme-name
with thetheme-file-extension
together.For example,
base16-nord
normally will look for any file that matchesbase16-nord.*
. Withtheme-file-extension="-theme.el"
,base16-nord
will now match for any file that isbase16-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.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)