emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
626 stars 161 forks source link

Using multiple R programs: Buffer-local variable `inferior-ess-r-program` ignored #1158

Closed jackkamm closed 3 years ago

jackkamm commented 3 years ago

I would like to use different versions of R within Emacs, by setting inferior-ess-r-program as a buffer-local variable. However, the buffer-local value is ignored, and M-x R always uses the global value of inferior-ess-r-program.

Minimal reproducible example:

Init.el:

(add-to-list 'load-path "/gstore/home/kammj2/.emacs.d/elpa/ess-20210318.748")
(require 'ess)
(require 'ess-r-mode)

test.R (with inferior-ess-r-program set locally via a file-local variable):

x <- 1+1
print(x)

;; Local Variables:
;; inferior-ess-r-program: "R-prd"
;; End:

Calling M-x R within test.R does not use my desired value of inferior-ess-r-program.

Emacs version: 27.1 ESS version: Pulled from MELPA on 2021-03-18

jackkamm commented 3 years ago

Right after I posted this I realized there's another way to achieve what I want -- define a new function to call the version of R I want:

(defun R-prd ()
  (interactive)
  (let ((inferior-ess-r-program "R-prd"))
    (R)))

Is this the recommended way to use multiple versions of R within Emacs?

If so, feel free to close the issue.

vspinu commented 3 years ago

The comments in R should start with #:

This works for me:

x <- 1+1
print(x)

## Local Variables:
## inferior-ess-r-program: "R-prd"
## End: