[ESS] Sweave: focus after `M-n P'

Martin Maechler maechler at stat.math.ethz.ch
Thu May 3 10:45:00 CEST 2007


>>>>> "PaDre" == Patrick Drechsler <patrick at pdrechsler.de>
>>>>>     on Wed, 02 May 2007 23:25:43 +0200 writes:

    PaDre> Hi, when invoking `M-n s' on foo.Rnw and everything
    PaDre> is OK one normally then parses the result (foo.tex)
    PaDre> through (pdf)latex with `M-n l' or `M-n P'.

    PaDre> Failing an interface between ESS and AUCTeX, I think
    PaDre> it would be a good idea to place the "cursor focus"
    PaDre> at the end of the *Shell Command Output Buffer*
    PaDre> instead of the empty *Async Shell Command* buffer.

    PaDre> Let me try to show using a minimal example:

very nice and reproducible.  Thank you, Patrick!

Let me reply here instead of interspersed into your text.

You are entirely right with your diagnosis,
and indeed that behavior is not satisfactory.
It's simply because the (ess-swv-PDF) function which you call
via "M-n P"
ends with these two lines :

    (shell-command (concat "pdflatex " tex-filename))
    (shell-command (concat pdfviewer " " namestem ".pdf &"))))

which is simple, but really not sufficient.
The pdfviewer should not be called at all, as soon as an error
happens in "pdflatex".
I see that (shell-command .) could work with a separate error
buffer, and ESS could look at that error buffer.  That may be
one solution.

Alternatively, I think --- and I'd be glad for advice from Emacs experts ---
we should rather do these things similarly as  "M-n l" == (ess-swv-latex)
does it, namely using a deticated buffer, and switch back to
*.Rnw etc; maybe also using (call-process) which has the advantage that it
provides a return value.

We will try to implement one of the above approaches.

Can you confirm that 'M-n l'  behaves more conveniently?

Martin Maechler, ETH Zurich

    PaDre> 1. Save this as ~/tmp/foo.Rnw:

    PaDre> --8<---------------cut here---------------start------------->8---
    PaDre> \documentclass{article}
    PaDre> \begin{document}
    PaDre> \section{Intro}
    PaDre> \label{sec:intro}
    PaDre> some text some \emph{bold} text.
    PaDre> \end{document}
    PaDre> --8<---------------cut here---------------end--------------->8---

    PaDre> 2. Start R with `M-x R' and switch back to the foo.Rnw buffer[1].
    PaDre> 3. `M-n s'
    PaDre> 4. `M-n P'

    PaDre> Everything is fine.

    PaDre> 5. Now include a small syntax error by deleting the closing bracket after
    PaDre> `\label' so your foo.Rnw file looks like this:

    PaDre> --8<---------------cut here---------------start------------->8---
    PaDre> \documentclass{article}
    PaDre> \begin{document}
    PaDre> \section{Intro}
    PaDre> \label{sec:intro
    PaDre> some text some \emph{bold} text.
    PaDre> \end{document}
    PaDre> --8<---------------cut here---------------end--------------->8---

    PaDre> 6. `M-n s'
    PaDre> 7. 'M-n P'

    PaDre> The PDF file which is displayed is the same as after step 4. The user
    PaDre> will not see that the command `M-n P' had an error message. 

    PaDre> Why? 

    PaDre> At this time the standard Emacs screen is split in two: The top part
    PaDre> showing the source buffer code of `foo.Rnw', the bottom part showing
    PaDre> an empty buffer called *Async Shell Command*.

    PaDre> Switching to the end of the *Shell Command Output* buffer one gets
    PaDre> this:

    PaDre> ,----
    PaDre> | ))
    PaDre> | Runaway argument?
    PaDre> | {sec:intro some text some \emph {bold} text. \end {document} 
    PaDre> | ! File ended while scanning use of \label.
    PaDre> | <inserted text> 
    PaDre> |                 \par 
    PaDre> | <*> foo.tex
    PaDre> |            
    PaDre> | ? 
    PaDre> | ! Emergency stop.
    PaDre> | <inserted text> 
    PaDre> |                 \par 
    PaDre> | <*> foo.tex
    PaDre> |            
    PaDre> | !  ==> Fatal error occurred, no output PDF file produced!
    PaDre> | Transcript written on foo.log.
    PaDre> `----

    PaDre> I think that the the bottom buffer should display the end of the
    PaDre> *Shell Command Output* buffer (instead of *Async Shell Command*) after
    PaDre> invoking `M-n P'.

    PaDre> Cheers

    PaDre> Patrick

    PaDre> Footnotes: 
    PaDre> [1] I always switch back to the Rnw buffer anyway. Can I keep the
    PaDre> focus there by default?

    PaDre> -- 
    PaDre> Europa: Die Zehn Gebote haben 279 Wörter, die amerikanische
    PaDre> Unabhängigkeits- erklärung hat 300 Wörter. Die EU-Verordnung zur
    PaDre> Einfuhr von Karamelbonbons hat 25911 Wörter.
    PaDre> [Bodo H. Hauser]

    PaDre> ______________________________________________
    PaDre> ESS-help at stat.math.ethz.ch mailing list
    PaDre> https://stat.ethz.ch/mailman/listinfo/ess-help




More information about the ESS-help mailing list