From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Get a command by its keybinding and also respecting key translation Date: Mon, 20 Dec 2010 09:19:59 +0100 Message-ID: <87y67kdff4.fsf@member.fsf.org> References: <871v5lpkk6.fsf@member.fsf.org> <201012142351.21774.tassilo@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1292833216 5169 80.91.229.12 (20 Dec 2010 08:20:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 20 Dec 2010 08:20:16 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 20 09:20:12 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PUayY-0001gt-SZ for ged-emacs-devel@m.gmane.org; Mon, 20 Dec 2010 09:20:11 +0100 Original-Received: from localhost ([127.0.0.1]:49329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUayY-0001MN-2l for ged-emacs-devel@m.gmane.org; Mon, 20 Dec 2010 03:20:10 -0500 Original-Received: from [140.186.70.92] (port=58707 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUayS-0001M8-Ol for emacs-devel@gnu.org; Mon, 20 Dec 2010 03:20:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PUayP-0006L5-OC for emacs-devel@gnu.org; Mon, 20 Dec 2010 03:20:04 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:29719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PUayP-0006Kc-HJ for emacs-devel@gnu.org; Mon, 20 Dec 2010 03:20:01 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 6442C78016AB; Mon, 20 Dec 2010 09:20:00 +0100 (CET) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08093-02; Mon, 20 Dec 2010 09:19:59 +0100 (CET) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad (tsdh.uni-koblenz.de [141.26.67.142]) by deliver.uni-koblenz.de (Postfix) with ESMTP id AD49A7801666; Mon, 20 Dec 2010 09:19:59 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Sat, 18 Dec 2010 11:16:17 -0500") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-Virus-Scanned: amavisd-new at uni-koblenz.de X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133826 Archived-At: Stefan Monnier writes: Hi Stefan, >>> (define-key outline-minor-mode-map >>> (kdb "") >>> `(menu-item "dummy" org-cycle >>> :filter ,(lambda (cmd) >>> (if (th-outline-context-p) cmd)))) > >> Hm, just for educational purposes, could you please explain the >> backquoting and the comma-substitution of the lambda? I mean, I know >> that `,' in a backquote triggers evaluation, but since a lambda evals >> to itself, what's the point in doing so? > > Without backquote and comma, the whole menu-item is just a piece of > data which happens to contain something that looks like a function. > With the backquote and comma, it turns into something that contains a > function, so tools can handle this `lambda' knowing that it *is* a > function (e.g. it can be byte-compiled, can cause warnings if it uses > obsolete functions, can be macro-expanded, ...). Thanks! So now the next question, how can I write a macro whose expansion contains backticks and commas, and I'm still able to comma-expand in the "inner" backquoted parts? Or with an example: (defmacro define-context-key (keymap key dispatch) `(define-key ,keymap ,key (backquote (menu-item "context-key" ignore :filter (lambda (&optional ignored) ,dispatch))))) How do I smuggle a `,' before the lambda? Bye, Tassilo