Repository: alacritty/alacritty (language: rust)

Issue:
Warnings when using OS-specific keys on alternative OSes
### System

OS: Linux/macOS
Version: alacritty 0.14.0-dev
Linux/BSD: X11/i3WM

I share my Alacritty config between my work Mac and my personal laptop. I've recently migrated my config to TOML and I now see a warning about unused keys for `option_as_alt`. This is a valid key on Mac OS, but not on Linux, so I'm receiving the warning only on Linux.

Is there a way to suppress this warning?


Discussion / hints:
Use imports (and symlink needed os specific config) or git.
~Looks like I can set `debug.log_level` to `Error` to suppress them (which saves me having to manage multiple config files).~

EDIT: Nope, that doesn't stop the warning appearing in my terminal...
We probably shouldn't warn for unused keys that are valid on other operating systems. We can just add the options for all systems and not read them.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12df09f9172..79893703f87 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - CLI env variables clearing configuration file variables
 - Vi inline search/semantic selection expanding across newlines
 
+### Changed
+
+- No unused-key warnings will be emitted for OS-specific config keys
+
 ## 0.13.1
 
 ### Added
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index 9e98941948f..794cb04d4da 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -120,7 +120,6 @@ pub enum Action {
     /// Store current selection into clipboard.
     Copy,
 
-    #[cfg(not(any(target_os = "macos", windows)))]
     /// Store current selection into selection buffer.
     CopySelection,
 
@@ -167,7 +166,6 @@ pub enum Action {
     Hide,
 
     /// Hide all windows other than Alacritty on macOS.
-    #[cfg(target_os = "macos")]
     HideOtherApplications,
 
     /// Minimize the Alacritty window.
@@ -182,58 +180,45 @@ pub enum Action {
     /// Spawn a new instance of Alacritty.
     SpawnNewInstance,
 
-    #[cfg(target_os = "macos")]
     /// Select next tab.
     SelectNextTab,
 
-    #[cfg(target_os = "macos")]
     /// Select previous tab.
     SelectPreviousTab,
 
-    #[cfg(target_os = "macos")]
     /// Select the first tab.
     SelectTab1,
 
-    #[cfg(target_os = "macos")]
     /// Select the second tab.
     SelectTab2,
 
-    #[cfg(target_os = "macos")]
     /// Select the third tab.
     SelectTab3,
 
-    #[cfg(target_os = "macos")]
     /// Select the fourth tab.
     SelectTab4,
 
-    #[cfg(target_os = "macos")]
     /// Select the fifth tab.
     SelectTab5,
 
-    #[cfg(target_os = "macos")]
     /// Select the sixth tab.
     SelectTab6,
 
-    #[cfg(target_os = "macos")]
     /// Select the seventh tab.
     SelectTab7,
 
-    #[cfg(target_os = "macos")]
     /// Select the eighth tab.
     SelectTab8,
 
-    #[cfg(target_os = "macos")]
     /// Select the ninth tab.
     SelectTab9,
 
-    #[cfg(target_os = "macos")]
     /// Select the last tab.
     SelectLastTab,
 
     /// Create a new Alacritty window.
     CreateNewWindow,
 
-    #[cfg(target_os = "macos")]
     /// Create new window in a tab.
     CreateNewTab,
 
@@ -244,7 +229,6 @@ pub enum Action {
     ToggleMaximized,
 
     /// Toggle simple fullscreen on macOS.
-    #[cfg(target_os = "macos")]
     ToggleSimpleFullscreen,
 
     /// Clear active selection.
diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs
index ed84622ef99..380f7a6f840 100644
--- a/alacritty/src/config/window.rs
+++ b/alacritty/src/config/window.rs
@@ -48,7 +48,6 @@ pub struct WindowConfig {
     pub blur: bool,
 
     /// Controls which `Option` key should be treated as `Alt`.
-    #[cfg(target_os = "macos")]
     option_as_alt: OptionAsAlt,
 
     /// Resize increments.
@@ -80,7 +79,6 @@ impl Default for WindowConfig {
             dynamic_padding: Default::default(),
             resize_increments: Default::default(),
             decorations_theme_variant: Default::default(),
-            #[cfg(target_os = "macos")]
             option_as_alt: Default::default(),
         }
     }
@@ -176,7 +174,6 @@ pub enum StartupMode {
     Windowed,
     Maximized,
     Fullscreen,
-    #[cfg(target_os = "macos")]
     SimpleFullscreen,
 }
 
@@ -184,9 +181,7 @@ pub enum StartupMode {
 pub enum Decorations {
     #[default]
     Full,
-    #[cfg(target_os = "macos")]
     Transparent,
-    #[cfg(target_os = "macos")]
     Buttonless,
     None,
 }
@@ -280,7 +275,6 @@ impl<'de> Deserialize<'de> for Class {
     }
 }
 
-#[cfg(target_os = "macos")]
 #[derive(ConfigDeserialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
 pub enum OptionAsAlt {
     /// The left `Option` key is treated as `Alt`.
diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs
index 5e8a4bfd664..5bc95bdf159 100644
--- a/alacritty/src/input/mod.rs
+++ b/alacritty/src/input/mod.rs
@@ -410,7 +410,7 @@ impl<T: EventListener> Execute<T> for Action {
             Action::SelectTab9 => ctx.window().select_tab_at_index(8),
             #[cfg(target_os = "macos")]
             Action::SelectLastTab => ctx.window().select_last_tab(),
-            Action::ReceiveChar | Action::None => (),
+            _ => (),
         }
     }
 }


Test patch: