[texworks] SCRIPTING: Autocompletion based on the current file.

Henrik Skov Midtiby henrikmidtiby at gmail.com
Mon Jan 31 08:25:49 CET 2011


Hi again

The file is now attached in a zipped file, maybe it will go through then ;-)
In addition I also uploaded the script to [1].

Henrik

[1] http://code.google.com/p/texworks/issues/detail?id=261



On 31 January 2011 04:01, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Dear Henrik,
>
> I thought I had missed something earlier, it looks like when you send
> email via nfit.au.dk attached .js are being removed. I believe the
> same may have happened on date 30 December 2010 23:07
>
> I was previously commenting on your first one - and got it from the
> Issues tracker 26 December 2010.
>
> You might be able to zip up  your file.js first and your mail server
> might let that pass through?
>
> Regards,
>
> Paul
>
>
>
> On 31 January 2011 01:00, 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.
>>
>>
>> Attached is the updated autocomplete script.
>>
>> There are two main changes.
>> 1) The script will no longer enter an infinite loop if activated with
>> non alphanumeric chars below the cursor.
>> 2) The script will look for completion candidates in all files
>> currently opened in TeXWorks.
>>
>> Henrik
>>
>> On 30 January 2011 12:36, Henrik Skov Midtiby <henrikmidtiby at gmail.com> wrote:
>>> Hi Paul (and others)
>>>
>>> I'm currently looking at the script once more. Primarily for cleaning
>>> up the code and try to remove a bug where the script enters an
>>> infinite loop.
>>>
>>> The code example looks like exactly what I needed. It will be tested
>>> later today.
>>>
>>> Henrik
>>>
>>> On 30 January 2011 12:23, Paul A Norman <paul.a.norman at gmail.com> wrote:
>>>> Dear Henrik,
>>>>
>>>> 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.
>>>>
>>>> http://twscript.paulanorman.com/docs/html/files/getOpenWindows.html
>>>>
>>>> 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,
>>>>
>>>> Paul
>>>>
>>>> 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:
>>>>>> Hi
>>>>>>
>>>>>> 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 [1].
>>>>>>
>>>>>> 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
>>>>>>
>>>>>> [1] http://code.google.com/p/texworks/issues/detail?id=261&q=script
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>



More information about the texworks mailing list