Fix non-prefix key error message when last character M-[char] is translated to ESC...
authorDon March <don@ohspite.net>
Tue, 2 Aug 2011 15:27:38 +0000 (17:27 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Tue, 2 Aug 2011 15:27:38 +0000 (17:27 +0200)
src/ChangeLog
src/keymap.c

index 8050853..858833d 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-03  Don March  <don@ohspite.net>
+
+       * keymap.c (Fdefine_key): Fix non-prefix key error message when
+       last character M-[char] is translated to ESC [char] (bug#7541).
+
 2011-08-02  Kenichi Handa  <handa@m17n.org>
 
        * lisp.h (uniprop_table): Extern it.
index 0169276..03688ab 100644 (file)
@@ -1216,13 +1216,27 @@ binding KEY to DEF is added at the front of KEYMAP.  */)
 
       keymap = get_keymap (cmd, 0, 1);
       if (!CONSP (keymap))
-       /* We must use Fkey_description rather than just passing key to
-          error; key might be a vector, not a string.  */
-       error ("Key sequence %s starts with non-prefix key %s",
-              SDATA (Fkey_description (key, Qnil)),
-              SDATA (Fkey_description (Fsubstring (key, make_number (0),
-                                                   make_number (idx)),
-                                       Qnil)));
+       {
+         char trailing_esc[5];
+         if (c == meta_prefix_char && metized)
+           {
+             if (idx == 0)
+               strcpy(trailing_esc, "ESC");
+             else
+               strcpy(trailing_esc, " ESC");
+           }
+         else
+             strcpy(trailing_esc, "");
+
+         /* We must use Fkey_description rather than just passing key to
+            error; key might be a vector, not a string.  */
+         error ("Key sequence %s starts with non-prefix key %s%s",
+                SDATA (Fkey_description (key, Qnil)),
+                SDATA (Fkey_description (Fsubstring (key, make_number (0),
+                                                     make_number (idx)),
+                                         Qnil)),
+                trailing_esc);
+       }
     }
 }