From murdoch at stats.uwo.ca  Sun Nov 28 16:25:24 2004
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sun Nov 28 16:24:45 2004
Subject: [Rd] RFC: Different handling of commands from clipboard in Windows
	Re: [R] how to pause between plots running scripts?
In-Reply-To: <vuhiq095lke0trblge8161b3dakaubg776@4ax.com>
References: <b68812e704112708422b5228a4@mail.gmail.com>
	<1101582479.13352.37.camel@horizons.localdomain>
	<b68812e704112718032d3cf7d8@mail.gmail.com>
	<vuhiq095lke0trblge8161b3dakaubg776@4ax.com>
Message-ID: <2kpjq0p9bq1i8b2258rl71bds4k9bg83fq@4ax.com>

(Moved from r-help to r-devel)

Terry Mu pointed out that in Windows par(ask=T) works when a script is
sourced, but not when it is run from the script editor.  I think the
reason for this is that the script editor copies the selection to the
clipboard and then pastes it to the console.  When the console stops
to ask the user to hit Enter to continue, the next pasted line
satisfies the request, and things continue on.

This is also a problem with other cut and paste mechanisms:  if you
cut from an external editor and paste to the console, often you'd want
par(ask=T) to work, and you'd want a syntax error to abort the paste,
etc.

Finally, I find that sometimes (e.g. when updating a function
definition) I'd like to be able to do a "silent paste", where the code
is processed and executed, but it doesn't show in the console or the
history list.

We already have code to source() from the clipboard, and it could
address the problems above, but:

 - Source with echo=T doesn't echo, it deparses, so some comments are
lost, formatting is changed, etc.

 - Often I want to paste just part of an expression as I'm typing, so
source'ing from the clipboard wouldn't be what I wanted.  I'd need to
choose which kind of paste.  But we already have 3 ways to paste
(Paste, Paste commands only, Copy and Paste), and I'm reluctant to add
another option which could conceivably be used on all existing
methods.

Another approach would be to make the input routines smarter:  e.g.
clear the input buffer when there's a syntax error, suspend it when
asking for confirmation before the next graph:  but this looks
potentially really messy to me.

Another that deals only with the original graphics problem is to have 
par(ask=T) wait for input to the graphics window, rather than to the
console.  This has the advantage that the graphics window probably has
the focus, so a simple Enter there could satisfy it.

Or some other approach, or some combination of approaches.  

Comments?

Duncan Murdoch


On Sat, 27 Nov 2004 22:38:34 -0500, Duncan Murdoch
<murdoch@stats.uwo.ca> wrote:

>
>>> > I used pause() from library(DAAG) to pasue between plots. This works
>>> > when I source a script, but seems don't work when I run (ctrl + R) the
>>> > script in R.
>
>This sounds like a bug to me, but I'm not sure it's going to be an
>easy one to fix.  
>
>Duncan Murdoch
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[Rd] RFC: Different handling of commands from clipboard in Windows Re: [R] how to pause between plots running scripts?
Duncan Murdoch