[ESS] ANSI escape sequences in ESS

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu May 14 20:05:51 CEST 2015


The solution is quite easy.  At least on that one of my computers where
crayon did not work:

You just need to make sure the   has_color()  function (from the
crayon package) returns TRUE.
On  a  non-Windows platform,
the following should work

Sys.setenv(COLORTERM = "emacs")

After that,
    example(green)
works for me also on my new Fedora 21 - Notebook  where things did not
work out of the box.
It seems  Ubuntu does set COLORTERM at least in some cases, and that's
why things worked there automatically.

We could add the above line to the the initial R commands that ESS
"sends for us" on startup.
This will not help for the crayon package as its  has_color()  will
currently always return FALSE  on Windows.
(and maybe the crayon author knows more than I do, and is sure that
these ANSI sequence will never work in emacs ESS in any incantation on
Windows ?)

Martin

Martin

On Tue, May 12, 2015 at 8:13 AM, Martin Maechler
<maechler using stat.math.ethz.ch> wrote:
> On Tue, May 12, 2015 at 12:40 AM, Vitalie Spinu <spinuvit using gmail.com> wrote:
>>
>>
>> Don't you have TERM=dumb in process-environment list?
>>
>> What's the value of Sys.getenv("TERM") for you?
>
> Yes, I do have both   TERM=dumb  set... I have some non-default comint
> settings.. Probably one of those must help....
> ...
> actually "no":
>
> emacs24 -Q
>
> manually    M-x load-file ...../ess/lisp/ess-site.el
>                    M-x R
> and it works ...
>
> for me.
>
>
>
>>
>>  >>> Martin Maechler on Mon, 11 May 2015 23:02:05 +0200 wrote:
>>
>>  > Interestingly, this *works* extremely nicely for me,  using emacs
>>  > 23.4.1 (still the default on ubuntu 14.03 LTS).
>>  > I attach an emacs window screen shot, which at least Vitalie and Tamas will get.
>>
>>  > (R 3.2.0 patched, "current";  emacs 15.09-devel "current")
>>
>>  > Martin
>>
>>  > On Mon, May 11, 2015 at 1:23 AM, Vitalie Spinu <spinuvit using gmail.com> wrote:
>>  >>
>>  >> We are not even getting those delimiters because TERM var is "dumb" by
>>  >> default. You can either:
>>  >>
>>  >> Sys.setenv(TERM = "xterm-256color")
>>  >>
>>  >> directly in R, or prepend that to process-environment in emacs.
>>  >>
>>  >> Vitalie
>>  >>
>>  >>
>>  >> >>> Tamas Papp on Sun, 10 May 2015 17:28:49 +0200 wrote:
>>  >>
>>  >> > On Fri, May 08 2015, Vitalie Spinu <spinuvit using gmail.com> wrote:
>>  >>
>>  >> >> >>> Tamas Papp on Fri, 08 May 2015 13:23:54 +0200 wrote:
>>  >> >>
>>  >> >> > Hi,
>>  >> >> > I saw some R packages that implement ANSI escapes in R and Julia, eg
>>  >> >> > https://github.com/gaborcsardi/crayon . But when I tried this in ESS/R,
>>  >> >> > the output was unchanged, in Julia I saw the escapes.
>>  >> >>
>>  >> >> There is ansi-color-process-output in comint-output-filter-functions so
>>  >> >> it should work in principle. But, as R is not producing any of shush, it
>>  >> >> was never tested.
>>  >> >>
>>  >> >> If you give a small reproducible example that works in terminal but not
>>  >> >> in ESS, I might have a look at it.
>>  >>
>>  >> > Hi Vitalie,
>>  >>
>>  >> > This works in the terminal, but not in Emacs/ESS (versions below):
>>  >>
>>  >> > install.packages("crayon")
>>  >> > library(crayon)
>>  >> > cat(green("test\n"))
>>  >>
>>  >> > Should print "test" in green.
>>  >>
>>  >> > Thanks for looking into this.
>>  >>
>>  >> > Best,
>>  >>
>>  >> > Tamas
>>  >>
>>  >> > PS.: Versions:
>>  >>
>>  >> > GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5) of
>>  >> > 2015-03-07 on trouble, modified by Debian
>>  >>
>>  >> > ess-version: 15.09-devel [elpa: 20150423.923] (loaded from /home/tamas/.emacs.d/elpa/ess-20150423.923/)
>>  >>
>>  >> > R version:
>>  >> >                _
>>  >> > platform       x86_64-pc-linux-gnu
>>  >> > arch           x86_64
>>  >> > os             linux-gnu
>>  >> > system         x86_64, linux-gnu
>>  >> > status
>>  >> > major          3
>>  >> > minor          2.0
>>  >> > year           2015
>>  >> > month          04
>>  >> > day            16
>>  >> > svn rev        68180
>>  >> > language       R
>>  >> > version.string R version 3.2.0 (2015-04-16)
>>  >> > nickname       Full of Ingredients
>>  >>
>>  >> > Crayon: 2015-04-09 00:30:34
>>  >>
>>  >> ______________________________________________
>>  >> ESS-help using r-project.org mailing list
>>  >> https://stat.ethz.ch/mailman/listinfo/ess-help>
>>
>>
>>
>
>>
>>
>>  >>> Martin Maechler on Mon, 11 May 2015 23:02:05 +0200 wrote:
>>
>>  > Interestingly, this *works* extremely nicely for me,  using emacs
>>  > 23.4.1 (still the default on ubuntu 14.03 LTS).
>>  > I attach an emacs window screen shot, which at least Vitalie and Tamas will get.
>>
>>  > (R 3.2.0 patched, "current";  emacs 15.09-devel "current")
>>
>>  > Martin
>>
>>  > On Mon, May 11, 2015 at 1:23 AM, Vitalie Spinu <spinuvit using gmail.com> wrote:
>>  >>
>>  >> We are not even getting those delimiters because TERM var is "dumb" by
>>  >> default. You can either:
>>  >>
>>  >> Sys.setenv(TERM = "xterm-256color")
>>  >>
>>  >> directly in R, or prepend that to process-environment in emacs.
>>  >>
>>  >> Vitalie
>>  >>
>>  >>
>>  >> >>> Tamas Papp on Sun, 10 May 2015 17:28:49 +0200 wrote:
>>  >>
>>  >> > On Fri, May 08 2015, Vitalie Spinu <spinuvit using gmail.com> wrote:
>>  >>
>>  >> >> >>> Tamas Papp on Fri, 08 May 2015 13:23:54 +0200 wrote:
>>  >> >>
>>  >> >> > Hi,
>>  >> >> > I saw some R packages that implement ANSI escapes in R and Julia, eg
>>  >> >> > https://github.com/gaborcsardi/crayon . But when I tried this in ESS/R,
>>  >> >> > the output was unchanged, in Julia I saw the escapes.
>>  >> >>
>>  >> >> There is ansi-color-process-output in comint-output-filter-functions so
>>  >> >> it should work in principle. But, as R is not producing any of shush, it
>>  >> >> was never tested.
>>  >> >>
>>  >> >> If you give a small reproducible example that works in terminal but not
>>  >> >> in ESS, I might have a look at it.
>>  >>
>>  >> > Hi Vitalie,
>>  >>
>>  >> > This works in the terminal, but not in Emacs/ESS (versions below):
>>  >>
>>  >> > install.packages("crayon")
>>  >> > library(crayon)
>>  >> > cat(green("test\n"))
>>  >>
>>  >> > Should print "test" in green.
>>  >>
>>  >> > Thanks for looking into this.
>>  >>
>>  >> > Best,
>>  >>
>>  >> > Tamas
>>  >>
>>  >> > PS.: Versions:
>>  >>
>>  >> > GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5) of
>>  >> > 2015-03-07 on trouble, modified by Debian
>>  >>
>>  >> > ess-version: 15.09-devel [elpa: 20150423.923] (loaded from /home/tamas/.emacs.d/elpa/ess-20150423.923/)
>>  >>
>>  >> > R version:
>>  >> >                _
>>  >> > platform       x86_64-pc-linux-gnu
>>  >> > arch           x86_64
>>  >> > os             linux-gnu
>>  >> > system         x86_64, linux-gnu
>>  >> > status
>>  >> > major          3
>>  >> > minor          2.0
>>  >> > year           2015
>>  >> > month          04
>>  >> > day            16
>>  >> > svn rev        68180
>>  >> > language       R
>>  >> > version.string R version 3.2.0 (2015-04-16)
>>  >> > nickname       Full of Ingredients
>>  >>
>>  >> > Crayon: 2015-04-09 00:30:34
>>  >>
>>  >> ______________________________________________
>>  >> ESS-help using r-project.org mailing list
>>  >> https://stat.ethz.ch/mailman/listinfo/ess-help>
>>
>>
>>




More information about the ESS-help mailing list