向ESS / R用户询问.emacs文件中有关elisp代码的建议

时间:2010-05-23 08:54:50

标签: emacs r elisp ess

我相信并非所有R用户都知道elisp。如果ESS用户可以在他们的.emacs文件中共享他们的代码,这将是很好的。评论良好的代码将特别有用。希望这将促进R用户使用ESS。

2 个答案:

答案 0 :(得分:7)

对我而言,这件事非常有用:

;; ESS: Emacs Speaks Statistics
(load "~/elisp/vendor/ess/lisp/ess-site.el") 

;; Use shift-enter to split window & launch R (if not running), execute highlighted
;; region (if R running & area highlighted), or execute current line
;; (and move to next line, skipping comments). Nice. 
;; See http://www.emacswiki.org/emacs/EmacsSpeaksStatistics,
;; FelipeCsaszar. Adapted to spilit vertically instead of
;; horizontally. 

(setq ess-ask-for-ess-directory nil)
  (setq ess-local-process-name "R")
  (setq ansi-color-for-comint-mode 'filter)
  (setq comint-prompt-read-only t)
  (setq comint-scroll-to-bottom-on-input t)
  (setq comint-scroll-to-bottom-on-output t)
  (setq comint-move-point-for-output t)
  (defun my-ess-start-R ()
    (interactive)
    (if (not (member "*R*" (mapcar (function buffer-name) (buffer-list))))
      (progn
    (delete-other-windows)
    (setq w1 (selected-window))
    (setq w1name (buffer-name))
    (setq w2 (split-window w1 nil t))
    (R)
    (set-window-buffer w2 "*R*")
    (set-window-buffer w1 w1name))))
  (defun my-ess-eval ()
    (interactive)
    (my-ess-start-R)
    (if (and transient-mark-mode mark-active)
    (call-interactively 'ess-eval-region)
      (call-interactively 'ess-eval-line-and-step)))
  (add-hook 'ess-mode-hook
        '(lambda()
           (local-set-key [(shift return)] 'my-ess-eval)))
  (add-hook 'inferior-ess-mode-hook
        '(lambda()
           (local-set-key [C-up] 'comint-previous-input)
           (local-set-key [C-down] 'comint-next-input)))
  (require 'ess-site)

取自:http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/

答案 1 :(得分:4)

在Debian / Ubuntu上,我使用的ESS包需要<{1}} 中没有其他条目,因为它使用.emacs中的系统范围设置。在Windows上,我必须将路径设置为/etc/emacs/site-start.d/50ess.el,并将源Rterm.exe设置为正如ESS手册所示。

我确实有这个...这是一个几乎直接的副本来自它引用的'R Extensions'手册:

ess-site.el