]> git.eshelyaron.com Git - emacs.git/commitdiff
(read_char_minibuf_menu_prompt):
authorKarl Heuer <kwzh@gnu.org>
Sun, 11 Jun 1995 20:09:49 +0000 (20:09 +0000)
committerKarl Heuer <kwzh@gnu.org>
Sun, 11 Jun 1995 20:09:49 +0000 (20:09 +0000)
If the char to type doesn't match the prompt string,
show the char explicitly.

src/keyboard.c

index 45b4079d25da6d0de472fb44575efeb581383ae5..ac5b2090b6db0eb03f8ff1a6063079d31464b55e 100644 (file)
@@ -4775,43 +4775,81 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps)
          else
            {
              /* An ordinary element.  */
-             if ( idx < 0 )
-               s = Fcar_safe (Fcdr_safe (elt));        /* alist */
+             Lisp_Object event;
+
+             if (idx < 0)
+               {
+                 s = Fcar_safe (Fcdr_safe (elt));      /* alist */
+                 event = Fcar_safe (elt);
+               }
              else
-               s = Fcar_safe(elt);                     /* vector */
-             if (!STRINGP (s))
-               /* Ignore the element if it has no prompt string.  */
-               ;
-             /* If we have room for the prompt string, add it to this line.
-                If this is the first on the line, always add it.  */
-             else if (XSTRING (s)->size + i + 2 < width
-                      || !notfirst)
                {
-                 int thiswidth;
+                 s = Fcar_safe (elt);                  /* vector */
+                 XSETINT (event, idx);
+               }
+
+             /* Ignore the element if it has no prompt string.  */
+             if (STRINGP (s) && INTEGERP (event))
+               {
+                 /* 1 if the char to type matches the string.  */
+                 int char_matches;
+                 Lisp_Object upcased_event, downcased_event;
+                 Lisp_Object desc;
+
+                 upcased_event = Fupcase (event);
+                 downcased_event = Fdowncase (event);
+                 char_matches = (XINT (upcased_event) == XSTRING (s)->data[0]
+                                 || XINT (downcased_event) == XSTRING (s)->data[0]);
+                 if (! char_matches)
+                   desc = Fsingle_key_description (event);
+
+                 /* If we have room for the prompt string, add it to this line.
+                    If this is the first on the line, always add it.  */
+                 if ((XSTRING (s)->size + i + 2
+                      + (char_matches ? 0 : XSTRING (desc)->size + 3))
+                     < width
+                     || !notfirst)
+                   {
+                     int thiswidth;
+
+                     /* Punctuate between strings.  */
+                     if (notfirst)
+                       {
+                         strcpy (menu + i, ", ");
+                         i += 2;
+                       }
+                     notfirst = 1;
+                     nobindings = 0 ;
 
-                 /* Punctuate between strings.  */
-                 if (notfirst)
+                     /* If the char to type doesn't match the string's
+                        first char, explicitly show what char to type.  */
+                     if (! char_matches)
+                       {
+                         /* Add as much of string as fits.  */
+                         thiswidth = XSTRING (desc)->size;
+                         if (thiswidth + i > width)
+                           thiswidth = width - i;
+                         bcopy (XSTRING (desc)->data, menu + i, thiswidth);
+                         i += thiswidth;
+                         strcpy (menu + i, " = ");
+                         i += 3;
+                       }
+
+                     /* Add as much of string as fits.  */
+                     thiswidth = XSTRING (s)->size;
+                     if (thiswidth + i > width)
+                       thiswidth = width - i;
+                     bcopy (XSTRING (s)->data, menu + i, thiswidth);
+                     i += thiswidth;
+                     menu[i] = 0;
+                   }
+                 else
                    {
-                     strcpy (menu + i, ", ");
-                     i += 2;
+                     /* If this element does not fit, end the line now,
+                        and save the element for the next line.  */
+                     strcpy (menu + i, "...");
+                     break;
                    }
-                 notfirst = 1;
-                 nobindings = 0 ;
-
-                 /* Add as much of string as fits.  */
-                 thiswidth = XSTRING (s)->size;
-                 if (thiswidth + i > width)
-                   thiswidth = width - i;
-                 bcopy (XSTRING (s)->data, menu + i, thiswidth);
-                 i += thiswidth;
-                 menu[i] = 0;
-               }
-             else
-               {
-                 /* If this element does not fit, end the line now,
-                    and save the element for the next line.  */
-                 strcpy (menu + i, "...");
-                 break;
                }
 
              /* Move past this element.  */