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

发布于 2024-09-02 05:31:55 字数 98 浏览 6 评论 0原文

我相信并不是所有的 R 用户都知道 elisp。如果 ESS 用户可以在此处共享 .emacs 文件中的代码,那就太好了。注释良好的代码将特别有用。希望这能促进R用户对ESS的使用。

I believe that not all R users know elisp. It would be nice if ESS users could share their code in their .emacs file here. Well commented code would be particularly useful. Hope this will promote the use of ESS by R users.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

舟遥客 2024-09-09 05:31:55

对我来说,这个东西非常有用:

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

For me, this thing is fantastically useful:

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

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

能否归途做我良人 2024-09-09 05:31:55

在 Debian / Ubuntu 上,我使用 ESS 软件包,它不需要 .emacs 中任何其他条目,因为它使用 /etc/emacs/ 中的系统范围设置site-start.d/50ess.el。在 Windows 上,我必须设置 Rterm.exe 的路径,并按照 ESS 手册的建议获取 ess-site.el 的路径。

然而我确实有这个......这几乎是它引用的“R Extensions”手册的直接副本:

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

On Debian / Ubuntu, I use the ESS package which requires no additional entries in .emacs whatsoever as it uses the system-wide setup from /etc/emacs/site-start.d/50ess.el. On Windows, I do have to set the path to Rterm.exe and I source ess-site.el just as the ESS manual suggests.

I do however have this ... which is an almost straight copy from the 'R Extensions' manual it references:

;; 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)   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文