all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dieter Deyke <dieter.deyke@gmail.com>
Cc: 51527@debbugs.gnu.org
Subject: bug#51527: 29.0.50; (wrong-type-argument symbolp 1) lookup-key((keymap) [menu-bar buffer 1])
Date: Sun, 31 Oct 2021 15:22:14 +0200	[thread overview]
Message-ID: <834k8xnxbt.fsf@gnu.org> (raw)
In-Reply-To: <87tugxodyn.fsf@gmail.com> (message from Dieter Deyke on Sun, 31 Oct 2021 08:22:56 +0100)

> 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.  */





  reply	other threads:[~2021-10-31 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31  7:22 bug#51527: 29.0.50; (wrong-type-argument symbolp 1) lookup-key((keymap) [menu-bar buffer 1]) Dieter Deyke
2021-10-31 13:22 ` Eli Zaretskii [this message]
2021-10-31 13:56   ` Dieter Deyke
2021-10-31 14:21     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=834k8xnxbt.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=51527@debbugs.gnu.org \
    --cc=dieter.deyke@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.