From 9bc47b83cb62d9e708aae07389bb352693ffb5ff Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 19 Jul 2017 10:22:13 +0200 Subject: [PATCH] Some minor polishment and comments. --- 3rdparty/evince_sync/README | 5 +++-- 3rdparty/evince_sync/evince_sync_lyx | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/3rdparty/evince_sync/README b/3rdparty/evince_sync/README index 84b3b4ff4e..7b78797242 100644 --- a/3rdparty/evince_sync/README +++ b/3rdparty/evince_sync/README @@ -37,8 +37,9 @@ of gedit-synctex-plugin by José Aliste (https://github.com/jaliste/gedit-syncte The work is based on a further derivation of this work for Sublime Text LaTeX Tools (https://github.com/SublimeText/LaTeXTools/tree/master/evince). -Adaptations for the use with LyX have been done by Jürgen Spitzmüller -in 2017. +Adaptations for the use with LyX and the tranformation of the original evince_sync bash +script to a python script (evince_sync_lyx) have been done by Jürgen Spitzmüller + in 2017. CONTACT diff --git a/3rdparty/evince_sync/evince_sync_lyx b/3rdparty/evince_sync/evince_sync_lyx index 83b8fefe89..7d45c8f307 100755 --- a/3rdparty/evince_sync/evince_sync_lyx +++ b/3rdparty/evince_sync/evince_sync_lyx @@ -20,35 +20,41 @@ # 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()