[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happened to the key-menu patch?

From: Stefan Monnier
Subject: Re: What happened to the key-menu patch?
Date: Tue, 09 Jul 2002 09:58:47 -0400

> I guess we should add a `map-keymap' for xemacs compatibility.

I don't think it's just for compatibility but also because it makes sense.

> sure if it's worth it to add a `dobindings' macro or not.

Agreed.  There's already a `loop' macro for it in CL.

>      key-description list' is, but it's something like (meta control x).
>      I guess this is a canonical format for key names in xemacs, but it
>      doesn't appear to be so in emacs, so I'm not sure how that argument
>      should be handled (perhaps just punt, and pass whatever's stored in
>      the keymap).

I don't think we should try to re-create the XEmacs (meta control x) form
from our M-C-x symbols.  We could provide an additional compatibility layer
on top of it, if it proves useful/necessary later on.

>  (2) How are menu entries handled with this?  I'm not sure whether xemacs
>      even stores menus in keymaps or not (it's somewhat hard to tell,
>      since keyaps are an opaque type in xemacs, and just calling
>      map-keymap doesn't yield anything obvious).  We could just pass the
>      whole menu entry (e.g., (menu-item ...)) as the first argument, and
>      perhaps extract the binding and pass it as the second arg, or even
>      pass something else for that.

XEmacs' keymap do not contain menu entries (of toolbar entries
for that matter).  As for how we should treat them, I think we should
not do anything special with them: i.e. `function' will be called
with key `menu-bar' and with the corresponding sub-keymap as the binding.

> affect the usual case (unless you're Stephan).
                                          ^^ f  (couldn't resist)

I have appended my current code.  It has several shortcomings, especially
the ugly "use integers to specify hard-coded C functions".  Also there
is the issue of eliminating/merging duplicate bindings, which I think
XEmacs' code punts on by declaring that `map-keymap' does not look at
the keymap's parent(s).
As you can see, the code is tentative and not ready for prime-time.
I only show it to give an idea of what I'm thinking of.


extern void menu_bar_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
static void (*map_keymap_functions[])
     P_ ((Lisp_Object, Lisp_Object, Lisp_Object))
     = { menu_bar_item };

static void
map_keymap_item (closure, key, val)
     Lisp_Object closure, key, val;
  Lisp_Object fun = XCAR (closure);
  Lisp_Object args = XCDR (closure);
  if (EQ (val, Qt))
    val = Qnil;
  if (NATNUMP (fun))
    map_keymap_functions[XFASTINT (fun)](args, key, val);
    call3 (fun, args, key, val);

static void
map_keymap_char_table_item (closure, key, val)
     Lisp_Object closure, key, val;
  if (!NILP (val))
    map_keymap_item (closure, key, val);

/* Call CLOSURE for every binding in MAP.
   CLOSURE is a cons cell of the form (FUN . ARGS).
   FUN is called with three arguments: FUN (ARGS, KEY, BINDING).
   If FUN is an integer, it denotes the index of the function to
   use from `map_keymap_functions'.  */
map_keymap (closure, map, autoload)
     Lisp_Object map, closure;
     int autoload;
  struct gcpro gcpro1, gcpro2, gcpro3;
  Lisp_Object tail;

  GCPRO3 (map, closure, tail);
  map = get_keymap (map, 1, autoload);
  for (tail = (CONSP (map) && EQ (Qkeymap, XCAR (map))) ? XCDR (map) : map;
       CONSP (tail) || (tail = get_keymap (tail, 0, autoload), CONSP (tail));
       tail = XCDR (tail))
      Lisp_Object binding = XCAR (tail);
      if (CONSP (binding))
        map_keymap_item (closure, XCAR (binding), XCDR (binding));
      else if (VECTORP (binding))
          /* Loop over the char values represented in the vector.  */
          int len = ASIZE (binding);
          int c;
          for (c = 0; c < len; c++)
              Lisp_Object character;
              XSETFASTINT (character, c);
              map_keymap_item (closure, character, AREF (binding, c));
      else if (CHAR_TABLE_P (binding))
          Lisp_Object indices[3];
          map_char_table (map_keymap_char_table_item,
                          Qnil, binding, closure, 0, indices);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]