Dirk Eddelbuettel | 28 Dec 18:53 2010
Picon

Combining sweave and pdflatex into one helper function


Hi all,

I feel a little sheepish because it took me more than half a decade to find M-n
s and M-n P.  But now that I found these new friends, I don't want to let go.

Better still, I would actually like to combine them both into a helper function
that runs them, additionally prefers pdflatex over texi2dvi and also tells the
pdf viewer to get lost as pdf viewers have been happy to refresh automagically.
 At least on the OS I run most often, but I digress.

Now, I have what is not even read-only access to elisp so my lame attempt

  (defun edd-sweave ()
    "Run sweave and pdflatex"
    (interactice)
    (ess-swv-run-in-R "Sweave")
    (ess-swv-latex)
    (ess-swv-PDF "pdflatex")
  )

  (define-key noweb-minor-mode-map "\M-np" 'edd-sweave)

evaluates but does not make it into the Rnw buffer I currently have.

Could some kind soul help me out?   CC to my address appreciated; I am not
subscribed here.

Also, if ESS Core could amend the behaviour of the ess-swv-PDF function, it
would already help a great deal. I cheat by defining /bin/true as my previewer
(Continue reading)

Stephen Eglen | 28 Dec 19:44 2010
Picon
Picon

Re: Combining sweave and pdflatex into one helper function


>   (defun edd-sweave ()
>     "Run sweave and pdflatex"
>     (interactice)

there's a typo above: interactive

S

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

Dirk Eddelbuettel | 28 Dec 19:50 2010
Picon

Re: Combining sweave and pdflatex into one helper function

Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> writes:
> >   (defun edd-sweave ()
> >     "Run sweave and pdflatex"
> >     (interactice)
> 
> there's a typo above: interactive

Indeed.  That was a last-minute addition.  Thanks for catching that!

Now I can half the posted function. Sweaving happens, but then I get

  ess-error: ESS process not ready. Finish your command before trying again.

which is not entirely truthful as my ESS buffer seems quite chipper. *Messages*
shows nothing either.

What would I need to do to run both functions from my simple wrapper?

Dirk

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

Stephen Eglen | 28 Dec 20:37 2010
Picon
Picon

Re: Combining sweave and pdflatex into one helper function


>   ess-error: ESS process not ready. Finish your command before trying
>   again.

that mighte indicate its trying to run the 2nd commmand before the 1st
has finished.  try the following:

  (defun edd-sweave ()
    "Run sweave and pdflatex"
    (interactive)
    (ess-swv-weave) ; this should make no difference to what you had
    (sleep-for 30)  ; wait 30 seconds ...
    ;;(ess-swv-latex)  ;; is this needed? if the next line runs pdflatex?
    (ess-swv-PDF "pdflatex")
  )

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

Dirk Eddelbuettel | 29 Dec 23:37 2010
Picon

Re: Combining sweave and pdflatex into one helper function


Hi Stephen,

Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> writes:
>   (defun edd-sweave ()
>     "Run sweave and pdflatex"
>     (interactive)
>     (ess-swv-weave) ; this should make no difference to what you had
>     (sleep-for 30)  ; wait 30 seconds ...
>     ;;(ess-swv-latex)  ;; is this needed? if the next line runs pdflatex?
>     (ess-swv-PDF "pdflatex")
>   )

Still doesn't work, sadly.

ess-swv-weave leaves me in the associated R buffer.   

Dirk

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

Paul Johnson | 8 Feb 22:04 2011
Picon

Re: Combining sweave and pdflatex into one helper function

Hello, I need to revive this thread from December.

I've got that same problem Dirk had. I'm running Ubuntu linux with
Emacs 23.2 and ess 5.12.  After Sweaving a document, I get no further,
ESS refuses, minibuffer says:

ess-error: ESS process not ready. Finish your command before trying again.

Did you find an answer to this problem?

Boring details below

On Wed, Dec 29, 2010 at 4:37 PM, Dirk Eddelbuettel <edd <at> debian.org> wrote:
>
> Hi Stephen,
>
> Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> writes:
>>   (defun edd-sweave ()
>>     "Run sweave and pdflatex"
>>     (interactive)
>>     (ess-swv-weave) ; this should make no difference to what you had
>>     (sleep-for 30)  ; wait 30 seconds ...
>>     ;;(ess-swv-latex)  ;; is this needed? if the next line runs pdflatex?
>>     (ess-swv-PDF "pdflatex")
>>   )
>
> Still doesn't work, sadly.
>
> ess-swv-weave leaves me in the associated R buffer.
>
(Continue reading)

Seb | 9 Feb 00:56 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Tue, 8 Feb 2011 15:04:49 -0600,
Paul Johnson <pauljohn32 <at> gmail.com> wrote:

> Hello, I need to revive this thread from December.  I've got that same
> problem Dirk had. I'm running Ubuntu linux with Emacs 23.2 and ess
> 5.12.  After Sweaving a document, I get no further, ESS refuses,
> minibuffer says:

> ess-error: ESS process not ready. Finish your command before trying
> again.

> Did you find an answer to this problem?

I haven't looked at this particular problem, but I suggested an
alternative way of working to Dirk (off-list), which he liked (so we're
2 at least!), but that requires AUCTeX, so may not appeal to everyone.
I may have stolen the major pieces of this from the AUCTeX list:

(add-hook 'Rnw-mode-hook
	  (lambda ()
	    (add-to-list 'TeX-command-list
			 '("Sweave" "R CMD Sweave %s"
			   TeX-run-command nil (latex-mode) :help "Run Sweave") t)
	    (add-to-list 'TeX-command-list
			 '("LatexSweave" "%l %(mode) %s"
			   TeX-run-TeX nil (latex-mode) :help "Run Latex after Sweave") t)
	    (setq TeX-command-default "Sweave")))

and then you can just do 'C-c C-c Sweave' without having to have an R
session running; you can just check that things are fine with 'C-c C-l',
(Continue reading)

Neil Shephard | 9 Feb 09:29 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Tue, Feb 8, 2011 at 11:56 PM, Seb <spluque <at> gmail.com> wrote:

> Should we suggest this in the ESS manual or incorporate into the source
> code?  I think it goes better in the manual, since maintaining it means
> watching for AUCTeX's changes to these parts (these have bit me a few
> times in the past).  Any arguments in favor/against any of these?

You could add it to the wiki entry at
http://www.emacswiki.org/emacs/EmacsSpeaksStatistics

Neil

--

-- 
“Truth in science can be defined as the working hypothesis best suited
to open the way to the next better one.” - Konrad Lorenz

Email - nshephard <at> gmail.com
Website - http://kimura.no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Dirk Eddelbuettel | 11 Feb 17:18 2011
Picon

Re: Combining sweave and pdflatex into one helper function

Seb <spluque <at> gmail.com> writes:
> I haven't looked at this particular problem, but I suggested an
> alternative way of working to Dirk (off-list), which he liked (so we're
> 2 at least!), but that requires AUCTeX, so may not appeal to everyone.

In fact I liked it so much that I encouraged Seb to post it here, and I am glad
to see he now did. Given that this about ESS + Sweave (ie LaTeX) I do not think
it is a stretch to assume AUCTeX (ie LaTeX).

I will try to test Vitali's proposal too.  It would be great to have "something"
in base ESS.

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Seb | 14 Feb 05:29 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Fri, 11 Feb 2011 16:18:46 +0000,
Dirk Eddelbuettel <edd <at> debian.org> wrote:

> Seb <spluque <at> gmail.com> writes:
>> I haven't looked at this particular problem, but I suggested an
>> alternative way of working to Dirk (off-list), which he liked (so
>> we're 2 at least!), but that requires AUCTeX, so may not appeal to
>> everyone.

> In fact I liked it so much that I encouraged Seb to post it here, and
> I am glad to see he now did. Given that this about ESS + Sweave (ie
> LaTeX) I do not think it is a stretch to assume AUCTeX (ie LaTeX).

I've just implemented this in SVN (4460).  All that should be required
is:

(setq ess-swv-plug-into-AUCTeX-p t)

or toggle the menu option Noweb -> Sweaving, Tangling, ... -> AUCTeX
Interface.  This variable defaults to nil.  Can you give it a try?
Thanks.

--

-- 
Seb

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

(Continue reading)

Frank Harrell | 14 Feb 05:33 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Sun, 13 Feb 2011 22:29:07 -0600, Seb <spluque <at> gmail.com> wrote:

> On Fri, 11 Feb 2011 16:18:46 +0000,
> Dirk Eddelbuettel <edd <at> debian.org> wrote:
>
>> Seb <spluque <at> gmail.com> writes:
>>> I haven't looked at this particular problem, but I suggested an
>>> alternative way of working to Dirk (off-list), which he liked (so
>>> we're 2 at least!), but that requires AUCTeX, so may not appeal to
>>> everyone.
>
>> In fact I liked it so much that I encouraged Seb to post it here, and
>> I am glad to see he now did. Given that this about ESS + Sweave (ie
>> LaTeX) I do not think it is a stretch to assume AUCTeX (ie LaTeX).
>
> I've just implemented this in SVN (4460).  All that should be required
> is:
>
> (setq ess-swv-plug-into-AUCTeX-p t)
>
> or toggle the menu option Noweb -> Sweaving, Tangling, ... -> AUCTeX
> Interface.  This variable defaults to nil.  Can you give it a try?
> Thanks.
>
>

Would someone mind summarizing the functionality of ESS+AUCTeX with noweb  
Sweave files?  I'm familiar with AUCTeX with straight LaTeX files.

Thanks
(Continue reading)

Seb | 14 Feb 05:44 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Sun, 13 Feb 2011 22:33:31 -0600,
Frank Harrell <f.harrell <at> vanderbilt.edu> wrote:

[...]

> Would someone mind summarizing the functionality of ESS+AUCTeX with
> noweb Sweave files?  I'm familiar with AUCTeX with straight LaTeX
> files.

I've added a brief section "Sweave and AUCTeX" in the recent commit to
highlight the main aspects.  Please let me know if something is not
clear.

--

-- 
Seb

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Brett Presnell | 14 Feb 17:43 2011
Picon

Re: Combining sweave and pdflatex into one helper function


I grabbed what you posted yesterday and added it into my .emacs, but I
had one strange problem that pushed me back to "M-n s" + "M-n P".  The
problem was that the line

\SweaveOpts{keep.source=TRUE}

which I usually put that the top of my .Rnw file seems to be ignored
when I run Sweave with "C-cC-c Sweave", while it is correctly picked up
by "M-n s".

I haven't gotten around to figuring out why this is happening, but it's
definitely a deal breaker for me.  I don't have time at the moment to
try the SVN version of ESS, but I am currently running

 Ubuntu 10.10
 GNU Emacs 23.1.1
 AUCTeX 11.86
 ESS 5.12

FWIW, I did check that that "M-n s" followed by "C-cC-c LatexSweave"
works correctly, so the problem arises in the running of Sweave, not
pdflatex.

Seb <spluque <at> gmail.com> writes:

> On Fri, 11 Feb 2011 16:18:46 +0000,
> Dirk Eddelbuettel <edd <at> debian.org> wrote:
>
>> Seb <spluque <at> gmail.com> writes:
(Continue reading)

Brett Presnell | 14 Feb 17:50 2011
Picon

Re: Combining sweave and pdflatex into one helper function


Sorry, forgot to mention that my R is version 2.12.1 (x86_64-pc-linux-gnu).

Brett Presnell <presnell <at> stat.ufl.edu> writes:

> I grabbed what you posted yesterday and added it into my .emacs, but I
> had one strange problem that pushed me back to "M-n s" + "M-n P".  The
> problem was that the line
>
> \SweaveOpts{keep.source=TRUE}
>
> which I usually put that the top of my .Rnw file seems to be ignored
> when I run Sweave with "C-cC-c Sweave", while it is correctly picked up
> by "M-n s".
>
> I haven't gotten around to figuring out why this is happening, but it's
> definitely a deal breaker for me.  I don't have time at the moment to
> try the SVN version of ESS, but I am currently running
>
>  Ubuntu 10.10
>  GNU Emacs 23.1.1
>  AUCTeX 11.86
>  ESS 5.12
>
> FWIW, I did check that that "M-n s" followed by "C-cC-c LatexSweave"
> works correctly, so the problem arises in the running of Sweave, not
> pdflatex.
>
>
> Seb <spluque <at> gmail.com> writes:
(Continue reading)

Seb | 14 Feb 18:36 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Mon, 14 Feb 2011 11:43:46 -0500,
Brett Presnell <presnell <at> stat.ufl.edu> wrote:

> I grabbed what you posted yesterday and added it into my .emacs, but I
> had one strange problem that pushed me back to "M-n s" + "M-n P".  The
> problem was that the line

> \SweaveOpts{keep.source=TRUE}

> which I usually put that the top of my .Rnw file seems to be ignored
> when I run Sweave with "C-cC-c Sweave", while it is correctly picked
> up by "M-n s".

Thanks for checking, as I never use keep.source=TRUE.  The problem is
with one of AUCTeX's expansion codes when running Sweave.  I'll commit a
fix for that soon.

--

-- 
Seb

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Seb | 15 Feb 05:50 2011
Picon

Re: Combining sweave and pdflatex into one helper function

On Mon, 14 Feb 2011 11:36:05 -0600,
Seb <spluque <at> gmail.com> wrote:

[...]

> Thanks for checking, as I never use keep.source=TRUE.  The problem is
> with one of AUCTeX's expansion codes when running Sweave.  I'll commit
> a fix for that soon.

This is now fixed in SVN.

--

-- 
Seb

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Vitalie S. | 10 Feb 12:48 2011
Picon

Re: Combining sweave and pdflatex into one helper function

Paul Johnson <pauljohn32 <at> gmail.com> writes:

> Hello, I need to revive this thread from December.
>
> I've got that same problem Dirk had. I'm running Ubuntu linux with
> Emacs 23.2 and ess 5.12.  After Sweaving a document, I get no further,
> ESS refuses, minibuffer says:
>
> ess-error: ESS process not ready. Finish your command before trying again.
>
> Did you find an answer to this problem?

Hi everyone!

I will address Dirk and Paul's problem of merging weaving and pdflatex first,
and the more general issue with the mechanism ESS uses to wait for the
inferior process in a sequel.

Here is the concatenation solution what works for me on Ubuntu:

(defun edd-sweave ()
  "Run sweave and pdflatex"
  (interactive)
  (ess-swv-run-in-R "Sweave")
  ;; need to wait for the prompt and refresh the emacs winds here:
  (ess-prompt-wait2 (get-process ess-current-process-name))
  (ess-swv-PDF "pdflatex")
  )

(defun ess-prompt-wait2 (proc &optional  start-of-output sleep)
(Continue reading)


Gmane