[R] Smart detection of wrap width?

Ista Zahn istazahn at gmail.com
Sun Apr 19 03:41:08 CEST 2015


I see now that the link I gave for configuring this is ESS doesn't
give the whole enchilada. Here is what I currently have in my emacs
config:

  (defun my-ess-execute-screen-options (foo)
                (ess-execute-screen-options))
  (add-hook 'inferior-ess-mode-hook
            (lambda()
              (setq-local
               window-size-change-functions
               '(my-ess-execute-screen-options))))

This should give the desired functionality.

Best,
Ista

On Sat, Apr 18, 2015 at 1:26 PM, Ista Zahn <istazahn at gmail.com> wrote:
> For ESS see https://github.com/gaborcsardi/dot-emacs/blob/master/.emacs
>
> Best,
> Ista
>
> On Apr 17, 2015 7:37 PM, "Paul Domaskis" <paul.domaskis at gmail.com> wrote:
>>
>> Yes, I found the width option in the help pages, but I was wondering
>> if there was automatic setting of the wrapping according to the
>> current window width.
>>
>> Your function works exactly as I wished.  I'll probably get smarter
>> with time (I hope) but would it be reasonably good practice to stick
>> this into ~/.Rprofile?  I don't suppose there is a way to have it
>> automatically invoked when the window size/positition changes?  (It's
>> still priceless even without automatic triggering).
>>
>> On Fri, Apr 17, 2015 at 7:20 PM, MacQueen, Don <macqueen1 at llnl.gov>
>> wrote:
>> > A lot of this depends on what context you are running R in, e.g.,
>> > Windows console, Mac console, or command line in a unix-alike. Or
>> > within ESS in emacs. Those are different interfaces supported by, to
>> > some extent, different people, and are based on the underlying
>> > capabilities provided by the operating system.
>> >
>> > Have you yet encountered
>> >   options()$width
>> > ?
>> > For example,
>> >   options(width=100)
>> > will cause wrapping at 100, at least for certain kinds of output.
>> >
>> > In an xterm shell running in an X windows context, I frequently use
>> >
>> > setwid <- function ()
>> > {
>> >     if (!interactive())
>> >         return(invisible(NULL))
>> >     scon <- pipe("stty -a")
>> >     stty <- scan(scon, what = "", sep = ";", quiet = T)
>> >     close(scon)
>> >     cstr <- stty[grep("columns", stty)]
>> >     options(width = as.numeric(gsub("[^0-9]", "", cstr, ignore.case = T)))
>> >     paste("width =", options()$width, "\n")
>> > }
>> >
>> > A function I wrote that resets the width option to match the window
>> > widths, and therefore adjusts the wrapping after I resize a windwo.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list