comparison src/keymap.c @ 219:262b8bb4a523 r20-4b8

Import from CVS: tag r20-4b8
author cvs
date Mon, 13 Aug 2007 10:09:35 +0200
parents 1f0dabaa0855
children f955c73f5258
comparison
equal deleted inserted replaced
218:c9f226976f56 219:262b8bb4a523
224 Lisp_Object Qsuppress_keymap; 224 Lisp_Object Qsuppress_keymap;
225 225
226 Lisp_Object Qmodeline_map; 226 Lisp_Object Qmodeline_map;
227 Lisp_Object Qtoolbar_map; 227 Lisp_Object Qtoolbar_map;
228 228
229 static void describe_command (Lisp_Object definition); 229 static void describe_command (Lisp_Object definition, Lisp_Object buffer);
230 static void describe_map (Lisp_Object keymap, Lisp_Object elt_prefix, 230 static void describe_map (Lisp_Object keymap, Lisp_Object elt_prefix,
231 void (*elt_describer) (Lisp_Object), 231 void (*elt_describer) (Lisp_Object, Lisp_Object),
232 int partial, 232 int partial,
233 Lisp_Object shadow, 233 Lisp_Object shadow,
234 int mice_only_p); 234 int mice_only_p,
235 Lisp_Object buffer);
235 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift; 236 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift;
236 /* Lisp_Object Qsymbol; defined in general.c */ 237 /* Lisp_Object Qsymbol; defined in general.c */
237 Lisp_Object Qbutton0, Qbutton1, Qbutton2, Qbutton3, Qbutton4, Qbutton5, 238 Lisp_Object Qbutton0, Qbutton1, Qbutton2, Qbutton3, Qbutton4, Qbutton5,
238 Qbutton6, Qbutton7; 239 Qbutton6, Qbutton7;
239 Lisp_Object Qbutton0up, Qbutton1up, Qbutton2up, Qbutton3up, Qbutton4up, 240 Lisp_Object Qbutton0up, Qbutton1up, Qbutton2up, Qbutton3up, Qbutton4up,
3752 Fifth argument MOUSE-ONLY-P says to only print bindings for mouse clicks. 3753 Fifth argument MOUSE-ONLY-P says to only print bindings for mouse clicks.
3753 */ 3754 */
3754 (map, all, shadow, prefix, mouse_only_p)) 3755 (map, all, shadow, prefix, mouse_only_p))
3755 { 3756 {
3756 /* This function can GC */ 3757 /* This function can GC */
3758
3759 /* #### At some point, this function should be changed to accept a
3760 BUFFER argument. Currently, the BUFFER argument to
3761 describe_map_tree is being used only internally. */
3757 describe_map_tree (map, NILP (all), shadow, prefix, 3762 describe_map_tree (map, NILP (all), shadow, prefix,
3758 !NILP (mouse_only_p)); 3763 !NILP (mouse_only_p), Fcurrent_buffer ());
3759 return Qnil; 3764 return Qnil;
3760 } 3765 }
3761 3766
3762 3767
3763 /* Insert a desription of the key bindings in STARTMAP, 3768 /* Insert a desription of the key bindings in STARTMAP,
3769 If PREFIX is non-nil, only list bindings which start with those keys. 3774 If PREFIX is non-nil, only list bindings which start with those keys.
3770 */ 3775 */
3771 3776
3772 void 3777 void
3773 describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, 3778 describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow,
3774 Lisp_Object prefix, int mice_only_p) 3779 Lisp_Object prefix, int mice_only_p, Lisp_Object buffer)
3775 { 3780 {
3776 /* This function can GC */ 3781 /* This function can GC */
3777 Lisp_Object maps = Qnil; 3782 Lisp_Object maps = Qnil;
3778 struct gcpro gcpro1, gcpro2; /* get_keymap may autoload */ 3783 struct gcpro gcpro1, gcpro2; /* get_keymap may autoload */
3779 GCPRO2 (maps, shadow); 3784 GCPRO2 (maps, shadow);
3829 : Qnil); 3834 : Qnil);
3830 describe_map (Fcdr (elt), keysdesc, 3835 describe_map (Fcdr (elt), keysdesc,
3831 describe_command, 3836 describe_command,
3832 partial, 3837 partial,
3833 sub_shadow, 3838 sub_shadow,
3834 mice_only_p); 3839 mice_only_p,
3840 buffer);
3835 } 3841 }
3836 SKIP: 3842 SKIP:
3837 NUNGCPRO; 3843 NUNGCPRO;
3838 } 3844 }
3839 UNGCPRO; 3845 UNGCPRO;
3840 } 3846 }
3841 3847
3842 3848
3843 static void 3849 static void
3844 describe_command (Lisp_Object definition) 3850 describe_command (Lisp_Object definition, Lisp_Object buffer)
3845 { 3851 {
3846 /* This function can GC */ 3852 /* This function can GC */
3847 Lisp_Object buffer;
3848 int keymapp = !NILP (Fkeymapp (definition)); 3853 int keymapp = !NILP (Fkeymapp (definition));
3849 struct gcpro gcpro1, gcpro2; 3854 struct gcpro gcpro1;
3850 GCPRO2 (definition, buffer); 3855 GCPRO1 (definition);
3851 3856
3852 XSETBUFFER (buffer, current_buffer);
3853 Findent_to (make_int (16), make_int (3), buffer); 3857 Findent_to (make_int (16), make_int (3), buffer);
3854 if (keymapp) 3858 if (keymapp)
3855 buffer_insert_c_string (XBUFFER (buffer), "<< "); 3859 buffer_insert_c_string (XBUFFER (buffer), "<< ");
3856 3860
3857 if (SYMBOLP (definition)) 3861 if (SYMBOLP (definition))
4097 reached by the sequence of prefix keys KEYS (a string or vector). 4101 reached by the sequence of prefix keys KEYS (a string or vector).
4098 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ 4102 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */
4099 4103
4100 static void 4104 static void
4101 describe_map (Lisp_Object keymap, Lisp_Object elt_prefix, 4105 describe_map (Lisp_Object keymap, Lisp_Object elt_prefix,
4102 void (*elt_describer) (Lisp_Object), 4106 void (*elt_describer) (Lisp_Object, Lisp_Object),
4103 int partial, 4107 int partial,
4104 Lisp_Object shadow, 4108 Lisp_Object shadow,
4105 int mice_only_p) 4109 int mice_only_p,
4110 Lisp_Object buffer)
4106 { 4111 {
4107 /* This function can GC */ 4112 /* This function can GC */
4108 struct describe_map_closure describe_map_closure; 4113 struct describe_map_closure describe_map_closure;
4109 Lisp_Object list = Qnil; 4114 Lisp_Object list = Qnil;
4110 struct buffer *buf = current_buffer; 4115 struct buffer *buf = XBUFFER (buffer);
4111 Emchar printable_min = (CHAR_OR_CHAR_INTP (buf->ctl_arrow) 4116 Emchar printable_min = (CHAR_OR_CHAR_INTP (buf->ctl_arrow)
4112 ? XCHAR_OR_CHAR_INT (buf->ctl_arrow) 4117 ? XCHAR_OR_CHAR_INT (buf->ctl_arrow)
4113 : ((EQ (buf->ctl_arrow, Qt) 4118 : ((EQ (buf->ctl_arrow, Qt)
4114 || EQ (buf->ctl_arrow, Qnil)) 4119 || EQ (buf->ctl_arrow, Qnil))
4115 ? 256 : 160)); 4120 ? 256 : 160));
4200 continue; 4205 continue;
4201 } 4206 }
4202 } 4207 }
4203 4208
4204 /* Print a description of the definition of this character. */ 4209 /* Print a description of the definition of this character. */
4205 (*elt_describer) (XCDR (XCAR (list))); 4210 (*elt_describer) (XCDR (XCAR (list)), buffer);
4206 list = XCDR (list); 4211 list = XCDR (list);
4207 } 4212 }
4208 } 4213 }
4209 UNGCPRO; 4214 UNGCPRO;
4210 } 4215 }