RETIRED, further work has moved to Debian project infrastructure
Go to file
Peter Ruibal 39c587d815 Improved nano support
Use "-R" (restricted) mode.
2015-01-10 22:56:13 -08:00
.gitignore Add vim artifacts to gitignore 2015-01-10 13:36:10 -08:00
LICENSE Initial commit 2015-01-10 13:35:34 -08:00
README.md Tweak, typo fix 2015-01-10 20:29:47 -08:00
editor.py Improved nano support 2015-01-10 22:56:13 -08:00
setup.py Add python 3.4 to trove classifiers 2015-01-10 13:47:40 -08:00

README.md

python-editor is a library that provides the editor module for programmatically interfacing with your system's $EDITOR.

Examples

import editor
commit_msg = editor.edit(contents="# 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.

import editor
editor.edit(file="README.txt")

Opens README.txt in an editor. Changes are saved in place.

How it Works

editor first looks for the ${EDITOR} environment variable. If set, it uses the value as-is, without fallbacks.

If no $EDITOR is set, editor will search through a list of known editors, and use the first one that exists on the system.

For example, on Linux, editor will look for the following editors in order:

  • vim
  • emacs
  • nano

When calling the edit() function, editor will open the editor in a subprocess, inheriting the parent process's stdin, stdout