[ESS] Easy argument list: r-autoyas

Rainer M Krug r.m.krug at gmail.com
Mon Mar 14 16:51:34 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/14/2011 01:16 PM, Vitalie Spinu wrote:
> "Sven Hartenstein" <lists at svenhartenstein.de> writes:
> 
>> Hi Vitalie,
>>
>> thanks again for your ideas and contribution to r-autoyas!

Hi

this sounds perfect - but it seems to break org-modes functionality of
editing a code block with C- '. Or is it only my setup?

Rainer


> 
> Pleased to be useful :), don't have much time to think about improvements
> though, but will try to keep an eye on what you do over there.
> 
> As one minor comment it might be already useful to pack the code in a
> package.  For this you need to just place (provide 'r-autoyas) at the end of
> the autoyas.el file. The users will have to download the file and place
> (require 'r-autoyas) in .emacs. See
> http://www.gnu.org/s/emacs/manual/html_node/elisp/Named-Features.html
> for more details.
> 
> The 
> (add-hook 'ess-mode-hook
>           '(lambda ()
>              (load "~/.emacs.d/plugins/r-autoyas.el")))
> 
> is not a very standard way of doing it, the hook might be executed hundreds
> of times during the session, loading autoyas each time.
> 
> You also might consider just telling the users to paste the code in their
> .emacs, so they won't have to mess with additional files and loads at all.
> 
>>
>>> First, it would be probably more convenient if "(" key would
>>> directly invoke the yas/expand.
>>
>> Yes, good point. I have changed it now so that the parentheses are not
>> part of the snippet. r-autoyas-expand has argument paren (instead of
>> no-paren as you suggested) and if it is t parentheses will be
>> inserted.
>>
>> (Your version was very skeleton-pair friendly, but would delete the
>> closing parenthesis if skeleton-pair was not used.)
> 
> Yes, that was my way of doing it. In general the following might be more
> useful:
> 
> (define-key ess-mode-map (kbd "(") '(lambda () (interactive)
>                                       (insert "(")
>                                       (r-autoyas-expand nil t))))
> 
> But in this case the closed parenthesis is not automatically inserted.
> 
> I think the ideal case would be if r-autoyas-expand would check internally
> for "(" and ")" and insert them if needed. And may be
> r-autoyas-exit-snippet-delete-remaining to check for closing ")".
> 
> 
>>
>>> Second, it is nice to have C-g to delete all the remaining arguments
>>> (as you've already suggested on your site). The easiest way I could
>>> find is to advise yas/abort-snippet. Please see below.
>>
>> Absolutely great! Included in the update.
>>
>>> Third, it is inconvenient to maintain both .emacs and .Rprofile, one
>>> way of avoiding it is to "inject" the necessary commands each time
>>> R-session starts by means of ess-post-run-hook.
> 
> One addition here, on slow machines there might be some problems with the
> default code  what ess inserts after the  hook (.help.ESS for example). The
> following seems to work more reliably:
> 
> (defun r-autoyas-inject-commands ()
>   (ess-eval-linewise
>    "r.autoyas.esc <- function(str) {
>    ....
>    str <- paste('(',str,')', sep='')
>    str
>    }\n"
>    t nil nil t)
>   )
> 
> 
>>
>> Also perfect! I was actually wondering whether something like this was
>> possible and you answered the question before I even asked. Included
>> in the update.
>>
>> I gratefully mention your full name in the Changelog. How is this for
>> you? Would you prefer it any different?
> 
> No worries at all, it's open-source isn't it :)
> 
> And welcome to the lisp which is amassing and so beautiful language. I am sure
> this project will bring you a lot of joy and knowledge.
> 
> Vitalie.
> 
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer at krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1+OYYACgkQoYgNqgF2egqmGQCfcUi5dYBCZ3QOL85M8OB+3CIb
eGYAn3zYLolL+e2nfFrgpsfGLYShlWm7
=SnwJ
-----END PGP SIGNATURE-----



More information about the ESS-help mailing list