GNU bug report logs - #7631
24.0.50; inconsistency in event-convert-list and event-basic-type

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Don March <don@HIDDEN>; dated Mon, 13 Dec 2010 06:17:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 7631 <at> debbugs.gnu.org:


Received: (at 7631) by debbugs.gnu.org; 14 Dec 2010 03:30:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 13 22:30:34 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PSLaz-0007ne-QC
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 22:30:34 -0500
Received: from cl05.gs01.gridserver.com ([64.13.192.14])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <don@HIDDEN>) id 1PSLax-0007nR-Nb
	for 7631 <at> debbugs.gnu.org; Mon, 13 Dec 2010 22:30:32 -0500
Received: from mail-iw0-f172.google.com ([209.85.214.172]:53191)
	by cl05.gs01.gridserver.com with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16)
	(Exim 4.63) (envelope-from <don@HIDDEN>) id 1PSLgw-0001ON-1O
	for 7631 <at> debbugs.gnu.org; Mon, 13 Dec 2010 19:36:43 -0800
Received: by iwn40 with SMTP id 40so237117iwn.3
	for <7631 <at> debbugs.gnu.org>; Mon, 13 Dec 2010 19:36:40 -0800 (PST)
Received: by 10.42.169.200 with SMTP id c8mr3679986icz.297.1292297800761; Mon,
	13 Dec 2010 19:36:40 -0800 (PST)
MIME-Version: 1.0
Received: by 10.42.222.134 with HTTP; Mon, 13 Dec 2010 19:36:20 -0800 (PST)
In-Reply-To: <jwvr5dlwo78.fsf-monnier+emacs@HIDDEN>
References: <AANLkTinrNcdbX7OyAUUsGYVBy9sgiGmUpDYnnw6EuAhj@HIDDEN>
	<jwvr5dlwo78.fsf-monnier+emacs@HIDDEN>
From: Don March <don@HIDDEN>
Date: Mon, 13 Dec 2010 22:36:20 -0500
Message-ID: <AANLkTikZoQWmHuPb7ZZ3kWQjMrPJbPN0BLgmVEna2Acp@HIDDEN>
Subject: Re: bug#7631: 24.0.50;
	inconsistency in event-convert-list and event-basic-type
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1
X-Authenticated-User: 14129 don@HIDDEN
X-Spam-Status: "score=-1.4 tests=ALL_TRUSTED version=3.1.7"
X-Spam-Level: 
X-Spam-Score: -4.6 (----)
X-Debbugs-Envelope-To: 7631
Cc: 7631 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.2 (----)

On Mon, Dec 13, 2010 at 1:01 PM, Stefan Monnier
<monnier@HIDDEN> wrote:
>> (event-convert-list '(t)) ; => 116
>
>> There's good reason to want this to eval to t (i.e. the symbol, not
>> the char).
>
> Could you explain what is this good reason?

I guess it boils down to the expected result of:

(setq event t)

(event-convert-list
 (append (event-modifiers event)
        (list (event-basic-type event)))) ; => 116, not t

In my mind, this should be an identity function (in the mathematical
sense) for events; if you take the event-modifiers and the
event-basic-type and then splice them together, the result should be
the original event.

A simplified version of what I was doing when I found this (which may
or may not be important) was something along the lines of:

(defun swap-C-and-M (event)
 (event-convert-list
  (append
   (mapcar (lambda (x) (case x
                         ('control 'meta)
                         ('meta    'control)
                         ('click   nil)
                         (t x)))
           (event-modifiers event))
   (list (event-basic-type event)))))

(setq new-keymap (make-sparse-keymap))

(map-keymap (lambda (key def)
             (define-key new-keymap
               (vector (swap-C-and-M key))
               def))
           isearch-mode-map)

(swap-C-and-M ?\M-x) ; => 24
(swap-C-and-M 'foo)  ; => foo
(swap-C-and-M t)     ; => 116

(lookup-key new-keymap [?t]) ; => isearch-other-control-char
(lookup-key new-keymap [t])  ; => nil




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7631; Package emacs. Full text available.

Message received at 7631 <at> debbugs.gnu.org:


Received: (at 7631) by debbugs.gnu.org; 13 Dec 2010 17:55:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 13 12:55:07 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PSCc6-0002v4-W3
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 12:55:07 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.181]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1PSCc4-0002ua-Ds
	for 7631 <at> debbugs.gnu.org; Mon, 13 Dec 2010 12:55:05 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AtUJALDuBU1FpZA//2dsb2JhbACiaYEcecMChUoEhGSOBQ
X-IronPort-AV: E=Sophos;i="4.59,336,1288584000"; d="scan'208";a="85319272"
Received: from 69-165-144-63.dsl.teksavvy.com (HELO pastel.home)
	([69.165.144.63])
	by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA;
	13 Dec 2010 13:01:15 -0500
Received: by pastel.home (Postfix, from userid 20848)
	id DE58A58CC2; Mon, 13 Dec 2010 13:01:14 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Don March <don@HIDDEN>
Subject: Re: bug#7631: 24.0.50;
	inconsistency in event-convert-list and event-basic-type
Message-ID: <jwvr5dlwo78.fsf-monnier+emacs@HIDDEN>
References: <AANLkTinrNcdbX7OyAUUsGYVBy9sgiGmUpDYnnw6EuAhj@HIDDEN>
Date: Mon, 13 Dec 2010 13:01:14 -0500
In-Reply-To: <AANLkTinrNcdbX7OyAUUsGYVBy9sgiGmUpDYnnw6EuAhj@HIDDEN>
	(Don March's message of "Mon, 13 Dec 2010 01:22:32 -0500")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 7631
Cc: 7631 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

> (event-convert-list '(t)) ; => 116

> There's good reason to want this to eval to t (i.e. the symbol, not
> the char).

Could you explain what is this good reason?
In Emacs, events corresponding to keys that are associated with
a characters are represented by an Elisp char, whereas other events are
represented by symbols.

AFAIK event-convert-list is mostly used to convert XEmacs style

  (define-key map [(control x)] 'foo)
to
  (define-key map ?\C-x 'foo)

so this single-char symbol conversion to a character is useful.
Maybe you can explain to us the problem it causes you.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7631; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Dec 2010 06:16:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 13 01:16:55 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PS1iR-0002Xd-2i
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 01:16:55 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <don@HIDDEN>) id 1PS1iO-0002XS-IE
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 01:16:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <don@HIDDEN>) id 1PS1oL-000720-Pd
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 01:23:02 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:60918)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <don@HIDDEN>) id 1PS1oL-00071v-Nb
	for submit <at> debbugs.gnu.org; Mon, 13 Dec 2010 01:23:01 -0500
Received: from [140.186.70.92] (port=51581 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PS1oJ-0007o7-M5
	for bug-gnu-emacs@HIDDEN; Mon, 13 Dec 2010 01:23:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <don@HIDDEN>) id 1PS1oH-00071D-TE
	for bug-gnu-emacs@HIDDEN; Mon, 13 Dec 2010 01:22:59 -0500
Received: from cl33.gs01.gridserver.com ([64.13.192.42]:48961)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <don@HIDDEN>) id 1PS1oH-00070X-Oi
	for bug-gnu-emacs@HIDDEN; Mon, 13 Dec 2010 01:22:57 -0500
Received: from mail-iw0-f175.google.com ([209.85.214.175]:57485)
	by cl33.gs01.gridserver.com with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16)
	(Exim 4.63) (envelope-from <don@HIDDEN>) id 1PS1oE-0005Vy-08
	for bug-gnu-emacs@HIDDEN; Sun, 12 Dec 2010 22:22:55 -0800
Received: by iwn8 with SMTP id 8so8752524iwn.34
	for <bug-gnu-emacs@HIDDEN>; Sun, 12 Dec 2010 22:22:52 -0800 (PST)
Received: by 10.42.164.66 with SMTP id f2mr2423767icy.431.1292221372395; Sun,
	12 Dec 2010 22:22:52 -0800 (PST)
MIME-Version: 1.0
Received: by 10.42.222.134 with HTTP; Sun, 12 Dec 2010 22:22:32 -0800 (PST)
From: Don March <don@HIDDEN>
Date: Mon, 13 Dec 2010 01:22:32 -0500
Message-ID: <AANLkTinrNcdbX7OyAUUsGYVBy9sgiGmUpDYnnw6EuAhj@HIDDEN>
Subject: 24.0.50; inconsistency in event-convert-list and event-basic-type
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=ISO-8859-1
X-Authenticated-User: 14129 don@HIDDEN
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Spam-Score: -6.6 (------)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.6 (------)

The definition for `event-convert-list' in keyboard.c has the
following code, which causes symbols consisting of a single character
to be interpreted as the character itself:

  /* Let the symbol A refer to the character A.  */
  if (SYMBOLP (base) && SCHARS (SYMBOL_NAME (base)) == 1)
    XSETINT (base, SREF (SYMBOL_NAME (base), 0));

I see how this is well-intentioned but I don't think that it's useful,
particularly because of the case where the symbol is `t'.

(event-convert-list '(t)) ; => 116

There's good reason to want this to eval to t (i.e. the symbol, not
the char).  For example, I found this interesting behavior when using
`map-keymap' to automate remapping commands from C- with M-.  It also
seems to produce inconsistent results:

(event-convert-list '(nil)) ; => nil
(event-convert-list '(t)) ; => 116
(event-convert-list '(tt)) ; => tt
(event-convert-list '(control t)) ; => 20
(event-convert-list '(control tt)) ; => C-tt

If, however, this the Right Thing for some reason I don't see, the
documentation for `event-convert-list' needs to be changed:

"The return value is an event type (a character or symbol) ***which
has the same base event type*** and all the specified modifiers"
(emphasis added).

(event-convert-list '(t)) ; => 116
(event-basic-type t) ; => t

In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.22.0)
 of 2010-12-12 on lappy
Windowing system distributor `The X.Org Foundation', version 11.0.10900000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t




Acknowledgement sent to Don March <don@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7631; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.