From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: A bug, I think, in key-binding Date: Tue, 22 Aug 2006 11:41:44 -0400 Message-ID: References: <858xly975r.fsf@lola.goethe.zz> <87y7tysd7e.fsf-monnier+emacs@gnu.org> <85oduitihg.fsf@lola.goethe.zz> Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1156261497 14134 80.91.229.2 (22 Aug 2006 15:44:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 22 Aug 2006 15:44:57 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 22 17:44:54 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GFYQH-0007X3-7V for ged-emacs-devel@m.gmane.org; Tue, 22 Aug 2006 17:44:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFYQH-00089A-3u for ged-emacs-devel@m.gmane.org; Tue, 22 Aug 2006 11:44:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GFYNu-0004u2-Nu for emacs-devel@gnu.org; Tue, 22 Aug 2006 11:41:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GFYNt-0004sE-Gl for emacs-devel@gnu.org; Tue, 22 Aug 2006 11:41:45 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFYNt-0004s2-0S for emacs-devel@gnu.org; Tue, 22 Aug 2006 11:41:45 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GFYVW-0005lW-HM for emacs-devel@gnu.org; Tue, 22 Aug 2006 11:49:38 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1GFYNs-0001v2-2E; Tue, 22 Aug 2006 11:41:44 -0400 Original-To: David Kastrup In-reply-to: <85oduitihg.fsf@lola.goethe.zz> (message from David Kastrup on Fri, 18 Aug 2006 13:02:03 +0200) 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:58725 Archived-At: > > Perhaps we should have a function to do lookup on a key > > sequence just the same way the command loop does. That can be > > written in Lisp; it just has to see if the first event is a > > mouse even, and move point there inside save-excursion. ... > Perhaps an optional argument to key-binding is the way to do it. > Would you like to implement that? Actually, I don't think we should need an optional argument at all: when feeding an event into key-binding (which is defined to use all local maps), one would likely rather have the same maps apply as read-key-sequence has. I agree that is the cleanest design, but I was worried about the incompatible change it involves. So I just checked all the calls to `key-binding' and `XYZ-key-binding' in the Emacs sources (except those in viper). It seems that this change would hardly ever cause a bug, and often might fix a bug. So I am now in favor of your proposal. Would someone please implement this, then ack this message? key-binding is a built-in function in `C source code'. (key-binding SEQUENCE &optional ACCEPT-DEFAULT NO-REMAP LOCATION) Return the binding for command SEQUENCE in current keymaps. SEQUENCE is a string or vector, a sequence of keystrokes, or an event to look up. The binding is probably a symbol with a function definition. Normally, `key-binding' ignores bindings for t, which act as default bindings, used when nothing else in the keymap applies; this makes it usable as a general function for probing keymaps. However, if the optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does recognize the default bindings, just as `read-key-sequence' does. Like the normal command loop, `key-binding' will remap the command resulting from looking up KEY by looking up the command in the current keymaps. However, if the optional third argument NO-REMAP is non-nil, `key-binding' returns the unmapped command. If SEQUENCE is a mouse event, the current maps may depend on whether the event occured above mouse-sensitive areas. If LOCATION is an event, the current maps will be selected according to LOCATION rather than SEQUENCE. This can be used for looking up artificial bindings like `follow-link'. If LOCATION is non-nil but not an event, the current maps will not be mouse-sensitive even when SEQUENCE is an event.