Mercurial > emacs
annotate src/keymap.c @ 17241:d5cbb3a06adc libc-970325 libc-970326 libc-970327 libc-970328 libc-970329 libc-970330 libc-970331 libc-970401 libc-970402 libc-970403 libc-970404 libc-970405 libc-970406 libc-970407 libc-970408 libc-970409 libc-970410 libc-970411
(m32r,mn10300): Add.
| author | Doug Evans <dje@gnu.org> |
|---|---|
| date | Mon, 24 Mar 1997 20:38:28 +0000 |
| parents | 7c008ec99e97 |
| children | fad065a280dc |
| rev | line source |
|---|---|
| 250 | 1 /* Manipulation of keymaps |
| 11235 | 2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc. |
| 250 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
| 647 | 8 the Free Software Foundation; either version 2, or (at your option) |
| 250 | 9 any later version. |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14129
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14129
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
| 250 | 20 |
| 21 | |
|
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4575
diff
changeset
|
22 #include <config.h> |
| 250 | 23 #include <stdio.h> |
| 24 #undef NULL | |
| 25 #include "lisp.h" | |
| 26 #include "commands.h" | |
| 27 #include "buffer.h" | |
| 17036 | 28 #include "charset.h" |
| 517 | 29 #include "keyboard.h" |
| 2059 | 30 #include "termhooks.h" |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2358
diff
changeset
|
31 #include "blockinput.h" |
|
13771
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
32 #include "puresize.h" |
| 250 | 33 |
| 34 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 35 | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
36 /* The number of elements in keymap vectors. */ |
| 250 | 37 #define DENSE_TABLE_SIZE (0200) |
| 38 | |
| 39 /* Actually allocate storage for these variables */ | |
| 40 | |
| 41 Lisp_Object current_global_map; /* Current global keymap */ | |
| 42 | |
| 43 Lisp_Object global_map; /* default global key bindings */ | |
| 44 | |
| 45 Lisp_Object meta_map; /* The keymap used for globally bound | |
| 46 ESC-prefixed default commands */ | |
| 47 | |
| 48 Lisp_Object control_x_map; /* The keymap used for globally bound | |
| 49 C-x-prefixed default commands */ | |
| 50 | |
| 51 /* was MinibufLocalMap */ | |
| 52 Lisp_Object Vminibuffer_local_map; | |
| 53 /* The keymap used by the minibuf for local | |
| 54 bindings when spaces are allowed in the | |
| 55 minibuf */ | |
| 56 | |
| 57 /* was MinibufLocalNSMap */ | |
| 58 Lisp_Object Vminibuffer_local_ns_map; | |
| 59 /* The keymap used by the minibuf for local | |
| 60 bindings when spaces are not encouraged | |
| 61 in the minibuf */ | |
| 62 | |
| 63 /* keymap used for minibuffers when doing completion */ | |
| 64 /* was MinibufLocalCompletionMap */ | |
| 65 Lisp_Object Vminibuffer_local_completion_map; | |
| 66 | |
| 67 /* keymap used for minibuffers when doing completion and require a match */ | |
| 68 /* was MinibufLocalMustMatchMap */ | |
| 69 Lisp_Object Vminibuffer_local_must_match_map; | |
| 70 | |
| 465 | 71 /* Alist of minor mode variables and keymaps. */ |
| 72 Lisp_Object Vminor_mode_map_alist; | |
| 73 | |
| 517 | 74 /* Keymap mapping ASCII function key sequences onto their preferred forms. |
| 75 Initialized by the terminal-specific lisp files. See DEFVAR for more | |
| 76 documentation. */ | |
| 77 Lisp_Object Vfunction_key_map; | |
| 78 | |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
79 /* Keymap mapping ASCII function key sequences onto their preferred forms. */ |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
80 Lisp_Object Vkey_translation_map; |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
81 |
|
12297
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
82 /* A list of all commands given new bindings since a certain time |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
83 when nil was stored here. |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
84 This is used to speed up recomputation of menu key equivalents |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
85 when Emacs starts up. t means don't record anything here. */ |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
86 Lisp_Object Vdefine_key_rebound_commands; |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
87 |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
88 Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii; |
| 250 | 89 |
| 2886 | 90 /* A char with the CHAR_META bit set in a vector or the 0200 bit set |
| 91 in a string key sequence is equivalent to prefixing with this | |
| 92 character. */ | |
| 250 | 93 extern Lisp_Object meta_prefix_char; |
| 94 | |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
95 extern Lisp_Object Voverriding_local_map; |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
96 |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
97 static Lisp_Object define_as_prefix (); |
| 250 | 98 static Lisp_Object describe_buffer_bindings (); |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
99 static void describe_command (), describe_translation (); |
| 250 | 100 static void describe_map (); |
| 101 | |
| 465 | 102 /* Keymap object support - constructors and predicates. */ |
| 103 | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
104 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0, |
| 250 | 105 "Construct and return a new keymap, of the form (keymap VECTOR . ALIST).\n\ |
|
2790
cf431814ce6a
(access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents:
2755
diff
changeset
|
106 VECTOR is a vector which holds the bindings for the ASCII\n\ |
| 250 | 107 characters. ALIST is an assoc-list which holds bindings for function keys,\n\ |
| 108 mouse events, and any other things that appear in the input stream.\n\ | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
109 All entries in it are initially nil, meaning \"command undefined\".\n\n\ |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
110 The optional arg STRING supplies a menu name for the keymap\n\ |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
111 in case you use it as a menu with `x-popup-menu'.") |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
112 (string) |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
113 Lisp_Object string; |
| 250 | 114 { |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
115 Lisp_Object tail; |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
116 if (!NILP (string)) |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
117 tail = Fcons (string, Qnil); |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
118 else |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
119 tail = Qnil; |
| 250 | 120 return Fcons (Qkeymap, |
| 121 Fcons (Fmake_vector (make_number (DENSE_TABLE_SIZE), Qnil), | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
122 tail)); |
| 250 | 123 } |
| 124 | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
125 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, 0, 1, 0, |
| 250 | 126 "Construct and return a new sparse-keymap list.\n\ |
| 127 Its car is `keymap' and its cdr is an alist of (CHAR . DEFINITION),\n\ | |
| 128 which binds the character CHAR to DEFINITION, or (SYMBOL . DEFINITION),\n\ | |
| 129 which binds the function key or mouse event SYMBOL to DEFINITION.\n\ | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
130 Initially the alist is nil.\n\n\ |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
131 The optional arg STRING supplies a menu name for the keymap\n\ |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
132 in case you use it as a menu with `x-popup-menu'.") |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
133 (string) |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
134 Lisp_Object string; |
| 250 | 135 { |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
136 if (!NILP (string)) |
|
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
137 return Fcons (Qkeymap, Fcons (string, Qnil)); |
| 250 | 138 return Fcons (Qkeymap, Qnil); |
| 139 } | |
| 140 | |
| 141 /* This function is used for installing the standard key bindings | |
| 142 at initialization time. | |
| 143 | |
| 144 For example: | |
| 145 | |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
146 initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */ |
| 250 | 147 |
| 148 void | |
| 149 initial_define_key (keymap, key, defname) | |
| 150 Lisp_Object keymap; | |
| 151 int key; | |
| 152 char *defname; | |
| 153 { | |
| 154 store_in_keymap (keymap, make_number (key), intern (defname)); | |
| 155 } | |
| 156 | |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
157 void |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
158 initial_define_lispy_key (keymap, keyname, defname) |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
159 Lisp_Object keymap; |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
160 char *keyname; |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
161 char *defname; |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
162 { |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
163 store_in_keymap (keymap, intern (keyname), intern (defname)); |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
164 } |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
165 |
| 250 | 166 /* Define character fromchar in map frommap as an alias for character |
| 167 tochar in map tomap. Subsequent redefinitions of the latter WILL | |
| 168 affect the former. */ | |
| 169 | |
| 170 #if 0 | |
| 171 void | |
| 172 synkey (frommap, fromchar, tomap, tochar) | |
| 173 struct Lisp_Vector *frommap, *tomap; | |
| 174 int fromchar, tochar; | |
| 175 { | |
| 176 Lisp_Object v, c; | |
|
9273
129621997564
(synkey, Fdescribe_bindings, describe_command): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents:
9123
diff
changeset
|
177 XSETVECTOR (v, tomap); |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
178 XSETFASTINT (c, tochar); |
| 250 | 179 frommap->contents[fromchar] = Fcons (v, c); |
| 180 } | |
| 181 #endif /* 0 */ | |
| 182 | |
| 183 DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0, | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
184 "Return t if OBJECT is a keymap.\n\ |
| 362 | 185 \n\ |
|
2790
cf431814ce6a
(access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents:
2755
diff
changeset
|
186 A keymap is a list (keymap . ALIST),\n\ |
| 6457 | 187 or a symbol whose function definition is itself a keymap.\n\ |
| 362 | 188 ALIST elements look like (CHAR . DEFN) or (SYMBOL . DEFN);\n\ |
|
2790
cf431814ce6a
(access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents:
2755
diff
changeset
|
189 a vector of densely packed bindings for small character codes\n\ |
|
cf431814ce6a
(access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents:
2755
diff
changeset
|
190 is also allowed as an element.") |
| 250 | 191 (object) |
| 192 Lisp_Object object; | |
| 193 { | |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
194 return (NILP (get_keymap_1 (object, 0, 0)) ? Qnil : Qt); |
| 250 | 195 } |
| 196 | |
| 197 /* Check that OBJECT is a keymap (after dereferencing through any | |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
198 symbols). If it is, return it. |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
199 |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
200 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
201 is an autoload form, do the autoload and try again. |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
202 If AUTOLOAD is nonzero, callers must assume GC is possible. |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
203 |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
204 ERROR controls how we respond if OBJECT isn't a keymap. |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
205 If ERROR is non-zero, signal an error; otherwise, just return Qnil. |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
206 |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
207 Note that most of the time, we don't want to pursue autoloads. |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
208 Functions like Faccessible_keymaps which scan entire keymap trees |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
209 shouldn't load every autoloaded keymap. I'm not sure about this, |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
210 but it seems to me that only read_key_sequence, Flookup_key, and |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
211 Fdefine_key should cause keymaps to be autoloaded. */ |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
212 |
| 250 | 213 Lisp_Object |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
214 get_keymap_1 (object, error, autoload) |
| 250 | 215 Lisp_Object object; |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
216 int error, autoload; |
| 250 | 217 { |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
218 Lisp_Object tem; |
| 250 | 219 |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
220 autoload_retry: |
| 647 | 221 tem = indirect_function (object); |
| 250 | 222 if (CONSP (tem) && EQ (XCONS (tem)->car, Qkeymap)) |
| 223 return tem; | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
224 |
|
1566
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
225 /* Should we do an autoload? Autoload forms for keymaps have |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
226 Qkeymap as their fifth element. */ |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
227 if (autoload |
|
8866
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
228 && SYMBOLP (object) |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
229 && CONSP (tem) |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
230 && EQ (XCONS (tem)->car, Qautoload)) |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
231 { |
|
1566
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
232 Lisp_Object tail; |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
233 |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
234 tail = Fnth (make_number (4), tem); |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
235 if (EQ (tail, Qkeymap)) |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
236 { |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
237 struct gcpro gcpro1, gcpro2; |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
238 |
|
3691
49ce2242f5c1
(get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents:
3674
diff
changeset
|
239 GCPRO2 (tem, object); |
|
49ce2242f5c1
(get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents:
3674
diff
changeset
|
240 do_autoload (tem, object); |
|
1566
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
241 UNGCPRO; |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
242 |
|
1566
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
243 goto autoload_retry; |
|
892c9f61217a
* keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents:
1517
diff
changeset
|
244 } |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
245 } |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
246 |
| 250 | 247 if (error) |
| 248 wrong_type_argument (Qkeymapp, object); | |
| 465 | 249 else |
| 250 return Qnil; | |
| 250 | 251 } |
| 252 | |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
253 |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
254 /* Follow any symbol chaining, and return the keymap denoted by OBJECT. |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
255 If OBJECT doesn't denote a keymap at all, signal an error. */ |
| 250 | 256 Lisp_Object |
| 257 get_keymap (object) | |
| 258 Lisp_Object object; | |
| 259 { | |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
260 return get_keymap_1 (object, 1, 0); |
| 250 | 261 } |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
262 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
263 /* Return the parent map of the keymap MAP, or nil if it has none. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
264 We assume that MAP is a valid keymap. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
265 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
266 DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
267 "Return the parent keymap of KEYMAP.") |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
268 (keymap) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
269 Lisp_Object keymap; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
270 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
271 Lisp_Object list; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
272 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
273 keymap = get_keymap_1 (keymap, 1, 1); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
274 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
275 /* Skip past the initial element `keymap'. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
276 list = XCONS (keymap)->cdr; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
277 for (; CONSP (list); list = XCONS (list)->cdr) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
278 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
279 /* See if there is another `keymap'. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
280 if (EQ (Qkeymap, XCONS (list)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
281 return list; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
282 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
283 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
284 return Qnil; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
285 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
286 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
287 /* Set the parent keymap of MAP to PARENT. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
288 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
289 DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
290 "Modify KEYMAP to set its parent map to PARENT.\n\ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
291 PARENT should be nil or another keymap.") |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
292 (keymap, parent) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
293 Lisp_Object keymap, parent; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
294 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
295 Lisp_Object list, prev; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
296 int i; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
297 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
298 keymap = get_keymap_1 (keymap, 1, 1); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
299 if (!NILP (parent)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
300 parent = get_keymap_1 (parent, 1, 1); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
301 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
302 /* Skip past the initial element `keymap'. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
303 prev = keymap; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
304 while (1) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
305 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
306 list = XCONS (prev)->cdr; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
307 /* If there is a parent keymap here, replace it. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
308 If we came to the end, add the parent in PREV. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
309 if (! CONSP (list) || EQ (Qkeymap, XCONS (list)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
310 { |
|
15422
dd639432a55a
(Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents:
15378
diff
changeset
|
311 /* If we already have the right parent, return now |
|
dd639432a55a
(Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents:
15378
diff
changeset
|
312 so that we avoid the loops below. */ |
|
dd639432a55a
(Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents:
15378
diff
changeset
|
313 if (EQ (XCONS (prev)->cdr, parent)) |
|
dd639432a55a
(Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents:
15378
diff
changeset
|
314 return parent; |
|
dd639432a55a
(Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents:
15378
diff
changeset
|
315 |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
316 XCONS (prev)->cdr = parent; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
317 break; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
318 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
319 prev = list; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
320 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
321 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
322 /* Scan through for submaps, and set their parents too. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
323 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
324 for (list = XCONS (keymap)->cdr; CONSP (list); list = XCONS (list)->cdr) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
325 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
326 /* Stop the scan when we come to the parent. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
327 if (EQ (XCONS (list)->car, Qkeymap)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
328 break; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
329 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
330 /* If this element holds a prefix map, deal with it. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
331 if (CONSP (XCONS (list)->car) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
332 && CONSP (XCONS (XCONS (list)->car)->cdr)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
333 fix_submap_inheritance (keymap, XCONS (XCONS (list)->car)->car, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
334 XCONS (XCONS (list)->car)->cdr); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
335 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
336 if (VECTORP (XCONS (list)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
337 for (i = 0; i < XVECTOR (XCONS (list)->car)->size; i++) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
338 if (CONSP (XVECTOR (XCONS (list)->car)->contents[i])) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
339 fix_submap_inheritance (keymap, make_number (i), |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
340 XVECTOR (XCONS (list)->car)->contents[i]); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
341 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
342 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
343 return parent; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
344 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
345 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
346 /* EVENT is defined in MAP as a prefix, and SUBMAP is its definition. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
347 if EVENT is also a prefix in MAP's parent, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
348 make sure that SUBMAP inherits that definition as its own parent. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
349 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
350 fix_submap_inheritance (map, event, submap) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
351 Lisp_Object map, event, submap; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
352 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
353 Lisp_Object map_parent, parent_entry; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
354 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
355 /* SUBMAP is a cons that we found as a key binding. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
356 Discard the other things found in a menu key binding. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
357 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
358 if (CONSP (submap) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
359 && STRINGP (XCONS (submap)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
360 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
361 submap = XCONS (submap)->cdr; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
362 /* Also remove a menu help string, if any, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
363 following the menu item name. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
364 if (CONSP (submap) && STRINGP (XCONS (submap)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
365 submap = XCONS (submap)->cdr; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
366 /* Also remove the sublist that caches key equivalences, if any. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
367 if (CONSP (submap) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
368 && CONSP (XCONS (submap)->car)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
369 { |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
370 Lisp_Object carcar; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
371 carcar = XCONS (XCONS (submap)->car)->car; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
372 if (NILP (carcar) || VECTORP (carcar)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
373 submap = XCONS (submap)->cdr; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
374 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
375 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
376 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
377 /* If it isn't a keymap now, there's no work to do. */ |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
378 if (! CONSP (submap) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
379 || ! EQ (XCONS (submap)->car, Qkeymap)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
380 return; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
381 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
382 map_parent = Fkeymap_parent (map); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
383 if (! NILP (map_parent)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
384 parent_entry = access_keymap (map_parent, event, 0, 0); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
385 else |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
386 parent_entry = Qnil; |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
387 |
|
15378
ecfc288350ab
(fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents:
15344
diff
changeset
|
388 /* If MAP's parent has something other than a keymap, |
|
ecfc288350ab
(fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents:
15344
diff
changeset
|
389 our own submap shadows it completely, so use nil as SUBMAP's parent. */ |
|
ecfc288350ab
(fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents:
15344
diff
changeset
|
390 if (! (CONSP (parent_entry) && EQ (XCONS (parent_entry)->car, Qkeymap))) |
|
ecfc288350ab
(fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents:
15344
diff
changeset
|
391 parent_entry = Qnil; |
|
ecfc288350ab
(fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents:
15344
diff
changeset
|
392 |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
393 if (! EQ (parent_entry, submap)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
394 Fset_keymap_parent (submap, parent_entry); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
395 } |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
396 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
397 /* Look up IDX in MAP. IDX may be any sort of event. |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
398 Note that this does only one level of lookup; IDX must be a single |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
399 event, not a sequence. |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
400 |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
401 If T_OK is non-zero, bindings for Qt are treated as default |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
402 bindings; any key left unmentioned by other tables and bindings is |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
403 given the binding of Qt. |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
404 |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
405 If T_OK is zero, bindings for Qt are not treated specially. |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
406 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
407 If NOINHERIT, don't accept a subkeymap found in an inherited keymap. */ |
| 250 | 408 |
| 409 Lisp_Object | |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
410 access_keymap (map, idx, t_ok, noinherit) |
| 250 | 411 Lisp_Object map; |
| 412 Lisp_Object idx; | |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
413 int t_ok; |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
414 int noinherit; |
| 250 | 415 { |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
416 int noprefix = 0; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
417 Lisp_Object val; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
418 |
| 250 | 419 /* If idx is a list (some sort of mouse click, perhaps?), |
| 420 the index we want to use is the car of the list, which | |
| 421 ought to be a symbol. */ | |
|
1315
884c3d7e7172
* keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents:
1264
diff
changeset
|
422 idx = EVENT_HEAD (idx); |
| 250 | 423 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
424 /* If idx is a symbol, it might have modifiers, which need to |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
425 be put in the canonical order. */ |
|
8866
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
426 if (SYMBOLP (idx)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
427 idx = reorder_modifiers (idx); |
|
3515
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
428 else if (INTEGERP (idx)) |
|
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
429 /* Clobber the high bits that can be present on a machine |
|
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
430 with more than 24 bits of integer. */ |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
431 XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1))); |
| 250 | 432 |
| 433 { | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
434 Lisp_Object tail; |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
435 Lisp_Object t_binding; |
| 250 | 436 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
437 t_binding = Qnil; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
438 for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
439 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
440 Lisp_Object binding; |
| 250 | 441 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
442 binding = XCONS (tail)->car; |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
443 if (SYMBOLP (binding)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
444 { |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
445 /* If NOINHERIT, stop finding prefix definitions |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
446 after we pass a second occurrence of the `keymap' symbol. */ |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
447 if (noinherit && EQ (binding, Qkeymap) && ! EQ (tail, map)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
448 noprefix = 1; |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
449 } |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
450 else if (CONSP (binding)) |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
451 { |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
452 if (EQ (XCONS (binding)->car, idx)) |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
453 { |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
454 val = XCONS (binding)->cdr; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
455 if (noprefix && CONSP (val) && EQ (XCONS (val)->car, Qkeymap)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
456 return Qnil; |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
457 if (CONSP (val)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
458 fix_submap_inheritance (map, idx, val); |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
459 return val; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
460 } |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
461 if (t_ok && EQ (XCONS (binding)->car, Qt)) |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
462 t_binding = XCONS (binding)->cdr; |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
463 } |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
464 else if (VECTORP (binding)) |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
465 { |
|
9957
940847846909
(access_keymap, store_in_keymap): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents:
9946
diff
changeset
|
466 if (NATNUMP (idx) && XFASTINT (idx) < XVECTOR (binding)->size) |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
467 { |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
468 val = XVECTOR (binding)->contents[XFASTINT (idx)]; |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
469 if (noprefix && CONSP (val) && EQ (XCONS (val)->car, Qkeymap)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
470 return Qnil; |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
471 if (CONSP (val)) |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
472 fix_submap_inheritance (map, idx, val); |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
473 return val; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
474 } |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
475 } |
|
1264
6ba9d5aaace6
* keymap.c (access_keymap): Don't forget to QUIT while scanning
Jim Blandy <jimb@redhat.com>
parents:
1236
diff
changeset
|
476 |
|
6ba9d5aaace6
* keymap.c (access_keymap): Don't forget to QUIT while scanning
Jim Blandy <jimb@redhat.com>
parents:
1236
diff
changeset
|
477 QUIT; |
| 250 | 478 } |
|
1388
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
479 |
|
02226bff1476
* keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents:
1315
diff
changeset
|
480 return t_binding; |
|
1236
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
481 } |
| 250 | 482 } |
| 483 | |
| 484 /* Given OBJECT which was found in a slot in a keymap, | |
| 485 trace indirect definitions to get the actual definition of that slot. | |
| 486 An indirect definition is a list of the form | |
| 487 (KEYMAP . INDEX), where KEYMAP is a keymap or a symbol defined as one | |
| 488 and INDEX is the object to look up in KEYMAP to yield the definition. | |
| 489 | |
| 490 Also if OBJECT has a menu string as the first element, | |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
491 remove that. Also remove a menu help string as second element. |
|
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
492 |
|
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
493 If AUTOLOAD is nonzero, load autoloadable keymaps |
|
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
494 that are referred to with indirection. */ |
| 250 | 495 |
| 496 Lisp_Object | |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
497 get_keyelt (object, autoload) |
| 250 | 498 register Lisp_Object object; |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
499 int autoload; |
| 250 | 500 { |
| 501 while (1) | |
| 502 { | |
| 503 register Lisp_Object map, tem; | |
| 504 | |
|
1236
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
505 /* If the contents are (KEYMAP . ELEMENT), go indirect. */ |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
506 map = get_keymap_1 (Fcar_safe (object), 0, autoload); |
| 250 | 507 tem = Fkeymapp (map); |
| 485 | 508 if (!NILP (tem)) |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
509 object = access_keymap (map, Fcdr (object), 0, 0); |
| 250 | 510 |
| 511 /* If the keymap contents looks like (STRING . DEFN), | |
| 512 use DEFN. | |
| 513 Keymap alist elements like (CHAR MENUSTRING . DEFN) | |
| 514 will be used by HierarKey menus. */ | |
|
8866
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
515 else if (CONSP (object) |
|
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
516 && STRINGP (XCONS (object)->car)) |
|
1160
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
517 { |
|
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
518 object = XCONS (object)->cdr; |
|
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
519 /* Also remove a menu help string, if any, |
|
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
520 following the menu item name. */ |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
521 if (CONSP (object) && STRINGP (XCONS (object)->car)) |
|
1160
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
522 object = XCONS (object)->cdr; |
|
6021
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
523 /* Also remove the sublist that caches key equivalences, if any. */ |
|
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
524 if (CONSP (object) |
|
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
525 && CONSP (XCONS (object)->car)) |
|
6008
d3ccce72be00
(get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents:
5785
diff
changeset
|
526 { |
|
6021
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
527 Lisp_Object carcar; |
|
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
528 carcar = XCONS (XCONS (object)->car)->car; |
|
de651e959736
(get_keyelt): Cached equiv-key data is now a sublist.
Richard M. Stallman <rms@gnu.org>
parents:
6008
diff
changeset
|
529 if (NILP (carcar) || VECTORP (carcar)) |
|
6008
d3ccce72be00
(get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents:
5785
diff
changeset
|
530 object = XCONS (object)->cdr; |
|
d3ccce72be00
(get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents:
5785
diff
changeset
|
531 } |
|
1160
f7b55bfe1c05
(get_keyelt): Skip menu help string after menu item name.
Richard M. Stallman <rms@gnu.org>
parents:
1120
diff
changeset
|
532 } |
| 250 | 533 |
| 534 else | |
| 535 /* Anything else is really the value. */ | |
| 536 return object; | |
| 537 } | |
| 538 } | |
| 539 | |
| 540 Lisp_Object | |
| 541 store_in_keymap (keymap, idx, def) | |
| 542 Lisp_Object keymap; | |
| 543 register Lisp_Object idx; | |
| 544 register Lisp_Object def; | |
| 545 { | |
|
10367
e1c7a3f0c15f
(store_in_keymap): Copy a cons only if car is a string.
Richard M. Stallman <rms@gnu.org>
parents:
10305
diff
changeset
|
546 /* If we are preparing to dump, and DEF is a menu element |
|
e1c7a3f0c15f
(store_in_keymap): Copy a cons only if car is a string.
Richard M. Stallman <rms@gnu.org>
parents:
10305
diff
changeset
|
547 with a menu item string, copy it to ensure it is not pure. */ |
|
13771
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
548 if (CONSP (def) && PURE_P (def) && STRINGP (XCONS (def)->car)) |
|
10305
ebb2a456a3e8
(store_in_keymap): While dumping, copy DEF if a cons.
Richard M. Stallman <rms@gnu.org>
parents:
10008
diff
changeset
|
549 def = Fcons (XCONS (def)->car, XCONS (def)->cdr); |
|
ebb2a456a3e8
(store_in_keymap): While dumping, copy DEF if a cons.
Richard M. Stallman <rms@gnu.org>
parents:
10008
diff
changeset
|
550 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
551 if (!CONSP (keymap) || ! EQ (XCONS (keymap)->car, Qkeymap)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
552 error ("attempt to define a key in a non-keymap"); |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
553 |
| 250 | 554 /* If idx is a list (some sort of mouse click, perhaps?), |
| 555 the index we want to use is the car of the list, which | |
| 556 ought to be a symbol. */ | |
|
1315
884c3d7e7172
* keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents:
1264
diff
changeset
|
557 idx = EVENT_HEAD (idx); |
| 250 | 558 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
559 /* If idx is a symbol, it might have modifiers, which need to |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
560 be put in the canonical order. */ |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
561 if (SYMBOLP (idx)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
562 idx = reorder_modifiers (idx); |
|
3515
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
563 else if (INTEGERP (idx)) |
|
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
564 /* Clobber the high bits that can be present on a machine |
|
9d0af0f2dc0d
(access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents:
3425
diff
changeset
|
565 with more than 24 bits of integer. */ |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
566 XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1))); |
| 250 | 567 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
568 /* Scan the keymap for a binding of idx. */ |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
569 { |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
570 Lisp_Object tail; |
| 250 | 571 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
572 /* The cons after which we should insert new bindings. If the |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
573 keymap has a table element, we record its position here, so new |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
574 bindings will go after it; this way, the table will stay |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
575 towards the front of the alist and character lookups in dense |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
576 keymaps will remain fast. Otherwise, this just points at the |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
577 front of the keymap. */ |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
578 Lisp_Object insertion_point; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
579 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
580 insertion_point = keymap; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
581 for (tail = XCONS (keymap)->cdr; CONSP (tail); tail = XCONS (tail)->cdr) |
| 250 | 582 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
583 Lisp_Object elt; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
584 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
585 elt = XCONS (tail)->car; |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
586 if (VECTORP (elt)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
587 { |
|
9957
940847846909
(access_keymap, store_in_keymap): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents:
9946
diff
changeset
|
588 if (NATNUMP (idx) && XFASTINT (idx) < XVECTOR (elt)->size) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
589 { |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
590 XVECTOR (elt)->contents[XFASTINT (idx)] = def; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
591 return def; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
592 } |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
593 insertion_point = tail; |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
594 } |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
595 else if (CONSP (elt)) |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
596 { |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
597 if (EQ (idx, XCONS (elt)->car)) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
598 { |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
599 XCONS (elt)->cdr = def; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
600 return def; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
601 } |
|
9973
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
602 } |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
603 else if (SYMBOLP (elt)) |
|
1d5a908f201e
(access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9957
diff
changeset
|
604 { |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
605 /* If we find a 'keymap' symbol in the spine of KEYMAP, |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
606 then we must have found the start of a second keymap |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
607 being used as the tail of KEYMAP, and a binding for IDX |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
608 should be inserted before it. */ |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
609 if (EQ (elt, Qkeymap)) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
610 goto keymap_end; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
611 } |
|
1441
929409595312
* keymap.c (store_in_keymap): Don't forget to QUIT in the
Jim Blandy <jimb@redhat.com>
parents:
1388
diff
changeset
|
612 |
|
929409595312
* keymap.c (store_in_keymap): Don't forget to QUIT in the
Jim Blandy <jimb@redhat.com>
parents:
1388
diff
changeset
|
613 QUIT; |
| 250 | 614 } |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
615 |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
616 keymap_end: |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
617 /* We have scanned the entire keymap, and not found a binding for |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
618 IDX. Let's add one. */ |
|
10305
ebb2a456a3e8
(store_in_keymap): While dumping, copy DEF if a cons.
Richard M. Stallman <rms@gnu.org>
parents:
10008
diff
changeset
|
619 XCONS (insertion_point)->cdr |
|
ebb2a456a3e8
(store_in_keymap): While dumping, copy DEF if a cons.
Richard M. Stallman <rms@gnu.org>
parents:
10008
diff
changeset
|
620 = Fcons (Fcons (idx, def), XCONS (insertion_point)->cdr); |
| 250 | 621 } |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
622 |
| 250 | 623 return def; |
| 624 } | |
| 625 | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
626 |
| 250 | 627 DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, |
| 628 "Return a copy of the keymap KEYMAP.\n\ | |
| 629 The copy starts out with the same definitions of KEYMAP,\n\ | |
| 630 but changing either the copy or KEYMAP does not affect the other.\n\ | |
| 362 | 631 Any key definitions that are subkeymaps are recursively copied.\n\ |
| 632 However, a key definition which is a symbol whose definition is a keymap\n\ | |
| 633 is not copied.") | |
| 250 | 634 (keymap) |
| 635 Lisp_Object keymap; | |
| 636 { | |
| 637 register Lisp_Object copy, tail; | |
| 638 | |
| 639 copy = Fcopy_alist (get_keymap (keymap)); | |
| 640 | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
641 for (tail = copy; CONSP (tail); tail = XCONS (tail)->cdr) |
| 250 | 642 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
643 Lisp_Object elt; |
| 250 | 644 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
645 elt = XCONS (tail)->car; |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
646 if (VECTORP (elt)) |
| 250 | 647 { |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
648 int i; |
| 250 | 649 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
650 elt = Fcopy_sequence (elt); |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
651 XCONS (tail)->car = elt; |
| 250 | 652 |
|
2790
cf431814ce6a
(access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents:
2755
diff
changeset
|
653 for (i = 0; i < XVECTOR (elt)->size; i++) |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
654 if (!SYMBOLP (XVECTOR (elt)->contents[i]) |
|
3674
cfa45731460e
(Fcopy_keymap): Check Fkeymapp value with NILP.
Richard M. Stallman <rms@gnu.org>
parents:
3632
diff
changeset
|
655 && ! NILP (Fkeymapp (XVECTOR (elt)->contents[i]))) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
656 XVECTOR (elt)->contents[i] = |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
657 Fcopy_keymap (XVECTOR (elt)->contents[i]); |
| 250 | 658 } |
|
6456
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
659 else if (CONSP (elt)) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
660 { |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
661 /* Skip the optional menu string. */ |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
662 if (CONSP (XCONS (elt)->cdr) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
663 && STRINGP (XCONS (XCONS (elt)->cdr)->car)) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
664 { |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
665 Lisp_Object tem; |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
666 |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
667 /* Copy the cell, since copy-alist didn't go this deep. */ |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
668 XCONS (elt)->cdr = Fcons (XCONS (XCONS (elt)->cdr)->car, |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
669 XCONS (XCONS (elt)->cdr)->cdr); |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
670 elt = XCONS (elt)->cdr; |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
671 |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
672 /* Also skip the optional menu help string. */ |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
673 if (CONSP (XCONS (elt)->cdr) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
674 && STRINGP (XCONS (XCONS (elt)->cdr)->car)) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
675 { |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
676 XCONS (elt)->cdr = Fcons (XCONS (XCONS (elt)->cdr)->car, |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
677 XCONS (XCONS (elt)->cdr)->cdr); |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
678 elt = XCONS (elt)->cdr; |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
679 } |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
680 /* There may also be a list that caches key equivalences. |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
681 Just delete it for the new keymap. */ |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
682 if (CONSP (XCONS (elt)->cdr) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
683 && CONSP (XCONS (XCONS (elt)->cdr)->car) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
684 && (NILP (tem = XCONS (XCONS (XCONS (elt)->cdr)->car)->car) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
685 || VECTORP (tem))) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
686 XCONS (elt)->cdr = XCONS (XCONS (elt)->cdr)->cdr; |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
687 } |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
688 if (CONSP (elt) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
689 && ! SYMBOLP (XCONS (elt)->cdr) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
690 && ! NILP (Fkeymapp (XCONS (elt)->cdr))) |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
691 XCONS (elt)->cdr = Fcopy_keymap (XCONS (elt)->cdr); |
|
9854df0e91e1
(Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents:
6021
diff
changeset
|
692 } |
| 250 | 693 } |
| 694 | |
| 695 return copy; | |
| 696 } | |
| 697 | |
| 465 | 698 /* Simple Keymap mutators and accessors. */ |
| 699 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
700 /* GC is possible in this function if it autoloads a keymap. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
701 |
| 250 | 702 DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0, |
| 703 "Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.\n\ | |
| 704 KEYMAP is a keymap. KEY is a string or a vector of symbols and characters\n\ | |
| 705 meaning a sequence of keystrokes and events.\n\ | |
| 5100 | 706 Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\ |
| 707 can be included if you use a vector.\n\ | |
| 250 | 708 DEF is anything that can be a key's definition:\n\ |
| 709 nil (means key is undefined in this keymap),\n\ | |
| 710 a command (a Lisp function suitable for interactive calling)\n\ | |
| 711 a string (treated as a keyboard macro),\n\ | |
| 712 a keymap (to define a prefix key),\n\ | |
| 713 a symbol. When the key is looked up, the symbol will stand for its\n\ | |
| 714 function definition, which should at that time be one of the above,\n\ | |
| 715 or another symbol whose function definition is used, etc.\n\ | |
| 716 a cons (STRING . DEFN), meaning that DEFN is the definition\n\ | |
| 717 (DEFN should be a valid definition in its own right),\n\ | |
| 368 | 718 or a cons (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP.\n\ |
| 719 \n\ | |
| 720 If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at\n\ | |
| 721 the front of KEYMAP.") | |
| 250 | 722 (keymap, key, def) |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
723 Lisp_Object keymap; |
| 250 | 724 Lisp_Object key; |
| 725 Lisp_Object def; | |
| 726 { | |
| 727 register int idx; | |
| 728 register Lisp_Object c; | |
| 729 register Lisp_Object tem; | |
| 730 register Lisp_Object cmd; | |
| 731 int metized = 0; | |
| 2059 | 732 int meta_bit; |
| 250 | 733 int length; |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
734 struct gcpro gcpro1, gcpro2, gcpro3; |
| 250 | 735 |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
736 keymap = get_keymap_1 (keymap, 1, 1); |
| 250 | 737 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
738 if (!VECTORP (key) && !STRINGP (key)) |
| 250 | 739 key = wrong_type_argument (Qarrayp, key); |
| 740 | |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
741 length = XFASTINT (Flength (key)); |
| 250 | 742 if (length == 0) |
| 743 return Qnil; | |
| 744 | |
|
12297
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
745 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt)) |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
746 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands); |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
747 |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
748 GCPRO3 (keymap, key, def); |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
749 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
750 if (VECTORP (key)) |
| 2059 | 751 meta_bit = meta_modifier; |
| 752 else | |
| 753 meta_bit = 0x80; | |
| 754 | |
| 250 | 755 idx = 0; |
| 756 while (1) | |
| 757 { | |
| 758 c = Faref (key, make_number (idx)); | |
| 759 | |
|
10840
3a7336f191b9
(Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents:
10810
diff
changeset
|
760 if (CONSP (c) && lucid_event_type_list_p (c)) |
|
12151
43b030e896eb
(Flookup_key, Fdefine_key): Use Fevent_convert_list.
Karl Heuer <kwzh@gnu.org>
parents:
11973
diff
changeset
|
761 c = Fevent_convert_list (c); |
|
10840
3a7336f191b9
(Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents:
10810
diff
changeset
|
762 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
763 if (INTEGERP (c) |
| 2059 | 764 && (XINT (c) & meta_bit) |
| 250 | 765 && !metized) |
| 766 { | |
| 767 c = meta_prefix_char; | |
| 768 metized = 1; | |
| 769 } | |
| 770 else | |
| 771 { | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
772 if (INTEGERP (c)) |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
773 XSETINT (c, XINT (c) & ~meta_bit); |
| 250 | 774 |
| 775 metized = 0; | |
| 776 idx++; | |
| 777 } | |
| 778 | |
|
6473
76bb655df959
(Fdefine_key): Check for non-events in keyvector.
Karl Heuer <kwzh@gnu.org>
parents:
6457
diff
changeset
|
779 if (! INTEGERP (c) && ! SYMBOLP (c) && ! CONSP (c)) |
|
8517
a7fe53588b6f
(Fdefine_key): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
8473
diff
changeset
|
780 error ("Key sequence contains invalid events"); |
|
6473
76bb655df959
(Fdefine_key): Check for non-events in keyvector.
Karl Heuer <kwzh@gnu.org>
parents:
6457
diff
changeset
|
781 |
| 250 | 782 if (idx == length) |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
783 RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); |
| 250 | 784 |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
785 cmd = get_keyelt (access_keymap (keymap, c, 0, 1), 1); |
| 250 | 786 |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
787 /* If this key is undefined, make it a prefix. */ |
| 485 | 788 if (NILP (cmd)) |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
789 cmd = define_as_prefix (keymap, c); |
| 250 | 790 |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
791 keymap = get_keymap_1 (cmd, 0, 1); |
|
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
792 if (NILP (keymap)) |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
793 /* We must use Fkey_description rather than just passing key to |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
794 error; key might be a vector, not a string. */ |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
795 error ("Key sequence %s uses invalid prefix characters", |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
796 XSTRING (Fkey_description (key))->data); |
| 250 | 797 } |
| 798 } | |
| 799 | |
| 800 /* Value is number if KEY is too long; NIL if valid but has no definition. */ | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
801 /* GC is possible in this function if it autoloads a keymap. */ |
| 250 | 802 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
803 DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, |
| 250 | 804 "In keymap KEYMAP, look up key sequence KEY. Return the definition.\n\ |
| 805 nil means undefined. See doc of `define-key' for kinds of definitions.\n\ | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
806 \n\ |
| 250 | 807 A number as value means KEY is \"too long\";\n\ |
| 808 that is, characters or symbols in it except for the last one\n\ | |
| 809 fail to be a valid sequence of prefix characters in KEYMAP.\n\ | |
| 810 The number is how many characters at the front of KEY\n\ | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
811 it takes to reach a non-prefix command.\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
812 \n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
813 Normally, `lookup-key' ignores bindings for t, which act as default\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
814 bindings, used when nothing else in the keymap applies; this makes it\n\ |
| 13947 | 815 usable as a general function for probing keymaps. However, if the\n\ |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
816 third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
817 recognize the default bindings, just as `read-key-sequence' does.") |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
818 (keymap, key, accept_default) |
| 250 | 819 register Lisp_Object keymap; |
| 820 Lisp_Object key; | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
821 Lisp_Object accept_default; |
| 250 | 822 { |
| 823 register int idx; | |
| 824 register Lisp_Object tem; | |
| 825 register Lisp_Object cmd; | |
| 826 register Lisp_Object c; | |
| 827 int metized = 0; | |
| 828 int length; | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
829 int t_ok = ! NILP (accept_default); |
| 2059 | 830 int meta_bit; |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
831 struct gcpro gcpro1; |
| 250 | 832 |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
833 keymap = get_keymap_1 (keymap, 1, 1); |
| 250 | 834 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
835 if (!VECTORP (key) && !STRINGP (key)) |
| 250 | 836 key = wrong_type_argument (Qarrayp, key); |
| 837 | |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
838 length = XFASTINT (Flength (key)); |
| 250 | 839 if (length == 0) |
| 840 return keymap; | |
| 841 | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
842 if (VECTORP (key)) |
| 2059 | 843 meta_bit = meta_modifier; |
| 844 else | |
| 845 meta_bit = 0x80; | |
| 846 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
847 GCPRO1 (key); |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
848 |
| 250 | 849 idx = 0; |
| 850 while (1) | |
| 851 { | |
| 852 c = Faref (key, make_number (idx)); | |
| 853 | |
|
10840
3a7336f191b9
(Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents:
10810
diff
changeset
|
854 if (CONSP (c) && lucid_event_type_list_p (c)) |
|
12151
43b030e896eb
(Flookup_key, Fdefine_key): Use Fevent_convert_list.
Karl Heuer <kwzh@gnu.org>
parents:
11973
diff
changeset
|
855 c = Fevent_convert_list (c); |
|
10840
3a7336f191b9
(Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents:
10810
diff
changeset
|
856 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
857 if (INTEGERP (c) |
| 2059 | 858 && (XINT (c) & meta_bit) |
| 250 | 859 && !metized) |
| 860 { | |
| 861 c = meta_prefix_char; | |
| 862 metized = 1; | |
| 863 } | |
| 864 else | |
| 865 { | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
866 if (INTEGERP (c)) |
| 2059 | 867 XSETINT (c, XINT (c) & ~meta_bit); |
| 250 | 868 |
| 869 metized = 0; | |
| 870 idx++; | |
| 871 } | |
| 872 | |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
873 cmd = get_keyelt (access_keymap (keymap, c, t_ok, 0), 1); |
| 250 | 874 if (idx == length) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
875 RETURN_UNGCPRO (cmd); |
| 250 | 876 |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
877 keymap = get_keymap_1 (cmd, 0, 1); |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
878 if (NILP (keymap)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
879 RETURN_UNGCPRO (make_number (idx)); |
| 250 | 880 |
| 881 QUIT; | |
| 882 } | |
| 883 } | |
| 884 | |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
885 /* Make KEYMAP define event C as a keymap (i.e., as a prefix). |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
886 Assume that currently it does not define C at all. |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
887 Return the keymap. */ |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
888 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
889 static Lisp_Object |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
890 define_as_prefix (keymap, c) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
891 Lisp_Object keymap, c; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
892 { |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
893 Lisp_Object inherit, cmd; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
894 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
895 cmd = Fmake_sparse_keymap (Qnil); |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
896 /* If this key is defined as a prefix in an inherited keymap, |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
897 make it a prefix in this map, and make its definition |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
898 inherit the other prefix definition. */ |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
899 inherit = access_keymap (keymap, c, 0, 0); |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
900 #if 0 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
901 /* This code is needed to do the right thing in the following case: |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
902 keymap A inherits from B, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
903 you define KEY as a prefix in A, |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
904 then later you define KEY as a prefix in B. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
905 We want the old prefix definition in A to inherit from that in B. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
906 It is hard to do that retroactively, so this code |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
907 creates the prefix in B right away. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
908 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
909 But it turns out that this code causes problems immediately |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
910 when the prefix in A is defined: it causes B to define KEY |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
911 as a prefix with no subcommands. |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
912 |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
913 So I took out this code. */ |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
914 if (NILP (inherit)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
915 { |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
916 /* If there's an inherited keymap |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
917 and it doesn't define this key, |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
918 make it define this key. */ |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
919 Lisp_Object tail; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
920 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
921 for (tail = Fcdr (keymap); CONSP (tail); tail = XCONS (tail)->cdr) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
922 if (EQ (XCONS (tail)->car, Qkeymap)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
923 break; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
924 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
925 if (!NILP (tail)) |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
926 inherit = define_as_prefix (tail, c); |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
927 } |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
928 #endif |
|
3735
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
929 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
930 cmd = nconc2 (cmd, inherit); |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
931 store_in_keymap (keymap, c, cmd); |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
932 |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
933 return cmd; |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
934 } |
|
7193a99a87c1
Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents:
3691
diff
changeset
|
935 |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
936 /* Append a key to the end of a key sequence. We always make a vector. */ |
|
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
937 |
| 250 | 938 Lisp_Object |
| 939 append_key (key_sequence, key) | |
| 940 Lisp_Object key_sequence, key; | |
| 941 { | |
| 942 Lisp_Object args[2]; | |
| 943 | |
| 944 args[0] = key_sequence; | |
| 945 | |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
946 args[1] = Fcons (key, Qnil); |
|
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
947 return Fvconcat (2, args); |
| 250 | 948 } |
| 949 | |
| 950 | |
| 465 | 951 /* Global, local, and minor mode keymap stuff. */ |
| 952 | |
| 485 | 953 /* We can't put these variables inside current_minor_maps, since under |
| 517 | 954 some systems, static gets macro-defined to be the empty string. |
| 955 Ickypoo. */ | |
| 485 | 956 static Lisp_Object *cmm_modes, *cmm_maps; |
| 957 static int cmm_size; | |
| 958 | |
|
12542
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
959 /* Error handler used in current_minor_maps. */ |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
960 static Lisp_Object |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
961 current_minor_maps_error () |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
962 { |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
963 return Qnil; |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
964 } |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
965 |
| 465 | 966 /* Store a pointer to an array of the keymaps of the currently active |
| 967 minor modes in *buf, and return the number of maps it contains. | |
| 968 | |
| 969 This function always returns a pointer to the same buffer, and may | |
| 970 free or reallocate it, so if you want to keep it for a long time or | |
| 971 hand it out to lisp code, copy it. This procedure will be called | |
| 972 for every key sequence read, so the nice lispy approach (return a | |
| 973 new assoclist, list, what have you) for each invocation would | |
| 974 result in a lot of consing over time. | |
| 975 | |
| 976 If we used xrealloc/xmalloc and ran out of memory, they would throw | |
| 977 back to the command loop, which would try to read a key sequence, | |
| 978 which would call this function again, resulting in an infinite | |
| 979 loop. Instead, we'll use realloc/malloc and silently truncate the | |
| 980 list, let the key sequence be read, and hope some other piece of | |
| 981 code signals the error. */ | |
| 982 int | |
| 983 current_minor_maps (modeptr, mapptr) | |
| 984 Lisp_Object **modeptr, **mapptr; | |
| 985 { | |
| 986 int i = 0; | |
| 517 | 987 Lisp_Object alist, assoc, var, val; |
| 465 | 988 |
| 989 for (alist = Vminor_mode_map_alist; | |
| 990 CONSP (alist); | |
| 991 alist = XCONS (alist)->cdr) | |
|
9946
571ddbef914a
(current_minor_maps): Avoid assignments in arguments to a type-test macro.
Karl Heuer <kwzh@gnu.org>
parents:
9862
diff
changeset
|
992 if ((assoc = XCONS (alist)->car, CONSP (assoc)) |
|
571ddbef914a
(current_minor_maps): Avoid assignments in arguments to a type-test macro.
Karl Heuer <kwzh@gnu.org>
parents:
9862
diff
changeset
|
993 && (var = XCONS (assoc)->car, SYMBOLP (var)) |
|
571ddbef914a
(current_minor_maps): Avoid assignments in arguments to a type-test macro.
Karl Heuer <kwzh@gnu.org>
parents:
9862
diff
changeset
|
994 && (val = find_symbol_value (var), ! EQ (val, Qunbound)) |
| 517 | 995 && ! NILP (val)) |
| 465 | 996 { |
|
12542
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
997 Lisp_Object temp; |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
998 |
| 485 | 999 if (i >= cmm_size) |
| 465 | 1000 { |
| 1001 Lisp_Object *newmodes, *newmaps; | |
| 1002 | |
| 485 | 1003 if (cmm_maps) |
| 465 | 1004 { |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2358
diff
changeset
|
1005 BLOCK_INPUT; |
|
5691
a93fc56763fd
Scale by sizeof when allocating objects.
Karl Heuer <kwzh@gnu.org>
parents:
5613
diff
changeset
|
1006 cmm_size *= 2; |
| 5704 | 1007 newmodes |
| 1008 = (Lisp_Object *) realloc (cmm_modes, | |
| 1009 cmm_size * sizeof (Lisp_Object)); | |
| 1010 newmaps | |
| 1011 = (Lisp_Object *) realloc (cmm_maps, | |
| 1012 cmm_size * sizeof (Lisp_Object)); | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2358
diff
changeset
|
1013 UNBLOCK_INPUT; |
| 465 | 1014 } |
| 1015 else | |
| 1016 { | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2358
diff
changeset
|
1017 BLOCK_INPUT; |
|
5691
a93fc56763fd
Scale by sizeof when allocating objects.
Karl Heuer <kwzh@gnu.org>
parents:
5613
diff
changeset
|
1018 cmm_size = 30; |
| 5704 | 1019 newmodes |
| 1020 = (Lisp_Object *) malloc (cmm_size * sizeof (Lisp_Object)); | |
| 1021 newmaps | |
| 1022 = (Lisp_Object *) malloc (cmm_size * sizeof (Lisp_Object)); | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2358
diff
changeset
|
1023 UNBLOCK_INPUT; |
| 465 | 1024 } |
| 1025 | |
| 1026 if (newmaps && newmodes) | |
| 1027 { | |
| 485 | 1028 cmm_modes = newmodes; |
| 1029 cmm_maps = newmaps; | |
| 465 | 1030 } |
| 1031 else | |
| 1032 break; | |
| 1033 } | |
|
12542
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1034 |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1035 /* Get the keymap definition--or nil if it is not defined. */ |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1036 temp = internal_condition_case_1 (Findirect_function, |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1037 XCONS (assoc)->cdr, |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1038 Qerror, current_minor_maps_error); |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1039 if (!NILP (temp)) |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1040 { |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1041 cmm_modes[i] = var; |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1042 cmm_maps [i] = temp; |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1043 i++; |
|
f86a10208f7e
(current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents:
12297
diff
changeset
|
1044 } |
| 465 | 1045 } |
| 1046 | |
| 485 | 1047 if (modeptr) *modeptr = cmm_modes; |
| 1048 if (mapptr) *mapptr = cmm_maps; | |
| 465 | 1049 return i; |
| 1050 } | |
| 1051 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1052 /* GC is possible in this function if it autoloads a keymap. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1053 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1054 DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 2, 0, |
| 250 | 1055 "Return the binding for command KEY in current keymaps.\n\ |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1056 KEY is a string or vector, a sequence of keystrokes.\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1057 The binding is probably a symbol with a function definition.\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1058 \n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1059 Normally, `key-binding' ignores bindings for t, which act as default\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1060 bindings, used when nothing else in the keymap applies; this makes it\n\ |
|
5055
bbe5bba17b10
(Fkey_binding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1061 usable as a general function for probing keymaps. However, if the\n\ |
|
bbe5bba17b10
(Fkey_binding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1062 optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does\n\ |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1063 recognize the default bindings, just as `read-key-sequence' does.") |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1064 (key, accept_default) |
|
6834
6a77fcbb5d44
(Fkey_binding): Declare accept_default.
Richard M. Stallman <rms@gnu.org>
parents:
6774
diff
changeset
|
1065 Lisp_Object key, accept_default; |
| 250 | 1066 { |
| 465 | 1067 Lisp_Object *maps, value; |
| 1068 int nmaps, i; | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1069 struct gcpro gcpro1; |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1070 |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1071 GCPRO1 (key); |
| 465 | 1072 |
|
12262
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1073 if (!NILP (current_kboard->Voverriding_terminal_local_map)) |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1074 { |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1075 value = Flookup_key (current_kboard->Voverriding_terminal_local_map, |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1076 key, accept_default); |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1077 if (! NILP (value) && !INTEGERP (value)) |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1078 RETURN_UNGCPRO (value); |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1079 } |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
1080 else if (!NILP (Voverriding_local_map)) |
| 250 | 1081 { |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1082 value = Flookup_key (Voverriding_local_map, key, accept_default); |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1083 if (! NILP (value) && !INTEGERP (value)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1084 RETURN_UNGCPRO (value); |
| 250 | 1085 } |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1086 else |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1087 { |
|
13771
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1088 Lisp_Object local; |
|
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1089 |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1090 nmaps = current_minor_maps (0, &maps); |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1091 /* Note that all these maps are GCPRO'd |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1092 in the places where we found them. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1093 |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1094 for (i = 0; i < nmaps; i++) |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1095 if (! NILP (maps[i])) |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1096 { |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1097 value = Flookup_key (maps[i], key, accept_default); |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1098 if (! NILP (value) && !INTEGERP (value)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1099 RETURN_UNGCPRO (value); |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1100 } |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1101 |
|
13771
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1102 local = get_local_map (PT, current_buffer); |
|
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1103 |
|
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1104 if (! NILP (local)) |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1105 { |
|
13771
28790743a5a3
(Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents:
13343
diff
changeset
|
1106 value = Flookup_key (local, key, accept_default); |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1107 if (! NILP (value) && !INTEGERP (value)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1108 RETURN_UNGCPRO (value); |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1109 } |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
1110 } |
| 465 | 1111 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1112 value = Flookup_key (current_global_map, key, accept_default); |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1113 UNGCPRO; |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1114 if (! NILP (value) && !INTEGERP (value)) |
| 465 | 1115 return value; |
| 1116 | |
| 1117 return Qnil; | |
| 250 | 1118 } |
| 1119 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1120 /* GC is possible in this function if it autoloads a keymap. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1121 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1122 DEFUN ("local-key-binding", Flocal_key_binding, Slocal_key_binding, 1, 2, 0, |
| 250 | 1123 "Return the binding for command KEYS in current local keymap only.\n\ |
| 1124 KEYS is a string, a sequence of keystrokes.\n\ | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1125 The binding is probably a symbol with a function definition.\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1126 \n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1127 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1128 bindings; see the description of `lookup-key' for more details about this.") |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1129 (keys, accept_default) |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1130 Lisp_Object keys, accept_default; |
| 250 | 1131 { |
| 1132 register Lisp_Object map; | |
| 1133 map = current_buffer->keymap; | |
| 485 | 1134 if (NILP (map)) |
| 250 | 1135 return Qnil; |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1136 return Flookup_key (map, keys, accept_default); |
| 250 | 1137 } |
| 1138 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1139 /* GC is possible in this function if it autoloads a keymap. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1140 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1141 DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 2, 0, |
| 250 | 1142 "Return the binding for command KEYS in current global keymap only.\n\ |
| 1143 KEYS is a string, a sequence of keystrokes.\n\ | |
| 517 | 1144 The binding is probably a symbol with a function definition.\n\ |
| 1145 This function's return values are the same as those of lookup-key\n\ | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1146 \(which see).\n\ |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1147 \n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1148 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1149 bindings; see the description of `lookup-key' for more details about this.") |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1150 (keys, accept_default) |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1151 Lisp_Object keys, accept_default; |
| 250 | 1152 { |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1153 return Flookup_key (current_global_map, keys, accept_default); |
| 250 | 1154 } |
| 1155 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1156 /* GC is possible in this function if it autoloads a keymap. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1157 |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1158 DEFUN ("minor-mode-key-binding", Fminor_mode_key_binding, Sminor_mode_key_binding, 1, 2, 0, |
| 465 | 1159 "Find the visible minor mode bindings of KEY.\n\ |
| 1160 Return an alist of pairs (MODENAME . BINDING), where MODENAME is the\n\ | |
| 1161 the symbol which names the minor mode binding KEY, and BINDING is\n\ | |
| 1162 KEY's definition in that mode. In particular, if KEY has no\n\ | |
| 1163 minor-mode bindings, return nil. If the first binding is a\n\ | |
| 1164 non-prefix, all subsequent bindings will be omitted, since they would\n\ | |
| 1165 be ignored. Similarly, the list doesn't include non-prefix bindings\n\ | |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1166 that come after prefix bindings.\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1167 \n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1168 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\ |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1169 bindings; see the description of `lookup-key' for more details about this.") |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1170 (key, accept_default) |
|
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1171 Lisp_Object key, accept_default; |
| 465 | 1172 { |
| 1173 Lisp_Object *modes, *maps; | |
| 1174 int nmaps; | |
| 1175 Lisp_Object binding; | |
| 1176 int i, j; | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1177 struct gcpro gcpro1, gcpro2; |
| 465 | 1178 |
| 1179 nmaps = current_minor_maps (&modes, &maps); | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1180 /* Note that all these maps are GCPRO'd |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1181 in the places where we found them. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1182 |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1183 binding = Qnil; |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1184 GCPRO2 (key, binding); |
| 465 | 1185 |
| 1186 for (i = j = 0; i < nmaps; i++) | |
| 485 | 1187 if (! NILP (maps[i]) |
|
1871
00bee181f7ed
* keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1188 && ! NILP (binding = Flookup_key (maps[i], key, accept_default)) |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1189 && !INTEGERP (binding)) |
| 465 | 1190 { |
|
1517
72b7bbcaf7d8
* keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents:
1441
diff
changeset
|
1191 if (! NILP (get_keymap (binding))) |
| 465 | 1192 maps[j++] = Fcons (modes[i], binding); |
| 1193 else if (j == 0) | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1194 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); |
| 465 | 1195 } |
| 1196 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1197 UNGCPRO; |
| 465 | 1198 return Flist (j, maps); |
| 1199 } | |
| 1200 | |
| 250 | 1201 DEFUN ("define-prefix-command", Fdefine_prefix_command, Sdefine_prefix_command, 1, 2, 0, |
|
2652
90485f37bfc3
* keymap.c (Fdefine_prefix_command): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1202 "Define COMMAND as a prefix command. COMMAND should be a symbol.\n\ |
| 250 | 1203 A new sparse keymap is stored as COMMAND's function definition and its value.\n\ |
| 362 | 1204 If a second optional argument MAPVAR is given, the map is stored as\n\ |
| 1205 its value instead of as COMMAND's value; but COMMAND is still defined\n\ | |
| 1206 as a function.") | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1207 (command, mapvar) |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1208 Lisp_Object command, mapvar; |
| 250 | 1209 { |
| 1210 Lisp_Object map; | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
1211 map = Fmake_sparse_keymap (Qnil); |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1212 Ffset (command, map); |
| 485 | 1213 if (!NILP (mapvar)) |
| 250 | 1214 Fset (mapvar, map); |
| 1215 else | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1216 Fset (command, map); |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1217 return command; |
| 250 | 1218 } |
| 1219 | |
| 1220 DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, | |
| 1221 "Select KEYMAP as the global keymap.") | |
| 1222 (keymap) | |
| 1223 Lisp_Object keymap; | |
| 1224 { | |
| 1225 keymap = get_keymap (keymap); | |
| 1226 current_global_map = keymap; | |
|
8464
edbb014c600a
(Fuse_global_map, Fuse_local_map): Call record_asynch_buffer_change.
Richard M. Stallman <rms@gnu.org>
parents:
8431
diff
changeset
|
1227 |
| 250 | 1228 return Qnil; |
| 1229 } | |
| 1230 | |
| 1231 DEFUN ("use-local-map", Fuse_local_map, Suse_local_map, 1, 1, 0, | |
| 1232 "Select KEYMAP as the local keymap.\n\ | |
| 1233 If KEYMAP is nil, that means no local keymap.") | |
| 1234 (keymap) | |
| 1235 Lisp_Object keymap; | |
| 1236 { | |
| 485 | 1237 if (!NILP (keymap)) |
| 250 | 1238 keymap = get_keymap (keymap); |
| 1239 | |
| 1240 current_buffer->keymap = keymap; | |
| 1241 | |
| 1242 return Qnil; | |
| 1243 } | |
| 1244 | |
| 1245 DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0, | |
| 1246 "Return current buffer's local keymap, or nil if it has none.") | |
| 1247 () | |
| 1248 { | |
| 1249 return current_buffer->keymap; | |
| 1250 } | |
| 1251 | |
| 1252 DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0, | |
| 1253 "Return the current global keymap.") | |
| 1254 () | |
| 1255 { | |
| 1256 return current_global_map; | |
| 1257 } | |
| 465 | 1258 |
| 1259 DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_maps, 0, 0, 0, | |
| 1260 "Return a list of keymaps for the minor modes of the current buffer.") | |
| 1261 () | |
| 1262 { | |
| 1263 Lisp_Object *maps; | |
| 1264 int nmaps = current_minor_maps (0, &maps); | |
| 1265 | |
| 1266 return Flist (nmaps, maps); | |
| 1267 } | |
| 250 | 1268 |
| 465 | 1269 /* Help functions for describing and documenting keymaps. */ |
| 1270 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1271 /* This function cannot GC. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1272 |
| 250 | 1273 DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps, |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1274 1, 2, 0, |
| 250 | 1275 "Find all keymaps accessible via prefix characters from KEYMAP.\n\ |
| 1276 Returns a list of elements of the form (KEYS . MAP), where the sequence\n\ | |
| 1277 KEYS starting from KEYMAP gets you to MAP. These elements are ordered\n\ | |
|
14304
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1278 so that the KEYS increase in length. The first element is ([] . KEYMAP).\n\ |
|
3962
38041a5069a8
(Faccessible_keymaps): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3952
diff
changeset
|
1279 An optional argument PREFIX, if non-nil, should be a key sequence;\n\ |
|
38041a5069a8
(Faccessible_keymaps): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3952
diff
changeset
|
1280 then the value includes only maps for prefixes that start with PREFIX.") |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1281 (keymap, prefix) |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1282 Lisp_Object keymap, prefix; |
| 250 | 1283 { |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1284 Lisp_Object maps, good_maps, tail; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1285 int prefixlen = 0; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1286 |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1287 /* no need for gcpro because we don't autoload any keymaps. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1288 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1289 if (!NILP (prefix)) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1290 prefixlen = XINT (Flength (prefix)); |
| 250 | 1291 |
|
8431
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1292 if (!NILP (prefix)) |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1293 { |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1294 /* If a prefix was specified, start with the keymap (if any) for |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1295 that prefix, so we don't waste time considering other prefixes. */ |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1296 Lisp_Object tem; |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1297 tem = Flookup_key (keymap, prefix, Qt); |
|
8473
c285c3b0ea54
(Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8464
diff
changeset
|
1298 /* Flookup_key may give us nil, or a number, |
|
c285c3b0ea54
(Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8464
diff
changeset
|
1299 if the prefix is not defined in this particular map. |
|
c285c3b0ea54
(Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8464
diff
changeset
|
1300 It might even give us a list that isn't a keymap. */ |
|
c285c3b0ea54
(Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8464
diff
changeset
|
1301 tem = get_keymap_1 (tem, 0, 0); |
|
8431
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1302 if (!NILP (tem)) |
|
8473
c285c3b0ea54
(Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8464
diff
changeset
|
1303 maps = Fcons (Fcons (prefix, tem), Qnil); |
|
8431
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1304 else |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1305 return Qnil; |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1306 } |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1307 else |
|
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1308 maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1309 get_keymap (keymap)), |
|
8431
b4138573c00f
(Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents:
7998
diff
changeset
|
1310 Qnil); |
| 250 | 1311 |
| 1312 /* For each map in the list maps, | |
| 1313 look at any other maps it points to, | |
| 1314 and stick them at the end if they are not already in the list. | |
| 1315 | |
| 1316 This is a breadth-first traversal, where tail is the queue of | |
| 1317 nodes, and maps accumulates a list of all nodes visited. */ | |
| 1318 | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1319 for (tail = maps; CONSP (tail); tail = XCONS (tail)->cdr) |
| 250 | 1320 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1321 register Lisp_Object thisseq, thismap; |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1322 Lisp_Object last; |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1323 /* Does the current sequence end in the meta-prefix-char? */ |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1324 int is_metized; |
| 250 | 1325 |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1326 thisseq = Fcar (Fcar (tail)); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1327 thismap = Fcdr (Fcar (tail)); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1328 last = make_number (XINT (Flength (thisseq)) - 1); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1329 is_metized = (XINT (last) >= 0 |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1330 && EQ (Faref (thisseq, last), meta_prefix_char)); |
| 250 | 1331 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1332 for (; CONSP (thismap); thismap = XCONS (thismap)->cdr) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1333 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1334 Lisp_Object elt; |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1335 |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1336 elt = XCONS (thismap)->car; |
| 250 | 1337 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1338 QUIT; |
| 250 | 1339 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1340 if (VECTORP (elt)) |
| 250 | 1341 { |
| 1342 register int i; | |
| 1343 | |
| 1344 /* Vector keymap. Scan all the elements. */ | |
|
2752
93eda5bbc4df
(Faccessible_keymaps): Use whatever size the vector has.
Richard M. Stallman <rms@gnu.org>
parents:
2727
diff
changeset
|
1345 for (i = 0; i < XVECTOR (elt)->size; i++) |
| 250 | 1346 { |
| 1347 register Lisp_Object tem; | |
| 1348 register Lisp_Object cmd; | |
| 1349 | |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
1350 cmd = get_keyelt (XVECTOR (elt)->contents[i], 0); |
| 485 | 1351 if (NILP (cmd)) continue; |
| 250 | 1352 tem = Fkeymapp (cmd); |
| 485 | 1353 if (!NILP (tem)) |
| 250 | 1354 { |
| 1355 cmd = get_keymap (cmd); | |
| 1356 /* Ignore keymaps that are already added to maps. */ | |
| 1357 tem = Frassq (cmd, maps); | |
| 485 | 1358 if (NILP (tem)) |
| 250 | 1359 { |
| 1360 /* If the last key in thisseq is meta-prefix-char, | |
| 1361 turn it into a meta-ized keystroke. We know | |
| 1362 that the event we're about to append is an | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1363 ascii keystroke since we're processing a |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1364 keymap table. */ |
| 250 | 1365 if (is_metized) |
| 1366 { | |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1367 int meta_bit = meta_modifier; |
| 250 | 1368 tem = Fcopy_sequence (thisseq); |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1369 |
|
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1370 Faset (tem, last, make_number (i | meta_bit)); |
| 250 | 1371 |
| 1372 /* This new sequence is the same length as | |
| 1373 thisseq, so stick it in the list right | |
| 1374 after this one. */ | |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1375 XCONS (tail)->cdr |
|
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1376 = Fcons (Fcons (tem, cmd), XCONS (tail)->cdr); |
| 250 | 1377 } |
| 1378 else | |
| 1379 { | |
| 1380 tem = append_key (thisseq, make_number (i)); | |
| 1381 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); | |
| 1382 } | |
| 1383 } | |
| 1384 } | |
| 1385 } | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1386 } |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1387 else if (CONSP (elt)) |
| 250 | 1388 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1389 register Lisp_Object cmd, tem, filter; |
| 250 | 1390 |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
1391 cmd = get_keyelt (XCONS (elt)->cdr, 0); |
| 250 | 1392 /* Ignore definitions that aren't keymaps themselves. */ |
| 1393 tem = Fkeymapp (cmd); | |
| 485 | 1394 if (!NILP (tem)) |
| 250 | 1395 { |
| 1396 /* Ignore keymaps that have been seen already. */ | |
| 1397 cmd = get_keymap (cmd); | |
| 1398 tem = Frassq (cmd, maps); | |
| 485 | 1399 if (NILP (tem)) |
| 250 | 1400 { |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1401 /* Let elt be the event defined by this map entry. */ |
| 250 | 1402 elt = XCONS (elt)->car; |
| 1403 | |
| 1404 /* If the last key in thisseq is meta-prefix-char, and | |
| 1405 this entry is a binding for an ascii keystroke, | |
| 1406 turn it into a meta-ized keystroke. */ | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1407 if (is_metized && INTEGERP (elt)) |
| 250 | 1408 { |
| 1409 tem = Fcopy_sequence (thisseq); | |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1410 Faset (tem, last, |
|
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1411 make_number (XINT (elt) | meta_modifier)); |
| 250 | 1412 |
| 1413 /* This new sequence is the same length as | |
| 1414 thisseq, so stick it in the list right | |
| 1415 after this one. */ | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1416 XCONS (tail)->cdr |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1417 = Fcons (Fcons (tem, cmd), XCONS (tail)->cdr); |
| 250 | 1418 } |
| 1419 else | |
| 1420 nconc2 (tail, | |
| 1421 Fcons (Fcons (append_key (thisseq, elt), cmd), | |
| 1422 Qnil)); | |
| 1423 } | |
| 1424 } | |
| 1425 } | |
| 1426 } | |
| 1427 } | |
| 1428 | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1429 if (NILP (prefix)) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1430 return maps; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1431 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1432 /* Now find just the maps whose access prefixes start with PREFIX. */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1433 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1434 good_maps = Qnil; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1435 for (; CONSP (maps); maps = XCONS (maps)->cdr) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1436 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1437 Lisp_Object elt, thisseq; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1438 elt = XCONS (maps)->car; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1439 thisseq = XCONS (elt)->car; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1440 /* The access prefix must be at least as long as PREFIX, |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1441 and the first elements must match those of PREFIX. */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1442 if (XINT (Flength (thisseq)) >= prefixlen) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1443 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1444 int i; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1445 for (i = 0; i < prefixlen; i++) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1446 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1447 Lisp_Object i1; |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1448 XSETFASTINT (i1, i); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1449 if (!EQ (Faref (thisseq, i1), Faref (prefix, i1))) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1450 break; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1451 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1452 if (i == prefixlen) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1453 good_maps = Fcons (elt, good_maps); |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1454 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1455 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1456 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1457 return Fnreverse (good_maps); |
| 250 | 1458 } |
| 1459 | |
| 1460 Lisp_Object Qsingle_key_description, Qkey_description; | |
| 1461 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1462 /* This function cannot GC. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1463 |
| 250 | 1464 DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0, |
| 1465 "Return a pretty description of key-sequence KEYS.\n\ | |
| 1466 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\"\n\ | |
| 1467 spaces are put between sequence elements, etc.") | |
| 1468 (keys) | |
| 1469 Lisp_Object keys; | |
| 1470 { | |
|
7809
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1471 int len; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1472 int i; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1473 Lisp_Object sep; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1474 Lisp_Object *args; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1475 |
|
8866
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
1476 if (STRINGP (keys)) |
| 2059 | 1477 { |
| 1478 Lisp_Object vector; | |
| 1479 vector = Fmake_vector (Flength (keys), Qnil); | |
| 1480 for (i = 0; i < XSTRING (keys)->size; i++) | |
| 1481 { | |
| 1482 if (XSTRING (keys)->data[i] & 0x80) | |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1483 XSETFASTINT (XVECTOR (vector)->contents[i], |
|
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1484 meta_modifier | (XSTRING (keys)->data[i] & ~0x80)); |
| 2059 | 1485 else |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1486 XSETFASTINT (XVECTOR (vector)->contents[i], |
|
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1487 XSTRING (keys)->data[i]); |
| 2059 | 1488 } |
| 1489 keys = vector; | |
| 1490 } | |
|
8922
67b7eb875a1e
(Fkey_description): Reverse condition.
Karl Heuer <kwzh@gnu.org>
parents:
8866
diff
changeset
|
1491 else if (!VECTORP (keys)) |
|
8866
48a0ea73a9d7
(Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents:
8731
diff
changeset
|
1492 keys = wrong_type_argument (Qarrayp, keys); |
|
7809
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1493 |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1494 /* In effect, this computes |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1495 (mapconcat 'single-key-description keys " ") |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1496 but we shouldn't use mapconcat because it can do GC. */ |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1497 |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1498 len = XVECTOR (keys)->size; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1499 sep = build_string (" "); |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1500 /* This has one extra element at the end that we don't pass to Fconcat. */ |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1501 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object)); |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1502 |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1503 for (i = 0; i < len; i++) |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1504 { |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1505 args[i * 2] = Fsingle_key_description (XVECTOR (keys)->contents[i]); |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1506 args[i * 2 + 1] = sep; |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1507 } |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1508 |
|
cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents:
7669
diff
changeset
|
1509 return Fconcat (len * 2 - 1, args); |
| 250 | 1510 } |
| 1511 | |
| 1512 char * | |
| 1513 push_key_description (c, p) | |
| 1514 register unsigned int c; | |
| 1515 register char *p; | |
| 1516 { | |
|
2343
ddb30eaf2f56
(push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents:
2093
diff
changeset
|
1517 /* Clear all the meaningless bits above the meta bit. */ |
|
ddb30eaf2f56
(push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents:
2093
diff
changeset
|
1518 c &= meta_modifier | ~ - meta_modifier; |
|
ddb30eaf2f56
(push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents:
2093
diff
changeset
|
1519 |
| 2059 | 1520 if (c & alt_modifier) |
| 1521 { | |
| 1522 *p++ = 'A'; | |
| 1523 *p++ = '-'; | |
| 1524 c -= alt_modifier; | |
| 1525 } | |
| 1526 if (c & ctrl_modifier) | |
| 1527 { | |
| 1528 *p++ = 'C'; | |
| 1529 *p++ = '-'; | |
| 1530 c -= ctrl_modifier; | |
| 1531 } | |
| 1532 if (c & hyper_modifier) | |
| 1533 { | |
| 1534 *p++ = 'H'; | |
| 1535 *p++ = '-'; | |
| 1536 c -= hyper_modifier; | |
| 1537 } | |
| 1538 if (c & meta_modifier) | |
| 250 | 1539 { |
| 1540 *p++ = 'M'; | |
| 1541 *p++ = '-'; | |
| 2059 | 1542 c -= meta_modifier; |
| 1543 } | |
| 1544 if (c & shift_modifier) | |
| 1545 { | |
| 1546 *p++ = 'S'; | |
| 1547 *p++ = '-'; | |
| 1548 c -= shift_modifier; | |
| 1549 } | |
| 1550 if (c & super_modifier) | |
| 1551 { | |
| 1552 *p++ = 's'; | |
| 1553 *p++ = '-'; | |
| 1554 c -= super_modifier; | |
| 250 | 1555 } |
| 1556 if (c < 040) | |
| 1557 { | |
| 1558 if (c == 033) | |
| 1559 { | |
| 1560 *p++ = 'E'; | |
| 1561 *p++ = 'S'; | |
| 1562 *p++ = 'C'; | |
| 1563 } | |
| 2059 | 1564 else if (c == '\t') |
| 250 | 1565 { |
| 1566 *p++ = 'T'; | |
| 1567 *p++ = 'A'; | |
| 1568 *p++ = 'B'; | |
| 1569 } | |
|
16875
d9956cf6699b
(push_key_description): Print C-j, not TAB.
Richard M. Stallman <rms@gnu.org>
parents:
16465
diff
changeset
|
1570 else if (c == Ctl ('M')) |
| 250 | 1571 { |
| 1572 *p++ = 'R'; | |
| 1573 *p++ = 'E'; | |
| 1574 *p++ = 'T'; | |
| 1575 } | |
| 1576 else | |
| 1577 { | |
| 1578 *p++ = 'C'; | |
| 1579 *p++ = '-'; | |
| 1580 if (c > 0 && c <= Ctl ('Z')) | |
| 1581 *p++ = c + 0140; | |
| 1582 else | |
| 1583 *p++ = c + 0100; | |
| 1584 } | |
| 1585 } | |
| 1586 else if (c == 0177) | |
| 1587 { | |
| 1588 *p++ = 'D'; | |
| 1589 *p++ = 'E'; | |
| 1590 *p++ = 'L'; | |
| 1591 } | |
| 1592 else if (c == ' ') | |
| 1593 { | |
| 1594 *p++ = 'S'; | |
| 1595 *p++ = 'P'; | |
| 1596 *p++ = 'C'; | |
| 1597 } | |
| 17036 | 1598 else if (c < 128) |
| 1599 *p++ = c; | |
| 2059 | 1600 else if (c < 256) |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1601 *p++ = c; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1602 else if (c < 512) |
| 17036 | 1603 { |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1604 *p++ = '\\'; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1605 *p++ = (7 & (c >> 6)) + '0'; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1606 *p++ = (7 & (c >> 3)) + '0'; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
1607 *p++ = (7 & (c >> 0)) + '0'; |
| 17036 | 1608 } |
| 250 | 1609 else |
| 2059 | 1610 { |
| 1611 *p++ = '\\'; | |
| 1612 *p++ = (7 & (c >> 15)) + '0'; | |
| 1613 *p++ = (7 & (c >> 12)) + '0'; | |
| 1614 *p++ = (7 & (c >> 9)) + '0'; | |
| 1615 *p++ = (7 & (c >> 6)) + '0'; | |
| 1616 *p++ = (7 & (c >> 3)) + '0'; | |
| 1617 *p++ = (7 & (c >> 0)) + '0'; | |
| 1618 } | |
| 250 | 1619 |
| 1620 return p; | |
| 1621 } | |
| 1622 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1623 /* This function cannot GC. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1624 |
| 250 | 1625 DEFUN ("single-key-description", Fsingle_key_description, Ssingle_key_description, 1, 1, 0, |
| 1626 "Return a pretty description of command character KEY.\n\ | |
| 1627 Control characters turn into C-whatever, etc.") | |
| 1628 (key) | |
| 1629 Lisp_Object key; | |
| 1630 { | |
| 2059 | 1631 char tem[20]; |
| 250 | 1632 |
|
1315
884c3d7e7172
* keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents:
1264
diff
changeset
|
1633 key = EVENT_HEAD (key); |
| 517 | 1634 |
|
10008
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1635 if (INTEGERP (key)) /* Normal character */ |
| 250 | 1636 { |
| 2059 | 1637 *push_key_description (XUINT (key), tem) = 0; |
| 250 | 1638 return build_string (tem); |
| 1639 } | |
|
10008
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1640 else if (SYMBOLP (key)) /* Function key or event-symbol */ |
|
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1641 return Fsymbol_name (key); |
|
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1642 else if (STRINGP (key)) /* Buffer names in the menubar. */ |
|
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1643 return Fcopy_sequence (key); |
|
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1644 else |
|
b83150a8020d
(Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9973
diff
changeset
|
1645 error ("KEY must be an integer, cons, symbol, or string"); |
| 250 | 1646 } |
| 1647 | |
| 1648 char * | |
| 1649 push_text_char_description (c, p) | |
| 1650 register unsigned int c; | |
| 1651 register char *p; | |
| 1652 { | |
| 1653 if (c >= 0200) | |
| 1654 { | |
| 1655 *p++ = 'M'; | |
| 1656 *p++ = '-'; | |
| 1657 c -= 0200; | |
| 1658 } | |
| 1659 if (c < 040) | |
| 1660 { | |
| 1661 *p++ = '^'; | |
| 1662 *p++ = c + 64; /* 'A' - 1 */ | |
| 1663 } | |
| 1664 else if (c == 0177) | |
| 1665 { | |
| 1666 *p++ = '^'; | |
| 1667 *p++ = '?'; | |
| 1668 } | |
| 1669 else | |
| 1670 *p++ = c; | |
| 1671 return p; | |
| 1672 } | |
| 1673 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1674 /* This function cannot GC. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1675 |
| 250 | 1676 DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0, |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1677 "Return a pretty description of file-character CHARACTER.\n\ |
| 250 | 1678 Control characters turn into \"^char\", etc.") |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1679 (character) |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1680 Lisp_Object character; |
| 250 | 1681 { |
| 1682 char tem[6]; | |
| 1683 | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1684 CHECK_NUMBER (character, 0); |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1685 |
| 17036 | 1686 if (!SINGLE_BYTE_CHAR_P (XFASTINT (character))) |
| 1687 { | |
| 1688 char *str; | |
| 1689 int len = non_ascii_char_to_string (XFASTINT (character), tem, &str); | |
| 1690 | |
| 1691 return make_string (str, len); | |
| 1692 } | |
| 1693 | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
1694 *push_text_char_description (XINT (character) & 0377, tem) = 0; |
| 250 | 1695 |
| 1696 return build_string (tem); | |
| 1697 } | |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1698 |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1699 /* Return non-zero if SEQ contains only ASCII characters, perhaps with |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1700 a meta bit. */ |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1701 static int |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1702 ascii_sequence_p (seq) |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1703 Lisp_Object seq; |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1704 { |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1705 int i; |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1706 int len = XINT (Flength (seq)); |
|
6008
d3ccce72be00
(get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents:
5785
diff
changeset
|
1707 |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1708 for (i = 0; i < len; i++) |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1709 { |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1710 Lisp_Object ii, elt; |
|
6008
d3ccce72be00
(get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents:
5785
diff
changeset
|
1711 |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1712 XSETFASTINT (ii, i); |
|
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1713 elt = Faref (seq, ii); |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1714 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1715 if (!INTEGERP (elt) |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1716 || (XUINT (elt) & ~CHAR_META) >= 0x80) |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1717 return 0; |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1718 } |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1719 |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1720 return 1; |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1721 } |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1722 |
| 250 | 1723 |
| 465 | 1724 /* where-is - finding a command in a set of keymaps. */ |
| 1725 | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1726 /* This function can GC if Flookup_key autoloads any keymaps. */ |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1727 |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1728 DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 4, 0, |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1729 "Return list of keys that invoke DEFINITION.\n\ |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1730 If KEYMAP is non-nil, search only KEYMAP and the global keymap.\n\ |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1731 If KEYMAP is nil, search all the currently active keymaps.\n\ |
| 250 | 1732 \n\ |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1733 If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found,\n\ |
|
5246
bec1126c6c00
(Fwhere_is_internal): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5100
diff
changeset
|
1734 rather than a list of all possible key sequences.\n\ |
|
10810
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1735 If FIRSTONLY is the symbol `non-ascii', return the first binding found,\n\ |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1736 no matter what it is.\n\ |
|
11089
3759523c1773
(Fwhere_is_internal): Fix missing \n\.
Karl Heuer <kwzh@gnu.org>
parents:
10840
diff
changeset
|
1737 If FIRSTONLY has another non-nil value, prefer sequences of ASCII characters,\n\ |
|
10810
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1738 and entirely reject menu bindings.\n\ |
| 250 | 1739 \n\ |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1740 If optional 4th arg NOINDIRECT is non-nil, don't follow indirections\n\ |
| 250 | 1741 to other keymaps or slots. This makes it possible to search for an\n\ |
| 1742 indirect definition itself.") | |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1743 (definition, keymap, firstonly, noindirect) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1744 Lisp_Object definition, keymap; |
| 250 | 1745 Lisp_Object firstonly, noindirect; |
| 1746 { | |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1747 Lisp_Object maps; |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1748 Lisp_Object found, sequence; |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1749 int keymap_specified = !NILP (keymap); |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1750 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
|
10810
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1751 /* 1 means ignore all menu bindings entirely. */ |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1752 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); |
| 250 | 1753 |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1754 if (! keymap_specified) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1755 { |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1756 #ifdef USE_TEXT_PROPERTIES |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1757 keymap = get_local_map (PT, current_buffer); |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1758 #else |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1759 keymap = current_buffer->keymap; |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1760 #endif |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1761 } |
| 250 | 1762 |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1763 if (!NILP (keymap)) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1764 maps = nconc2 (Faccessible_keymaps (get_keymap (keymap), Qnil), |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1765 Faccessible_keymaps (get_keymap (current_global_map), |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1766 Qnil)); |
| 250 | 1767 else |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1768 maps = Faccessible_keymaps (get_keymap (current_global_map), Qnil); |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1769 |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1770 /* Put the minor mode keymaps on the front. */ |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1771 if (! keymap_specified) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1772 { |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1773 Lisp_Object minors; |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1774 minors = Fnreverse (Fcurrent_minor_mode_maps ()); |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1775 while (!NILP (minors)) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1776 { |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1777 maps = nconc2 (Faccessible_keymaps (get_keymap (XCONS (minors)->car), |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1778 Qnil), |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1779 maps); |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1780 minors = XCONS (minors)->cdr; |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1781 } |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1782 } |
| 250 | 1783 |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1784 GCPRO5 (definition, keymap, maps, found, sequence); |
| 250 | 1785 found = Qnil; |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1786 sequence = Qnil; |
| 250 | 1787 |
| 485 | 1788 for (; !NILP (maps); maps = Fcdr (maps)) |
| 250 | 1789 { |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1790 /* Key sequence to reach map, and the map that it reaches */ |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1791 register Lisp_Object this, map; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1792 |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1793 /* If Fcar (map) is a VECTOR, the current element within that vector. */ |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1794 int i = 0; |
| 250 | 1795 |
| 1796 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into | |
| 1797 [M-CHAR] sequences, check if last character of the sequence | |
| 1798 is the meta-prefix char. */ | |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1799 Lisp_Object last; |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1800 int last_is_meta; |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1801 |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1802 this = Fcar (Fcar (maps)); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1803 map = Fcdr (Fcar (maps)); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1804 last = make_number (XINT (Flength (this)) - 1); |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1805 last_is_meta = (XINT (last) >= 0 |
|
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1806 && EQ (Faref (this, last), meta_prefix_char)); |
| 250 | 1807 |
|
1236
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1808 QUIT; |
|
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1809 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1810 while (CONSP (map)) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1811 { |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1812 /* Because the code we want to run on each binding is rather |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1813 large, we don't want to have two separate loop bodies for |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1814 sparse keymap bindings and tables; we want to iterate one |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1815 loop body over both keymap and vector bindings. |
| 250 | 1816 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1817 For this reason, if Fcar (map) is a vector, we don't |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1818 advance map to the next element until i indicates that we |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1819 have finished off the vector. */ |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1820 |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1821 Lisp_Object elt, key, binding; |
|
6502
18dfda644bc0
(access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents:
6475
diff
changeset
|
1822 elt = XCONS (map)->car; |
| 250 | 1823 |
|
1236
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1824 QUIT; |
|
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1825 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1826 /* Set key and binding to the current key and binding, and |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1827 advance map and i to the next binding. */ |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1828 if (VECTORP (elt)) |
| 250 | 1829 { |
| 1830 /* In a vector, look at each element. */ | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1831 binding = XVECTOR (elt)->contents[i]; |
|
9312
dfaf1d41e53d
(synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents:
9273
diff
changeset
|
1832 XSETFASTINT (key, i); |
| 250 | 1833 i++; |
| 1834 | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1835 /* If we've just finished scanning a vector, advance map |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1836 to the next element, and reset i in anticipation of the |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1837 next vector we may find. */ |
|
2752
93eda5bbc4df
(Faccessible_keymaps): Use whatever size the vector has.
Richard M. Stallman <rms@gnu.org>
parents:
2727
diff
changeset
|
1838 if (i >= XVECTOR (elt)->size) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1839 { |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1840 map = XCONS (map)->cdr; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1841 i = 0; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1842 } |
| 250 | 1843 } |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1844 else if (CONSP (elt)) |
| 250 | 1845 { |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1846 key = Fcar (Fcar (map)); |
| 250 | 1847 binding = Fcdr (Fcar (map)); |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1848 |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1849 map = XCONS (map)->cdr; |
| 250 | 1850 } |
| 1851 else | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1852 /* We want to ignore keymap elements that are neither |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
1853 vectors nor conses. */ |
|
1236
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1854 { |
|
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1855 map = XCONS (map)->cdr; |
|
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1856 continue; |
|
5e8c234e5f03
* keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents:
1209
diff
changeset
|
1857 } |
| 250 | 1858 |
| 1859 /* Search through indirections unless that's not wanted. */ | |
| 485 | 1860 if (NILP (noindirect)) |
|
10810
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1861 { |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1862 if (nomenus) |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1863 { |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1864 while (1) |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1865 { |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1866 Lisp_Object map, tem; |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1867 /* If the contents are (KEYMAP . ELEMENT), go indirect. */ |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1868 map = get_keymap_1 (Fcar_safe (definition), 0, 0); |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1869 tem = Fkeymapp (map); |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1870 if (!NILP (tem)) |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1871 definition = access_keymap (map, Fcdr (definition), 0, 0); |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1872 else |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1873 break; |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1874 } |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1875 /* If the contents are (STRING ...), reject. */ |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1876 if (CONSP (definition) |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1877 && STRINGP (XCONS (definition)->car)) |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1878 continue; |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1879 } |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1880 else |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1881 binding = get_keyelt (binding, 0); |
|
9b418bde9fcf
(Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents:
10541
diff
changeset
|
1882 } |
| 250 | 1883 |
| 1884 /* End this iteration if this element does not match | |
| 1885 the target. */ | |
| 1886 | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1887 if (CONSP (definition)) |
| 250 | 1888 { |
| 1889 Lisp_Object tem; | |
| 1890 tem = Fequal (binding, definition); | |
| 485 | 1891 if (NILP (tem)) |
| 250 | 1892 continue; |
| 1893 } | |
| 1894 else | |
| 1895 if (!EQ (binding, definition)) | |
| 1896 continue; | |
| 1897 | |
| 1898 /* We have found a match. | |
| 1899 Construct the key sequence where we found it. */ | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1900 if (INTEGERP (key) && last_is_meta) |
| 250 | 1901 { |
| 1902 sequence = Fcopy_sequence (this); | |
|
2093
ce8bad247b1a
(Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents:
2059
diff
changeset
|
1903 Faset (sequence, last, make_number (XINT (key) | meta_modifier)); |
| 250 | 1904 } |
| 1905 else | |
| 1906 sequence = append_key (this, key); | |
| 1907 | |
| 1908 /* Verify that this key binding is not shadowed by another | |
| 1909 binding for the same key, before we say it exists. | |
| 1910 | |
| 1911 Mechanism: look for local definition of this key and if | |
| 1912 it is defined and does not match what we found then | |
| 1913 ignore this key. | |
| 1914 | |
| 1915 Either nil or number as value from Flookup_key | |
| 1916 means undefined. */ | |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1917 if (keymap_specified) |
| 250 | 1918 { |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1919 binding = Flookup_key (keymap, sequence, Qnil); |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1920 if (!NILP (binding) && !INTEGERP (binding)) |
| 250 | 1921 { |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
1922 if (CONSP (definition)) |
| 250 | 1923 { |
| 1924 Lisp_Object tem; | |
| 1925 tem = Fequal (binding, definition); | |
| 485 | 1926 if (NILP (tem)) |
| 250 | 1927 continue; |
| 1928 } | |
| 1929 else | |
| 1930 if (!EQ (binding, definition)) | |
| 1931 continue; | |
| 1932 } | |
| 1933 } | |
|
5785
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1934 else |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1935 { |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1936 binding = Fkey_binding (sequence, Qnil); |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1937 if (!EQ (binding, definition)) |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1938 continue; |
|
e761c2b18894
(Fwhere_is_internal): Take just one keymap arg.
Richard M. Stallman <rms@gnu.org>
parents:
5704
diff
changeset
|
1939 } |
| 250 | 1940 |
|
6524
cedc6c52a812
(Fwhere_is_internal): Skip duplicates.
Karl Heuer <kwzh@gnu.org>
parents:
6502
diff
changeset
|
1941 /* It is a true unshadowed match. Record it, unless it's already |
|
cedc6c52a812
(Fwhere_is_internal): Skip duplicates.
Karl Heuer <kwzh@gnu.org>
parents:
6502
diff
changeset
|
1942 been seen (as could happen when inheriting keymaps). */ |
|
cedc6c52a812
(Fwhere_is_internal): Skip duplicates.
Karl Heuer <kwzh@gnu.org>
parents:
6502
diff
changeset
|
1943 if (NILP (Fmember (sequence, found))) |
|
cedc6c52a812
(Fwhere_is_internal): Skip duplicates.
Karl Heuer <kwzh@gnu.org>
parents:
6502
diff
changeset
|
1944 found = Fcons (sequence, found); |
| 250 | 1945 |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1946 /* If firstonly is Qnon_ascii, then we can return the first |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1947 binding we find. If firstonly is not Qnon_ascii but not |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1948 nil, then we should return the first ascii-only binding |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1949 we find. */ |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1950 if (EQ (firstonly, Qnon_ascii)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1951 RETURN_UNGCPRO (sequence); |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1952 else if (! NILP (firstonly) && ascii_sequence_p (sequence)) |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1953 RETURN_UNGCPRO (sequence); |
| 250 | 1954 } |
| 1955 } | |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1956 |
|
7998
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1957 UNGCPRO; |
|
d4b5f4dd9c51
(Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7894
diff
changeset
|
1958 |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1959 found = Fnreverse (found); |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1960 |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1961 /* firstonly may have been t, but we may have gone all the way through |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1962 the keymaps without finding an all-ASCII key sequence. So just |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1963 return the best we could find. */ |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1964 if (! NILP (firstonly)) |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1965 return Fcar (found); |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1966 |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
1967 return found; |
| 250 | 1968 } |
| 1969 | |
| 465 | 1970 /* describe-bindings - summarizing all the bindings in a set of keymaps. */ |
| 1971 | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1972 DEFUN ("describe-bindings", Fdescribe_bindings, Sdescribe_bindings, 0, 1, "", |
| 250 | 1973 "Show a list of all defined keys, and their definitions.\n\ |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1974 The list is put in a buffer, which is displayed.\n\ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1975 An optional argument PREFIX, if non-nil, should be a key sequence;\n\ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1976 then we display only bindings that start with that prefix.") |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1977 (prefix) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1978 Lisp_Object prefix; |
| 250 | 1979 { |
| 1980 register Lisp_Object thisbuf; | |
|
9273
129621997564
(synkey, Fdescribe_bindings, describe_command): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents:
9123
diff
changeset
|
1981 XSETBUFFER (thisbuf, current_buffer); |
| 250 | 1982 internal_with_output_to_temp_buffer ("*Help*", |
| 1983 describe_buffer_bindings, | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1984 Fcons (thisbuf, prefix)); |
| 250 | 1985 return Qnil; |
| 1986 } | |
| 1987 | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1988 /* ARG is (BUFFER . PREFIX). */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1989 |
| 250 | 1990 static Lisp_Object |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1991 describe_buffer_bindings (arg) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1992 Lisp_Object arg; |
| 250 | 1993 { |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
1994 Lisp_Object descbuf, prefix, shadow; |
|
7186
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
1995 register Lisp_Object start1; |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
1996 struct gcpro gcpro1; |
| 250 | 1997 |
|
1120
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
1998 char *alternate_heading |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
1999 = "\ |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2000 Alternate Characters (use anywhere the nominal character is listed):\n\ |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2001 nominal alternate\n\ |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2002 ------- ---------\n"; |
| 250 | 2003 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2004 descbuf = XCONS (arg)->car; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2005 prefix = XCONS (arg)->cdr; |
|
4575
bf0f07186369
(describe_buffer_bindings): Declare shadow just once.
Richard M. Stallman <rms@gnu.org>
parents:
4138
diff
changeset
|
2006 shadow = Qnil; |
|
7186
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2007 GCPRO1 (shadow); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2008 |
| 250 | 2009 Fset_buffer (Vstandard_output); |
| 2010 | |
|
1120
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2011 /* Report on alternates for keys. */ |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2012 if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix)) |
|
1120
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2013 { |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2014 int c; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2015 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2016 int translate_len = XSTRING (Vkeyboard_translate_table)->size; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2017 |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2018 for (c = 0; c < translate_len; c++) |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2019 if (translate[c] != c) |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2020 { |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2021 char buf[20]; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2022 char *bufend; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2023 |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2024 if (alternate_heading) |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2025 { |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2026 insert_string (alternate_heading); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2027 alternate_heading = 0; |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2028 } |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2029 |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2030 bufend = push_key_description (translate[c], buf); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2031 insert (buf, bufend - buf); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2032 Findent_to (make_number (16), make_number (1)); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2033 bufend = push_key_description (c, buf); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2034 insert (buf, bufend - buf); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2035 |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2036 insert ("\n", 1); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2037 } |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2038 |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2039 insert ("\n", 1); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2040 } |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2041 |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2042 if (!NILP (Vkey_translation_map)) |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2043 describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2044 "Key translations", 0, 1, 0); |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2045 |
| 465 | 2046 { |
| 2047 int i, nmaps; | |
| 2048 Lisp_Object *modes, *maps; | |
| 2049 | |
|
1120
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2050 /* Temporarily switch to descbuf, so that we can get that buffer's |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2051 minor modes correctly. */ |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2052 Fset_buffer (descbuf); |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2053 |
|
12262
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
2054 if (!NILP (current_kboard->Voverriding_terminal_local_map) |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
2055 || !NILP (Voverriding_local_map)) |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2056 nmaps = 0; |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2057 else |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2058 nmaps = current_minor_maps (&modes, &maps); |
|
1120
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2059 Fset_buffer (Vstandard_output); |
|
0a486e1a45bc
* keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents:
1095
diff
changeset
|
2060 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2061 /* Print the minor mode maps. */ |
| 465 | 2062 for (i = 0; i < nmaps; i++) |
| 2063 { | |
|
6695
c66bed2f25af
(describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents:
6524
diff
changeset
|
2064 /* The title for a minor mode keymap |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2065 is constructed at run time. |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2066 We let describe_map_tree do the actual insertion |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2067 because it takes care of other features when doing so. */ |
|
6695
c66bed2f25af
(describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents:
6524
diff
changeset
|
2068 char *title, *p; |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2069 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2070 if (!SYMBOLP (modes[i])) |
|
7186
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2071 abort(); |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2072 |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2073 p = title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size); |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2074 *p++ = '`'; |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2075 bcopy (XSYMBOL (modes[i])->name->data, p, |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2076 XSYMBOL (modes[i])->name->size); |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2077 p += XSYMBOL (modes[i])->name->size; |
|
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2078 *p++ = '\''; |
|
6695
c66bed2f25af
(describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents:
6524
diff
changeset
|
2079 bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings") - 1); |
|
c66bed2f25af
(describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents:
6524
diff
changeset
|
2080 p += sizeof (" Minor Mode Bindings") - 1; |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2081 *p = 0; |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2082 |
|
16465
398e3995162d
(describe_buffer_bindings): Pass 1 for PARTIAL
Richard M. Stallman <rms@gnu.org>
parents:
16227
diff
changeset
|
2083 describe_map_tree (maps[i], 1, shadow, prefix, title, 0, 0, 0); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2084 shadow = Fcons (maps[i], shadow); |
| 465 | 2085 } |
| 2086 } | |
| 2087 | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2088 /* Print the (major mode) local map. */ |
|
12262
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
2089 if (!NILP (current_kboard->Voverriding_terminal_local_map)) |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
2090 start1 = current_kboard->Voverriding_terminal_local_map; |
|
a7d5578ebb25
(Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents:
12151
diff
changeset
|
2091 else if (!NILP (Voverriding_local_map)) |
|
5613
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2092 start1 = Voverriding_local_map; |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2093 else |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2094 start1 = XBUFFER (descbuf)->keymap; |
|
cad51b2de6cd
(Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents:
5551
diff
changeset
|
2095 |
| 485 | 2096 if (!NILP (start1)) |
| 250 | 2097 { |
|
16465
398e3995162d
(describe_buffer_bindings): Pass 1 for PARTIAL
Richard M. Stallman <rms@gnu.org>
parents:
16227
diff
changeset
|
2098 describe_map_tree (start1, 1, shadow, prefix, |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2099 "Major Mode Bindings", 0, 0, 0); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2100 shadow = Fcons (start1, shadow); |
| 250 | 2101 } |
| 2102 | |
|
16465
398e3995162d
(describe_buffer_bindings): Pass 1 for PARTIAL
Richard M. Stallman <rms@gnu.org>
parents:
16227
diff
changeset
|
2103 describe_map_tree (current_global_map, 1, shadow, prefix, |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2104 "Global Bindings", 0, 0, 1); |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2105 |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2106 /* Print the function-key-map translations under this prefix. */ |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2107 if (!NILP (Vfunction_key_map)) |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2108 describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2109 "Function key map translations", 0, 1, 0); |
| 250 | 2110 |
|
9862
d35ed70c84d4
(describe_buffer_bindings): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9312
diff
changeset
|
2111 call0 (intern ("help-mode")); |
| 250 | 2112 Fset_buffer (descbuf); |
|
7186
092688f7ebbb
(describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents:
7184
diff
changeset
|
2113 UNGCPRO; |
| 250 | 2114 return Qnil; |
| 2115 } | |
| 2116 | |
| 13947 | 2117 /* Insert a description of the key bindings in STARTMAP, |
| 250 | 2118 followed by those of all maps reachable through STARTMAP. |
| 2119 If PARTIAL is nonzero, omit certain "uninteresting" commands | |
| 2120 (such as `undefined'). | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2121 If SHADOW is non-nil, it is a list of maps; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2122 don't mention keys which would be shadowed by any of them. |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2123 PREFIX, if non-nil, says mention only keys that start with PREFIX. |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2124 TITLE, if not 0, is a string to insert at the beginning. |
|
5551
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2125 TITLE should not end with a colon or a newline; we supply that. |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2126 If NOMENU is not 0, then omit menu-bar commands. |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2127 |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2128 If TRANSL is nonzero, the definitions are actually key translations |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2129 so print strings and vectors differently. |
|
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2130 |
|
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2131 If ALWAYS_TITLE is nonzero, print the title even if there are no maps |
|
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2132 to look through. */ |
| 250 | 2133 |
| 2134 void | |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2135 describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl, |
|
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2136 always_title) |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2137 Lisp_Object startmap, shadow, prefix; |
| 250 | 2138 int partial; |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2139 char *title; |
|
5551
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2140 int nomenu; |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2141 int transl; |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2142 int always_title; |
| 250 | 2143 { |
|
7184
caac285c072d
(describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7183
diff
changeset
|
2144 Lisp_Object maps, seen, sub_shadows; |
|
caac285c072d
(describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7183
diff
changeset
|
2145 struct gcpro gcpro1, gcpro2, gcpro3; |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2146 int something = 0; |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2147 char *key_heading |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2148 = "\ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2149 key binding\n\ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2150 --- -------\n"; |
| 250 | 2151 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2152 maps = Faccessible_keymaps (startmap, prefix); |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2153 seen = Qnil; |
|
7184
caac285c072d
(describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7183
diff
changeset
|
2154 sub_shadows = Qnil; |
|
caac285c072d
(describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7183
diff
changeset
|
2155 GCPRO3 (maps, seen, sub_shadows); |
| 250 | 2156 |
|
5551
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2157 if (nomenu) |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2158 { |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2159 Lisp_Object list; |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2160 |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2161 /* Delete from MAPS each element that is for the menu bar. */ |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2162 for (list = maps; !NILP (list); list = XCONS (list)->cdr) |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2163 { |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2164 Lisp_Object elt, prefix, tem; |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2165 |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2166 elt = Fcar (list); |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2167 prefix = Fcar (elt); |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2168 if (XVECTOR (prefix)->size >= 1) |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2169 { |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2170 tem = Faref (prefix, make_number (0)); |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2171 if (EQ (tem, Qmenu_bar)) |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2172 maps = Fdelq (elt, maps); |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2173 } |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2174 } |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2175 } |
|
2b8f405f5103
(describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents:
5367
diff
changeset
|
2176 |
|
13245
2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
13201
diff
changeset
|
2177 if (!NILP (maps) || always_title) |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2178 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2179 if (title) |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2180 { |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2181 insert_string (title); |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2182 if (!NILP (prefix)) |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2183 { |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2184 insert_string (" Starting With "); |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2185 insert1 (Fkey_description (prefix)); |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2186 } |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2187 insert_string (":\n"); |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2188 } |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2189 insert_string (key_heading); |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2190 something = 1; |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2191 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2192 |
| 485 | 2193 for (; !NILP (maps); maps = Fcdr (maps)) |
| 250 | 2194 { |
|
7184
caac285c072d
(describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7183
diff
changeset
|
2195 register Lisp_Object elt, prefix, tail; |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2196 |
| 250 | 2197 elt = Fcar (maps); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2198 prefix = Fcar (elt); |
| 250 | 2199 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2200 sub_shadows = Qnil; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2201 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2202 for (tail = shadow; CONSP (tail); tail = XCONS (tail)->cdr) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2203 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2204 Lisp_Object shmap; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2205 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2206 shmap = XCONS (tail)->car; |
| 250 | 2207 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2208 /* If the sequence by which we reach this keymap is zero-length, |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2209 then the shadow map for this keymap is just SHADOW. */ |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2210 if ((STRINGP (prefix) && XSTRING (prefix)->size == 0) |
|
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2211 || (VECTORP (prefix) && XVECTOR (prefix)->size == 0)) |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2212 ; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2213 /* If the sequence by which we reach this keymap actually has |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2214 some elements, then the sequence's definition in SHADOW is |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2215 what we should use. */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2216 else |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2217 { |
|
6859
f34b91fa388c
(describe_map_tree): Fix call to Flookup_key.
Richard M. Stallman <rms@gnu.org>
parents:
6834
diff
changeset
|
2218 shmap = Flookup_key (shmap, Fcar (elt), Qt); |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2219 if (INTEGERP (shmap)) |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2220 shmap = Qnil; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2221 } |
| 250 | 2222 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2223 /* If shmap is not nil and not a keymap, |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2224 it completely shadows this map, so don't |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2225 describe this map at all. */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2226 if (!NILP (shmap) && NILP (Fkeymapp (shmap))) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2227 goto skip; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2228 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2229 if (!NILP (shmap)) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2230 sub_shadows = Fcons (shmap, sub_shadows); |
| 250 | 2231 } |
| 2232 | |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2233 describe_map (Fcdr (elt), Fcar (elt), |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2234 transl ? describe_translation : describe_command, |
|
14129
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2235 partial, sub_shadows, &seen, nomenu); |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2236 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2237 skip: ; |
| 250 | 2238 } |
| 2239 | |
|
4023
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2240 if (something) |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2241 insert_string ("\n"); |
|
5e4f918d5d44
(describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents:
3962
diff
changeset
|
2242 |
| 250 | 2243 UNGCPRO; |
| 2244 } | |
| 2245 | |
|
14304
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2246 static int previous_description_column; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2247 |
| 250 | 2248 static void |
| 2249 describe_command (definition) | |
| 2250 Lisp_Object definition; | |
| 2251 { | |
| 2252 register Lisp_Object tem1; | |
|
14304
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2253 int column = current_column (); |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2254 int description_column; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2255 |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2256 /* If column 16 is no good, go to col 32; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2257 but don't push beyond that--go to next line instead. */ |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2258 if (column > 30) |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2259 { |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2260 insert_char ('\n'); |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2261 description_column = 32; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2262 } |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2263 else if (column > 14 || (column > 10 && previous_description_column == 32)) |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2264 description_column = 32; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2265 else |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2266 description_column = 16; |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2267 |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2268 Findent_to (make_number (description_column), make_number (1)); |
|
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2269 previous_description_column = description_column; |
| 250 | 2270 |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2271 if (SYMBOLP (definition)) |
| 250 | 2272 { |
|
9273
129621997564
(synkey, Fdescribe_bindings, describe_command): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents:
9123
diff
changeset
|
2273 XSETSTRING (tem1, XSYMBOL (definition)->name); |
| 250 | 2274 insert1 (tem1); |
| 2275 insert_string ("\n"); | |
| 2276 } | |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2277 else if (STRINGP (definition) || VECTORP (definition)) |
|
5367
e4f5f2674f34
(describe_command): If binding is a kbd macro, say so.
Richard M. Stallman <rms@gnu.org>
parents:
5246
diff
changeset
|
2278 insert_string ("Keyboard Macro\n"); |
| 250 | 2279 else |
| 2280 { | |
| 2281 tem1 = Fkeymapp (definition); | |
| 485 | 2282 if (!NILP (tem1)) |
| 250 | 2283 insert_string ("Prefix Command\n"); |
| 2284 else | |
| 2285 insert_string ("??\n"); | |
| 2286 } | |
| 2287 } | |
| 2288 | |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2289 static void |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2290 describe_translation (definition) |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2291 Lisp_Object definition; |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2292 { |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2293 register Lisp_Object tem1; |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2294 |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2295 Findent_to (make_number (16), make_number (1)); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2296 |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2297 if (SYMBOLP (definition)) |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2298 { |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2299 XSETSTRING (tem1, XSYMBOL (definition)->name); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2300 insert1 (tem1); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2301 insert_string ("\n"); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2302 } |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2303 else if (STRINGP (definition) || VECTORP (definition)) |
|
13343
cc0f24bdfab1
(describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents:
13245
diff
changeset
|
2304 { |
|
cc0f24bdfab1
(describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents:
13245
diff
changeset
|
2305 insert1 (Fkey_description (definition)); |
|
cc0f24bdfab1
(describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents:
13245
diff
changeset
|
2306 insert_string ("\n"); |
|
cc0f24bdfab1
(describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents:
13245
diff
changeset
|
2307 } |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2308 else |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2309 { |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2310 tem1 = Fkeymapp (definition); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2311 if (!NILP (tem1)) |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2312 insert_string ("Prefix Command\n"); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2313 else |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2314 insert_string ("??\n"); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2315 } |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2316 } |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2317 |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2318 /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2319 Returns the first non-nil binding found in any of those maps. */ |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2320 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2321 static Lisp_Object |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2322 shadow_lookup (shadow, key, flag) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2323 Lisp_Object shadow, key, flag; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2324 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2325 Lisp_Object tail, value; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2326 |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2327 for (tail = shadow; CONSP (tail); tail = XCONS (tail)->cdr) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2328 { |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2329 value = Flookup_key (XCONS (tail)->car, key, flag); |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2330 if (!NILP (value)) |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2331 return value; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2332 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2333 return Qnil; |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2334 } |
|
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2335 |
|
6974
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2336 /* Describe the contents of map MAP, assuming that this map itself is |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2337 reached by the sequence of prefix keys KEYS (a string or vector). |
|
14129
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2338 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ |
| 250 | 2339 |
| 2340 static void | |
|
14129
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2341 describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu) |
|
6974
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2342 register Lisp_Object map; |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2343 Lisp_Object keys; |
| 250 | 2344 int (*elt_describer) (); |
| 2345 int partial; | |
| 2346 Lisp_Object shadow; | |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2347 Lisp_Object *seen; |
|
14129
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2348 int nomenu; |
| 250 | 2349 { |
|
6974
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2350 Lisp_Object elt_prefix; |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2351 Lisp_Object tail, definition, event; |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2352 Lisp_Object tem; |
| 250 | 2353 Lisp_Object suppress; |
| 2354 Lisp_Object kludge; | |
| 2355 int first = 1; | |
| 2356 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 2357 | |
|
6974
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2358 if (!NILP (keys) && XFASTINT (Flength (keys)) > 0) |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2359 { |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2360 /* Call Fkey_description first, to avoid GC bug for the other string. */ |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2361 tem = Fkey_description (keys); |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2362 elt_prefix = concat2 (tem, build_string (" ")); |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2363 } |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2364 else |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2365 elt_prefix = Qnil; |
|
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2366 |
| 250 | 2367 if (partial) |
| 2368 suppress = intern ("suppress-keymap"); | |
| 2369 | |
| 2370 /* This vector gets used to present single keys to Flookup_key. Since | |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2371 that is done once per keymap element, we don't want to cons up a |
| 250 | 2372 fresh vector every time. */ |
| 2373 kludge = Fmake_vector (make_number (1), Qnil); | |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2374 definition = Qnil; |
| 250 | 2375 |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2376 GCPRO3 (elt_prefix, definition, kludge); |
| 250 | 2377 |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2378 for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) |
| 250 | 2379 { |
| 2380 QUIT; | |
| 2381 | |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2382 if (VECTORP (XCONS (tail)->car)) |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2383 describe_vector (XCONS (tail)->car, |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2384 elt_prefix, elt_describer, partial, shadow, map); |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2385 else if (CONSP (XCONS (tail)->car)) |
| 250 | 2386 { |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2387 event = XCONS (XCONS (tail)->car)->car; |
|
7341
516dd16e2017
(describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents:
7191
diff
changeset
|
2388 |
|
516dd16e2017
(describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents:
7191
diff
changeset
|
2389 /* Ignore bindings whose "keys" are not really valid events. |
|
516dd16e2017
(describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents:
7191
diff
changeset
|
2390 (We get these in the frames and buffers menu.) */ |
|
516dd16e2017
(describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents:
7191
diff
changeset
|
2391 if (! (SYMBOLP (event) || INTEGERP (event))) |
|
7191
bd2f9c5ee54e
(Fsingle_key_description): Undo previous change.
Karl Heuer <kwzh@gnu.org>
parents:
7186
diff
changeset
|
2392 continue; |
|
7341
516dd16e2017
(describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents:
7191
diff
changeset
|
2393 |
|
14129
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2394 if (nomenu && EQ (event, Qmenu_bar)) |
|
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2395 continue; |
|
d0b95da4f1f2
(describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents:
14099
diff
changeset
|
2396 |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2397 definition = get_keyelt (XCONS (XCONS (tail)->car)->cdr, 0); |
| 250 | 2398 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2399 /* Don't show undefined commands or suppressed commands. */ |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2400 if (NILP (definition)) continue; |
|
9123
c225137ddefb
(get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents:
8922
diff
changeset
|
2401 if (SYMBOLP (definition) && partial) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2402 { |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2403 tem = Fget (definition, suppress); |
|
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2404 if (!NILP (tem)) |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2405 continue; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2406 } |
| 250 | 2407 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2408 /* Don't show a command that isn't really visible |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2409 because a local definition of the same key shadows it. */ |
| 250 | 2410 |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2411 XVECTOR (kludge)->contents[0] = event; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2412 if (!NILP (shadow)) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2413 { |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2414 tem = shadow_lookup (shadow, kludge, Qt); |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2415 if (!NILP (tem)) continue; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2416 } |
| 250 | 2417 |
|
6974
ab22b527d380
(describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents:
6859
diff
changeset
|
2418 tem = Flookup_key (map, kludge, Qt); |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2419 if (! EQ (tem, definition)) continue; |
|
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2420 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2421 if (first) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2422 { |
|
14304
57194b6a555d
(Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2423 previous_description_column = 0; |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2424 insert ("\n", 1); |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2425 first = 0; |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2426 } |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2427 |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2428 if (!NILP (elt_prefix)) |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2429 insert1 (elt_prefix); |
| 250 | 2430 |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2431 /* THIS gets the string to describe the character EVENT. */ |
|
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2432 insert1 (Fsingle_key_description (event)); |
| 250 | 2433 |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2434 /* Print a description of the definition of this character. |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2435 elt_describer will take care of spacing out far enough |
|
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2436 for alignment purposes. */ |
|
3908
a148b4ff79c6
(describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents:
3735
diff
changeset
|
2437 (*elt_describer) (definition); |
|
1209
1aa2cd425737
* keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1160
diff
changeset
|
2438 } |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2439 else if (EQ (XCONS (tail)->car, Qkeymap)) |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2440 { |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2441 /* The same keymap might be in the structure twice, if we're |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2442 using an inherited keymap. So skip anything we've already |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2443 encountered. */ |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2444 tem = Fassq (tail, *seen); |
|
7669
93b5868150b9
(describe_map): Fix the call to Fequal.
Richard M. Stallman <rms@gnu.org>
parents:
7341
diff
changeset
|
2445 if (CONSP (tem) && !NILP (Fequal (XCONS (tem)->car, keys))) |
|
6976
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2446 break; |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2447 *seen = Fcons (Fcons (tail, keys), *seen); |
|
4d540eeb2dd5
(describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents:
6974
diff
changeset
|
2448 } |
| 250 | 2449 } |
| 2450 | |
| 2451 UNGCPRO; | |
| 2452 } | |
| 2453 | |
| 2454 static int | |
| 2455 describe_vector_princ (elt) | |
| 2456 Lisp_Object elt; | |
| 2457 { | |
|
3691
49ce2242f5c1
(get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents:
3674
diff
changeset
|
2458 Findent_to (make_number (16), make_number (1)); |
| 250 | 2459 Fprinc (elt, Qnil); |
|
3632
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2460 Fterpri (Qnil); |
| 250 | 2461 } |
| 2462 | |
| 2463 DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 1, 0, | |
|
3632
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2464 "Insert a description of contents of VECTOR.\n\ |
| 250 | 2465 This is text showing the elements of vector matched against indices.") |
| 2466 (vector) | |
| 2467 Lisp_Object vector; | |
| 2468 { | |
|
3632
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2469 int count = specpdl_ptr - specpdl; |
|
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2470 |
|
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2471 specbind (Qstandard_output, Fcurrent_buffer ()); |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2472 CHECK_VECTOR_OR_CHAR_TABLE (vector, 0); |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2473 describe_vector (vector, Qnil, describe_vector_princ, 0, Qnil, Qnil); |
|
3632
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2474 |
|
72cfde0cd8cd
(Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents:
3542
diff
changeset
|
2475 return unbind_to (count, Qnil); |
| 250 | 2476 } |
| 2477 | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2478 /* Insert in the current buffer a description of the contents of VECTOR. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2479 We call ELT_DESCRIBER to insert the description of one value found |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2480 in VECTOR. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2481 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2482 ELT_PREFIX describes what "comes before" the keys or indices defined |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2483 by this vector. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2484 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2485 If the vector is in a keymap, ELT_PREFIX is a prefix key which |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2486 leads to this keymap. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2487 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2488 If the vector is a chartable, ELT_PREFIX is the vector |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2489 of bytes that lead to the character set or portion of a character |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2490 set described by this chartable. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2491 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2492 If PARTIAL is nonzero, it means do not mention suppressed commands |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2493 (that assumes the vector is in a keymap). |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2494 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2495 SHADOW is a list of keymaps that shadow this map. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2496 If it is non-nil, then we look up the key in those maps |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2497 and we don't mention it now if it is defined by any of them. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2498 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2499 ENTIRE_MAP is the keymap in which this vector appears. |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2500 If the definition in effect in the whole map does not match |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2501 the one in this vector, we ignore this one. */ |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2502 |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2503 describe_vector (vector, elt_prefix, elt_describer, |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2504 partial, shadow, entire_map) |
| 250 | 2505 register Lisp_Object vector; |
| 2506 Lisp_Object elt_prefix; | |
| 2507 int (*elt_describer) (); | |
| 2508 int partial; | |
| 2509 Lisp_Object shadow; | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2510 Lisp_Object entire_map; |
| 250 | 2511 { |
| 2512 Lisp_Object dummy; | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2513 Lisp_Object definition; |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2514 Lisp_Object tem2; |
| 250 | 2515 register int i; |
| 2516 Lisp_Object suppress; | |
| 2517 Lisp_Object kludge; | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2518 Lisp_Object chartable_kludge; |
| 250 | 2519 int first = 1; |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2520 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 17036 | 2521 /* Range of elements to be handled. */ |
| 2522 int from, to; | |
| 2523 /* The current depth of VECTOR if it is char-table. */ | |
| 2524 int this_level; | |
|
17111
60ad27660a65
(describe_vector): Do not descibe deeper char-table if
Kenichi Handa <handa@m17n.org>
parents:
17036
diff
changeset
|
2525 /* Flag to tell if we should handle multibyte characters. */ |
|
60ad27660a65
(describe_vector): Do not descibe deeper char-table if
Kenichi Handa <handa@m17n.org>
parents:
17036
diff
changeset
|
2526 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 17036 | 2527 /* Array of indices to access each level of char-table. |
| 2528 The elements are charset, code1, and code2. */ | |
| 2529 int idx[3]; | |
| 2530 /* A flag to tell if a leaf in this level of char-table is not a | |
| 2531 generic character (i.e. a complete multibyte character). */ | |
| 2532 int complete_char; | |
| 250 | 2533 |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2534 definition = Qnil; |
| 250 | 2535 |
| 2536 /* This vector gets used to present single keys to Flookup_key. Since | |
| 2537 that is done once per vector element, we don't want to cons up a | |
| 2538 fresh vector every time. */ | |
| 2539 kludge = Fmake_vector (make_number (1), Qnil); | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2540 GCPRO4 (elt_prefix, definition, kludge, chartable_kludge); |
| 250 | 2541 |
| 2542 if (partial) | |
| 2543 suppress = intern ("suppress-keymap"); | |
| 2544 | |
| 17036 | 2545 if (CHAR_TABLE_P (vector)) |
| 2546 { | |
| 2547 /* Prepare for handling a nested char-table. */ | |
| 2548 if (NILP (elt_prefix)) | |
| 2549 { | |
| 2550 /* VECTOR is the top level of char-table. */ | |
| 2551 this_level = 0; | |
| 2552 complete_char = 0; | |
| 2553 from = 0; | |
| 2554 to = CHAR_TABLE_ORDINARY_SLOTS; | |
| 2555 } | |
| 2556 else | |
| 2557 { | |
| 2558 /* VECTOR is the deeper level of char-table. */ | |
| 2559 this_level = XVECTOR (elt_prefix)->size; | |
| 2560 if (this_level >= 3) | |
| 2561 /* A char-table is not that deep. */ | |
| 2562 wrong_type_argument (Qchar_table_p, vector); | |
| 2563 | |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2564 /* For multibyte characters, the top level index for |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2565 charsets starts from 256. */ |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2566 idx[0] = XINT (XVECTOR (elt_prefix)->contents[0]) - 128; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2567 for (i = 1; i < this_level; i++) |
| 17036 | 2568 idx[i] = XINT (XVECTOR (elt_prefix)->contents[i]); |
| 2569 complete_char | |
| 2570 = (CHARSET_VALID_P (idx[0]) | |
| 2571 && ((CHARSET_DIMENSION (idx[0]) == 1 && this_level == 1) | |
| 2572 || this_level == 2)); | |
| 2573 | |
| 2574 /* Meaningful elements are from 32th to 127th. */ | |
| 2575 from = 32; | |
| 2576 to = 128; | |
| 2577 } | |
| 2578 chartable_kludge = Fmake_vector (make_number (this_level + 1), Qnil); | |
| 2579 if (this_level != 0) | |
| 2580 bcopy (XVECTOR (elt_prefix)->contents, | |
| 2581 XVECTOR (chartable_kludge)->contents, | |
| 2582 this_level * sizeof (Lisp_Object)); | |
| 2583 } | |
| 2584 else | |
| 2585 { | |
| 2586 this_level = 0; | |
| 2587 from = 0; | |
| 2588 /* This does the right thing for ordinary vectors. */ | |
| 2589 to = XFASTINT (Flength (vector)); | |
| 2590 /* Now, can this be just `XVECTOR (vector)->size'? -- K.Handa */ | |
| 2591 } | |
| 2592 | |
| 2593 for (i = from; i < to; i++) | |
| 250 | 2594 { |
| 2595 QUIT; | |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2596 |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2597 if (this_level == 0 |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2598 && i >= CHAR_TABLE_SINGLE_BYTE_SLOTS |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2599 && !CHARSET_DEFINED_P (i - 128)) |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2600 continue; |
|
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2601 |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2602 definition = get_keyelt (XVECTOR (vector)->contents[i], 0); |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2603 if (NILP (definition)) continue; |
| 250 | 2604 |
| 2605 /* Don't mention suppressed commands. */ | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2606 if (SYMBOLP (definition) && partial) |
| 250 | 2607 { |
| 17036 | 2608 Lisp_Object tem; |
| 2609 | |
| 2610 tem = Fget (definition, suppress); | |
| 2611 | |
| 2612 if (!NILP (tem)) continue; | |
| 250 | 2613 } |
| 2614 | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2615 /* If this binding is shadowed by some other map, ignore it. */ |
| 485 | 2616 if (!NILP (shadow)) |
| 250 | 2617 { |
| 2618 Lisp_Object tem; | |
| 2619 | |
| 2620 XVECTOR (kludge)->contents[0] = make_number (i); | |
|
3952
f9dfc2872fb0
(describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents:
3908
diff
changeset
|
2621 tem = shadow_lookup (shadow, kludge, Qt); |
| 250 | 2622 |
| 485 | 2623 if (!NILP (tem)) continue; |
| 250 | 2624 } |
| 2625 | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2626 /* Ignore this definition if it is shadowed by an earlier |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2627 one in the same keymap. */ |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2628 if (!NILP (entire_map)) |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2629 { |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2630 Lisp_Object tem; |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2631 |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2632 XVECTOR (kludge)->contents[0] = make_number (i); |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2633 tem = Flookup_key (entire_map, kludge, Qt); |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2634 |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2635 if (! EQ (tem, definition)) |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2636 continue; |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2637 } |
|
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2638 |
| 250 | 2639 if (first) |
| 2640 { | |
| 17036 | 2641 if (this_level == 0) |
| 2642 insert ("\n", 1); | |
| 250 | 2643 first = 0; |
| 2644 } | |
| 2645 | |
| 17036 | 2646 /* If VECTOR is a deeper char-table, show the depth by indentation. |
| 2647 THIS_LEVEL can be greater than 0 only for char-table. */ | |
| 2648 if (this_level > 0) | |
| 2649 insert (" ", this_level * 2); /* THIS_LEVEL is 1 or 2. */ | |
| 2650 | |
| 2651 /* Get a Lisp object for the character I. */ | |
| 2652 XSETFASTINT (dummy, i); | |
| 2653 | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2654 if (CHAR_TABLE_P (vector)) |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2655 { |
| 17036 | 2656 if (complete_char) |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2657 { |
| 17036 | 2658 /* Combine ELT_PREFIX with I to produce a character code, |
| 2659 then insert that character's description. */ | |
| 2660 idx[this_level] = i; | |
| 2661 insert_char (MAKE_NON_ASCII_CHAR (idx[0], idx[1], idx[2])); | |
| 2662 } | |
| 2663 else if (this_level > 0) | |
| 2664 { | |
| 2665 /* We need an octal representation. */ | |
| 2666 char work[5]; | |
| 2667 sprintf (work, "\\%03o", i & 255); | |
| 2668 insert (work, 4); | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2669 } |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2670 else |
| 17036 | 2671 insert1 (Fsingle_key_description (dummy)); |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2672 } |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2673 else |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2674 { |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2675 /* Output the prefix that applies to every entry in this map. */ |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2676 if (!NILP (elt_prefix)) |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2677 insert1 (elt_prefix); |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2678 |
| 17036 | 2679 /* Get the string to describe the character DUMMY, and print it. */ |
| 2680 insert1 (Fsingle_key_description (dummy)); | |
| 2681 } | |
| 2682 | |
| 2683 /* If we find a char-table within a char-table, | |
| 2684 scan it recursively; it defines the details for | |
| 2685 a character set or a portion of a character set. */ | |
|
17111
60ad27660a65
(describe_vector): Do not descibe deeper char-table if
Kenichi Handa <handa@m17n.org>
parents:
17036
diff
changeset
|
2686 if (multibyte && CHAR_TABLE_P (vector) && CHAR_TABLE_P (definition)) |
| 17036 | 2687 { |
| 2688 if (this_level == 0 | |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2689 && CHARSET_VALID_P (i - 128)) |
| 17036 | 2690 { |
| 2691 /* Before scanning the deeper table, print the | |
| 2692 information for this character set. */ | |
| 2693 insert_string ("\t\t<charset:"); | |
|
17189
7c008ec99e97
(describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents:
17111
diff
changeset
|
2694 tem2 = CHARSET_TABLE_INFO (i - 128, CHARSET_SHORT_NAME_IDX); |
| 17036 | 2695 insert_from_string (tem2, 0 , XSTRING (tem2)->size, 0); |
| 2696 insert (">", 1); | |
| 2697 } | |
| 2698 | |
| 2699 insert ("\n", 1); | |
| 2700 XVECTOR (chartable_kludge)->contents[this_level] = make_number (i); | |
| 2701 describe_vector (definition, chartable_kludge, elt_describer, | |
| 2702 partial, shadow, entire_map); | |
| 2703 continue; | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2704 } |
| 250 | 2705 |
| 2706 /* Find all consecutive characters that have the same definition. */ | |
| 17036 | 2707 while (i + 1 < to |
|
6774
a29237d1fdca
(get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents:
6695
diff
changeset
|
2708 && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1], 0), |
| 17036 | 2709 !NILP (tem2)) |
| 2710 && !NILP (Fequal (tem2, definition))) | |
| 250 | 2711 i++; |
| 2712 | |
| 2713 /* If we have a range of more than one character, | |
| 2714 print where the range reaches to. */ | |
| 2715 | |
| 2716 if (i != XINT (dummy)) | |
| 2717 { | |
| 2718 insert (" .. ", 4); | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2719 if (CHAR_TABLE_P (vector)) |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2720 { |
| 17036 | 2721 if (complete_char) |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2722 { |
| 17036 | 2723 idx[this_level] = i; |
| 2724 insert_char (MAKE_NON_ASCII_CHAR (idx[0], idx[1], idx[2])); | |
| 2725 } | |
| 2726 else if (this_level > 0) | |
| 2727 { | |
| 2728 char work[5]; | |
| 2729 sprintf (work, "\\%03o", i & 255); | |
| 2730 insert (work, 4); | |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2731 } |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2732 else |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2733 { |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2734 XSETFASTINT (dummy, i); |
| 17036 | 2735 insert1 (Fsingle_key_description (dummy)); |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2736 } |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2737 } |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2738 else |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2739 { |
| 17036 | 2740 if (!NILP (elt_prefix) && !CHAR_TABLE_P (vector)) |
|
13201
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2741 insert1 (elt_prefix); |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2742 |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2743 XSETFASTINT (dummy, i); |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2744 insert1 (Fsingle_key_description (dummy)); |
|
e9007fec678e
(describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents:
13145
diff
changeset
|
2745 } |
| 250 | 2746 } |
| 2747 | |
| 2748 /* Print a description of the definition of this character. | |
| 2749 elt_describer will take care of spacing out far enough | |
| 2750 for alignment purposes. */ | |
|
11973
4e0f3e3b4cc7
(describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents:
11924
diff
changeset
|
2751 (*elt_describer) (definition); |
| 250 | 2752 } |
| 2753 | |
| 17036 | 2754 /* For char-table, print `defalt' slot at last. */ |
| 2755 if (CHAR_TABLE_P (vector) && !NILP (XCHAR_TABLE (vector)->defalt)) | |
| 2756 { | |
| 2757 insert (" ", this_level * 2); | |
| 2758 insert_string ("<<default>>"); | |
| 2759 (*elt_describer) (XCHAR_TABLE (vector)->defalt); | |
| 2760 } | |
| 2761 | |
| 250 | 2762 UNGCPRO; |
| 2763 } | |
| 2764 | |
| 465 | 2765 /* Apropos - finding all symbols whose names match a regexp. */ |
| 250 | 2766 Lisp_Object apropos_predicate; |
| 2767 Lisp_Object apropos_accumulate; | |
| 2768 | |
| 2769 static void | |
| 2770 apropos_accum (symbol, string) | |
| 2771 Lisp_Object symbol, string; | |
| 2772 { | |
| 2773 register Lisp_Object tem; | |
| 2774 | |
| 2775 tem = Fstring_match (string, Fsymbol_name (symbol), Qnil); | |
| 485 | 2776 if (!NILP (tem) && !NILP (apropos_predicate)) |
| 250 | 2777 tem = call1 (apropos_predicate, symbol); |
| 485 | 2778 if (!NILP (tem)) |
| 250 | 2779 apropos_accumulate = Fcons (symbol, apropos_accumulate); |
| 2780 } | |
| 2781 | |
| 2782 DEFUN ("apropos-internal", Fapropos_internal, Sapropos_internal, 1, 2, 0, | |
| 2783 "Show all symbols whose names contain match for REGEXP.\n\ | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
2784 If optional 2nd arg PREDICATE is non-nil, (funcall PREDICATE SYMBOL) is done\n\ |
| 250 | 2785 for each symbol and a symbol is mentioned only if that returns non-nil.\n\ |
| 2786 Return list of symbols found.") | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
2787 (regexp, predicate) |
|
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
2788 Lisp_Object regexp, predicate; |
| 250 | 2789 { |
| 2790 struct gcpro gcpro1, gcpro2; | |
|
14099
6215cbb7f702
(Fapropos_internal): Fix previous change.
Karl Heuer <kwzh@gnu.org>
parents:
14080
diff
changeset
|
2791 CHECK_STRING (regexp, 0); |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
2792 apropos_predicate = predicate; |
| 250 | 2793 GCPRO2 (apropos_predicate, apropos_accumulate); |
| 2794 apropos_accumulate = Qnil; | |
|
14080
439185f0ef37
(Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents:
13947
diff
changeset
|
2795 map_obarray (Vobarray, apropos_accum, regexp); |
| 250 | 2796 apropos_accumulate = Fsort (apropos_accumulate, Qstring_lessp); |
| 2797 UNGCPRO; | |
| 2798 return apropos_accumulate; | |
| 2799 } | |
| 2800 | |
| 2801 syms_of_keymap () | |
| 2802 { | |
| 2803 Lisp_Object tem; | |
| 2804 | |
| 2805 Qkeymap = intern ("keymap"); | |
| 2806 staticpro (&Qkeymap); | |
| 2807 | |
| 2808 /* Initialize the keymaps standardly used. | |
| 2809 Each one is the value of a Lisp variable, and is also | |
| 2810 pointed to by a C variable */ | |
| 2811 | |
|
3224
6be8f63060b3
(syms_of_keymap): Create global_map 256 slots long.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
2812 global_map = Fcons (Qkeymap, |
|
3425
c513638ee7ed
(syms_of_keymap): Add missing 2nd arg to Fcons.
Richard M. Stallman <rms@gnu.org>
parents:
3224
diff
changeset
|
2813 Fcons (Fmake_vector (make_number (0400), Qnil), Qnil)); |
| 250 | 2814 Fset (intern ("global-map"), global_map); |
| 2815 | |
|
16125
2e0a45264368
(syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents:
15422
diff
changeset
|
2816 current_global_map = global_map; |
|
16227
6acf08913847
(syms_of_keymap): staticpro global_map.
Erik Naggum <erik@naggum.no>
parents:
16125
diff
changeset
|
2817 staticpro (&global_map); |
|
16125
2e0a45264368
(syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents:
15422
diff
changeset
|
2818 staticpro (¤t_global_map); |
|
2e0a45264368
(syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents:
15422
diff
changeset
|
2819 |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2820 meta_map = Fmake_keymap (Qnil); |
| 250 | 2821 Fset (intern ("esc-map"), meta_map); |
| 2822 Ffset (intern ("ESC-prefix"), meta_map); | |
| 2823 | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2824 control_x_map = Fmake_keymap (Qnil); |
| 250 | 2825 Fset (intern ("ctl-x-map"), control_x_map); |
| 2826 Ffset (intern ("Control-X-prefix"), control_x_map); | |
| 2827 | |
|
12297
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2828 DEFVAR_LISP ("define-key-rebound-commands", &Vdefine_key_rebound_commands, |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2829 "List of commands given new key bindings recently.\n\ |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2830 This is used for internal purposes during Emacs startup;\n\ |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2831 don't alter it yourself."); |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2832 Vdefine_key_rebound_commands = Qt; |
|
fe458a8ecfa2
(Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12262
diff
changeset
|
2833 |
| 250 | 2834 DEFVAR_LISP ("minibuffer-local-map", &Vminibuffer_local_map, |
| 2835 "Default keymap to use when reading from the minibuffer."); | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2836 Vminibuffer_local_map = Fmake_sparse_keymap (Qnil); |
| 250 | 2837 |
| 2838 DEFVAR_LISP ("minibuffer-local-ns-map", &Vminibuffer_local_ns_map, | |
| 2839 "Local keymap for the minibuffer when spaces are not allowed."); | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2840 Vminibuffer_local_ns_map = Fmake_sparse_keymap (Qnil); |
| 250 | 2841 |
| 2842 DEFVAR_LISP ("minibuffer-local-completion-map", &Vminibuffer_local_completion_map, | |
| 2843 "Local keymap for minibuffer input with completion."); | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2844 Vminibuffer_local_completion_map = Fmake_sparse_keymap (Qnil); |
| 250 | 2845 |
| 2846 DEFVAR_LISP ("minibuffer-local-must-match-map", &Vminibuffer_local_must_match_map, | |
| 2847 "Local keymap for minibuffer input with completion, for exact match."); | |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2848 Vminibuffer_local_must_match_map = Fmake_sparse_keymap (Qnil); |
| 250 | 2849 |
| 465 | 2850 DEFVAR_LISP ("minor-mode-map-alist", &Vminor_mode_map_alist, |
| 2851 "Alist of keymaps to use for minor modes.\n\ | |
| 2852 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read\n\ | |
| 2853 key sequences and look up bindings iff VARIABLE's value is non-nil.\n\ | |
| 2854 If two active keymaps bind the same key, the keymap appearing earlier\n\ | |
| 2855 in the list takes precedence."); | |
| 2856 Vminor_mode_map_alist = Qnil; | |
| 2857 | |
| 517 | 2858 DEFVAR_LISP ("function-key-map", &Vfunction_key_map, |
| 2859 "Keymap mapping ASCII function key sequences onto their preferred forms.\n\ | |
| 2860 This allows Emacs to recognize function keys sent from ASCII\n\ | |
| 2861 terminals at any point in a key sequence.\n\ | |
| 2862 \n\ | |
|
8731
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2863 The `read-key-sequence' function replaces any subsequence bound by\n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2864 `function-key-map' with its binding. More precisely, when the active\n\ |
| 517 | 2865 keymaps have no binding for the current key sequence but\n\ |
|
8731
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2866 `function-key-map' binds a suffix of the sequence to a vector or string,\n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2867 `read-key-sequence' replaces the matching suffix with its binding, and\n\ |
| 517 | 2868 continues with the new sequence.\n\ |
| 2869 \n\ | |
|
8731
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2870 The events that come from bindings in `function-key-map' are not\n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2871 themselves looked up in `function-key-map'.\n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2872 \n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2873 For example, suppose `function-key-map' binds `ESC O P' to [f1].\n\ |
|
7ebb77d4aff2
(syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8517
diff
changeset
|
2874 Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing\n\ |
|
4138
42faad1466fa
* keyboard.c (read_key_sequence): Accept both strings and vectors
Jim Blandy <jimb@redhat.com>
parents:
4023
diff
changeset
|
2875 `C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix\n\ |
|
42faad1466fa
* keyboard.c (read_key_sequence): Accept both strings and vectors
Jim Blandy <jimb@redhat.com>
parents:
4023
diff
changeset
|
2876 key, typing `ESC O P x' would return [f1 x]."); |
|
1095
6578f07e9eb8
(Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
647
diff
changeset
|
2877 Vfunction_key_map = Fmake_sparse_keymap (Qnil); |
| 517 | 2878 |
|
12710
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2879 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2880 "Keymap of key translations that can override keymaps.\n\ |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2881 This keymap works like `function-key-map', but comes after that,\n\ |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2882 and applies even for keys that have ordinary bindings."); |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2883 Vkey_translation_map = Qnil; |
|
26c09987d2f3
(describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents:
12542
diff
changeset
|
2884 |
| 250 | 2885 Qsingle_key_description = intern ("single-key-description"); |
| 2886 staticpro (&Qsingle_key_description); | |
| 2887 | |
| 2888 Qkey_description = intern ("key-description"); | |
| 2889 staticpro (&Qkey_description); | |
| 2890 | |
| 2891 Qkeymapp = intern ("keymapp"); | |
| 2892 staticpro (&Qkeymapp); | |
| 2893 | |
|
2727
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
2894 Qnon_ascii = intern ("non-ascii"); |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
2895 staticpro (&Qnon_ascii); |
|
b8911c8b9700
* keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents:
2652
diff
changeset
|
2896 |
| 250 | 2897 defsubr (&Skeymapp); |
|
15344
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
2898 defsubr (&Skeymap_parent); |
|
82615c826910
(Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
14738
diff
changeset
|
2899 defsubr (&Sset_keymap_parent); |
| 250 | 2900 defsubr (&Smake_keymap); |
| 2901 defsubr (&Smake_sparse_keymap); | |
| 2902 defsubr (&Scopy_keymap); | |
| 2903 defsubr (&Skey_binding); | |
| 2904 defsubr (&Slocal_key_binding); | |
| 2905 defsubr (&Sglobal_key_binding); | |
| 465 | 2906 defsubr (&Sminor_mode_key_binding); |
| 250 | 2907 defsubr (&Sdefine_key); |
| 2908 defsubr (&Slookup_key); | |
| 2909 defsubr (&Sdefine_prefix_command); | |
| 2910 defsubr (&Suse_global_map); | |
| 2911 defsubr (&Suse_local_map); | |
| 2912 defsubr (&Scurrent_local_map); | |
| 2913 defsubr (&Scurrent_global_map); | |
| 465 | 2914 defsubr (&Scurrent_minor_mode_maps); |
| 250 | 2915 defsubr (&Saccessible_keymaps); |
| 2916 defsubr (&Skey_description); | |
| 2917 defsubr (&Sdescribe_vector); | |
| 2918 defsubr (&Ssingle_key_description); | |
| 2919 defsubr (&Stext_char_description); | |
| 2920 defsubr (&Swhere_is_internal); | |
| 2921 defsubr (&Sdescribe_bindings); | |
| 2922 defsubr (&Sapropos_internal); | |
| 2923 } | |
| 2924 | |
| 2925 keys_of_keymap () | |
| 2926 { | |
| 2927 Lisp_Object tem; | |
| 2928 | |
| 2929 initial_define_key (global_map, 033, "ESC-prefix"); | |
| 2930 initial_define_key (global_map, Ctl('X'), "Control-X-prefix"); | |
| 2931 } |
