Skip to content

Commit 9300eaa

Browse files
committed
update README
1 parent 5a32ae6 commit 9300eaa

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,33 @@ Examples
66

77
```python
88
import editor
9-
commit_msg = editor.edit(contents="# Enter commit message here")
9+
commit_msg = editor.edit(contents=b"# Enter commit message here")
1010
```
11+
1112
Opens an editor, prefilled with the contents, `# Enter commit message here`.
12-
When the editor is closed, returns the contents in variable `commit_msg`.
13+
When the editor is closed, returns the contents (bytes) in variable `commit_msg`.
14+
Note that the argument to `contents` needs to be a bytes object on Python 3.
1315

1416

1517
```python
16-
import editor
1718
editor.edit(file="README.txt")
1819
```
19-
Opens README.txt in an editor. Changes are saved in place.
20+
21+
Opens README.txt in an editor. Changes are saved in place. If there is
22+
a `contents` argument then the file contents will be overwritten.
23+
24+
```python
25+
editor.edit(..., use_tty=True)
26+
```
27+
28+
Opens the editor in a TTY. This is usually done in programs which output is
29+
piped to other programs. In this case the TTY is used as the editor's stdout,
30+
allowing interactive usage.
2031

2132

2233
How it Works
2334
------------
35+
2436
`editor` first looks for the ${EDITOR} environment variable. If set, it uses
2537
the value as-is, without fallbacks.
2638

@@ -33,5 +45,5 @@ For example, on Linux, `editor` will look for the following editors in order:
3345
* emacs
3446
* nano
3547

36-
When calling the `edit()` function, `editor` will open the editor in a subprocess,
37-
inheriting the parent process's stdin, stdout
48+
When calling `editor.edit`, an editor will be opened in a subprocess, inheriting
49+
the parent process's stdin, stdout.

0 commit comments

Comments
 (0)