iwelch
September 16, 2018, 3:53pm
#1
on macos and linux, copy
julia> x=2
julia> x + 1
into the copy-paste buffer.
obviously, this should not be pasted into a running REPL, because each line starts with julia>
.
except , the REPL is smart enough to recognize this somehow. in fact, on paste, the paste-buffer julia>
does not show up on the screen.
typing the code into the REPL does not work. the 'julia> ’ becomes visible, and then it does not work.
so, how does this feature work? is this special paste functionality in the julia REPL?
1 Like
How did I not notice that this works until now? This wants to be part of the discourse FAQ/PSA, amazing.
iwelch
September 16, 2018, 4:34pm
#4
this is a great feature addition. love it. alas, why did it now work when I typed it:
julia> julia> x=2
> (generic function with 1 method)
julia> julia> x=2
> (generic function with 1 method)
similarly. it does not work with julia source code:
$ cat test.jl
julia> x=2
julia> x=x+1
julia> println(x)
^D
$ julia test.jl
ERROR: LoadError: UndefVarError: x not defined
Stacktrace:
It is only active when pasting (and the terminal supports detecting paste, https://cirw.in/blog/bracketed-paste ).
1 Like
iwelch
September 16, 2018, 4:37pm
#6
great. mille grazie. I did not know that terminal-paste-detection-passthrough existed.
tk3369
September 16, 2018, 4:45pm
#7
This is a good reminder to take a look at the doc. I have never really spent the time in going through the key bindings before.
I found some surprises for myself.
Setting a mark and coming back to it (C-space and C-x C-x)
Moving forward/backward by word (M-f and M-b)
Transpose characters! (C-t, and I had fun C-t all the way to move a char to the end of line)
etc.
But some functions don’t work (I’m using Mac):
M-left/right arrow does not indent/deindent. Instead, it moves cursor left/right a word similar to M-f and M-b
C-/ does nothing but C-_ works properly.
We should also add ]
for entering the package manager mode in the doc.
Liso
September 16, 2018, 4:46pm
#8
Doesn’t Base.REPL.enable_promptpaste(::Bool)
needs to be replaced by REPL.enable_promptpaste(::Bool)
in julia 1.0 doc?
Yes. But the whole option should probably just be removed.
As in just enable it unconditionally?
Yeah, I don’t think anyone has ever disabled it. I think the only reason to disable it is if you wanted to define >
using the infix method which doesn’t seem too likely:
julia> julia> x = 3
> (generic function with 1 method)
julia> "foo" > :bar
3
Liso
September 16, 2018, 5:11pm
#12
BTW if I want to have my own prompt and use this feature I have to use something like:
repl.interface.modes[1].prompt="julia> #=$VERSION=# "
Then I will have (not very nice prompt):
julia> #=1.0.1-pre.4=# a = 3
3
And if I copy+paste it works (but is even more ugly):
julia> #=1.0.1-pre.4=# #=1.0.1-pre.4=# a = 3
3
I would rather see something more flexible:
# maybe julia[any string without '>']>
julia 1.0.1-pre.4>
# or maybe julia([any string without '>'])>
julia( 1.0.1-pre.4 )>
Liso
September 16, 2018, 5:17pm
#13
This one also doesn’t work:
(v1.0) pkg> add package
# copy+paste it
julia> (v1.0) pkg> add package
ERROR: syntax: missing comma or ) in argument list
# or
(v1.0) pkg> (v1.0) pkg> add package
ERROR: expected command. instead got [(v1.0)]
It is only active for julia>
.