all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Find all commands bound to key prefix
@ 2008-04-03 19:37 Seung Jun
  2008-04-04  9:55 ` Peter Dyballa
  0 siblings, 1 reply; 17+ messages in thread
From: Seung Jun @ 2008-04-03 19:37 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I'd like to see a list of commands that are bound to key sequences
that starts with some prefix (e.g., C-x C-v).  How do I do that?

Thanks,
Seung




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
       [not found] <mailman.9964.1207277776.18990.help-gnu-emacs@gnu.org>
@ 2008-04-04  3:26 ` rustom
  2008-04-04  4:28   ` Drew Adams
                     ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: rustom @ 2008-04-04  3:26 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 4, 12:37 am, "Seung Jun" <seungw...@gmail.com> wrote:
> Hi,
>
> I'd like to see a list of commands that are bound to key sequences
> that starts with some prefix (e.g., C-x C-v).  How do I do that?
>
> Thanks,
> Seung

C-x C-v is (usually) find alternate file ie its not a prefix.
But if you mean a prefix like C-x you can get the possible completions
by
C-x C-h


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Find all commands bound to key prefix
  2008-04-04  3:26 ` rustom
@ 2008-04-04  4:28   ` Drew Adams
       [not found]   ` <mailman.9967.1207283328.18990.help-gnu-emacs@gnu.org>
  2008-04-04  6:41   ` Jens Teich
  2 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2008-04-04  4:28 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> > I'd like to see a list of commands that are bound to key sequences
> > that starts with some prefix (e.g., C-x C-v).  How do I do that?
> 
> if you mean a prefix like C-x you can get the possible completions
> by C-x C-h

That doesn't work for all (even most) prefixes. It doesn't work for C-s, for
instance (isearch-mode-map).

If you use Icicles, then just use the prefix, followed by S-TAB. In this case,
C-x S-TAB. 

All possible key-sequence completions of prefix C-x are then completion
candidates - they are shown in *Completions* along with their bindings
(commands). 

You can see the complete command definitions of selected candidates during
completion using C-M-RET or C-M-mouse-2, or you can see the definitions of
several or all candidates, in order, by repeating C-next.

http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Key_Completion





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
       [not found]   ` <mailman.9967.1207283328.18990.help-gnu-emacs@gnu.org>
@ 2008-04-04  5:45     ` Pascal Bourguignon
  2008-04-04  7:34       ` Sébastien Vauban
  0 siblings, 1 reply; 17+ messages in thread
From: Pascal Bourguignon @ 2008-04-04  5:45 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>> > I'd like to see a list of commands that are bound to key sequences
>> > that starts with some prefix (e.g., C-x C-v).  How do I do that?
>> 
>> if you mean a prefix like C-x you can get the possible completions
>> by C-x C-h
>
> That doesn't work for all (even most) prefixes. It doesn't work for C-s, for
> instance (isearch-mode-map).


Here is a command that gives you a list of all the bindings.  A little
slow, but exhaustive AFAIK.

(defmacro rloop (clauses &rest body)
  (if (null clauses)
      `(progn ,@body)
      `(loop ,@(car clauses) do (rloop ,(cdr clauses) ,@body))))

(defun all-bindings ()
  (interactive)
  (message "all-bindings: wait a few seconds please...")
  (let ((data
         (with-output-to-string
             (let ((bindings '()))
               (rloop ((for C in '("" "C-"))       ; Control
                       (for M in '("" "M-"))       ; Meta
                       (for A in '("" "A-"))       ; Alt
                       (for S in '("" "S-"))       ; Shift
                       (for H in '("" "H-"))       ; Hyper
                       (for s in '("" "s-"))       ; super
                       (for x from 32 to 127))
                      (let* ((k (format "%s%s%s%s%s%s%c" C M A S H s x))
                             (key (ignore-errors (read-kbd-macro k))))
                        (when key
                          (push
                           (list k
                                 (format "%-12s  %-12s  %S\n" k key
                                         (or
                                          ;; (string-key-binding key)
                                          ;; What is this string-key-binding?
                                          (key-binding key))))
                           bindings))))
               (dolist (item
                         (sort bindings
                               (lambda (a b)
                                 (or (< (length (first a))
                                        (length (first b)))
                                     (and (= (length (first a))
                                             (length (first b)))
                                          (string< (first a)
                                                   (first b)))))))
                 (princ (second item)))))))  
    (switch-to-buffer (format "Keybindings in %s" (buffer-name)))
    (erase-buffer)
    (insert data)
    (goto-char (point-min))
    (values)))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Wanna go outside.
Oh, no! Help! I got outside!
Let me back inside!


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04  3:26 ` rustom
  2008-04-04  4:28   ` Drew Adams
       [not found]   ` <mailman.9967.1207283328.18990.help-gnu-emacs@gnu.org>
@ 2008-04-04  6:41   ` Jens Teich
  2 siblings, 0 replies; 17+ messages in thread
From: Jens Teich @ 2008-04-04  6:41 UTC (permalink / raw)
  To: help-gnu-emacs

rustom <rustompmody@gmail.com> writes:

> On Apr 4, 12:37 am, "Seung Jun" <seungw...@gmail.com> wrote:
>> Hi,
>>
>> I'd like to see a list of commands that are bound to key sequences
>> that starts with some prefix (e.g., C-x C-v).  How do I do that?
>>
>> Thanks,
>> Seung
>
> C-x C-v is (usually) find alternate file ie its not a prefix.
> But if you mean a prefix like C-x you can get the possible completions
> by
> C-x C-h

Show all bindings starting with C-x:

C-h b
M-x occur RET ^C-x RET

Jens



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04  5:45     ` Pascal Bourguignon
@ 2008-04-04  7:34       ` Sébastien Vauban
  0 siblings, 0 replies; 17+ messages in thread
From: Sébastien Vauban @ 2008-04-04  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

To add on Pascal's answer, if you want to see the bindings
attached to the function keys, here's a solution found on
http://www-xray.ast.cam.ac.uk/~gmorris/dotemacs.html (slightly
modified):

--8<---------------cut here---------------start------------->8---
;; print the key bindings in a tabular form
    (defun my-keytable (arg)
      "Print the key bindings in a tabular form."
      (interactive "sEnter a modifier string:")
      (with-output-to-temp-buffer "*Key table*"
        (let* ((i 0)
               (keys (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n"
                           "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
                           "<return>" "<down>" "<up>" "<right>" "<left>"
                           "<home>" "<end>" "<f1>" "<f2>" "<f3>" "<f4>" "<f5>"
                           "<f6>" "<f7>" "<f8>" "<f9>" "<f10>" "<f11>" "<f12>"
                           "1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
                           "`" "~" "!" "@" "#" "$" "%" "^" "&" "*" "(" ")" "-" "_"
                           "=" "+" "\\" "|" "{" "[" "]" "}" ";" "'" ":" "\""
                           "<" ">" "," "." "/" "?"))
               (n (length keys))
               (modifiers (list "" "S-" "C-" "M-" "M-C-"))
               (k))
          (or (string= arg "") (setq modifiers (list arg)))
          (setq k (length modifiers))
          (princ (format " %-10.10s |" "Key"))
          (let ((j 0))
            (while (< j k)
              (princ (format " %-28.28s |" (nth j modifiers)))
              (setq j (1+ j))))
          (princ "\n")
          (princ (format "_%-10.10s_|" "__________"))
          (let ((j 0))
            (while (< j k)
              (princ (format "_%-28.28s_|"
                             "_______________________________"))
              (setq j (1+ j))))
          (princ "\n")
          (while (< i n)
            (princ (format " %-10.10s |" (nth i keys)))
            (let ((j 0))
              (while (< j k)
                (let* ((binding
                        (key-binding (read-kbd-macro (concat (nth j modifiers)
                                                             (nth i keys)))))
                       (binding-string "_"))
                  (when binding
                    (if (eq binding 'self-insert-command)
                        (setq binding-string (concat "'" (nth i keys) "'"))
                      (setq binding-string (format "%s" binding))))
                  (setq binding-string
                        (substring binding-string 0 (min (length
                                                          binding-string) 28)))
                  (princ (format " %-28.28s |" binding-string))
                  (setq j (1+ j)))))
            (princ "\n")
            (setq i (1+ i)))
          (princ (format "_%-10.10s_|" "__________"))
          (let ((j 0))
            (while (< j k)
              (princ (format "_%-28.28s_|"
                             "_______________________________"))
              (setq j (1+ j))))))
      (delete-window)
      (hscroll-mode)
      (setq truncate-lines t))
--8<---------------cut here---------------end--------------->8---

Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-03 19:37 Find all commands bound to key prefix Seung Jun
@ 2008-04-04  9:55 ` Peter Dyballa
  2008-04-04 13:05   ` Tassilo Horn
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Dyballa @ 2008-04-04  9:55 UTC (permalink / raw)
  To: Seung Jun; +Cc: help-gnu-emacs


Am 03.04.2008 um 21:37 schrieb Seung Jun:
> I'd like to see a list of commands that are bound to key sequences
> that starts with some prefix (e.g., C-x C-v).  How do I do that?

C-h b – it creates a *Help* buffer that will show all "key  
translations."

Now mark the whole buffer and apply a shell-command on that region  
(M-|):

	M-| | egrep '^<your prefix>' | sort -u

The egrep command takes a regular expression ('^' is part of that and  
stands for: "at the beginning of the line", the '<your prefix>' part  
needs to be substituted with your search pattern, i.e., C-x C-v) and  
tries to find matching lines in the marked region. The final sort  
command removes all duplicates (-u) and presents egrep's findings in  
a sorted form.

--
Greetings

   Pete     === -Q
              ==<__/% >>
_____________(_)____@_____________________________






^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04  9:55 ` Peter Dyballa
@ 2008-04-04 13:05   ` Tassilo Horn
  2008-04-04 15:19     ` Peter Dyballa
       [not found]     ` <mailman.9987.1207322388.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 17+ messages in thread
From: Tassilo Horn @ 2008-04-04 13:05 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

Hi Peter,

>> I'd like to see a list of commands that are bound to key sequences
>> that starts with some prefix (e.g., C-x C-v).  How do I do that?
>
> C-h b – it creates a *Help* buffer that will show all "key
> translations."
>
> Now mark the whole buffer and apply a shell-command on that region
> (M-|):
>
> 	M-| | egrep '^<your prefix>' | sort -u

There's a much easier way.  Press the prefix key followed by C-h.  Let's
say you want to see all keys that start with the prefix C-x RET, you'd
type C-x RET C-h and get a *Help* buffer with all that keys.

Bye,
Tassilo
-- 
Richard Stallman spends  his leasure time playing Duke  Nukem Forever on
GNU Hurd.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04 13:05   ` Tassilo Horn
@ 2008-04-04 15:19     ` Peter Dyballa
  2008-04-04 17:26       ` Tassilo Horn
       [not found]     ` <mailman.9987.1207322388.18990.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Dyballa @ 2008-04-04 15:19 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs


Am 04.04.2008 um 15:05 schrieb Tassilo Horn:
> There's a much easier way.  Press the prefix key followed by C-h.   
> Let's
> say you want to see all keys that start with the prefix C-x RET, you'd
> type C-x RET C-h and get a *Help* buffer with all that keys.


The original question was aiming towards C-x C-v prefix – which seems  
to fail with this method ...

--
Mit friedvollen Grüßen

   Pete

Gut durch ist besser als unten durch!






^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
       [not found]     ` <mailman.9987.1207322388.18990.help-gnu-emacs@gnu.org>
@ 2008-04-04 16:52       ` rustom
  2008-04-04 18:22         ` Drew Adams
       [not found]         ` <mailman.9996.1207333434.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 17+ messages in thread
From: rustom @ 2008-04-04 16:52 UTC (permalink / raw)
  To: help-gnu-emacs

I am bewildered by these answers. (Or we are talking of different
editors/concepts??)

On Apr 4, 8:19 pm, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
>
> The original question was aiming towards C-x C-v prefix - which seems
> to fail with this method ...
>
> --
> Mit friedvollen Grüßen
>
>    Pete

Likewise
Drew Adams wrote:
> That doesn't work for all (even most) prefixes. It doesn't work for C-s, for
> instance (isearch-mode-map).

What is C-x C-v a prefix for -- all possible files in the system?
What is C-s a prefix for -- all possible substrings of the current
buffer?

True, Seung Jun (the OP) did ask about "list of commands that are
bound to key sequences that starts with some prefix (e.g., C-x C-v)"
Could you clarify what you were asking for?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04 15:19     ` Peter Dyballa
@ 2008-04-04 17:26       ` Tassilo Horn
  2008-04-04 18:27         ` Peter Dyballa
       [not found]         ` <mailman.9997.1207333651.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 17+ messages in thread
From: Tassilo Horn @ 2008-04-04 17:26 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

>> There's a much easier way.  Press the prefix key followed by C-h.
>> Let's say you want to see all keys that start with the prefix C-x
>> RET, you'd type C-x RET C-h and get a *Help* buffer with all that
>> keys.
>
> The original question was aiming towards C-x C-v prefix – which seems
> to fail with this method ...

For me (Emacs 23) C-x C-v is no prefix, but `find-alternate-file'.  What
is it for you?

Bye,
Tassilo
-- 
Richard  Stallman  needs  neither  mouse  nor keyboard  to  operate  his
computer. He just stares it down until it does what he wants.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Find all commands bound to key prefix
  2008-04-04 16:52       ` rustom
@ 2008-04-04 18:22         ` Drew Adams
       [not found]         ` <mailman.9996.1207333434.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 17+ messages in thread
From: Drew Adams @ 2008-04-04 18:22 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> Likewise Drew Adams wrote:
>
> > That doesn't work for all (even most) prefixes. It doesn't 
> > work for C-s, for instance (isearch-mode-map).
> 
> What is C-x C-v a prefix for -- all possible files in the system?

I didn't say anything about C-x C-v. I said that a prefix key followed by C-h
doesn't always show the prefix key bindings.

FWIW, I suspect that the OP might have meant `C-x v', which is a prefix key and
for which C-h does work: `C-h v C-h'. But there are other prefix keys for which
it does not work.

> What is C-s a prefix for -- all possible substrings of the current
> buffer?

,----
| isearch-mode-map
| ----------------
| 
| Keymap for `isearch-mode'.
| 
| key             binding
| ---             -------
| 
| C-@ .. C-f	isearch-other-control-char
| C-g		isearch-abort
| C-h		isearch-other-control-char
| TAB .. C-j	isearch-printing-char
| C-k .. C-l	isearch-other-control-char
| RET		isearch-exit
...
`----

Some users, such as myself, explicitly bind C-h in isearch-mode-map so that C-s
C-h does show the C-s bindings. RMS does not want that behavior for Emacs,
however.  





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
  2008-04-04 17:26       ` Tassilo Horn
@ 2008-04-04 18:27         ` Peter Dyballa
       [not found]         ` <mailman.9997.1207333651.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 17+ messages in thread
From: Peter Dyballa @ 2008-04-04 18:27 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs


Am 04.04.2008 um 19:26 schrieb Tassilo Horn:
> For me (Emacs 23) C-x C-v is no prefix, but `find-alternate-file'.   
> What
> is it for you?


The same. Therefore I chose my recommendation for the job.

I also assumed that Seung was trying to find a series of free key  
bindings to use them for his purposes. For this my method is not  
perfect: it works only on the key bindings known at this moment. Some  
extra-mode loaded later could introduce more key bindings ... or  
prefixes!

--
Mit friedvollen Grüßen

   Pete

There are three types of people in this world: those who can count,  
and those who cannot.






^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
       [not found]         ` <mailman.9997.1207333651.18990.help-gnu-emacs@gnu.org>
@ 2008-04-07  2:20           ` Alan
  2008-04-07  4:42             ` Drew Adams
  0 siblings, 1 reply; 17+ messages in thread
From: Alan @ 2008-04-07  2:20 UTC (permalink / raw)
  To: help-gnu-emacs

I have accidentally stumbled upon one of the nicest features in
emacs---that apparently escaped the list!  C-x [F1] .

Is this unique to my setup?  This is how I discovered it:

Long agon, I started using C-x6, C-x7, etc., as keymap prefixes to
numerous little utilities.  I would forget the keybindings, so in
my .emacs.el file, I defined a pop-up that would show me any
keybindings to the particular prefix.  I had to manually insert them.

Then, one day, after some years, I accidentally hit someother prefix,
followed by F1, and --- lo and behold --- what did I see, but a
listing of all bindings to that prefix.

I just tried it: it works with C-x !

Alan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Find all commands bound to key prefix
  2008-04-07  2:20           ` Alan
@ 2008-04-07  4:42             ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2008-04-07  4:42 UTC (permalink / raw)
  To: 'Alan', help-gnu-emacs

> I have accidentally stumbled upon one of the nicest features in
> emacs---that apparently escaped the list!  C-x [F1] .

That is what was discussed here as `C-x C-h'. `f1' has the same binding as
`C-h'. 

And, as was pointed out, it does not work for all prefix keys (but it does work
for `C-x').





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Find all commands bound to key prefix
       [not found]         ` <mailman.9996.1207333434.18990.help-gnu-emacs@gnu.org>
@ 2008-05-04  1:16           ` David Combs
  2008-05-04  1:53             ` Drew Adams
  0 siblings, 1 reply; 17+ messages in thread
From: David Combs @ 2008-05-04  1:16 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.9996.1207333434.18990.help-gnu-emacs@gnu.org>,
Drew Adams <drew.adams@oracle.com> wrote:
>
>Some users, such as myself, explicitly bind C-h in isearch-mode-map so that C-s
>C-h does show the C-s bindings. RMS does not want that behavior for Emacs,
>however.  


And how do you do that?

And what command do you bind it to?

Thanks,

David




^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Find all commands bound to key prefix
  2008-05-04  1:16           ` David Combs
@ 2008-05-04  1:53             ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2008-05-04  1:53 UTC (permalink / raw)
  To: 'David Combs', help-gnu-emacs

> > Some users, such as myself, explicitly bind C-h in 
> > isearch-mode-map so that C-s C-h does show the C-s
> > bindings.  
> 
> And how do you do that? And what command do you bind it to?

http://www.emacswiki.org/cgi-bin/wiki/IsearchPlus - description

http://www.emacswiki.org/cgi-bin/wiki/isearch%2b.el - code

This is the relevant part:

(add-hook 'isearch-mode-hook
          (lambda ()
            (define-key isearch-mode-map "\C-h" 'isearch-mode-help)))

(defun isearch-mode-help ()
  "Display information on interactive search in buffer *Help*."
  (interactive)
  (describe-function 'isearch-forward)
  (isearch-done)
  (isearch-clean-overlays)
  (save-excursion
    (set-buffer "*Help*")
    (goto-char (point-max))
    (let ((buffer-read-only nil))
      (insert (substitute-command-keys "

Bindings in Isearch minor mode:
------------------------------

\\{isearch-mode-map}")))))





^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-05-04  1:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-03 19:37 Find all commands bound to key prefix Seung Jun
2008-04-04  9:55 ` Peter Dyballa
2008-04-04 13:05   ` Tassilo Horn
2008-04-04 15:19     ` Peter Dyballa
2008-04-04 17:26       ` Tassilo Horn
2008-04-04 18:27         ` Peter Dyballa
     [not found]         ` <mailman.9997.1207333651.18990.help-gnu-emacs@gnu.org>
2008-04-07  2:20           ` Alan
2008-04-07  4:42             ` Drew Adams
     [not found]     ` <mailman.9987.1207322388.18990.help-gnu-emacs@gnu.org>
2008-04-04 16:52       ` rustom
2008-04-04 18:22         ` Drew Adams
     [not found]         ` <mailman.9996.1207333434.18990.help-gnu-emacs@gnu.org>
2008-05-04  1:16           ` David Combs
2008-05-04  1:53             ` Drew Adams
     [not found] <mailman.9964.1207277776.18990.help-gnu-emacs@gnu.org>
2008-04-04  3:26 ` rustom
2008-04-04  4:28   ` Drew Adams
     [not found]   ` <mailman.9967.1207283328.18990.help-gnu-emacs@gnu.org>
2008-04-04  5:45     ` Pascal Bourguignon
2008-04-04  7:34       ` Sébastien Vauban
2008-04-04  6:41   ` Jens Teich

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.