comparison src/keyboard.c @ 12144:12720a817d83

(Vhelp_event_list): New var. (syms_of_keyboard): Set up Lisp var. (help_char_p): New function. (read_char, echo_char, read_key_sequence): Use help_char_p.
author Karl Heuer <kwzh@gnu.org>
date Fri, 09 Jun 1995 00:55:30 +0000
parents 0131a61184ab
children 64b16f71a15c
comparison
equal deleted inserted replaced
12143:4aa248ba0abb 12144:12720a817d83
146 int immediate_quit; 146 int immediate_quit;
147 147
148 /* Character to recognize as the help char. */ 148 /* Character to recognize as the help char. */
149 Lisp_Object Vhelp_char; 149 Lisp_Object Vhelp_char;
150 150
151 /* List of other event types to recognize as meaning "help". */
152 Lisp_Object Vhelp_event_list;
153
151 /* Form to execute when help char is typed. */ 154 /* Form to execute when help char is typed. */
152 Lisp_Object Vhelp_form; 155 Lisp_Object Vhelp_form;
153 156
154 /* Command to run when the help character follows a prefix key. */ 157 /* Command to run when the help character follows a prefix key. */
155 Lisp_Object Vprefix_help_command; 158 Lisp_Object Vprefix_help_command;
561 bcopy (name->data, ptr, name->size); 564 bcopy (name->data, ptr, name->size);
562 ptr += name->size; 565 ptr += name->size;
563 } 566 }
564 567
565 if (current_kboard->echoptr == current_kboard->echobuf 568 if (current_kboard->echoptr == current_kboard->echobuf
566 && EQ (c, Vhelp_char)) 569 && help_char_p (c))
567 { 570 {
568 strcpy (ptr, " (Type ? for further options)"); 571 strcpy (ptr, " (Type ? for further options)");
569 ptr += strlen (ptr); 572 ptr += strlen (ptr);
570 } 573 }
571 574
2048 reread: 2051 reread:
2049 last_input_char = c; 2052 last_input_char = c;
2050 num_input_chars++; 2053 num_input_chars++;
2051 2054
2052 /* Process the help character specially if enabled */ 2055 /* Process the help character specially if enabled */
2053 if (EQ (c, Vhelp_char) && !NILP (Vhelp_form)) 2056 if (!NILP (Vhelp_form) && help_char_p (c))
2054 { 2057 {
2055 Lisp_Object tem0; 2058 Lisp_Object tem0;
2056 count = specpdl_ptr - specpdl; 2059 count = specpdl_ptr - specpdl;
2057 2060
2058 record_unwind_protect (Fset_window_configuration, 2061 record_unwind_protect (Fset_window_configuration,
2078 while (BUFFERP (c)); 2081 while (BUFFERP (c));
2079 } 2082 }
2080 } 2083 }
2081 2084
2082 return c; 2085 return c;
2086 }
2087
2088 /* Return 1 if should recognize C as "the help character". */
2089
2090 int
2091 help_char_p (c)
2092 Lisp_Object c;
2093 {
2094 Lisp_Object tail;
2095
2096 if (EQ (c, Vhelp_char))
2097 return 1;
2098 for (tail = Vhelp_event_list; CONSP (tail); tail = XCONS (tail)->cdr)
2099 if (EQ (c, XCONS (tail)->car))
2100 return 1;
2101 return 0;
2083 } 2102 }
2084 2103
2085 /* Record the input event C in various ways. */ 2104 /* Record the input event C in various ways. */
2086 2105
2087 static void 2106 static void
5442 if (first_binding >= nmaps) 5461 if (first_binding >= nmaps)
5443 { 5462 {
5444 Lisp_Object head; 5463 Lisp_Object head;
5445 5464
5446 head = EVENT_HEAD (key); 5465 head = EVENT_HEAD (key);
5447 if (EQ (head, Vhelp_char)) 5466 if (help_char_p (head))
5448 { 5467 {
5449 read_key_sequence_cmd = Vprefix_help_command; 5468 read_key_sequence_cmd = Vprefix_help_command;
5450 keybuf[t++] = key; 5469 keybuf[t++] = key;
5451 last_nonmenu_event = key; 5470 last_nonmenu_event = key;
5452 /* The Microsoft C compiler can't handle the goto that 5471 /* The Microsoft C compiler can't handle the goto that
6963 "Character to recognize as meaning Help.\n\ 6982 "Character to recognize as meaning Help.\n\
6964 When it is read, do `(eval help-form)', and display result if it's a string.\n\ 6983 When it is read, do `(eval help-form)', and display result if it's a string.\n\
6965 If the value of `help-form' is nil, this char can be read normally."); 6984 If the value of `help-form' is nil, this char can be read normally.");
6966 XSETINT (Vhelp_char, Ctl ('H')); 6985 XSETINT (Vhelp_char, Ctl ('H'));
6967 6986
6987 DEFVAR_LISP ("help-event-list", &Vhelp_event_list,
6988 "List of input events to recognize as meaning Help.\n\
6989 These work just like the value of `help-char' (see that).");
6990 Vhelp_event_list = Qnil;
6991
6968 DEFVAR_LISP ("help-form", &Vhelp_form, 6992 DEFVAR_LISP ("help-form", &Vhelp_form,
6969 "Form to execute when character `help-char' is read.\n\ 6993 "Form to execute when character `help-char' is read.\n\
6970 If the form returns a string, that string is displayed.\n\ 6994 If the form returns a string, that string is displayed.\n\
6971 If `help-form' is nil, the help char is not recognized."); 6995 If `help-form' is nil, the help char is not recognized.");
6972 Vhelp_form = Qnil; 6996 Vhelp_form = Qnil;