[ESS] ess-toggle-underscore not working in init.el

Vincent Goulet vincent.goulet at me.com
Tue Sep 16 07:44:51 CEST 2014


Le 2014-09-16 à 01:27, Frede Aakmann Tøgersen <frtog at vestas.com> a écrit :

> Hi
> 
> I am using the Goulet Emacs installation.
> 
> If I put (ess-toggle-underscore nil) in my .emacs (which is in my home directory) file I get the same error as Gregory. However if I put it in the file /path/to/GNU Emacs 24.3/site-lisp/default.el after the (require 'ess-site) it works.

Indeed, but it is not recommended to write stuff in this file and site-start.el as these might be overwritten upon upgrades.

[One might object that there a start menu entry to edit the site configuration file. It's a remnant from a time where ESS didn't yet know how to find R automagically and one had to write the full path in the config file. I should ditch the icon.]

> I guess .emacs is 'sourced' before default.el when starting Emacs in the Goulet installation.

It is, as specified at the top of default.el.

> In that case ess-toggle-underscore has not been defined yet.
> 
> I am not sure how this could be handled graceful. I think that there is a recommended sequence of opening system-wide, personal, and other init files for Emacs. Don't know if Vincent Goulet's installation adhere to that.

This has been discussed here a couple of years ago and I don't think there's a consensus on the issue. In any case, loading ess-site before other init files also caused problems for some people.

From what I understand, one should set variables in site-start.el and .emacs instead of calling functions directly. Emacs and ESS gurus can provide more accurate guidelines. The way my ESS config is done (and works) is through hooks. Something like this in ~/.emacs would solve the problem at hand:

(add-hook 'ess-mode-hook
	  (lambda ()
	    (ess-toggle-underscore nil)))

Feel free to add other customizations in the lambda function.

Hope this helps

v.

>  
> 
> Yours sincerely / Med venlig hilsen
> 
> 
> Frede Aakmann Tøgersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
> 
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog at vestas.com
> http://www.vestas.com
> 
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender. 
> 
> 
>> -----Original Message-----
>> From: ess-help-bounces at r-project.org [mailto:ess-help-bounces at r-
>> project.org] On Behalf Of Vitalie Spinu
>> Sent: 15. september 2014 20:40
>> To: Gregory Warnes
>> Cc: Stephen Eglen; ess-help at r-project.org
>> Subject: Re: [ESS] ess-toggle-underscore not working in init.el
>> 
>> 
>> Sorry, I didn't notice Stephen's code. This function is defined in
>> `ess-s-l.el`. Try "ess" or "ess-s-l".  I don't see why eval-after-load
>> shouldn't work.
>> 
>>  Vitalie
>> 
>>>>> Vitalie Spinu on Mon, 15 Sep 2014 11:35:17 -0700 wrote:
>> 
>>> How do you write you eval-after-load? It should work.
>> 
>>> Vitalie
>> 
>>>>> Gregory Warnes on Mon, 15 Sep 2014 12:32:54 -0400 wrote:
>> 
>>>> Hi Stephen,
>>>> Sadly, eval-after-load produces the same error message, :-(
>> 
>>>> -Greg
>> 
>>>> On Mon, Sep 15, 2014 at 12:04 PM, Stephen Eglen
>> <S.J.Eglen at damtp.cam.ac.uk>
>>>> wrote:
>> 
>>>>> 
>>>>> 
>>>>>> Hi All,
>>>>>> 
>>>>>> I'm using Vincent Goulet's fine Emacs for OSX with ess bundled.
>>>>>> 
>>>>>> For some reason, "(ess-toggle-underscore nil)" is generating an error
>>>>>> message when I include it in my .emacs.d/init.el file:
>>>>>> 
>>>>>> Warning (initialization): An error occurred while loading
>>>>>> `/Users/warnes/.emacs.d/init.el':
>>>>>> 
>>>>>> Symbol's function definition is void: ess-toggle-underscore
>>>>>> 
>>>>>> 
>>>>>> I recall this working in the past, and executing "(ess-toggle-underscore
>>>>>> nil)" after emacs starts up successfully works properly.
>>>>>> 
>>>>>> I suppose that emacs introduced 'lazy-loading' of the ess code, so that
>>>>>> ess-toggle-underscore simply isn't defined until after startup is
>>>>>> complete.
>>>>> 
>>>>> Yes, I think this is because of the way ESS is loaded in Vincent's fine
>>>>> package.  Does something like the following (untested) work?
>>>>> 
>>>>> (eval-after-load  "ess-mode" '(ess-toggle-underscore))
>>>>> 
>> 
>> ______________________________________________
>> ESS-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help
> 
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list