SendCode icon indicating copy to clipboard operation
SendCode copied to clipboard

How do I send request to open the help in Julia?

Open PetrKryslUCSD opened this issue 7 years ago • 7 comments

Binding the key as

// Send code to display help information
    {
        "keys": ["ctrl+shift+h", "ctrl+h"], "command": "send_code",
        "args": {"cmd": " ?$selection"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.julia" }
        ]
    }

results in an error: ERROR: syntax: invalid identifier name "?"

What am I missing?

PetrKryslUCSD avatar Nov 06 '18 03:11 PetrKryslUCSD

Actually, it also does the same thing with no leading space ("args": {"cmd": "?$selection"},).

PetrKryslUCSD avatar Nov 06 '18 03:11 PetrKryslUCSD

To clarify: this is what gets printed:

julia> ?collect                                                                   
ERROR: syntax: invalid identifier name "?"    

when the selection is "collect".

PetrKryslUCSD avatar Nov 06 '18 03:11 PetrKryslUCSD

It does not work because julia interprets ?$selection as a whole thing. There is no easy workaround for now. Basically, you'll need to send the ? and the selection seperately.

randy3k avatar Nov 06 '18 04:11 randy3k

I am not sure I follow. Even sending the ? by itself results in an error:

julia> ?                                                                          
ERROR: syntax: invalid identifier name "?"          

PetrKryslUCSD avatar Nov 06 '18 16:11 PetrKryslUCSD

It is because SendCode sends ?\n rather than just ? , there is no user option to choose not to commit the text.

randy3k avatar Nov 06 '18 21:11 randy3k

Hmm. When I type in ? into the REPL, and then I press return, I don't get an error, I get

help?>                                                                            
search: ⊻ ⊋ ⊊ ⊉ ⊈ ⊇ ⊆ ≥ ≤ ≢ ≡ ≠ ≉ ≈ ∪ ∩ ∛ √ ∘ ∌ ∋ ∉ ∈ ℯ π ÷ ~ | ^ \ > < : / - + * 
                                                                                  
  Welcome to Julia 1.0.1. The full manual is available at                         
                                                                                  
  https://docs.julialang.org/                                                     
                                                                                  
  as well as many great tutorials and learning resources:                         
                                                                                  
  https://julialang.org/learning/                                                 
                                                                                  
  For help on a specific function or macro, type ? followed by its name, e.g.     
  ?cos, or ?@time, and press enter. Type ; to enter shell mode, ] to enter        
  package mode.   

Does that have something to do with carriage return versus newline?

Anyway, at the moment I think it's solved reasonably well with

// Send code to display help information. Thanks to @mbauman for the suggestion.
    {
        "keys": ["ctrl+shift+x", "ctrl+h"], "command": "send_code",
        "args": {"cmd": "REPL.@repl $selection"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.julia" }
        ]
    }

Thanks for your help.

PetrKryslUCSD avatar Nov 06 '18 22:11 PetrKryslUCSD

Perhaps, most standard keyboards send \r.

randy3k avatar Nov 06 '18 22:11 randy3k