2010-05-23 24 views
8

Tôi tin rằng không phải tất cả người dùng R đều biết rõ. Sẽ rất tuyệt nếu người dùng ESS có thể chia sẻ mã của họ trong tệp .emacs của họ tại đây. Mã nhận xét tốt sẽ đặc biệt hữu ích. Hy vọng điều này sẽ thúc đẩy việc sử dụng ESS của người dùng R.Yêu cầu người dùng ESS/R đề xuất các mã elisp trong tệp .emacs

Trả lời

7

Đối với tôi, điều này là fantastically hữu ích:

;; 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) 

Lấy từ: http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/

+1

Tôi cũng đã sử dụng. Điều này làm cho hành vi của ESS [S] gần hơn với Rgui.exe và có thể thu hút người dùng ESS mới. – ggg

4

trên Debian/Ubuntu, tôi sử dụng gói ESS đòi hỏi không có mục bổ sung trong .emacs nào vì nó sử dụng các thiết lập trên toàn hệ thống từ /etc/emacs/site-start.d/50ess.el. Trên Windows, tôi phải đặt đường dẫn đến Rterm.exe và tôi nguồn ess-site.el giống như hướng dẫn ESS đề xuất.

Tôi tuy nhiên có điều này ... mà là một bản sao gần như thẳng từ 'R Extensions' nó tài liệu tham khảo thủ công:

;; edd 12 May 2006 from R-exts.texi 
;;     with one variation 
;;; C 
(add-hook 'c-mode-hook 
      ;;(lambda() (c-set-style "bsd"))) 
      (lambda() (c-set-style "c++"))) ; edd 
;;;; ESS 
(add-hook 'ess-mode-hook 
      (lambda() 
      (ess-set-style 'C++) 
      ;; Because 
      ;;         DEF GNU BSD K&R C++ 
      ;; ess-indent-level     2 2 8 5 4 
      ;; ess-continued-statement-offset 2 2 8 5 4 
      ;; ess-brace-offset     0 0 -8 -5 -4 
      ;; ess-arg-function-offset   2 4 0 0 0 
      ;; ess-expression-offset    4 2 8 5 4 
      ;; ess-else-offset     0 0 0 0 0 
      ;; ess-close-brace-offset   0 0 0 0 0 
      (add-hook 'local-write-file-hooks 
         (lambda()  
         (ess-nuke-trailing-whitespace))))) 
;(setq ess-nuke-trailing-whitespace-p 'ask)  
;; or even 
(setq ess-nuke-trailing-whitespace-p t) 
+0

Thú vị. Bạn có thiết lập ESS theo cách thủ công mỗi khi bạn khởi động nó không? Ví dụ, tách cửa sổ và bắt đầu R. Tôi thấy nó khá rắc rối. Tôi đã sử dụng mã từ http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/ để tự động hóa điều đó. – ggg

+2

Bạn có thể tìm thấy tệp cấu hình tốt trên trang web của John Fox http://socserv.mcmaster.ca/jfox/Books/Companion/ESS/, thiết lập mọi thứ tự động. Nó được thiết kế cho Xemacs nhưng hoạt động tốt cho Emacs (có thể với một vài sửa đổi). – Calimo

Các vấn đề liên quan