'emacs ess-indent-or-complete sends newline to R process

Occasionally, for reasons I can not determine, ess-indent-or-complete sends an input to the R console. In other words, I will be typing something, hit tab to autocomplete (or company autocompletes for me), and the R process will update with a newline (.R file on the left "buffer", R process on the right):

x <- mea█                        | >
                                 |
                                 |

... and then I hit tab to complete "mean":

x <- mean█                       | >
                                 | > ## note the new line here
                                 |

This can be really annoying for at least two reasons:

  1. It fills up the process buffer with blank lines.
  2. If I am using a browser(), it advances lines which is often undesirable.

I have tried to diagnose this myself to no avail. Restarting emacs fixes it every time, however it seems to start happening at random throughout the day. Once it starts it does not stop until emacs restarts.

I am running emacs 27.1, ess-20210818.843 (though this has been a thing for a long time, so I don't believe it is version-specific), and am in ESS[R] mode.

Calling M-: (ess-command "") from my .R file buffer replicates the undesired behavior once it starts happening in a particular session. I have no insight beyond this.



Solution 1:[1]

I think you solved it yourself, with your GH issue suggestion: https://github.com/emacs-ess/ESS/issues/1198

I've changed things in my own version of ESS, and will commit after a few days of testing it.

Thank you VERY VERY much for persevering and (I think) finding the fault .. a simple typo inside the internal (ess--command-make-restore-function)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Mächler