diff options
| author | Stefan Kangas | 2021-03-08 03:29:42 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-03-08 04:23:08 +0100 |
| commit | 4a112fd7a6f0dcbd1b99b811b324123f5699bdfb (patch) | |
| tree | b3816a8ab7f3a05785ead1a590d0ab2dc5cd2921 /src | |
| parent | 8e103ebef12bb723723c7e6ec8e1053e86878a5b (diff) | |
| download | emacs-4a112fd7a6f0dcbd1b99b811b324123f5699bdfb.tar.gz emacs-4a112fd7a6f0dcbd1b99b811b324123f5699bdfb.zip | |
Add new face 'help-key-binding' for keybindings in help
* lisp/faces.el (help-key-binding): New face.
* lisp/help.el
(help-for-help): Rename from 'help-for-help-internal'. Use
'substitute-command-keys' syntax.
(help): Make into alias for 'help-for-help'.
(help-for-help-internal): Make into obsolete alias for
'help-for-help'.
(help--key-description-fontified): New function to add the
'help-key-binding' face.
(help-key-description, substitute-command-keys)
(describe-map-tree, help--describe-command)
(help--describe-translation, describe-map):
* lisp/help-fns.el (help-fns--key-bindings, describe-mode):
Use above new function.
* lisp/isearch.el (isearch-help-for-help-internal): Use
`substitute-command-keys' syntax.
* lisp/help-macro.el (make-help-screen): Use
'substitute-command-keys' and 'help--key-description-fontified'.
Simplify.
* src/keymap.c (describe_key_maybe_fontify): New function to add
the 'help-key-binding' face to keybindings.
(describe_vector): Use above new keybinding.
(syms_of_keymap) <Qfont_lock_face, Qhelp_key_binding>: New
DEFSYMs.
(fontify_key_properties): New static variable.
* lisp/tooltip.el (tooltip-show): Avoid overriding faces in
specified tooltip text.
* test/lisp/help-tests.el (with-substitute-command-keys-test):
Don't test for text properties.
(help-tests-substitute-command-keys/add-key-face)
(help-tests-substitute-command-keys/add-key-face-listing):
New tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/keymap.c b/src/keymap.c index 782931fadff..bb26b6389d4 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2846,6 +2846,21 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 2846 | return unbind_to (count, Qnil); | 2846 | return unbind_to (count, Qnil); |
| 2847 | } | 2847 | } |
| 2848 | 2848 | ||
| 2849 | static Lisp_Object fontify_key_properties; | ||
| 2850 | |||
| 2851 | static Lisp_Object | ||
| 2852 | describe_key_maybe_fontify (Lisp_Object str, Lisp_Object prefix, | ||
| 2853 | bool keymap_p) | ||
| 2854 | { | ||
| 2855 | Lisp_Object key_desc = Fkey_description (str, prefix); | ||
| 2856 | if (keymap_p) | ||
| 2857 | Fadd_text_properties (make_fixnum (0), | ||
| 2858 | make_fixnum (SCHARS (key_desc)), | ||
| 2859 | fontify_key_properties, | ||
| 2860 | key_desc); | ||
| 2861 | return key_desc; | ||
| 2862 | } | ||
| 2863 | |||
| 2849 | DEFUN ("help--describe-vector", Fhelp__describe_vector, Shelp__describe_vector, 7, 7, 0, | 2864 | DEFUN ("help--describe-vector", Fhelp__describe_vector, Shelp__describe_vector, 7, 7, 0, |
| 2850 | doc: /* Insert in the current buffer a description of the contents of VECTOR. | 2865 | doc: /* Insert in the current buffer a description of the contents of VECTOR. |
| 2851 | Call DESCRIBER to insert the description of one value found in VECTOR. | 2866 | Call DESCRIBER to insert the description of one value found in VECTOR. |
| @@ -3021,7 +3036,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | |||
| 3021 | if (!NILP (elt_prefix)) | 3036 | if (!NILP (elt_prefix)) |
| 3022 | insert1 (elt_prefix); | 3037 | insert1 (elt_prefix); |
| 3023 | 3038 | ||
| 3024 | insert1 (Fkey_description (kludge, prefix)); | 3039 | insert1 (describe_key_maybe_fontify (kludge, prefix, keymap_p)); |
| 3025 | 3040 | ||
| 3026 | /* Find all consecutive characters or rows that have the same | 3041 | /* Find all consecutive characters or rows that have the same |
| 3027 | definition. But, if VECTOR is a char-table, we had better | 3042 | definition. But, if VECTOR is a char-table, we had better |
| @@ -3071,7 +3086,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, | |||
| 3071 | if (!NILP (elt_prefix)) | 3086 | if (!NILP (elt_prefix)) |
| 3072 | insert1 (elt_prefix); | 3087 | insert1 (elt_prefix); |
| 3073 | 3088 | ||
| 3074 | insert1 (Fkey_description (kludge, prefix)); | 3089 | insert1 (describe_key_maybe_fontify (kludge, prefix, keymap_p)); |
| 3075 | } | 3090 | } |
| 3076 | 3091 | ||
| 3077 | /* Print a description of the definition of this character. | 3092 | /* Print a description of the definition of this character. |
| @@ -3200,6 +3215,12 @@ be preferred. */); | |||
| 3200 | staticpro (&where_is_cache); | 3215 | staticpro (&where_is_cache); |
| 3201 | staticpro (&where_is_cache_keymaps); | 3216 | staticpro (&where_is_cache_keymaps); |
| 3202 | 3217 | ||
| 3218 | DEFSYM (Qfont_lock_face, "font-lock-face"); | ||
| 3219 | DEFSYM (Qhelp_key_binding, "help-key-binding"); | ||
| 3220 | staticpro (&fontify_key_properties); | ||
| 3221 | fontify_key_properties = Fcons (Qfont_lock_face, | ||
| 3222 | Fcons (Qhelp_key_binding, Qnil)); | ||
| 3223 | |||
| 3203 | defsubr (&Skeymapp); | 3224 | defsubr (&Skeymapp); |
| 3204 | defsubr (&Skeymap_parent); | 3225 | defsubr (&Skeymap_parent); |
| 3205 | defsubr (&Skeymap_prompt); | 3226 | defsubr (&Skeymap_prompt); |