From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry OReilly Newsgroups: gmane.emacs.help Subject: Trouble using a lambda in the key-translation-map Date: Wed, 18 Jul 2012 18:45:08 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1342663774 515 80.91.229.3 (19 Jul 2012 02:09:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2012 02:09:34 +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 04:09:34 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 1SrgBB-00073L-UF for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 04:09:26 +0200 Original-Received: from localhost ([::1]:44744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrgBB-0003c7-5R for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 22:09:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrczW-0005jx-KV for help-gnu-emacs@gnu.org; Wed, 18 Jul 2012 18:45:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrczV-0002QK-Iq for help-gnu-emacs@gnu.org; Wed, 18 Jul 2012 18:45:10 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:58914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrczV-0002Pt-EJ for help-gnu-emacs@gnu.org; Wed, 18 Jul 2012 18:45:09 -0400 Original-Received: by obhx4 with SMTP id x4so3496073obh.0 for ; Wed, 18 Jul 2012 15:45:08 -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=A2H8Si6odJZ+BMAEjuzwKy7uUFiGvcnWfRm16M1UEZA=; b=qMIRp1tnSXWhUweuL/DwJa8WPstz8OQFi+6bW8eKAs0HO46pPQoo1PRByLLU38XzRT VmGtHInwCONSy6d1e6PSrdFm8rteu+TWgfaurHhOBNzqnHiYsD4eTpIhPG6wtiP0IEZB VqfAr6FyG85SXRioP3az/+XAH6w8Dc7a9tbYp7VGidp/LQL2nReWyC9SpioVsS4YYVGU 47lTertf4y0z7fNjdMESX0/VRW9I1e+f9ofIoIB34o9T31aVru4NiHTqBSr90/xyz7bZ +fAyeXQ3fKSEFVbW8GoogZAeJD/VnsXYrS8j6YgJkdNwCf9YMG1iYXXFk6y/+f6WBezd ZRdQ== Original-Received: by 10.182.108.71 with SMTP id hi7mr3815948obb.21.1342651508536; Wed, 18 Jul 2012 15:45:08 -0700 (PDT) Original-Received: by 10.182.179.35 with HTTP; Wed, 18 Jul 2012 15:45:08 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-Mailman-Approved-At: Wed, 18 Jul 2012 22:09:14 -0400 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:85926 Archived-At: 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?