From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Commands with more than one keybinding in menus Date: Wed, 14 Aug 2013 12:23:12 -0400 Organization: A noiseless patient Spider Message-ID: References: <87ob91i99x.fsf@gmail.com> <871u5wh2jx.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1376497514 18310 80.91.229.3 (14 Aug 2013 16:25:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Aug 2013 16:25:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 14 18:25:17 2013 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 1V9dsr-0005lP-Aw for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Aug 2013 18:25:17 +0200 Original-Received: from localhost ([::1]:43711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9dsq-0001Gy-UY for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Aug 2013 12:25:16 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 19 Injection-Info: mx05.eternal-september.org; posting-host="bef50a77c8482b3cee00ee60292ca3f1"; logging-data="26887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eTlP6N7Gk/NeE3FfK5aAP" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:3oNMFxiXtq1LbCUOqWqWDhbysDU= sha1:2zWmzDuvggz2jZfAnRPUy8a8+D8= Original-Xref: usenet.stanford.edu gnu.emacs.help:200621 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:92888 Archived-At: > The macro was offered by a user of outshine, I only fiddled around with > it until it worked without errors. It serves its purpose, because > without it a minor-mode, unconditionally defining 'M-[S-]' > bindings, runs a high risk of breaking major-mode or user settings - I > would not want to do without it. There are a few ways to have your cake and eat it too: - Move the conditional test into the command, so the menu entries are bound to the same command as the keys. If you want the menu-entries to skip the test, then you can do that by checking the event(s) that triggered the command. - You can use ":keys STRING" in the menu. This will show "STRING" as the shortcut without checking if it indeed runs the same command. - You can use dynamic key-bindings, i.e. instead of binding your key to (lambda () (interactive) (if foo (CMD))), bind it to (menu-item "" CMD :filter (lambda (cmd) (if foo cmd))). Stefan