Mercurial > emacs
comparison src/keymap.c @ 1095:6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
(keymap_table): No longer static.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 11 Sep 1992 23:30:25 +0000 |
parents | 529171c8b71c |
children | 0a486e1a45bc |
comparison
equal
deleted
inserted
replaced
1094:861c2997afee | 1095:6578f07e9eb8 |
---|---|
86 static void describe_map (); | 86 static void describe_map (); |
87 static void describe_alist (); | 87 static void describe_alist (); |
88 | 88 |
89 /* Keymap object support - constructors and predicates. */ | 89 /* Keymap object support - constructors and predicates. */ |
90 | 90 |
91 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 0, 0, | 91 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0, |
92 "Construct and return a new keymap, of the form (keymap VECTOR . ALIST).\n\ | 92 "Construct and return a new keymap, of the form (keymap VECTOR . ALIST).\n\ |
93 VECTOR is a 128-element vector which holds the bindings for the ASCII\n\ | 93 VECTOR is a 128-element vector which holds the bindings for the ASCII\n\ |
94 characters. ALIST is an assoc-list which holds bindings for function keys,\n\ | 94 characters. ALIST is an assoc-list which holds bindings for function keys,\n\ |
95 mouse events, and any other things that appear in the input stream.\n\ | 95 mouse events, and any other things that appear in the input stream.\n\ |
96 All entries in it are initially nil, meaning \"command undefined\".") | 96 All entries in it are initially nil, meaning \"command undefined\".\n\n\ |
97 () | 97 The optional arg STRING supplies a menu name for the keymap\n\ |
98 { | 98 in case you use it as a menu with `x-popup-menu'.") |
99 (string) | |
100 Lisp_Object string; | |
101 { | |
102 Lisp_Object tail; | |
103 if (!NILP (string)) | |
104 tail = Fcons (string, Qnil); | |
105 else | |
106 tail = Qnil; | |
99 return Fcons (Qkeymap, | 107 return Fcons (Qkeymap, |
100 Fcons (Fmake_vector (make_number (DENSE_TABLE_SIZE), Qnil), | 108 Fcons (Fmake_vector (make_number (DENSE_TABLE_SIZE), Qnil), |
101 Qnil)); | 109 tail)); |
102 } | 110 } |
103 | 111 |
104 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, 0, 0, 0, | 112 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, 0, 1, 0, |
105 "Construct and return a new sparse-keymap list.\n\ | 113 "Construct and return a new sparse-keymap list.\n\ |
106 Its car is `keymap' and its cdr is an alist of (CHAR . DEFINITION),\n\ | 114 Its car is `keymap' and its cdr is an alist of (CHAR . DEFINITION),\n\ |
107 which binds the character CHAR to DEFINITION, or (SYMBOL . DEFINITION),\n\ | 115 which binds the character CHAR to DEFINITION, or (SYMBOL . DEFINITION),\n\ |
108 which binds the function key or mouse event SYMBOL to DEFINITION.\n\ | 116 which binds the function key or mouse event SYMBOL to DEFINITION.\n\ |
109 Initially the alist is nil.") | 117 Initially the alist is nil.\n\n\ |
110 () | 118 The optional arg STRING supplies a menu name for the keymap\n\ |
111 { | 119 in case you use it as a menu with `x-popup-menu'.") |
120 (string) | |
121 Lisp_Object string; | |
122 { | |
123 if (!NILP (string)) | |
124 return Fcons (Qkeymap, Fcons (string, Qnil)); | |
112 return Fcons (Qkeymap, Qnil); | 125 return Fcons (Qkeymap, Qnil); |
113 } | 126 } |
114 | 127 |
115 /* This function is used for installing the standard key bindings | 128 /* This function is used for installing the standard key bindings |
116 at initialization time. | 129 at initialization time. |
192 | 205 |
193 | 206 |
194 /* If KEYMAP is a dense keymap, return the vector from its cadr. | 207 /* If KEYMAP is a dense keymap, return the vector from its cadr. |
195 Otherwise, return nil. */ | 208 Otherwise, return nil. */ |
196 | 209 |
197 static Lisp_Object | 210 Lisp_Object |
198 keymap_table (keymap) | 211 keymap_table (keymap) |
199 Lisp_Object keymap; | 212 Lisp_Object keymap; |
200 { | 213 { |
201 Lisp_Object cadr; | 214 Lisp_Object cadr; |
202 | 215 |
462 | 475 |
463 cmd = get_keyelt (access_keymap (keymap, c)); | 476 cmd = get_keyelt (access_keymap (keymap, c)); |
464 | 477 |
465 if (NILP (cmd)) | 478 if (NILP (cmd)) |
466 { | 479 { |
467 cmd = Fmake_sparse_keymap (); | 480 cmd = Fmake_sparse_keymap (Qnil); |
468 store_in_keymap (keymap, c, cmd); | 481 store_in_keymap (keymap, c, cmd); |
469 } | 482 } |
470 | 483 |
471 tem = Fkeymapp (cmd); | 484 tem = Fkeymapp (cmd); |
472 if (NILP (tem)) | 485 if (NILP (tem)) |
760 { | 773 { |
761 register Lisp_Object map; | 774 register Lisp_Object map; |
762 map = current_buffer->keymap; | 775 map = current_buffer->keymap; |
763 if (NILP (map)) | 776 if (NILP (map)) |
764 { | 777 { |
765 map = Fmake_sparse_keymap (); | 778 map = Fmake_sparse_keymap (Qnil); |
766 current_buffer->keymap = map; | 779 current_buffer->keymap = map; |
767 } | 780 } |
768 | 781 |
769 if (XTYPE (keys) != Lisp_Vector | 782 if (XTYPE (keys) != Lisp_Vector |
770 && XTYPE (keys) != Lisp_String) | 783 && XTYPE (keys) != Lisp_String) |
804 as a function.") | 817 as a function.") |
805 (name, mapvar) | 818 (name, mapvar) |
806 Lisp_Object name, mapvar; | 819 Lisp_Object name, mapvar; |
807 { | 820 { |
808 Lisp_Object map; | 821 Lisp_Object map; |
809 map = Fmake_sparse_keymap (); | 822 map = Fmake_sparse_keymap (Qnil); |
810 Ffset (name, map); | 823 Ffset (name, map); |
811 if (!NILP (mapvar)) | 824 if (!NILP (mapvar)) |
812 Fset (mapvar, map); | 825 Fset (mapvar, map); |
813 else | 826 else |
814 Fset (name, map); | 827 Fset (name, map); |
1765 | 1778 |
1766 /* Initialize the keymaps standardly used. | 1779 /* Initialize the keymaps standardly used. |
1767 Each one is the value of a Lisp variable, and is also | 1780 Each one is the value of a Lisp variable, and is also |
1768 pointed to by a C variable */ | 1781 pointed to by a C variable */ |
1769 | 1782 |
1770 global_map = Fmake_keymap (); | 1783 global_map = Fmake_keymap (Qnil); |
1771 Fset (intern ("global-map"), global_map); | 1784 Fset (intern ("global-map"), global_map); |
1772 | 1785 |
1773 meta_map = Fmake_keymap (); | 1786 meta_map = Fmake_keymap (Qnil); |
1774 Fset (intern ("esc-map"), meta_map); | 1787 Fset (intern ("esc-map"), meta_map); |
1775 Ffset (intern ("ESC-prefix"), meta_map); | 1788 Ffset (intern ("ESC-prefix"), meta_map); |
1776 | 1789 |
1777 control_x_map = Fmake_keymap (); | 1790 control_x_map = Fmake_keymap (Qnil); |
1778 Fset (intern ("ctl-x-map"), control_x_map); | 1791 Fset (intern ("ctl-x-map"), control_x_map); |
1779 Ffset (intern ("Control-X-prefix"), control_x_map); | 1792 Ffset (intern ("Control-X-prefix"), control_x_map); |
1780 | 1793 |
1781 DEFVAR_LISP ("minibuffer-local-map", &Vminibuffer_local_map, | 1794 DEFVAR_LISP ("minibuffer-local-map", &Vminibuffer_local_map, |
1782 "Default keymap to use when reading from the minibuffer."); | 1795 "Default keymap to use when reading from the minibuffer."); |
1783 Vminibuffer_local_map = Fmake_sparse_keymap (); | 1796 Vminibuffer_local_map = Fmake_sparse_keymap (Qnil); |
1784 | 1797 |
1785 DEFVAR_LISP ("minibuffer-local-ns-map", &Vminibuffer_local_ns_map, | 1798 DEFVAR_LISP ("minibuffer-local-ns-map", &Vminibuffer_local_ns_map, |
1786 "Local keymap for the minibuffer when spaces are not allowed."); | 1799 "Local keymap for the minibuffer when spaces are not allowed."); |
1787 Vminibuffer_local_ns_map = Fmake_sparse_keymap (); | 1800 Vminibuffer_local_ns_map = Fmake_sparse_keymap (Qnil); |
1788 | 1801 |
1789 DEFVAR_LISP ("minibuffer-local-completion-map", &Vminibuffer_local_completion_map, | 1802 DEFVAR_LISP ("minibuffer-local-completion-map", &Vminibuffer_local_completion_map, |
1790 "Local keymap for minibuffer input with completion."); | 1803 "Local keymap for minibuffer input with completion."); |
1791 Vminibuffer_local_completion_map = Fmake_sparse_keymap (); | 1804 Vminibuffer_local_completion_map = Fmake_sparse_keymap (Qnil); |
1792 | 1805 |
1793 DEFVAR_LISP ("minibuffer-local-must-match-map", &Vminibuffer_local_must_match_map, | 1806 DEFVAR_LISP ("minibuffer-local-must-match-map", &Vminibuffer_local_must_match_map, |
1794 "Local keymap for minibuffer input with completion, for exact match."); | 1807 "Local keymap for minibuffer input with completion, for exact match."); |
1795 Vminibuffer_local_must_match_map = Fmake_sparse_keymap (); | 1808 Vminibuffer_local_must_match_map = Fmake_sparse_keymap (Qnil); |
1796 | 1809 |
1797 current_global_map = global_map; | 1810 current_global_map = global_map; |
1798 | 1811 |
1799 DEFVAR_LISP ("minor-mode-map-alist", &Vminor_mode_map_alist, | 1812 DEFVAR_LISP ("minor-mode-map-alist", &Vminor_mode_map_alist, |
1800 "Alist of keymaps to use for minor modes.\n\ | 1813 "Alist of keymaps to use for minor modes.\n\ |
1818 \n\ | 1831 \n\ |
1819 For example, suppose function-key-map binds `ESC O P' to [pf1].\n\ | 1832 For example, suppose function-key-map binds `ESC O P' to [pf1].\n\ |
1820 Typing `ESC O P' to read-key-sequence would return [pf1]. Typing\n\ | 1833 Typing `ESC O P' to read-key-sequence would return [pf1]. Typing\n\ |
1821 `C-x ESC O P' would return [?\C-x pf1]. If [pf1] were a prefix\n\ | 1834 `C-x ESC O P' would return [?\C-x pf1]. If [pf1] were a prefix\n\ |
1822 key, typing `ESC O P x' would return [pf1 x]."); | 1835 key, typing `ESC O P x' would return [pf1 x]."); |
1823 Vfunction_key_map = Fmake_sparse_keymap (); | 1836 Vfunction_key_map = Fmake_sparse_keymap (Qnil); |
1824 | 1837 |
1825 Qsingle_key_description = intern ("single-key-description"); | 1838 Qsingle_key_description = intern ("single-key-description"); |
1826 staticpro (&Qsingle_key_description); | 1839 staticpro (&Qsingle_key_description); |
1827 | 1840 |
1828 Qkey_description = intern ("key-description"); | 1841 Qkey_description = intern ("key-description"); |