I've attached a patch to get symbol documentation working in the keymap
buffer.

Note that I've rebound mouse-3 as the insert command in deference to
platforms that don't have a convenient way to emulate the middle mouse
button.

I've also bound ? to bring up help on the symbol under point.

Help is only available for the symbols on the APL side of each key. The
keymap buffer won't offer help on symbols such as ravel, compress and
expand. This is an existing limitation of the help buffer code.

-- 
"The secret to creativity is knowing how to hide your sources."
   Albert Einstein


http://soundcloud.com/davidlamkins
http://reverbnation.com/lamkins
http://reverbnation.com/lcw
http://lamkins-guitar.com/
http://lamkins.net/
http://successful-lisp.com/
diff --git a/gnu-apl-documentation.el b/gnu-apl-documentation.el
index 72c6c5a..14371bf 100644
--- a/gnu-apl-documentation.el
+++ b/gnu-apl-documentation.el
@@ -169,7 +169,7 @@ dervived from the APL2 documentation.")
   (propertize string
               'mouse-face 'highlight
               'help-echo (concat "mouse-1: Show documentation for " string "\n"
-                                 "mouse-2: Insert " string " in GNU APL buffer")
+                                 "mouse-3: Insert " string " in GNU APL buffer")
               'gnu-apl-insert string
               'keymap keymap
               'follow-link t))
@@ -195,9 +195,28 @@ dervived from the APL2 documentation.")
     (with-current-buffer session
       (insert string))))
 
+(defun gnu-apl-mouse-help-from-keymap (event)
+  "In the keymap buffer, describe the symbol that was clicked."
+  (interactive "e")
+  (let ((window (posn-window (event-end event)))
+        (pos (posn-point (event-end event))))
+    (unless (windowp window)
+      (error "Can't find window"))
+    (let ((string (with-current-buffer (window-buffer window)
+                    (get-text-property pos 'gnu-apl-insert))))
+      (gnu-apl-show-help-for-symbol string))))
+
+(defun gnu-apl-symbol-help-from-keymap ()
+  "Describe a symbol in the keymap buffer."
+  (interactive)
+  (let ((string (get-text-property (point) 'gnu-apl-insert)))
+    (gnu-apl-show-help-for-symbol string)))
+
 (defun gnu-apl--make-help-property-keymap ()
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-2] 'gnu-apl-mouse-insert-from-keymap)
+    (define-key map [down-mouse-1] 'gnu-apl-mouse-help-from-keymap)
+    (define-key map [mouse-3] 'gnu-apl-mouse-insert-from-keymap)
+    (define-key map (kbd "?") 'gnu-apl-symbol-help-from-keymap)
     (define-key map (kbd "RET") 'gnu-apl-symbol-insert-from-keymap)
     map))
 

Reply via email to