From 0a2ea2219a1266af808fb75999267a5d59c13353 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Sun, 11 Jun 1995 20:09:49 +0000 Subject: [PATCH] (read_char_minibuf_menu_prompt): If the char to type doesn't match the prompt string, show the char explicitly. --- src/keyboard.c | 102 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 45b4079d25d..ac5b2090b6d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -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. */ -- 2.39.2