Hi Frank,
Yes it should be possible to do what you want without any changes to Geany, basically doing what you proposed on IRC.
Detailed algorithm: [n] refers to tl;dr notes at the end
1) Your plugin keeps a list of GeanyDocument pointers that have % master and the master file path [1]
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.
3) On "document-close" signal remove the document from the list if its present.
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:
build_set_menu_item( GEANY_BCS_FT, GEANY_GBG_FT, 0 or 1, GEANY_BC_COMMAND, string) [4]
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.
Cheers Lex
[1] I assume the master file can be anything, not just master.tex [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. [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. [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.
Am 02.08.2013 01:50, schrieb Lex Trotman:
Hi Frank,
Yes it should be possible to do what you want without any changes to Geany, basically doing what you proposed on IRC.
Detailed algorithm: [n] refers to tl;dr notes at the end
- Your plugin keeps a list of GeanyDocument pointers that have %
master and the master file path [1]
Does "% master" refer to a special comment? If yes I wonder what this is for? We support and can build projects for other filetypes without such a comment. I would expect the master file to be set in some dialog like all other IDEs with Latex support do.
Best regards.
On Fri, 02 Aug 2013 08:39:37 +0200 Thomas Martitz thomas.martitz@student.htw-berlin.de wrote:
Does "% master" refer to a special comment? If yes I wonder what this is for? We support and can build projects for other filetypes without such a comment. I would expect the master file to be set in some dialog like all other IDEs with Latex support do.
vim as well as Emacs/AucTeX are supporting local variables where you can e.g. set the master-document for a tex file. On emacs it looks like
%%% Local Variables: %%% mode: latex %%% TeX-master: "../da" %%% End:
(Example from my diploma thesis some time ago)
On vim such a string could look like at the end of the file
vim: fileencoding=utf8 textwidth=128 tabstop=4 nowrap shiftwidth=4 spell spelllang=de
(OK. Not an example with master-file ...)
My gaol is to support these things also in Geany (for TeX-files and for master-document, as these are the most important to me). But of course, creating a project is a very good idea for the meanwhile on a Geany-only project.
Cheers, Frank