unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: Emacs <Help-gnu-emacs@gnu.org>
Subject: Re: Find bindings for all modes
Date: Tue, 28 Oct 2014 14:53:22 -0700	[thread overview]
Message-ID: <CAOj2CQSRgNK1vVOkZ_5yNYsodtT_563X79rigoN-rQyfgcQJoA@mail.gmail.com> (raw)
In-Reply-To: <20141028175824.GD7374@mail.akwebsoft.com>

Tim Johnson <tim@akwebsoft.com> 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



  reply	other threads:[~2014-10-28 21:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 17:58 Find bindings for all modes Tim Johnson
2014-10-28 21:53 ` John Mastro [this message]
2014-10-28 22:00   ` Tim Johnson
2014-10-28 22:18     ` John Mastro
2014-10-29  0:31       ` Tim Johnson
2014-10-29  3:09       ` Robert Thorpe
2014-10-29 18:19         ` Tim Johnson
2014-10-29 23:05         ` John Mastro
2014-10-30  1:46           ` Tim Johnson
2014-10-30  2:04           ` Robert Thorpe
2014-10-30 18:25             ` Tim Johnson
2014-11-01 21:00               ` Robert Thorpe
2014-11-04  0:04                 ` Tim Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOj2CQSRgNK1vVOkZ_5yNYsodtT_563X79rigoN-rQyfgcQJoA@mail.gmail.com \
    --to=john.b.mastro@gmail.com \
    --cc=Help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).