GNUEmacs / ESS / Latex / Sweave: text is displayed differently when the cursor is in latex code or in R code

When I look at a Sweave (Rnw) document with latex and R code, the text jumps when the mode changes between latex and ESS. These two modes do not agree on how the text should be wrapped. Moreover, I noticed that when I do

  • Mx toggle-truncate-lines to enable truncation of long lines while the cursor is in latex code
  • move the cursor to the R-code
  • back to latex code

truncated long line mode is no longer enabled. Has anyone noticed this? Has anyone solved this problem?

+6
source share
1 answer

After reading a similar question on the ess-help@r-project.org mailing list, I found out about it. When we view the noweb file, we switch the main modes from ESS to LaTeX. Most basic modes kill all local variables as part of their initialization, so when we simply set the variable locally, it is overwritten. To solve this problem, I changed the found hook:

(add-hook 'LaTeX-mode-hook '(lambda () (if (string-match "\\.Rnw\\'" buffer-file-name) (setq fill-column 80)))) 

You can set a similar hook for longline or skew-truncation-lines, etc., to suit your needs. The disadvantage of this solution is that you are stuck with a single value for the variable set in the hook.

+4
source

Source: https://habr.com/ru/post/903807/


All Articles