aboutsummaryrefslogtreecommitdiff
path: root/hcel-results.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-09-29 14:32:42 +1000
committerYuchen Pei <hi@ypei.me>2022-09-29 14:32:42 +1000
commit5e9cd756af1e0b1bbd54103204189832e4860527 (patch)
tree2a75f0a0dee5f4de56480a81c2776a13a7dc0e43 /hcel-results.el
parent968100499cabf0c3d27c8d2df6a08b957102ac30 (diff)
Extracting out button actions in rendered html doc
- help mode: should stay in help mode (unimplemented due to API limitation, goto definition for now). - eldoc / id query results: should goto definition.
Diffstat (limited to 'hcel-results.el')
-rw-r--r--hcel-results.el26
1 files changed, 20 insertions, 6 deletions
diff --git a/hcel-results.el b/hcel-results.el
index d793032..da0335e 100644
--- a/hcel-results.el
+++ b/hcel-results.el
@@ -273,14 +273,15 @@ Start by choosing a package."
(alist-get 'json results))
(goto-char (point-min))))
-(defun hcel-ids-render-result (result)
+(defun hcel-ids-render-result (result &optional button-action)
(let* ((location-info (alist-get 'locationInfo result))
(doc (hcel-render-html
(or (alist-get 'doc result)
(alist-get 'documentation
(ignore-errors
(hcel-definition-site-location-info
- location-info)))))))
+ location-info))))
+ button-action)))
(concat
(propertize
(format "%s :: %s\n"
@@ -433,6 +434,21 @@ Start by choosing a package."
(hcel-ids 'package query hcel-package-id))
(define-key hcel-mode-map "i" #'hcel-package-ids)
+;; TODO: this is impossible with the current API, as definitionSite does not
+;; contain signature, and ExactLocation does not contain component name or even
+;; name
+(defun hcel-help-tag-span-button-action (marker)
+ (hcel-help-internal
+ (print (hcel-definition-site-location-info
+ (get-text-property marker 'location-info)))))
+
+(defun hcel-help-internal (info)
+ (help-setup-xref (list #'hcel-help-internal info)
+ (called-interactively-p 'interactive))
+ (with-help-window (help-buffer)
+ (with-current-buffer standard-output
+ (insert (hcel-ids-render-result info)))))
+
(defun hcel-help (query)
(interactive
(list
@@ -440,10 +456,8 @@ Start by choosing a package."
(completing-read "Find help for identifier: "
#'hcel-global-ids-minibuffer-collection))))
(when (length= (split-string query " ") 2)
- (with-help-window "*hcel-help*"
- (with-current-buffer standard-output
- (insert (hcel-ids-render-result
- (get-text-property 0 'info hcel-ids--minibuffer-selected)))))))
+ (hcel-help-internal
+ (get-text-property 0 'info hcel-ids--minibuffer-selected))))
(provide 'hcel-results)
;;; hcel-results.el ends here.