[OS X TeX] Applescript and chktex
Ramon M. Figueroa-Centeno
ramonf at hawaii.edu
Sat Apr 17 10:33:18 EDT 2004
A week ago I asked:
> Does anybody know how to compile the LaTeX semantics checker chktex
> <http://www.nongnu.org/chktex/> on OS X? I have tried the included
> instructions and cannot get it to work.
Frank Stengel replied:
> I gave it a try and had to manually edit the makefile and change line
> 42 from
> DEFS=-DHAVE_CONFIG_H -D__unix__
> and it compiled...
I tried it and it works. Thanks! I have run several of my currents projects
through and found a lot of little mistakes (some that I have been making for
years :) ). Some errors are subjective.
So I decide to write a small applescript that would call chktex (which in my
case resides in "~/bin") and open the result (saved in a file with extension
.err) in SubEthaEdit.
Now, what would be great would be some sort of GUI or at least a way of
getting the output to link with ITeXMac or TeXShop so one could click on the
"error" line number and go to that line in the document.
Anyway, here is the script. Any suggestion to improve it are welcome.
--set editor to the name of the program you want to use to display the
property editor : "SubEthaEdit"
--set chktex to your path to chktex
property chktex : "~/bin/chktex"
set filecount to 0
on open filelist
repeat with myfile in filelist
set filecount to 1
if filecount < 1 then
set myfile to choose file with prompt "Choose a file, please:"
if (myfile as string) ends with ".tex" then
set filename to do shell script "perl -e \"print quotemeta ('" &
POSIX path of myfile & "');\""
set basename to do shell script "basename " & filename & " .tex"
set dirname to do shell script "dirname " & filename
do shell script "cd " & dirname & "; " & chktex & " " & basename &
".tex" & "> " & basename & ".err 2>&1 & open -a " & editor & " " &
basename & ".err"
Ramón M. Figueroa-Centeno, Ph.D.
University of Hawaii at Hilo
College Hall 4-A
200 W. Kawili St.
Hilo, HI 96720-4091
(808) 974-7387 (office)
(808) 933-3473 (fax)
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.
More information about the MacOSX-TeX