[ESS] Adjust R option width to current frame width
Friedrich.Leisch at tuwien.ac.at
Friedrich.Leisch at tuwien.ac.at
Fri Jan 20 17:17:06 CET 2006
>>>>> On Fri, 20 Jan 2006 16:57:38 +0100,
>>>>> Martin Maechler (MM) wrote:
FrL> Martin Mächler asked me to post the following lisp snippet to the list:
>>> (defun fl-ess-adjust-width ()
>>> (interactive)
>>> (ess-execute
>>> (concat "options(width="
>>> (number-to-string (frame-width))
>>> ")") 'buffer))
> note that ESS already has (almost) this functionality,
> though in ess-inf.el and with a more generic name.
> (defun ess-execute-screen-options ()
> "Cause S to set the \"width\" option to 1 less than the frame width.
> Also sets the \"length\" option to 99999.
> This is a good thing to put in `ess-post-run-hook' --- for the S dialects."
> (interactive)
> (if (string= ess-language "S")
> (ess-eval-linewise (format "options(width=%d,length=99999)"
> (1- (frame-width))))))
Well, I looked a little bit before I wrote it, but obviously didn't
find it, and reinventing the wheel here was not exactly rocket science
;-)
> it does use frame-width -1' though.
probably a better choice
>>> (add-hook 'inferior-ess-mode-hook
>>> (lambda ()
>>> (define-key inferior-ess-mode-map "\C-cw"
>>> 'fl-ess-adjust-width)))
FrL> which sets R option width to the current frame width when pressing C-cw
FrL> ... I personally don't want that the width changes automatically as in
FrL> the windows console, hence I never bothered to look whether that is
FrL> possible.
> Now that's a good idea and I propose to add the following to the
> (defun ess-add-MM-keys )
> which already was use to set such useful "C-c <letter>" settings
> which would lead to
> (defun ess-add-MM-keys ()
> "Define MM's user keys, currently only \\<ess-mode-map>\\[ess-insert-function-outline]."
> (interactive)
> (require 'ess-mode)
> (define-key ess-mode-map "\C-cf" 'ess-insert-function-outline)
> (require 'ess-inf)
> (define-key inferior-ess-mode-map "\C-cw" 'ess-execute-screen-options)
> )
Umm, the emacs manual says
As a user, you can redefine any key; but it is usually best to
stick to key sequences that consist of `C-c' followed by a letter.
These keys are "reserved for users," so they won't conflict with
any properly designed Emacs extension.
so ESS should use a different binding (same for your "\C-cf").
.f
More information about the ESS-help
mailing list