# HG changeset patch # User Aidan Kehoe # Date 1426295805 0 # Node ID 916b48abd1c6959f81904ad159a2f49dbef3e038 # Parent 5423bb35a956138caa61151a27732335dc2a67b7 event-stream.c, support help-event-list as does GNU. src/ChangeLog addition: 2015-03-14 Aidan Kehoe Add support for GNU's help-event-list here, useful for accepting F1 and C-h as the help character at the same time. * event-stream.c: * event-stream.c (echo_key_event): Be better about calculation, comments here, in passing. * event-stream.c (help_char_p): New. * event-stream.c (execute_help_form): There's no need to reset the command builder here; the code that did relied on zero-termination, which we can't anymore, and did not actually discard the help character. Remove this. * event-stream.c (Fnext_event): Use help_char_p (). * event-stream.c (command_builder_find_leaf_no_jit_binding): Use help_char_p (). * event-stream.c (vars_of_event_stream): Make help-event-list available. man/ChangeLog addition: 2015-03-14 Aidan Kehoe * lispref/help.texi (Help Functions): Document help-event-list, just added. lisp/ChangeLog addition: 2015-03-14 Aidan Kehoe * cus-start.el (all): Describe help-event-list for Custom. * keydefs.el (help-event-list): Initialise it. diff -r 5423bb35a956 -r 916b48abd1c6 lisp/ChangeLog --- a/lisp/ChangeLog Sat Mar 14 00:42:46 2015 +0000 +++ b/lisp/ChangeLog Sat Mar 14 01:16:45 2015 +0000 @@ -1,3 +1,8 @@ +2015-03-14 Aidan Kehoe + + * cus-start.el (all): Describe help-event-list for Custom. + * keydefs.el (help-event-list): Initialise it. + 2015-03-12 Aidan Kehoe * simple.el (append-message): Be more careful about saving a diff -r 5423bb35a956 -r 916b48abd1c6 lisp/cus-start.el --- a/lisp/cus-start.el Sat Mar 14 00:42:46 2015 +0000 +++ b/lisp/cus-start.el Sat Mar 14 01:16:45 2015 +0000 @@ -152,6 +152,7 @@ (focus-follows-mouse x boolean) (help-char keyboard (choice character (sexp :tag "Single key specifier"))) + (help-event-list keyboard (repeat (sexp :format "%v"))) (max-lisp-eval-depth limits integer) (max-specpdl-size limits integer) (meta-prefix-char keyboard character) diff -r 5423bb35a956 -r 916b48abd1c6 lisp/keydefs.el --- a/lisp/keydefs.el Sat Mar 14 00:42:46 2015 +0000 +++ b/lisp/keydefs.el Sat Mar 14 01:16:45 2015 +0000 @@ -162,6 +162,8 @@ ;; do backspace. (define-key global-map '(meta ??) 'help-command) +(setq help-event-list '(help f1 (meta ??))) + ;; FSFmacs indent.el ;;(define-key global-map "\t" 'self-insert-command) diff -r 5423bb35a956 -r 916b48abd1c6 man/ChangeLog --- a/man/ChangeLog Sat Mar 14 00:42:46 2015 +0000 +++ b/man/ChangeLog Sat Mar 14 01:16:45 2015 +0000 @@ -1,3 +1,8 @@ +2015-03-14 Aidan Kehoe + + * lispref/help.texi (Help Functions): + Document help-event-list, just added. + 2015-02-23 Mike Kupfer * internals/internals.texi (The Redisplay Mechanism): diff -r 5423bb35a956 -r 916b48abd1c6 man/lispref/help.texi --- a/man/lispref/help.texi Sat Mar 14 00:42:46 2015 +0000 +++ b/man/lispref/help.texi Sat Mar 14 01:16:45 2015 +0000 @@ -584,6 +584,13 @@ subcommands of the prefix key. @end defvar +@defvar help-event-list +This variable provides a means to specify other characters that should +act in the same way @code{help-char} does, with regard to +@code{help-form} and supplying help. It is usually set to include +@kbd{f1}, so that this key is also treated as giving help. +@end defvar + @defvar help-form If this variable is non-@code{nil}, its value is a form to evaluate whenever the character @code{help-char} is read. If evaluating the form diff -r 5423bb35a956 -r 916b48abd1c6 src/ChangeLog --- a/src/ChangeLog Sat Mar 14 00:42:46 2015 +0000 +++ b/src/ChangeLog Sat Mar 14 01:16:45 2015 +0000 @@ -1,3 +1,21 @@ +2015-03-14 Aidan Kehoe + + Add support for GNU's help-event-list here, useful for accepting + F1 and C-h as the help character at the same time. + * event-stream.c: + * event-stream.c (echo_key_event): + Be better about calculation, comments here, in passing. + * event-stream.c (help_char_p): New. + * event-stream.c (execute_help_form): + There's no need to reset the command builder here; the code that + did relied on zero-termination, which we can't anymore, and did + not actually discard the help character. Remove this. + * event-stream.c (Fnext_event): Use help_char_p (). + * event-stream.c (command_builder_find_leaf_no_jit_binding): + Use help_char_p (). + * event-stream.c (vars_of_event_stream): + Make help-event-list available. + 2015-03-14 Aidan Kehoe * .gdbinit.in.in (Lisp): lrecord_type_lcrecord_list is specific to diff -r 5423bb35a956 -r 916b48abd1c6 src/event-stream.c --- a/src/event-stream.c Sat Mar 14 00:42:46 2015 +0000 +++ b/src/event-stream.c Sat Mar 14 01:16:45 2015 +0000 @@ -197,10 +197,13 @@ of the last-command-event. */ Lisp_Object Vlast_command_event_time; -/* Character to recognize as the help char. */ +/* Key specifier to recognize as the help char. */ Lisp_Object Vhelp_char; -/* Form to execute when help char is typed. */ +/* List of other key specifiers that work in the same way as Vhelp_char. */ +Lisp_Object Vhelp_event_list; + +/* Form to execute when Vhelp_char or one of Vhelp_event_list is typed. */ Lisp_Object Vhelp_form; /* Command to run when the help character follows a prefix key. */ @@ -650,7 +653,7 @@ len = eilen (buf); if (NILP (command_builder->echo_buf) || - (len + buf_fill_pointer + 4 > XSTRING_LENGTH (command_builder->echo_buf))) + (len + buf_fill_pointer + 3 > XSTRING_LENGTH (command_builder->echo_buf))) { eifree (buf); return; @@ -665,7 +668,7 @@ sledgehammer_check_ascii_begin (command_builder->echo_buf); command_builder->echo_buf_end = buf_fill_pointer + eilen (buf); - /* *Not* including the trailing " - ". */ + /* Including the first space of the trailing " - ". */ command_builder->echo_buf_fill_pointer = buf_fill_pointer + len + 1; eifree (buf); } @@ -790,6 +793,27 @@ return Qnil; } +/* Return true if should recognize C as "the help character". */ +static Boolint +help_char_p (Lisp_Object event) +{ + if (event_matches_key_specifier_p (event, Vhelp_char)) + { + return 1; + } + + { + EXTERNAL_LIST_LOOP_2 (key_sequence, Vhelp_event_list) + { + if (event_matches_key_specifier_p (event, key_sequence)) + { + return 1; + } + } + } + return 0; +} + static void execute_help_form (struct command_builder *command_builder, Lisp_Object event) @@ -797,18 +821,13 @@ /* This function can GC */ Lisp_Object help = Qnil; int speccount = specpdl_depth (); - Bytecount buf_fill_pointer = command_builder->echo_buf_fill_pointer; - Bytecount buf_end = command_builder->echo_buf_end; - Lisp_Object echo = ((buf_fill_pointer <= 0) ? Qnil - : Fcopy_sequence (command_builder->echo_buf)); - - struct gcpro gcpro1, gcpro2; - GCPRO2 (echo, help); + + struct gcpro gcpro1; + GCPRO1 (help); record_unwind_protect (Feval, list2 (Qset_window_configuration, call0 (Qcurrent_window_configuration))); - reset_key_echo (command_builder, 1); help = IGNORE_MULTIPLE_VALUES (Feval (Vhelp_form)); if (STRINGP (help)) @@ -835,17 +854,11 @@ if (event_matches_key_specifier_p (event, make_char (' '))) { /* Discard next key if it is a space */ - reset_key_echo (command_builder, 1); + /* No need to reset the key echo here. */ + /* reset_key_echo (command_builder, 1); */ Fnext_command_event (event, Qnil); } - command_builder->echo_buf_fill_pointer = buf_fill_pointer; - command_builder->echo_buf_end = buf_end; - - if (buf_fill_pointer > 0) - { - command_builder->echo_buf = echo; - } UNGCPRO; } @@ -2379,8 +2392,7 @@ the help form and swallow this character. Note that execute_help_form() calls Fnext_command_event(), which calls this function, as well as Fdispatch_event. */ - if (!NILP (Vhelp_form) && - event_matches_key_specifier_p (event, Vhelp_char)) + if (!NILP (Vhelp_form) && help_char_p (event)) { /* temporarily reenable quit checking here, because we could get stuck */ Vquit_flag = Qnil; /* see begin_dont_check_for_quit() */ @@ -3396,8 +3408,8 @@ } /* help-char is `auto-bound' in every keymap */ - if (!NILP (Vprefix_help_command) && - event_matches_key_specifier_p (builder->most_current_event, Vhelp_char)) + if (!NILP (Vprefix_help_command) + && help_char_p (builder->most_current_event)) return Vprefix_help_command; return Qnil; @@ -5154,18 +5166,25 @@ Vthis_command_properties = Qnil; DEFVAR_LISP ("help-char", &Vhelp_char /* -Character to recognize as meaning Help. +Key specifier to recognize as meaning Help. When it is read, do `(eval help-form)', and display result if it's a string. -If the value of `help-form' is nil, this char can be read normally. -This can be any form recognized as a single key specifier. -The help-char cannot be a negative number in XEmacs. +If the value of `help-form' is nil, this key can be read normally. +This can be any form recognized as a single key specifier; see +`event-matches-key-specifier-p' and `define-key'. */ ); Vhelp_char = make_char (8); /* C-h */ + DEFVAR_LISP ("help-event-list", &Vhelp_event_list /* +List of extra key specifiers to recognize as meaning Help. +These are in addition to the value of `help-char', which see. They function +in the same way, and can equally be suppressed by binding `help-form' to nil. +*/ ); + Vhelp_event_list = Qnil; + DEFVAR_LISP ("help-form", &Vhelp_form /* -Form to execute when character help-char is read. +Form to execute when `help-char' or an element of `help-event-list' is read. If the form returns a string, that string is displayed. -If `help-form' is nil, the help char is not recognized. +If `help-form' is nil, `help-char' and `help-event-list' are ignored. */ ); Vhelp_form = Qnil;