accelorator key for 'ESS - ESS Eval - Eval chunk'

Stephen Eglen stephen at
Mon Dec 8 12:09:55 CET 2003

 > > For ESS core: is this the right approach to take?
 > I think it is a good first pass; in particular, I think that most
 > (60%? more) will be using eval-line prior to running all chunks.  
 > (otherwise, if using it for writing Sweave files, one might consider
 > just using Sweave...).
 > > Also, if the value of ess-local-process-name in the .Rnw buffer is
 > > nil, after the chunk has been run, ess-local-process-name should have
 > > a value; should that value then be copied (inherited) back into the
 > > .Rnw buffer?
 > Yes, that does sound in-line with the others.  If you have time,
 > Stephen, please do and commit.

Thanks Tony, I've just committed the following version of the defun to
CVS.  This version means that you don't need to use eval-line before

John: could you please check it works for you?


(defun ess-eval-chunk (vis)
  "Tangle the current chunk and send it to the inferior ESS process.
Arg has same meaning as for `ess-eval-region'."
  (interactive "P")
  (let ( (process-name ess-local-process-name)
	 (cbuf (current-buffer))
	 (temp-buffer (ess-create-temp-buffer "Tangle Buffer")))
    (noweb-tangle-chunk temp-buffer)
    (set-buffer temp-buffer)
    ;; When the temp buffer is created, it does not inherit any value
    ;; of ess-local-process-name from the .Rnw buffer, so we have to set it
    ;; here.  If ess-local-process-name is not set in the .Rnw buffer, 
    ;; it will inherit the value that is chosen here.
    (set (make-local-variable 'ess-local-process-name) process-name)
    (ess-eval-region (point-min) (point-max) vis "Eval buffer")
    (if process-name
	(kill-buffer temp-buffer)
      ;; if process-name was nil, source buffer did not have a local process
      ;; so keep value from temp buffer before killing it.
      (setq new-process-name ess-local-process-name)
      (kill-buffer temp-buffer)
      (set-buffer cbuf)
      (set (make-local-variable 'ess-local-process-name) new-process-name))))

More information about the ESS-help mailing list