gnu-emacs-sources
[Top][All Lists]
Advanced

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

A simple repacement for `describe-bindings' function.


From: Sandip Chitale
Subject: A simple repacement for `describe-bindings' function.
Date: Wed, 9 May 2001 23:49:46 -0700

Does not deal with C-c prefix keymaps yet. In fact I would
like to know how to get keybindings from a prefix keymap.

(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)
  )




reply via email to

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