Simplify ESS layer autoloads and add keybindings for starting REPLs

This commit is contained in:
Ista Zahn 2015-10-11 23:01:45 -04:00 committed by syl20bnr
parent f89ec043fd
commit a761c0def4
2 changed files with 41 additions and 66 deletions

View file

@ -16,14 +16,16 @@ To use this contribution add it to your =~/.spacemacs=
(setq-default dotspacemacs-configuration-layers '(ess)) (setq-default dotspacemacs-configuration-layers '(ess))
#+END_SRC #+END_SRC
*Important:*
In order to speed up the boot time of =Spacemacs=, =ESS= must be loaded
manually via the key binding: ~SPC e s s~
* Key Bindings * Key Bindings
** Inferior REPL process ** Inferior REPL process
Start an =R= inferior REPL process with ~SPC m s i~. Start an inferior REPL process with these commands:
| Keybinding | Description |
|------------+---------------------|
| ~SCP msir~ | start R process |
| ~SPC msis~ | start Stata process |
| ~SPC msiS~ | start SAS process |
| ~SPC msij~ | start Julia process |
Send code to inferior process commands: Send code to inferior process commands:

View file

@ -21,24 +21,8 @@
)) ))
(defun ess/init-ess () (defun ess/init-ess ()
;; ESS is not quick to load so we just load it when (use-package ess-site
;; we need it (see my-keybindings.el for the associated :mode (("\\.sp\\'" . S-mode)
;; keybinding)
(defun load-ess-on-demand ()
(interactive)
(-all? '---truthy? (list
(require 'ess-site)
(require 'ess-R-object-popup)
(require 'ess-R-data-view))))
(evil-leader/set-key "ess" 'load-ess-on-demand)
(use-package ess
:defer t
:init
(progn
(setq auto-mode-alist (append
'(("\\.sp\\'" . S-mode)
("/R/.*\\.q\\'" . R-mode) ("/R/.*\\.q\\'" . R-mode)
("\\.[qsS]\\'" . S-mode) ("\\.[qsS]\\'" . S-mode)
("\\.ssc\\'" . S-mode) ("\\.ssc\\'" . S-mode)
@ -55,6 +39,7 @@
("\\.do\\'" . STA-mode) ("\\.do\\'" . STA-mode)
("\\.ado\\'" . STA-mode) ("\\.ado\\'" . STA-mode)
("\\.[Ss][Aa][Ss]\\'" . SAS-mode) ("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
("\\.jl\\'" . ess-julia-mode)
("\\.[Ss]t\\'" . S-transcript-mode) ("\\.[Ss]t\\'" . S-transcript-mode)
("\\.Sout" . S-transcript-mode) ("\\.Sout" . S-transcript-mode)
("\\.[Rr]out" . R-transcript-mode) ("\\.[Rr]out" . R-transcript-mode)
@ -65,28 +50,13 @@
("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode) ("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode) ("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode)
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode)) ("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode))
auto-mode-alist)) :commands (R stata julia SAS)
:init
(defun ess/auto-load-hack (mode-symbol) (progn
(eval
`(defun ,mode-symbol ()
"This is a function that will hijack itself with its
definition from ess. The reason this exists is that ess does
not play nicely with autoloads"
(when (load-ess-on-demand)
(,mode-symbol)))))
(defvar ess/r-modes-list '(R-mode R-transcript-mode Rd-mode Rnw-mode S-mode S-transcript-mode
SAS-mode STA-mode Snw-mode XLS-mode ess-bugs-mode ess-jags-mode omegahat-mode)
"This is the list of modes defined by ess")
(mapc (lambda (sym) (ess/auto-load-hack sym)) ess/r-modes-list)
(push '(company-R-args company-R-objects) company-backends-ess-mode))) (push '(company-R-args company-R-objects) company-backends-ess-mode)))
;; R -------------------------------------------------------------------------- ;; R --------------------------------------------------------------------------
(with-eval-after-load 'ess-site (with-eval-after-load 'ess-site
(add-to-list 'auto-mode-alist '("\\.R$" . R-mode))
;; Follow Hadley Wickham's R style guide ;; Follow Hadley Wickham's R style guide
(setq ess-first-continued-statement-offset 2 (setq ess-first-continued-statement-offset 2
ess-continued-statement-offset 0 ess-continued-statement-offset 0
@ -94,7 +64,10 @@ not play nicely with autoloads"
ess-nuke-trailing-whitespace-p t ess-nuke-trailing-whitespace-p t
ess-default-style 'DEFAULT) ess-default-style 'DEFAULT)
(evil-leader/set-key-for-mode 'ess-mode (evil-leader/set-key-for-mode 'ess-mode
"msi" 'R "msir" 'R
"msis" 'stata
"msiS" 'SAS
"msij" 'julia
;; noweb ;; noweb
"mcC" 'ess-eval-chunk-and-go "mcC" 'ess-eval-chunk-and-go
"mcc" 'ess-eval-chunk "mcc" 'ess-eval-chunk