I thought I will share this with people on jde list. It helps
you quickly identify what key combinations are available.

(defun keytable (arg)
  "A simple repacement for `describe-bindings' function to print the key
bindings in a tabular form.
The `describe-bindings' function shows a single column of keys to their
bindings. The `keytable'
shows the same information in a tabular form. You can choose to display the
bindings using
only certain modifiers.

Bind \\[describe-bindings] to `keytable', which usually binds to
`describe-bindings', like so
\(global-set-key \(read-kbd-macro \"\\[describe-bindings]\"\) 'keytable\)
"
  (interactive "sEnter a modifier [a space separated C- S- M- A- or even
comibination like C-S- M-C-S-]:")
  (with-output-to-temp-buffer "*Key table*"
    (princ (format "Major Mode: %s\nMinor Modes: %s\n" major-mode
minor-mode-alist))
    (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"
    "1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
    "<down>" "<up>" "<right>" "<left>"
    "<kp-down>" "<kp-up>" "<kp-right>" "<kp-left>"
     "<return>" "<home>" "<end>"
     "<f1>" "<f2>" "<f3>" "<f4>" "<f5>" "<f6>" "<f7>" "<f8>" "<f9>" "<f10>"
"<f11>" "<f12>"
     "`" "~" "!" "@" "#" "$" "%" "^" "&" "*" "(" ")" "-" "_" "=" "+" "\\"
"|" "{" "[" "]" "}" ";" "'" ":" "\"" "<" ">" "," "." "/" "?"
         ))
    (n (length keys))
    (modifiers (list "" "C-" "M-" "S-" "M-C-" "S-C-"))
    )
      (if (not (string= arg ""))
   (setq modifiers (split-string arg))
 )
      (setq k (length modifiers))
      (princ (format "_%-10.10s__" "__________"))
      (let ((j 0))
 (while (< j k)
   (princ (format "_%-50.50s__"
"__________________________________________________"))
   (setq j (+ j 1))
   )
 )
      (princ "\n")
      (princ (format " %-10.10s |" "Key"))
      (let ((j 0))
 (while (< j k)
   (princ (format " %-50.50s |" (nth j modifiers)))
   (setq j (+ j 1))
   )
 )
      (princ "\n")
      (princ (format "_%-10.10s_|" "__________"))
      (let ((j 0))
 (while (< j k)
   (princ (format "_%-50.50s_|"
"__________________________________________________"))
   (setq j (+ j 1))
   )
 )
      (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 "_")
     )
       (if (null 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) 48)))
       (princ (format " %-50.50s |" binding-string))
       (setq j (+ j 1))
       )
     )
   )
 (princ "\n")
 (setq i (+ i 1))
 )
      (princ (format "_%-10.10s_|" "__________"))
      (let ((j 0))
 (while (< j k)
   (princ (format "_%-50.50s_|"
"__________________________________________________"))
   (setq j (+ j 1))
   )
 )
      )
    )
  (delete-window)
  (hscroll-mode)
  )
(global-set-key [(control h) (b)] 'keytable)

Hope this is useful to some people...
-sandip


Reply via email to