I'm working on a connector for TeXmacs with Juris-M / Zotero that will
utilize the pre-existing TCP protocol that's there for the OpenOffice
integration. The wire protocol is documented here:


https://www.zotero.org/support/dev/client_coding/libreoffice_plugin_wire_protocol
<https://www.zotero.org/support/dev/client_coding/libreoffice_plugin_wire_protocol>

The project is on Github. I've ported the guile json library to guile-1.8
so it can be used from TeXmacs, and I made a start on an rtf to texmacs
converter, though I think it will be better to have Zotero send output as
LaTeX (bbl), or even as TeXmacs scheme. It's easy enough to create a new
output format. I have forked and patched versions of zotero and
better-bibtex-for-zotero in my GitHub as well. Some patches to
better-bibtex-for-zotero have been accepted; the one to Juris-M / Zotero is
not ready until it's tested and working. I told them about it, and created
a pull request, but said I don't expect them to apply it yet, just look at
it and advise me. Also in my GitHub repositories is a "git svn" mirror of
TeXmacs itself.

 https://github.com/KarlHegbloom/zotero-texmacs-integration

I'm not asking for anyone else to write the program for me... But if
somebody makes a fork and writes something significant that this thing
needs, I won't complain, no worries... mainly I need help understanding how
to do some things that I'm having difficulty figuring out for myself
through code reading and experimentation.

There's a scheme-session.tm file in my project directory that shows that I
can send and receive commands with Zotero. I'm having trouble figuring out
how to do the protocol loop. When I initiate the sequence by sending,
*e.g.,* an "addCitation" *integration command*, Zotero responds with a *word
processor command*, to which the integration code must respond after
processing it. It must stay in an IO loop with Zotero until it is issued a
*Document_complete* and sends the JSON null response to that. At that point
it does not need to listen for connections from Zotero until another
*integration
command* is sent by TeXmacs to Zotero. While it is in the *word processor
command* mode, TeXmacs is not expected to accept input from the user until
Zotero is done with the sequence of operations.

*Q: How do I devise the loop that runs to handle the incoming word
processor commands? Do I need to use 'delayed'? Please advise.*

By 'delayed' here I mean the Scheme "delayed" macro I see all over the GUI
widget code, and in the tm-server and tm-client codes. How does this
interact with "select" to wait for information to arrive on a socket port?
I need help designing this IO loop so that it won't cause TeXmacs to hang,
and so it will be robust in case of things like Firefox crashing or being
closed by the user, etc.


The other problem that I need to solve is that I'll have to save data in
the document. I think I can mostly figure that out by looking over the
database code, and the bibliography handling, saving it in the aux data or
with a set-binding... I think that set-binding is for setting the strings
that are displayed by an in-text citation... but for some CSL citation
styles, the citation belongs in a footnote. Switching styles from a "note"
style to an "in-text" style should make the citations flip between being in
footnotes (or end-notes; see below) or being displayed in-text at the point
where the cite tag appears.

My initial experiments with using set-binding from inside TeXmacs, right
there in the buffer, show that I can set a binding to a footnote, and then
later recall it with get-binding. But when I define one, then move up above
it and define another one, then call on get-binding in a different order,
the footnote numbers are not updated to reflect the new document order...
So I think what I need is delayed evaluation... as in quote-arg with later
eval...  Or what?

Should I use the already available 'label' -> 'reference' mechanism to
display the citation text? Or is there a lower-level thing that it uses
which I should use more directly?  When you look at the "scheme-session.tm"
there, you'll see what it sends and what it expects to be kept, in a hidden
part of the citation field, for later sending back to Zotero to
re-initialize the state. I think that if I just use 'label' and 'reference'
that it's not good since sometimes a citation needs to make it's own
footnote, and really expanding 'reference' ought to only give back some
text to display in-line, not a tree that makes a footnote. A tree with
formatting, maybe...

Ideas please! I need help understanding this.

Thank you.
    Karl M. Hegbloom
_______________________________________________
Texmacs-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/texmacs-dev

Reply via email to