some initial refactoring

was was once a dinky script that wrapped locate and evince is becoming more
full-featured, and so I started to divide it into functions to manage the
growing complexity

this will also make it easier to write a test suite
more refactoring to be amenable for testing