[ESS] setting transcript file name

Martin Maechler maechler at stat.math.ethz.ch
Tue Aug 2 12:29:48 CEST 2005

>>>>> "StEgl" == Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk>
>>>>>     on Tue, 02 Aug 2005 09:50:29 +0100 writes:

    >> Is it possible to set transcript file name to a predefined one, when
    >> starting ESS? If you set ess-ask-about-transfile to t, it will ask the
    >> filename, but it is a hassle to enter it everytime. I for example
    >> want, that every R session I start with ESS would be recorded in a
    >> transcript file with name
    >> "name-of-directory-R-was-started-in--current-date.St". The bash
    >> equivalent of name would be
    >> $(echo "`pwd`" | sed "s/\/.*\///")-`date +%y-%m-%d`.St
    >> How to translate that to lisp? I have none lisp experience, but if
    >> someone would give an example of similar script, I would be very
    >> grateful.

    StEgl> Currently, ESS does not have that behaviour.  The relevant function is 
    StEgl> inferior-ess which has:

    StEgl> (if ess-ask-about-transfile
    StEgl>    (let ((transfilename (read-file-name
    StEgl>                          "Use transcript file (default none):"
    StEgl>          startdir "")))

    StEgl> One possibility is that we could overload ess-ask-about-transfile
    StEgl> so that if it is bound to a function, that function is executed to
    StEgl> return the default transcript name.  Then you could have a simple
    StEgl> function like:

> (defun my-transcript-name ()
>   (let ((date (format-time-string "%y-%m-%d" (current-time)))
> 	(directory (car
> 		    (last (split-string default-directory "/" 'omit-null)))))
> 	(concat date "-" directory ".Rt")))

    StEgl> when then returns something like

    StEgl> (my-transcript-name) 
    StEgl> "05-08-02-Code.Rt"

    StEgl> But as you can see, this requires a little knowledge of lisp to
    StEgl> write the defun to return the transcript name.

    StEgl> Ess-core: does this sound like worth adding 

Hmm, I have never heard of such a wish, and in all my "teaching"
about ESS I'd rather encourage people to work with 'scripts'
(*.R) rather than 'transcripts' (*.Rt or *.Rout).  

But then, ESS has always been supporting (at least) two kinds of
work habits.  For Vaidotas' habits this will be worth  
{but then I still think he should change them :-) }

    StEgl> (& is there an easier way to get the name of the current directory?)

I think default-directory is quite desirable, but don't know for sure.
To get the `basename' of that directory  however, I'd use

  (file-name-nondirectory (expand-file-name default-directory))

This would also bypass the use of (split-string ..) which does
not accept an  'omit-null argument in my versions of Emacs
(21.3, 21.4).


More information about the ESS-help mailing list