2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- ESS (R) Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq ess-packages
|
2014-11-11 03:27:06 +00:00
|
|
|
'(
|
2015-04-09 03:57:22 +00:00
|
|
|
company
|
2014-11-11 03:27:06 +00:00
|
|
|
ess
|
|
|
|
ess-R-data-view
|
|
|
|
ess-R-object-popup
|
2015-03-02 23:37:34 +00:00
|
|
|
ess-smart-equals
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-11-12 04:02:50 +00:00
|
|
|
|
2014-11-11 05:08:23 +00:00
|
|
|
(defun ess/init-ess ()
|
2015-10-12 03:01:45 +00:00
|
|
|
(use-package ess-site
|
|
|
|
:mode (("\\.sp\\'" . S-mode)
|
|
|
|
("/R/.*\\.q\\'" . R-mode)
|
|
|
|
("\\.[qsS]\\'" . S-mode)
|
|
|
|
("\\.ssc\\'" . S-mode)
|
|
|
|
("\\.SSC\\'" . S-mode)
|
|
|
|
("\\.[rR]\\'" . R-mode)
|
|
|
|
("\\.[rR]nw\\'" . Rnw-mode)
|
|
|
|
("\\.[sS]nw\\'" . Snw-mode)
|
|
|
|
("\\.[rR]profile\\'" . R-mode)
|
|
|
|
("NAMESPACE\\'" . R-mode)
|
|
|
|
("CITATION\\'" . R-mode)
|
|
|
|
("\\.omg\\'" . omegahat-mode)
|
|
|
|
("\\.hat\\'" . omegahat-mode)
|
|
|
|
("\\.lsp\\'" . XLS-mode)
|
|
|
|
("\\.do\\'" . STA-mode)
|
|
|
|
("\\.ado\\'" . STA-mode)
|
|
|
|
("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
|
|
|
|
("\\.jl\\'" . ess-julia-mode)
|
|
|
|
("\\.[Ss]t\\'" . S-transcript-mode)
|
|
|
|
("\\.Sout" . S-transcript-mode)
|
|
|
|
("\\.[Rr]out" . R-transcript-mode)
|
|
|
|
("\\.Rd\\'" . Rd-mode)
|
|
|
|
("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
|
|
|
|
("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode)
|
|
|
|
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode))
|
|
|
|
:commands (R stata julia SAS)
|
2015-02-05 16:09:21 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-01-26 16:31:15 +00:00
|
|
|
(spacemacs/register-repl 'ess-site 'julia)
|
2016-02-01 04:41:40 +00:00
|
|
|
(spacemacs/register-repl 'ess-site 'R)
|
|
|
|
(spacemacs/register-repl 'ess-site 'SAS)
|
|
|
|
(spacemacs/register-repl 'ess-site 'stata)
|
2015-11-28 12:17:02 +00:00
|
|
|
;; Explicitly run prog-mode hooks since ess-mode does not derive from
|
|
|
|
;; prog-mode major-mode
|
2016-04-11 13:12:53 +00:00
|
|
|
(add-hook 'ess-mode-hook 'spacemacs/run-prog-mode-hooks)
|
2015-10-13 17:19:25 +00:00
|
|
|
(when (configuration-layer/package-usedp 'company)
|
2015-12-11 13:43:50 +00:00
|
|
|
(add-hook 'ess-mode-hook 'company-mode))))
|
2015-02-05 16:09:21 +00:00
|
|
|
|
2014-11-11 03:27:06 +00:00
|
|
|
;; R --------------------------------------------------------------------------
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'ess-site
|
|
|
|
;; Follow Hadley Wickham's R style guide
|
|
|
|
(setq ess-first-continued-statement-offset 2
|
|
|
|
ess-continued-statement-offset 0
|
|
|
|
ess-expression-offset 2
|
|
|
|
ess-nuke-trailing-whitespace-p t
|
|
|
|
ess-default-style 'DEFAULT)
|
2015-10-14 14:52:26 +00:00
|
|
|
|
|
|
|
(defun spacemacs/ess-start-repl ()
|
|
|
|
"Start a REPL corresponding to the ess-language of the current buffer."
|
|
|
|
(interactive)
|
|
|
|
(cond
|
|
|
|
((string= "S" ess-language) (call-interactively 'R))
|
|
|
|
((string= "STA" ess-language) (call-interactively 'stata))
|
|
|
|
((string= "SAS" ess-language) (call-interactively 'SAS))))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'ess-julia-mode
|
2016-01-26 16:31:15 +00:00
|
|
|
"'" 'julia
|
2015-11-18 00:38:05 +00:00
|
|
|
"si" 'julia)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'ess-mode
|
2016-01-26 16:31:15 +00:00
|
|
|
"'" 'spacemacs/ess-start-repl
|
2015-11-18 00:38:05 +00:00
|
|
|
"si" 'spacemacs/ess-start-repl
|
2015-09-29 05:07:57 +00:00
|
|
|
;; noweb
|
2015-11-18 00:38:05 +00:00
|
|
|
"cC" 'ess-eval-chunk-and-go
|
|
|
|
"cc" 'ess-eval-chunk
|
|
|
|
"cd" 'ess-eval-chunk-and-step
|
|
|
|
"cm" 'ess-noweb-mark-chunk
|
|
|
|
"cN" 'ess-noweb-previous-chunk
|
|
|
|
"cn" 'ess-noweb-next-chunk
|
2015-09-29 05:07:57 +00:00
|
|
|
;; REPL
|
2015-11-18 00:38:05 +00:00
|
|
|
"sB" 'ess-eval-buffer-and-go
|
|
|
|
"sb" 'ess-eval-buffer
|
|
|
|
"sD" 'ess-eval-function-or-paragraph-and-step
|
|
|
|
"sd" 'ess-eval-region-or-line-and-step
|
|
|
|
"sL" 'ess-eval-line-and-go
|
|
|
|
"sl" 'ess-eval-line
|
|
|
|
"sR" 'ess-eval-region-and-go
|
|
|
|
"sr" 'ess-eval-region
|
|
|
|
"sT" 'ess-eval-function-and-go
|
|
|
|
"st" 'ess-eval-function
|
2015-10-14 14:52:26 +00:00
|
|
|
;; R helpers
|
2015-11-18 00:38:05 +00:00
|
|
|
"hd" 'ess-R-dv-pprint
|
|
|
|
"hi" 'ess-R-object-popup
|
|
|
|
"ht" 'ess-R-dv-ctable
|
2015-09-29 05:07:57 +00:00
|
|
|
)
|
|
|
|
(define-key ess-mode-map (kbd "<s-return>") 'ess-eval-line)
|
|
|
|
(define-key inferior-ess-mode-map (kbd "C-j") 'comint-next-input)
|
|
|
|
(define-key inferior-ess-mode-map (kbd "C-k") 'comint-previous-input)))
|
2015-02-05 00:33:10 +00:00
|
|
|
|
2015-04-03 21:35:33 +00:00
|
|
|
(defun ess/init-ess-R-data-view ())
|
|
|
|
|
|
|
|
(defun ess/init-ess-R-object-popup ())
|
|
|
|
|
2015-02-05 00:33:10 +00:00
|
|
|
(defun ess/init-ess-smart-equals ()
|
2015-02-25 18:47:50 +00:00
|
|
|
(use-package ess-smart-equals
|
|
|
|
:defer t
|
|
|
|
:if ess-enable-smart-equals
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'ess-mode-hook 'ess-smart-equals-mode)
|
|
|
|
(add-hook 'inferior-ess-mode-hook 'ess-smart-equals-mode))))
|