aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/hcel-results.el11
-rw-r--r--lisp/hcel-source.el23
-rw-r--r--lisp/hcel-utils.el7
3 files changed, 32 insertions, 9 deletions
diff --git a/lisp/hcel-results.el b/lisp/hcel-results.el
index d623d59..63f3c91 100644
--- a/lisp/hcel-results.el
+++ b/lisp/hcel-results.el
@@ -228,7 +228,13 @@ Start by choosing a package."
hcel-results-max-page-number))
(mapc
(lambda (result)
- (let ((location-info (alist-get 'locationInfo result)))
+ (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)))))))
(insert "--\n")
(insert (propertize
(format "%s :: %s\n"
@@ -239,7 +245,8 @@ Start by choosing a package."
(insert (format "Defined in %s %s\n"
(hcel-format-package-id
(alist-get 'packageId location-info) "-")
- (alist-get 'modulePath location-info)))))
+ (alist-get 'modulePath location-info)))
+ (when doc (insert doc))))
(alist-get 'json results))
(goto-char (point-min))))
diff --git a/lisp/hcel-source.el b/lisp/hcel-source.el
index c397387..29efab0 100644
--- a/lisp/hcel-source.el
+++ b/lisp/hcel-source.el
@@ -89,6 +89,19 @@ If NO-JUMP is non-nil, just open the source and does not jump to the location wi
'next-error))
buffer))
+(defun hcel-switch-buffer ()
+ (interactive)
+ (switch-to-buffer
+ (read-buffer
+ "Switch to buffer: " nil t
+ (lambda (buffer)
+ (equal
+ (buffer-local-value
+ 'major-mode
+ (get-buffer (if (stringp buffer) buffer (car buffer))))
+ 'hcel-mode)))))
+(define-key hcel-mode-map "b" 'hcel-switch-buffer)
+
(defun hcel-definition-site-at-point ()
"Call definitionSite for identifier at point.
@@ -149,17 +162,13 @@ May cause error if the identifier has exact location."
;; same module
(alist-get 'doc (hcel-lookup-identifier-at-point))
;; other module
- (when-let
- ((definition (ignore-errors (hcel-definition-site-at-point))))
- (alist-get 'documentation definition))
+ (alist-get 'documentation
+ (ignore-errors (hcel-definition-site-at-point)))
;; hoogle
(when-let ((hoogle-docs
(ignore-errors (hcel-hoogle-docs-at-point))))
(when (length> hoogle-docs 0) (concat "Hoogle: " hoogle-docs))))))
- (with-temp-buffer
- (insert docs)
- (shr-render-region (point-min) (point-max))
- (buffer-string))))
+ (hcel-render-html docs)))
;; TODO: multiple expressions
(defun hcel-expressions-type (beg end)
diff --git a/lisp/hcel-utils.el b/lisp/hcel-utils.el
index c7b6755..9db5d81 100644
--- a/lisp/hcel-utils.el
+++ b/lisp/hcel-utils.el
@@ -140,4 +140,11 @@ Example of an idSrcSpan:
(alist-get 'exprType (alist-get 'info expr)))))
(cons expression type)))
+(defun hcel-render-html (html)
+ (when html
+ (with-temp-buffer
+ (insert html)
+ (shr-render-region (point-min) (point-max))
+ (buffer-string))))
+
(provide 'hcel-utils)