[ESS] cat a "\n" when ess-eval-visibly-p is nil?
Feng Li
m at feng.li
Thu Oct 20 19:18:45 CEST 2011
Good job! Thanks a lot:)
Feng
On 10/20/2011 06:47 PM, Vitalie Spinu wrote:
> Hi Feng,
>
> That has been annoying me for years, but it never occurred to me to
> try to do something about it.
>
> I have just implemented this (very) desirable behavior in ess-tracebug
> (http://code.google.com/p/ess-tracebug/).
>
> Executing
>
> head(iris)
> str(iris)
> system.time(Sys.sleep(1))
>
> outputs:
>
>>
> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> 1 5.1 3.5 1.4 0.2 setosa
> 2 4.9 3.0 1.4 0.2 setosa
> 3 4.7 3.2 1.3 0.2 setosa
> 4 4.6 3.1 1.5 0.2 setosa
> 5 5.0 3.6 1.4 0.2 setosa
> 6 5.4 3.9 1.7 0.4 setosa
>>
> 'data.frame': 150 obs. of 5 variables:
> $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
> $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
> $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
> $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
> $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1
> 1 1 1 1 1 1 ...
>> +
> user system elapsed
> 0.004 0.000 1.001
>>
>
> instead of the default
>
>>> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> 1 5.1 3.5 1.4 0.2 setosa
> 2 4.9 3.0 1.4 0.2 setosa
> 3 4.7 3.2 1.3 0.2 setosa
> 4 4.6 3.1 1.5 0.2 setosa
> 5 5.0 3.6 1.4 0.2 setosa
> 6 5.4 3.9 1.7 0.4 setosa
>> 'data.frame': 150 obs. of 5 variables:
> $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
> $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
> $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
> $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
> $ Species : Factor w/ 3 levels "setosa","versicolor",..:
>> user system elapsed
> 0.000 0.000 1.003
>
>
> Here is how to do it if you are not using ess-tracebug:
>
> (defun inferior-ess-output-filter (proc string)
> (let ((pbuf (process-buffer proc))
> (pmark (process-mark proc))
> (prompt-regexp "^>\\( [>+]\\)*\\( \\)$")
> (prompt-replace-regexp "^>\\( [>+]\\)*\\( \\)[^>+\n]"))
> (setq string (replace-regexp-in-string prompt-replace-regexp " \n"
> string nil nil 2))
> (with-current-buffer pbuf
> (goto-char pmark)
> (beginning-of-line)
> (when (looking-at prompt-regexp)
> (goto-char pmark)
> (insert "\n")
> (set-marker pmark (point)))
> ))
> (comint-output-filter proc (inferior-ess-strip-ctrl-g string)))
>
> This is R specific and might interfere with other languages.
>
> Cheers,
> Vitalie.
>
>
> On Wed, Oct 19, 2011 at 8:18 PM, Feng Li<m at feng.li> wrote:
>> Hi folks,
>>
>> Is it possible to cat a newline (\n) after each evaluation when
>> ess-eval-visibly-p is nil ? It does not look nice if I have the print or cat
>> function in my code. See this example of output with ESS 5.14,
>>
>>>> + + + + + + + + + + + + + + + + + + + +> > user system elapsed
>> 1.528 0.012 1.548
>>
>> I would like to have something like
>>
>>>> + + + + + + + + + + + + + + + + + + + +> >
>> user system elapsed
>> 1.528 0.012 1.548
>>
>> Thanks!
>>
>>
>>
>> Feng
>>
>> --
>> Feng Li
>> Department of Statistics
>> Stockholm University
>> 106 91 Stockholm, Sweden
>> http://feng.li/
>>
>> ______________________________________________
>> 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
>
--
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm, Sweden
http://feng.li/
More information about the ESS-help
mailing list