When compiling an *.Rnw file with the commands M-n r
and M-n P
my open R buffer is swapped for a buffer that appears to shows knitr compilation information. Is there a way to automatically switch back to the R buffer if knitr compiles without any errors?
Asked
Active
Viewed 247 times
8

Chernoff
- 2,494
- 2
- 20
- 24
-
You may find this question useful http://stackoverflow.com/questions/11043004/emacs-compile-buffer-auto-close – Oleg Pavliv Oct 18 '12 at 18:49
1 Answers
1
Well the easiest way is to advice the function. An advice is a way the add something at the beginning, end (or both) of the function.
Now, I don't know which function takes care of compilation in r-mode, but assuming it is foo
(defadvice foo (after foo-advice () activate)
(other-window 1))
You just have to add an if expression to check if the compilation was error free.

PuercoPop
- 6,707
- 4
- 30
- 40