[ESS] Prevent ESS From Writing .Rhistory

Kevin Coombes kevin.r.coombes at gmail.com
Thu Aug 25 18:40:24 CEST 2016


Thanks for the suggestion. I _never_ would have guessed that the choice 
of password prompt mattered (especially since I need to read and use two 
different passwords and was planning to customize the prompts to make 
sure I knew which was which).

But I'd already found an even better solution (since I also wanted to 
avoid echoing the password to the screen when I typed it). There is a 
relatively new R package called "getPass" that will popup a tcltk window 
to get the password while only showing asterisks.  As a side effect, it 
also prevents the password from getting written to the .Rhistory file.

On 8/25/2016 11:32 AM, Stephen Eglen wrote:
> hi Kevin,
>
> coming to this late, sorry, but if your main issue is not showing the
> password, then if you change your code slightly, from:
>
>     cat("Password? "); pwd <- readLines(file("stdin"), 1)
>
> to
>
>     cat("Password: "); pwd <- readLines(file("stdin"), 1)
>
> then in version 2, Emacs will not echo the password, and (for me) it
> does not appear in the history file when you quit.
>
> Emacs does this via the variable `comint-password-prompt-regexp'.
>
> Stephen
>
>
>
> On Tue, Aug 23 2016, Kevin Coombes wrote:
>
>> Almost. (Not sure why I couldn't find that in the documentation, so
>> thanks for pointing it out.)
>>
>> If I use (setq ess-history-file nil) in the .emacs, file, then it does
>> indeed prevent the .Rhistory file from being written. But then, of
>> course, for the >99% of the time when I'm not updating clinical data
>> files, it prevents all other .Rhistoery files from being written.
>>
>> So, I tried editing the script file so the first line starts with
>>
>> -*- inferior-R-args: "--no-save" ess-history-file: nil -*-
>>
>> And I confirmed that the value of the variable in the buffer containing
>> the script is indeed 'nil'. (Some of you can already see where this is
>> heading....) But, starting the inferior R process with M-x R from that
>> buffer, the variable is NOT inherited.  So, the *R* buffer still has
>> ess-history-file set to the default value ".Rhistory" and it goes ahead
>> and saves it anyway.
>>
>> Is there anything I can put in the R script that will convince ESS to
>> keep the ess-history-file set to 'nil' in the other (*R*) buffer?
>>
>> Thanks again,
>>     Kevin
>>
>> On 8/23/2016 2:45 PM, Enrico Schumann wrote:
>>> On Tue, 23 Aug 2016, Kevin Coombes <kevin.r.coombes at gmail.com> writes:
>>>
>>>> Hi,
>>>>
>>>> My question: Is it possible to prevent ESS from saving a ".Rhistory" file?
>>>>
>>>> While I know this question has appeared in ess-help before (in
>>>> September 2009), I'd like to resurrect it.  Briefly, the previous
>>>> discussion pointed out that running R from the command line with
>>>>       R --no-save
>>>> will prevent R itself from even asking about writing a workspace
>>>> ".RData" file, and will prevent it from creating a .Rhistory
>>>> file. However, using
>>>>       (setq inferior-R-args "--no-save")
>>>> prevents the RData file but *not* the Rhistory file. The explanation
>>>> had something to do with the (comint-write-input-ring).
>>>>
>>>> I'd like to request that the behavior be changed, by explaining the
>>>> use-case that got me to this point.
>>>>
>>>> The application is that I am the "honest broker" who holds the keys to
>>>> update a clinical data file. That is, I have a password-protected
>>>> Excel file that contains the keys mapping between HIPPA-safe
>>>> identifiers (like Sample013) to the protected health information of
>>>> either the medical record number or patient name. Then there is a
>>>> second password-protected Excel file that contains the updated
>>>> clinical information using unsafe identifiers. I have to open both
>>>> files, put the HIPAA-safe identifiers on the updated clinical
>>>> information, remove the protected information, and write the results.
>>>>
>>>> For obvious reasons, I don't want to hard-code the password into the
>>>> R-script running in ESS.  So, I use the following lines to get the
>>>> password
>>>>
>>>> cat("Password? ")
>>>> pwd <- readLines(file("stdin"), 1)
>>>>
>>>> and go merrily on my way, reading the data, deleting traces that might
>>>> have existed in temporary files, and all should be good.
>>>>
>>>> But it isn't.  Because ESS saves the .Rhistory file at the end, AND
>>>> the .Rhistory file contains the password that I typed. So now there is
>>>> a record of the password in a file left on my machine, and I have to
>>>> manually track down that file and delete it.
>>>>
>>>> Oh, and I'd like a solution that works by using a local file variable
>>>> to set inferior-R-args (or something similar) in the script so that it
>>>> automatically prevents the history file from being written.
>>>>
>>>> So, is my use case strong enough to inspire someone to figure out if
>>>> the current behavior of ESS can be modified? I would be very happy to
>>>> help test things....
>>>>
>>>> Best,
>>>>     Kevin
>>>>
>>>>
>>> Hi Kevin,
>>>
>>> does setting
>>>
>>>     (setq-default inferior-R-args "--no-restore-history --no-save -q")
>>>     (setq ess-history-file nil)
>>>
>>> in your .emacs file help?
>>>
>>> See also http://ess.r-project.org/Manual/ess.html#Saving-History .
>>>
>>>
>>> Kind regards
>>>        Enrico
>>>
>>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>>
>> ______________________________________________
>> ESS-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the ESS-help mailing list