From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Find bindings for all modes Date: Tue, 28 Oct 2014 14:53:22 -0700 Message-ID: References: <20141028175824.GD7374@mail.akwebsoft.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1414533246 4139 80.91.229.3 (28 Oct 2014 21:54:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2014 21:54:06 +0000 (UTC) To: Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 28 22:53:59 2014 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 1XjEiF-000581-1c for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2014 22:53:59 +0100 Original-Received: from localhost ([::1]:41552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjEiE-0006bL-Nv for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2014 17:53:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjEi3-0006bF-9u for Help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 17:53:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjEi0-0004kr-Ja for Help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 17:53:47 -0400 Original-Received: from mail-ob0-x22e.google.com ([2607:f8b0:4003:c01::22e]:34722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjEi0-0004km-Cn for Help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 17:53:44 -0400 Original-Received: by mail-ob0-f174.google.com with SMTP id uz6so1366825obc.5 for ; Tue, 28 Oct 2014 14:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Yr7+UL7CpRBgOpvrsPUUH1xUqE12DXUoXxGN5aKwbR8=; b=CEFXwDgVNw+TMY+kWN722CAlZHcM1g8JGMUpX9+hMmd6dGGwisuPw4Dme1JrrRt3fU XNgAiINuMQucNB1gOoJxIvV7I0Jhfihw/jz1UNhcEko1p/e8Rzqo5AH+C+fTa/qeR/7b nQ2tg84gjphfcWRtUA3gNmtlzMGlG1q4iJEyRr6cStKyepZxejm0otfR0RCakuujtEar zNrTp7MizsAZA87QK3QmJBl78gnfMS2RVsmo6F6qp/q86li/pdvaMIYLzgg6QYz723xr xm4DSjzN6RLmVna6UEeFwNwhL54zjuM5zjCRcFKmIDOtWyUnkjUECFDoxAwmGebTQyh3 zScA== X-Received: by 10.202.75.202 with SMTP id y193mr4783334oia.56.1414533222194; Tue, 28 Oct 2014 14:53:42 -0700 (PDT) Original-Received: by 10.76.125.194 with HTTP; Tue, 28 Oct 2014 14:53:22 -0700 (PDT) In-Reply-To: <20141028175824.GD7374@mail.akwebsoft.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22e 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:100638 Archived-At: Tim Johnson wrote: > Is there a way to find out all mode - specific bindings for a given > key sequence? I think it depends on what your intended use is. For instance, you could do something like this: (defun bindings-for (key) (let ((seen nil) (bindings nil)) (dolist (buffer (buffer-list)) (with-current-buffer buffer (unless (memq major-mode seen) (push major-mode seen) (push (cons major-mode (key-binding key)) bindings)))) bindings)) (pp (bindings-for (kbd "C-j"))) This will show you an alist mapping major mode names to the command bound to C-j in some active buffer of that mode. Unfortunately, this is far from perfect. The binding could well be associated with a minor mode rather than a major mode, but it shows the major mode's name anyway. And different `foo-mode' buffers could have different bindings for the same key, but it assumes they're all the same. I don't know a way to get a really definitive look at "what's bound where by whom", but hopefully someone else will chime in. -- john