From: Akira Yokosawa <akiyks@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: perfbook@vger.kernel.org, Balbir Singh <bsingharora@gmail.com>
Subject: [PATCH v3 2/6] Add synctex-forward.sh
Date: Tue, 22 Oct 2019 20:19:39 +0900 [thread overview]
Message-ID: <663968ba-bc03-cb5a-da27-499135cc0533@gmail.com> (raw)
In-Reply-To: <eda1f6d1-50ef-8447-1eab-5db776eb3981@gmail.com>
From 967beab61d94f966c06f245b9c22e1e702d6c785 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sun, 20 Oct 2019 00:51:00 +0900
Subject: [PATCH v3 2/6] Add synctex-forward.sh
This script sets up "% mainfile:" tags in sub .tex files with
a suitable "perfbook-xx.tex" file name.
They enable SyncTeX forward search to perfbook-xx.pdf.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
utilities/synctex-forward.sh | 89 ++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
create mode 100755 utilities/synctex-forward.sh
diff --git a/utilities/synctex-forward.sh b/utilities/synctex-forward.sh
new file mode 100755
index 00000000..312f9cc3
--- /dev/null
+++ b/utilities/synctex-forward.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Set "% mainfile:" lines with proper "% mainfile: <...>" tags in
+# sub .tex files.
+#
+# With no argument, the main file will be "perfbook.tex",
+# which will do nothing by default.
+# With abbrev target such as "1c", "hb", and so on, the main file
+# will be "perfbook-1c.tex", perfbook-hb.tex", and so on.
+#
+# Depth of subdirectory is deduced from the path of each sub .tex file.
+#
+# Changes made by this script can be reverted by running without
+# argument.
+#
+# WARNING: By runnig this script, your working tree will be modified.
+# It is highly recommented to commit your changes before running
+# this script.
+
+# If LATEX_OPT does not have "synctex", do nothing
+if ! echo $LATEX_OPT | grep -q synctex ; then
+ echo "LATEX_OPT has no synctex option. Exiting..."
+ exit 1
+fi
+
+# warn if git status is not clean later
+gitstatus=`git status --porcelain | wc -l`
+if [ $gitstatus != "0" ] ; then
+ wasnotclean=1
+else
+ wasnotclean=0
+fi
+
+if [ $# -eq 0 ] ; then
+ main="perfbook.tex"
+ change="reverted"
+else
+ case $1 in
+ 2c)
+ main="perfbook.tex"
+ change="reverted"
+ ;;
+ 1c|hb|tcb|msnt|mstx|msr|msn|1csf|msns|mss)
+ main="perfbook-$1.tex"
+ change="modified"
+ ;;
+ *)
+ echo "Unknown target!!"
+ exit 1
+ ;;
+ esac
+fi
+
+tmpf=`mktemp`
+texfiles=`find . -name '*.tex' -print`
+modified=0
+for i in $texfiles
+do
+ c=$(expr `echo $i | grep -o "/" | wc -l` - 1)
+ x=
+ for j in $(seq 1 $c)
+ do
+ x=..\\/$x
+ done
+ mainpath=$x$main
+ pattern="s/% mainfile: .*perfbook.*\.tex/% mainfile: $mainpath/"
+ cat $i | sed -e "$pattern" > $tmpf
+ if ! diff -q $i $tmpf >/dev/null ; then
+ echo "$i $change."
+ cp -f $tmpf $i
+ modified=1
+ fi
+done
+
+if [ $modified -eq 0 ] ; then
+ echo "No modification."
+else
+ if [ $main != "perfbook.tex" -a $wasnotclean -eq 1 ] ; then
+ echo "### Git status was not clean."
+ echo "### To revert the changes, just run '$0'."
+ fi
+fi
+
+# check if synctex database exists
+mainbase="${main%.tex}"
+if [ `ls -1 perfbook* | grep -c $mainbase.synctex` -eq 0 ] ; then
+ echo "### $mainbase.synctex*: file not found."
+fi
--
2.17.1
next prev parent reply other threads:[~2019-10-22 11:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fac2cbbb-492c-acde-14a8-15ee04b95ea9@gmail.com>
[not found] ` <2d2eb3d6-d050-6f0c-aca5-b0cc76e8e0ec@gmail.com>
2019-10-19 11:43 ` [PATCH v2] Always generate perfbook.synctex.gz Akira Yokosawa
2019-10-19 15:35 ` Paul E. McKenney
2019-10-22 11:15 ` [PATCH v3 0/6] Enable SyncTeX forward (.tex -> .pdf) search Akira Yokosawa
2019-10-22 11:17 ` [PATCH v3 1/6] treewide: Add '% mainfile:' tags in headers in sub .tex files Akira Yokosawa
2019-10-22 11:19 ` Akira Yokosawa [this message]
2019-10-22 11:21 ` [PATCH v3 3/6] Add output of '% mainfile: perfbook.tex' tags in extraction scripts Akira Yokosawa
2019-10-22 11:22 ` [PATCH v3 4/6] FAQ-BUILD: Mention how to enable SyncTeX support Akira Yokosawa
2019-10-22 11:23 ` [PATCH v3 5/6] defer/rcuintro: Convert snippet to new scheme Akira Yokosawa
2019-10-22 11:24 ` [PATCH v3 6/6] defer/rcuapi: Tweak horizontal spacing of wide tables in 1c layout Akira Yokosawa
2019-10-22 12:05 ` [PATCH v3 0/6] Enable SyncTeX forward (.tex -> .pdf) search Paul E. McKenney
2019-10-22 14:34 ` [PATCH v4 5/6] defer/rcuintro: Convert snippet to new scheme Akira Yokosawa
2019-10-22 15:51 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=663968ba-bc03-cb5a-da27-499135cc0533@gmail.com \
--to=akiyks@gmail.com \
--cc=bsingharora@gmail.com \
--cc=paulmck@kernel.org \
--cc=perfbook@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.