On 26 Mar 2015, at 16:18 , Zvi Biener
I have a very superficial knowledge of perl, so I wonder if someone
Setup: before I compile my LaTeX document, I need to run a shell
script (using sed) to find/replace certain strings. [There is a long
story for why I need to do this, and why its not easily avoidable.]
Possible solution: I was wondering if I can insert something in the
latex_watch.pl script that would run this shell script, without
causing latex_watch to go into an infinite loop (since the shell
script changes the underlying LaTeX file/s).
I've tried inserting the relevant code in several locations, but I
can't seem to avoid the loop. That's not surprising, since I don't
really know perl. Does anyone know if there is easy way to
1) modify latex_watch.pl so it executes a shell script that modifies
the underlying LaTeX file without going in to a loop?
since the main loop of `latex_watch.pl` triggers the compilation after
file changes, I don't think there is an easy way to execute your
script in there, without causing an infinite loop.
2) cause the shell script to run on the file
whenever the file
changes by some other means?
That sounds like a good idea. You can use
`callback.document.will-save` for that. A command with this semantic
class will be called just before you save a file. E.g. To replace
every occurrence of the word `bla` with the word `blubb` in tex files,
create a command with the following content:
Use the following options:
Scope Selector: text.tex
Semantic Class: callback.document.will-save
Output: Replace Input
Caret Placement: Line Interpolation
I included a bundle with one command called “Replace Strings”
which does exactly that. You can extend this command by replacing `sed
s/bla/blubb/g` with the name of your shell script. Just make sure that
your shell script works with input from standard input (`STDIN`).
textmate mailing list