<<< Date Index >>>     <<< Thread Index >>>

Disabling all default key bindings



    Hello all!

    Yesterday I've started playing with Mutt and kind of liked it.
But... (I'll try to be short and describe the context, problem,
solution and the resulting quirk.)

    Getting back, I had an issue with Mutt: (like in Emacs) any key
you press does something, and this could be kind of confusing for the
(novice) user... (I also should add that usually I like to customize
every option in my applications...) :)

    Therefore I've searched for a way to "unbind" any default bound
key, and didn't found any way to do it. (Or maybe I've missed
something?)

    As a consequence, I've made some little modifications to the
source code, by adding a new option "-K" which sets an option
(OPTVIRGINKEYS), which in turn disables the default key bindings from
being registered (km_init function). (See the attached patch.) I've
also wanted to add a variable (virgin_keys) that would do the same
thing. (Not in the attached patch.)

    But the problem is that the option in the muttrc file would be
ignored. (I suppose that the muttrc file is read after the km_init
function is called.) So my question is: any ideas on how to overcome
this problem?

    Also any comments on my solution? Any other solutions?

    Thanks for the good application,
    Ciprian Craciun.
diff --git a/keymap.c b/keymap.c
index bcc0022..42ee326 100644
--- a/keymap.c
+++ b/keymap.c
@@ -577,6 +577,9 @@ void km_init (void)
 {
   memset (Keymaps, 0, sizeof (struct keymap_t *) * MENU_MAX);
 
+  if (option(OPTVIRGINKEYS))
+    return;
+
   create_bindings (OpAttach, MENU_ATTACH);
   create_bindings (OpBrowser, MENU_FOLDER);
   create_bindings (OpCompose, MENU_COMPOSE);
diff --git a/main.c b/main.c
index baea582..0f2eb90 100644
--- a/main.c
+++ b/main.c
@@ -148,6 +148,7 @@ options:\n\
   -y\t\tselect a mailbox specified in your `mailboxes' list\n\
   -z\t\texit immediately if there are no messages in the mailbox\n\
   -Z\t\topen the first folder with new message, exit immediately if none\n\
+  -K\t\tignore all default key bindings\n\
   -h\t\tthis help message");
   puts _("  --\t\ttreat remaining arguments as addr even if starting with a 
dash\n\
 \t\twhen using -a with multiple filenames using -- is mandatory");
@@ -594,7 +595,7 @@ int main (int argc, char **argv)
         argv[nargc++] = argv[optind];
     }
 
-    if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != 
EOF)
+    if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZK")) != 
EOF)
       switch (i)
       {
       case 'A':
@@ -699,6 +700,10 @@ int main (int argc, char **argv)
        flags |= M_BUFFY | M_IGNORE;
        break;
 
+      case 'K':
+       set_option(OPTVIRGINKEYS);
+       break;
+
       default:
        mutt_usage ();
       }
diff --git a/mutt.h b/mutt.h
index a0e3354..fc31441 100644
--- a/mutt.h
+++ b/mutt.h
@@ -507,6 +507,8 @@ enum
   OPTDONTHANDLEPGPKEYS,        /* (pseudo) used to extract PGP keys */
   OPTUNBUFFEREDINPUT,   /* (pseudo) don't use key buffer */
 
+  OPTVIRGINKEYS,
+
   OPTMAX
 };