Skip to content

Single-line pipes? #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
krlmlr opened this issue Jul 14, 2017 · 10 comments
Closed

Single-line pipes? #74

krlmlr opened this issue Jul 14, 2017 · 10 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Jul 14, 2017

tidyverse/style#28

@lorenzwalthert
Copy link
Collaborator

Reference (#118).

@krlmlr
Copy link
Member Author

krlmlr commented Sep 16, 2017

styler::style_text("a %>% b()")
#> a %>%
#>   b()

The style guide PR has been merged now.

@lorenzwalthert
Copy link
Collaborator

So does that mean we do not add line breaks after pipes at all anymore?

@krlmlr
Copy link
Member Author

krlmlr commented Sep 16, 2017

Not if they fit on a single line. Looking into it right now.

@krlmlr krlmlr closed this as completed in 9e847af Sep 16, 2017
@krlmlr
Copy link
Member Author

krlmlr commented Sep 16, 2017

Closed in 9e847af.

krlmlr added a commit that referenced this issue Oct 23, 2017
- Hotfix: utf8 should not be verbose (#245).
- Allow styling of Rmd files(#233).
- Remove duplicate @family (#244).
- Fixing token insertion (#242).
- Capitalize Addin titles (#241).
- Explicit `NULL` creation to make styler compatible with R3.2.0 (#237).
- Improve vignettes (#232).
- Allow exclusion of files with `style_pkg()` and `style_dir()`.
- Correct styling with long strings (#230).
- Add tools for re-indenting tokens (#217).
- Math token spacing (#221).
- Remove outdated line and col information (#218).
- Empty input for styling does not cause an error (#227, #228).
- Tools to insert tokens + application on `if`-`else` clauses (#212).
- Improve example in documentation (#222).
- Fix spacing around in (#214).
- Maintenance: renaming functions / files, extend helper, documentation, if_else etc. (#204).
- Disallow line break after ( for function calls (#210).
- Preserve space between `!` and bang (#209).
- Simplify RStudio Addin (#208, #211).
- Indention based on square brackets (#207).
- Add vignette on introducing styler (#203).
- Indent function declaration without curly braces correctly (#202).
- Fix indention in if-else statement (#200).
- Sorting key (#196).
- Use safe sequences (#197).
- Fix space between two commas (#195).
- Keep single-line pipes on one line (#74).
- Remove tidyr and dplyr dependency (#182, #183, @jimhester).
- Fix parsing inconsistency (#188).
- Substitute create filler (#190).
- Introducing class vertical (#189).
- Adapt line break rules (#172).
- Fix `R CMD check` (#185).
- Force argument evaluation for proper error handling (#179).
- Add nonstrict version of set_space_before_comment (#174).
- Add installation instructions to README (#175).
- Addin to style highlighted region (#143).
- Improve spelling (#168).
- Add coverage badge
- Change badge from WIP to active
- Add the number of files to message (#166).
- Improve documentation (#164).
- Add informative messages while styling files (#165).
- More examples in help file (#161).
- No line breaks after pipe if comment is next token (#160).
- Fixing spacing around `!` (non-bang-bang) (#157).
- Finalize function documentation (#154).
- Review vignette (#158).
- Update bang-bang rule (#156).
@harrismcgehee
Copy link

How is "if they fit on a single line" defined? Is there a way to turn off single line pipes?

@lorenzwalthert lorenzwalthert reopened this Feb 9, 2018
@lorenzwalthert
Copy link
Collaborator

If I am not mistaken there is currently no option to force a line break after %>%. @krlmlr maybe we should force it for strict = TRUE? Or is that option already overloaded? We could add another option to give granular control.
Related #65.

@krlmlr
Copy link
Member Author

krlmlr commented Feb 10, 2018

They fit on a single line if they don't contain a line break. We currently don't care about line length, but when we have this, we should also break overly long pipes. Not sure if we should turn this on with strict = TRUE or define a new option.

@krlmlr
Copy link
Member Author

krlmlr commented Feb 10, 2018

For a one-time transformation, you could do sed -r -i 's/([>]%[>])/\1\n /g' R/* and then apply styler (the -i option must be -ibak on OS X).

@lorenzwalthert
Copy link
Collaborator

Let's revisit that once we have implemented #247.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants