[OS X TeX] Applescript and chktex

Ramon M. Figueroa-Centeno ramonf at hawaii.edu
Sat Apr 17 16:33:18 CEST 2004


Hi,

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
> 
> to
> 
> 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
results
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
        try
            set filecount to 1
            check(myfile)
        on error
            beep
        end try
    end repeat
end open

if filecount < 1 then
    set myfile to choose file with prompt "Choose a file, please:"
    check(myfile)
end if

on check(myfile)
    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"
    end if
end check


Ramon

-- 

Ramón M. Figueroa-Centeno, Ph.D.
Assistant Professor

Mathematics Department
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)

http://www2.hawaii.edu/~ramonf/


-----------------------------------------------------
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the macostex-archives mailing list