ESS and R from spacemacs - r

I hope this isn't a really dumb question, but I've used emacs in the past with ESS to edit R files and run them in an R process. I'd like to do the same with spacemacs. As far as I can read and grasp, it just means I have to enable the ess layer in the .spacemacs file, and that's it.
So in my .spacemacs I have the following:
'(
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
;; <M-m f e R> (Emacs style) to install them.
;; ----------------------------------------------------------------
;; auto-completion
;; better-defaults
emacs-lisp
;; git
markdown
javascript
colors
haskell
c-c++
ess
html
;; org
;; (shell :variables
;; shell-default-height 30
;; shell-default-position 'bottom)
;; spell-checking
;; syntax-checking
;; version-control
)
But if I close spacemacs then, and reboot, and try to create say an R file, there's no ess or formatting/colours or anything like that. The same for something like markdown too. All files are just opened in Fundamental mode. I thought spacemacs had layers so you can just add them and it work out of the box. So what am I missing or what should I check? I'm on OSX.
Thanks,
Ben.

Related

Start ESS process in R script

I've got the following problem in my Emacs (i am a complete newby and way far from LISP programming): When i open a .R file, no ESS process is starting. This is a problem because i want to configure TAB-completion and see R Documentation in scripts.
This is the Error message:"No ESS process associated with current buffer
"
This is only the case in .R files. When starting inferior ESS i dont have this problem. (hope i got this right: M-x R starts a process und Emacs and is therefore called inferior?)
My .emacs is cofigured like this:
(require 'auto-complete)
(require 'auto-complete-config)
(require 'ess-stata-mode)
(require 'ess-eldoc)
(add-hook 'inferior-ess-mode-hook 'ess-use-eldoc)
(autoload 'R-mode "ess-site.el" "" t)
(add-to-list 'auto-mode-alist '("\\.R\\'" . R-mode))
Those two lines above should start ESS in script, shouldn't they?
(global-auto-complete-mode t)
(setq ess-tab-complete-in-script t)
(setq ess-use-auto-complete 't)
(setq ess-use-eldoc 't)
(setq ess-use-company 't)
And I included ElDoc and AC to get Autocompletion.
I want to get to see the Documentation of R in Emacs.
I'd really appreciate your help. What did I miss?
Greetings and Thanks in advance

spacemacs ess knitr doesn't work with Rmd files

I really want to switch from RStudio to Spacemacs with ess layer. However I can't get it to work. I have the following in my dotfile:
dotspacemacs-configuration-layers
'(
html
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
;; <M-m f e R> (Emacs style) to install them.
;; ----------------------------------------------------------------
markdown
helm
ess
auto-completion
better-defaults
emacs-lisp
git
polymode
mu4e
;; markdown
;; (shell :variables
org
;; shell-default-height 30
;; shell-default-position 'bottom)
spell-checking
syntax-checking
;; version-control
)
I have the following packages.el in my .emacs.d private folder copied with thanks from github.
;;; packages.el --- polymode layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Walmes Zeviani & Fernando Mayer
;; URL: https://github.com/syl20bnr/spacemacs
;;; Code:
(defconst polymode-packages
'(polymode))
(defun polymode/init-polymode ()
(use-package polymode
:mode (("\\.Rmd" . Rmd-mode))
:init
(progn
(defun Rmd-mode ()
"ESS Markdown mode for Rmd files"
(interactive)
(require 'poly-R)
(require 'poly-markdown)
(R-mode)
(poly-markdown+r-mode))
))
)
;;; packages.el ends here
Syntax highlighting and code completeion etc are working fine but if I try and send code chunks to REPL i get 'wrong type argument stringp nil' error with both Rmd and Rmv files.
emacs 25.2.1 with spacemacs
fresh install on both mac and linux with no other config loaded. Own .emacs has been deleted
some functions seem to work but not like they should e.g. eval-buffer will just send the current code chunk to REPL
Very grateful for any help.
It was a bit tricky to me to make it works with Rmd. Have you try with a simple .R file to see if it works?
This is what I currently have in mi .emacs file for the Rmd files
;; MARKDOWN
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))
;; R modes
(add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
;; polymode
(setq load-path (append '("/home/fer/.emacs.d/elpa/polymode-20170307.322"
"/home/farce/.emacs.d/polymode/modes") load-path))
(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))

How to stop current execution process in ESS when C-c C-c is unresponsive?

I'm handling a datatable with a big amount of text in its fields and when, by mistake, I call a command that starts to print it causes R to freeze or to slowly print everything, I then have to kill emacs and resetup all my windows and buffers. This because during the printing process the command C-c C-c is unresponsive.
Do you knnow how to proceed to handle this without killing the whole working setup ?
You could kill just the ess process with something like,
(defun ess-abort ()
(interactive)
(kill-process (ess-get-process)))
(define-key ess-mode-map (kbd "C-c C-a") 'ess-abort)
(define-key inferior-ess-mode-map (kbd "C-c C-a") 'ess-abort)
eg, in R repl,
library(ggplot2)
toString(diamonds)
followed by C-c C-a. Haven't tried it on Windows however.

Smalltalk equivalent to Common Lisp's #| ... |# comments?

Common Lisp's multiline comments make it easier to include multiline shebangs:
#!/bin/bash
#|
exec clisp -q -q $0 $0 ${1+"$#"}
exit
|#
;;; Usage: ./scriptname.lisp
(defun main (args)
(let ((program (car args)))
(format t "Program: ~a~%" program)
(quit)))
Without this syntax, only very simple shebangs can be used. Is there a pound-based multiline comment for Smalltalk that would facilitate multiline shebangs?
It doesn't NEED to be multi-line; as long as bash can see "into" the Smalltalk comment, you should be okay. I'd be more worried about Smalltalk seeing past the #!
How about something based on:
"exec" "/usr/bin/gst" "--foo" "$0" "--bar" "$#"
There's no need for exit unless you expect the exec ever to fail. Make sure your Smalltalk is where you expect it to be! If you do want the safety valve:
"exec" ...
"exit"
Having to double-quote arguments can get in the way, of course. Double-quoting shell operators breaks their specialness, for example.
"echo" "hello" ">" "/dev/null"
just prints "hello > /dev/null"

How do you pass arguments (I.E. the binarys name) to the Emacs gdb command?

Right now, I have F5 set to start gdb in emacs for me:
(global-set-key [f5] 'gdb)
This switches to the mini-buffer, which I then type a path to an executable... I'd like to find a way to bypass this path typing...
I wrote an executable that looks at the Makefile, parses it and figures out the full path of the executable and prints it to standard out... Is it possible to call this from my .emacs... And then somehow pass the output to the gdb command?
(defun gdb-getpath ()
"Figures out the path to executable and launches gdb."
(interactive)
(let ((path (shell-command-to-string "/path/to/your/executable")))
(gdb (concat "gdb " path))
))
(global-set-key [f5] 'gdb-getpath)

Resources