bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51527: 29.0.50; (wrong-type-argument symbolp 1) lookup-key((keymap)


From: Dieter Deyke
Subject: bug#51527: 29.0.50; (wrong-type-argument symbolp 1) lookup-key((keymap) [menu-bar buffer 1])
Date: Sun, 31 Oct 2021 14:56:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Dieter Deyke <dieter.deyke@gmail.com>
>> Date: Sun, 31 Oct 2021 08:22:56 +0100
>>
>>
>> Using emacs -Q (build from git master) works fine. Starting it with my
>> customizations fails:
>>
>> Debugger entered--Lisp error: (wrong-type-argument symbolp 1)
>>   lookup-key((keymap) [menu-bar buffer 1])
>>   substitute-key-definition-key(("Most recently used (1)" keymap
>> "Most recently used (1)" ("*Messages*" "*% *Messages*"
>> . msb--select-buffer)) beginning-of-line allout-beginning-of-line
>> [menu-bar buffer 1] (keymap))
>
> Thanks.
>
> Does the patch below fix this?
>
> diff --git a/src/keymap.c b/src/keymap.c
> index 5ff13ba..4d8944d 100644
> --- a/src/keymap.c
> +++ b/src/keymap.c
> @@ -1314,36 +1314,44 @@ DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 
> 0,
>        "foo-bar-baz".  */
>        for (int i = 0; i < key_len; i++)
>       {
> -       Lisp_Object key_item = Fsymbol_name (AREF (key, i));
> -       Lisp_Object new_item;
> -       if (!STRING_MULTIBYTE (key_item))
> -         new_item = Fdowncase (key_item);
> +       Lisp_Object item = AREF (key, i);
> +       if (!SYMBOLP (item))
> +         ASET (new_key, i, item);
>         else
>           {
> -           USE_SAFE_ALLOCA;
> -           ptrdiff_t size = SCHARS (key_item), n;
> -           if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n))
> -             n = PTRDIFF_MAX;
> -           unsigned char *dst = SAFE_ALLOCA (n);
> -           unsigned char *p = dst;
> -           ptrdiff_t j_char = 0, j_byte = 0;
> -
> -           while (j_char < size)
> +           Lisp_Object key_item = Fsymbol_name (item);
> +           Lisp_Object new_item;
> +           if (!STRING_MULTIBYTE (key_item))
> +             new_item = Fdowncase (key_item);
> +           else
>               {
> -               int ch = fetch_string_char_advance (key_item, &j_char, 
> &j_byte);
> -               Lisp_Object ch_conv = CHAR_TABLE_REF (tables[tbl_num], ch);
> -               if (!NILP (ch_conv))
> -                 CHAR_STRING (XFIXNUM (ch_conv), p);
> -               else
> -                 CHAR_STRING (ch, p);
> -               p = dst + j_byte;
> +               USE_SAFE_ALLOCA;
> +               ptrdiff_t size = SCHARS (key_item), n;
> +               if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n))
> +                 n = PTRDIFF_MAX;
> +               unsigned char *dst = SAFE_ALLOCA (n);
> +               unsigned char *p = dst;
> +               ptrdiff_t j_char = 0, j_byte = 0;
> +
> +               while (j_char < size)
> +                 {
> +                   int ch = fetch_string_char_advance (key_item,
> +                                                       &j_char, &j_byte);
> +                   Lisp_Object ch_conv = CHAR_TABLE_REF (tables[tbl_num],
> +                                                         ch);
> +                   if (!NILP (ch_conv))
> +                     CHAR_STRING (XFIXNUM (ch_conv), p);
> +                   else
> +                     CHAR_STRING (ch, p);
> +                   p = dst + j_byte;
> +                 }
> +               new_item = make_multibyte_string ((char *) dst,
> +                                                 SCHARS (key_item),
> +                                                 SBYTES (key_item));
> +               SAFE_FREE ();
>               }
> -           new_item = make_multibyte_string ((char *) dst,
> -                                             SCHARS (key_item),
> -                                             SBYTES (key_item));
> -           SAFE_FREE ();
> +           ASET (new_key, i, Fintern (new_item, Qnil));
>           }
> -       ASET (new_key, i, Fintern (new_item, Qnil));
>       }
>
>        /* Check for match.  */
> @@ -1356,6 +1364,9 @@ DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0,
>        "foo-bar-baz".  */
>        for (int i = 0; i < key_len; i++)
>       {
> +       if (!SYMBOLP (AREF (new_key, i)))
> +         continue;
> +
>         Lisp_Object lc_key = Fsymbol_name (AREF (new_key, i));
>
>         /* If there are no spaces in this symbol, just skip it.  */
>

Yes, the patch fixed it.

Thank you, Eli.
-- 
Dieter Deyke
mailto:dieter.deyke@gmail.com
Get my Gnupg key:
gpg --keyserver keys.gnupg.net --recv-keys B116EA20





reply via email to

[Prev in Thread] Current Thread [Next in Thread]