[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find bindings for all modes

From: Tim Johnson
Subject: Re: Find bindings for all modes
Date: Tue, 28 Oct 2014 14:00:24 -0800
User-agent: Mutt/

* John Mastro <> [141028 13:54]:
> 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:
   I'd like to use C-j as a prefix key. 
   Note: I have limited mobility in my hands and always have the
   control key to the left of my "A" key.

>     (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 is very handy. Thank You! 

> 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.
  :) The more the merrier...
  thanks again
tim at tee jay forty nine dot com or akwebsoft dot com,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]