JuliaLang/julia — pull request #6683 by mbauman (2014-04-28 21:30:53+00:00)
Title: RFC: Make pasting into the REPL much simpler

Previously, the REPL would try to determine if you had pasted a complete expression, and, if that expression was followed by a newline, it would evaluate it. If there were multiple expressions, it would evaluate each one by one. However, this often fails for me when pasting incomplete snippets that I intend to edit in the command line, and since we have such good multi-line editing support I don't even think it's necessary.

This patch simply removes those smarts. All pasted text is entered into the buffer verbatim (except for an unindentation pass if the cursor is at the beginning of the buffer). The pasted text is not sent for evaluation, even if followed by trailing newlines. Additionally, this fixes #6664 as the cursor ends up at the end of the pasted snippet.

This may be controversial, but I think this dramatically reduces the number of surprises when pasting text. The case that bit me again today was simply pasting two floating point numbers: I just wanted to divide one by the other, but mistakenly pasted the denominator first. So I then copied the numerator, went back to the beginning of the line, and hit paste, intending to type `/` and then evaluate it. But it ended up getting evaluated immediately and throwing a syntax error. I could probably make it smarter for this case, too, but… what is the gain here? Simply so pasted text gets evaluated immediately if it is a complete syntax? I'm not sure that's worth it.