* bug#12022: Unable to use anonymous functions for Key Translations
@ 2012-07-22 2:53 Barry OReilly
2012-08-12 2:45 ` bug#12022: [PATCH] Unable to use anonymous functions for Key Translations, Barry OReilly
0 siblings, 1 reply; 2+ messages in thread
From: Barry OReilly @ 2012-07-22 2:53 UTC (permalink / raw)
To: 12022
[-- Attachment #1: Type: text/plain, Size: 5739 bytes --]
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 <return> C-y <return> C-y <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> C-e M-x e v a l - l a s t s
e x p <backspace> <backspace> <backspace> <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>
<backspace> a l - l a s t - s e x p <return> <down-mouse-1>
<mouse-movement> <mouse-1> <right> ) <right> <right>
<right> <right> <right> <right> <backspace> <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> <left> <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
<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> <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 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)
[-- Attachment #2: Type: text/html, Size: 7415 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#12022: [PATCH] Unable to use anonymous functions for Key Translations,
2012-07-22 2:53 bug#12022: Unable to use anonymous functions for Key Translations Barry OReilly
@ 2012-08-12 2:45 ` Barry OReilly
0 siblings, 0 replies; 2+ messages in thread
From: Barry OReilly @ 2012-08-12 2:45 UTC (permalink / raw)
To: 12022
[-- Attachment #1.1: Type: text/plain, Size: 1248 bytes --]
> 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)
Hi,
I found where the definition of a key translation is called, and made a
patch. The quoted test case works correctly now. Is the change ok?
[-- Attachment #1.2: Type: text/html, Size: 1679 bytes --]
[-- Attachment #2: lambdaKeyTranslation.txt --]
[-- Type: text/plain, Size: 2198 bytes --]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: gundaetiapo@gmail.com-20120812022358-9hf38s3yqrngmwj0
# target_branch: bzr://bzr.savannah.gnu.org/emacs/trunk/
# testament_sha1: 97ac7d396cfcbf692e8e88df42589ecba0fc8c70
# timestamp: 2012-08-11 22:24:03 -0400
# base_revision_id: jasonr@gnu.org-20120811145028-ax1qarn6z0mj5gtr
#
# Begin patch
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2012-08-08 15:53:52 +0000
+++ src/keyboard.c 2012-08-12 02:23:58 +0000
@@ -8837,7 +8837,8 @@
/* If the keymap gives a function, not an
array, then call the function with one arg and use
its value instead. */
- if (SYMBOLP (next) && !NILP (Ffboundp (next)) && do_funcall)
+ if ((SYMBOLP (next) && !NILP (Ffboundp (next)) || FUNCTIONP(next))
+ && do_funcall)
{
Lisp_Object tem;
tem = next;
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWWp4r5MAAXxfgBAQceP/93sn
3iC////0UAN88dFe9qAANJT1NpDQ0BoD0gaAaNH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nKFy6LaKGtPUgtuqgmpiJ77SIOnwcoLzFJ9z4Qo1NV9p1FRbGs7
GV7AZBap2K/lSTQ/6qDWNK2TkbIXzSwpM6PnKoK03gmxk1YdqaGG9RStjS3ooq4HcBZqlXqgWikr
c0a1T6i8VG8o98f/F3JFOFCQanivkw==
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-12 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-22 2:53 bug#12022: Unable to use anonymous functions for Key Translations Barry OReilly
2012-08-12 2:45 ` bug#12022: [PATCH] Unable to use anonymous functions for Key Translations, Barry OReilly
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.