Function: minor-mode-key-binding

minor-mode-key-binding is a function defined in keymap.c.

Signature

(minor-mode-key-binding KEY &optional ACCEPT-DEFAULT)

Documentation

Find the visible minor mode bindings of KEY.

Return an alist of pairs (MODENAME . BINDING), where MODENAME is the symbol which names the minor mode binding KEY, and BINDING is KEY's definition in that mode. In particular, if KEY has no minor-mode bindings, return nil. If the first binding is a non-prefix, all subsequent bindings will be omitted, since they would be ignored. Similarly, the list doesn't include non-prefix bindings that come after prefix bindings.

If optional argument ACCEPT-DEFAULT is non-nil, recognize default bindings; see the description of lookup-key for more details about this.

View in manual

Source Code

// Defined in /usr/src/emacs/src/keymap.c
{
  Lisp_Object *modes, *maps;
  int nmaps = current_minor_maps (&modes, &maps);
  Lisp_Object binding = Qnil;

  int j;
  for (int i = j = 0; i < nmaps; i++)
    if (!NILP (maps[i])
	&& !NILP (binding = Flookup_key (maps[i], key, accept_default))
	&& !FIXNUMP (binding))
      {
	if (KEYMAPP (binding))
	  maps[j++] = Fcons (modes[i], binding);
	else if (j == 0)
	  return list1 (Fcons (modes[i], binding));
      }

  return Flist (j, maps);
}