[Geany-devel] snippet keybindings? - Re: [PATCH] Some editor/snippets/keybindings enhancements

Eugene Arshinov earshinov at xxxxx
Thu Sep 9 07:01:04 UTC 2010


On Wed, 8 Sep 2010 23:47:28 +0400%
Eugene Arshinov <earshinov at gmail.com> wrote:

> Hi
> 
> On Wed, 8 Sep 2010 16:14:07 +0100%
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> 
> > On Sun, 29 Aug 2010 21:59:32 +0400
> > Eugene Arshinov <earshinov at gmail.com> wrote:
> > 
> > > > > >> >> If we do want snippet keybindings perhaps it would be
> > > > > >> >> better to integrate with the existing keybindings rather
> > > > > >> >> than storing them separately - then users could
> > > > > >> >> configure them in the normal way.
> > 
> > > > Here is the new patch.  It seems to be not so simple and clean
> > > > as the previous one, but now keybindings are edited in
> > > > Preferences dialog as (I believe) most users prefer.
> > > > 
> > > > 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.

OK, it does not read keybindings from snippets.conf, only snippet names.
Maybe function names are confusing: if you look at
load_snippet_keybindings_from_snippets, you may think it really loads
keybindings, but it doesn't :)  Instead it reads just snippet names and
accordingly updates list of snippet keybindings available in
Preferences. 

> 
> 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…
> 
> > > > Currently there are two little problems
> > > > 
> > > > - All underscores from keybinding names are removed (I wonder
> > > > why), so names of some "special" snippets are displayed
> > > > incorrectly (**)
> > 
> > > > ** and users are allowed to assign keybindings for "special"
> > > > snippets
> > 
> > This is so a menu item string with underscores for mnemonics can be
> > reused without adding a translation string but without displaying
> > the underscore mnemonics for the keybindings dialog.
> > 
> > This could be fixed by adding a keygroup field 'translatable', on by
> > default.
> 
> OK, I will implement it after we decide what to do with the
> overcomplexity mentioned above.
> 
> > 
> > > > - Editing of keybindings in the Preferences dialog isn't
> > > > "caught" completely by Geany.  For example, if I remove a
> > > > keybinding using click - BackSpace - Enter and press OK, Geany
> > > > thinks I edited nothing and does not update keybindings.conf.
> > > > Though, as expected, the removed keybinding no longer
> > > > functions. 
> > 
> > I can't reproduce this as described.
> > 
> 
> I'll try to reproduce it with trunk.
> 

Works fine :)  Probably my mistake.

> > > > I finished this patch today, so I hadn't much time for testing.
> > > > As for now, everything except the two issues above seems to work
> > > > fine.
> > > > 
> > > > Best regards,
> > > > Eugene.
> > > 
> > > Sorry, that patch is a little outdated.  Here is the last
> > > version. 
> > > 

I attach slightly updated version, with 2 code comments updated and 1
unneeded function parameter removed.


Best regards,
Eugene.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: geany.20.alt_snippet_keybindings.upd.r5065.patch
Type: text/x-patch
Size: 16651 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100909/6a59abb6/attachment.bin>


More information about the Devel mailing list