Tuomo,

I got a bug report about warnings for keysym translation failure for
some of the standard bindings: http://bugs.debian.org/488673

Some of the standard bindings refer to keys that aren't in all keymaps
(e.g. Home in this case).  Thankfully they are redundant with other
bindings.  So it seems like it would be OK to suppress the warnings for
those bindings.

I came up with a patch that makes that change, which I'd like to apply
to the Debian package.  What do you think of this approach?
Unfortunately it changes the signature of ioncore_parse_keybut() which
means an ABI break - maybe you can think of a better way to pass in the
new flag.

Ben.

--- ion3.orig/etc/cfg_menu.lua
+++ ion3/etc/cfg_menu.lua
@@ -9,14 +9,14 @@
 
 defbindings("WMenu", {
     bdoc("Close the menu."),
-    kpress("Escape", "WMenu.cancel(_)"),
+    kpress("Escape", "WMenu.cancel(_)", nil, true),
     kpress("Control+G", "WMenu.cancel(_)"),
     kpress("Control+C", "WMenu.cancel(_)"),
     kpress("Left", "WMenu.cancel(_)"),
     
     bdoc("Activate current menu entry."),
     kpress("Return",  "WMenu.finish(_)"),
-    kpress("KP_Enter", "WMenu.finish(_)"),
+    kpress("KP_Enter", "WMenu.finish(_)", nil, true),
     kpress("Control+M", "WMenu.finish(_)"),
     kpress("Right", "WMenu.finish(_)"),
     
--- ion3.orig/etc/cfg_query.lua
+++ ion3/etc/cfg_query.lua
@@ -17,8 +17,8 @@
     bdoc("Go to end/beginning."),
     kpress("Control+E", "WEdln.eol(_)"),
     kpress("Control+A", "WEdln.bol(_)"),
-    kpress("End", "WEdln.eol(_)"),
-    kpress("Home", "WEdln.bol(_)"),
+    kpress("End", "WEdln.eol(_)", nil, true),
+    kpress("Home", "WEdln.bol(_)", nil, true),
     
     bdoc("Skip one word forward/backward."),
     kpress("Control+X", "WEdln.skip_word(_)"),
@@ -26,7 +26,7 @@
 
     bdoc("Delete next character."),
     kpress("Control+D", "WEdln.delete(_)"),
-    kpress("Delete", "WEdln.delete(_)"),
+    kpress("Delete", "WEdln.delete(_)", nil, true),
     
     bdoc("Delete previous character."),
     kpress("BackSpace", "WEdln.backspace(_)"),
@@ -87,21 +87,21 @@
     bdoc("Close the query and execute bound action."),
     kpress("Control+M", "WEdln.finish(_)"),
     kpress("Return", "WEdln.finish(_)"),
-    kpress("KP_Enter", "WEdln.finish(_)"),
+    kpress("KP_Enter", "WEdln.finish(_)", nil, true),
 })
 
 
 defbindings("WInput", {
     bdoc("Close the query/message box, not executing bound actions."),
-    kpress("Escape", "WInput.cancel(_)"),
+    kpress("Escape", "WInput.cancel(_)", nil, true),
     kpress("Control+G", "WInput.cancel(_)"),
     kpress("Control+C", "WInput.cancel(_)"),
     
     bdoc("Scroll the message or completions up/down."),
     kpress("Control+U", "WInput.scrollup(_)"),
     kpress("Control+V", "WInput.scrolldown(_)"),
-    kpress("Page_Up", "WInput.scrollup(_)"),
-    kpress("Page_Down", "WInput.scrolldown(_)"),
+    kpress("Page_Up", "WInput.scrollup(_)", nil, true),
+    kpress("Page_Down", "WInput.scrolldown(_)", nil, true),
 })
 
 
--- ion3.orig/ioncore/conf-bindings.c
+++ ion3/ioncore/conf-bindings.c
@@ -55,7 +55,7 @@
 
 
 bool ioncore_parse_keybut(const char *str, uint *mod_ret, uint *ksb_ret,
-                          bool button, bool init_any)
+                          bool button, bool init_any, bool quiet_absent)
 {
     char *str2, *p, *p2;
     int keysym=NoSymbol, i;
@@ -94,7 +94,8 @@
                 break;
             }
             if(XKeysymToKeycode(ioncore_g.dpy, keysym)==0){
-                warn_obj(str, TR("Could not convert keysym to keycode."));
+                if(!quiet_absent)
+                    warn_obj(str, TR("Could not convert keysym to keycode."));
                 break;
             }
             *ksb_ret=keysym;
@@ -256,6 +257,7 @@
     ExtlFn func;
     bool wr=FALSE;
     int area=0;
+    bool extra;
     
     if(!extl_table_gets_s(tab, "action", &action_str)){
         warn(TR("Binding type not set."));
@@ -277,9 +279,12 @@
         if(!extl_table_gets_s(tab, "kcb", &ksb_str))
             goto fail;
 
+        if(!extl_table_gets_b(tab, "extra", &extra))
+            extra=FALSE;
+
         if(!ioncore_parse_keybut(ksb_str, &mod, &ksb,
                                  (action!=BINDING_KEYPRESS && action!=-1), 
-                                 init_any)){
+                                 init_any, extra)){
             goto fail;
         }
     }
--- ion3.orig/ioncore/ioncore_bindings.lua
+++ ion3/ioncore/ioncore_bindings.lua
@@ -125,9 +125,12 @@
 -- Creates a binding description table for the action of pressing a key given 
 -- by \var{keyspec} (with possible modifiers) to the function \var{cmd}.
 -- The \var{guard} controls when the binding can be called.
+-- The \var{extra} flag signals whether the binding is a non-critical extra
+-- binding.  If this is true and a named key does not exist, the binding will
+-- be quietly ignored.
 -- For more informationp see Section \ref{sec:bindings}.
-function ioncore.kpress(keyspec, cmd, guard)
-    return putcmd(cmd, guard, {action = "kpress", kcb = keyspec})
+function ioncore.kpress(keyspec, cmd, guard, extra)
+    return putcmd(cmd, guard, {action = "kpress", kcb = keyspec, extra = 
extra})
 end
 
 --DOC
--- ion3.orig/ioncore/conf-bindings.h
+++ ion3/ioncore/conf-bindings.h
@@ -19,6 +19,6 @@
 
 extern bool ioncore_parse_keybut(const char *str, 
                                  uint *mod_ret, uint *ksb_ret,
-                                 bool button, bool init_any);
+                                 bool button, bool init_any, bool 
quiet_absent);
 
 #endif /* ION_IONCORE_CONF_BINDINGS_H */
--- ion3.orig/etc/cfg_ioncore.lua
+++ ion3/etc/cfg_ioncore.lua
@@ -284,7 +284,7 @@
 
 defbindings("WMoveresMode", {
     bdoc("Cancel the resize mode."),
-    kpress("AnyModifier+Escape","WMoveresMode.cancel(_)"),
+    kpress("AnyModifier+Escape","WMoveresMode.cancel(_)", nil, true),
 
     bdoc("End the resize mode."),
     kpress("AnyModifier+Return","WMoveresMode.finish(_)"),
--- END ---

-- 
Ben Hutchings
You can't have everything.  Where would you put it?

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to