unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
@ 2010-12-03 16:35 Don March
  2011-07-03 13:39 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Don March @ 2010-12-03 16:35 UTC (permalink / raw)
  To: 7541

[-- 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);		 
! 	}
      }
  }
  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
  2010-12-03 16:35 bug#7541: 24.0.50; define-key error message for non-prefix M-[char] Don March
@ 2011-07-03 13:39 ` Lars Magne Ingebrigtsen
  2011-07-03 16:24   ` Don March
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-03 13:39 UTC (permalink / raw)
  To: Don March; +Cc: 7541

Don March <don@ohspite.net> writes:

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

Your patch for this bug looks correct, but it's more than 10 lines long,
so the FSF needs copyright assignment papers for the code.

Do you have such paperwork on file with the FSF?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
  2011-07-03 13:39 ` Lars Magne Ingebrigtsen
@ 2011-07-03 16:24   ` Don March
  2011-07-03 16:30     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Don March @ 2011-07-03 16:24 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 7541

I just sent an email to assign@gnu.org.  I'll report back when the
process is complete.

On Sun, Jul 3, 2011 at 9:39 AM, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Don March <don@ohspite.net> writes:
>
>> 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.
>
> Your patch for this bug looks correct, but it's more than 10 lines long,
> so the FSF needs copyright assignment papers for the code.
>
> Do you have such paperwork on file with the FSF?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>  bloggy blog http://lars.ingebrigtsen.no/
>





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
  2011-07-03 16:24   ` Don March
@ 2011-07-03 16:30     ` Lars Magne Ingebrigtsen
  2011-08-01 21:24       ` Don March
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-03 16:30 UTC (permalink / raw)
  To: Don March; +Cc: 7541

Don March <don@ohspite.net> writes:

> I just sent an email to assign@gnu.org.  I'll report back when the
> process is complete.

Great!

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
  2011-07-03 16:30     ` Lars Magne Ingebrigtsen
@ 2011-08-01 21:24       ` Don March
  2011-08-02 15:28         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Don March @ 2011-08-01 21:24 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 7541

Okay, I just got an email saying my copyright assignment papers have
been received and executed.

On Sun, Jul 3, 2011 at 12:30 PM, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Don March <don@ohspite.net> writes:
>
>> I just sent an email to assign@gnu.org.  I'll report back when the
>> process is complete.
>
> Great!
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>  bloggy blog http://lars.ingebrigtsen.no/
>





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#7541: 24.0.50; define-key error message for non-prefix M-[char]
  2011-08-01 21:24       ` Don March
@ 2011-08-02 15:28         ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-08-02 15:28 UTC (permalink / raw)
  To: Don March; +Cc: 7541

Don March <don@ohspite.net> writes:

> Okay, I just got an email saying my copyright assignment papers have
> been received and executed.

Thanks; I've now applied the patch.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-08-02 15:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-03 16:35 bug#7541: 24.0.50; define-key error message for non-prefix M-[char] Don March
2011-07-03 13:39 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).