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

For 1.5.9: make <complete-query> similar to <complete>



Summary:
        With this patch, you can do 'bind editor <tab> complete-query'
with no trouble. Without this patch, you cannot use <complete-query>
as an alternative to <complete> function.


Background:
        Mutt's query feature is much more powerful than mutt's simple
alias feature. So, you may want to do 'bind editor <tab> complete-query'.
But it causes many troubles on non-address prompts. For example, when
you type <tab> after 'c/va', you may expect to see 'Open mailbox: /var',
but you'll see 'Open mailbox: /va^I'.


Implementation:
        This patch makes <complete-query> similar to <complete>.
In fact, these two functions will be the same, except for addresses.
No options to set. The only thing you have to do is to bind <tab> to
complete-query.

-- 
tamo
--- enter.c.BAK 2005-03-07 20:32:44.000000000 +0900
+++ enter.c     2005-03-07 20:53:05.000000000 +0900
@@ -269,7 +269,7 @@
     if (ch != OP_NULL)
     {
       first = 0;
-      if (ch != OP_EDITOR_COMPLETE)
+      if (ch != OP_EDITOR_COMPLETE && ch != OP_EDITOR_COMPLETE_QUERY)
        state->tabs = 0;
       redraw = M_REDRAW_LINE;
       switch (ch)
@@ -458,6 +458,7 @@
          /* fall through to completion routine (M_FILE) */
 
        case OP_EDITOR_COMPLETE:
+       case OP_EDITOR_COMPLETE_QUERY:
          state->tabs++;
          if (flags & M_CMD)
          {
@@ -484,7 +485,7 @@
 
            replace_part (state, i, buf);
          }
-         else if (flags & M_ALIAS)
+         else if (flags & M_ALIAS && ch == OP_EDITOR_COMPLETE)
          {
            /* invoke the alias-menu to get more addresses */
            for (i = state->curpos; i && state->wbuf[i-1] != ',' && 
@@ -502,6 +503,24 @@
            }
            break;
          }
+         else if (flags & M_ALIAS && ch == OP_EDITOR_COMPLETE_QUERY)
+         {
+           /* invoke the query-menu to get more addresses */
+           if ((i = state->curpos))
+           {
+             for (; i && state->wbuf[i - 1] != ','; i--)
+               ;
+             for (; i < state->curpos && state->wbuf[i] == ' '; i++)
+               ;
+           }
+
+           my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
+           mutt_query_complete (buf, buflen);
+           replace_part (state, i, buf);
+
+           rv = 1; 
+           goto bye;
+         }
          else if (flags & M_COMMAND)
          {
            my_wcstombs (buf, buflen, state->wbuf, state->curpos);
@@ -553,28 +572,6 @@
            goto self_insert;
          break;
 
-       case OP_EDITOR_COMPLETE_QUERY:
-         if (flags & M_ALIAS)
-         {
-           /* invoke the query-menu to get more addresses */
-           if ((i = state->curpos))
-           {
-             for (; i && state->wbuf[i - 1] != ','; i--)
-               ;
-             for (; i < state->curpos && state->wbuf[i] == ' '; i++)
-               ;
-           }
-
-           my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
-           mutt_query_complete (buf, buflen);
-           replace_part (state, i, buf);
-
-           rv = 1; 
-           goto bye;
-         }
-         else
-           goto self_insert;
-
        case OP_EDITOR_QUOTE_CHAR:
          {
            event_t event;