[Rd] Undocumented features of 'browser' (and possible changes)

2006-03-24 Thread Kevin Wright
I often use browser() when debugging a function.  After entering
browser, I would find it very useful to be able to cut-and-paste a
chunk of R code to the browser (or use ess-eval-region in Emacs).  An
inconvenience, however, is that both blank lines and comment lines
will exit the browser.

The man page for browser says nothing about exiting the browser via
ENTER or via a line that begins with a comment, only that
"sub-interpreter can be exited by typing c" and "Typing Q quits the
current execution".

A hack that does allow code pasting into the browser is to put "NULL"
at the start of blank lines and comment lines.

Question: How would people react to a request to change the browser so
that blank lines and comment lines do not exit the browser?

Possible answers (check one or write your own)
[ ] - Who are you kidding?
[ ] - Even though it is undocumented and redundant, I use ENTER to exit browser
[ ] - You are forgetting about this scenario...
[ ] - A patch would be welcome
[ ] - Sounds great and I committed the changes already.  :-)


Kevin Wright, Windows 2000, R 2.2.1

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Undocumented features of 'browser' (and possible changes)

2006-03-24 Thread Peter Dalgaard
"Kevin Wright" <[EMAIL PROTECTED]> writes:

> I often use browser() when debugging a function.  After entering
> browser, I would find it very useful to be able to cut-and-paste a
> chunk of R code to the browser (or use ess-eval-region in Emacs).  An
> inconvenience, however, is that both blank lines and comment lines
> will exit the browser.
> 
> The man page for browser says nothing about exiting the browser via
> ENTER or via a line that begins with a comment, only that
> "sub-interpreter can be exited by typing c" and "Typing Q quits the
> current execution".
> 
> A hack that does allow code pasting into the browser is to put "NULL"
> at the start of blank lines and comment lines.
> 
> Question: How would people react to a request to change the browser so
> that blank lines and comment lines do not exit the browser?
> 
> Possible answers (check one or write your own)
> [ ] - Who are you kidding?
> [ ] - Even though it is undocumented and redundant, I use ENTER to exit 
> browser
> [x] - You are forgetting about this scenario...

ENTER does not actually quit the browser, it repeats the last command,
as in

> f(2)
Called from: f(2)
Browse[1]> n
debug: x <- 2
Browse[1]> 
debug: y <- x + 1
Browse[1]> 

This is useful, since it drives you nuts to type "n",ENTER if you're
debugging a lengthy piece of code (possibly more noticeable when
you're using debug() than with browser(), but the two need to be
consistent). This is also the way things work in e.g. the gdb
debugger.

Having "c" as the initial default is still open for discussion, of
course. The scenario where browser() is in a function that gets called
repeatedly does require some attention; it might be convenient to be
able to continue with a single keystroke in that case.


> [ ] - A patch would be welcome
> [ ] - Sounds great and I committed the changes already.  :-)
> 
> 
> Kevin Wright, Windows 2000, R 2.2.1
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Undocumented features of 'browser' (and possible changes)

2006-03-24 Thread Kevin Wright
Thanks for the clarification about ENTER and for explaining that
browser and debug use the same parser.  I'll crawl back into my
cubicle and keep using my hack.  Maybe I'll look into  re-writing
ess-eval-region to not send blank lines and comment lines.

Kevin


On 24 Mar 2006 23:11:25 +0100, Peter Dalgaard <[EMAIL PROTECTED]> wrote:
> "Kevin Wright" <[EMAIL PROTECTED]> writes:
>
> > I often use browser() when debugging a function.  After entering
> > browser, I would find it very useful to be able to cut-and-paste a
> > chunk of R code to the browser (or use ess-eval-region in Emacs).  An
> > inconvenience, however, is that both blank lines and comment lines
> > will exit the browser.
> >
> > The man page for browser says nothing about exiting the browser via
> > ENTER or via a line that begins with a comment, only that
> > "sub-interpreter can be exited by typing c" and "Typing Q quits the
> > current execution".
> >
> > A hack that does allow code pasting into the browser is to put "NULL"
> > at the start of blank lines and comment lines.
> >
> > Question: How would people react to a request to change the browser so
> > that blank lines and comment lines do not exit the browser?
> >
> > Possible answers (check one or write your own)
> > [ ] - Who are you kidding?
> > [ ] - Even though it is undocumented and redundant, I use ENTER to exit 
> > browser
> > [x] - You are forgetting about this scenario...
>
> ENTER does not actually quit the browser, it repeats the last command,
> as in
>
> > f(2)
> Called from: f(2)
> Browse[1]> n
> debug: x <- 2
> Browse[1]>
> debug: y <- x + 1
> Browse[1]>
>
> This is useful, since it drives you nuts to type "n",ENTER if you're
> debugging a lengthy piece of code (possibly more noticeable when
> you're using debug() than with browser(), but the two need to be
> consistent). This is also the way things work in e.g. the gdb
> debugger.
>
> Having "c" as the initial default is still open for discussion, of
> course. The scenario where browser() is in a function that gets called
> repeatedly does require some attention; it might be convenient to be
> able to continue with a single keystroke in that case.
>
>
> > [ ] - A patch would be welcome
> > [ ] - Sounds great and I committed the changes already.  :-)
> >
> >
> > Kevin Wright, Windows 2000, R 2.2.1
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> --
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Undocumented features of 'browser' (and possible changes)

2006-03-24 Thread Seth Falcon
"Kevin Wright" <[EMAIL PROTECTED]> writes:

> Thanks for the clarification about ENTER and for explaining that
> browser and debug use the same parser.  I'll crawl back into my
> cubicle and keep using my hack.  Maybe I'll look into  re-writing
> ess-eval-region to not send blank lines and comment lines.

Well, modifying ess to get what you want seems reasonable.  I have
used the ENTER as repeat feature so I wouldn't want that to go away.
But it does suggest a couple of alternative solutions:

1. Add one more command that the debug mode knows about that is a
   no-op.  Then copy/paste commands can send that first.

2. Add an option to browser that turns of the ENTER is repeat.

+ seth

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Undocumented features of 'browser' (and possible changes)

2006-03-25 Thread Charles C. Berry
On Fri, 24 Mar 2006, Kevin Wright wrote:

> I often use browser() when debugging a function.  After entering
> browser, I would find it very useful to be able to cut-and-paste a
> chunk of R code to the browser (or use ess-eval-region in Emacs).  An
> inconvenience, however, is that both blank lines and comment lines
> will exit the browser.

Kevin,

This trick may help:

Browse[1]> { ### blank lines will be ignored
+
+
+
+ x+1
+ }
[1] 2
Browse[1]>

Maybe you want to write 'ess-eval-region-in-braces'.

[rest deleted]

Chuck

Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel