From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry OReilly Newsgroups: gmane.emacs.bugs Subject: bug#12022: Unable to use anonymous functions for Key Translations Date: Sat, 21 Jul 2012 22:53:05 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8fb205f27ad92e04c5623a0e X-Trace: dough.gmane.org 1342925629 18577 80.91.229.3 (22 Jul 2012 02:53:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 22 Jul 2012 02:53:49 +0000 (UTC) To: 12022@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 22 04:53:47 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SsmIh-0000B1-OS for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Jul 2012 04:53:44 +0200 Original-Received: from localhost ([::1]:51676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmIg-0004sx-Qw for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Jul 2012 22:53:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmId-0004ss-IF for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SsmIb-00029N-Mk for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:39 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmIb-00029J-Id for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SsmOo-0001ts-S1 for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 23:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Barry OReilly Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Jul 2012 03:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12022 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13429259837252 (code B ref -1); Sun, 22 Jul 2012 03:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jul 2012 02:59:43 +0000 Original-Received: from localhost ([127.0.0.1]:56566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SsmOU-0001su-Jx for submit@debbugs.gnu.org; Sat, 21 Jul 2012 22:59:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46356) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SsmOR-0001sk-0E for submit@debbugs.gnu.org; Sat, 21 Jul 2012 22:59:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SsmIB-00028K-7I for submit@debbugs.gnu.org; Sat, 21 Jul 2012 22:53:13 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:33019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmIB-00028G-3o for submit@debbugs.gnu.org; Sat, 21 Jul 2012 22:53:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmI9-0004sj-7N for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SsmI7-00027n-05 for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:09 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:64654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SsmI6-00027g-Nq for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2012 22:53:06 -0400 Original-Received: by obhx4 with SMTP id x4so9087095obh.0 for ; Sat, 21 Jul 2012 19:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=gcAUoWTlVUtzrKv8C5Fur7uCYeUWEtF7Nyx1VbTge44=; b=Mz7a+rUNxNpdsXuMQUTV6Om93wDlT9X8xU5v7k8TUkAspVaSGhGALMVgfAGQDzDtLY Mc7OLWL4S9BT6L2RUHaS5A6qB8pTiOwmtFDCR9V6VHp7quiBZK6F/T5Zy8Qfd9kcDpcD 4DzFH2Uu5amb5BDAzXb4GMZSHYSDyfvh6sGtzCcB9DHb+6AX1jCjlJD6LykLNu0w1LRk IdRfdh03qu5YGl/rnDZeSxEOb4WTyXBWNIG76/oACJXaRZZ/fsk0CgOna/UT8sFJvkfT GNLtBK797fejR5jI4n7v9P109OjxK1v/JWDXtXqIPwlCpLnceK1c9Rmx22wJKqgVkvuv Wk0w== Original-Received: by 10.60.2.3 with SMTP id 3mr14797693oeq.0.1342925585438; Sat, 21 Jul 2012 19:53:05 -0700 (PDT) Original-Received: by 10.182.179.35 with HTTP; Sat, 21 Jul 2012 19:53:05 -0700 (PDT) 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, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62260 Archived-At: --e89a8fb205f27ad92e04c5623a0e Content-Type: text/plain; charset=ISO-8859-1 Using an anonymous function to translate keys as described in the Elisp manual at http://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-Keymaps.htmldoes not work as expected. Using a named function to map C-e to C-c, the Key Translation is successful: (progn (fset 'foo (lambda (prompt) (kbd "C-c"))) (define-key key-translation-map (kbd "C-e") 'foo)) Using an anonymous function for another keymap binds C-e to the lambda-defined command. (define-key global-map (kbd "C-e") (lambda () (interactive) (message "Inside C-e's lambda"))) But using an anonymous function for key-translation-map does not change behavior of inputting C-e: (define-key key-translation-map (kbd "C-e") (lambda (prompt) (kbd "C-c"))) I find no reason why the last Elisp shouldn't define a Key Translation. The Elisp manual section on Anonymous Functions states "Anonymous functions are valid wherever function names are." ( http://www.gnu.org/software/emacs/manual/html_node/elisp/Anonymous-Functions.html) This bug report will be sent to the Bug-GNU-Emacs mailing list and the GNU bug tracker at debbugs.gnu.org. Please check that the From: line contains a valid email address. After a delay of up to one day, you should receive an acknowledgement at that address. Please write in English if possible, as the Emacs maintainers usually do not have translators for other languages. Please describe exactly what actions triggered the bug, and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. For information about debugging Emacs, please read the file /home/epich/sw/emacs-24.1/install/share/emacs/24.1/etc/DEBUG. In GNU Emacs 24.1.1 (i686-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2012-07-07 on epich-hp Windowing system distributor `The X.Org Foundation', version 11.0.11001000 Configured using: `configure '--prefix=/home/epich/sw/emacs-24.1/install'' 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.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-y C-y C-y C-e M-x e v a l - l a s t s e x p - s e x p C-e C-g ( d e f i n e - k e y SPC k e y - t r a n s l a t i o n - m a p SPC ( k b d SPC " C - e " SPC n i l ) ) M-x e v i l a l - l a s t - s e x p ) SPC M-x e v a l - l a s t - s e x p C-e C-e M-x e v a l - l a s t - s e x p C-e M-x e v a l - l a s t - s e x p C-e C-e C-e M-x r e p o r t - e m a c s - q q M-x r e p o r t - e m a c s - b u g Recent messages: You can run the command `eval-last-sexp' with C-x C-e (lambda nil (interactive) (message "Inside C-e's lambda")) You can run the command `eval-last-sexp' with C-x C-e Inside C-e's lambda (lambda (prompt) (kbd "C-c")) You can run the command `eval-last-sexp' with C-x C-e Inside C-e's lambda [3 times] delete-backward-char: Text is read-only [2 times] Quit Back to top level. Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode easymenu view debug edmacro kmacro time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dynamic-setting font-render-setting x-toolkit x multi-tty emacs) --e89a8fb205f27ad92e04c5623a0e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Using an anonymous function to translate keys as described in the Elisp man= ual at http://www.gnu.org/software/emacs/manual/html_nod= e/elisp/Translation-Keymaps.html does not work as expected.

Using a named function to map C-e to C-c, the Key Translation is succes= sful:
=A0 (progn (fset 'foo (lambda (prompt) (kbd "C-c")))=
=A0=A0=A0=A0=A0=A0=A0=A0 (define-key key-translation-map (kbd "C-e= ") 'foo))
=A0=A0=A0=A0=A0=A0=A0=A0
Using an anonymous function for another keymap= binds C-e to the lambda-defined command.
=A0 (define-key global-map
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (kbd "C-e")
=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (lambda () (interactive) (message "Insi= de C-e's lambda")))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
But using an anonymous function for k= ey-translation-map does not change behavior of inputting C-e:
=A0 (defin= e-key key-translation-map
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (kbd &= quot;C-e")
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (lambda (prompt)= (kbd "C-c")))

I find no reason why the last Elisp shouldn't define a Key Translat= ion.=A0 The Elisp manual section on Anonymous Functions states "Anonym= ous functions are valid wherever function names are."=A0 ( http://www.gnu.org/software/emacs/manual/html_node/elisp/Anonymous-= Functions.html )







This bug report will be sent to the Bug-GNU-Ema= cs mailing list
and the GNU bug tracker at debbugs.gnu.org.=A0 Please check that
the From: line contains = a valid email address.=A0 After a delay of up
to one day, you should receive an acknowledgement at that address.

P= lease write in English if possible, as the Emacs maintainers
usually do = not have translators for other languages.

Please describe exactly wh= at actions triggered the bug, and
the precise symptoms of the bug.=A0 If you can, give a recipe
starting f= rom `emacs -Q':



If Emacs crashed, and you have the Emacs= process in the gdb debugger,
please include the output from the followi= ng gdb commands:
=A0=A0=A0 `bt full' and `xbacktrace'.
For information about debu= gging Emacs, please read the file
/home/epich/sw/emacs-24.1/install/shar= e/emacs/24.1/etc/DEBUG.


In GNU Emacs 24.1.1 (i686-pc-linux-gnu, = X toolkit, Xaw scroll bars)
=A0of 2012-07-07 on epich-hp
Windowing system distributor `The X.Org Fou= ndation', version 11.0.11001000
Configured using:
=A0`configure &= #39;--prefix=3D/home/epich/sw/emacs-24.1/install''

Important= settings:
=A0 value of $LC_ALL: nil
=A0 value of $LC_COLLATE: nil
=A0 value of = $LC_CTYPE: nil
=A0 value of $LC_MESSAGES: nil
=A0 value of $LC_MONETA= RY: nil
=A0 value of $LC_NUMERIC: nil
=A0 value of $LC_TIME: nil
= =A0 value of $LANG: en_US.UTF-8
=A0 value of $XMODIFIERS: nil
=A0 locale-coding-system: utf-8-unix
= =A0 default enable-multibyte-characters: t

Major mode: Lisp Interact= ion

Minor modes in effect:
=A0 tooltip-mode: t
=A0 mouse-wheel= -mode: t
=A0 tool-bar-mode: t
=A0 menu-bar-mode: t
=A0 file-name-shadow-mode: = t
=A0 global-font-lock-mode: t
=A0 font-lock-mode: t
=A0 blink-cur= sor-mode: t
=A0 auto-composition-mode: t
=A0 auto-encryption-mode: t<= br>=A0 auto-compression-mode: t
=A0 line-number-mode: t
=A0 transient-mark-mode: t

Recent input:<= br>C-y <return> C-y <return> C-y <up> <up> <up&g= t; <up> <up>
<up> <up> <up> <up> &l= t;up> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <r= ight> <right>
<right> <right> <right> <ri= ght> <right> <right> <right>
<right> <rig= ht> <right> <right> <right> <right> <right>= ;
<right> <right> <right> <right> <right> <r= ight> <right>
<right> <right> <right> C-e M-= x e v a l - l a s t s
e x p <backspace> <backspace> <bac= kspace> <backspace>
- s e x p <return> <left> <left> <left> C-e C-g <= ;right>
<right> <right> <return> <return> ( = d e f i n e - k
e y SPC k e y - t r a n s l a t i o n - m a p SPC ( k b d SPC " C - e " SPC n i l ) ) M-x e v i l <backspace> <= br><backspace> a l - l a s t - s e x p <return> <down-mouse-= 1>
<mouse-movement> <mouse-1> <right> ) <right&= gt; <right>
<right> <right> <right> <right> <backspace> &= lt;left>
<right> <right> <left> SPC M-x e v a l - = l a s t -
s e x p <return> <left> <left> <left>= <left> C-e <down>
<down> <down> <up> <left> <left> <down>= <down> C-e
M-x e v a l - l a s t - s e x p <return> <le= ft> <left>
<left> C-e <down> <down> <down= > <down> M-x e v a l
- l a s t - s e x p <return> <left> <left> C-e C-e
&l= t;left> <left> C-e M-x r e p o r t - e m a c s - <backspace>=
<backspace> <backspace> <backspace> <backspace>= ; <backspace>
<backspace> <backspace> <backspace> <backspace> <= ;backspace>
<backspace> <backspace> <backspace> &l= t;backspace> <down-mouse-1>
q <mouse-1> q <down-mouse= -1> <mouse-1> M-x r e p o
r t - e m a c s - b u g <return>

Recent messages:
You can r= un the command `eval-last-sexp' with C-x C-e
(lambda nil (interactiv= e) (message "Inside C-e's lambda"))
You can run the comman= d `eval-last-sexp' with C-x C-e
Inside C-e's lambda
(lambda (prompt) (kbd "C-c"))
You c= an run the command `eval-last-sexp' with C-x C-e
Inside C-e's la= mbda [3 times]
delete-backward-char: Text is read-only [2 times]
Quit
Back to top level.

Load-path shadows:
None found.

= Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec = rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mail= abbrev
gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045 ietf-drums
mm-u= til mail-prsvr mail-utils help-mode easymenu view debug edmacro
kmacro t= ime-date tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd = tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
sy= ntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnam= ese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slov= ak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefsbutton faces cus-face files text-properties overlay sha1 md5 base64
for= mat env code-pages mule custom widget hashtable-print-readable
backquote= make-network-process dynamic-setting font-render-setting
x-toolkit x multi-tty emacs)

--e89a8fb205f27ad92e04c5623a0e--