Skip to content
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

Paragraph command not respecting leading non-content formatting characters #63

Closed
uvtc opened this issue Aug 12, 2019 · 3 comments
Closed

Comments

@uvtc
Copy link
Contributor

uvtc commented Aug 12, 2019

Given this paragraph:

> foo bar
> aoeu aoeu
> baz moo

I'd expect [p to give me:

> foo bar aoeu aoeu baz moo

but instead it gives me:

> foo bar > aoeu aoeu > baz moo

I see the same problem with //, *, #, and so on. Works fine if the leading / left-hand-side characters are only spaces.

This is with ne v3.1.2 running on a fully updated Debian "Testing".

The docs for paragraph indicate ne should support this smart Paragraph behaviour, and I thought it got this feature years ago.

I think it's an extremely useful and necessary feature. I write lots of code comments (prefixed with // or # ) and markdown blockquoted paragraphs (prefixed with > ) --- it would be painful if ne couldn't Paragraph them while preserving the left-hand-side prefixins.

Actually, I'd expect that for any series of lines, ne should be able to identify if every line starts with the same prefix (whatever it may be --- different programming languages may use different commenting/quoting/whatever styles), and preserve that pattern when Paragraphing it. For example, I'd expect ne to be able to correctly Paragraph:

// XXX This comment is all kinds of important. I'm not kidding. Please keep reading!
// XXX Make a note of it in your records.
// XXX And
// XXX also watch for detritus.

I'm not sure why ne would be limited to special-cases like // and > .

@utoddl
Copy link
Collaborator

utoddl commented Aug 12, 2019

Hmm. This is in the category of "historical accident". There was a brief time when the Paragraph command tried to do what you indicated above, and it usually worked out alright. But there were lots of corner cases -- paragraphs that had nothing to do with programming or that contained comment-like characters that weren't comments at all -- which prompted us to revert back to a "dumber but consistent" behavior. Looks like the docs didn't make the transition.

I would like to have a comment-aware paragraphing option, but not at the expense of breaking normal text. Ne is supposed to be a Nice Editor, where unexpectedly mangling your text is decidedly Not Nice. I hope to revisit this issue some day.

@uvtc
Copy link
Contributor Author

uvtc commented Aug 12, 2019

Thanks, Todd. Glad to hear it may be revisited in the future. Super useful feature, IMO, even if it were strictly limited to a subset of prefixes (like "> ", "// ", "# ") or to even just one prefix ("> ") to start with.

Maybe it would be possible for the user to set a default pref that says, "consider only the following strings as formatting prefixes when reflowing text with Paragraph: ...", if that simplifies and tightens things up.

Also, not sure if this is a corner case you were thinking about trying to solve, but I see that in code, lines of code usually directly follow comment lines (with no empty line between them). I could see how making Paragraph smart enough to handle that corner case would be complicated, and I would not expect Paragraph to try and figure that out. Paragraph works on paragraphs (delineated by blank lines). That is, I'd be happy to and expect to change:

// Comment line 1.
// Comment line 2.
function code(goes here) {...}

to

// Comment line 1.
// Comment line 2.

function code(goes here) {...}

before hitting [p on that comment block to Paragraph it, and then go back and remove the extra newline.

@uvtc
Copy link
Contributor Author

uvtc commented Aug 12, 2019

It occurs to me that I could also use the ne Through command, and have a small shell script do this. I'll give that a try.

@vigna vigna closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants