update README

This commit is contained in:
Eeo Jun
2016-11-09 21:14:32 +08:00
parent 5a32ae6180
commit 9300eaa693

View File

@@ -6,21 +6,33 @@ Examples
```python
import editor
commit_msg = editor.edit(contents="# Enter commit message here")
commit_msg = editor.edit(contents=b"# Enter commit message here")
```
Opens an editor, prefilled with the contents, `# Enter commit message here`.
When the editor is closed, returns the contents in variable `commit_msg`.
When the editor is closed, returns the contents (bytes) in variable `commit_msg`.
Note that the argument to `contents` needs to be a bytes object on Python 3.
```python
import editor
editor.edit(file="README.txt")
```
Opens README.txt in an editor. Changes are saved in place.
Opens README.txt in an editor. Changes are saved in place. If there is
a `contents` argument then the file contents will be overwritten.
```python
editor.edit(..., use_tty=True)
```
Opens the editor in a TTY. This is usually done in programs which output is
piped to other programs. In this case the TTY is used as the editor's stdout,
allowing interactive usage.
How it Works
------------
`editor` first looks for the ${EDITOR} environment variable. If set, it uses
the value as-is, without fallbacks.
@@ -33,5 +45,5 @@ For example, on Linux, `editor` will look for the following editors in order:
* emacs
* nano
When calling the `edit()` function, `editor` will open the editor in a subprocess,
inheriting the parent process's stdin, stdout
When calling `editor.edit`, an editor will be opened in a subprocess, inheriting
the parent process's stdin, stdout.