[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: complete list of keybindings
From: |
Pascal J. Bourguignon |
Subject: |
Re: complete list of keybindings |
Date: |
Wed, 12 Aug 2009 04:12:02 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
Lennart Borgman <lennart.borgman@gmail.com> writes:
> Does this really catch longer key bindings?
No, for prefixes, it just write the prefix handling function, or
print the keymap. (that's why there's no specific processing for the
various mode variants). You may improve it and send me a patch ;-)
> And chars above 127?
Read the source!
It says "to 127" right there!
Scanning the while unicode would be even slower. Well, we could skip
inserting lines form unbound keys, this is where the time is spent
actually.
>> (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__