lesscode.org


editor

Routines for bringing up an external editor on a string or file.


Attributes

a EDITOR

None

Functions

f edit_file(filehandle) ...

Spawn an editor and return edited file content.

Expects a filehandle as returned by tempfile.NamedTemporaryFile(). Note that filehandle is not closed. The caller is responsible for managing the filehandle.

f edit_string(content) ...

Spawn an editor and return edited string content.

Take a string, dump it to a tempfile, spawn the editor, read the modified tempfile, and close the tempfile.

If the editor is interrupted, None is returned.

f get_editor() ...

Figure out which editing program to use.

  • This module's EDITOR attribute.
  • The EDITOR environment variable.
  • vi

See the source for more information.