[ESS] knitr

Vitalie Spinu spinuvit at gmail.com
Wed Jun 6 22:11:34 CEST 2012


It looks like adding support to Rnw is a 30 minutes job. Adding Rhtml,
Rbrew, Rmd will require a bit of a rewrite of noweb which we plan
anyways. What is the state of the art in the noweb-for-emacs world?

Stephen, you have pointed once to an improved noweb mode. Was it this one:

 http://www.loveshack.ukfsn.org/emacs/noweb.el


  >> Yihui Xie <xie at yihui.name>
  >> on Wed, 6 Jun 2012 10:54:27 -0400 wrote:

  > When we were working on the auto-completion feature in RStudio, I
  > wrote an internal object in knitr for RStudio to use. See

  > str(knitr:::opts_chunk_attr)

This is great, thanks.  Would be also good to have explicit arguments
for functions like opts_knit$get().

  >>> As the first step of the implementation, ESS may just call
  >>> library(knitr);knit(foo.Rnw) just like R CMD Sweave foo.Rnw.
  >> 
  >> Perhaps it would be better to just keep the generic `Sweave' + friends
  >> buttons and make a customization option to choose either Knitr, Sweave
  >> or something else.

We need generic binding. Let's try not to add backend specific
keys. Ideally there would be one key (may be "M-n .") and a menu entry
to select a backend (be it sweave, knitr, pander, brew, or whatever
comes in the future). All other keys should have generic purpose and
names. So far we have only sweave related keys:

 "\M-ns" 'ess-swv-weave) 
 "\M-nT" 'ess-swv-tangle) ;;
 "\M-nl" 'ess-swv-latex)
 "\M-np" 'ess-swv-PS)
 "\M-nP" 'ess-swv-PDF)
 "\M-nx" 'ess-insert-Sexpr)

And noweb generics:

 "\C-n" 'noweb-next-chunk)
 "\C-p" 'noweb-previous-chunk)
 "\M-n" 'noweb-goto-next)
 "\M-m" 'noweb-insert-default-mode-line)
 "\M-p" 'noweb-goto-previous)
 "c" 'noweb-next-code-chunk)
 "C" 'noweb-previous-code-chunk)
 "d" 'noweb-next-doc-chunk)
 "D" 'noweb-previous-doc-chunk)
 "g" 'noweb-goto-chunk)
 "\C-l" 'noweb-update-chunk-vector)
 "\M-l" 'noweb-update-chunk-vector)
 "w" 'noweb-copy-chunk-as-kill)
 "W" 'noweb-copy-chunk-pair-as-kill)
 "k" 'noweb-kill-chunk)
 "K" 'noweb-kill-chunk-pair)
 "m" 'noweb-mark-chunk)
 "M" 'noweb-mark-chunk-pair)
 "n" 'noweb-narrow-to-chunk)
 "N" 'noweb-narrow-to-chunk-pair)
 "t" 'noweb-toggle-narrowing)
 "\t" 'noweb-complete-chunk)
 "q" 'noweb-fill-chunk)
 "i" 'noweb-new-chunk)
 "o" 'noweb-occur)
 "v" 'noweb-mode-version)
 "h" 'noweb-describe-mode)


Would be good to have a meaningful conventions. For example I think pdf
output is preferred by most of the people and M-n p should rather give
PDF output and not  ps. 

Also noweb takes a bunch of useful keys for actions almost no-one
ever use. Example M-n w, would be better ess-weave. M-n t would be
better ess-tangle. I would also put ess-insert-sexp on M-n s etc.

Would be good to have a binding for ess-eval-chunk. And an additional
function ess-eval-chunk-in-place to insert output immediately after the
chunk. This would allow "notebook" type of interaction in the file.

There must also be keys to fold code and doc chunks. Also I think M-n g
sucks, there must be an unified (ido) interface (based on Imenu
probably) and one key to navigate to latex sections, R-code objects and
chunk names.

Please spill your ideas and suggestions. It might be too late, once we
have a brand new noweb.

Vitalie.



More information about the ESS-help mailing list