Hi list,

I am sometimes annoyed by the plots in R showed only in a separate window,
mainly because I don't want to deal with a separate window and I don't have
the ability to keep some old plots I made without actively saving them. In
fact I would like to have something like R studio where the plots are
integrated with the rest of the IDE, and there is the ability to go back to
the previous plots.

So I'd like to show the plots in a separate buffers of emacs called
something like *R-plots*.

For this my idea is to do the following:
1. change the graphic device of R to output the plots in a temp file
(called something like "temp-plot.png").
2. have a file watcher that monitors the changes makde to temp-plot.png,
and whenever a change is made to that file, emacs will add the
corresponding image into *R-plots* (using (insert-image (create-image
"/my/working/directory/temp-plot.png")

However, I have some problems:
1. I don't know how to have R save the plots into a file automatically
(without runnung: png("temp-plot.png"); runMyPlot(); dev.off() - I want to
have it by just doing runMyPlot() ).
2. I briefly tested the following:
(defun install-monitor-test (file secs)
  (run-with-timer
   0 secs
   (lambda (f p)
     (let ((att (file-attributes f)))
       (unless (or (null monitor-attributes) (equalp monitor-attributes
att))

         (with-current-buffer  "*scratch*" (insert-image (create-image
file))))
       (setq monitor-attributes att)))
   file secs))

And it doesn't show anything.
However, replacing (with-current-buffer  "*scratch*" (insert-image
(create-image file))) by (message "test") works, and also that code works
when ran separately.

So I would be grateful if someone can indicate me how to fix the problems
listed or suggest me another approach.

Thanks a lot,
Sam

	[[alternative HTML version deleted]]

