[ESS] trace(edit=TRUE) under MS Windows

Ross Boylan ross at biostat.ucsf.edu
Thu Mar 7 20:18:36 CET 2013


I got one thing working, but not the other.
On 3/7/2013 1:15 AM, Vitalie Spinu wrote:
> Hi Ross,
>
> It works fine for me on linux. The error message you get is from emacs
> not R. You have to start emacs server before able to run emacsclient.
>
> Put this into your .emacs:
>
>     (require 'server)
>     (server-start)
Thank you.  That seems like something that should be in the ESS 
manual--or did I miss it?  I got this working.

For the record, my initial attempts to edit the function were 
ineffective.  I had to
1) notice the buffer message about typing C-# when done with the edits.  
I am not sure if it is also necessary to save the buffer; I've been 
saving to be safe.
2) realize that, although I edited mice.impute.2L.norm  the code is like 
this
mice.impute.2L.norm <- function() {.......}
mice.impute.2l.norm <- mice.impute.2L.norm
My original edits to the 2L (uppercase) version were ineffective because 
they did not add tracing the the 2l (lowercase) version, and that was 
the route used to invoke the routine.  tracing the 2l version worked.
3) ignore the fact that when I typed mice.impute.2L.norm to see a 
listing of the code my tracing code was not present.  I guess the 
listing just shows the original version.

As noted previously, I also had to set the editor system option to use 
the full path.

BTW, mice.impute.2l.norm is an exported function from a package. trace 
seems to handle that properly; I did not end up with any copies of the 
function in the global namespace as indicated by ls().

>     
>
>
> The following, ESS specific alternative could also be used here.  Press
> C-c C-e C-d and choose mice.impute.2L.norm. Edit and eval or source.
This did not work.  Every time I tried it emacs hung up until I hit 
C-g.  After the C-g the *R* buffer had
Enter an item from the menu, or 0 to exit
Selection: 0
While it was waiting the status line showed "Forming completions for 
package:glmmADMB" .
After the *ESS* buffer showed
*ddeclient-p: ess-loc-proc-name is 'R'(get-object-list R) ..--> 
(ess-get-modtime-list)
  (ess-search-list ... ) *ddeclient-p: ess-loc-proc-name is 'R'after 
'search()
', point-max=326
(ess-object-names obj=.GlobalEnv): no directory - trying names
*ddeclient-p: ess-loc-proc-name is 'R'(ess-object-names obj=.GlobalEnv): 
no dir.; -> objects()
*ddeclient-p: ess-loc-proc-name is 'R'(ess-object-names 
obj=package:glmmADMB): no directory - trying names
*ddeclient-p: ess-loc-proc-name is 'R'

I also tried typing mice.impute.2L.norm at the R prompt and, with the 
cursor at the end of the line, C-c C-e C-d.  The misbehavior was the same.
>
> For simple cases that should work fine. For more complex situations you
> have to source into the package environment/namespace. Activate
> ess-developer (C-c C-t C-t) and add a package you want to source into
> (C-c C-t C-a).
Definitely something I want to try.  Thanks for the pointer.
Ross

>  From now on all you eval/load commands should work on
> that package environment/namespace instead of .GlobalEnv.
>
>      Vitalie
>
>
>    >> Ross Boylan <ross at biostat.ucsf.edu>
>    >> on Wed, 06 Mar 2013 17:41:19 -0800 wrote:
>
>    > I just tried
>
>    >> trace(mice.impute.2L.norm, where=mice, edit=TRUE, print=FALSE)
>    > Error in edit(name, file, title, editor) :
>    >   unable to run editor 'emacsclient.exe'
>
>    > Emacs 24.2.1, ESS 12.09-1, Windows 7, R 2.15.2.
>
>    > A few observations:
>    > I suspect this isn't working because my PATH doesn't include the right
>    > directory.  I tried setting the full path, but still had problems:
>
>    >> getOption("editor")
>    > [1] "C:\\Program Files\\GNU Emacs 24.2\\bin\\emacsclient.exe"
>    >> trace(mice.impute.2L.norm, where=mice, edit=TRUE, print=FALSE)
>    > C:\PROGRA~1\GNUEMA~1.2\bin\EMACSC~1.EXE: No socket or alternate editor.  Please use:
>
>    > 	--server-file      (or environment variable EMACS_SERVER_FILE)
>    > 	--alternate-editor (or environment variable ALTERNATE_EDITOR)
>
>    > Some of the R functions seem to attempt to hardcode for emacs, but they don't
>    > know that emacsclient.exe is emacs.  In particular, .makeTracedFunction()
>    > includes this code:
>
>    >         if (is(editor, "character") && !is.na(match(editor, c("emacs",
>    >             "xemacs")))) {
>    >             file <- tempfile("emacs")
>    >             file <- sub("..$", ".R", file)
>    >         }
>    >         else file <- ""
>
>    > It might be good to adjust either R or ESS for greater compatibility.
>
>    > Finally, the ESS info file says
>
>    > 4.7 Using emacsclient
>    > =====================
>
>    > When starting R or S under Unix, ESS sets
>    > `options(editor="emacsclient")'.  (Under Microsoft Windows, it will use
>    > gnuclient.exe rather than emacsclient, but the same principle applies.)
>
>    > That doesn't seem to be true, at least on my MS Windows machine.  I have no
>    > customizations related to this in my .emacs file.
>
>    > Ross Boylan
>
>    > ______________________________________________
>    > ESS-help at r-project.org mailing list
>    > https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list