Best way to access docstings (like ? mode)

In the emacs interface julia-repl.el currently we access docstrings with @docs, eg when the user requests help for foo,

@docs foo

is sent to the Julia REPL.

But this does not work for keywords like break or continue, among other things. What’s the best way to replicate what ?foo does?

1 Like
import REPL
Core.eval(Main, REPL.helpmode("break"))

You can intercept the output with:

buf = IOBuffer()
help = Core.eval(Main, REPL.helpmode(buf, "break"))
helpstdout = String(take!(buf))

The helpstdout string is the search output for related things, e.g. search: break AbstractVecOrMat, and the help object is what you show or display to see the actual help (typically it is a Markdown.MD object, but you can of course show it as text/plain, text/markdown, text/html, etc.

2 Likes

Just out of curiosity- why is it not possible to have julia-repl just send “? foo” to the Julia REPL (or what are the disadvantages of this? )
This seems to work (at least with N=1 test cases :slight_smile: ) , but probably I’m missing something about the cases when one needs bracketed pasting ?

(defun julia-repl-doc2 ()
  "Documentation for symbol at point."
  (interactive)
  (julia-repl--send-string (concat "? " (thing-at-point 'symbol t)) nil t))
1 Like

It should be feasible, I just probably need to check and restore the char/line mode.

1 Like