remedy icon indicating copy to clipboard operation
remedy copied to clipboard

Add 'function_wrap' wrap shortcut

Open whtns opened this issue 5 years ago • 4 comments

Add a function called 'function_wrap' that places parentheses around a given text selection and moves to cursor to a position immediately before the newly added parentheses

I often would like to wrap a text selection in a function call. One extremely common case is a call to View for a given R object from the console. This pull request makes this process smoother. I accomplish this with a slight modification to the enclose function (returning the selection)

whtns avatar Aug 23 '19 19:08 whtns

thank you for the pull request. please follow the contribution instructions and add all relevant files to the pull request.

yonicd avatar Aug 23 '19 20:08 yonicd

Thank you for the feedback; will update and resubmit

whtns avatar Aug 23 '19 23:08 whtns

From my perspective it would make sense to have something that allows that behaviour with other symbol like " — selecting the content, and returning before the first ".

Also, I wonder if we could pimp this with an

rstudioapi::showPrompt("Name", "What's the function name?")

So that the user is interactively asked for the function name, and it is pasted back in the document.

What do you folks think?

On another hand, it might be out of scope for {remedy} as the package is Rmd-focused 🤔

ColinFay avatar Sep 03 '19 12:09 ColinFay

Yes, maybe this is beyond the focus of rmarkdown. It seems useful to allow this function with multiple different symbols. Besides ( and ", maybe also { as applicable in shiny development.

I really wish I could do this in the console, but can't see how.

This sounds analogous to rstudio 'extract function' and 'extract variable' shortcuts.

Thanks for the consideration.

whtns avatar Sep 03 '19 18:09 whtns