From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Josh Newsgroups: gmane.emacs.bugs Subject: bug#13948: no key-binding-locus Date: Tue, 23 Apr 2013 12:41:28 -0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1366746130 23679 80.91.229.3 (23 Apr 2013 19:42:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Apr 2013 19:42:10 +0000 (UTC) Cc: 13948@debbugs.gnu.org To: Brian Malehorn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 23 21:42:14 2013 Return-path: Envelope-to: geb-bug-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 1UUj6T-0001xa-4N for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Apr 2013 21:42:13 +0200 Original-Received: from localhost ([::1]:43377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUj6S-0008Pa-NY for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Apr 2013 15:42:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUj6M-0008KW-Ri for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2013 15:42:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUj6K-0006P9-61 for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2013 15:42:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUj6K-0006P5-3J for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2013 15:42:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UUjB8-0004jM-1v for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2013 15:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Josh Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Apr 2013 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13948 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13948-submit@debbugs.gnu.org id=B13948.136674642018177 (code B ref 13948); Tue, 23 Apr 2013 19:47:02 +0000 Original-Received: (at 13948) by debbugs.gnu.org; 23 Apr 2013 19:47:00 +0000 Original-Received: from localhost ([127.0.0.1]:39547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UUjB5-0004j7-Sj for submit@debbugs.gnu.org; Tue, 23 Apr 2013 15:47:00 -0400 Original-Received: from mail-qc0-f176.google.com ([209.85.216.176]:61923) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UUjB3-0004j1-Rn for 13948@debbugs.gnu.org; Tue, 23 Apr 2013 15:46:58 -0400 Original-Received: by mail-qc0-f176.google.com with SMTP id n41so522563qco.7 for <13948@debbugs.gnu.org>; Tue, 23 Apr 2013 12:41:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=qa4zg7Q0UwuXVR35fpNF4fsyA9PNpHO6IpCNGNJMn8k=; b=BBvatB1kFiNhmQxnr6dXSmopLpdNGDYsZVa2HPOewFpz8pwy8Vot9dy8lS2MpRvVFK BhWdeYFEky3MiHVH5un4/4VVd3XSVoJRR4qIGPVrLd+fIqJLHaltlmyEObjYGRUrgEV3 aF9UvA7KsWD8auz2ig5nEusmsxfy3kq4fzMAUXPwZvqJouFpm9nnZqeJs8QNQ0cI2VvJ k/e7hN+N46AoeUkncgHG7EVQeundu7wuiImg/+Mj6O09dV5G8gLrBeFB2PQ5KcBozsbT 6WybVULDojjwY5cy3w263NlxI9e3cotvULDLUV8GZ/3HjEYUeDXqS169TDSbjZTUapR6 h+mA== X-Received: by 10.224.17.2 with SMTP id q2mr21530729qaa.59.1366746119139; Tue, 23 Apr 2013 12:41:59 -0700 (PDT) Original-Received: by 10.49.59.115 with HTTP; Tue, 23 Apr 2013 12:41:28 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: T-VbMcg5aA17PFhWBGl5BdQfzzc X-Gm-Message-State: ALoCoQmIHd/AHUfiiuK4psDoggTRNpgtKZkxPIFwHkUtyzhreJE6jdGPW4ZVutzM5epgsUxVUKD8 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73610 Archived-At: On Wed, Mar 13, 2013 at 1:34 PM, Brian Malehorn wrote: > Why isn't there a key equivalent to variable-binding-locus? As > in, a way to figure out where a particular keybinding is coming > from. For example, > > M-x key-binding-locus C-j > > would evaluate to 'lisp-interaction-mode-map, which is the first > map in which C-j was found. +1. The hierarchy, search order, and precedence of Emacs' various keymaps and key translation mechanisms is complex and in my experience seldom well understood by users. This often manifests as confusion about why global-set-key or local-set-key forms that users have added to their init files do not have the expected effects. The documentation that Brian quoted below doesn't seem very useful to a typical Emacs user trying to troubleshoot key binding problems. One reason is that while the mechanisms for binding keys are described in the Emacs manual[0], the key binding lookup procedure is not described therein, but instead in the Elisp manual[1] where it is likely to be overlooked. A second reason is that even for those users who do manage to find that info node, perhaps with info-apropos for example, a "pseudo Lisp" description is not very helpful to users who don't know Lisp. I think the command Brian suggested would help average users with little to no Elisp knowledge to debug key binding problems, especially if it supported optionally showing all of the keymaps that were searched in the process. It would also be helpful for describe-key to show the governing keymap and to disclose the existence and location of any shadowed key bindings, something like this: C-c { runs the command some-foo-mode-command, which is an interactive autoloaded compiled Lisp function bound by `foo-mode.el' in `foo-mode-map'. It is bound to C-c {[, any other non-shadowed bindings] Shadowed C-c { bindings in other keymaps: bar-minor-mode-command (bound by `bar-mode.el' in `bar-mode-map'. my-func (bound by `init.el' in `global-map') [remainder of standard describe-key output follows] Josh [0] (info "(emacs) Key Bindings") [1] (info "(elisp) Searching Keymaps") > In terms of implementation, the process for finding a binding is > described in (info "(elisp) Searching Keymaps"): > > ...Here is a pseudo-Lisp description of the order and > conditions for searching them: > > (or (cond > (overriding-terminal-local-map > (FIND-IN overriding-terminal-local-map)) > (overriding-local-map > (FIND-IN overriding-local-map)) > ((or (FIND-IN (get-char-property (point) 'keymap)) > (FIND-IN-ANY emulation-mode-map-alists) > (FIND-IN-ANY minor-mode-overriding-map-alist) > (FIND-IN-ANY minor-mode-map-alist) > (if (get-text-property (point) 'local-map) > (FIND-IN (get-char-property (point) 'local-map)) > (FIND-IN (current-local-map)))))) > (FIND-IN (current-global-map)))