]> git.lyx.org Git - lyx.git/blobdiff - 3rdparty/evince_sync/evince_sync_lyx
Revise dash documentation in the UserGuide (en and de).
[lyx.git] / 3rdparty / evince_sync / evince_sync_lyx
index 83b8fefe89227a2afbdb71b15ef2ea7c75ea3b20..7d45c8f3070410ed5db406e87275b954f6963710 100755 (executable)
 # Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import sys, os.path
-from subprocess import Popen, call
+from subprocess import Popen
 
+# The lyxclient command for backward search
 editor_cmd = "lyxclient -g %f %l"
 
-def print_usage():
+# Check we have (only) one argument
+if len(sys.argv) != 2:
     print("Usage: evince_sync_lyx pdf_file")
     sys.exit(1)
 
-if len(sys.argv) != 2:
-    print_usage()
-
+# Arg 1 is supposed to be the PDF file
 pdf_file = os.path.abspath(sys.argv[1])
 
+# Check whether the file exists & is readable
 if not os.path.isfile(pdf_file):
-    print_usage()
+    print("%s is not valid/readable PDF file." % pdf_file)
+    sys.exit(1)
 
+# The accompanying synctex file has the same name than the PDF
+# but with .synctex.gz extension
 synctex_file, ext = os.path.splitext(pdf_file)
-
 synctex_file += ".synctex.gz"
 
+# If we have a synctex file, start the evince_backward_search script
 SyncTeX = False
-
 if os.path.isfile(synctex_file):
     bsproc = Popen(["evince_backward_search", pdf_file, editor_cmd])
     SyncTeX = True
 
+# Notwithstanding the previous, start evince and open the PDF
 vproc = Popen(['evince', pdf_file])
 vproc.wait()
 
+# If evince has been closed (hence vproc.wait()), we terminate
+# the evince_backward_search script (if we have started it)
 if SyncTeX:
     bsproc.terminate()