Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs editing Rnw keep region highlighted when highlighting R chunk

Tags:

emacs

r

sweave

When editing an Rnw file in Emacs, I often want to make the region cover a chunk of text that contains an R chunk. For a simple example:

ewr
<<>>=
@ 
wer

I use transient-mark-mode such that the region is highlighted. But, if I put the point on the first line and hit C-SPC, then use C-n to move the point down, the highlighting disappears when I try to advance the point past the <<. The region I want is still selected, but highlighting seems to fail when crossing the <<. How can I fix this?

Thanks and best regards

like image 433
stevejb Avatar asked May 17 '10 14:05

stevejb


2 Answers

I find that your problem shows up when I do what you describe, but it goes away if you scroll down using C-down or C-M-n instead. I think you can even use C-down to get past the R chunk and then C-n to step past lines afterward.

like image 95
Fojtasek Avatar answered Nov 20 '22 00:11

Fojtasek


I had the same problem and the solution suggested by fojtasek did not work for me because I had an additional configuration problem. I hope that this might be useful for you and other users. Make sure that if you are using ESS and Auctex that you have fully loaded Auctex. To be more specific, it turned out that when I had previously installed auctex 11.86, I did not correctly load the package. Because I am a novice emacs user, I only managed to load the first of the following two lines:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

If you have not added the second line, you will only have an Auctex menu but NOT a preview-latex menu.

like image 45
Evan Misshula Avatar answered Nov 19 '22 23:11

Evan Misshula