[texworks] SCRIPTING: Autocompletion based on the current file.
Paul A Norman
paul.a.norman at gmail.com
Sun Jan 30 12:23:29 CET 2011
I really like your script very useful thank you - sorry that it has
taken so long to get back.
I am going to have more of a look at it over the next few days.
>"My question is then how to determine the other tex files witch are
opened by texworks when the script is invoked?"
This link if you have not already found the information may help, the
terminology may have not been obvious.
You would want in terms of that link
var windows = TW.app.getOpenWindows();
var textList = ;
for (editor in windows)
var targetDocument = windows[editor];
textList.push(targetDocument.text + "\n");
Or augment a string perhaps instead of an array
Please let me know if I have misunderstood what you were looking for,
On 30 December 2010 23:07, Henrik Skov Midtiby <henrikmidtiby at gmail.com> wrote:
> WARNING: This e-mail has been altered by the NFIT virus/spamfilter. Please see below for a record of the changes made.
> . In case of problems consider contacting the sender or postmaster at nfit.au.dk
> -------Change report:
> An attachment named autocomplete.js was removed from this document as it
> constituted a security hazard. If you require this document, please contact
> the sender and arrange an alternate means of receiving it.
> A new version of the script is available. It is now context aware with
> respect to the commands \label \ref and \pageref.
> If you try to complete a parameter to a \label it will only search for
> matches which itself are parameters to the commands \ref and \pageref.
> Comments and suggestions are welcome.
> Best regards,
> Henrik Skov Midtiby
> On 27 December 2010 08:59, Henrik Skov Midtiby <henrikmidtiby at gmail.com> wrote:
>> I have just started messing around with the texworks scripting
>> capabilities, and a lot of possibilities begin to appear. I hope to
>> find time to explore it further ;-)
>> My first real script is a kind of autocompleter, inspired by the one
>> found in vim. It looks at the word you were typing when the script was
>> activated and locates matching words in the current file. The script
>> is uploaded to the script issue .
>> Some ideas for where the script can be improved:
>> * look for matching words in related files (files opened by texworks,
>> bibtex file, ...)
>> * context aware: only locate labels when autocompleting a parameter to
>> a \ref command
>> My question is then how to determine the other tex files witch are
>> opened by texworks when the script is invoked?
>> Best regards,
>> Henrik Skkov Midtiby
>>  http://code.google.com/p/texworks/issues/detail?id=261&q=script
More information about the texworks