[ESS] Introducing Polymode

Vitalie Spinu spinuvit at gmail.com
Wed Mar 27 16:26:12 CET 2013


  >> Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk>
  >> on Wed, 27 Mar 2013 12:01:09 +0000 wrote:

  > a lot of people on this list will presumably be interested in .[RS]nw
  > support; I just tested it and found the following:

  > * If you (require 'poly-r) after ESS, then the auto-mode entries for
  >   polymode take precedence over what ESS has, so when I visit
  >   tests/minimal.Rnw, I am in polymode, as noted by the modeline "PM".
  >   It also switches between latex and R, but:

Yes. ESS and poly-R both reassign .Rnw files. So the latter will take
precedence.

  > * when moving into a R chunk, I see:

  > polymode error: Args out of range: "hite", 4, 6 [5 times]

Rodney reported exactly the same error. I have no clue where it comes
from :(.

You can try to comment out the condition-case at 

╭──────── #326 ─ polymode.el ──
│ (defun polymode-select-buffer ()
│   "Select the appropriate (indirect) buffer corresponding to point's context.
│ This funciton is placed in local post-command hook."
│   (condition-case error
│       (unless pm--ignore-post-command-hook
╰──────── #330 ─


I hope you can get a meaningfully backtrace. The error most likely comes
from font-lock which doesn't show any backtrace either. This makes
development extremely tedious.


  > * When point is on the line <<foo...>>= then the modeline says
  >   "Fundamental PM", except when at the end of the line.  I guess that
  >   makes sense, since technically the chunk name is neither latex or R.

Yes. This is by design. Head and tail are placed in their own
modes. This way people can add arbitrary functionality (like completion
and font-lock) without interfering with other submodes.

  > * In readme.md, I found the comment "No literate programming backends"
  >   confusing.  Isn't Rnw support already here, as noted above?  Or do you
  >   mean there is no support for *processing* literate programming docs?

Rnw is just a polymode. What I mean by literate programming backend is a
tool that can process/convert the file into something else. Like knitr
or org-mode. I will hook these days ess-swv-weave and ess-swv-PDF in R
related polymode maps. That should be quite ok for time being as knitr
is smart enough to recognize the stuff it is dealing with.

You can add your own keys in polymode-mode-map. All other polymode maps
either inherit or use directly this map. The prefix is M-n. See
define-polymode for description.

    Vitalie



More information about the ESS-help mailing list