From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Trouble using a lambda in the key-translation-map Date: Wed, 18 Jul 2012 23:45:09 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1342669818 3774 80.91.229.3 (19 Jul 2012 03:50:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2012 03:50:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 19 05:50:17 2012 Return-path: Envelope-to: geh-help-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 1Srhki-0002gl-AD for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 05:50:12 +0200 Original-Received: from localhost ([::1]:57707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srhkh-0006AB-ML for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 23:50:11 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 30 Injection-Info: barmar.motzarella.org; posting-host="a9b4e51b87895258cf550adcd0b368a2"; logging-data="17368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lUj3iLOFoXKLN0KngPe+a" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:lNaNxm1GxnalZT9Xb7xClVUPQoo= Original-Xref: usenet.stanford.edu gnu.emacs.help:193552 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85927 Archived-At: In article , Barry OReilly wrote: > As the Elisp manual describes, one can bind a key to a function in the > key-translation-map, and use that function to programmatically > determine what to translate the key to. > http://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-Keymaps > .html > > I got this to work for functions defined with defun, but can't get it > to work with a lambda. In an 'emacs -q' session, I put this in the > scratch buffer: > (defun my-translate-key (prompt) (interactive) (kbd "C-c")) > (define-key key-translation-map (kbd "C-e") (lambda (prompt) > (interactive) (kbd "C-c"))) ; Doesn't work > (define-key key-translation-map (kbd "C-e") 'my-translate-key) ; Works > > I evaluate the first and second sexp, and find C-e still goes to the > end of the line. When I next execute the third sexp, C-e now > translates to C-c. Why doesn't the second sexp enable the translation > from C-e to C-c? Look at the description of define-key -- the third argument has to be a SYMBOL for it to be treated as a function. Lambda doesn't return a function, it returns a list. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***