aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorStefan Kangas2020-10-18 15:32:22 +0200
committerStefan Kangas2020-10-18 17:25:23 +0200
commit8a1441310aa151e739cfed3bd2eff3358edc8001 (patch)
treeaf158ee0c497e53ba021e14329607b271975946e /src/keymap.c
parentafde53cd81c7817c5b3187e60e7a49790e0af832 (diff)
downloademacs-8a1441310aa151e739cfed3bd2eff3358edc8001.tar.gz
emacs-8a1441310aa151e739cfed3bd2eff3358edc8001.zip
Prefer Lisp version of describe-map-tree
This is a prerequisite to remove the old C functions, and gives a measured 3 ms slowdown on my machine, from 0.27s to 0.30s per call to describe-buffer-bindings (average over 50 calls). * src/keymap.c (Fdescribe_buffer_bindings): Call Lisp function describe-map-tree instead of C function describe_map_tree.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c89
1 files changed, 63 insertions, 26 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 5ae8da6a05a..1eded130b5d 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2750,7 +2750,7 @@ The optional argument MENUS, if non-nil, says to mention menu bindings.
2750 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) 2750 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus)
2751{ 2751{
2752 Lisp_Object outbuf, shadow; 2752 Lisp_Object outbuf, shadow;
2753 bool nomenu = NILP (menus); 2753 Lisp_Object nomenu = NILP (menus) ? Qt : Qnil;
2754 Lisp_Object start1; 2754 Lisp_Object start1;
2755 2755
2756 const char *alternate_heading 2756 const char *alternate_heading
@@ -2799,9 +2799,13 @@ You type Translation\n\
2799 } 2799 }
2800 2800
2801 if (!NILP (Vkey_translation_map)) 2801 if (!NILP (Vkey_translation_map))
2802 describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, 2802 {
2803 "Key translations", nomenu, 1, 0, 0); 2803 Lisp_Object msg = build_unibyte_string ("Key translations");
2804 2804 CALLN (Ffuncall,
2805 Qdescribe_map_tree,
2806 Vkey_translation_map, Qnil, Qnil, prefix,
2807 msg, nomenu, Qt, Qnil, Qnil);
2808 }
2805 2809
2806 /* Print the (major mode) local map. */ 2810 /* Print the (major mode) local map. */
2807 start1 = Qnil; 2811 start1 = Qnil;
@@ -2810,8 +2814,11 @@ You type Translation\n\
2810 2814
2811 if (!NILP (start1)) 2815 if (!NILP (start1))
2812 { 2816 {
2813 describe_map_tree (start1, 1, shadow, prefix, 2817 Lisp_Object msg = build_unibyte_string ("\f\nOverriding Bindings");
2814 "\f\nOverriding Bindings", nomenu, 0, 0, 0); 2818 CALLN (Ffuncall,
2819 Qdescribe_map_tree,
2820 start1, Qt, shadow, prefix,
2821 msg, nomenu, Qnil, Qnil, Qnil);
2815 shadow = Fcons (start1, shadow); 2822 shadow = Fcons (start1, shadow);
2816 start1 = Qnil; 2823 start1 = Qnil;
2817 } 2824 }
@@ -2820,8 +2827,11 @@ You type Translation\n\
2820 2827
2821 if (!NILP (start1)) 2828 if (!NILP (start1))
2822 { 2829 {
2823 describe_map_tree (start1, 1, shadow, prefix, 2830 Lisp_Object msg = build_unibyte_string ("\f\nOverriding Bindings");
2824 "\f\nOverriding Bindings", nomenu, 0, 0, 0); 2831 CALLN (Ffuncall,
2832 Qdescribe_map_tree,
2833 start1, Qt, shadow, prefix,
2834 msg, nomenu, Qnil, Qnil, Qnil);
2825 shadow = Fcons (start1, shadow); 2835 shadow = Fcons (start1, shadow);
2826 } 2836 }
2827 else 2837 else
@@ -2841,9 +2851,11 @@ You type Translation\n\
2841 XBUFFER (buffer), Qkeymap); 2851 XBUFFER (buffer), Qkeymap);
2842 if (!NILP (start1)) 2852 if (!NILP (start1))
2843 { 2853 {
2844 describe_map_tree (start1, 1, shadow, prefix, 2854 Lisp_Object msg = build_unibyte_string ("\f\n`keymap' Property Bindings");
2845 "\f\n`keymap' Property Bindings", nomenu, 2855 CALLN (Ffuncall,
2846 0, 0, 0); 2856 Qdescribe_map_tree,
2857 start1, Qt, shadow, prefix,
2858 msg, nomenu, Qnil, Qnil, Qnil);
2847 shadow = Fcons (start1, shadow); 2859 shadow = Fcons (start1, shadow);
2848 } 2860 }
2849 2861
@@ -2852,7 +2864,7 @@ You type Translation\n\
2852 { 2864 {
2853 /* The title for a minor mode keymap 2865 /* The title for a minor mode keymap
2854 is constructed at run time. 2866 is constructed at run time.
2855 We let describe_map_tree do the actual insertion 2867 We let describe-map-tree do the actual insertion
2856 because it takes care of other features when doing so. */ 2868 because it takes care of other features when doing so. */
2857 char *title, *p; 2869 char *title, *p;
2858 2870
@@ -2872,8 +2884,11 @@ You type Translation\n\
2872 p += strlen (" Minor Mode Bindings"); 2884 p += strlen (" Minor Mode Bindings");
2873 *p = 0; 2885 *p = 0;
2874 2886
2875 describe_map_tree (maps[i], 1, shadow, prefix, 2887 Lisp_Object msg = build_unibyte_string (title);
2876 title, nomenu, 0, 0, 0); 2888 CALLN (Ffuncall,
2889 Qdescribe_map_tree,
2890 maps[i], Qt, shadow, prefix,
2891 msg, nomenu, Qnil, Qnil, Qnil);
2877 shadow = Fcons (maps[i], shadow); 2892 shadow = Fcons (maps[i], shadow);
2878 SAFE_FREE (); 2893 SAFE_FREE ();
2879 } 2894 }
@@ -2883,30 +2898,51 @@ You type Translation\n\
2883 if (!NILP (start1)) 2898 if (!NILP (start1))
2884 { 2899 {
2885 if (EQ (start1, BVAR (XBUFFER (buffer), keymap))) 2900 if (EQ (start1, BVAR (XBUFFER (buffer), keymap)))
2886 describe_map_tree (start1, 1, shadow, prefix, 2901 {
2887 "\f\nMajor Mode Bindings", nomenu, 0, 0, 0); 2902 Lisp_Object msg = build_unibyte_string ("\f\nMajor Mode Bindings");
2903 CALLN (Ffuncall,
2904 Qdescribe_map_tree,
2905 start1, Qt, shadow, prefix,
2906 msg, nomenu, Qnil, Qnil, Qnil);
2907 }
2888 else 2908 else
2889 describe_map_tree (start1, 1, shadow, prefix, 2909 {
2890 "\f\n`local-map' Property Bindings", 2910 Lisp_Object msg = build_unibyte_string ("\f\n`local-map' Property Bindings");
2891 nomenu, 0, 0, 0); 2911 CALLN (Ffuncall,
2912 Qdescribe_map_tree,
2913 start1, Qt, shadow, prefix,
2914 msg, nomenu, Qnil, Qnil, Qnil);
2915 }
2892 2916
2893 shadow = Fcons (start1, shadow); 2917 shadow = Fcons (start1, shadow);
2894 } 2918 }
2895 } 2919 }
2896 2920
2897 describe_map_tree (current_global_map, 1, shadow, prefix, 2921 Lisp_Object msg = build_unibyte_string ("\f\nGlobal Bindings");
2898 "\f\nGlobal Bindings", nomenu, 0, 1, 0); 2922 CALLN (Ffuncall,
2923 Qdescribe_map_tree,
2924 current_global_map, Qt, shadow, prefix,
2925 msg, nomenu, Qnil, Qt, Qnil);
2899 2926
2900 /* Print the function-key-map translations under this prefix. */ 2927 /* Print the function-key-map translations under this prefix. */
2901 if (!NILP (KVAR (current_kboard, Vlocal_function_key_map))) 2928 if (!NILP (KVAR (current_kboard, Vlocal_function_key_map)))
2902 describe_map_tree (KVAR (current_kboard, Vlocal_function_key_map), 0, Qnil, prefix, 2929 {
2903 "\f\nFunction key map translations", nomenu, 1, 0, 0); 2930 Lisp_Object msg = build_unibyte_string ("\f\nFunction key map translations");
2931 CALLN (Ffuncall,
2932 Qdescribe_map_tree,
2933 KVAR (current_kboard, Vlocal_function_key_map), Qnil, Qnil, prefix,
2934 msg, nomenu, Qt, Qt, Qt);
2935 }
2904 2936
2905 /* Print the input-decode-map translations under this prefix. */ 2937 /* Print the input-decode-map translations under this prefix. */
2906 if (!NILP (KVAR (current_kboard, Vinput_decode_map))) 2938 if (!NILP (KVAR (current_kboard, Vinput_decode_map)))
2907 describe_map_tree (KVAR (current_kboard, Vinput_decode_map), 0, Qnil, prefix, 2939 {
2908 "\f\nInput decoding map translations", nomenu, 1, 0, 0); 2940 Lisp_Object msg = build_unibyte_string ("\f\nInput decoding map translations");
2909 2941 CALLN (Ffuncall,
2942 Qdescribe_map_tree,
2943 KVAR (current_kboard, Vinput_decode_map), Qnil, Qnil, prefix,
2944 msg, nomenu, Qt, Qnil, Qnil);
2945 }
2910 return Qnil; 2946 return Qnil;
2911} 2947}
2912 2948
@@ -3619,6 +3655,7 @@ void
3619syms_of_keymap (void) 3655syms_of_keymap (void)
3620{ 3656{
3621 DEFSYM (Qkeymap, "keymap"); 3657 DEFSYM (Qkeymap, "keymap");
3658 DEFSYM (Qdescribe_map_tree, "describe-map-tree");
3622 staticpro (&apropos_predicate); 3659 staticpro (&apropos_predicate);
3623 staticpro (&apropos_accumulate); 3660 staticpro (&apropos_accumulate);
3624 apropos_predicate = Qnil; 3661 apropos_predicate = Qnil;