I started using LyX at about LyX 1.3--LyX 1.4. In following the lists since then I don't recall seeing any mention about the possibility of exploiting the fact that a(n uncompressed) LyX file is a *text* file and hence can be read and manipulated in a straightforward way by other programs. With its converter mechanism, LyX itself provides a means of launching scripts which can do such manipulating. All one needs to do is define a file format, call it LyX2 which is LyX in all but name, and specify a converter to get from LyX format to LyX2 format. The converter manipulates the file in the desired way; the file can then be imported back into LyX.

Earlier in the year I discovered that LyX2 does *not* need a different extension as I had first thought, that if it uses lyx as extension (and obviously maintains LyX formatting of the document) then the export proceeds as before and no importing is necessary: a buffer-reload overwrites the document displaying in LyX. Alternatively, if LyX is specified as the viewer for LyX2 one can play safe by using the View/Update buttons to see the effects of the manipulations. Living dangerously, with various tweaks and toolbar buttons the export-reload procedure can avoid "nag" screens and is sufficiently fast with modern computers that it feels like any other editing process -- copy & paste for instance. One isn't aware of the document being exported and manipulated then reloaded. It simply updates on screen before one's eyes: a table is sorted, a list is sorted, abbreviations are expanded. (I have python scripts for each of these functions, and some others.)

With its support of ERT, access to the LaTeX preamble and the vast array of LaTeX packages, external templates, the LyX pipe, the module system, LyX has embraced ways of filling gaps in its "native" functionality. In this vein, I propose (easy for me because I'm not a developer) that LyX support the process outlined with a GUI. It enables certain tasks to be done in LyX which currently are not possible: sorting (tables, lists, bibliographies, indexes), find-&-replace across paragraph boundaries, expansion of abbreviations/text macros, heuristic structuring of "formless text", styling of indexes (line-by-line to run-on). These are possibilities that occur to me and for some of which I have functioning scripts. The process is *already* available in LyX via the converter GUI, File > Export, & the buffer-reload LFUN, but this is too convoluted to be convenient (although it can be tweaked to greater convenience).

I envisage the GUI being readily available on clicking an easily accessible icon (like the insert-cross-reference or insert-citation GUIs). The GUI would contain a drop-down box of available scripts, and slots for entering command-line options (plus launch and cancel buttons & perhaps View/Update buttons). Perhaps some scripts would "come with LyX"; others could be downloaded by users as needed from the Wiki, to be placed in their personal scripts folder. One can imagine a library of such scripts developing.

In the subject line, I said "A 'new' area of extensibility". Obviously it's an old one and has been there since the converter mechanism was developed, but it seems to have passed entirely "under the radar".

Andrew

Reply via email to