From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 17:21:51 2013 Received: (at submit) by debbugs.gnu.org; 13 Mar 2013 21:21:51 +0000 Received: from localhost ([127.0.0.1]:51997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFt7M-0002LK-4u for submit@debbugs.gnu.org; Wed, 13 Mar 2013 17:21:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36174) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFsPs-0001Ey-W2 for submit@debbugs.gnu.org; Wed, 13 Mar 2013 16:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFsOe-0006Dn-PK for submit@debbugs.gnu.org; Wed, 13 Mar 2013 16:35:40 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:46166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFsOe-0006Di-Lm for submit@debbugs.gnu.org; Wed, 13 Mar 2013 16:35:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFsOb-0005SP-8z for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:35:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFsOX-00069p-A6 for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:35:33 -0400 Received: from mail-ie0-x234.google.com ([2607:f8b0:4001:c03::234]:57854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFsOX-00069a-0P for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:35:29 -0400 Received: by mail-ie0-f180.google.com with SMTP id bn7so2094006ieb.11 for ; Wed, 13 Mar 2013 13:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=UZ1JUmrcnUR8AC+73iAtCiPLKKtZ6DYQb6i/v6njZ+s=; b=vNuyAAUJAnVzhQNklEaCBvjl4lEOAa1So+eP+Yf/LmiSjX65cOoDIrSTBiT1obP+YG SkDKfiAa/u/kp6CpTHQONRaKcSdBIHRsj+jtNUSdwfiXh5+AkX7KISrkfB2sLwP8CVsD f/a04txsEI620CPPE9t4mb54fuJH1qwedMUPfX1YpejUhSWaHolzQ2t1GBJ5J/b+dTYC QUghhBkyJnu4rkLoO03/WzJD9hH1e4Mm7fNKF0GW5hEH0aCBqADUPycDRUVrOdsuWPjN uQY3IugGulj3WkRrEk27muja2sDbbE9NE5hrGML57pWrwuEwcYdyae4K0mQqOSZ48b0l +DHQ== X-Received: by 10.50.11.138 with SMTP id q10mr18116887igb.5.1363206928147; Wed, 13 Mar 2013 13:35:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.43.100.201 with HTTP; Wed, 13 Mar 2013 13:34:48 -0700 (PDT) From: Brian Malehorn Date: Wed, 13 Mar 2013 16:34:48 -0400 Message-ID: Subject: no key-binding-locus To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=e89a8f503254b579e204d7d45875 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 13 Mar 2013 17:21:46 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --e89a8f503254b579e204d7d45875 Content-Type: text/plain; charset=ISO-8859-1 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. 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))) So implementing key-binding-locus would only be a small tweak of the key lookup code: the first time you find the key, just return the map you found it in, rather than the command it's supposed to call. Thanks, Brian --e89a8f503254b579e204d7d45875 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Why isn't there a key equivalent to variable-bind= ing-locus? As
in, a way to figure out where a particular keybindi= ng is coming
from. For example,

=A0 =A0 = 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.


In terms of implementation, the process for finding a bind= ing is
described in (info "(elisp) Searching Keymaps"):
<= br>
=A0 =A0 ...Here is a pseudo-Lisp description of the order and=
=A0 =A0 conditions for searching them:

= =A0 =A0 =A0(or (cond
=A0 =A0 =A0 =A0 =A0 (overriding-terminal-local-map
=A0 =A0 = =A0 =A0 =A0 =A0(FIND-IN overriding-terminal-local-map))
=A0 =A0 = =A0 =A0 =A0 (overriding-local-map
=A0 =A0 =A0 =A0 =A0 =A0(FIND-IN= overriding-local-map))
=A0 =A0 =A0 =A0 =A0 ((or (FIND-IN (get-ch= ar-property (point) 'keymap))
=A0 =A0 =A0 =A0(FIN= D-IN-ANY emulation-mode-map-alists)
=A0 =A0 =A0 =A0(FIND-IN-ANY minor-mode-overriding-map= -alist)
=A0 =A0 =A0 =A0(FIND-IN-ANY minor-mode-map-alist)
=A0 =A0 =A0 =A0(if = (get-text-property (point) 'local-map)
=A0 =A0 =A0 =A0 =A0 =A0(FIND-IN (get-char-prop= erty (point) 'local-map))
=A0 =A0 =A0 =A0 =A0= (FIND-IN (current-local-map))))))
=A0 =A0 =A0 =A0 =A0(FIND-IN (cu= rrent-global-map)))

So implementing key-binding-lo= cus would only be a small tweak of
the key lookup code: the first time you find the key, just return
the map you found it in, rather than the command it's supposed to=
call.

Thanks,
Brian

--e89a8f503254b579e204d7d45875-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 23 15:47:00 2013 Received: (at 13948) by debbugs.gnu.org; 23 Apr 2013 19:47:00 +0000 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 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 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) MIME-Version: 1.0 Received: by 10.49.59.115 with HTTP; Tue, 23 Apr 2013 12:41:28 -0700 (PDT) In-Reply-To: References: From: Josh Date: Tue, 23 Apr 2013 12:41:28 -0700 X-Google-Sender-Auth: T-VbMcg5aA17PFhWBGl5BdQfzzc Message-ID: Subject: Re: bug#13948: no key-binding-locus To: Brian Malehorn Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmIHd/AHUfiiuK4psDoggTRNpgtKZkxPIFwHkUtyzhreJE6jdGPW4ZVutzM5epgsUxVUKD8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) 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))) From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 02 06:14:29 2014 Received: (at 13948) by debbugs.gnu.org; 2 Jun 2014 10:14:29 +0000 Received: from localhost ([127.0.0.1]:40307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrPG9-0001pr-6Z for submit@debbugs.gnu.org; Mon, 02 Jun 2014 06:14:29 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:48788) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrPG6-0001ph-VU for 13948@debbugs.gnu.org; Mon, 02 Jun 2014 06:14:28 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhQKAABOjFOkD4Xx/2dsb2JhbABYrmMGmBsBgSh0giUBAQQBeQULCw4TJQ8BBA08E4gtAQMJCLFWm3ABSg2GBBeFVYIDhGSCFgeEQASYCIhOhmSFc4M6Ow Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3.ulb.ac.be) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 02 Jun 2014 12:14:21 +0200 From: Nicolas Richard To: Brian Malehorn Subject: Re: bug#13948: no key-binding-locus References: Date: Mon, 02 Jun 2014 12:15:34 +0200 In-Reply-To: (Brian Malehorn's message of "Wed, 13 Mar 2013 16:34:48 -0400") Message-ID: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Brian Malehorn writes: > 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, > So implementing key-binding-locus would only be a small tweak of > the key lookup code: the first time you find the key, just return > the map you found it in, rather than the command it's supposed to > call. IIUC, it's slightly more complicated than just modifying the return value of a function. One reason is that "finding active keymaps" and "looking up keys in keymaps" are done by different bits of the code. By the time keys are being looked up, we don't know where they keymaps came from anymore. Another reason is that some keymaps might not even be stored in any variable (symbol's value cell) at all. Anyway, here's some code that seems to work in some cases (but not when the command was remapped, and not for finding where a mouse event is bound). First is a helper function, then the actual function. Not the cleanest code, but good enough for my .emacs. (defun yf/find-object-in-variables (object &optional pred) "Find all symbols (variables) whose content is the same as OBJECT. PRED defaults to `eq'" (unless pred (setq pred #'eq)) (let ((result)) (mapatoms (lambda (x) (when (and (boundp x) (funcall pred (symbol-value x) object)) (push x result)))) result)) (defun yf/key-binding-locus (key) "Return a list of symbols whose value is the active keymap which holds a binding for the given KEY." (interactive "KKey seq: ") (let ((active-maps (current-active-maps t)) map found) ;; we loop over active-maps like key-binding does. (while (not (setq found (lookup-key (setq map (pop active-maps)) key t))) ;; do nothing ) (if (not found) (message "Key not found (which is weird, if you want my opinion).") (if (and (symbolp found) (command-remapping found)) ;; fixme. We should mimic command-remapping ? (message "Found key but it got remapped and I don't know how to search that.") (let ((res (yf/find-object-in-variables map))) (if res (message "Found key (bound to %s) in a keymap bound to: %S" found res) (message "Found key (bound to %s) in a keymap which isn't in any variable." found))))))) -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 02 09:55:36 2014 Received: (at 13948) by debbugs.gnu.org; 2 Jun 2014 13:55:36 +0000 Received: from localhost ([127.0.0.1]:40653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrSi7-0001Q6-U1 for submit@debbugs.gnu.org; Mon, 02 Jun 2014 09:55:36 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:28911) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrSi4-0001PC-R8 for 13948@debbugs.gnu.org; Mon, 02 Jun 2014 09:55:33 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IPAS-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="65346786" Received: from 206-248-131-163.dsl.teksavvy.com (HELO pastel.home) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 02 Jun 2014 09:55:26 -0400 Received: by pastel.home (Postfix, from userid 20848) id 95D18600E1; Mon, 2 Jun 2014 09:55:26 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-ID: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> Date: Mon, 02 Jun 2014 09:55:26 -0400 In-Reply-To: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> (Nicolas Richard's message of "Mon, 02 Jun 2014 12:15:34 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) >> So implementing key-binding-locus would only be a small tweak of >> the key lookup code: the first time you find the key, just return >> the map you found it in, rather than the command it's supposed to >> call. > IIUC, it's slightly more complicated than just modifying the return > value of a function. Indeed, the code was not written with this in mind. E.g. looking up "C-c C-s" first looks up "C-c" which returns a new keymap which combines the C-c part of all the active keymaps, and then we lookup C-s in that "composed" map. Tracking the origin would require changing the data representation (which is visible to ELisp), so it could be tricky to do without breaking compatibility (tho we do such risky changes on a regular basis ;-) > Another reason is that some keymaps might not even be stored in any > variable (symbol's value cell) at all. Yes, keeping track of the original keymap in which the binding is found is one thing, but keeping track of where that keymap is coming from is yet another. I'd welcome a change in C-h k to try and show where the binding comes from, and it'd be OK to implement it with the kind of code you showed (i.e. something not 100% reliable). Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 04 06:52:06 2014 Received: (at 13948) by debbugs.gnu.org; 4 Jun 2014 10:52:06 +0000 Received: from localhost ([127.0.0.1]:43115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ws8nd-0005nj-0c for submit@debbugs.gnu.org; Wed, 04 Jun 2014 06:52:05 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:42726) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ws8nY-0005n7-Mj for 13948@debbugs.gnu.org; Wed, 04 Jun 2014 06:52:01 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhcKAOf5jlOkD4Xn/2dsb2JhbABZrnIBBAaYJwGBIXSCJgEFeRAIAyElDwEESROILQEUrj2dHgGGXxeFVYIDhnoHhEABA5oPhliMXoM6Ow Received: from pno-math-231.ulb.ac.be (HELO LDLC-portable) ([164.15.133.231]) by smtp.ulb.ac.be with ESMTP; 04 Jun 2014 12:51:57 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus In-Reply-To: (Stefan Monnier's message of "Mon, 02 Jun 2014 09:55:26 -0400") References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) Date: Wed, 04 Jun 2014 12:51:56 +0200 Message-ID: <87k38xhrqr.fsf@yahoo.fr> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Stefan Monnier writes: > I'd welcome a change in C-h k to try and show where the binding comes > from, and it'd be OK to implement it with the kind of code you showed > (i.e. something not 100% reliable). Here's an update which covers more cases. I also provide a rough patch for help-fns--key-bindings to show the keymap in C-h k. (defun yf/find-object-in-variables (object &optional pred) "Find all symbols (variables) whose content is the same as OBJECT. PRED defaults to `eq'" (unless pred (setq pred #'eq)) (let ((result)) (mapatoms (lambda (x) (when (and (boundp x) (funcall pred (symbol-value x) object)) (push x result)))) result)) (defun yf/key-binding-keymap (key &optional accept-default no-remap _position) "Determine in which keymap KEY is defined. When the key was found, return an active keymap in which it was found." (let ((active-maps (current-active-maps t)) map found) ;; we loop over active maps like key-binding does. (while (not found) (setq found (lookup-key (setq map (pop active-maps)) key accept-default)) (when (integerp found) ;; prefix was found but not the whole sequence (setq found nil))) (when found (if (and (symbolp found) (not no-remap) (command-remapping found)) (yf/key-binding-keymap (vector 'remap found)) map)))) (defun yf/key-binding-locus (key) "Determine in which keymap KEY is defined. Return value is : - nil if KEY was not found or we couldn't determine which symbols holds the keymap that defines it. - t if KEY was found in the current global map - a list of symbols whose value cell holds a keymap in which the binding was found when searching the active keymaps. " (let ((map (yf/key-binding-keymap key t))) (if (eq map (current-global-map)) t (yf/find-object-in-variables map)))) --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -314,7 +314,16 @@ suitable file is found, return nil." ;; If lots of ordinary text characters run this command, ;; don't mention them one by one. (if (< (length non-modified-keys) 10) - (princ (mapconcat 'key-description keys ", ")) + (princ (mapconcat + (lambda (k) + "Describe key and its originating keymap" + (let ((keymaps (yf/key-binding-locus k))) + (concat + (key-description k) + (when (and keymaps + (listp keymaps)) + (format " %S" keymaps))))) + keys ", ")) (dolist (key non-modified-keys) (setq keys (delq key keys))) (if keys -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 04 09:50:31 2014 Received: (at 13948) by debbugs.gnu.org; 4 Jun 2014 13:50:31 +0000 Received: from localhost ([127.0.0.1]:43298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsBaE-0003qg-89 for submit@debbugs.gnu.org; Wed, 04 Jun 2014 09:50:31 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:49725) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsBa7-0003qJ-It for 13948@debbugs.gnu.org; Wed, 04 Jun 2014 09:50:24 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s54DoHxS012678; Wed, 4 Jun 2014 09:50:17 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 2EFFFAE23E; Wed, 4 Jun 2014 09:50:17 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-ID: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> Date: Wed, 04 Jun 2014 09:50:17 -0400 In-Reply-To: <87k38xhrqr.fsf@yahoo.fr> (Nicolas Richard's message of "Wed, 04 Jun 2014 12:51:56 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4963=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4963> : inlines <965> : streams <1203153> : uri <1775024> X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) > I also provide a rough patch for help-fns--key-bindings to show the > keymap in C-h k. Thanks. But I think this is too wordy. We only want to show the locus for C-h k and not for C-h f (and only show it for the particular key sequence used). > (let ((map (yf/key-binding-keymap key t))) > (if (eq map (current-global-map)) > t > (yf/find-object-in-variables map)))) Why do we need to treat the global map specially? > + "Describe key and its originating keymap" Please punctuate your docstrings. Could you turn it into a self-contained patch (e.g. move the yf/* functions to help*.el and rename it accordingly)? Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 04 09:59:12 2014 Received: (at 13948) by debbugs.gnu.org; 4 Jun 2014 13:59:13 +0000 Received: from localhost ([127.0.0.1]:43888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsBii-0004Lp-Ar for submit@debbugs.gnu.org; Wed, 04 Jun 2014 09:59:12 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:12900) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsBif-0004Ld-Gn for 13948@debbugs.gnu.org; Wed, 04 Jun 2014 09:59:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArAKAIQlj1OkD4Xx/2dsb2JhbABZrnMBAQEBAQaYJwGBIHSCJQEBBAF5BQsLISUPAQRJE4gtAQwIrgSdHQGGXxeFVYIDhnoHhEAEoGyMYIM6Ow Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3.ulb.ac.be) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 04 Jun 2014 15:59:07 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> Date: Wed, 04 Jun 2014 16:00:23 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 04 Jun 2014 09:50:17 -0400") Message-ID: <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Stefan Monnier writes: >> (let ((map (yf/key-binding-keymap key t))) >> (if (eq map (current-global-map)) >> t >> (yf/find-object-in-variables map)))) > > Why do we need to treat the global map specially? to be honest, I did it because (eq widget-global-map global-map) => t and I didn't want to see these two results everytime. > Could you turn it into a self-contained patch (e.g. move the yf/* > functions to help*.el and rename it accordingly)? Will do. -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 04 10:20:52 2014 Received: (at 13948) by debbugs.gnu.org; 4 Jun 2014 14:20:52 +0000 Received: from localhost ([127.0.0.1]:43905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsC3a-00055d-Jq for submit@debbugs.gnu.org; Wed, 04 Jun 2014 10:20:51 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:59557) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsC3T-00055G-N8 for 13948@debbugs.gnu.org; Wed, 04 Jun 2014 10:20:44 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s54EKbbn019442; Wed, 4 Jun 2014 10:20:38 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 4B12AAE23E; Wed, 4 Jun 2014 10:20:37 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-ID: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> Date: Wed, 04 Jun 2014 10:20:37 -0400 In-Reply-To: <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> (Nicolas Richard's message of "Wed, 04 Jun 2014 16:00:23 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4963=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4963> : inlines <966> : streams <1203181> : uri <1775047> X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) > to be honest, I did it because (eq widget-global-map global-map) => > t and I didn't want to see these two results everytime. Ah, good point. I think a more general solution would be preferable, where we provide a list of "advertized vars" and if the keymap is found in this list, don't look via mapatoms. This list of advertized vars could be built dynamically mimicking current-active-maps. >> Could you turn it into a self-contained patch (e.g. move the yf/* >> functions to help*.el and rename it accordingly)? > Will do. Thanks, Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 06 13:57:26 2014 Received: (at 13948) by debbugs.gnu.org; 6 Jun 2014 17:57:26 +0000 Received: from localhost ([127.0.0.1]:39830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsyOL-00045l-Gh for submit@debbugs.gnu.org; Fri, 06 Jun 2014 13:57:25 -0400 Received: from mailrelay004.isp.belgacom.be ([195.238.6.170]:54020) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsyOI-00045I-FC for 13948@debbugs.gnu.org; Fri, 06 Jun 2014 13:57:23 -0400 X-Belgacom-Dynamic: yes Received: from 8.159-178-91.adsl-dyn.isp.belgacom.be (HELO LDLC-portable) ([91.178.159.8]) by relay.skynet.be with ESMTP; 06 Jun 2014 19:57:15 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus In-Reply-To: (Stefan Monnier's message of "Wed, 04 Jun 2014 10:20:37 -0400") References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) Date: Fri, 06 Jun 2014 19:57:15 +0200 Message-ID: <871tv1gbus.fsf@yahoo.fr> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Stefan Monnier writes: >> to be honest, I did it because (eq widget-global-map global-map) => >> t and I didn't want to see these two results everytime. > > Ah, good point. I think a more general solution would be preferable, > where we provide a list of "advertized vars" and if the keymap is found > in this list, don't look via mapatoms. > > This list of advertized vars could be built dynamically mimicking > current-active-maps. I don't know how to do that. My problem is that when a minor or major mode is defined, the symbol that holds the keymap is not stored afaics. Thus when current-active-maps is run, the information is no more accessible, and mimicking it doesn't bring me much. I could make a list of (intern (format "%s-map" major-mode)) and (intern (format "%s-map" minor-mode)) for currently active minor-modes and check in those. But that will not solve the global map problem, so it still needs some special casing. >>> Could you turn it into a self-contained patch (e.g. move the yf/* >>> functions to help*.el and rename it accordingly)? My current suggestion is as follows. --- a/lisp/help.el +++ b/lisp/help.el @@ -647,6 +647,48 @@ temporarily enables it to allow getting help on disabled items and buttons." (princ (format "%s%s is undefined" key-desc mouse-msg)) (princ (format "%s%s runs the command %S" key-desc mouse-msg defn))))) +(defun key-binding-keymap (key &optional accept-default no-remap _position) + "Determine in which keymap KEY is defined. +When the key was found, return an active keymap in which it was +found." + (let ((active-maps (current-active-maps t)) + map found) + ;; we loop over active maps like key-binding does. + (while (and + (not found) + (setq map (pop active-maps))) + (setq found (lookup-key + map + key + accept-default)) + (when (integerp found) + ;; prefix was found but not the whole sequence + (setq found nil))) + (when found + (if (and (symbolp found) + (not no-remap) + (command-remapping found)) + (key-binding-keymap (vector 'remap found)) + map)))) + +(defun describe-key--binding-locus (key) + "Describe in which keymap KEY is defined. +Return the description (a string) or nil." + (let ((map (key-binding-keymap key t))) + (if (eq map (current-global-map)) + " (found in global map)" + (let ((symbols)) + (mapatoms + (lambda (x) + (when (and (boundp x) + ;; Avoid let-bound symbols + (special-variable-p x) + (eq (symbol-value x) map)) + (push x symbols)))) + (when symbols + (format " (found in %s)" + (mapconcat #'symbol-name symbols ", "))))))) + (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. KEY can be any kind of a key sequence; it can include keyboard events, @@ -753,9 +795,8 @@ temporarily enables it to allow getting help on disabled items and buttons." (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event)))))) (with-help-window (help-buffer) (princ (help-key-description key untranslated)) - (princ (format "\ -%s runs the command %S, which is " - mouse-msg defn)) + (princ (format "%s runs the command %S%s, which is " + mouse-msg defn (describe-key--binding-locus key))) (describe-function-1 defn) (when up-event (unless (or (null defn-up) -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 06 14:28:03 2014 Received: (at 13948) by debbugs.gnu.org; 6 Jun 2014 18:28:03 +0000 Received: from localhost ([127.0.0.1]:39843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wsyrz-00055a-6n for submit@debbugs.gnu.org; Fri, 06 Jun 2014 14:28:03 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:2835) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wsyrw-000554-AG for 13948@debbugs.gnu.org; Fri, 06 Jun 2014 14:28:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IPAS-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="66056337" Received: from 206-248-131-163.dsl.teksavvy.com (HELO pastel.home) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 06 Jun 2014 14:27:54 -0400 Received: by pastel.home (Postfix, from userid 20848) id 4F33C600D1; Fri, 6 Jun 2014 14:27:54 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-ID: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> Date: Fri, 06 Jun 2014 14:27:54 -0400 In-Reply-To: <871tv1gbus.fsf@yahoo.fr> (Nicolas Richard's message of "Fri, 06 Jun 2014 19:57:15 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) >> This list of advertized vars could be built dynamically mimicking >> current-active-maps. > I don't know how to do that. You need to do it heuristically. E.g. the list would look like (list 'global-map (intern (format "%s-map" major-mode)) ...) > I could make a list of (intern (format "%s-map" major-mode)) and (intern > (format "%s-map" minor-mode)) for currently active minor-modes and check > in those. That's right. > But that will not solve the global map problem, so it still > needs some special casing. The global map should be in `global-map'. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 10 15:47:04 2014 Received: (at 13948) by debbugs.gnu.org; 10 Jun 2014 19:47:04 +0000 Received: from localhost ([127.0.0.1]:43185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuS0d-0002wO-HL for submit@debbugs.gnu.org; Tue, 10 Jun 2014 15:47:04 -0400 Received: from mailrelay009.isp.belgacom.be ([195.238.6.176]:24560) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuS0a-0002vr-OS for 13948@debbugs.gnu.org; Tue, 10 Jun 2014 15:47:01 -0400 X-Belgacom-Dynamic: yes Received: from 208.166-177-91.adsl-dyn.isp.belgacom.be (HELO LDLC-portable) ([91.177.166.208]) by relay.skynet.be with ESMTP; 10 Jun 2014 21:46:53 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> Date: Tue, 10 Jun 2014 21:46:53 +0200 Message-ID: <87ppigv976.fsf@yahoo.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Stefan Monnier writes: >>> This list of advertized vars could be built dynamically mimicking >>> current-active-maps. Here's another attempt. Like the previous patch, I define key-binding-keymap which finds the keymap by mimicking key-binding, and describe-key--binding-locus which matches the keymap to a symbol and makes a description suitable for describe-key. Sorry it is a bit lengthy but I'm afraid I don't know better. diff --git a/lisp/help.el b/lisp/help.el index 72a9524..9721fcf 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -647,6 +647,74 @@ temporarily enables it to allow getting help on disabled items and buttons." (princ (format "%s%s is undefined" key-desc mouse-msg)) (princ (format "%s%s runs the command %S" key-desc mouse-msg defn))))) +(defun key-binding-keymap (key &optional accept-default no-remap position) + "Return a keymap holding a binding for KEY within current keymaps. +The effect of the arguments KEY, ACCEPT-DEFAULT, NO-REMAP and +POSITION is as documented in the function `key-binding'." + (let* ((active-maps (current-active-maps t position)) + map found) + ;; we loop over active maps like key-binding does. + (while (and + (not found) + (setq map (pop active-maps))) + (setq found (lookup-key + map + key + accept-default)) + (when (integerp found) + ;; prefix was found but not the whole sequence + (setq found nil))) + (when found + (if (and (symbolp found) + (not no-remap) + (command-remapping found)) + (key-binding-keymap (vector 'remap found)) + map)))) + +(defun describe-key--binding-locus (key position) + "Describe in which keymap KEY is defined. +Return the description (a string)." + (or + (let ((map (key-binding-keymap key t nil position))) + (when map + (let ((advertised-syms (nconc + (list 'overriding-terminal-local-map + 'overriding-local-map) + (delq nil + (mapcar + (lambda (mode) + (when + (symbol-value mode) + (intern + (format "%s-map" mode)))) + minor-mode-list)) + (list 'global-map + (intern (format "%s-map" major-mode))))) + found) + ;; look into these advertised symbols first + (while (and (not found) advertised-syms) + (let ((sym (pop advertised-syms))) + (setq found + (when (and + (boundp sym) + (eq map (symbol-value sym))) + sym)))) + ;; only look in other symbols otherwise + (when (not found) + (mapatoms + (lambda (x) + (when (and (boundp x) + ;; avoid let-bound symbols + (special-variable-p x) + (eq (symbol-value x) map)) + (push x found)))) + (when (and (consp found) + (null (cdr found))) + (setq found (car found)))) + (when found + (format " (found in %s)" found))))) + "")) + (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. KEY can be any kind of a key sequence; it can include keyboard events, @@ -709,6 +777,7 @@ temporarily enables it to allow getting help on disabled items and buttons." (mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers) (memq 'drag modifiers)) " at that spot" "")) (defn (key-binding key t)) + key-locus key-locus-up key-locus-up-tricky defn-up defn-up-tricky ev-type mouse-1-remapped mouse-1-tricky) @@ -747,15 +816,17 @@ temporarily enables it to allow getting help on disabled items and buttons." (setcar up-event (elt mouse-1-remapped 0))) (t (setcar up-event 'mouse-2)))) (setq defn-up (key-binding sequence nil nil (event-start up-event))) + (setq key-locus-up (describe-key--binding-locus sequence (event-start up-event))) (when mouse-1-tricky (setq sequence (vector up-event)) (aset sequence 0 'mouse-1) - (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event)))))) + (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event))) + (setq key-locus-up-tricky (describe-key--binding-locus sequence (event-start up-event)))))) + (setq key-locus (describe-key--binding-locus key (event-start event))) (with-help-window (help-buffer) (princ (help-key-description key untranslated)) - (princ (format "\ -%s runs the command %S, which is " - mouse-msg defn)) + (princ (format "%s runs the command %S%s, which is " + mouse-msg defn key-locus)) (describe-function-1 defn) (when up-event (unless (or (null defn-up) @@ -765,13 +836,13 @@ temporarily enables it to allow getting help on disabled items and buttons." ----------------- up-event %s---------------- -%s%s%s runs the command %S, which is " +%s%s%s runs the command %S%s, which is " (if mouse-1-tricky "(short click) " "") (key-description (vector up-event)) mouse-msg (if mouse-1-remapped " is remapped to , which" "") - defn-up)) + defn-up key-locus-up)) (describe-function-1 defn-up)) (unless (or (null defn-up-tricky) (integerp defn-up-tricky) @@ -781,10 +852,10 @@ temporarily enables it to allow getting help on disabled items and buttons." ----------------- up-event (long click) ---------------- Pressing <%S>%s for longer than %d milli-seconds -runs the command %S, which is " +runs the command %S%s, which is " ev-type mouse-msg mouse-1-click-follows-link - defn-up-tricky)) + defn-up-tricky key-locus-up-tricky)) (describe-function-1 defn-up-tricky))))))) (defun describe-mode (&optional buffer) -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 10 18:24:59 2014 Received: (at 13948) by debbugs.gnu.org; 10 Jun 2014 22:24:59 +0000 Received: from localhost ([127.0.0.1]:43279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuUTS-0006wh-Tj for submit@debbugs.gnu.org; Tue, 10 Jun 2014 18:24:59 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:38777) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuUTQ-0006wT-9m for 13948@debbugs.gnu.org; Tue, 10 Jun 2014 18:24:57 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IPAS-Result: ArUGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="66507021" Received: from 75-119-224-253.dsl.teksavvy.com (HELO pastel.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 10 Jun 2014 18:24:50 -0400 Received: by pastel.home (Postfix, from userid 20848) id 239B360310; Tue, 10 Jun 2014 18:24:50 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-ID: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> Date: Tue, 10 Jun 2014 18:24:50 -0400 In-Reply-To: <87ppigv976.fsf@yahoo.fr> (Nicolas Richard's message of "Tue, 10 Jun 2014 21:46:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Here's another attempt. Like the previous patch, I define > key-binding-keymap which finds the keymap by mimicking key-binding, and > describe-key--binding-locus which matches the keymap to a symbol and > makes a description suitable for describe-key. Looks pretty good. Feel free to install it into `trunk'. See some nitpicks below. > +(defun key-binding-keymap (key &optional accept-default no-remap position) Please name it (and all the functions/vars you add in help*.el) with a leading "help-". I'd name it help--key-binding-keymap. > + "Return a keymap holding a binding for KEY within current keymaps. > +The effect of the arguments KEY, ACCEPT-DEFAULT, NO-REMAP and > +POSITION is as documented in the function `key-binding'." > + (let* ((active-maps (current-active-maps t position)) > + map found) > + ;; we loop over active maps like key-binding does. Please capitalize your comments. > + (setq found (lookup-key > + map > + key > + accept-default)) I think this all fits on a single line. > + (when (integerp found) > + ;; prefix was found but not the whole sequence > + (setq found nil))) If key-binding returned a command, then we should never hit this case. It's OK to keep the code, but you might like to add a comment mentioning that we don't expect this case to happen. > + (when found > + (if (and (symbolp found) > + (not no-remap) > + (command-remapping found)) > + (key-binding-keymap (vector 'remap found)) Please add a comment here mentioning that to be really thorough, in the remap case the use would like to know in which map the final command was found but also in which map the remapping was found. > + (mapcar > + (lambda (mode) > + (when > + (symbol-value mode) > + (intern > + (format "%s-map" mode)))) > + minor-mode-list)) Use minor-mode-map-alist instead (which requires a tweak to the body of the mapcar, of course). Also I'd use intern-soft here (tho it probably doesn't make any difference in practice, here). > + ;; look into these advertised symbols first > + (while (and (not found) advertised-syms) > + (let ((sym (pop advertised-syms))) > + (setq found > + (when (and > + (boundp sym) > + (eq map (symbol-value sym))) > + sym)))) > + ;; only look in other symbols otherwise > + (when (not found) > + (mapatoms > + (lambda (x) > + (when (and (boundp x) > + ;; avoid let-bound symbols > + (special-variable-p x) > + (eq (symbol-value x) map)) > + (push x found)))) > + (when (and (consp found) > + (null (cdr found))) > + (setq found (car found)))) I think this code will be simpler if you use catch/throw (you can then use dolist over advertised-syms, for example and you don't need `found'). > + (when found > + (format " (found in %s)" found))))) > + "")) I think it's better to make this function return the symbol rather than a string, and let the caller turn it into a string. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 11 07:22:03 2014 Received: (at 13948) by debbugs.gnu.org; 11 Jun 2014 11:22:03 +0000 Received: from localhost ([127.0.0.1]:43658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WugbR-0001Or-Jt for submit@debbugs.gnu.org; Wed, 11 Jun 2014 07:22:02 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:25577) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WugbO-0001Og-T4 for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 07:22:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYFALs6mFOkD4Xx/2dsb2JhbABZrxUBAQEBAQEGmRkBgR11hAMBAQQBeQULCxEDAQIKJQ8BBDsOE4gtAQMJCLE2ll0BhgAXhViBfIRWghERB4RBBIRjBZNSiFKGcIV7gz47gTAk Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3.ulb.ac.be) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 11 Jun 2014 13:21:56 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> Date: Wed, 11 Jun 2014 13:23:17 +0200 In-Reply-To: (Stefan Monnier's message of "Tue, 10 Jun 2014 18:24:50 -0400") Message-ID: <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Here's another attempt. Like the previous patch, I define >> key-binding-keymap which finds the keymap by mimicking key-binding, and >> describe-key--binding-locus which matches the keymap to a symbol and >> makes a description suitable for describe-key. > > Looks pretty good. Feel free to install it into `trunk'. I can send a patch, including a ChangeLog entry, but I don't have permission to commit. >> + (when (integerp found) >> + ;; prefix was found but not the whole sequence >> + (setq found nil))) > > If key-binding returned a command, then we should never hit this case. > It's OK to keep the code, but you might like to add a comment mentioning > that we don't expect this case to happen. We do hit the case, because we look in active keymaps one by one, instead of using the keymap (cons 'keymap active-keymaps) like key-binding does. >> + ;; look into these advertised symbols first >> + (while (and (not found) advertised-syms) >> + (let ((sym (pop advertised-syms))) >> + (setq found >> + (when (and >> + (boundp sym) >> + (eq map (symbol-value sym))) >> + sym)))) >> + ;; only look in other symbols otherwise >> + (when (not found) >> + (mapatoms >> + (lambda (x) >> + (when (and (boundp x) >> + ;; avoid let-bound symbols >> + (special-variable-p x) >> + (eq (symbol-value x) map)) >> + (push x found)))) >> + (when (and (consp found) >> + (null (cdr found))) >> + (setq found (car found)))) > > I think this code will be simpler if you use catch/throw (you can then > use dolist over advertised-syms, for example and you don't need > `found'). Shall I return only the first symbol that matches, also in the mapatoms case ? I assume yes because of your next suggestion : > I think it's better to make this function return the symbol rather than > a string, and let the caller turn it into a string. Ok. Here's the patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-describe-key-mention-the-keymap-in-which-the-binding.patch >>From 685224012675c7b608ad67825cb7ff4d88ce8392 Mon Sep 17 00:00:00 2001 From: Nicolas Richard Date: Tue, 10 Jun 2014 20:06:27 +0200 Subject: [PATCH] describe-key: mention the keymap in which the binding was found. * help.el (help--key-binding-keymap): New function. (help--binding-locus): New function. (describe-key): Mention the keymap in which the binding was found. --- lisp/ChangeLog | 6 ++++ lisp/help.el | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 84 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2f40577..9912407 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-06-11 Nicolas Richard + + * help.el (help--key-binding-keymap): New function. + (help--binding-locus): New function. + (describe-key): Mention the keymap in which the binding was found. + 2014-05-26 Paul Eggert Include sources used to create macuvs.h. diff --git a/lisp/help.el b/lisp/help.el index 72a9524..0effdfa 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -647,6 +647,67 @@ temporarily enables it to allow getting help on disabled items and buttons." (princ (format "%s%s is undefined" key-desc mouse-msg)) (princ (format "%s%s runs the command %S" key-desc mouse-msg defn))))) +(defun help--key-binding-keymap (key &optional accept-default no-remap position) + "Return a keymap holding a binding for KEY within current keymaps. +The effect of the arguments KEY, ACCEPT-DEFAULT, NO-REMAP and +POSITION is as documented in the function `key-binding'." + (let* ((active-maps (current-active-maps t position)) + map found) + ;; We loop over active maps like key-binding does. + (while (and + (not found) + (setq map (pop active-maps))) + (setq found (lookup-key map key accept-default)) + (when (integerp found) + ;; Prefix was found but not the whole sequence. + (setq found nil))) + (when found + (if (and (symbolp found) + (not no-remap) + (command-remapping found)) + ;; The user might want to know in which map the binding is + ;; found, or in which map the remapping is found. The + ;; default is to show where the remapping is done. + (key-binding-keymap (vector 'remap found)) + map)))) + +(defun help--binding-locus (key position) + "Describe in which keymap KEY is defined. +Return a symbol pointing to that keymap if one exists ; otherwise +return nil." + (let ((map (key-binding-keymap key t nil position))) + (when map + (catch 'found + (let ((advertised-syms (nconc + (list 'overriding-terminal-local-map + 'overriding-local-map) + (delq nil + (mapcar + (lambda (mode-and-map) + (let ((mode (car mode-and-map))) + (when (symbol-value mode) + (intern-soft + (format "%s-map" mode))))) + minor-mode-map-alist)) + (list 'global-map + (intern-soft (format "%s-map" major-mode))))) + found) + ;; Look into these advertised symbols first. + (dolist (sym advertised-syms) + (when (and + (boundp sym) + (eq map (symbol-value sym))) + (throw 'found sym))) + ;; Only look in other symbols otherwise. + (mapatoms + (lambda (x) + (when (and (boundp x) + ;; Avoid let-bound symbols. + (special-variable-p x) + (eq (symbol-value x) map)) + (throw 'found x)))) + nil))))) + (defun describe-key (&optional key untranslated up-event) "Display documentation of the function invoked by KEY. KEY can be any kind of a key sequence; it can include keyboard events, @@ -709,6 +770,7 @@ temporarily enables it to allow getting help on disabled items and buttons." (mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers) (memq 'drag modifiers)) " at that spot" "")) (defn (key-binding key t)) + key-locus key-locus-up key-locus-up-tricky defn-up defn-up-tricky ev-type mouse-1-remapped mouse-1-tricky) @@ -747,15 +809,19 @@ temporarily enables it to allow getting help on disabled items and buttons." (setcar up-event (elt mouse-1-remapped 0))) (t (setcar up-event 'mouse-2)))) (setq defn-up (key-binding sequence nil nil (event-start up-event))) + (setq key-locus-up (help--binding-locus sequence (event-start up-event))) (when mouse-1-tricky (setq sequence (vector up-event)) (aset sequence 0 'mouse-1) - (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event)))))) + (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event))) + (setq key-locus-up-tricky (help--binding-locus sequence (event-start up-event)))))) + (setq key-locus (help--binding-locus key (event-start event))) (with-help-window (help-buffer) (princ (help-key-description key untranslated)) - (princ (format "\ -%s runs the command %S, which is " - mouse-msg defn)) + (princ (format "%s runs the command %S%s, which is " + mouse-msg defn (if key-locus + (format " (found in %s)" key-locus) + ""))) (describe-function-1 defn) (when up-event (unless (or (null defn-up) @@ -765,13 +831,15 @@ temporarily enables it to allow getting help on disabled items and buttons." ----------------- up-event %s---------------- -%s%s%s runs the command %S, which is " +%s%s%s runs the command %S%s, which is " (if mouse-1-tricky "(short click) " "") (key-description (vector up-event)) mouse-msg (if mouse-1-remapped " is remapped to , which" "") - defn-up)) + defn-up (if key-locus-up + (format " (found in %s)" key-locus-up) + ""))) (describe-function-1 defn-up)) (unless (or (null defn-up-tricky) (integerp defn-up-tricky) @@ -781,10 +849,12 @@ temporarily enables it to allow getting help on disabled items and buttons." ----------------- up-event (long click) ---------------- Pressing <%S>%s for longer than %d milli-seconds -runs the command %S, which is " +runs the command %S%s, which is " ev-type mouse-msg mouse-1-click-follows-link - defn-up-tricky)) + defn-up-tricky (if key-locus-up-tricky + (format " (found in %s)" key-locus-up-tricky) + ""))) (describe-function-1 defn-up-tricky))))))) (defun describe-mode (&optional buffer) -- 2.0.0 --=-=-= Content-Type: text/plain -- Nico. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 11 14:06:26 2014 Received: (at 13948) by debbugs.gnu.org; 11 Jun 2014 18:06:27 +0000 Received: from localhost ([127.0.0.1]:44516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wumuo-0006Xr-I9 for submit@debbugs.gnu.org; Wed, 11 Jun 2014 14:06:26 -0400 Received: from relais.videotron.ca ([24.201.245.36]:57667) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wumum-0006Xj-Qh for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 14:06:25 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from ceviche.home ([24.203.184.39]) by VL-VM-MR003.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0N700001SNMNP1Z1@VL-VM-MR003.ip.videotron.ca> for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 14:06:23 -0400 (EDT) Received: by ceviche.home (Postfix, from userid 20848) id 1FDF666159; Wed, 11 Jun 2014 14:06:24 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-id: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> Date: Wed, 11 Jun 2014 14:06:24 -0400 In-reply-to: <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) >> Looks pretty good. Feel free to install it into `trunk'. > I can send a patch, including a ChangeLog entry, but I don't have > permission to commit. Hmm... any hope we could fix this problem? E.g. request membership in the "emacs" group from your savannah account? >>> + (when (integerp found) >>> + ;; prefix was found but not the whole sequence >>> + (setq found nil))) >> If key-binding returned a command, then we should never hit this case. >> It's OK to keep the code, but you might like to add a comment mentioning >> that we don't expect this case to happen. > We do hit the case, because we look in active keymaps one by one, > instead of using the keymap (cons 'keymap active-keymaps) like > key-binding does. Hmm... I know the two are very slightly different, so there are odd corner cases, but I'd be curious to know in which circumstance you bumped into it. Might actually point to a bug somewhere. > Shall I return only the first symbol that matches, also in the mapatoms > case ? I assume yes because of your next suggestion : Yes. > Here's the patch. Thanks, Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 11 16:20:48 2014 Received: (at 13948) by debbugs.gnu.org; 11 Jun 2014 20:20:48 +0000 Received: from localhost ([127.0.0.1]:44589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wup0q-0001sx-0n for submit@debbugs.gnu.org; Wed, 11 Jun 2014 16:20:48 -0400 Received: from mailrelay004.isp.belgacom.be ([195.238.6.170]:25497) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wup0n-0001si-8c for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 16:20:46 -0400 X-Belgacom-Dynamic: yes Received: from 208.166-177-91.adsl-dyn.isp.belgacom.be (HELO LDLC-portable) ([91.177.166.208]) by relay.skynet.be with ESMTP; 11 Jun 2014 22:20:38 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> Date: Wed, 11 Jun 2014 22:20:38 +0200 Message-ID: <87k38n5hbd.fsf@yahoo.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 13948 Cc: Nicolas Richard , 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Stefan Monnier writes: >>> Looks pretty good. Feel free to install it into `trunk'. >> I can send a patch, including a ChangeLog entry, but I don't have >> permission to commit. > > Hmm... any hope we could fix this problem? E.g. request membership in > the "emacs" group from your savannah account? I have now done that. > Hmm... I know the two are very slightly different, so there are odd > corner cases, but I'd be curious to know in which circumstance you > bumped into it. Sure. (lookup-key lisp-interaction-mode-map (kbd "C-x C-f") t) => 1 I'm a bit surprised, I thought that in this situation this would return non-nil, but I'm wrong : (lookup-key lisp-interaction-mode-map (kbd "C-x") t) => nil -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 11 18:00:32 2014 Received: (at 13948) by debbugs.gnu.org; 11 Jun 2014 22:00:32 +0000 Received: from localhost ([127.0.0.1]:44639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuqZL-0004iB-MI for submit@debbugs.gnu.org; Wed, 11 Jun 2014 18:00:31 -0400 Received: from relais.videotron.ca ([24.201.245.36]:59020) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WuqZI-0004i2-TR for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 18:00:29 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from ceviche.home ([24.201.151.191]) by VL-VM-MR004.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0N7000FX0YGS7DE3@VL-VM-MR004.ip.videotron.ca> for 13948@debbugs.gnu.org; Wed, 11 Jun 2014 18:00:28 -0400 (EDT) Received: by ceviche.home (Postfix, from userid 20848) id 1564866228; Wed, 11 Jun 2014 18:00:28 -0400 (EDT) From: Stefan Monnier To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus Message-id: References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> <87k38n5hbd.fsf@yahoo.fr> Date: Wed, 11 Jun 2014 18:00:28 -0400 In-reply-to: <87k38n5hbd.fsf@yahoo.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > (lookup-key lisp-interaction-mode-map (kbd "C-x C-f") t) > => 1 Duh! Right! Sorry, I was completely confused, this integer is used when we're past nil, so yes it can happen very often. Thanks. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 12 04:16:38 2014 Received: (at 13948) by debbugs.gnu.org; 12 Jun 2014 08:16:38 +0000 Received: from localhost ([127.0.0.1]:45042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv0BZ-0007zU-53 for submit@debbugs.gnu.org; Thu, 12 Jun 2014 04:16:38 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:8585) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv0BW-0007yo-Hv for 13948@debbugs.gnu.org; Thu, 12 Jun 2014 04:16:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEFAN9gmVOkD4Xn/2dsb2JhbABahCsBAalXAQEBAQEBBpkbgSF1hAQBBXkQCAMhJQ8BBEMGE4gtAQMRsy+WaAGGaheFXIF/hFuCI4RIAQOEYwWTU4Fzhl+GcYV7gz47 Received: from pno-math-231.ulb.ac.be (HELO LDLC-portable) ([164.15.133.231]) by smtp.ulb.ac.be with ESMTP; 12 Jun 2014 10:16:34 +0200 From: Nicolas Richard To: Nicolas Richard Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> <87fvjbd716.fsf@geodiff-mac3.ulb.ac.be> <87k38n5hbd.fsf@yahoo.fr> Date: Thu, 12 Jun 2014 10:16:32 +0200 Message-ID: <871tuu4k67.fsf@yahoo.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948 Cc: 13948@debbugs.gnu.org, Stefan Monnier , Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Nicolas Richard writes: > (lookup-key lisp-interaction-mode-map (kbd "C-x C-f") t) > => 1 > I'm a bit surprised, I thought that in this situation this would return > non-nil, but I'm wrong : > (lookup-key lisp-interaction-mode-map (kbd "C-x") t) > => nil For the record, my surprise is gone : the return value 1 means that "C-x" is not a prefix in the given keymap. I thought it meant "C-x" was bound to something. I'll amend my comment : I think using the word "prefix" was misleading. -- Nico. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 12 12:09:57 2014 Received: (at 13948-done) by debbugs.gnu.org; 12 Jun 2014 16:09:57 +0000 Received: from localhost ([127.0.0.1]:45784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv7ZZ-0007rT-IN for submit@debbugs.gnu.org; Thu, 12 Jun 2014 12:09:57 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:3672) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv7ZU-0007rG-3O for 13948-done@debbugs.gnu.org; Thu, 12 Jun 2014 12:09:52 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQFAHzPmVOkD4Xn/2dsb2JhbABargYBAQEBAQEGmR4BgSB1hAQBBXkQCAMhJQ8BBEkTiC0BFLQQl0IBhlkXhVyBf4cAB4RBAQOaMoZjjG+DPjs Received: from pno-math-231.ulb.ac.be (HELO LDLC-portable) ([164.15.133.231]) by smtp.ulb.ac.be with ESMTP; 12 Jun 2014 18:09:46 +0200 From: Nicolas Richard To: Stefan Monnier Subject: Re: bug#13948: no key-binding-locus References: <87k38zipmh.fsf@geodiff-mac3.ulb.ac.be> <87k38xhrqr.fsf@yahoo.fr> <87zjhsg4g8.fsf@geodiff-mac3.ulb.ac.be> <871tv1gbus.fsf@yahoo.fr> <87ppigv976.fsf@yahoo.fr> Date: Thu, 12 Jun 2014 18:09:43 +0200 In-Reply-To: (Stefan Monnier's message of "Tue, 10 Jun 2014 18:24:50 -0400") Message-ID: <87mwdi2jp4.fsf@yahoo.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 13948-done Cc: Nicolas Richard , 13948-done@debbugs.gnu.org, Brian Malehorn X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Stefan Monnier writes: >> Here's another attempt. Like the previous patch, I define >> key-binding-keymap which finds the keymap by mimicking key-binding, and >> describe-key--binding-locus which matches the keymap to a symbol and >> makes a description suitable for describe-key. > > Looks pretty good. Feel free to install it into `trunk'. It seems I have done that in revision 117324 (thanks to vc.el) -- Nico. From unknown Fri Jun 20 07:18:08 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 11 Jul 2014 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator