From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Elena Newsgroups: gmane.emacs.help Subject: Re: Short-circuiting keybindings? Date: Wed, 10 Nov 2010 03:15:13 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <614cd66c-4814-4f58-89b7-cfdc067cc620@d8g2000yqf.googlegroups.com> <87k4kmf3at.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291890501 29326 80.91.229.12 (9 Dec 2010 10:28:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 10:28:21 +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 Dec 09 11:28:17 2010 Return-path: Envelope-to: geh-help-gnu-emacs@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 1PQdjT-0006SR-2u for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 11:28:15 +0100 Original-Received: from localhost ([127.0.0.1]:36861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQdjR-00048p-O7 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 05:28:14 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!d28g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 21 Original-NNTP-Posting-Host: 89.96.190.244 Original-X-Trace: posting.google.com 1289387713 26950 127.0.0.1 (10 Nov 2010 11:15:13 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 10 Nov 2010 11:15:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d28g2000yqn.googlegroups.com; posting-host=89.96.190.244; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.6.30 Version/10.63,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:182310 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76955 Archived-At: On 10 Nov, 00:08, p...@informatimago.com (Pascal J. Bourguignon) wrote: > Elena writes: > > is there a generic way to create "short-circuiting" keybindings? =A0I > > mean: let's say I want "C-b" to issue a command only whenever a > > condition is met, otherwise if "C-b" is a prefix key then Emacs should > > continue listening for keystrokes and execute commands when > > appropriate. > > Really, to do what you have in mind, the easiest and cleanest would be > to modify the core of emacs, in the C sources. Ouch! That would be cumbersome. > > You could add hooks, or change the mechanisms. Thanks for your suggestion. Such goal can be achieved on case basis. For instance, let's say we want "C-b" to be bound to a command, thus shadowing "C-b C-c", only when region is active. We could bind "C-b C- b" globally, while binding "C-b" in `activate-mark-hook' and unbinding it in `deactivate-mark-hook'. Right?