Q: how can I automatically copy output from ess to the kill ring?


I use ess to conduct statistical analysis. On occasion, I need to copy its raw output into another buffer (usually something like the raw output from xtable to a .tex file).

Doing it by hand

Right now, after I send code to the running process, I have to:

  1. switch to the output buffer
  2. manually mark the relevant output
  3. copy to the kill ring
  4. move on with my day

That's laborious, error prone, and breaks my train of thought. Boo hiss.

Can I do it automatically?

How can I automate the first three steps?

I want to send code to the running process (R, in my case) and copy the output to the kill ring. Does this functionality already exist in ess?

Related posts

(I could probably adapt the answer in this post if necessary, but I don't want to reinvent the wheel.)

1 Answer 1


Maybe not as elegant as what you want, but there are functions for each step in your workflow:

  1. ess-switch-to-inferior-or-script-buffer, C-c C-z
  2. set-mark, C-<space>
  3. comint-previous-prompt, C-c C-p
  4. kill-ring-save, M-w
  5. ess-switch-to-inferior-or-script-buffer, C-c C-z

The elisp version would be:

(defun kill-last-output ()
    (ess-switch-to-ESS t)
    (comint-previous-prompt 1)
    (kill-ring-save (region-beginning) (region-end))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.