diff options
| author | Stefan Kangas | 2020-10-18 16:49:55 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-10-18 17:25:23 +0200 |
| commit | 420023a6f066d6ffb85e23ffe3abcfee3d523ea7 (patch) | |
| tree | 15f408b22538e59be8a71d6d4b8eda2e4fbbe606 | |
| parent | ef5a604f082f772424400f48b64e9c04edbcc766 (diff) | |
| download | emacs-scratch/substitute-command-keys.tar.gz emacs-scratch/substitute-command-keys.zip | |
Prefer Lisp version of describer in help--describe-vectorscratch/substitute-command-keys
* src/keymap.c (Fhelp__describe_vector):
* lisp/help.el (describe-map): Use Lisp versions of describe_command
and describe_translation.
* src/keymap.c (describe_command, describe_translation): Remove.
(describe_vector_basic): New function.
| -rw-r--r-- | lisp/help.el | 5 | ||||
| -rw-r--r-- | src/keymap.c | 78 |
2 files changed, 13 insertions, 70 deletions
diff --git a/lisp/help.el b/lisp/help.el index e8dfbdef74a..6ae2664cf41 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -1274,10 +1274,13 @@ TRANSL, PARTIAL, SHADOW, NOMENU, MENTION-SHADOW are as in | |||
| 1274 | (map (keymap-canonicalize map)) | 1274 | (map (keymap-canonicalize map)) |
| 1275 | (tail map) | 1275 | (tail map) |
| 1276 | (first t) | 1276 | (first t) |
| 1277 | (describer (if transl | ||
| 1278 | #'help--describe-translation | ||
| 1279 | #'help--describe-command)) | ||
| 1277 | done vect) | 1280 | done vect) |
| 1278 | (while (and (consp tail) (not done)) | 1281 | (while (and (consp tail) (not done)) |
| 1279 | (cond ((or (vectorp (car tail)) (char-table-p (car tail))) | 1282 | (cond ((or (vectorp (car tail)) (char-table-p (car tail))) |
| 1280 | (help--describe-vector (car tail) prefix transl partial | 1283 | (help--describe-vector (car tail) prefix describer partial |
| 1281 | shadow map mention-shadow)) | 1284 | shadow map mention-shadow)) |
| 1282 | ((consp (car tail)) | 1285 | ((consp (car tail)) |
| 1283 | (let ((event (caar tail)) | 1286 | (let ((event (caar tail)) |
diff --git a/src/keymap.c b/src/keymap.c index 46fa586c753..e5b4781076f 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -89,8 +89,6 @@ static Lisp_Object where_is_cache_keymaps; | |||
| 89 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); | 89 | static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); |
| 90 | 90 | ||
| 91 | static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); | 91 | static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); |
| 92 | static void describe_command (Lisp_Object, Lisp_Object); | ||
| 93 | static void describe_translation (Lisp_Object, Lisp_Object); | ||
| 94 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, | 92 | static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, |
| 95 | void (*) (Lisp_Object, Lisp_Object), bool, | 93 | void (*) (Lisp_Object, Lisp_Object), bool, |
| 96 | Lisp_Object, Lisp_Object, bool, bool); | 94 | Lisp_Object, Lisp_Object, bool, bool); |
| @@ -2943,74 +2941,18 @@ You type Translation\n\ | |||
| 2943 | return Qnil; | 2941 | return Qnil; |
| 2944 | } | 2942 | } |
| 2945 | 2943 | ||
| 2946 | static int previous_description_column; | ||
| 2947 | |||
| 2948 | static void | ||
| 2949 | describe_command (Lisp_Object definition, Lisp_Object args) | ||
| 2950 | { | ||
| 2951 | register Lisp_Object tem1; | ||
| 2952 | ptrdiff_t column = current_column (); | ||
| 2953 | int description_column; | ||
| 2954 | |||
| 2955 | /* If column 16 is no good, go to col 32; | ||
| 2956 | but don't push beyond that--go to next line instead. */ | ||
| 2957 | if (column > 30) | ||
| 2958 | { | ||
| 2959 | insert_char ('\n'); | ||
| 2960 | description_column = 32; | ||
| 2961 | } | ||
| 2962 | else if (column > 14 || (column > 10 && previous_description_column == 32)) | ||
| 2963 | description_column = 32; | ||
| 2964 | else | ||
| 2965 | description_column = 16; | ||
| 2966 | |||
| 2967 | Findent_to (make_fixnum (description_column), make_fixnum (1)); | ||
| 2968 | previous_description_column = description_column; | ||
| 2969 | |||
| 2970 | if (SYMBOLP (definition)) | ||
| 2971 | { | ||
| 2972 | tem1 = SYMBOL_NAME (definition); | ||
| 2973 | insert1 (tem1); | ||
| 2974 | insert_string ("\n"); | ||
| 2975 | } | ||
| 2976 | else if (STRINGP (definition) || VECTORP (definition)) | ||
| 2977 | insert_string ("Keyboard Macro\n"); | ||
| 2978 | else if (KEYMAPP (definition)) | ||
| 2979 | insert_string ("Prefix Command\n"); | ||
| 2980 | else | ||
| 2981 | insert_string ("??\n"); | ||
| 2982 | } | ||
| 2983 | |||
| 2984 | static void | 2944 | static void |
| 2985 | describe_translation (Lisp_Object definition, Lisp_Object args) | 2945 | describe_vector_princ (Lisp_Object elt, Lisp_Object fun) |
| 2986 | { | 2946 | { |
| 2987 | register Lisp_Object tem1; | ||
| 2988 | |||
| 2989 | Findent_to (make_fixnum (16), make_fixnum (1)); | 2947 | Findent_to (make_fixnum (16), make_fixnum (1)); |
| 2990 | 2948 | call1 (fun, elt); | |
| 2991 | if (SYMBOLP (definition)) | 2949 | Fterpri (Qnil, Qnil); |
| 2992 | { | ||
| 2993 | tem1 = SYMBOL_NAME (definition); | ||
| 2994 | insert1 (tem1); | ||
| 2995 | insert_string ("\n"); | ||
| 2996 | } | ||
| 2997 | else if (STRINGP (definition) || VECTORP (definition)) | ||
| 2998 | { | ||
| 2999 | insert1 (Fkey_description (definition, Qnil)); | ||
| 3000 | insert_string ("\n"); | ||
| 3001 | } | ||
| 3002 | else if (KEYMAPP (definition)) | ||
| 3003 | insert_string ("Prefix Command\n"); | ||
| 3004 | else | ||
| 3005 | insert_string ("??\n"); | ||
| 3006 | } | 2950 | } |
| 3007 | 2951 | ||
| 3008 | static void | 2952 | static void |
| 3009 | describe_vector_princ (Lisp_Object elt, Lisp_Object fun) | 2953 | describe_vector_basic (Lisp_Object elt, Lisp_Object fun) |
| 3010 | { | 2954 | { |
| 3011 | Findent_to (make_fixnum (16), make_fixnum (1)); | ||
| 3012 | call1 (fun, elt); | 2955 | call1 (fun, elt); |
| 3013 | Fterpri (Qnil, Qnil); | ||
| 3014 | } | 2956 | } |
| 3015 | 2957 | ||
| 3016 | DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0, | 2958 | DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0, |
| @@ -3032,6 +2974,7 @@ DESCRIBER is the output function used; nil means use `princ'. */) | |||
| 3032 | 2974 | ||
| 3033 | DEFUN ("help--describe-vector", Fhelp__describe_vector, Shelp__describe_vector, 7, 7, 0, | 2975 | DEFUN ("help--describe-vector", Fhelp__describe_vector, Shelp__describe_vector, 7, 7, 0, |
| 3034 | doc: /* Insert in the current buffer a description of the contents of VECTOR. | 2976 | doc: /* Insert in the current buffer a description of the contents of VECTOR. |
| 2977 | Call DESCRIBER to insert the description of one value found in VECTOR. | ||
| 3035 | 2978 | ||
| 3036 | PREFIX is a string describing the key which leads to the keymap that | 2979 | PREFIX is a string describing the key which leads to the keymap that |
| 3037 | this vector is in. | 2980 | this vector is in. |
| @@ -3045,7 +2988,7 @@ if it is defined by any of them. | |||
| 3045 | ENTIRE-MAP is the keymap in which this vector appears. | 2988 | ENTIRE-MAP is the keymap in which this vector appears. |
| 3046 | If the definition in effect in the whole map does not match | 2989 | If the definition in effect in the whole map does not match |
| 3047 | the one in this keymap, we ignore this one. */) | 2990 | the one in this keymap, we ignore this one. */) |
| 3048 | (Lisp_Object vector, Lisp_Object prefix, Lisp_Object transl, | 2991 | (Lisp_Object vector, Lisp_Object prefix, Lisp_Object describer, |
| 3049 | Lisp_Object partial, Lisp_Object shadow, Lisp_Object entire_map, | 2992 | Lisp_Object partial, Lisp_Object shadow, Lisp_Object entire_map, |
| 3050 | Lisp_Object mention_shadow) | 2993 | Lisp_Object mention_shadow) |
| 3051 | { | 2994 | { |
| @@ -3053,19 +2996,16 @@ the one in this keymap, we ignore this one. */) | |||
| 3053 | specbind (Qstandard_output, Fcurrent_buffer ()); | 2996 | specbind (Qstandard_output, Fcurrent_buffer ()); |
| 3054 | CHECK_VECTOR_OR_CHAR_TABLE (vector); | 2997 | CHECK_VECTOR_OR_CHAR_TABLE (vector); |
| 3055 | 2998 | ||
| 3056 | bool b_transl = NILP (transl) ? false : true; | ||
| 3057 | bool b_partial = NILP (partial) ? false : true; | 2999 | bool b_partial = NILP (partial) ? false : true; |
| 3058 | bool b_mention_shadow = NILP (mention_shadow) ? false : true; | 3000 | bool b_mention_shadow = NILP (mention_shadow) ? false : true; |
| 3059 | 3001 | ||
| 3060 | describe_vector (vector, prefix, Qnil, | 3002 | describe_vector (vector, prefix, describer, describe_vector_basic, b_partial, |
| 3061 | b_transl ? describe_translation : describe_command, | 3003 | shadow, entire_map, true, b_mention_shadow); |
| 3062 | b_partial, shadow, entire_map, | ||
| 3063 | true, b_mention_shadow); | ||
| 3064 | return unbind_to (count, Qnil); | 3004 | return unbind_to (count, Qnil); |
| 3065 | } | 3005 | } |
| 3066 | 3006 | ||
| 3067 | /* Insert in the current buffer a description of the contents of VECTOR. | 3007 | /* Insert in the current buffer a description of the contents of VECTOR. |
| 3068 | We call ELT_DESCRIBER to insert the description of one value found | 3008 | Call ELT_DESCRIBER to insert the description of one value found |
| 3069 | in VECTOR. | 3009 | in VECTOR. |
| 3070 | 3010 | ||
| 3071 | ELT_PREFIX describes what "comes before" the keys or indices defined | 3011 | ELT_PREFIX describes what "comes before" the keys or indices defined |