From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Find all commands bound to key prefix Date: Fri, 04 Apr 2008 07:45:45 +0200 Organization: Informatimago Message-ID: <87abkakwae.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1207291270 2275 80.91.229.12 (4 Apr 2008 06:41:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Apr 2008 06:41:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 04 08:41:39 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JhfcI-0002TI-DZ for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Apr 2008 08:41:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jhfbf-0006Ry-QF for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Apr 2008 02:40:59 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!feeder1-2.proxad.net!cleanfeed4-b.proxad.net!nnrp8-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:NzhmMjA4YzVhYjdlMTA4NTExY2JhYTI3NzM3MjM3OGZhZDdiNjEzZg== Original-Lines: 65 Original-NNTP-Posting-Date: 04 Apr 2008 07:45:46 MEST Original-NNTP-Posting-Host: 88.180.86.168 Original-X-Trace: 1207287946 news-3.free.fr 1283 88.180.86.168:60595 Original-X-Complaints-To: abuse@proxad.net Original-Xref: shelby.stanford.edu gnu.emacs.help:157665 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53036 Archived-At: "Drew Adams" 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!