-
Notifications
You must be signed in to change notification settings - Fork 160
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
Introduce SetGlobalLineWrappingStatus #4511
base: master
Are you sure you want to change the base?
Conversation
Let's see what other people have to say before you make further changes, but I wonder if this should be a per-stream option (like the existing PrintFormattingStatus), rather than a global setting. Personally, I'm happy for it to be a global setting, but it is a bit weird that PrintFormattingStatus (which also effects this) is file-specific. |
Yes, that's why I didn't invest time into adding documentation and tests yet :D
I thought about this, but then I think we would have the same problems as in #4496 again, that is, how we could synchronize the different stdouts. And with the global setting one can still emulate a per-stream option by changing the global setting before writing to a stream and resetting it afterwards (for remembering the original state we would of course also need a getter |
For me this would be a last resort: For years I've been working hard on eliminating global state in the GAP kernel, so I am reluctant to add more of it. One reason for avoiding global state is that it can have weird and unexpected effects... like using it can break Thus I'd indeed greatly prefer if "line wrapping" and "indentation" could be toggled for each stream separately. But if we decide to merge this PR anyway (e.g. because it provides a quick solution, now) then at the very least we should also add a way to query the status of this flag so that it can be saved and restored if necessary |
@fingolfin I see. I am carrying around some downstream patches anyway, so I am happy with simply keeping this patch for my local build for now, hoping for a official solution in the future. Should I close this PR or keep it open for future discussion? |
Please leave it open |
Here is what I suggest we do:
This leaves the question how to set the two new settings independently. Now there is quite some code which saves the current formatting status, sets it to some new value, then restores. To keep this code working, we could do this:
So turn off just line wrapping for stdout, you could do Of course we could still add additional functions like |
Sounds good, I would only propose one change regarding point 4.: I think it would be nicer if |
Description
This is a prototype of my suggestion in #4496.
My setting is: I never want line wrapping (because I prefer to let my terminal wrap lines and do not want "random" backslashes when printing to strings/files) and I always want indentation, regardless of the print target (stdout, file, string). This PR introduces a function
SetGlobalLineWrappingStatus
which disables (or re-enables) line wrapping completely (I hope).If you like the idea, I would add some documentation and tests and fill in the text for release notes below.
Text for release notes
TODO
If this pull request shall not be mentioned in the release notes
(to be distributed in the file
CHANGES.md
),please add the label
release notes: not needed
.Otherwise, please proceed in one of the following ways:
Choose a title that can serve as text for the release notes,
and add the label
release notes: use title
.Put the text for the release notes here,
that is, between the markers
Text for release notes
and
(End of text for release notes)
.The first variant is recommended whenever the text for release notes
is suitable as title.
In both cases, please follow the style of the GAP
CHANGES.md
filein the root directory.
In particular, please surround the names of GAP functions with backquotes.
(End of text for release notes)
Further details
If necessary, please provide further details here.
Checklist for pull request reviewers
If your code contains kernel C code, run
clang-format
on it; thesimplest way is to use
git clang-format
, e.g. like this (don'tforget to commit the resulting changes):
usage of relevant labels
release notes: not needed
orrelease notes: to be added
bug
orenhancement
ornew feature
stable-4.X
add thebackport-to-4.X
labelbuild system
,documentation
,kernel
,library
,tests
runnable tests
lines changed in commits are sufficiently covered by the tests
adequate pull request title
well formulated text for release notes
relevant documentation updates
sensible comments in the code