Hi
I need to loop all supported geany filetypes in my geanydoc plugin (http://repo.or.cz/w/geanydoc.git).
filetypes_get_from_uid() is just what I need. Please add it to plugin api. Patch attached.
Also I notice filetypes_get_from_uid() is written somehow strange. Since "id" field also act as pos in filetypes array I think it is not necessary to loop filetypes every time. Second patch use simple if to do job.
On Wed, 12 Mar 2008 11:13:36 +0200 Yura Siamashka yurand2@gmail.com wrote:
Hi
I need to loop all supported geany filetypes in my geanydoc plugin (http://repo.or.cz/w/geanydoc.git).
Out of interest, what does the plugin do? I couldn't find anything that explained it.
filetypes_get_from_uid() is just what I need. Please add it to plugin api. Patch attached.
Also I notice filetypes_get_from_uid() is written somehow strange. Since "id" field also act as pos in filetypes array I think it is not necessary to loop filetypes every time. Second patch use simple if to do job.
The UID is not the index into the filetypes array. Look at the enum with FILETYPE_UID_C in filetypes.c, the enum values cannot change. The filetype_id enum can change, and is the index.
You can use GeanyData::filetypes, which is an array of filetype pointers, to loop through each filetype.
Regards, Nick
2008/3/12, Nick Treleaven nick.treleaven@btinternet.com:
I need to loop all supported geany filetypes in my geanydoc plugin (http://repo.or.cz/w/geanydoc.git).
Out of interest, what does the plugin do? I couldn't find anything that explained it.
It is still in early development no readme yet, sorry . It suppose to call get documentation on current word using F1 key.
Something similar to emacs: (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))
Method to get this documentation is filetype dependand and suppose to be configureable (That is why I need to loop through all supported filetypes).
For example: 1) C - call "man -S 2:3", if it return nothing, call "devhelp -s" 2) Python - call "pydoc"
The UID is not the index into the filetypes array. Look at the enum with FILETYPE_UID_C in filetypes.c, the enum values cannot change. The filetype_id enum can change, and is the index.
Oh, then I guess I don't need this function.
You can use GeanyData::filetypes, which is an array of filetype pointers, to loop through each filetype.
Good, but how can I get it's size? I think I can't trust GEANY_MAX_FILE_TYPES since it can be different for geany and plugin.
Best regards, Yura Siamashka
2008/3/12, Yura Siamashka yurand2@gmail.com:
You can use GeanyData::filetypes, which is an array of filetype pointers, to loop through each filetype.
Good, but how can I get it's size? I think I can't trust GEANY_MAX_FILE_TYPES since it can be different for geany and plugin.
I think I can check if filetype is GEANY_FILETYPES_ALL and assume it is last. Sorry no need to add anything to geany. ;-)
Best regards, Yura Siamashka
On Wed, 12 Mar 2008 15:14:16 +0200 "Yura Siamashka" yurand2@gmail.com wrote:
2008/3/12, Yura Siamashka yurand2@gmail.com:
You can use GeanyData::filetypes, which is an array of filetype pointers, to loop through each filetype.
Good, but how can I get it's size? I think I can't trust GEANY_MAX_FILE_TYPES since it can be different for geany and plugin.
I think I can check if filetype is GEANY_FILETYPES_ALL and assume it is last. Sorry no need to add anything to geany. ;-)
GEANY_FILETYPES_ALL is always one before GEANY_MAX_FILE_TYPES. This is the best you can do for now. I guess because of this we need to always increment the ABI when adding filetypes. (I'm planning on making the filetypes array dynamic in future, so then it would be something like filetypes->len.)
Regards, Nick
On Wed, 12 Mar 2008 14:13:55 +0000 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Wed, 12 Mar 2008 15:14:16 +0200 "Yura Siamashka" yurand2@gmail.com wrote:
2008/3/12, Yura Siamashka yurand2@gmail.com:
You can use GeanyData::filetypes, which is an array of filetype pointers, to loop through each filetype.
Good, but how can I get it's size? I think I can't trust GEANY_MAX_FILE_TYPES since it can be different for geany and plugin.
I think I can check if filetype is GEANY_FILETYPES_ALL and assume it is last. Sorry no need to add anything to geany. ;-)
GEANY_FILETYPES_ALL is always one before GEANY_MAX_FILE_TYPES. This is the best you can do for now. I guess because of this we need to always increment the ABI when adding filetypes. (I'm planning on making the filetypes array dynamic in future, so then it would be something like filetypes->len.)
No need. I can calculate filetypes length checking if current filetype is last (check it's uid with FILETYPE_UID_ALL).
What about allocating filetypes as [GEANY_MAX_FILE_TYPES + 1]? Extra NULL pointer will tell array size for sure and there are glib functions for working with such data.
On Wed, 12 Mar 2008 22:52:39 +0200 Yura Siamashka yurand2@gmail.com wrote:
On Wed, 12 Mar 2008 14:13:55 +0000 Nick Treleaven nick.treleaven@btinternet.com wrote:
GEANY_FILETYPES_ALL is always one before GEANY_MAX_FILE_TYPES. This is the best you can do for now. I guess because of this we need to always increment the ABI when adding filetypes. (I'm planning on making the filetypes array dynamic in future, so then it would be something like filetypes->len.)
No need. I can calculate filetypes length checking if current
There are other reasons why it needs to be dynamic, just thought I'd mention it.
filetype is last (check it's uid with FILETYPE_UID_ALL).
I guess that is pretty robust way of checking it - although we will increment the plugin ABI if we add any filetypes, as other plugins might rely on GEANY_MAX_FILE_TYPES as well.
What about allocating filetypes as [GEANY_MAX_FILE_TYPES + 1]? Extra NULL pointer will tell array size for sure and there are glib functions for working with such data.
If there's going to be a change, it should be to make filetypes a dynamic array (necessary for loading custom filetypes). But if you want you could write a filetypes_foreach() function for the plugin API, that might be useful.
BTW which GLib functions do you mean?
Regards, Nick
On Wed, 12 Mar 2008 15:09:35 +0200 "Yura Siamashka" yurand2@gmail.com wrote:
2008/3/12, Nick Treleaven nick.treleaven@btinternet.com:
I need to loop all supported geany filetypes in my geanydoc plugin (http://repo.or.cz/w/geanydoc.git).
Out of interest, what does the plugin do? I couldn't find anything that explained it.
It is still in early development no readme yet, sorry . It suppose to call get documentation on current word using F1 key.
Thanks for explaining. Geany does have Context Action support per filetype for this purpose, but perhaps you want it to be more powerful.
Something similar to emacs: (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))
I'm soon to merge plugin keybinding support into the trunk, maybe this would help you.
Regards, Nick
On Wed, 12 Mar 2008 14:10:34 +0000 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Wed, 12 Mar 2008 15:09:35 +0200 "Yura Siamashka" yurand2@gmail.com wrote:
2008/3/12, Nick Treleaven nick.treleaven@btinternet.com:
I need to loop all supported geany filetypes in my geanydoc plugin (http://repo.or.cz/w/geanydoc.git).
Out of interest, what does the plugin do? I couldn't find anything that explained it.
It is still in early development no readme yet, sorry . It suppose to call get documentation on current word using F1 key.
Thanks for explaining. Geany does have Context Action support per filetype for this purpose, but perhaps you want it to be more powerful.
I completely forgot about it. Funny I think I was person why ask for Context Action support in the first place. ;-)
But plugin is going to be better for documentation since it:
1) Will be able to search different documentation type. (Call devhelp only if nothing was found in man) 2) Will include sane defaults exactly for documentatin right after install. (configuring Context Actions for different filetypes is not very interesting thing to do). 3) Will be able to place documentation inside geany buffer, not just call external program.