]> git.eshelyaron.com Git - emacs.git/commitdiff
Add better descriptions for lambdas, closures, keymaps
authorMatus Goljer <dota.keys@gmail.com>
Tue, 18 Feb 2014 12:40:25 +0000 (13:40 +0100)
committerMatus Goljer <dota.keys@gmail.com>
Tue, 18 Feb 2014 12:40:25 +0000 (13:40 +0100)
lisp/use-package/bind-key.el

index c15a4321ef984951699b71b86467f240b5f7e381..a6bba121fe7e6af34cfee785ee7738ad8a80380b 100644 (file)
   :type 'regexp
   :group 'bind-key)
 
+(defcustom bind-key-describe-special-forms nil
+  "If non-nil, extract docstrings from lambdas, closures and keymaps if possible."
+  :type 'boolean
+  :group 'bind-key)
+
 ;; Create override-global-mode to force key remappings
 
 (defvar override-global-map (make-keymap)
@@ -184,15 +189,25 @@ function symbol (unquoted)."
    ((listp elem)
     (cond
      ((eq 'lambda (car elem))
-      "#<lambda>")
+      (if (and bind-key-describe-special-forms
+               (stringp (nth 2 elem)))
+          (nth 2 elem)
+        "#<lambda>"))
      ((eq 'closure (car elem))
-      "#<closure>")
+      (if (and bind-key-describe-special-forms
+               (stringp (nth 3 elem)))
+          (nth 3 elem)
+        "#<closure>"))
      ((eq 'keymap (car elem))
       "#<keymap>")
      (t
       elem)))
    ((keymapp elem)
-    "#<keymap>")
+    (if (and bind-key-describe-special-forms
+             (symbolp elem)
+             (get elem 'variable-documentation))
+        (format "%s" (get elem 'variable-documentation))
+      "#<keymap>"))
    ((symbolp elem)
     elem)
    (t