On Wed, 8 Sep 2010 23:47:28 +0400 Eugene Arshinov earshinov@gmail.com wrote:
Unfortunately, keybindings_set_item was not enough for me to implement this. For example, I had to extend GeanyKeyGroup struct so that I have a way to tweak loading from / saving to keybindings.conf. Anyway, any suggestions about how to improve the patch are welcome.
OK, I didn't explain before what I had in mind but I think this patch is too complex.
What I think we could accept is setting up the snippet keybinding group size and items (like a plugin) when snippets.conf is read, using any defaults found in the file. I don't think we should write to snippets.conf. If the user wants to set the keybinding in snippets.conf, then they must remember that it won't be kept in sync with keybindings.conf. This should make the code simpler.
No, I didn't mean to read/save keybindings in snippets.conf. It is very strange that my patch does it, maybe I forgot to remove something from the code :) I'll recheck the patch, probably tomorrow.
I didn't study the patch much, but you said 'I have a way to tweak loading from / saving to keybindings.conf'.
The patch is complex because the list of snippets is somewhat used in two places: snippets.conf and keybindings.conf (now containing snippet keybindings). When one of each files is [re]loaded, the list of keybindings in Preferences should be updated. Maybe I used too complex logic for handling that…
I may be wrong, but why does any keybinding code need to know about snippets? I thought when snippets.conf is read or re-read, we would just resize the keybinding group and initialize each keybinding based on the keys listed in a snippets.conf [keybindings] section. (Just like a plugin would).
I'm not sure why editor.c needs to cache the keybindings either. Maybe I'm missing something.
Regards, Nick