From: Don March <don@ohspite.net>
To: 7541@debbugs.gnu.org
Subject: bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
Date: Fri, 3 Dec 2010 11:35:03 -0500 [thread overview]
Message-ID: <AANLkTim3xWLUT-3D3RvgHNO2ZLzmsd_u20jzHxA84FGw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]
Typing and evaluating the following code in the scratch
buffer results in an (appropriate) error, but with an incorrect
message:
(setq new-kmap (make-sparse-keymap))
(define-key new-kmap [?a 27] 'command)
(define-key new-kmap [?a ?\M-x] 'command)
;; Debugger entered--Lisp error:
;; (error "Key sequence a M-x starts with non-prefix key a")
;; (should be:
;; "Key sequence a M-x starts with non-prefix key a ESC")
The code in keymap.c loops over the characters in the key sequence and
says to report everything before the current character as the
non-prefix key. But that misses the case when M-x is converted into
[27 ?x] and it's the `27' part that causes the error.
Please see the attached patch.
A few other cases that show the problem:
(setq a (make-sparse-keymap))
(define-key a [27] 'command)
(define-key a [?\M-x] 'command)
;; Debugger entered--Lisp error:
;; (error "Key sequence M-x starts with non-prefix key ")
;; (should be:
;; "Key sequence M-x starts with non-prefix key ESC")
(setq new-kmap (make-sparse-keymap))
(define-key new-kmap [?a 27] 'command)
(define-key new-kmap [?a 27 ?x] 'command)
;; Debugger entered--Lisp error:
;; (error "Key sequence a M-x starts with non-prefix key a ESC")
;; (error text is correct)
(setq new-kmap (make-sparse-keymap))
(define-key new-kmap [?a] 'command)
(define-key new-kmap [?a ?\M-x] 'command)
;; Debugger entered--Lisp error:
;; (error "Key sequence a M-x starts with non-prefix key a")
;; (error text is correct)
In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.22.0)
of 2010-12-03 on lappy
Windowing system distributor `The X.Org Foundation', version 11.0.10900000
[-- Attachment #2: define-key_diff --]
[-- Type: application/octet-stream, Size: 1813 bytes --]
=== modified file 'src/ChangeLog'
*** src/ChangeLog 2010-12-02 09:33:57 +0000
--- src/ChangeLog 2010-12-03 16:15:41 +0000
***************
*** 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].
+
2010-12-02 Jan Djärv <jan.h.d@swipnet.se>
* nsmenu.m (update_frame_tool_bar): Remove NSLog on invalid image.
=== modified file 'src/keymap.c'
*** src/keymap.c 2010-08-09 09:35:21 +0000
--- src/keymap.c 2010-12-03 08:05:11 +0000
*************** binding KEY to DEF is added at the front
*** 1234,1246 ****
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)));
}
}
--- 1234,1260 ----
keymap = get_keymap (cmd, 0, 1);
if (!CONSP (keymap))
! {
! 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);
! }
}
}
next reply other threads:[~2010-12-03 16:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 16:35 Don March [this message]
2011-07-03 13:39 ` bug#7541: 24.0.50; define-key error message for non-prefix M-[char] Lars Magne Ingebrigtsen
2011-07-03 16:24 ` Don March
2011-07-03 16:30 ` Lars Magne Ingebrigtsen
2011-08-01 21:24 ` Don March
2011-08-02 15:28 ` Lars Magne Ingebrigtsen
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=AANLkTim3xWLUT-3D3RvgHNO2ZLzmsd_u20jzHxA84FGw@mail.gmail.com \
--to=don@ohspite.net \
--cc=7541@debbugs.gnu.org \
/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.