Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return Emacs buffer focus to R after compiling with knitr

Tags:

emacs

r

knitr

ess

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?

like image 608
Chernoff Avatar asked Oct 18 '12 18:10

Chernoff


1 Answers

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.

like image 80
PuercoPop Avatar answered Nov 15 '22 06:11

PuercoPop