[ESS] Eval line or region from r-help mails in gnus buffers.

Vitaly S. spinuvit.list at gmail.com
Fri Aug 6 14:51:04 CEST 2010

Dear ESS community,

I've just wrote a function to evaluate line or region directly from 
the r-help mails (in my case gnus article buffers).

Here it is, in case anyone else is interested in this sort of behavior.

(defun ess-eval-line-or-region-gnus ()
  "Evaluate a line or a region from r-help gnus article, depending on whether
    the selection is active.  Cleans the region/line with
    ess-transcript-clean-buffer first. Works from any buffer in emacs."
    (let ((is-region (and transient-mark-mode mark-active)))
      (let ((start (if is-region (region-beginning)
            (end (if is-region (region-end)
            (curbuff (current-buffer))
            (tbuf (get-buffer-create "*ess.gnus.trns*")))
        (set-buffer tbuf)
        (toggle-read-only -1)
        (delete-region (mark) (point))
        (insert-buffer-substring curbuff start end)
        (goto-char (point-min))
        (while (re-search-forward "^>[> +]+" nil t)
          (replace-match "> "))
        (ess-eval-buffer nil)
  (goto-char (region-end))
  (move-beginning-of-line 2)
  (ess-show-buffer (buffer-name (process-buffer (get-ess-process ess-current-process-name t))))

Bind it to C-j

  (define-key gnus-article-mode-map [(control j)] 'ess-eval-line-or-region-gnus)


More information about the ESS-help mailing list