[R-SIG-Mac] Setting locale for running R in emacs / ess

Marc Schwartz marc_schwartz at me.com
Fri Oct 23 13:26:03 CEST 2015


> On Oct 23, 2015, at 5:33 AM, Rainer M Krug <Rainer at krugs.de> wrote:
> 
> Hi
> 
> I installed R via homebrew, but it should be the same for the normal R
> installation.
> 
> When I start R in emacs, I get these unset locale warnings:
> 
> ,----
> | During startup - Warning messages:
> | 1: Setting LC_CTYPE failed, using "C" 
> | 2: Setting LC_COLLATE failed, using "C" 
> | 3: Setting LC_TIME failed, using "C" 
> | 4: Setting LC_MESSAGES failed, using "C" 
> | 5: Setting LC_MONETARY failed, using "C" 
> | > > options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
> | > sessionInfo()
> | R version 3.2.2 (2015-08-14)
> | Platform: x86_64-apple-darwin14.5.0 (64-bit)
> | Running under: OS X 10.11 (El Capitan)
> | 
> | locale:
> | [1] C
> | 
> | attached base packages:
> | [1] stats     graphics  grDevices utils     datasets  methods   base     
> | > version
> |                _                           
> | platform       x86_64-apple-darwin14.5.0   
> | arch           x86_64                      
> | os             darwin14.5.0                
> | system         x86_64, darwin14.5.0        
> | status                                     
> | major          3                           
> | minor          2.2                         
> | year           2015                        
> | month          08                          
> | day            14                          
> | svn rev        69053                       
> | language       R                           
> | version.string R version 3.2.2 (2015-08-14)
> | nickname       Fire Safety                 
> | > 
> `----
> 
> But I have the following in my .emacs file which should set the locales
> (as far as I know)
> 
> ,----
> | (setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
> | (set-language-environment 'utf-8)
> | ;; (set-keyboard-coding-system 'utf-8-mac) ; For old Carbon emacs on OS X only
> | (setq locale-coding-system 'utf-8)
> | (set-default-coding-systems 'utf-8)
> | (set-terminal-coding-system 'utf-8)
> | (unless (eq system-type 'windows-nt)
> |   (set-selection-coding-system 'utf-8))
> | (prefer-coding-system 'utf-8)
> `----
> 
> which apparently does not work.
> 
> Do I have to resort to setting the locales as described at
> http://stackoverflow.com/questions/30264526/why-does-my-ess-r-session-fall-back-to-c-locale
> 
> or am I missing something?
> 
> Thanks,
> 
> Rainer


Rainer,

Download exec-path-from-shell.el from:

  https://github.com/purcell/exec-path-from-shell

and place it where you may have other Emacs related add ins.

Then, in your ~/.emacs file, add:

  (load "/PATH.TO/exec-path-from-shell")
  (exec-path-from-shell-initialize)

Replacing PATH.TO with the actual path to the exec-path-from-shell.el file.

You should remove the other lines pertaining to locales that you have above.

That should help Emacs/ESS started from the GUI/dock pick up the environment that you would normally have in a terminal session of R.

Also, in case you are not aware, there is a dedicated ESS list here:

  https://stat.ethz.ch/mailman/listinfo/ess-help


Regards,

Marc Schwartz



More information about the R-SIG-Mac mailing list