Some minor polishment and comments.

This commit is contained in:
Juergen Spitzmueller 2017-07-19 10:22:13 +02:00
parent e79782c4cc
commit 9bc47b83cb
2 changed files with 17 additions and 10 deletions

View File

@ -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 <spitz@lyx.org>
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
<spitz@lyx.org> in 2017.
CONTACT

View File

@ -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()