[texworks] Scripts: Hooks

Stefan Löffler st.loeffler at gmail.com
Mon Nov 1 16:53:51 CET 2010


Hi,

> Searched Wiki  but could find little on hooks yet.

Yeah, there's not much in it. As mentioned a few times before, a
scripting manual is in the making (planning), that should cover this
(and other stuff) in more detail.


Am 2010-10-31 11:11, schrieb Paul A Norman:
> Should add that searching through    TeXDocument.cpp    I have found
> these and they all work.
>
> newFile
> newFromTemplate
> loadFile
> AfterTypeset

I think the names should be capitalized (e.g., "LoadFile"). I don't
remember off-hand if this is necessary, though. Note that "LoadFile"
only works for .tex files ATM.
AFAIK, these are all currently implemented hooks.

> Is there one for ApplicationStart at all please?

No, though this might make a good addition. You could add this (and
others you're missing) to the issue list on GC so we don't forget.

> Header for script file should have this in its preamble? (replace
> LoadFile as appropriate):
>
> // Script-Type: hook
> // Hook: LoadFile
>
> Are there any other requirements / or options for the Script
> header/preamble please?

Nope, no options, no requirements.

> Is there any way of setting more than one hook for a  script like...
>
> // Script-Type: hook
> // Hook: newFile, newFromTemplate
>
> As newFile and newFromTemplate will often be appropriate i.e one or
> the other may require the same script. I can see that I can simply
> replicate the script with a different hook, but just want to try and
> simplify management of it.

Hm, this is not implemented right now, but might be a good idea (and
shouldn't be too difficult to do). I just don't know if it will be very
helpful except in this particular case... Anyway, could you add it to GC?
Please note that all this should come about naturally once we have
"library" scripts (since there the script registers itself for hooks,
menu items, etc.).

HTH
Stefan


More information about the texworks mailing list