diff options
| author | Stefan Kangas | 2019-07-08 18:37:50 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-10-18 17:23:24 +0200 |
| commit | dcf9cd47ae71e39eb616d77acb531ac11357391f (patch) | |
| tree | b677b2916ad50bfe3932829396436154cfbb0ce6 /src | |
| parent | 282f35083c02ace9b287dc311bef1d16721e6c0c (diff) | |
| download | emacs-dcf9cd47ae71e39eb616d77acb531ac11357391f.tar.gz emacs-dcf9cd47ae71e39eb616d77acb531ac11357391f.zip | |
Add new Lisp implementation of substitute-command-keys
This is only the first step towards a full Lisp implementation, and
does not remove the old C code. On the contrary, it is partly based
on using the old C code, which is to be replaced in steps. This also
makes it easy to test that it produces the same output as the old.
* src/doc.c (Fsubstitute_command_keys_old): Rename from
Fsubstitute_command_keys.
(Fget_quoting_style): New defun to expose text_quoting_style to Lisp.
(syms_of_doc): Expose above symbols.
* lisp/help.el (substitute-command-keys): New Lisp version of
substitute-command-keys. (Bug#8951)
* src/keymap.c
(Fdescribe_map_tree): New defun to expose describe_map_tree to Lisp.
(syms_of_keymap): New defsubr for Fdescribe_map_tree.
* src/keyboard.c (help_echo_substitute_command_keys):
* src/doc.c (Fdocumentation, Fdocumentation_property):
* src/print.c (print_error_message):
* src/syntax.c (Finternal_describe_syntax_value): Fix calls to use new
Lisp implementation of substitute-command-keys.
* test/src/doc-tests.el: Remove file.
* test/lisp/help-tests.el: Add tests for substitute-command-keys
copied from above file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 36 | ||||
| -rw-r--r-- | src/keyboard.c | 4 | ||||
| -rw-r--r-- | src/keymap.c | 32 | ||||
| -rw-r--r-- | src/print.c | 2 | ||||
| -rw-r--r-- | src/syntax.c | 2 |
5 files changed, 65 insertions, 11 deletions
| @@ -415,7 +415,7 @@ string is passed through `substitute-command-keys'. */) | |||
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | if (NILP (raw)) | 417 | if (NILP (raw)) |
| 418 | doc = Fsubstitute_command_keys (doc); | 418 | doc = call1 (Qsubstitute_command_keys, doc); |
| 419 | return doc; | 419 | return doc; |
| 420 | } | 420 | } |
| 421 | 421 | ||
| @@ -472,7 +472,7 @@ aren't strings. */) | |||
| 472 | tem = Feval (tem, Qnil); | 472 | tem = Feval (tem, Qnil); |
| 473 | 473 | ||
| 474 | if (NILP (raw) && STRINGP (tem)) | 474 | if (NILP (raw) && STRINGP (tem)) |
| 475 | tem = Fsubstitute_command_keys (tem); | 475 | tem = call1 (Qsubstitute_command_keys, tem); |
| 476 | return tem; | 476 | return tem; |
| 477 | } | 477 | } |
| 478 | 478 | ||
| @@ -696,8 +696,27 @@ text_quoting_style (void) | |||
| 696 | return CURVE_QUOTING_STYLE; | 696 | return CURVE_QUOTING_STYLE; |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 699 | DEFUN ("substitute-command-keys", Fsubstitute_command_keys, | 699 | /* This is just a Lisp wrapper for text_quoting_style above. */ |
| 700 | Ssubstitute_command_keys, 1, 1, 0, | 700 | DEFUN ("get-quoting-style", Fget_quoting_style, |
| 701 | Sget_quoting_style, 0, 0, 0, | ||
| 702 | doc: /* Return the current effective text quoting style. | ||
| 703 | See variable `text-quoting-style'. */) | ||
| 704 | (void) | ||
| 705 | { | ||
| 706 | switch (text_quoting_style ()) | ||
| 707 | { | ||
| 708 | case STRAIGHT_QUOTING_STYLE: | ||
| 709 | return Qstraight; | ||
| 710 | case CURVE_QUOTING_STYLE: | ||
| 711 | return Qcurve; | ||
| 712 | case GRAVE_QUOTING_STYLE: | ||
| 713 | default: | ||
| 714 | return Qgrave; | ||
| 715 | } | ||
| 716 | } | ||
| 717 | |||
| 718 | DEFUN ("substitute-command-keys-old", Fsubstitute_command_keys_old, | ||
| 719 | Ssubstitute_command_keys_old, 1, 1, 0, | ||
| 701 | doc: /* Substitute key descriptions for command names in STRING. | 720 | doc: /* Substitute key descriptions for command names in STRING. |
| 702 | Each substring of the form \\=\\[COMMAND] is replaced by either a | 721 | Each substring of the form \\=\\[COMMAND] is replaced by either a |
| 703 | keystroke sequence that invokes COMMAND, or "M-x COMMAND" if COMMAND | 722 | keystroke sequence that invokes COMMAND, or "M-x COMMAND" if COMMAND |
| @@ -884,12 +903,12 @@ Otherwise, return a new string (without any text properties). */) | |||
| 884 | { | 903 | { |
| 885 | name = Fsymbol_name (name); | 904 | name = Fsymbol_name (name); |
| 886 | AUTO_STRING (msg_prefix, "\nUses keymap `"); | 905 | AUTO_STRING (msg_prefix, "\nUses keymap `"); |
| 887 | insert1 (Fsubstitute_command_keys (msg_prefix)); | 906 | insert1 (Fsubstitute_command_keys_old (msg_prefix)); |
| 888 | insert_from_string (name, 0, 0, | 907 | insert_from_string (name, 0, 0, |
| 889 | SCHARS (name), | 908 | SCHARS (name), |
| 890 | SBYTES (name), 1); | 909 | SBYTES (name), 1); |
| 891 | AUTO_STRING (msg_suffix, "', which is not currently defined.\n"); | 910 | AUTO_STRING (msg_suffix, "', which is not currently defined.\n"); |
| 892 | insert1 (Fsubstitute_command_keys (msg_suffix)); | 911 | insert1 (Fsubstitute_command_keys_old (msg_suffix)); |
| 893 | if (!generate_summary) | 912 | if (!generate_summary) |
| 894 | keymap = Qnil; | 913 | keymap = Qnil; |
| 895 | } | 914 | } |
| @@ -1002,9 +1021,11 @@ Otherwise, return a new string (without any text properties). */) | |||
| 1002 | void | 1021 | void |
| 1003 | syms_of_doc (void) | 1022 | syms_of_doc (void) |
| 1004 | { | 1023 | { |
| 1024 | DEFSYM (Qsubstitute_command_keys, "substitute-command-keys"); | ||
| 1005 | DEFSYM (Qfunction_documentation, "function-documentation"); | 1025 | DEFSYM (Qfunction_documentation, "function-documentation"); |
| 1006 | DEFSYM (Qgrave, "grave"); | 1026 | DEFSYM (Qgrave, "grave"); |
| 1007 | DEFSYM (Qstraight, "straight"); | 1027 | DEFSYM (Qstraight, "straight"); |
| 1028 | DEFSYM (Qcurve, "curve"); | ||
| 1008 | 1029 | ||
| 1009 | DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name, | 1030 | DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name, |
| 1010 | doc: /* Name of file containing documentation strings of built-in symbols. */); | 1031 | doc: /* Name of file containing documentation strings of built-in symbols. */); |
| @@ -1036,5 +1057,6 @@ otherwise. */); | |||
| 1036 | defsubr (&Sdocumentation); | 1057 | defsubr (&Sdocumentation); |
| 1037 | defsubr (&Sdocumentation_property); | 1058 | defsubr (&Sdocumentation_property); |
| 1038 | defsubr (&Ssnarf_documentation); | 1059 | defsubr (&Ssnarf_documentation); |
| 1039 | defsubr (&Ssubstitute_command_keys); | 1060 | defsubr (&Sget_quoting_style); |
| 1061 | defsubr (&Ssubstitute_command_keys_old); | ||
| 1040 | } | 1062 | } |
diff --git a/src/keyboard.c b/src/keyboard.c index 10d2f6323ed..2e0143379a0 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2040,7 +2040,7 @@ help_echo_substitute_command_keys (Lisp_Object help) | |||
| 2040 | help))) | 2040 | help))) |
| 2041 | return help; | 2041 | return help; |
| 2042 | 2042 | ||
| 2043 | return Fsubstitute_command_keys (help); | 2043 | return call1 (Qsubstitute_command_keys, help); |
| 2044 | } | 2044 | } |
| 2045 | 2045 | ||
| 2046 | /* Display the help-echo property of the character after the mouse pointer. | 2046 | /* Display the help-echo property of the character after the mouse pointer. |
| @@ -7856,7 +7856,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) | |||
| 7856 | /* The previous code preferred :key-sequence to :keys, so we | 7856 | /* The previous code preferred :key-sequence to :keys, so we |
| 7857 | preserve this behavior. */ | 7857 | preserve this behavior. */ |
| 7858 | if (STRINGP (keyeq) && !CONSP (keyhint)) | 7858 | if (STRINGP (keyeq) && !CONSP (keyhint)) |
| 7859 | keyeq = concat2 (space_space, Fsubstitute_command_keys (keyeq)); | 7859 | keyeq = concat2 (space_space, call1 (Qsubstitute_command_keys, keyeq)); |
| 7860 | else | 7860 | else |
| 7861 | { | 7861 | { |
| 7862 | Lisp_Object prefix = keyeq; | 7862 | Lisp_Object prefix = keyeq; |
diff --git a/src/keymap.c b/src/keymap.c index 0608bdddeea..05b0814c475 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2915,6 +2915,37 @@ You type Translation\n\ | |||
| 2915 | 2915 | ||
| 2916 | Any inserted text ends in two newlines (used by `help-make-xrefs'). */ | 2916 | Any inserted text ends in two newlines (used by `help-make-xrefs'). */ |
| 2917 | 2917 | ||
| 2918 | DEFUN ("describe-map-tree", Fdescribe_map_tree, Sdescribe_map_tree, 1, 8, 0, | ||
| 2919 | doc: /* This is just temporary. */) | ||
| 2920 | (Lisp_Object startmap, Lisp_Object partial, Lisp_Object shadow, | ||
| 2921 | Lisp_Object prefix, Lisp_Object title, Lisp_Object nomenu, | ||
| 2922 | Lisp_Object transl, Lisp_Object always_title) | ||
| 2923 | { | ||
| 2924 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 2925 | char *title_string; | ||
| 2926 | |||
| 2927 | if ( !NILP (title) ) | ||
| 2928 | { | ||
| 2929 | CHECK_STRING (title); | ||
| 2930 | title_string = SSDATA(title); | ||
| 2931 | } | ||
| 2932 | else | ||
| 2933 | { | ||
| 2934 | title_string = NULL; | ||
| 2935 | } | ||
| 2936 | |||
| 2937 | bool b_partial = NILP (partial) ? false : true; | ||
| 2938 | bool b_nomenu = NILP (nomenu) ? false : true; | ||
| 2939 | bool b_transl = NILP (transl) ? false : true; | ||
| 2940 | bool b_always_title = NILP (always_title) ? false : true; | ||
| 2941 | |||
| 2942 | /* specbind (Qstandard_output, Fcurrent_buffer ()); */ | ||
| 2943 | describe_map_tree (startmap, b_partial, shadow, prefix, title_string, | ||
| 2944 | b_nomenu, b_transl, b_always_title, true); | ||
| 2945 | |||
| 2946 | return unbind_to (count, Qnil); | ||
| 2947 | } | ||
| 2948 | |||
| 2918 | void | 2949 | void |
| 2919 | describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow, | 2950 | describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow, |
| 2920 | Lisp_Object prefix, const char *title, bool nomenu, | 2951 | Lisp_Object prefix, const char *title, bool nomenu, |
| @@ -3708,6 +3739,7 @@ be preferred. */); | |||
| 3708 | defsubr (&Scurrent_active_maps); | 3739 | defsubr (&Scurrent_active_maps); |
| 3709 | defsubr (&Saccessible_keymaps); | 3740 | defsubr (&Saccessible_keymaps); |
| 3710 | defsubr (&Skey_description); | 3741 | defsubr (&Skey_description); |
| 3742 | defsubr (&Sdescribe_map_tree); | ||
| 3711 | defsubr (&Sdescribe_vector); | 3743 | defsubr (&Sdescribe_vector); |
| 3712 | defsubr (&Ssingle_key_description); | 3744 | defsubr (&Ssingle_key_description); |
| 3713 | defsubr (&Stext_char_description); | 3745 | defsubr (&Stext_char_description); |
diff --git a/src/print.c b/src/print.c index dca095f2812..53aa353769b 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -941,7 +941,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 941 | else | 941 | else |
| 942 | { | 942 | { |
| 943 | Lisp_Object error_conditions = Fget (errname, Qerror_conditions); | 943 | Lisp_Object error_conditions = Fget (errname, Qerror_conditions); |
| 944 | errmsg = Fsubstitute_command_keys (Fget (errname, Qerror_message)); | 944 | errmsg = call1 (Qsubstitute_command_keys, Fget (errname, Qerror_message)); |
| 945 | file_error = Fmemq (Qfile_error, error_conditions); | 945 | file_error = Fmemq (Qfile_error, error_conditions); |
| 946 | } | 946 | } |
| 947 | 947 | ||
diff --git a/src/syntax.c b/src/syntax.c index 066972e6d88..df07809aaaf 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1421,7 +1421,7 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1421 | { | 1421 | { |
| 1422 | AUTO_STRING (prefixdoc, | 1422 | AUTO_STRING (prefixdoc, |
| 1423 | ",\n\t is a prefix character for `backward-prefix-chars'"); | 1423 | ",\n\t is a prefix character for `backward-prefix-chars'"); |
| 1424 | insert1 (Fsubstitute_command_keys (prefixdoc)); | 1424 | insert1 (call1 (Qsubstitute_command_keys, prefixdoc)); |
| 1425 | } | 1425 | } |
| 1426 | 1426 | ||
| 1427 | return syntax; | 1427 | return syntax; |