<div dir="ltr">Hi Frank,<div><br></div><div>Yes it should be possible to do what you want without any changes to Geany, basically doing what you proposed on IRC.</div><div><br></div><div>Detailed algorithm: [n] refers to tl;dr notes at the end</div>
<div><br></div><div>1) Your plugin keeps a list of GeanyDocument pointers that have % master and the master file path [1]</div><div><br></div><div>2) On plugin start, "document-open" signal, "document-reload" signal, "document-save" signal search tex documents for %master [2] and store them in the list % master or remove them from the list if they no longer have % master in them.</div>
<div><br></div><div>3) On "document-close" signal remove the document from the list if its present.</div><div><br></div><div>4) On "document-activate" signal or after updating the list at step 2, if the current document filetype is latex check if it is in the list [3] and set the command using:</div>
<div><br></div><div>    build_set_menu_item( GEANY_BCS_FT, GEANY_GBG_FT, 0 or 1,</div><div>               GEANY_BC_COMMAND, string) [4]</div><div><br></div><div>You may also wish to also set the menu text to alert the user to your changes? just replace GEANY_BC_COMMAND with GEANY_BC_LABEL.</div>
<div><br></div><div>Cheers</div><div>Lex</div><div><br></div><div>[1] I assume the master file can be anything, not just master.tex</div><div>[2] These are slow operations anyway so the search won't affect them significantly.  Use sci_findtext should be ok, limited to whichever lines you want.</div>
<div>[3] searching a short list (say a few tens) of pointers should be fast, if you have hundreds of subdocuments open at once use a g_tree or g_hash keyed by the GeanyDocument pointer.</div><div>[4] GEANY_BCS_FT is the system filetype file value which is never written out so your command can never be saved accidentally and user entered commands will correctly override it. 0 is latex -> dvi command and 1 is latex -> pdf command.  You can construct the "string" to be whatever you need for an individual document or the master document.</div>
</div>