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

[PATCHES] Re: We need unbind function (was Re: [PATCHES] awaiting...)



Hello,

On Wed, May 26, 2004 at 11:17:05PM +0200, Alain Bench wrote:

>     The current behaviour (unbind to unbound) seems to me consistent
> with the manual: A key you unbind then press does ??Key is not bound.??
> error, not some generic operation.
> 
>     Also consistent with command syntax: "bind map key noop" binds noop
> to the key, and noop means "no operation", not back to whichever generic
> operation. And "bind generic key noop" confirms this scheme.

Logically, "bind to noop" has to be "bind to noop" of course.
But then, we have no way to "bind to generic."
So here is another patch. If this is approved, I and Pawel would
"set trygeneric." Others wouldn't. (default: unset)

This works run-time. i.e. This patch does not modify
"bind" function, but modifies key-interpreting routine.


> > bug#1880 is really a bug.
> 
>     I see #1880 as a misunderstanding of the intended and documented
> behaviour, not as a bug. I would have closed it, but am surprised you
> are 3 to think the contrary (Pawel, you, and Dave). So I hesitate.

Reading your post, I finally realize that the problem is just
"the word <unbind> is unclear." I don't think I misunderstood
the document. But I might have misunderstood the intended behaviour.


>     In last December, Final Approved Consensus(1) was:
> 
> | wish (unbind to generic) seems legitimate, but not as a replacement of
> | current behaviour (unbind to unbound).
> 
>     IMHO we should not change the noop behaviour, to not unnecessarilly
> break existing muttrcs. So manual needs more precision. The added new
> unbind to generic feature would need another command. Perhaps "unbind"
> or something as "bind map key generic". The behaviour of special case
> when map == generic has to be defined (Error? Do nothing? Bind noop?)
> and documented.

Here is one more patch, which implements "bind map key generic."
Pawel may do:
        bind index ' ' generic
        bind generic ' ' next-page
and voila, <space> works as next-page on index menu.

Thomas Roessler would choose one of four patches:
dgc's patch, my two patches, and /dev/null.

Anyway, Thomas, commit my fix-browser-segv patch and
my fix-builtin-editor patch, please.
Commit assumed_charset patch, please. (This has been
approved, hasn't it?)


> > Include dgc's excellent "unbind" patch. (This provides the most
> > intuitive UI (and many changes))
> 
>     What does it do? Why was it rejected?

I don't know why.

-- 
tamo
Index: init.h
===================================================================
RCS file: /home/roessler/cvs/mutt/init.h,v
retrieving revision 3.47
diff -u -r3.47 init.h
--- init.h      13 Apr 2004 08:02:12 -0000      3.47
+++ init.h      27 May 2004 01:59:17 -0000
@@ -2581,6 +2581,13 @@
   ** by \fIyou\fP.  The sixth character is used to indicate when a mail
   ** was sent to a mailing-list you subscribe to (default: L).
   */
+  { "trygeneric",      DT_BOOL, R_NONE, OPTTRYGENERIC, 0 },
+  /*
+  ** .pp
+  ** When set, unbound keys will look for generic bindings.
+  ** When unset, unbound keys will just say "Key is not bound."
+  ** (\fIunbound keys\fP means the keys you did "bind x x noop")
+  */
 #ifdef USE_SOCKET
   { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
   /*
Index: keymap.c
===================================================================
RCS file: /home/roessler/cvs/mutt/keymap.c,v
retrieving revision 3.11
diff -u -r3.11 keymap.c
--- keymap.c    12 Apr 2004 20:02:49 -0000      3.11
+++ keymap.c    27 May 2004 01:59:18 -0000
@@ -443,6 +443,9 @@
     if (LastKey != map->keys[pos])
       return (retry_generic (menu, map->keys, pos, LastKey));
 
+    if ((option (OPTTRYGENERIC)) && (map->op == OP_NULL))
+      return (retry_generic (menu, map->keys, pos, LastKey));
+
     if (++pos == map->len)
     {
 
@@ -657,7 +660,7 @@
   
   if(!(km_expand_key(buf, sizeof(buf), key)))
   {
-    mutt_error _("Key is not bound.");
+    mutt_error _("Key is bound to noop or not bound.");
     return;
   }
 
@@ -665,11 +668,11 @@
   push_string (buf);
   if (km_dokey (menu) != OP_HELP)
   {
-    mutt_error _("Key is not bound.");
+    mutt_error _("Key is bound to noop or not bound.");
     return;
   }
 
-  mutt_error (_("Key is not bound.  Press '%s' for help."), buf);
+  mutt_error (_("Key is bound to noop or not bound.  Press '%s' for help."), 
buf);
   return;
 }
 
Index: mutt.h
===================================================================
RCS file: /home/roessler/cvs/mutt/mutt.h,v
retrieving revision 3.27
diff -u -r3.27 mutt.h
--- mutt.h      13 Apr 2004 08:02:12 -0000      3.27
+++ mutt.h      27 May 2004 01:59:20 -0000
@@ -414,6 +414,7 @@
   OPTTHOROUGHSRC,
   OPTTHREADRECEIVED,
   OPTTILDE,
+  OPTTRYGENERIC,
   OPTUNCOLLAPSEJUMP,
   OPTUSE8BITMIME,
   OPTUSEDOMAIN,
Index: doc/manual.sgml.head
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/manual.sgml.head,v
retrieving revision 3.29
diff -u -r3.29 manual.sgml.head
--- doc/manual.sgml.head        12 Apr 2004 20:02:49 -0000      3.29
+++ doc/manual.sgml.head        27 May 2004 01:59:37 -0000
@@ -961,7 +961,8 @@
 <em/function/ specifies which action to take when <em/key/ is pressed.
 For a complete list of functions, see the <ref id="functions"
 name="reference">.  The special function <tt/noop/ unbinds the specified key
-sequence.
+sequence. Note that the unbound key does not fall back to generic
+binding if <ref id="trygeneric" name="&dollar;trygeneric"> is unset.
 
 <sect1>Defining aliases for character sets <label id="charset-hook">
 <p>
Index: OPS
===================================================================
RCS file: /home/roessler/cvs/mutt/OPS,v
retrieving revision 3.5
diff -u -r3.5 OPS
--- OPS 4 Jul 2003 17:07:22 -0000       3.5
+++ OPS 27 May 2004 01:42:35 -0000
@@ -174,3 +174,4 @@
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
+OP_TRY_GENERIC "try generic binding"
Index: functions.h
===================================================================
RCS file: /home/roessler/cvs/mutt/functions.h,v
retrieving revision 3.7
diff -u -r3.7 functions.h
--- functions.h 4 Jul 2003 17:07:22 -0000       3.7
+++ functions.h 27 May 2004 01:42:40 -0000
@@ -139,6 +139,7 @@
   { "next-unread",             OP_MAIN_NEXT_UNREAD,            NULL },
   { "previous-unread",         OP_MAIN_PREV_UNREAD,            NULL },
   { "parent-message",          OP_MAIN_PARENT_MESSAGE,         "P" },
+  { "generic",                 OP_TRY_GENERIC,                 NULL },
 
 
   { "extract-keys",            OP_EXTRACT_KEYS,                "\013" },
@@ -264,6 +265,7 @@
   { "delete-entry",    OP_DELETE,                      "d" },
   { "undelete-entry",  OP_UNDELETE,                    "u" },
   { "collapse-parts",  OP_ATTACH_COLLAPSE,             "v" },
+  { "generic",         OP_TRY_GENERIC,                 NULL },
 
   { "check-traditional-pgp",   OP_CHECK_TRADITIONAL,           "\033P"   },
   { "extract-keys",            OP_EXTRACT_KEYS,                "\013" },
@@ -307,6 +309,7 @@
   { "view-attach",     OP_VIEW_ATTACH,                 M_ENTER_S },
   { "send-message",    OP_COMPOSE_SEND_MESSAGE,        "y" },
   { "pipe-entry",      OP_PIPE,                        "|" },
+  { "generic",         OP_TRY_GENERIC,                 NULL },
 
   { "attach-key",      OP_COMPOSE_ATTACH_KEY,          "\033k" },
   { "pgp-menu",                OP_COMPOSE_PGP_MENU,            "p"     },
@@ -325,12 +328,14 @@
 struct binding_t OpPost[] = {
   { "delete-entry",    OP_DELETE,      "d" },
   { "undelete-entry",  OP_UNDELETE,    "u" },
+  { "generic",         OP_TRY_GENERIC, NULL },
   { NULL,              0,              NULL }
 };
 
 struct binding_t OpAlias[] = {
   { "delete-entry",    OP_DELETE,      "d" },
   { "undelete-entry",  OP_UNDELETE,    "u" },
+  { "generic",         OP_TRY_GENERIC, NULL },
   { NULL,              0,              NULL }
 };
   
@@ -347,6 +352,7 @@
   { "toggle-mailboxes", OP_TOGGLE_MAILBOXES,   "\t" },
   { "view-file",       OP_BROWSER_VIEW_FILE,   " " },
   { "buffy-list",      OP_BUFFY_LIST,          "." },
+  { "generic",         OP_TRY_GENERIC,         NULL },
 #ifdef USE_IMAP
   { "create-mailbox",   OP_CREATE_MAILBOX,      "C" },
   { "delete-mailbox",   OP_DELETE_MAILBOX,      "d" },
@@ -363,6 +369,7 @@
   { "mail",            OP_MAIL,                "m" },
   { "query",           OP_QUERY,               "Q" },
   { "query-append",    OP_QUERY_APPEND,        "A" },
+  { "generic",         OP_TRY_GENERIC,         NULL },
   { NULL,              0,                      NULL }
 };
 
@@ -397,11 +404,13 @@
 struct binding_t OpPgp[] = {
   { "verify-key",      OP_VERIFY_KEY,          "c" },
   { "view-name",       OP_VIEW_ID,             "%" },
+  { "generic",         OP_TRY_GENERIC,                 NULL },
   { NULL,              0,                              NULL }
 };
 
 /* Don't know an useful key binding yet. But. just in case, adding this 
already */
 struct binding_t OpSmime[] = {
+  { "generic",                 OP_TRY_GENERIC,                 NULL },
   { NULL,      0,      NULL }
 };
 
@@ -413,6 +422,7 @@
   { "delete",          OP_MIX_DELETE,  "d"       },
   { "chain-prev",      OP_MIX_CHAIN_PREV, "<left>" },
   { "chain-next",      OP_MIX_CHAIN_NEXT, "<right>" },
+  { "generic",         OP_TRY_GENERIC, NULL      },
   { NULL,              0,              NULL }
 };
 #endif /* MIXMASTER */
Index: keymap.c
===================================================================
RCS file: /home/roessler/cvs/mutt/keymap.c,v
retrieving revision 3.11
diff -u -r3.11 keymap.c
--- keymap.c    12 Apr 2004 20:02:49 -0000      3.11
+++ keymap.c    27 May 2004 01:42:43 -0000
@@ -440,7 +440,7 @@
       map = map->next;
     }
 
-    if (LastKey != map->keys[pos])
+    if ((LastKey != map->keys[pos]) || (map->op == OP_TRY_GENERIC))
       return (retry_generic (menu, map->keys, pos, LastKey));
 
     if (++pos == map->len)
Index: doc/manual.sgml.head
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/manual.sgml.head,v
retrieving revision 3.29
diff -u -r3.29 manual.sgml.head
--- doc/manual.sgml.head        12 Apr 2004 20:02:49 -0000      3.29
+++ doc/manual.sgml.head        27 May 2004 01:43:27 -0000
@@ -960,7 +960,8 @@
 
 <em/function/ specifies which action to take when <em/key/ is pressed.
 For a complete list of functions, see the <ref id="functions"
-name="reference">.  The special function <tt/noop/ unbinds the specified key
+name="reference">.  The special function <tt/noop/ disables the specified key
+sequence. The special function <tt/generic/ unbinds the specified key
 sequence.
 
 <sect1>Defining aliases for character sets <label id="charset-hook">
Index: doc/manual.sgml.tail
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/manual.sgml.tail,v
retrieving revision 3.2
diff -u -r3.2 manual.sgml.tail
--- doc/manual.sgml.tail        25 Apr 2002 13:26:30 -0000      3.2
+++ doc/manual.sgml.tail        27 May 2004 01:43:27 -0000
@@ -72,6 +72,7 @@
 flag-message               F   toggle a message's 'important' flag
 forget-passphrase         ^F   wipe PGP passphrase from memory
 forward-message            f   forward a message with comments
+generic            not bound   try generic binding
 group-reply                g   reply to all recipients
 limit                      l   show only messages matching a pattern
 list-reply                 L   reply to specified mailing list
@@ -195,6 +196,7 @@
 <sect2>alias
 <p>
 <verb>
+generic            not bound   try generic binding
 search                     /   search for a regular expression
 search-next                n   search for next match
 search-reverse         ESC /   search backwards for a regular expression
@@ -203,6 +205,7 @@
 <p>
 <verb>
 create-alias               a   create an alias from a message sender
+generic            not bound   try generic binding
 mail                       m   compose a new mail message
 query                      Q   query external program for addresses
 query-append               A   append new query results to current results
@@ -222,6 +225,7 @@
 extract-keys              ^K   extract PGP public keys
 forward-message            f   forward a message with comments
 group-reply                g   reply to all recipients
+generic            not bound   try generic binding
 list-reply                 L   reply to specified mailing list
 pipe-entry                 |   pipe message/attachment to a shell command
 print-entry                p   print the current entry
@@ -258,6 +262,7 @@
 edit-type                 ^T   edit attachment type
 filter-entry               F   filter attachment through a shell command
 forget-passphrase         ^F   wipe PGP passphrase from memory
+generic            not bound   try generic binding
 ispell                     i   run ispell on the message
 new-mime                   n   compose new attachment using mailcap entry
 pgp-menu                   p   show PGP options
@@ -274,6 +279,7 @@
 <p>
 <verb>
 delete-entry               d   delete the current entry
+generic            not bound   try generic binding
 undelete-entry             u   undelete the current entry
 </verb>
 <sect2>browser
@@ -282,6 +288,7 @@
 change-dir                 c   change directories
 check-new                TAB   check mailboxes for new mail
 enter-mask                 m   enter a file mask
+generic            not bound   try generic binding
 search                     /   search for a regular expression
 search-next                n   search for next match
 search-reverse         ESC /   search backwards for a regular expression
@@ -297,6 +304,7 @@
 <sect2>pgp
 <p>
 <verb>
+generic            not bound   try generic binding
 view-name                  %   view the key's user id
 verify-key                 c   verify a PGP public key
 </verb>