[ESS] insert result in the current buffer?
spinuvit at gmail.com
Wed Aug 29 21:15:41 CEST 2012
I also think org-mode is the best for this type of things.
>> Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk>
>> on Wed, 29 Aug 2012 19:29:15 +0100 wrote:
>> my usual workflow is to keep everything I ever type in a file-bound
>> buffer and send stuff to the *R* buffer using C-c C-p or C-c C-j.
>> sometimes I want to copy the result from *R* to the current buffer.
Why not C-c C-c or C-M-x, faster and more powerful (especially from
today, check the HEAD:) ).
>> I wish there were either
>> 1. a separate command which would send stuff to *R* and then copy *R*
>> output into the current buffer OR
>> 2. C-u before an eval command would do that OR
>> 3. a separate command which would copy the last output from *R* into the
>> current buffer
>> Any chance this is already available?
This has been asked before. Back then I wrote a quick lisp. May be it's
good to include it in ESS?
(defun ess-eval-line-or-region-in-place ()
(let ((buf (get-buffer-create " *ess-command-output*")))
(if (not (and transient-mark-mode mark-active))
;; execute current line
(ess-command (format "\n%s\n" (buffer-substring (point-at-bol) (point-at-eol))) buf)
;; else - execute region
(ess-command (format "\n%s\n" (buffer-substring (mark) (point))) buf)
(setq mark-active nil)
(goto-char (max (mark) (point)))
(while (re-search-forward "^" nil t)
(insert "## ")))
(set-mark (point) )
Does exactly what it says, if region is selected eval it and insert
after the code (commented), otherwise eval the current line.
More information about the ESS-help