To demonstrate: Starting an R session with M-x R. The comments "# default-directory" are evaluated with C-u C-x C-e. Sourcing a small file doesn't change default-directory, but running it from the buffer with C-c C-r strips the final slash.
ess-version: 18.10.3snapshot [elpa: 20210227.2101] (loaded from /home/brendan/.emacs.d/elpa/ess-20210227.2101/) > setwd('/tmp/test/') > # default-directory "/tmp/test/" > ls() character(0) > # default-directory "/tmp/test/" > source("mwe.R") [1] "Start 2021-03-05 10:44:32" [1] "End 2021-03-05 10:44:32" > # default-directory "/tmp/test/" > start <- Sys.time() + print(sprintf("Start %s", start)) + print(sprintf("End %s", Sys.time())) > [1] "Start 2021-03-05 10:44:49" > [1] "End 2021-03-05 10:44:49" > # default-directory "/tmp/test" However, I can't reproduce this all the time: in a fresh emacs session it might not happen to begin with. I have reproduced this in emacs -q, with just: (package-initialize) (require 'ess) as setup, so it's not down to my (extensive) cruft. It may be worth noting that this happens in the *R* buffer, but not the mwe.R buffer (which retains the correct value). Regards, Brendan -- Brendan Halpin, Department of Sociology, University of Limerick, Ireland Tel: w +353-61-213147 Room F1-007 x 3147 http://teaching.sociology.ul.ie/bhalpin/wordpress twitter:@BrendanTHalpin Papers online at: http://teaching.sociology.ul.ie/bhalpin/publications.html ULSociology on Facebook: Sociology@Limerick twitter:@ULSociology ______________________________________________ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help