julia-shell-mode icon indicating copy to clipboard operation
julia-shell-mode copied to clipboard

Handling help queries

Open salvipeter opened this issue 9 years ago • 3 comments

In the standard Julia shell, pressing ? at an empty prompt changes the prompt to help?>, and entering a word followed by a newline gives help on that word.

This is a very useful tool, and should be implemented in julia-shell-mode, as well. Note that calling @doc on the word is not really the same, because

  • @doc does not give hints on alternatives
  • @doc cannot be used on some words, such as let or for

The method for displaying the documentation need not be the same, for example it can be an Emacs function bound to shortcut such as C-c C-h, looking up the word at point or querying the user.

The standard shell also has a shell mode, which can be entered by pressing ; at an empty prompt. But running shell commands is already present in Emacs, so it is low priority.

See also the Julia manual on help mode.

salvipeter avatar Nov 05 '15 10:11 salvipeter

I agree. I recently ran into the same problem. Before v0.4, I was able to circumvent that issue by just using help() from the REPL, but that feature was removed in v0.4. It seems like most of the docs/help code happens here, and I'll try to look into it soon. Any suggestions?

EDIT: I'm probably going to build something that does this

dennisog avatar Nov 05 '15 16:11 dennisog

Thanks for the quick reply!

Based on the code you've mentioned, maybe you can do the following:

  1. Define a help function as soon as the shell starts:

    julia_shell_help(ex) = eval(:(Base.Docs.@repl $(symbol(ex))))
    

    This function accepts either strings (e.g. "for") or symbols (e.g. :let) as arguments.

  2. Substitute (internally) ?foo with julia_shell_help("foo"). History should show the original ?foo version.

salvipeter avatar Nov 05 '15 23:11 salvipeter

I'd love to see this feature implemented too. Just started learning Julia. :grinning:

microamp avatar Dec 03 '15 08:12 microamp