aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-07-28 02:57:41 +0000
committerRichard M. Stallman1995-07-28 02:57:41 +0000
commitd7bf9bf5e41a99118a7d16a8fe9fcf98820ada0e (patch)
tree0c4eb5df999b8c9bad8f28a32c2a97d685b392a5 /src
parent4f875022f2ebcd5f37f2015c88db5d152b83306b (diff)
downloademacs-d7bf9bf5e41a99118a7d16a8fe9fcf98820ada0e.tar.gz
emacs-d7bf9bf5e41a99118a7d16a8fe9fcf98820ada0e.zip
(describe_buffer_bindings): Print bindings from
Vfunction_key_map and from Vkey_translation_map. (describe_translation): New function. (describe_command): Handle vector like string. (describe_map_tree): New arg TRANSL. Callers changed.
Diffstat (limited to 'src')
-rw-r--r--src/keymap.c68
1 files changed, 59 insertions, 9 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 034b5d64260..fd98df15d2b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -73,6 +73,9 @@ Lisp_Object Vminor_mode_map_alist;
73 documentation. */ 73 documentation. */
74Lisp_Object Vfunction_key_map; 74Lisp_Object Vfunction_key_map;
75 75
76/* Keymap mapping ASCII function key sequences onto their preferred forms. */
77Lisp_Object Vkey_translation_map;
78
76/* A list of all commands given new bindings since a certain time 79/* A list of all commands given new bindings since a certain time
77 when nil was stored here. 80 when nil was stored here.
78 This is used to speed up recomputation of menu key equivalents 81 This is used to speed up recomputation of menu key equivalents
@@ -90,7 +93,7 @@ extern Lisp_Object Voverriding_local_map;
90 93
91static Lisp_Object define_as_prefix (); 94static Lisp_Object define_as_prefix ();
92static Lisp_Object describe_buffer_bindings (); 95static Lisp_Object describe_buffer_bindings ();
93static void describe_command (); 96static void describe_command (), describe_translation ();
94static void describe_map (); 97static void describe_map ();
95 98
96/* Keymap object support - constructors and predicates. */ 99/* Keymap object support - constructors and predicates. */
@@ -1839,7 +1842,7 @@ nominal alternate\n\
1839 Fset_buffer (Vstandard_output); 1842 Fset_buffer (Vstandard_output);
1840 1843
1841 /* Report on alternates for keys. */ 1844 /* Report on alternates for keys. */
1842 if (STRINGP (Vkeyboard_translate_table)) 1845 if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix))
1843 { 1846 {
1844 int c; 1847 int c;
1845 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data; 1848 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data;
@@ -1869,6 +1872,10 @@ nominal alternate\n\
1869 insert ("\n", 1); 1872 insert ("\n", 1);
1870 } 1873 }
1871 1874
1875 if (!NILP (Vkey_translation_map))
1876 describe_map_tree (Vkey_translation_map, 0, Qnil, prefix,
1877 "Key translations", 0, 1);
1878
1872 { 1879 {
1873 int i, nmaps; 1880 int i, nmaps;
1874 Lisp_Object *modes, *maps; 1881 Lisp_Object *modes, *maps;
@@ -1876,6 +1883,7 @@ nominal alternate\n\
1876 /* Temporarily switch to descbuf, so that we can get that buffer's 1883 /* Temporarily switch to descbuf, so that we can get that buffer's
1877 minor modes correctly. */ 1884 minor modes correctly. */
1878 Fset_buffer (descbuf); 1885 Fset_buffer (descbuf);
1886
1879 if (!NILP (current_kboard->Voverriding_terminal_local_map) 1887 if (!NILP (current_kboard->Voverriding_terminal_local_map)
1880 || !NILP (Voverriding_local_map)) 1888 || !NILP (Voverriding_local_map))
1881 nmaps = 0; 1889 nmaps = 0;
@@ -1905,7 +1913,7 @@ nominal alternate\n\
1905 p += sizeof (" Minor Mode Bindings") - 1; 1913 p += sizeof (" Minor Mode Bindings") - 1;
1906 *p = 0; 1914 *p = 0;
1907 1915
1908 describe_map_tree (maps[i], 0, shadow, prefix, title, 0); 1916 describe_map_tree (maps[i], 0, shadow, prefix, title, 0, 0);
1909 shadow = Fcons (maps[i], shadow); 1917 shadow = Fcons (maps[i], shadow);
1910 } 1918 }
1911 } 1919 }
@@ -1921,12 +1929,17 @@ nominal alternate\n\
1921 if (!NILP (start1)) 1929 if (!NILP (start1))
1922 { 1930 {
1923 describe_map_tree (start1, 0, shadow, prefix, 1931 describe_map_tree (start1, 0, shadow, prefix,
1924 "Major Mode Bindings", 0); 1932 "Major Mode Bindings", 0, 0);
1925 shadow = Fcons (start1, shadow); 1933 shadow = Fcons (start1, shadow);
1926 } 1934 }
1927 1935
1928 describe_map_tree (current_global_map, 0, shadow, prefix, 1936 describe_map_tree (current_global_map, 0, shadow, prefix,
1929 "Global Bindings", 0); 1937 "Global Bindings", 0, 0);
1938
1939 /* Print the function-key-map translations under this prefix. */
1940 if (!NILP (Vfunction_key_map))
1941 describe_map_tree (Vfunction_key_map, 0, Qnil, prefix,
1942 "Function key map translations", 0, 1);
1930 1943
1931 call0 (intern ("help-mode")); 1944 call0 (intern ("help-mode"));
1932 Fset_buffer (descbuf); 1945 Fset_buffer (descbuf);
@@ -1943,14 +1956,18 @@ nominal alternate\n\
1943 PREFIX, if non-nil, says mention only keys that start with PREFIX. 1956 PREFIX, if non-nil, says mention only keys that start with PREFIX.
1944 TITLE, if not 0, is a string to insert at the beginning. 1957 TITLE, if not 0, is a string to insert at the beginning.
1945 TITLE should not end with a colon or a newline; we supply that. 1958 TITLE should not end with a colon or a newline; we supply that.
1946 If NOMENU is not 0, then omit menu-bar commands. */ 1959 If NOMENU is not 0, then omit menu-bar commands.
1960
1961 If TRANSL is nonzero, the definitions are actually key translations
1962 so print strings and vectors differently. */
1947 1963
1948void 1964void
1949describe_map_tree (startmap, partial, shadow, prefix, title, nomenu) 1965describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl)
1950 Lisp_Object startmap, shadow, prefix; 1966 Lisp_Object startmap, shadow, prefix;
1951 int partial; 1967 int partial;
1952 char *title; 1968 char *title;
1953 int nomenu; 1969 int nomenu;
1970 int transl;
1954{ 1971{
1955 Lisp_Object maps, seen, sub_shadows; 1972 Lisp_Object maps, seen, sub_shadows;
1956 struct gcpro gcpro1, gcpro2, gcpro3; 1973 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -2041,7 +2058,8 @@ key binding\n\
2041 sub_shadows = Fcons (shmap, sub_shadows); 2058 sub_shadows = Fcons (shmap, sub_shadows);
2042 } 2059 }
2043 2060
2044 describe_map (Fcdr (elt), Fcar (elt), describe_command, 2061 describe_map (Fcdr (elt), Fcar (elt),
2062 transl ? describe_translation : describe_command,
2045 partial, sub_shadows, &seen); 2063 partial, sub_shadows, &seen);
2046 2064
2047 skip: ; 2065 skip: ;
@@ -2067,7 +2085,7 @@ describe_command (definition)
2067 insert1 (tem1); 2085 insert1 (tem1);
2068 insert_string ("\n"); 2086 insert_string ("\n");
2069 } 2087 }
2070 else if (STRINGP (definition)) 2088 else if (STRINGP (definition) || VECTORP (definition))
2071 insert_string ("Keyboard Macro\n"); 2089 insert_string ("Keyboard Macro\n");
2072 else 2090 else
2073 { 2091 {
@@ -2079,6 +2097,32 @@ describe_command (definition)
2079 } 2097 }
2080} 2098}
2081 2099
2100static void
2101describe_translation (definition)
2102 Lisp_Object definition;
2103{
2104 register Lisp_Object tem1;
2105
2106 Findent_to (make_number (16), make_number (1));
2107
2108 if (SYMBOLP (definition))
2109 {
2110 XSETSTRING (tem1, XSYMBOL (definition)->name);
2111 insert1 (tem1);
2112 insert_string ("\n");
2113 }
2114 else if (STRINGP (definition) || VECTORP (definition))
2115 insert1 (Fkey_description (definition));
2116 else
2117 {
2118 tem1 = Fkeymapp (definition);
2119 if (!NILP (tem1))
2120 insert_string ("Prefix Command\n");
2121 else
2122 insert_string ("??\n");
2123 }
2124}
2125
2082/* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. 2126/* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map.
2083 Returns the first non-nil binding found in any of those maps. */ 2127 Returns the first non-nil binding found in any of those maps. */
2084 2128
@@ -2460,6 +2504,12 @@ Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing\n\
2460key, typing `ESC O P x' would return [f1 x]."); 2504key, typing `ESC O P x' would return [f1 x].");
2461 Vfunction_key_map = Fmake_sparse_keymap (Qnil); 2505 Vfunction_key_map = Fmake_sparse_keymap (Qnil);
2462 2506
2507 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
2508 "Keymap of key translations that can override keymaps.\n\
2509This keymap works like `function-key-map', but comes after that,\n\
2510and applies even for keys that have ordinary bindings.");
2511 Vkey_translation_map = Qnil;
2512
2463 Qsingle_key_description = intern ("single-key-description"); 2513 Qsingle_key_description = intern ("single-key-description");
2464 staticpro (&Qsingle_key_description); 2514 staticpro (&Qsingle_key_description);
2465 2515