setwidth no longer on CRAN

274 views
Skip to first unread message

Jakson Alves de Aquino

unread,
Feb 14, 2017, 7:19:47 AM2/14/17
to Vim-R-plugin
Dear all,

People running R in a terminal emulator (on Linux, Mac OS X and other Unix systems) noted that setwidth is no longer on CRAN.

I asked for the removal of the package from CRAN because there was a change in R code and setwidth stopped working. R now catches the SIGWINCH signal that is sent to applications when the terminal is resized. So, the signal no longer reaches setwidth. R does call the readline funtion rl_resize_terminal(), that is, it adjusts the input to the current number of columns, but it does not call options(width = number_of_columns) as setwidth did.

Perhaps this feature could be implemented directly in R if someone requested it to the R Core Team.

The workaround is to run R in a Neovim buffer (built-in terminal emulator) because Nvim-R constantly checks the terminal size and sends the command options(width=number_of_columns) to nvimcom whenever necessary.

-- 
Jakson Aquino

daan...@gmail.com

unread,
Feb 15, 2017, 7:03:28 AM2/15/17
to Vim-R-plugin
Thank you for describing this issue. Indeed, setwidth no longer automatically adjusts the number of columns of R output to the width of my terminal.


I added a function to my .Rprofile to more easily adjust the width manually:

setwidth_fun <- function(howWide=Sys.getenv("COLUMNS"))
options(width=as.integer(howWide))
makeActiveBinding("sw", setwidth_fun, baseenv())

as suggested here: http://stackoverflow.com/a/1173161.

joss....@gmail.com

unread,
Dec 6, 2018, 9:23:09 AM12/6/18
to Nvim-R
I know that this is a very old thread, but I came across this whilst looking how to handle this.

As a result of the discussion here: http://r.789695.n4.nabble.com/patch-automatically-adjust-width-option-when-terminal-is-resized-td4745068.html it seems that you can now set "options(setWidthOnResize = TRUE)" and R will behave as expected (on modern installs).

Reply all
Reply to author
Forward
0 new messages