Disabling all default key bindings
- To: mutt-dev@xxxxxxxx
- Subject: Disabling all default key bindings
- From: "Ciprian Dorin, Craciun" <ciprian.craciun@xxxxxxxxx>
- Date: Fri, 24 Jul 2009 22:16:33 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=+a5DpbGL0o/Jnp7j9DWG+1kBGsZy9Lw8PqS37L8j4qQ=; b=PRgJbEglnSdvDqGqGtMEZw2YYhyY9Jb5ZwVtlCUImPHawO8UVLMsOLCaxuGxB/076E UXUqevB8jlKNb0ay6zmzTCAcQ4rvhQTkn6/03ayI7kvMf7jNH3xWx+L0nY4piuD0x+s9 QY4BRObeXD/fzMsEERyAXlKKH/nOY4ujcdS+4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=XR7vMLVMUui0PEbLWAXLWyRoJ90VMpCL5Tedo5opWCrD2rpNweAc9ILs7ZkvX2buIl y6F7qIr+gs7eOEOT239lIbo6Nd8wjgsx0E7CJZfKUVkTZIvBWnGb3xAbL+eEJr7IjVmm Wz6W3uc2pFNCaShFYaWHiapoRDAUucJjuvHcc=
- List-post: <mailto:mutt-dev@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-dev"
- Sender: owner-mutt-dev@xxxxxxxx
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
};