jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Re: jed limits


On Thu, 14 Mar 2002 13:06:25 -0500 wrote "John E. Davis" <davis@xxxxxxxxxxxxx>:

> Guenter Milde <G.Milde@xxxxxxxxxxxxxxxxxxxx> wrote:
> >If there were a 
> >delete_keymap(map) function or if copy_keymap could overwrite an
> >existing keymap, the limit of 30 keymaps were no problem. 
> >(Feature Request :-)
> 
> I had forgotten about the copy_keymap restriction.  The keymaps are
> handled via the slang library, which is on a different schedule from
> jed.  I will add a delete-keymap function to the library but I cannot
> say when that would be available.

I am looking forward to this :-) 

> Perhaps I should add a function to jed that returns what is in the
> keymap via two arrays, e.g.,
> 
>     (keys, functions) = get_keymap_bindings ("global");
> 
> Then you would able to implement overwrite_keymap via something like:
> 
>     define overwrite_keymap (src, dest)
>     {
>        undefinekey ("^@", dest);
>        array_map (Void_Type, &undefinekey, 
>                   array_map (String_Type, &char, [1:255]), 
>                   dest);
>        array_map (Void_Type, &definekey, 
>                   get_keymap_bindings (src),
>                   dest);
>     }

How about returning an associative array? 

    keybindings = get_keymap_bindings ("global");

This would facilitate the use of the dump in a variety of slang functions
and it would let the copy_keymap_overwrite function look more transparent (at
least to me)

    define copy_keymap_overwrite (new_map, old_map)
    {
       variable keybindings = get_keymap_bindings (old_map)

       foreach (keybindings) using keys
       {
          () = key;
          undefinekey(key);
          definekey(keybindings[key], key, new_map);
       }
    }


> Also by having get_keymap_bindings, I would be able to remove
> "dump_bindings" from the C code and put in in a .sl file.


Of course we could do it the other way round: Let a slang function parse the
dump_bindings output.

something like

    define copy_keymap_overwrite (new_map, old_map)
    {
       setbuf("*keybindings*");
       dump_bindings("old_map");
       bob;
       definekeys(new_map);
    }

with
   define definekeys(map)       
   {
       % do replacements (ESC -> \e, ^K K -> ^KK, ...)
       spaces2tab;
       do
       {
         line = line_as_string();
         key = extract_element(line, 0, TAB);
         fun = extract_element(line, 1, TAB);
                definekey(fun, key, map);
       }
       while (down_1);
    }

Which would also allow a comfortable (and new-user friendly) way of defining
a set of keybindings via a special file.


Guenter

--
G.Milde@xxxxxxxxxxxxxxxxxxxx


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]