[ESS] feature request: ess-swv-pdflatex

Martin Maechler maechler at stat.math.ethz.ch
Mon May 7 17:17:39 CEST 2007

>>>>> "PaDre" == Patrick Drechsler <patrick at pdrechsler.de>
>>>>>     on Fri, 04 May 2007 11:19:33 +0200 writes:

    PaDre> Hi,
    PaDre> I just noticed that there is no function `ess-swv-pdflatex'. I think
    PaDre> there are two reasons for including this: 

    PaDre> First, for completeness sake (why not have it?). 

    PaDre> Secondly, there are cases where it can enhance the workflow. Here is
    PaDre> an example case:

    PaDre> 1. Open a Rnw file.

    PaDre> with ESS 5.3.4:
    PaDre> 2a. start R (`M-x R') and switch back to Rnw buffer.
    PaDre> 2b. Start Sweave (`M-n s')

    PaDre> with current development version:
    PaDre> 2. Start Sweave ('M-n s') (which now automatically starts an R
    PaDre> process, thanks Martin)

    PaDre> 3. create a PDF (`M-n P')
    PaDre> 4. make some changes to Rnw file.
    PaDre> 5. run Sweave

    PaDre> Now, when using XPDF with GNU/Linux it is faster not to close and
    PaDre> restart the XPDF-viewer but instead to run pdflatex again, switch back
    PaDre> to the XPDF-viewer and press `r' (refresh).

    PaDre> A simple function could look like this (I just replace `latex' with
    PaDre> `pdflatex'):

   --8<---------------cut here---------------start------------->8---
    ;; NOTE: adding function pdflatex
    (defun ess-swv-pdflatex ()
      "Run PDFLaTeX on the product of Sweave()ing the current file."
	(let* ((namestem (file-name-sans-extension (buffer-file-name)))
	       (latex-filename (concat namestem ".tex"))
	       (tex-buf (get-buffer-create " *ESS-tex-output*")))
	  (message "Running PDFLaTeX on '%s' ..." latex-filename)
	  (switch-to-buffer tex-buf)
	  (call-process "pdflatex" nil tex-buf 1 latex-filename)
	  (switch-to-buffer (buffer-name))
	  (display-buffer tex-buf)
	  (message "Finished running PDFLaTeX" ))))
   ;; NOTE: remapping keybinding (old: latex; new: pdflatex)
    (define-key noweb-minor-mode-map "\M-nl" 'ess-swv-pdflatex)
   --8<---------------cut here---------------end--------------->8---

I note your key re-mapping.

I think an improved approach would

 1a)  use one e-lisp function that is mapped to  "\M-nl"

 1b)  that function would have a prefix *) argument that typically
      specifies "latex" or "pdflatex" (but could be "any name"),
      *) a prefix argument could then be user specified via
         \C-u \M-nl
 2)  use a user customizable variable which specifies which of 
     latex or pdflatex should be the default behavior.


I don't have time, at least for another day or two, to go there.

So if anyone is willing to provide patches to ess-swv.el and ess-cust.el
from  https://svn.r-project.org/ESS/trunk/lisp/  ... that would
help/accelerate progress ..


More information about the ESS-help mailing list