Skip to content

Commit

Permalink
Add racket-eldoc-app-full-docs
Browse files Browse the repository at this point in the history
Although I think it's too slow to be enabled by default, let's see.

Note: It's not quite as bad when the racket-scribble.el file is native
compiled... but in my experience, it still wasn't great.

To use in a racket-mode buffer that also has racket-xp-mode enabled:

  (remove-hook 'eldoc-documentation-functions
               #'racket-eldoc-app
               t)

  (add-hook 'eldoc-documentation-functions
            #'racket-eldoc-app-full-docs
            nil t)
  • Loading branch information
greghendershott committed Sep 13, 2024
1 parent 085736b commit f6d68fb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions racket-eldoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
;; SPDX-License-Identifier: GPL-3.0-or-later

(require 'racket-cmd)
(require 'racket-company-doc)

;; Given that `eldoc-documentation-functions' is plural, you might
;; wonder why `racket--eldoc-sexp-app' employs two methods. Wouldn't
Expand Down Expand Up @@ -70,6 +71,29 @@ the surface syntax, or Typed Racket type information."
(racket--eldoc-do-callback callback thing str)))
t)))

(defun racket-eldoc-app-full-docs (callback &rest _more)
"Call eldoc CALLBACK with full docs about app around point.
Assume sexp language. Use doc text property added by racket-xp-mode.
Can be slow when the doc HTML is large/complicated, so, probably
won't enable this by default."
(when (and (racket--cmd-open-p)
(> (point) (point-min)))
(save-excursion
(ignore-errors
(backward-up-list)
(forward-char 1)
(pcase (get-text-property (point) 'racket-xp-doc)
(`(,path ,anchor ,_tag)
(let* ((end (next-single-property-change (point) 'racket-xp-doc))
(thing (buffer-substring-no-properties (point) end)))
(racket--eldoc-do-callback
callback
thing
(with-temp-buffer
(racket--scribble-path+anchor-insert path anchor)
(buffer-string)))
t)))))))

(defun racket--eldoc-do-callback (callback thing str)
(if str
(funcall callback
Expand Down

0 comments on commit f6d68fb

Please sign in to comment.