-
Notifications
You must be signed in to change notification settings - Fork 53
Use /dev/tty by default #8
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
Conversation
This is because vim (and other terminal editors) typically output to stdout. This is not very nice behaviour especially if the program using the editor is piped to some other program. Hence, using tty is saner.
Some initial feedback:
|
Also, style wise, I prefer assignment and a light branch to ternary operators and most extra logic to be split into helper functions. Also prefer explicit kwargs to **extra. E.g., explicitly pass stdout=... and initialize to sys.stdout I guess? |
Tested on MacVim ('mvim') and Sublime Text as they are the only GUI editors I have on OSX, it doesn't work for both cases. The string gets returned immediately. On
We can check if Update: Update: Even git seems to have trouble with GUI |
|
||
cont = editor.edit(contents='ABC!', | ||
use_tty='use_tty' in sys.argv) | ||
sys.stdout.write(cont) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the blank newline at the end of file
I think it does, via the special file "CON:". I'll have to test when I'm on windows later today. The default should be
Add a helper function to get the tty filename:
Which is exactly why the current |
👍 Check out the new commits |
Pushed to pypi as 1.0 |
This is because vim (and other terminal editors) typically output to stdout. This is not very nice behaviour especially if the program using the editor is piped to some other program. Hence, using tty is saner. Example:
$ python test.py > t.xt Vim: Warning: Output is not to a terminal